[R] complain about a[-integer(0)]

Jim Lemon jim at bitwrit.com.au
Sat Oct 11 11:57:40 CEST 2014


On Sat, 11 Oct 2014 05:25:14 PM PO SU wrote:
> Dear helpeRs,
>     let a <- 1:10
>     let b <- integer(0) first, then i will randomly write a integer
> differently in the range(1,10)  or NULL into b. for supposed 5 times. 
then
> i want to get a[-b],that means i not want the values at index b. if any
> time of  5 times generate a integer, it works fine. but when all the 5
> times generate NULL, it can't work! Because of  the  a[-integer(0)]
> =integer(0) .
>   I ask the same question once before, now i encount it again, i think
> a[-integer(0)] should return a not integer(0) ! Is any one have the 
same
> idea with me ? or give me a oppisite case that a[-integer(0)] need to 
be
> integer(0) ?
> 
Hi PO SU,
How about:

if(length(b)) a<-a[-b]

Jim



More information about the R-help mailing list