Hi everyone,
Ignore my previous post, i realised that the rows and columns i typed into the 
email were unreadable, sincere apologies for this.
A simple question, but i cannot figure this out.
I have a data-frame with 4 columns (onset, offset, outcome, mean):
df<-data.frame(onset=c(72071,142598,293729), offset=c(72503,143030,294161), 
outcome=c(1,1,1), mean=c(7244615,NaN,294080))
For each 'NaN' in the mean column, i want to replace that NaN with the 'offset' 
value in the same row. I tried:
df$mean <- replace(df$mean, is.na(df$mean), df$offset)
but i get the error message: 'number of items to replace is not a multiple of 
replacement length'. I'm assuming because this is trying to insert the whole 
'offset' column into my one NaN cell. Is this a correct interpretation of the 
error message?
Can anyone tell me how to replace any mean row NaN's with the offset value from 
that very same row?I don't want to use any pasting etc as this needs to be used 
as part of a function working over a larger data set than the one shown here.
CheersJonathan                                            
        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Reply via email to