[R] NAs are not allowed in subscripted assignments

Alain Guillet alain.guillet at uclouvain.be
Fri Apr 9 11:37:52 CEST 2010


Sorry I forgot to add that you don't need the for loop:

  new[new>5.5] <- NA
  new
[1]  5  5  5  5 NA

Alain

On 09-Apr-10 11:23, Paul Chatfield wrote:
> new<-c(rep(5,4),6)
> for (i in 1:6)
> {new[new[i]>5.5][i]<-NA}
>    

-- 
Alain Guillet
Statistician and Computer Scientist

SMCS - IMMAQ - Université catholique de Louvain
Bureau c.316
Voie du Roman Pays, 20
B-1348 Louvain-la-Neuve
Belgium

tel: +32 10 47 30 50



More information about the R-help mailing list