kaneplusplus / bigmemory

126 stars 24 forks source link

Failed to assign a string to big.matrix #117

Closed Sherry520 closed 3 days ago

Sherry520 commented 3 days ago

Why can't I assign a value?

out <- filebacked.big.matrix(
      nrow = len.r,
      ncol = count,
      type = 'char', 
      backingfile = "combn.bin", 
      backingpath = dirname("combn"), 
      descriptorfile = "combn.des",
      dimnames = c(NULL, NULL)
    )
out[,1] <- c("S1_6986754","S1_15089837")

Warning messages:
1: In na.omit(as.integer(value)) : NAs introduced by coercion
2: In na.omit(as.integer(value)) : NAs introduced by coercion
3: In SetMatrixCols(x@address, as.double(j), as.integer(value)) :
  NAs introduced by coercion
privefl commented 3 days ago

I'm afraid that char is used to store one character, not one entire string. It's an integer value between -128 and 127, or between 0 and 255 in case you're using unsigned chars.

Basically, you can only store numbers in a big.matrix.

Sherry520 commented 3 days ago

@privefl I see. Thank you.