1

I've a matrix of CHARACTER values that I want to be DOUBLE

if get typeof(matrix[index,index]) give me in output CHARACTER

so I need as.double() to swipe it to DOUBLE

I was trying to do it with a for cycle like:

for (el in 4:269){
  for (i in 5:66){
   new_value <- paste(as.double(pollution_ds[el,i]));
   pollution_ds[el,i] <- new_value;
  }
}

So why isn't the assignment working?

Martin Gal
  • 16,640
  • 5
  • 21
  • 39
  • A matrix does have one class. So you can't change the class of an element but of the whole matrix. Try `as.double(pollution_ds)`. Btw: If you are using `paste`, take a look at `?paste`, section _Value_ (the returned value of the function `paste` is described here): _A character vector of the concatenated values._ – Martin Gal Nov 15 '21 at 18:57

0 Answers0