Re: [R] NAs are not allowed in subscripted assignments

2010-04-09 Thread Paul Chatfield
Thank you – that’s sorted it. Trying to make things too complicated! J From: Alain Guillet-2 [via R] [mailto:ml-node+1819104-1154170184-120...@n4.nabble.com] Sent: 09 April 2010 10:34 To: Paul Chatfield Subject: Re: NAs are not allowed in subscripted assignments Maybe you can withdr

Re: [R] NAs are not allowed in subscripted assignments

2010-04-09 Thread Eik Vettorazzi
Hi Paul, what's wrong with new[new>5.5]<-NA ? Btw. your variable new has a length of 5 not 6. hth. Am 09.04.2010 11:23, schrieb Paul Chatfield: > > 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 lo

Re: [R] NAs are not allowed in subscripted assignments

2010-04-09 Thread Alain Guillet
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é c

Re: [R] NAs are not allowed in subscripted assignments

2010-04-09 Thread Alain Guillet
Maybe you can withdraw the [i] in your code... > for (i in 1:6) + {new[new[i]>5.5]<-NA} > new [1] 5 5 5 5 NA Alain On 09-Apr-10 11:23, Paul Chatfield wrote: I'm trying to assign NAs to values that satisfy certain conditions (more complex than shown below) and it gives the right result, b

[R] NAs are not allowed in subscripted assignments

2010-04-09 Thread Paul Chatfield
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 appear

Re: [R] NAs are not allowed in subscripted assignments

2009-01-08 Thread Prof Brian Ripley
On Thu, 8 Jan 2009, Rune Schjellerup Philosof wrote: Browse[1]> j <- c(1,2,NA) Browse[1]> j[j==1][-1] [1] NA Browse[1]> j[j==1][-2] [1] 1 Browse[1]> j[j==1][-2] <- 2 Error during wrapup: NAs are not allowed in subscripted assignments As far as I can see, I have no NA in the lhs (not after the s

[R] NAs are not allowed in subscripted assignments

2009-01-08 Thread Rune Schjellerup Philosof
Browse[1]> j <- c(1,2,NA) Browse[1]> j[j==1][-1] [1] NA Browse[1]> j[j==1][-2] [1] 1 Browse[1]> j[j==1][-2] <- 2 Error during wrapup: NAs are not allowed in subscripted assignments As far as I can see, I have no NA in the lhs (not after the second subscript anyway). Besides, I have a single value