[R] NAs are not allowed in subscripted assignments

Paul Chatfield p.s.chatfield at reading.ac.uk
Fri Apr 9 11:23:54 CEST 2010


I'm trying to assign NAs to values that satisfy certain conditions (more
complex than shown below) and it gives the right result, but breaks the loop
having done the first one viz:

new<-c(rep(5,4),6)
for (i in 1:6)
{new[new[i]>5.5][i]<-NA}

gives the correct result, though an error message appears which causes a
break if it's in a loop.  If I can get rid of the error message and get the
loop to continue, this should work fine.  I'm sure I'm missing a simple
solution, but can't seem to see it,

Any help, as always, greatly appreciated,

Paul


-- 
View this message in context: http://n4.nabble.com/NAs-are-not-allowed-in-subscripted-assignments-tp1819094p1819094.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list