#print start { #1:3 isarray for(i in 1:3) { print(1:i) } } #print end #if start{ x<- 1 if(x==1) print(x) elseprint("not eq 1") } #if end#loop start { x <- 1repeat { print(9:x) x <- x+1 if(x==10) break} for(y in 1:1000) { if(y==10) breakprint(1:y) } y <- 0 while(y <= 100) { if(y==10) breakprint(1:y) y <- y+1} } #loop end #if end#switchstart y <- "fruit" switch(y,fruit="banana",vegetable = "broccoli","Neither") y <- "test" switch(y,fruit="banana",vegetable = "broccoli","Neither") x <- 2 switch(x,1,2,3) x <- 2 switch(x,1,mean(1:10)) x <- 3 switch(x,1,mean(1:10),rnorm(5)) x <- 4 switch(x,1,mean(1:10),rnorm(5),"Neither") print("switch with function") centre <-function(x,type) { switch(type,mean=mean(x),median=median(x),trimmend=mean(x,trim= .1)) } #随机函数 x <- rcauchy(5) print(x) centre(x,"mean") centre(x,"median") centre(x,"trimmend") #switch end
hello-R
免责声明:文章转载自《hello-R》仅用于学习参考。如对内容有疑问,请及时联系本站处理。
上篇VC6使用Crypto++库执行对称加密运算时异常报错的解决办法不难懂--------react笔记下篇
宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=