Assign values in a for loop using R changing type

Viewed 35

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?

0 Answers
Related