[R] Bind together two vectors of different length...
François Pinard
pinard at iro.umontreal.ca
Mon Jul 30 12:44:29 CEST 2007
[Andris Jankevics]
>I have two vectors:
>A <- c(1:10)
>B<- seq(1,10,2)
>Now I want to make a table form vectors A and B as rows, and if a value of A
>isn't present B, then I want to put a N/A symbol in it:
>Output should look like this:
>1 2 3 4 5 6 7 8 9 10
>1 0 3 0 5 0 7 0 9 0
>How can I do this in R?
Either of:
A[!A %in% B] <- NA
A[!A %in% B] <- 0
depending on what you want your N/A symbol to be.
--
François Pinard http://pinard.progiciels-bpi.ca
More information about the R-help
mailing list