I have three columns from three different files. I want to merge these three columns in a new data frame. To do that, I did the following:
df1 <- read.csv("location of file1")
df2 <- read.csv("location of file2")
df3 <- read.csv("location of file3")
dataset <- data.frame(B1_1=integer(), B1_2=integer(), B1_3=integer(), stringsAsFactors=FALSE)
dataset$B1_1 <- df1$Rate
dataset$B1_2 <- df2$Price
dataset$B1_3 <- df3$Code
The error that I get:
Error in `$<-.data.frame`(`*tmp*`, B1_1, value = c(5L, 7L, 9L, 11L, 13L, :
replacement has 10 rows, data has 0
I checked that each of df1$Rate
, df2$Price
, and df3$Code
has data, in other words, they are not empty. Also, I also checked the data type of these columns and all of the three columns of integer type.
How can I solve it?