I have two sets of data:
town <- c("a","b","c","d","e")
point1 <- c(1,2,3,4,5)
point2 <- c(3,6,1,7,9)
point3 <- c(1,76,3,77,32)
a <- cbind(town,point1,point2,point3)
town point1 point2 point3
[1,] "a" "1" "3" "1"
[2,] "b" "2" "6" "76"
[3,] "c" "3" "1" "3"
[4,] "d" "4" "7" "77"
[5,] "e" "5" "9" "32"
town <- c("f","f")
point3 <- c(4,5)
b <- cbind(town,point3)
town point3
[1,] "f" "4"
[2,] "f" "5"
I want to combine these into one data frame so that it will look like this:
town<-c("a","b","c","d","e","f","f")
point1<-c(1,2,3,4,5,NA,NA)
point2<-c(3,6,1,7,9,NA,NA)
point3<-c(1,76,3,77,32,4,5)
c<-cbind(town,point1,point2,point3)
town point1 point2 point3
[1,] "a" "1" "3" "1"
[2,] "b" "2" "6" "76"
[3,] "c" "3" "1" "3"
[4,] "d" "4" "7" "77"
[5,] "e" "5" "9" "32"
[6,] "f" NA NA "4"
[7,] "f" NA NA "5"
I thought c <- rbind(a$town, b$town)
would work but didn't have any success.