Fatal Error - R crashes when I am assigning NA values to specific indexes of a data frame

I don't know why but recently I cannot assign NA values to specific indexes of a data frame without getting a fatal error. I didn't have this problem in the past. My code was working perfectly exactly as it is now. I didn't change a single chunk. However, when I try to run the following chunk of code:

NaN_PFT_ID <- which(is.na(values(preds_present_cut$value_1))) # NaN_PFT_ID is just a vector with positions of the NA values

preds_present_cut[NaN_PFT_ID] <- NA #here is where the fatal error always occurs

I cannot understand why I now get this fatal error since this is a very basic command. The data frame is big but it used to work anyway, so I don't think it's a RAM issue. I have tried running the code with the latest version of R and Rstudio but also with older ones and the problems persist.

Thank you in advance for your help.

Sincerely,
Anastasios

Hi, it's a bit hard to understand without sample of data and the exact error but:

  1. if preds_present_cut is a data frame then sub-setting it must be done with preds_present_cut[row, column] syntax.

  2. if you want to assign value to the feature NaN_PFT_ID then do it with preds_present_cut$NaN_PFT_ID <- operator.

if these doesn't help, please provide more details.

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.