merger <- cbind(as.character(Date),weather1$High,weather1$Low,weather1$Avg..High,weather1$Avg.Low,sale$Scanned.Movement[a])
After cbind
the data, the new DF has column names automatically V1
, V2
......
I want rename the column by
colnames(merger)[,1] <- "Date"
but failed. And when I use merger$V1
,
Error in merger$V1 : $ operator is invalid for atomic vectors
You can also name columns directly in the cbind
call, e.g.
cbind(date=c(0,1), high=c(2,3))
Output:
date high
[1,] 0 2
[2,] 1 3