[R] Beginner's query - segmentation fault

Uwe Ligges ligges at statistik.uni-dortmund.de
Tue Oct 7 14:37:26 CEST 2003


Laura Quinn wrote:

> I am dealing with a huge matrix in R (20 columns, 54000 rows) and have
> lots of missing values within the dataset which are currently displayed as
> the value "-999.00" I am trying to create a new matrix (or change the
> existing one) to display these values as "NA" so that I can then perform
> the necessary analysis on the columns within the matrix.
> 
> The matrix name is temp and the column names are t1 to t20 inclusive.
> 
> I have tried the following command:
> 
> temp$t1[temp$t1 == -999.00] <- NA
>
> and it returns a segmentation fault, can someone tell me what I am doing
> wrong?

The crash for this inappropriate usage has already been fixed for 
R-1.7.1, so you are using an outdated version, I guess.


1. If temp is a matrix, you have to use matrix indexing, not data.frame 
or list indexing, see the manuals.

Now, we have got the (still wrong) line
   temp[temp[ ,"t1"] == -999.00, "t1"] <- NA

2. Use "is.na(x) <- TRUE" instead of "x <- NA":
   is.na(temp[temp[ ,"t1"] == -999.00, "t1"]) <- TRUE


Or change all values "-999" to "NA" in the whole matrix by
   is.na(temp[temp == -999.00]) <- TRUE


Uwe Ligges


> Thanks
> Laura
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help




More information about the R-help mailing list