0

I would like to subsetting my dataset using one variable ("id"), selecting specific values based on a vector ("x"). For example, considering these data and vector x:

id <- c(31,32,33,34,35)
z<- c(1,1,2,3,4)
y <- c(8,4,12,6,15)
data <- data.frame(id,z,y)

x <- (31,34)

I would like to have the following result:

id <- c(31,34)
z <- c(1,3)
y <- c(8,6)
data <- data.frame(id,z,y)

0 Answers0