[R] Random data

Erik Iverson eiverson at NMDP.ORG
Wed Nov 25 16:09:41 CET 2009


One option, first, generate the range of "x" data that you want, then add normally distributed noise to each x, these will be your "y" data. 

n <- 20
x <- sample(20:50, n)
y <- rnorm(n, mean = x, sd = 3)
plot(y ~ x)


Erik 


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
> On Behalf Of mentor_
> Sent: Wednesday, November 25, 2009 8:43 AM
> To: r-help at r-project.org
> Subject: [R] Random data
> 
> 
> Hi,
> 
> how can I produce random data which lies around a straight line with angle
> 45 degree.
> Similar to this image: http://zoonek2.free.fr/UNIX/48_R/g134.png
> 
> Cheers
> --
> View this message in context: http://old.nabble.com/Random-data-
> tp26513822p26513822.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list