0

I am trying to add a column to a dataframe but get a weird error-message:

Error in if (m < n * p && (m == 0L || (n * p)%%m)) stop(sprintf(ngettext(m, : missing value where TRUE/FALSE needed In addition: Warning messages: 1: In n * p : NAs produced by integer overflow 2: In n * p : NAs produced by integer overflow

I am executing the line: data[ ,extra_columns] <- 0

Where 'extra_columns' is a character vector. This worked before.

Does anybody knows this problem?

Thanks!

Elke
  • 13
  • 1
  • 8
  • Please post an minimal reproducible example as advised [here](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – alan ocallaghan Feb 13 '20 at 10:55
  • I can't reproduce your error but it looks like your data is not a data.frame, it is maybe a matrix in this case. Use `str(data)` to check the structure of your data and `data <- as.data.frame(data)` if needed. If not share your data and extra_columns with `dput(data)` and `dput(extra_columns)`. – cbo Feb 13 '20 at 11:03
  • str(data) 'data.frame': 3245341 obs. of 3367 variables: str(extra_colums) chr [1:2208] I cannot share my data because it is highly sensitive data. – Elke Feb 13 '20 at 11:45
  • May this be possible because I have such big data? – Elke Feb 13 '20 at 13:01
  • I also faced this error before. Mostly it is because you are doing an operation that is exploding the number of columns in your data-frame. – mathkid Oct 07 '21 at 11:16

0 Answers0