- 博客(8)
- 收藏
- 关注
原创 Loop Functions-mapply-notes from R programming coursera
mapply is a multivariate apply of sourts which applies a function in parallel over a set of arguments.>str(mapply)function (FUN, ..., MoreArgs = NULL, SIMPLIFY = TRUE, USE.NAMES = TRUE) FUN is a fun
2015-11-14 21:32:51 184
原创 Looping Function-lapply- R programming notes from couresera
lapply: Loop over a list and evaluate a function on each element sapply:Same as lapply but try to simplify the result apply: Apply a function over the margins of an array tapply: Apply a function ov
2015-11-14 21:10:56 370
原创 next, break, repeat, return
next is used to skip an ineration of a loop for(i in 1:100) { + if(i <=20) { + ##skip the first 20 inerations + next + } + ## Do something here + }Tips: return signals that a func
2015-11-10 12:07:46 294
原创 while loop
while(count<10) { + print(count) + count<-count+1} [1] 0 [1] 1 [1] 2 [1] 3 [1] 4 [1] 5 [1] 6 [1] 7 [1] 8 [1] 9r中{回车就会多一个+号。如果习惯性打{},然后在花括号中编辑,想换行却不能换。 z<-5 wh
2015-11-10 11:50:13 266
原创 for
for( i in 1:10) print(i) [1] 1 [1] 2 [1] 3 [1] 4 [1] 5 [1] 6 [1] 7 [1] 8 [1] 9 [1] 10 for(i in 1:4) print(x[i]) [1] “a” [1] “b” [1] “c” [1] “d” for(i i
2015-11-09 22:14:02 158
原创 if
x<-3 y<- if(x>1){ 10 }else {0} y [1] 10 if(x>5){ y <- 10} else{y<-1} y [1] 1
2015-11-09 22:04:38 127
原创 complete.cases筛选NA数据
x<-c(1,2,NA,4,NA,5) y<-c(“a”, “b”, NA, “d”,NA, “f”) good<-complete.cases(x,y) good [1] TRUE TRUE FALSE TRUE FALSE [6] TRUE x[good] [1] 1 2 4 5 y[good] [1] “a” “b” “d” “f”
2015-11-09 21:57:57 876
转载 欢迎使用CSDN-markdown编辑器
欢迎使用Markdown编辑器写博客本Markdown编辑器使用StackEdit修改而来,用它写博客,将会带来全新的体验哦:Markdown和扩展Markdown简洁的语法代码块高亮图片链接和图片上传LaTex数学公式UML序列图和流程图离线写博客导入导出Markdown文件丰富的快捷键快捷键加粗 Ctrl + B 斜体 Ctrl + I 引用 Ctrl
2015-11-09 21:56:23 157
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人