[R] removing elements from a "unit" vector

baptiste auguie baptiste.auguie at gmail.com
Tue Jun 9 15:02:41 CEST 2009


Dear list,

I'm quite surprised by this,

unit(1:5,"char")[-c(1:2)]
#4char 3char # what's going on??

while I expected something like,


c(1:5)[-c(1:2)]

# 3 4 5

Note that,

unit(1:5,"char")[c(1:2)]

# 1char 2char  # fine

?unit warns about unit.c for concatenating, but also says,

It is possible to subset unit objects in the normal way (e.g., unit(1:5,"npc")[2:4])

Am I missing something obvious?

Thanks,

baptiste

sessionInfo()
R version 2.9.0 (2009-04-17) 
i386-apple-darwin8.11.1 

locale:
en_GB.UTF-8/en_US.UTF-8/C/C/en_GB.UTF-8/en_GB.UTF-8

attached base packages:
[1] datasets  stats     grid      graphics  grDevices utils     methods   base




More information about the R-help mailing list