-1

You need to combine two files data, data1 into one table (the code below)

mat <- read.table(file='data',header =TRUE)
mat1 <- read.table(file='data',header =TRUE)
x01 <- mat$R_1 
y02 <- mat$T_1 
x03 <- mat$R_2 
y04 <- mat$T_2 
x05 <- mat$R_3 
y06 <- mat$T_3 
x11 <- mat1$R_1 
y12 <- mat1$T_1 
x13 <- mat1$R_2 
y14 <- mat1$T_2 
x15 <- mat1$R_3 
y16 <- mat1$T_3
mat <- data.frame(x01,y02,x03,y04,x05,y06,x11,x12,x13,y14,x15,y16)

but I get an error:

 Error in data.frame(x01, y02, x03, y04, x05, y06, x11, y12, x13,y14,  : 
 arguments imply differing number of rows: 19, 17

How to solve this problem? Has data 20 lines, has data1 18 lines.

Zero149
  • 41
  • 8
  • 2
    Hi, you should read [this thread](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) about how to ask a reproducible question to increase your chances of getting a good answer. Having said that, by looking at your code I think you would benefit from using the command `cbind` instead of manually matching your data frames. You will need to pad the shorter data frame with suitable values though. – Michael Bird Sep 19 '17 at 15:05

1 Answers1

1

You can input NA where makes sense given your data:

If in the end, you can make

x11 <- c(mat1$R_1, NA, NA)
y12 <- c(mat1$T_1, NA, NA)
x13 <- c(mat1$R_2, NA, NA)
y14 <- c(mat1$T_2, NA, NA)
x15 <- c(mat1$R_3, NA, NA)
y16 <- c(mat1$T_3, NA, NA)
Rafael Neves
  • 467
  • 3
  • 10