[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 ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.