I have a function that takes as input a dataframe with certain columns
columns =['a', 'b',...,'z']
Now I have a dataframe DF
with only few of these columns DF_columns = ['f', 'u', 'z']
How can I create a dataframe that has all the columns with value NA if the columns are not in DF
and that coincides with DF
on the columns ['f', 'u', 'z']
Example:
d = data.frame('g'=c(1,2,3), 's' = c(4,2,3))
columns = letters[1:21]
columns
[1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s" "t"
[21] "u"
> d
g s
1 1 4
2 2 2
3 3 3
>