-1

my data frame had many outliers in each column / variable. I removed them using Boxplot / IQR cut-off for 75% / 25%. I took out each column and removed outliers from them. Therefore, each column has different number of values in it. Now I want to combine those all NEW variables which does not has any outlier in it to single data frame. I am getting this error in Data frame. How do I solve this problem? Because, I have to perform logistic regression on that NEW data frame. I tried cbind.data.frame and then similar with rbind, but that is not solving the issue.

Here is the code:

newdata <- data.frame(finalsbp, mynewT, mynewldl,mynewtypea1, mynewobesity, mynewalcohol, age, famhist)

Error in data.frame(finalsbp, mynewT, mynewldl, mynewtypea1, mynewobesity,  : 

arguments imply differing number of rows: 447, 443, 448, 458, 454, 429, 462

P.S. Length of age and famhist is same. i.e. 462

Osro_db40
  • 23
  • 9
  • 1
    I would look into using merge() on your data. Please give some code to make a minimum reproducible example, and what your expected output is. – Richard Lusch Sep 15 '17 at 22:16
  • 1
    @RichardLusch I tried this > merge(finalsbp, mynewT, mynewldl,mynewtypea1, mynewobesity, mynewalcohol, age, famhist) Error in fix.by(by.x, x) : 'by' must match numbers of columns – Osro_db40 Sep 15 '17 at 23:04
  • @RichardLuschL I have edited my question, you can check. Need help with my question. If you cannot answer, fine but do not give -1 (especially when I have made changes). – Osro_db40 Sep 16 '17 at 00:01

1 Answers1

0

Without knowing more about your data, you could try to just make each vector the same length like this as indicated in this post.

a <- seq(from = 1, to = 10)
b <- seq(15, 30)
c <- seq(2, 10)

length(a) <- n
length(b) <- n
length(c) <- n

newdata <- cbind(a, b, c)

This should solve your problem, assuming you want all the blanks to appear as NA at the end of the data frame.

Richard Lusch
  • 1,050
  • 10
  • 19