Dear R users,
I am reading data from a file where there are some missing that are
represented by -9999.00.
I am using the command below.
=====My original data ===========
PARM = TMPC;T12X;T12N;DWPC;PALT;SKNT;DRCT;P24M;CLCL
STN YYMMDD/HHMM TMPC T12X T12N DWPC PALT
SKNT
DRCT P24M CLCL
820420 110429/1200 22.50 -9999.00 22.40 22.20 -9999.00
0.00
0.00 84.00 4.00
820980 110429/1200 26.90 -9999.00 23.40 24.10 1010.20
2.91
360.00 2.00 6.00
821130 110429/1200 24.30 -9999.00 23.30 23.70 -9999.00
1.94
230.00 3.00 4.00
821410 110429/1200 24.40 -9999.00 23.70 24.20 1011.80
2.91
===========
dados<-read.table("2011042912_teste.dat",sep='',fill=TRUE,na.strings="-9999.00",skip=4)
head(dados)
V1 V2 V3 V4 V5 V6 V7 V8 group
1 820420 110429/1200 22.5 NA 22.4 22.2 NA 0.00 1
2 0 84.00 4.0 NA NA NA NA NA 1
3 820980 110429/1200 26.9 NA 23.4 24.1 1010.2 2.91 2
4 360 2.00 6.0 NA NA NA NA NA 2
5 821130 110429/1200 24.3 NA 23.3 23.7 NA 1.94 3
6 230 3.00 4.0 NA NA NA NA NA 3
=============
After some procedures a have the data as below:
> head(Alldados)
Station_NO date1 T_2M TMAX_2M TMIN_2M TD_2M PS FF_10M DD_10M
1 820420 110429/1200 22.5 NA 22.4 22.2 NA 0.00 0
2 820980 110429/1200 26.9 NA 23.4 24.1 1010.2 2.91 360
3 821130 110429/1200 24.3 NA 23.3 23.7 NA 1.94 230
4 821410 110429/1200 24.4 NA 23.7 24.2 1011.8 2.91 270
5 821450 110429/1200 28.2 NA 21.1 25.8 1008.8 0.00 0
6 821810 110429/1200 23.3 NA 22.8 22.9 1001.6 0.00 0
TOT_PRCP CLCL date2
1 84.00 NA 2011042912
2 2.00 NA 2011042912
3 3.00 NA 2011042912
4 12.00 NA 2011042912
5 6.00 NA 2011042912
6 38.00 NA 2011042912
But I need to feed my database. These missings should be represented by
NULL.
I mean, all "NA" should be replaced by "NULL" in my database.
I am trying the command below to pick up the rows and columns with NA but I
don't know how to fill the original data :
which(is.na(Alldados),arr.ind=TRUE)
But I don't know how to replace each NA with NULL. I tried using as.null but
NA is not replace at all.
I hope someone could help me.
Best Wishes,
Nilza Barros
[[alternative HTML version deleted]]
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.