x=scan(n=2) 3 4 x #view one at a time (hit enter to advance, 'quit' to stop) for(i in 1:100){ hist(rnorm(1000)); scan()} ##or par(ask=TRUE) ##turn off par(ask=F) ## returns a factor cut y=cut(1:1000, seq(0,1000,100)) table(y) y=cut(1:1000, seq(1,1000,100)) table(y) ## 1 is not bigger than 1, so ... y[1] ## is NA. x=rnorm(1000) table( cut(x,quantile(x,seq(0,1,len=10)) )) sum( is.na( cut(x,quantile(x,seq(0,1,len=10)) ))) ## has 1, so.. table( cut(x,quantile(x,seq(0,1,len=10)),include.lowest=TRUE) ) ## read help file for CUT ## to change from scientific notation ## Change dig.lab = 3 to biggest number not in scientifice notation options() options(scipen=10) 1000000*100*10001000000000000000 ## doesn't change cut ## can turn off labels in cut...but beware ## sample(3,5,replace=T) table( sample(3,5,replace=T) ) sapply(1:1000, function(i) table( sample(3,5,replace=T) ) ) ##returns list! because sometimes there isn't a 3..due to sampling. ##try factor sapply(1:1000, function(i) table( factor( sample(3,5,replace=T), levels=c(1,2,3)) ) ) ## now a matrix. ### ## beware of drops dim(x, drop=F) sample(1:5,1) sample(3:5,1) sample(3:5,1) sample(,1) sample(4:10) sample(2:7) sample(8) # -- it is not resampleing....here it is drawing 1:8. look at help file if sampling one ..."resample" op = par() par( op ) oo = options() options(oo) ## try op <- par(no.readonly=T) par(op) y=data.frame( x=letters[1:10]) y[,1] ## levels!!!! y=data.frame( I (x=letters[1:10]) ) y[,1] ## no levels!!!! ## should be an error but is not. x == "j" x == 10 ... be careful when indicing arrays...