I would like to add 3 columns below a data who exist. But the problem is that My first data got 10 column with (id,num, x, xx, xxx, xxx, xxx, .....) and the second data got only 3 column with (id,num, x)
I would like to put the second data in first data and for that I would like to create 7 new column (only NA
) to use rbind
.
For example I have data:
df1 <- data.frame(id = 1:5, num = 6:10, V1 = 11:15, V2 = 16:20)
df2 <- data.frame(id = 6:10, num = 11:15)
I wanted to get expected output:
id num V1 V2
1 1 6 11 16
2 2 7 12 17
3 3 8 13 18
4 4 9 14 19
5 5 10 15 20
6 6 11 NA NA
7 7 12 NA NA
8 8 13 NA NA
9 9 14 NA NA
10 10 15 NA NA
I tried to create a matrix with only NA
and I research on the net but I found nothing