I have two vectors.
x <- c("a","b","c")
y <- c(NA, 1, NA)
I want to combine to get the following where x is the column heading:
a b c
NA 1 NA
I have two vectors.
x <- c("a","b","c")
y <- c(NA, 1, NA)
I want to combine to get the following where x is the column heading:
a b c
NA 1 NA
You can data frame the transpose of y
and then use x
to assign the column names.
df <- data.frame(t(y))
names(df) <- x
df
a b c
1 NA 1 NA