Re: [R] ifelse + numeric

2012-11-22 Thread djbanana
Thanks, it worked without quotation marks. -- View this message in context: http://r.789695.n4.nabble.com/ifelse-numeric-tp4650390p4650482.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat

Re: [R] ifelse + numeric

2012-11-21 Thread jim holtman
Try leaving the quote marks off the NA: data[,4] <- ifelse(data[,3]<1,data[,1]/(1-data[,3]),NA) You are putting a character value with the "NA" which converts everything else to a character. If you had examined the dataframe with 'str(data)' you would probably have seen the problem. On Wed, Nov

[R] ifelse + numeric

2012-11-21 Thread djbanana
Hi, I have a data frame and I need to add another column. I am using: data[,4] <- ifelse(data[,3]<1,data[,1]/(1-data[,3]),"NA") This is returning values but are in quotation marks. The error I am getting is "non-numeric argument to binary operator" I need column four in data to be numeric. Trie