[R] wanna create all points.....

David Winsemius dwinsemius at comcast.net
Fri Oct 26 07:46:29 CEST 2012


On Oct 25, 2012, at 8:49 PM, Rlotus wrote:

> Plz help me ;(( I lost 7 hours for thinking and doing this code ;( I need to
> create points.....20 points(dots). All these dots have to be in one graph...
> when i run this code....it gives me only one dote.....

You got twenty dots. It's just that they were on twenty separate plots.

> 
> number<- (0,2,3,4,5,6,8)

That line above is not valid R code. You should have gotten an error
> 
> for (i in seq(1:20))
> {rsidpVector=rsidp(i)
> mean(rsidpVector)
> plot (length(rsidpVector), mean(rsidpVector), ylab="sample mean", xlab=
> "sample size")
> }

You should define a function before it is called. It was only because I corrected the error in the assignment to "number" and ran it again that the function was available ... for plotting twenty separate points in twenty separate plots.

 number<- c(0,2,3,4,5,6,8)
 rsidp<- function(x){
 i+0    #   that line does nothing
 {y<-sample(number,x,replace = TRUE)}
 return(y)  # that line only wastes time
 }
 plot(NA, xlim=c(1,20), ylim=range(number), ylab="sample mean", xlab=
 "sample size")
 
 for (i in seq(1:20))
 {rsidpVector=rsidp(i)
 mean(rsidpVector)  # that line does nothing
 points (length(rsidpVector), mean(rsidpVector) )
 }





> 
> rsidp<- function(x){
> i+0
> {y<-sample(number,x,replace = TRUE)}
> return(y)
> }
> 
-- 
David Winsemius, MD
Alameda, CA, USA




More information about the R-help mailing list