[R] Using NULL to my data?
Gabor Grothendieck
ggrothendieck at gmail.com
Mon May 9 18:47:11 CEST 2011
You certainly can't assign a character string into a numeric column.
There is no reason to expect that to work.
Can you provide some clarity on what the problem is in terms of a very
small self contained example explaining what you get and what you
expected to get.
Regards.
On Mon, May 9, 2011 at 12:40 PM, Nilza BARROS <nilzabarros at gmail.com> wrote:
> Dear Ruser,
>
> Thank for your help.
> I've just tried the command below and it works
> Alldados[is.na(Alldados)]<-"NULL"
>
> But I am facing other problem, since I need to format my data before feeding
> my database.
> I am using the command below:
>
> with(Alldados,sprintf("INSERT INTO OBS
> (date,T_2M,TMAX_2M,TMIN_2M,TD_2M,PS,FF_10M,DD_10M,TOT_PRCP,CLCL,Station_NO)
> VALUES (%s, %5.2f, %5.2f, %5.2f,%5.2f,%5.2f,%5.2f,%5.2f,%5.2f,%5.2f,%s)",
>
> date2,T_2M,TMAX_2M,TMIN_2M,TD_2M,PS,FF_10M,DD_10M,TOT_PRCP,CLCL,Station_NO))
>
> But it is not working anymore. Because now the same field can be numeric or
> character.
> How can I use the format command above the allow it.
>
> I really appreciate any help.
> Nilza
>
>
>
>
>
> On Mon, May 9, 2011 at 12:55 PM, David Winsemius <dwinsemius at comcast.net>wrote:
>
>>
>> On May 9, 2011, at 10:07 AM, Nilza BARROS wrote:
>>
>> 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
>>>
>>
>> snipped
>>
>>
>> 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.
>>>
>>
>> Do you mean a string that is spelled "NULL"
>>
>> If so, try:
>>
>> dfrm[is.na(dfrm)] <- "NULL"
>>
>>
>> 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.
>>>
>>
>> If you set a column of a data.frame to NULL , it will erase it.
>>
>>
>>
>>> I hope someone could help me.
>>>
>>> Best Wishes,
>>> Nilza Barros
>>>
>>>
>> David Winsemius, MD
>> West Hartford, CT
>>
>>
>
>
> --
> Abraço,
> Nilza Barros
>
> [[alternative HTML version deleted]]
>
>
> ______________________________________________
> R-help at r-project.org 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.
>
>
--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com
More information about the R-help
mailing list