Hi, Thanks for your attentio.

I have the data frame 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    NULL    22.4  22.2   NULL      0      0
2     820980 110429/1200 26.9    NULL    23.4  24.1 1010.2   2.91    360
3     821130 110429/1200 24.3    NULL    23.3  23.7   NULL   1.94    230
4     821410 110429/1200 24.4    NULL    23.7  24.2 1011.8   2.91    270
5     821450 110429/1200 28.2    NULL    21.1  25.8 1008.8      0      0
6     821810 110429/1200 23.3    NULL    22.8  22.9 1001.6      0      0
  TOT_PRCP CLCL      date2
1    84.00 NULL 2011042912
2     2.00 NULL 2011042912
3     3.00 NULL 2011042912
4    12.00 NULL 2011042912
5     6.00 NULL 2011042912
6    38.00 NULL 2011042912
====
Now each line will feed my database. So I need to format each line like
below:

===================================
 [1] "INSERT INTO OBS
(date,T_2M,TMAX_2M,TMIN_2M,TD_2M,PS,FF_10M,DD_10M,TOT_PRCP,CLCL,Station_NO)
VALUES (2011042912, 22.50,    NA, 22.40,22.20,   NA, 0.00, 0.00,36.00,
NA,820420)"
  [2] "INSERT INTO OBS
(date,T_2M,TMAX_2M,TMIN_2M,TD_2M,PS,FF_10M,DD_10M,TOT_PRCP,CLCL,Station_NO)
VALUES (2011042912, 26.90,    NA, 23.40,24.10,1010.20, 2.91,360.00,16.00,
NA,820980)"
  [3] "INSERT INTO OBS
(date,T_2M,TMAX_2M,TMIN_2M,TD_2M,PS,FF_10M,DD_10M,TOT_PRCP,CLCL,Station_NO)
VALUES (2011042912, 24.30,    NA, 23.30,23.70,   NA, 1.94,230.00,19.00,
NA,821130)"
  [4] "INSERT INTO OBS
(date,T_2M,TMAX_2M,TMIN_2M,TD_2M,PS,FF_10M,DD_10M,TOT_PRCP,CLCL,Station_NO)
VALUES (2011042912, 24.40,    NA, 23.70,24.20,1011.80, 2.91,270.00,12.00,
NA,821410)"
  [5] "INSERT INTO OBS
(date,T_2M,TMAX_2M,TMIN_2M,TD_2M,PS,FF_10M,DD_10M,TOT_PRCP,CLCL,Station_NO)
VALUES (2011042912, 28.20,    NA, 21.10,25.80,1008.80, 0.00, 0.00,31.00,
NA,821450)"
  [6] "INSERT INTO OBS
(date,T_2M,TMAX_2M,TMIN_2M,TD_2M,PS,FF_10M,DD_10M,TOT_PRCP,CLCL,Station_NO)
VALUES (2011042912, 23.30,    NA, 22.80,22.90,1001.60, 0.00, 0.00,24.00,
NA,821810)"
  [7] "INSERT INTO OBS
===============

I hope it helps.

Best Regards,
Nilza

On Mon, May 9, 2011 at 1:47 PM, Gabor Grothendieck
<ggrothendi...@gmail.com>wrote:

> 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 <nilzabar...@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 <dwinsem...@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@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<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
>



-- 
Abraço,
Nilza Barros

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to