Hi, How can I create an NA? for example, i have this program but it has errors> x=scan()1: 1 2 3 4 5 6: Read 5 items> "na"*xError in "na" * x : non-numeric argument to binary operator what should I multiply x so that I will get an NA? And I really need to multiply that with my x vector. I need this output: (na,na,na,na,na) Thank you for your time and help!=) -- View this message in context: http://n4.nabble.com/Create-NA-tp1678543p1678543.html Sent from the R help mailing list archive at Nabble.com.
Hi tj, May be the following? x <- 1:5 NA*x rep(NA, length(x)) HTH, Jorge On Mon, Mar 22, 2010 at 9:05 PM, tj <> wrote:> > Hi, > > How can I create an NA? > for example, i have this program but it has errors > > > x=scan() > 1: 1 2 3 4 5 > 6: > Read 5 items > > "na"*x > Error in "na" * x : non-numeric argument to binary operator > > > what should I multiply x so that I will get an NA? And I really need to > multiply that with my x vector. > I need this output: (na,na,na,na,na) > > Thank you for your time and help!=) > -- > View this message in context: > http://n4.nabble.com/Create-NA-tp1678543p1678543.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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]]
I think you don't need to multiply... you need to figure out where your NAs need to be and then index the vector and assign "NA" to it: x[1:5] <- "NA" On Mon, Mar 22, 2010 at 8:05 PM, tj <girlme80 at yahoo.com> wrote:> > Hi, > > How can I create an NA? > for example, i have this program but it has errors > >> x=scan() > 1: 1 2 3 4 5 > 6: > Read 5 items >> "na"*x > Error in "na" * x : non-numeric argument to binary operator > > > what should I multiply x so that I will get an NA? And I really need to > multiply that with my x vector. > I need this output: (na,na,na,na,na) > > Thank you for your time and help!=) > -- > View this message in context: http://n4.nabble.com/Create-NA-tp1678543p1678543.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. >-- Stephen Sefick Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis