Hi All, I have the matrix called 'X' with 200 rows and 12 variables. I want to create 2 new variables (V1 and V2) based on random number generator p1<-rnorm(200. mean=0, std=1) p2<-rnorm(200. mean=0, std=1) x <- cbind(x, v1=ifelse(x[,'p1'] > 0.4, 1, 0), v2=ifelse(x[,'p2'] > 0.6, 0, 1)) I found the following error message *Error: unexpected symbol in "p1<-rnorm(200. mean" Any help? * [[alternative HTML version deleted]]
Hi Ashta, On Sun, Oct 11, 2009 at 4:06 PM, Ashta <> wrote:> Hi All, > I have the matrix called 'X' with 200 rows and 12 variables. I want to > create 2 new variables (V1 and V2) based on random number generator > > p1<-rnorm(200. mean=0, std=1) > p2<-rnorm(200. mean=0, std=1) >^^^^^^^ You are using "." instead of ",". HTH, Jorge> x <- cbind(x, v1=ifelse(x[,'p1'] > 0.4, 1, 0), v2=ifelse(x[,'p2'] > 0.6, 0, > 1)) > > I found the following error message > *Error: unexpected symbol in "p1<-rnorm(200. mean" > > Any help? > > * > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@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. >[[alternative HTML version deleted]]
Ashta wrote:> Hi All, > I have the matrix called 'X' with 200 rows and 12 variables. I want to > create 2 new variables (V1 and V2) based on random number generator > > p1<-rnorm(200. mean=0, std=1) > p2<-rnorm(200. mean=0, std=1) > x <- cbind(x, v1=ifelse(x[,'p1'] > 0.4, 1, 0), v2=ifelse(x[,'p2'] > 0.6, 0, > 1)) > > I found the following error message > *Error: unexpected symbol in "p1<-rnorm(200. mean" > > Any help? >You need to increase the size of the font you're working with. It seems that your eyes can't distinguish a '.' from a ','! -Peter Ehlers> * > > [[alternative HTML version deleted]] > > ______________________________________________ > 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. > >