作者celestialgod (天)
看板Statistics
标题Re: [程式] R的画图
时间Thu Dec 31 12:52:16 2015
※ 引述《jackhzt (巴克球)》之铭言:
: [软体程式类别]:R
: [程式问题]:其实是关於一个套件,leaflet中的问题,但是其实也没有很相关
: 反而和for的放法比较相关
: [软体熟悉度]:
: 熟悉
: [问题叙述]:
: [程式范例]:
: addTiles(leaflet()) %>%
: addRectangles(
: lng1=poi2(1)[1], lat1=poi2(1)[2],
: lng2=poi2(1)[1]+0.002, lat2=poi2(1)[2]+0.002,
: fillColor = "transparent"
: )
: 其中poi2是自己做的函数 就是放经度以及纬度的一个函数
: 问题是 我想要做到
: leaflet() %>% addTiles() %>%
: addRectangles(
: lng1=poi2(1)[1], lat1=poi2(1)[2],
: lng2=(poi2(1)[1]+50/10000), lat2=(poi2(1)[2]+50/10000),
: fillColor = "transparent"
: )%>%
: addRectangles(
: lng1=poi2(2)[1], lat1=poi2(2)[2],
: lng2=(poi2(2)[1]+50/10000), lat2=(poi2(2)[2]+50/10000),
: fillColor = "transparent"
: )%>% addRectangles(
: lng1=poi2(3)[1], lat1=poi2(3)[2],
: lng2=(poi2(3)[1]+50/10000), lat2=(poi2(3)[2]+50/10000),
: fillColor = "transparent"
: )%>%addRectangles(
: lng1=poi2(4)[1], lat1=poi2(4)[2],
: lng2=(poi2(4)[1]+50/10000), lat2=(poi2(4)[2]+50/10000),
: fillColor = "transparent"
: )
: 可以让poi2(i)这函数一直自动跑吗?
: poi2(i)中的i 可以一直自动放下去 到指定的大小
: 那麽for要挂上去 是要挂哪边?
: 目前正在苦力朝50迈进 R光滑鼠滚轮滚下去就要当掉了
leaflet() %>% addTiles() %>%
{
l_ply(1:4, function(i){
addRectangles(.,
lng1=poi2(i)[1], lat1=poi2(i)[2],
lng2=(poi2(i)[1]+50/10000), lat2=(poi2(i)[2]+50/10000),
fillColor = "transparent")
})
}
红色的大括号是关键,详情见签名档magrittr
--
R资料整理套件系列文:
magrittr #1LhSWhpH (R_Language) http://tinyurl.com/1LhSWhpH
data.table #1LhW7Tvj (R_Language) http://tinyurl.com/1LhW7Tvj
dplyr(上) #1LhpJCfB (R_Language) http://tinyurl.com/1LhpJCfB
dplyr(下) #1Lhw8b-s (R_Language)
tidyr #1Liqls1R (R_Language) http://tinyurl.com/1Liqls1R
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 140.109.74.87
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Statistics/M.1451537541.A.7F9.html
※ 编辑: celestialgod (140.109.74.87), 12/31/2015 13:03:10
1F:推 jackhzt: 真的很感谢大大 12/31 13:21