出處:http://www.kdnuggets.com/2015/05/r-vs-python-meetup-report.html
library(ggplot2) df <- data.frame( date = as.Date(c("2007-04-12", "2009-10-04", "2011-05-12", "2012-08-23", "2013-11-08", "2014-10-29")), pkgs = 1:6 * 1000 ) ggplot(df, aes(x = date, y = pkgs)) + geom_point() + geom_line()
資料來源:http://www.r-bloggers.com/milestone-6000-packages-on-cran/
# 抓資料 library(DataTaipei) rs <- dataSetMetadataSearch(q = "公廁") data <- resourceAquire(getResources(rs, 1)$resourceId) # 畫圖 library(ggmap) qmap("台北火車站", zoom = 16,legend = "topleft") + geom_point(aes(x = lng, y = lat), colour = "blue", data = data)
# 抓資料 library(DataTaipei) rs <- dataSetMetadataSearch(q = "公廁") data <- resourceAquire(getResources(rs, 1)$resourceId) # 畫圖 library(ggmap) suppressMessages({ qmap("台北火車站", zoom = 16,legend = "topleft") + geom_point(aes(x = lng, y = lat), colour = "blue", data = data) })
# 抓資料 library(DataTaipei) rs <- dataSetMetadataSearch(q = "youbike") data <- resourceAquire(getResources(rs, 1)$resourceId) # 整理資料 library(dplyr) data <- dplyr::mutate(data, lat = as.numeric(lat), lng = as.numeric(lng)) # 畫圖 library(ggmap) qmap("台北火車站", zoom = 15,legend = "topleft") + geom_point(aes(x = lng, y = lat, size = bemp), colour = "blue", data = data)
# 抓資料 suppressPackageStartupMessages({ library(DataTaipei) library(dplyr) library(ggmap) }) rs <- dataSetMetadataSearch(q = "youbike") data <- resourceAquire(getResources(rs, 1)$resourceId) # 整理資料 data <- dplyr::mutate(data, lat = as.numeric(lat), lng = as.numeric(lng)) # 畫圖 suppressMessages({ qmap("台北火車站", zoom = 15,legend = "topleft") + geom_point(aes(x = lng, y = lat, size = bemp), colour = "blue", data = data) })
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.