Re: [R] [R-sig-DB] Reading data from a worksheet on the Internet

2012-02-12 Thread Nilza BARROS
Hi,

I really appreciate your help. I definitively need a reusable program since
I have been asking to  someone to extract these data from the Internet
everyday.  That's the reason why I am trying to do a program to do that
Related to the url I sent, I have just realized that although I had written
 the one related to only worksheet (PLANILHA2) when I copy it to my browse
it is showed the link with both worksheets.


I am going to read about Rcurl and XML libraries but I hope you can help me
too.

Thanks in advance
Nilza Barros


On Sun, Feb 12, 2012 at 10:42 AM, CIURANA EUGENE (R) wrote:

> **
>
> On Sat, 11 Feb 2012 22:49:07 -0200, Nilza BARROS wrote:
>
> I have to read data from a worksheet that is available on the Internet. I
> have been doing this by copying the worksheet from the browser.
> But I would like to be able to copy the data automatically using the url
> command.
>
> But when using  "url" command the result is the source code, I mean, a html
> code.
> I see that the data I need is in the source code but before thinking about
> reading the data from the html code I wonder if there is a package or
> anoher way to extract these data since reading  from the code will demand
> many work and it can be not so accurate.
>
> Below one can see the from where I am trying to export the data:
>
> dadoshttp://www.mar.mil.br/dhn/chm/meteo/prev/dados/pnboia/sc1201_arquivos/sheet002.htm","r
> ")
>
>
>
> Hi Nilza,
>
> The URL that you posted points at a document that has another document
> within it, in a frame.  These files are Excel dumps into HTML.  To view the
> actual data you need the URIs for each data set.  Those appear at the
> bottom of the listing, under sc1201_arquivos/sheet001.htm and sheet002.htm.
>  Your code must fetch these files, not the one at
> http://www.mar.mil.br/dhn/chm/meteo/prev/dados/pnboia/sc1202.htm which
> only "wraps" them.  Most of what you see on the file that you linked isn't
> HTML - it's JavaScript and style information for the data living on the two
> separate HTML documents.
>
> You can do this in R using the RCurl and XML libraries, by pulling the
> specific files for each data source.  If this is a one-time thing, I'd
> suggest just coding something simple that loads the data for each file.  If
> this is something you'll execute periodically, you'll need a bit more code
> to extract the internal data sheets (e.g. the "planhilas" at the bottom),
> then extracting the actual data.
>
> Let me know if you want this as a one-time thing, or as a reusable
> program.  If you don't know how to use RCurl and XML to parse HTML I'll be
> happy to help with that too.  I'd just like to know more about the scope of
> your question.
>
> Cheers,
>
> pr3d
>
> --
> pr3d4t0r at #R, ##java, #awk, #pytonirc.freeenode.net
>
>


-- 
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.


[R] Reading data from a worksheet on the Internet

2012-02-11 Thread Nilza BARROS
Dear R-users,

I have to read data from a worksheet that is available on the Internet. I
have been doing this by copying the worksheet from the browser.
But I would like to be able to copy the data automatically using the url
command.

But when using  "url" command the result is the source code, I mean, a html
code.
I see that the data I need is in the source code but before thinking about
reading the data from the html code I wonder if there is a package or
anoher way to extract these data since reading  from the code will demand
many work and it can be not so accurate.

Below one can see the from where I am trying to export the data:

dados<-url("
http://www.mar.mil.br/dhn/chm/meteo/prev/dados/pnboia/sc1201_arquivos/sheet002.htm","r
")
I am looking forward  any help.

Thanks in advance ,

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.


Re: [R] File to MYSQL

2011-05-16 Thread Nilza BARROS
Dear Jerome,

I am a little ashamed about myself because the solutions is very easy. I
thought I have already read help about write.table.
But in fact I would like to use the RMysql to feed my database if you know
something about I'd like to know.

Bye and Thanks.


On Mon, May 16, 2011 at 5:01 PM, Nilza BARROS  wrote:

> Hi, Jerome
>
> I was trying to use RMYSQL
>
> for (i in length(Query)) {
> rs1<-dbSendQuery(con,Query[i])
> }
>
> But although the Query have several  lines the command above just feed my
> database with the first one.
>
> > Query
>  [1] "INSERT INTO OBS
> (date,T_2M,TMAX_2M,TMIN_2M,TD_2M,PS,FF_10M,DD_10M,TOT_PRCP,CLCL,Station_NO)
> VALUES (2011051312,26,NULL,20.6,19.4,1014.8,2.91,220,0.00,6,836490);"
>  [2] "INSERT INTO OBS
> (date,T_2M,TMAX_2M,TMIN_2M,TD_2M,PS,FF_10M,DD_10M,TOT_PRCP,CLCL,Station_NO)
> VALUES (2011051312,17,NULL,15.5,15.7,912.8,9.91,180,0.00,8,836920);"
>  [3] "INSERT INTO OBS
> (date,T_2M,TMAX_2M,TMIN_2M,TD_2M,PS,FF_10M,DD_10M,TOT_PRCP,CLCL,Station_NO)
> VALUES (2011051312,21.6,NULL,18.1,19.7,1003,1.94,140,0.00,2,836950);"
>
> Thanks,
>
>
>
> On Mon, May 16, 2011 at 4:46 PM, Jerome Asselin <
> jerome.asselin.s...@gmail.com> wrote:
>
>> On Mon, 2011-05-16 at 14:55 -0300, Nilza BARROS wrote:
>> > Dear R-user,
>> >
>> > I have to feed my database using some SQL commands. I have already read
>> a
>> > data frame with the data I need but
>> > after that these data should be write in a file wtih SQL commands.
>> >
>> > 1)  My dataframe:
>> >
>> > dput(Alldados)
>> >
>> > structure(list(Station_NO = c(836490, 836920, 836950, 836980,
>> > 837380, 837460), TMAX_2M = c("NULL", "NULL", "NULL", "NULL",
>> > "NULL", "NULL"), TMIN_2M = c("20.6", "15.5", "18.1", "19.9",
>> > "17", "21.5"), TD_2M = c("19.4", "15.7", "19.7", "20.1", "17.5",
>> > "20.4"), PS = c("1014.8", "912.8", "1003", "1014.4", "967.8",
>> > "NULL"), FF_10M = c("2.91", "9.91", "1.94", "4.08", "0", "6.02"
>> > ), DD_10M = c(220, 180, 140, 180, 0, 320), date2 = c("2011051312",
>> > "2011051312", "2011051312", "2011051312", "2011051312", "2011051312"
>> > )), .Names = c("Station_NO", "TMAX_2M", "TMIN_2M", "TD_2M", "PS",
>> > "FF_10M", "DD_10M", "date2"), row.names = c(108L, 112L, 113L,
>> > 114L, 119L, 120L), class = "data.frame")
>> >
>> >
>> > 2) My script
>> >
>> > outfile<- with(as.data.frame(Alldados),sprintf("INSERT INTO OBS
>> > (date,TMAX_2M,TMIN_2M,TD_2M,PS,FF_10M,DD_10M,Station_NO) VALUES (%s, %s,
>> %s,
>> > %s,%s,%s,%s,%s)",date2,TMAX_2M,TMIN_2M,TD_2M,PS,Station_NO))
>> >
>> write.table(outfile,file=paste(dat.dir,"outfile_13mai.txt",sep=""),append=FALSE,col.names=FALSE,
>> > row.names=FALSE)
>> >
>> >
>> > 3)  The commands above works but the problem is that the
>> oufile_13mai.txt
>> > have several quotes (") . So  when I am going to feed my database using
>> the
>> > command
>> > /usr/bin/mysql -uxx -pxxx ormverif < ~/ormverif/syn/outfile_13mai.txt
>> > ERROR 1064 (42000) at line 1: You have an error in your SQL syntax;
>> check
>> > the manual that corresponds to your MySQL server version for the right
>> > syntax to use near '"INSERT INTO OBS
>> > (date,T_2M,TMAX_2M,TMIN_2M,TD_2M,PS,FF_10M,DD_10M,TOT_PRCP,CLCL' at line
>> 1
>> >
>> >
>> > "INSERT INTO OBS (date,TMAX_2M,TMIN_2M,TD_2M,PS,Station_NO) VALUES
>> > (2011051312, NULL, 20.6,19.4,1014.8,836490)"
>> > "INSERT INTO OBS (date,TMAX_2M,TMIN_2M,TD_2M,PS,Station_NO) VALUES
>> > (2011051312, NULL, 15.5,15.7,912.8,836920)"
>> >
>> >
>> > So I need a file like below:
>> >
>> >
>> > INSERT INTO OBS (date,TMAX_2M,TMIN_2M,TD_2M,PS,Station_NO) VALUES
>> > (2011051312, NULL, 20.6,19.4,1014.8,836490)
>> > INSERT INTO OBS (date,TMAX_2M,TMIN_2M,TD_2M,PS,Station_NO) VALUES
>> > (2011051312, NULL, 15.5,15.7,912.8,836920)
>>
>> Have you considered the "quote=FALSE" option in write.table?
>>
>> Another option would be to use the sqlUpdate() command from the RODBC
>> package. That would allow you to insert data into your SQL server
>> directly from R.
>>
>> HTH,
>> Jerome
>>
>>
>
>
> --
> Abraço,
> Nilza Barros
>



-- 
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.


Re: [R] File to MYSQL

2011-05-16 Thread Nilza BARROS
Hi, Jerome

I was trying to use RMYSQL

for (i in length(Query)) {
rs1<-dbSendQuery(con,Query[i])
}

But although the Query have several  lines the command above just feed my
database with the first one.

> Query
 [1] "INSERT INTO OBS
(date,T_2M,TMAX_2M,TMIN_2M,TD_2M,PS,FF_10M,DD_10M,TOT_PRCP,CLCL,Station_NO)
VALUES (2011051312,26,NULL,20.6,19.4,1014.8,2.91,220,0.00,6,836490);"
 [2] "INSERT INTO OBS
(date,T_2M,TMAX_2M,TMIN_2M,TD_2M,PS,FF_10M,DD_10M,TOT_PRCP,CLCL,Station_NO)
VALUES (2011051312,17,NULL,15.5,15.7,912.8,9.91,180,0.00,8,836920);"
 [3] "INSERT INTO OBS
(date,T_2M,TMAX_2M,TMIN_2M,TD_2M,PS,FF_10M,DD_10M,TOT_PRCP,CLCL,Station_NO)
VALUES (2011051312,21.6,NULL,18.1,19.7,1003,1.94,140,0.00,2,836950);"

Thanks,


On Mon, May 16, 2011 at 4:46 PM, Jerome Asselin <
jerome.asselin.s...@gmail.com> wrote:

> On Mon, 2011-05-16 at 14:55 -0300, Nilza BARROS wrote:
> > Dear R-user,
> >
> > I have to feed my database using some SQL commands. I have already read a
> > data frame with the data I need but
> > after that these data should be write in a file wtih SQL commands.
> >
> > 1)  My dataframe:
> >
> > dput(Alldados)
> >
> > structure(list(Station_NO = c(836490, 836920, 836950, 836980,
> > 837380, 837460), TMAX_2M = c("NULL", "NULL", "NULL", "NULL",
> > "NULL", "NULL"), TMIN_2M = c("20.6", "15.5", "18.1", "19.9",
> > "17", "21.5"), TD_2M = c("19.4", "15.7", "19.7", "20.1", "17.5",
> > "20.4"), PS = c("1014.8", "912.8", "1003", "1014.4", "967.8",
> > "NULL"), FF_10M = c("2.91", "9.91", "1.94", "4.08", "0", "6.02"
> > ), DD_10M = c(220, 180, 140, 180, 0, 320), date2 = c("2011051312",
> > "2011051312", "2011051312", "2011051312", "2011051312", "2011051312"
> > )), .Names = c("Station_NO", "TMAX_2M", "TMIN_2M", "TD_2M", "PS",
> > "FF_10M", "DD_10M", "date2"), row.names = c(108L, 112L, 113L,
> > 114L, 119L, 120L), class = "data.frame")
> >
> >
> > 2) My script
> >
> > outfile<- with(as.data.frame(Alldados),sprintf("INSERT INTO OBS
> > (date,TMAX_2M,TMIN_2M,TD_2M,PS,FF_10M,DD_10M,Station_NO) VALUES (%s, %s,
> %s,
> > %s,%s,%s,%s,%s)",date2,TMAX_2M,TMIN_2M,TD_2M,PS,Station_NO))
> >
> write.table(outfile,file=paste(dat.dir,"outfile_13mai.txt",sep=""),append=FALSE,col.names=FALSE,
> > row.names=FALSE)
> >
> >
> > 3)  The commands above works but the problem is that the oufile_13mai.txt
> > have several quotes (") . So  when I am going to feed my database using
> the
> > command
> > /usr/bin/mysql -uxx -pxxx ormverif < ~/ormverif/syn/outfile_13mai.txt
> > ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check
> > the manual that corresponds to your MySQL server version for the right
> > syntax to use near '"INSERT INTO OBS
> > (date,T_2M,TMAX_2M,TMIN_2M,TD_2M,PS,FF_10M,DD_10M,TOT_PRCP,CLCL' at line
> 1
> >
> >
> > "INSERT INTO OBS (date,TMAX_2M,TMIN_2M,TD_2M,PS,Station_NO) VALUES
> > (2011051312, NULL, 20.6,19.4,1014.8,836490)"
> > "INSERT INTO OBS (date,TMAX_2M,TMIN_2M,TD_2M,PS,Station_NO) VALUES
> > (2011051312, NULL, 15.5,15.7,912.8,836920)"
> >
> >
> > So I need a file like below:
> >
> >
> > INSERT INTO OBS (date,TMAX_2M,TMIN_2M,TD_2M,PS,Station_NO) VALUES
> > (2011051312, NULL, 20.6,19.4,1014.8,836490)
> > INSERT INTO OBS (date,TMAX_2M,TMIN_2M,TD_2M,PS,Station_NO) VALUES
> > (2011051312, NULL, 15.5,15.7,912.8,836920)
>
> Have you considered the "quote=FALSE" option in write.table?
>
> Another option would be to use the sqlUpdate() command from the RODBC
> package. That would allow you to insert data into your SQL server
> directly from R.
>
> HTH,
> Jerome
>
>


-- 
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.


[R] File to MYSQL

2011-05-16 Thread Nilza BARROS
Dear R-user,

I have to feed my database using some SQL commands. I have already read a
data frame with the data I need but
after that these data should be write in a file wtih SQL commands.

1)  My dataframe:

dput(Alldados)

structure(list(Station_NO = c(836490, 836920, 836950, 836980,
837380, 837460), TMAX_2M = c("NULL", "NULL", "NULL", "NULL",
"NULL", "NULL"), TMIN_2M = c("20.6", "15.5", "18.1", "19.9",
"17", "21.5"), TD_2M = c("19.4", "15.7", "19.7", "20.1", "17.5",
"20.4"), PS = c("1014.8", "912.8", "1003", "1014.4", "967.8",
"NULL"), FF_10M = c("2.91", "9.91", "1.94", "4.08", "0", "6.02"
), DD_10M = c(220, 180, 140, 180, 0, 320), date2 = c("2011051312",
"2011051312", "2011051312", "2011051312", "2011051312", "2011051312"
)), .Names = c("Station_NO", "TMAX_2M", "TMIN_2M", "TD_2M", "PS",
"FF_10M", "DD_10M", "date2"), row.names = c(108L, 112L, 113L,
114L, 119L, 120L), class = "data.frame")


2) My script

outfile<- with(as.data.frame(Alldados),sprintf("INSERT INTO OBS
(date,TMAX_2M,TMIN_2M,TD_2M,PS,FF_10M,DD_10M,Station_NO) VALUES (%s, %s, %s,
%s,%s,%s,%s,%s)",date2,TMAX_2M,TMIN_2M,TD_2M,PS,Station_NO))
write.table(outfile,file=paste(dat.dir,"outfile_13mai.txt",sep=""),append=FALSE,col.names=FALSE,
row.names=FALSE)


3)  The commands above works but the problem is that the oufile_13mai.txt
have several quotes (") . So  when I am going to feed my database using the
command
/usr/bin/mysql -uxx -pxxx ormverif < ~/ormverif/syn/outfile_13mai.txt
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check
the manual that corresponds to your MySQL server version for the right
syntax to use near '"INSERT INTO OBS
(date,T_2M,TMAX_2M,TMIN_2M,TD_2M,PS,FF_10M,DD_10M,TOT_PRCP,CLCL' at line 1


"INSERT INTO OBS (date,TMAX_2M,TMIN_2M,TD_2M,PS,Station_NO) VALUES
(2011051312, NULL, 20.6,19.4,1014.8,836490)"
"INSERT INTO OBS (date,TMAX_2M,TMIN_2M,TD_2M,PS,Station_NO) VALUES
(2011051312, NULL, 15.5,15.7,912.8,836920)"


So I need a file like below:


INSERT INTO OBS (date,TMAX_2M,TMIN_2M,TD_2M,PS,Station_NO) VALUES
(2011051312, NULL, 20.6,19.4,1014.8,836490)
INSERT INTO OBS (date,TMAX_2M,TMIN_2M,TD_2M,PS,Station_NO) VALUES
(2011051312, NULL, 15.5,15.7,912.8,836920)


Thanks in advance,

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.


Re: [R] Using NULL to my data?

2011-05-09 Thread Nilza BARROS
Dear Gabor,

Thanks for your help. I was trying to do what you ask me and I've found the
solution.

> with(teste,sprintf("INSERT INTO OBS (date,T_2M,TMAX_2M,TMIN_2M) VALUES
(%s, %5.2f, %5.2f, %5.2f,%s)",date2,T_2M,TMAX_2M,TMIN_2M,Station_NO))
Error in sprintf("INSERT INTO OBS (date,T_2M,TMAX_2M,TMIN_2M) VALUES (%s,
%5.2f, %5.2f, %5.2f,%s)",  :
  invalid format '%5.2f'; use format %s for character objects
>
>
> with(teste,sprintf("INSERT INTO OBS (date,T_2M,TMAX_2M,TMIN_2M) VALUES
(%s, %s, %s, %s,%s)",date2,T_2M,TMAX_2M,TMIN_2M,Station_NO))

 [1] "INSERT INTO OBS (date,T_2M,TMAX_2M,TMIN_2M) VALUES (2011042912, 22.5,
NULL, 22.4,820420)"
 [2] "INSERT INTO OBS (date,T_2M,TMAX_2M,TMIN_2M) VALUES (2011042912, 26.9,
NULL, 23.4,820980)"
 [3] "INSERT INTO OBS (date,T_2M,TMAX_2M,TMIN_2M) VALUES (2011042912, 24.3,
NULL, 23.3,821130)"
 [4] "INSERT INTO OBS (date,T_2M,TMAX_2M,TMIN_2M) VALUES (2011042912, 24.4,
NULL, 23.7,821410)"
 [5] "INSERT INTO OBS (date,T_2M,TMAX_2M,TMIN_2M) VALUES (2011042912, 28.2,
NULL, 21.1,821450)"
 [6] "INSERT INTO OBS (date,T_2M,TMAX_2M,TMIN_2M) VALUES (2011042912, 23.3,
NULL, 22.8,821810)"


On Mon, May 9, 2011 at 2:05 PM, Gabor Grothendieck
wrote:

>  On Mon, May 9, 2011 at 12:59 PM, Nilza BARROS 
> wrote:
> > 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.5NULL22.4  22.2   NULL  0  0
> > 2 820980 110429/1200 26.9NULL23.4  24.1 1010.2   2.91360
> > 3 821130 110429/1200 24.3NULL23.3  23.7   NULL   1.94230
> > 4 821410 110429/1200 24.4NULL23.7  24.2 1011.8   2.91270
> > 5 821450 110429/1200 28.2NULL21.1  25.8 1008.8  0  0
> > 6 821810 110429/1200 23.3NULL22.8  22.9 1001.6  0  0
> >   TOT_PRCP CLCL  date2
> > 184.00 NULL 2011042912
> > 2 2.00 NULL 2011042912
> > 3 3.00 NULL 2011042912
> > 412.00 NULL 2011042912
> > 5 6.00 NULL 2011042912
> > 638.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
> > =======
> >
>
> Please
>
> 1. reduce Allados to a smaller number of columns and rows.  Say 10
> rows and 3 columns such that it still exhibits the problem and then
> show the result of dput:
>
> dput(smallDF)
>
> 2. provide the R code that you would use with smallDF
>
> 3. explain what the problem is and how that differs from what you expect.
>
> --
>  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.


Re: [R] Using NULL to my data?

2011-05-09 Thread Nilza BARROS
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.5NULL22.4  22.2   NULL  0  0
2 820980 110429/1200 26.9NULL23.4  24.1 1010.2   2.91360
3 821130 110429/1200 24.3NULL23.3  23.7   NULL   1.94230
4 821410 110429/1200 24.4NULL23.7  24.2 1011.8   2.91270
5 821450 110429/1200 28.2NULL21.1  25.8 1008.8  0  0
6 821810 110429/1200 23.3NULL22.8  22.9 1001.6  0  0
  TOT_PRCP CLCL  date2
184.00 NULL 2011042912
2 2.00 NULL 2011042912
3 3.00 NULL 2011042912
412.00 NULL 2011042912
5 6.00 NULL 2011042912
638.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
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 
> 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  >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 -.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

Re: [R] Using NULL to my data?

2011-05-09 Thread Nilza BARROS
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 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 -.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
and provide commented, minimal, self-contained, reproducible code.


[R] Using NULL to my data?

2011-05-09 Thread Nilza BARROS
Dear R users,

I am reading data from a file where there are some missing that are
represented by -.00.
I am using the command below.
=My original data ===

PARM = TMPC;T12X;T12N;DWPC;PALT;SKNT;DRCT;P24M;CLCL


STNYYMMDD/HHMM  TMPC T12X T12N DWPC PALT
SKNT
DRCT P24M CLCL
 820420110429/1200 22.50 -.0022.4022.20 -.00
0.00
0.0084.00 4.00
 820980110429/1200 26.90 -.0023.4024.10  1010.20
2.91
  360.00 2.00 6.00
 821130110429/1200 24.30 -.0023.3023.70 -.00
1.94
  230.00 3.00 4.00
 821410110429/1200 24.40 -.0023.7024.20  1011.80
2.91
===

dados<-read.table("2011042912_teste.dat",sep='',fill=TRUE,na.strings="-.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
43602.00  6.0 NA   NA   NA NA   NA 2
5 821130 110429/1200 24.3 NA 23.3 23.7 NA 1.94 3
62303.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  NA22.4  22.2 NA   0.00  0
2 820980 110429/1200 26.9  NA23.4  24.1 1010.2   2.91360
3 821130 110429/1200 24.3  NA23.3  23.7 NA   1.94230
4 821410 110429/1200 24.4  NA23.7  24.2 1011.8   2.91270
5 821450 110429/1200 28.2  NA21.1  25.8 1008.8   0.00  0
6 821810 110429/1200 23.3  NA22.8  22.9 1001.6   0.00  0
  TOT_PRCP CLCL  date2
184.00   NA 2011042912
2 2.00   NA 2011042912
3 3.00   NA 2011042912
412.00   NA 2011042912
5 6.00   NA 2011042912
638.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]]

__
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.


Re: [R] R-sig-DB Digest, Vol 74, Issue 2

2010-12-18 Thread Nilza BARROS
 Hi,
Your mistake is related with   "read.table(n)". I haven`t got what you want
but I put an example below (where I used loop to read many files). Hope it
helps. Anyway, I thougth should have sent your question to

.
Bye
Nilza


=example 
nomesout <- dir(dat.dir,pattern="^[s]") #obtem no diretorio de atual todos
arquivo iniciado com a letra s

OUT <- read.table(paste(dat.dir,nomesout[1] ,sep = ""),header = FALSE, sep =
",", na.strings = c("/","///","","/","//"))

for(i in 2:length(nomesout)){

Y <- read.table(paste(dat.dir,nomesout[i] ,sep = ""),header = FALSE, sep =
",")

OUT <- rbind(OUT, Y)

}

OUT <- OUT[-1,] ## Remove linhas em branco


On Fri, Dec 17, 2010 at 9:00 AM,  wrote:

> Send R-sig-DB mailing list submissions to
>r-sig...@r-project.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>https://stat.ethz.ch/mailman/listinfo/r-sig-db
> or, via email, send a message with subject or body 'help' to
>r-sig-db-requ...@r-project.org
>
> You can reach the person managing the list at
>r-sig-db-ow...@r-project.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of R-sig-DB digest..."
>
>
> Today's Topics:
>
>   1. Help with loop (Daniel)
>
>
> --
>
> Message: 1
> Date: Thu, 16 Dec 2010 21:47:47 -0200
> From: Daniel 
> To: r-sig...@stat.math.ethz.ch
> Subject: [R-sig-DB] Help with loop
> Message-ID:
>
> Content-Type: text/plain
>
> Hello all,
> Is there a way to get each file from a website list and aggregate in a
> unique file?
> Otherwise I have to type 23 thousand web address into a long script like
> it:
>
> base1 <- read.table("site 1", sep=";", header=T,
> fileEncoding="windows-1252")
> base2 <- read.table("site 2", sep=";", header=T,
> fileEncoding="windows-1252")
>
> I need to download each .CSV file from each web address and "rbind" all
> them
> into one data frame.
> Also I need to translate each object to UTF-8. Of course many of address
> maybe be empty, so, my loop can't stops because this.
>
> I never type a loop before, so, in my first shot I get an error. Can
> somebody help me?
>
> myresult <- NULL
> n <-length(mysites)
> for (i in 1:n) {
>  bases <- read.table(n)
>  bases[i]<-read.table(mysites[[i]], sep=";", header=TRUE,
> fileEncoding="windows-1252")
> tudo <- rbind(myresult, bases)
> }
>
> Error in read.table(n) : 'file' must be a character string or connection
> --
> Daniel Marcelino
> Skype: dmsilv
> www.sites.google.com/site/politicaevoce/ <http://bit.ly/pol4vc>
>
>[[alternative HTML version deleted]]
>
>
>
> --
>
> ___
> R-sig-DB mailing list
> r-sig...@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-db
>
>
> End of R-sig-DB Digest, Vol 74, Issue 2
> ***
>



-- 
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.


Re: [R] [R-sig-DB] Rmysql - dbWritetable

2010-10-16 Thread Nilza BARROS
Dear Spencer,

Thank you for your help. I read your email  and that`s the reason why I sent
an email to r-sig-db as you suggested.
 But I have just realized that you suggested the command below too. I`ve
tried it and that`s fine. I was waiting to solve my problem to reply the
email to r-help group. That`s what I am doing now! Thank you!!

x2010 <- read.table('2010101000.txt')
dbWriteTable(con, "b20101010", x2010, overwrite = T)
xx<- dbGetQuery(con, "SELECT * FROM b20101010  ")
*> dim(xx)
[1] 338  17
*
  row_namesV1   V2 V3 V4 V5 V6 V7 V8   V9   V10  V11  V12 V13
V14
1 1 82824 2010 10 10  0  0 -63.91  -8.76  102 - 1002 1012  50
10.3
2 2  5125 2010 10 10  0  0 -46.90 -19.60 1000 -  903 1015 117
1.8
3 3  9223 2010 10 10  0  0 -54.60 -16.40  284 -  980 1012 224
2.3
4 4 8 2010 10 10  0  0 -48.10 -15.90 1000 -  890  999 290
2.6
5 5  5133 2010 10 10  0  0 -43.80 -20.60 1000 -  902 1016 120
3.8
6 6  5147 2010 10 10  0  0 -41.50 -17.90  475 -  965 1020  65
4.8
V15   V16
1 297.1 295.4
2 293.4 282.1
3 300.9 280.8
4 295.8 288.9
5 288.1 283.6
6 294.4 289.2


On Sat, Oct 16, 2010 at 12:16 AM, Spencer Graves <
spencer.gra...@structuremonitoring.com> wrote:

> Hi, Nilza:
>
>
>   Did you receive my reply to your earlier post to R-Help, which looks
> to me identical to this (
> https://stat.ethz.ch/pipermail/r-help/2010-October/256012.html)?  I'd like
> to know if you tried what I suggested there.  If you did, what were the
> results?  If not, why not?
>
>
>   PLEASE do read the posting guide "
> www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html>"
> and provide commented, minimal, self-contained, reproducible code.  Your
> example is not completely self contained.  It might help if you include
> "sessionInfo()".  In my previous reply, there are help pages documenting
> "dbWriteTable" in 10 different packages.  I've not used "dbWriteTable" very
> much, but it might help to know which of these 10 packages you are using.
>
>
>
>   I've found that following the posting guide often helps me find a
> solution to my problem.  If I still can't solve the problem, this often
> helps me pose the question in a way more likely to generate an answer that
> actually helps me solve the problem.
>
>
>   I'm sorry if this is not any more helpful than my previous reply.
>   Spencer Graves
>
>
> On 10/15/2010 7:39 PM, Nilza BARROS wrote:
>
>   Dear Rusers,
>
> I am trying to feed my database with data from a file.
>
> But since my file (2010101000.txt) there`s no headers I am facing problem
> because the
> result data.frame is not separated my columns.
>
> How could I set variables names for each columns in *dbWriteTable*? I have
> tried the command below but I don`t know how to fill the *field.type*option.
>
>
> dbWriteTable(con, "b20101010", "./2010101000.txt", overwrite = T, sep =
> "\t",row.names=c("V01", "V02", "V03", "V04", "V05", "V06"," V07","V08",
> "V09", "V10", "V11", "V12", "V13", "V14"),field.type=)
>
> ===Below what I have been used. I need to know how to set the column names
> to xx (my dataframe).
>
>
> drv=dbDriver("MySQL")
> con <- dbConnect(drv,dbname='buoy',user="xx",password="xxx")
> dbWriteTable(con, "b20101010", "./2010101000.txt", overwrite = T, sep =
>
> "\t", head = F)
> [1] TRUE
>
> *xx*<- dbGetQuery(con, "SELECT * FROM b20101010  ")
> xx
>
> *  V1
> *1 00859 2010 10 10 00 50  -41.51   6.83  -   1016  - -.0
> -.0 -.0
> 2 00859 2010 10 09 22 50  -41.51   6.81  -   1015  - -.0 -.0
> -.0
> 3 00707 2010 10 09 23 00  -34.04 -37.63  -   1025  - -.0 -.0
> -.0
> 4 5 2010 10 09 23 00  -34.69 -18.89  -   1017207 7.2   297.1
> -.0
> 5 00859 2010 10 09 23 50  -41.51   6.81  -   1015  - -.0 -.0
> -9999.0
> 6 5 2010 10 09 23 00  -34.69 -18.89  -   1017207 7.2   297.1
> -.0
> 7 00617 2010 10 09 23 20  -18.43 -23.09  -   1023  - -.0 -.0
> -.0
> 8 00707 2010 10 10 00 00  -34.03 -37.62  -   1025  - -.0 -.0
> -.0
> 9 00707 2010 10 10 01 00  -34.03 -37.62  -   1025  - -.0 -.0
> -.0
> *> length(xx)
> [1] 1
> *
>
>
> ___
> R-sig-DB mailing list -- R Special Interest groupr-sig...@stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-db
>
>
>


-- 
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.


[R] Rmysql - dbWritetable

2010-10-12 Thread Nilza BARROS
Dear Rusers,

I am trying to feed my database with data from a file.

But since my file (2010101000.txt) there`s no headers I am facing problem
because the
result data.frame is not separated my columns.

How could I set variables names for each columns in *dbWriteTable*? I have
tried the command below but I don`t know how to fill the *field.type*option.


dbWriteTable(con, "b20101010", "./2010101000.txt", overwrite = T, sep =
"\t",row.names=c("V01", "V02", "V03", "V04", "V05", "V06"," V07","V08",
"V09", "V10", "V11", "V12", "V13", "V14"),field.type=)

===Below what I have been used. I need to know how to set the column names
to xx (my dataframe).

> drv=dbDriver("MySQL")
> con <- dbConnect(drv,dbname='buoy',user="xx",password="xxx")
> dbWriteTable(con, "b20101010", "./2010101000.txt", overwrite = T, sep =
"\t", head = F)
[1] TRUE
>
> *xx*<- dbGetQuery(con, "SELECT * FROM b20101010  ")
> xx

*  V1
*1 00859 2010 10 10 00 50  -41.51   6.83  -   1016  - -.0
-.0 -.0
2 00859 2010 10 09 22 50  -41.51   6.81  -   1015  - -.0 -.0
-.0
3 00707 2010 10 09 23 00  -34.04 -37.63  -   1025  - -.0 -.0
-.0
4 5 2010 10 09 23 00  -34.69 -18.89  -   1017207 7.2   297.1
-.0
5 00859 2010 10 09 23 50  -41.51   6.81  -   1015  - -.0 -.0
-.0
6 5 2010 10 09 23 00  -34.69 -18.89  -   1017207 7.2   297.1
-.0
7 00617 2010 10 09 23 20  -18.43 -23.09  -   1023  - -.0 -.0
-.0
8 00707 2010 10 10 00 00  -34.03 -37.62  -   1025  - -.0 -.0
-.0
9 00707 2010 10 10 01 00  -34.03 -37.62  -   1025  - -.0 -.0
-.0
*> length(xx)
[1] 1
*
-- 
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.


Re: [R] Read file

2010-10-05 Thread Nilza BARROS
Dear Gabor and Jim
You both gave me amazing solutions.
I will use.
Thanks!
Nilza

On Tue, Oct 5, 2010 at 2:11 AM, Gabor Grothendieck
wrote:

> On Sat, Oct 2, 2010 at 11:31 PM, Nilza BARROS 
> wrote:
> > Dear R-users,
> >
> > I would like to know how could I read a file with different lines
> lengths.
> > I need read this file and create an output to feed my database.
> > So after reading I'll need create an output like this
> >
> > "INSERT INTO TEMP (DATA,STATION,VAR1,VAR2) VALUES (20100910,837460,
> 39,390)"
> >
>
> Read the data filling the short lines (i.e. the date and station
> lines) with NAs.  Replace the *s with spaces and compute how many
> non-NAs are in each row (cnt).  Append group which is 1 for lines
> pertaining to the 1st station, 2 for the 2nd, etc.  Then merge it all
> together in one big data frame, All, and generate a vector of SQL
> strings:
>
> DF <- read.table("d2010100100.txt", fill = TRUE)
> DF[] <- lapply(DF, function(x) as.numeric(chartr("*", " ", x)))
> cnt <- rowSums(!is.na(DF))
> DF$group <- cumsum(cnt == 4)
> Merge <- function(x, y) merge(x, y, by = "group")
> All <- Reduce(Merge, split(DF, cnt))
> with(All, sprintf("INSERT INTO TEMP (DATA,STATION,VAR1,VAR2) VALUES
> (%04d%02d%02d, %d, %d, %d)", V1.x, V2.x, V3.x, V1.y, V1, V2))
>
> The result looks like this:
>
> [1] "INSERT INTO TEMP (DATA,STATION,VAR1,VAR2) VALUES (20101001,
> 82599, 1008, -)"
> [2] "INSERT INTO TEMP (DATA,STATION,VAR1,VAR2) VALUES (20101001,
> 83649, 1011, -)"
> [3] "INSERT INTO TEMP (DATA,STATION,VAR1,VAR2) VALUES (20101001,
> 83649, 1000, 96)"
> [4] "INSERT INTO TEMP (DATA,STATION,VAR1,VAR2) VALUES (20101001,
> 83649, 925, 782)"
> [5] "INSERT INTO TEMP (DATA,STATION,VAR1,VAR2) VALUES (20101001,
> 83649, 850, 1520)"
> [6] "INSERT INTO TEMP (DATA,STATION,VAR1,VAR2) VALUES (20101001,
> 83649, 700, 3171)"
> [7] "INSERT INTO TEMP (DATA,STATION,VAR1,VAR2) VALUES (20101001,
> 83649, 500, 5890)"
> [8] "INSERT INTO TEMP (DATA,STATION,VAR1,VAR2) VALUES (20101001,
> 83649, 400, 7600)"
>
> --
> 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.


Re: [R] Read file

2010-10-04 Thread Nilza BARROS
Sorry, guys
 I couldn`t explain what I really wanted.
I have a file with many station and many information for each one.
I need identified the line where the station information start. After that
I`d like to store that data (related to the station) so as to it could be
work in separate way.

If I was using another language as Fortran , I would save the data in a
vector.
But in R I don`t know how to do this :(

David`s Questions===

*my.data<-file("d2010100100.txt",open="rt")
indata <- readLines(my.data, n=2)
i<-grep("^[837]",indata)  #station number*
**
*That would give you the line numbers for any line that had an 8 , _or_ a 3,
_or_ a 7 as its first digit. Was that your intent? My guess is that you did
not really want to use the square braces and should have been using "^837".*
*?regex  # Paragraph starting "A character class  "*
*## In fact I am trying to find out the station in the file. As the
Brazilian station start with `83` I intend to picked them up.*
**
**
*my.data2<-read.table("d2010100100.txt",fill=TRUE,nrows=2)
stn<- my.data2$V1[i]*
**
*- That would give you the first column values for the lines you earlier
selected*.
## It gave me all the station that started with `873`. I did it just because
I needed to know how many station there was in the file. But it is not
helping me to solve the problem.
Thanks in Advanced
Nilza Barros
On Sun, Oct 3, 2010 at 11:05 PM, David Winsemius wrote:

>
> On Oct 3, 2010, at 9:40 PM, Nilza BARROS wrote:
>
> Hi, Michael
>> Thank you for your help. I have already done what you said.
>> But I am still facing problems to deal with my data.
>>
>> I need to split the data according to station..
>>
>> I was able to identify where the station information start using:
>>
>> my.data<-file("d2010100100.txt",open="rt")
>> indata <- readLines(my.data, n=2)
>> i<-grep("^[837]",indata)  #station number
>>
>
> That would give you the line numbers for any line that had an 8 , _or_ a 3,
> _or_ a 7 as its first digit. Was that your intent? My guess is that you did
> not really want to use the square braces and should have been using "^837".
>
> ?regex  # Paragraph starting "A character class  "
>
>
> my.data2<-read.table("d2010100100.txt",fill=TRUE,nrows=2)
>> stn<- my.data2$V1[i]
>>
>
> That would give you the first column values for the lines you earlier
> selected.
>
>
> 
>>
>
> This does not look like what I would expect as a value for stn. Is that
> what you wanted us to think this was?
>
> --
> David.
>
>
>
> 2010 10 01 00
>> *82599  -35.25  -5.91 52   1
>> * 1008.0  -115 3.1   298.6   294.6 64
>> 2010 10 01 00
>> *83649  -40.28 -20.26  4  7*
>> 1011.0  -  0 0.0   298.4   296.1 64
>> 1000.0 96 40 5.7   297.9   295.1 32
>>  925.0782325 3.1   295.4   294.1 32
>>  850.0   1520270 4.1   293.8   289.4 32
>>  700.0   3171240 8.7   284.1   279.1 32
>>  500.0   5890275 8.2   266.2   262.9 32
>>  400.0   7600335 9.8   255.4   242.4 32
>> ===
>> As you can see in the data above the line show the number of leves (or
>> lines) for each station.
>> I need to catch these lines so as to be able to feed my database.
>> By the way, I didn't understand the regular expression you've used. I've
>> tried to run it but it did not work.
>>
>> Hope you can help me!
>> Best Regards,
>> Nilza
>>
>>
>>
>>
>>
>> On Sun, Oct 3, 2010 at 2:18 AM, Michael Bedward
>> wrote:
>>
>> Hello Nilza,
>>>
>>> If your file is small you can read it into a character vector like this:
>>>
>>> indata <- readLines("foo.dat")
>>>
>>> If your file is very big you can read it in batches like this...
>>>
>>> MAXRECS <- 1000  # for example
>>> fcon <- file("foo.dat", open="r")
>>> indata <- readLines(fcon, n=MAXRECS)
>>>
>>> The number of lines read will be given by length(indata).
>>>
>>> You can check to see if the end of the file has been read yet with:
>>> isIncomplete( fcon )
>>>
>>> If a leading "*" character is a flag for the start of a station data
>>> block you can find this in the indata vector with grepl...
>>>
>>> start.pos <- which(indata, grepl("^\\s*\\*", indata)
>>>
>>> When you're finished reading the 

Re: [R] Read file

2010-10-03 Thread Nilza BARROS
Hi, Michael
Thank you for your help. I have already done what you said.
But I am still facing problems to deal with my data.

I need to split the data according to station..

I was able to identify where the station information start using:

my.data<-file("d2010100100.txt",open="rt")
indata <- readLines(my.data, n=2)
i<-grep("^[837]",indata)  #station number
my.data2<-read.table("d2010100100.txt",fill=TRUE,nrows=2)
stn<- my.data2$V1[i]

2010 10 01 00
*82599  -35.25  -5.91 52   1
* 1008.0  -115 3.1   298.6   294.6 64
2010 10 01 00
*83649  -40.28 -20.26  4  7*
 1011.0  -  0 0.0   298.4   296.1 64
 1000.0 96 40 5.7   297.9   295.1 32
  925.0782325 3.1   295.4   294.1 32
  850.0   1520270 4.1   293.8   289.4 32
  700.0   3171240 8.7   284.1   279.1 32
  500.0   5890275 8.2   266.2   262.9 32
  400.0   7600335 9.8   255.4   242.4 32
===
As you can see in the data above the line show the number of leves (or
lines) for each station.
I need to catch these lines so as to be able to feed my database.
By the way, I didn't understand the regular expression you've used. I've
tried to run it but it did not work.

Hope you can help me!
Best Regards,
Nilza





On Sun, Oct 3, 2010 at 2:18 AM, Michael Bedward
wrote:

> Hello Nilza,
>
> If your file is small you can read it into a character vector like this:
>
> indata <- readLines("foo.dat")
>
> If your file is very big you can read it in batches like this...
>
> MAXRECS <- 1000  # for example
> fcon <- file("foo.dat", open="r")
> indata <- readLines(fcon, n=MAXRECS)
>
> The number of lines read will be given by length(indata).
>
> You can check to see if the end of the file has been read yet with:
> isIncomplete( fcon )
>
> If a leading "*" character is a flag for the start of a station data
> block you can find this in the indata vector with grepl...
>
> start.pos <- which(indata, grepl("^\\s*\\*", indata)
>
> When you're finished reading the file...
> close(fcon)
>
> Hope this helps,
>
> Michael
>
>
> On 3 October 2010 13:31, Nilza BARROS  wrote:
> > Dear R-users,
> >
> > I would like to know how could I read a file with different lines
> lengths.
> > I need read this file and create an output to feed my database.
> > So after reading I'll need create an output like this
> >
> > "INSERT INTO TEMP (DATA,STATION,VAR1,VAR2) VALUES (20100910,837460,
> 39,390)"
> >
> > I mean,  each line should be read. But I don`t how to do this when these
> > lines have different lengths
> >
> > I really appreciate any help.
> >
> > Thanks.
> >
> >
> >
> > Below the file that should be read ===
> >
> >
> > *2010 10 01 00
> > 83746  -43.25 -22.81  6  51*
> > 1012.0  -320 1.5   299.1   294.4 64
> >  1000.0114250 4.1   298.4   294.8 32
> >  925.0797  0 0.0   293.6   292.9 32
> >  850.0   1524195 3.1   289.6   288.9 32
> >  700.0   315629011.3   280.1   280.1 32
> >  500.0   587028020.1   266.1   260.1 32
> >  400.0   757026523.7   256.6   222.7 32
> >  300.0   967026528.8   240.2   218.2 32
> >  250.0  1092028027.3   230.2   220.2 32
> >  200.0  1239026032.4   218.7   206.7 32
> >  176.0  -25537.6 -.0 -.0  8
> >  150.0  1418024535.5   205.1   196.1 32
> >  100.0  1656030017.0   195.2   186.2 32
> > *2010 10 01 00
> > 83768  -51.13 -23.33569  41
> > * 1000.0 79  - -.0 -.0 -.0 32
> >  946.0  -270 1.0   295.8   292.1 64
> >  925.0763 15 2.1   296.4   290.4 32
> >  850.0   1497175 3.6   290.8   288.4 32
> >  700.0   3140295 9.8   282.9   278.6 32
> >  500.0   584028523.7   267.1   232.1 32
> >  400.0   755025535.5   255.4   231.4 32
> >  300.0   964026537.0   242.2   216.2 32
> >
> >
> > Best Regards,
> >
> > --
> > 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.
> >
> >
>



-- 
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.


Re: [R] Output Graphics GIF

2010-10-03 Thread Nilza BARROS
On Mon, Sep 27, 2010 at 11:31 AM, Tal Galili  wrote:

> I am guessing you are saving the plot using the menu system.
>
> If that is the case, have a look at:
>
> ?pdf
> ?png
>
> Generally, I like saving my graphics to pdf since it is vectorized.
>
> Cheers,
> Tal
>
>
> Contact
> Details:---
> Contact me: tal.gal...@gmail.com |  972-52-7275845
> Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
> www.r-statistics.com (English)
>
> ----------
>
>
>
>
>  On Mon, Sep 27, 2010 at 2:39 PM, Nilza BARROS wrote:
>
>>  Dear R users,
>>
>> How could I managed graphics in GIF  format? What I have been doing is
>> graphics in *.ps or *.eps and after I convert them using CONVERT (from
>> ImageMagick) but the output quality is not good.  Since these graphics
>> will
>> be use for other users they must have a better image quality.
>>
>> I really appreciate any help,
>>
>> --
>> 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.
>>
>>
>


-- 
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.


[R] Read file

2010-10-02 Thread Nilza BARROS
Dear R-users,

I would like to know how could I read a file with different lines lengths.
I need read this file and create an output to feed my database.
So after reading I'll need create an output like this

"INSERT INTO TEMP (DATA,STATION,VAR1,VAR2) VALUES (20100910,837460, 39,390)"

I mean,  each line should be read. But I don`t how to do this when these
lines have different lengths

I really appreciate any help.

Thanks.



Below the file that should be read ===


*2010 10 01 00
83746  -43.25 -22.81  6  51*
1012.0  -320 1.5   299.1   294.4 64
 1000.0114250 4.1   298.4   294.8 32
  925.0797  0 0.0   293.6   292.9 32
  850.0   1524195 3.1   289.6   288.9 32
  700.0   315629011.3   280.1   280.1 32
  500.0   587028020.1   266.1   260.1 32
  400.0   757026523.7   256.6   222.7 32
  300.0   967026528.8   240.2   218.2 32
  250.0  1092028027.3   230.2   220.2 32
  200.0  1239026032.4   218.7   206.7 32
  176.0  -25537.6 -.0 -.0  8
  150.0  1418024535.5   205.1   196.1 32
  100.0  1656030017.0   195.2   186.2 32
*2010 10 01 00
83768  -51.13 -23.33569  41
* 1000.0 79  - -.0 -.0 -.0 32
  946.0  -270 1.0   295.8   292.1 64
  925.0763 15 2.1   296.4   290.4 32
  850.0   1497175 3.6   290.8   288.4 32
  700.0   3140295 9.8   282.9   278.6 32
  500.0   584028523.7   267.1   232.1 32
  400.0   755025535.5   255.4   231.4 32
  300.0   964026537.0   242.2   216.2 32


Best Regards,

-- 
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.


Re: [R] Output Graphics GIF

2010-10-02 Thread Nilza BARROS
Dear R users,



Thanks!. After reading the suggestions I have decided to choose
png format

Bye and Best Regards,
Nilza

On Mon, Sep 27, 2010 at 11:18 AM, Barry Rowlingson <
b.rowling...@lancaster.ac.uk> wrote:

> On Mon, Sep 27, 2010 at 1:39 PM, Nilza BARROS 
> wrote:
> > Dear R users,
> >
> > How could I managed graphics in GIF  format? What I have been doing is
> > graphics in *.ps or *.eps and after I convert them using CONVERT (from
> > ImageMagick) but the output quality is not good.  Since these graphics
> will
> > be use for other users they must have a better image quality.
>
>  The png() graphics driver will produce bitmap graphics which should
> convert better to a gif. PostScript is a vector format, so there may
> be all sorts of things going on.
>
>  Just feed png() with the width and height you want for your gif and
> then you wont have to resize as part of the conversion process.
>
>  Also, GIFs are pretty old-tech these days, so if you could persuade
> your other users to switch to png files, its a big win.
>
> Barry
>



-- 
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.


[R] Output Graphics GIF

2010-09-27 Thread Nilza BARROS
 Dear R users,

How could I managed graphics in GIF  format? What I have been doing is
graphics in *.ps or *.eps and after I convert them using CONVERT (from
ImageMagick) but the output quality is not good.  Since these graphics will
be use for other users they must have a better image quality.

I really appreciate any help,

-- 
Abraço,
Nilza Barros



-- 
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.


[R] Output Graphics GIF

2010-09-27 Thread Nilza BARROS
Dear R users,

How could I managed graphics in GIF  format? What I have been doing is
graphics in *.ps or *.eps and after I convert them using CONVERT (from
ImageMagick) but the output quality is not good.  Since these graphics will
be use for other users they must have a better image quality.

I really appreciate any help,

-- 
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.


[R] legend problem

2010-04-22 Thread Nilza BARROS
Dear R users,

I have been plotting several graphics in only one page. I intend to plot
only one legend in each page.
Since the graphics are inside a loop I have to do it automatically.
The main problem is that inside the loop I work with differente types of
variables, I mean , the range is different for each one.

I have already tried :

par(xpd=TRUE)
pos<-par("usr")
legend(pos[1],pos[3]-(pos[3]*.05),c("Modelo","Observado"),col =
c("blue","orange"),cex=1.0, pch=15)
I would like to be able to plot the legend outer the graphics region.
Something like I've done with title.
You can see one figure an attached file.

I really appreciate any help.
Nilza Barros







-- 
Abraço,
Nilza Barros
__
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.


[R] error in map library

2010-03-20 Thread Nilza BARROS
>
>
>  Dear Ruser,
>>
>>
>> I am trying to use the map library. But unfortunately I am facing the
>> warning message  above:
>> Warning message:
>> *In readGDAL(destfile, silent = TRUE) : GeoTransform values not available
>> *
>
> I want to use that library because I intend to plot some station in a
> Brazilian map.
>
> I really appreciate any help.
>


>
>>
> ===here what I was testing
>
>>  library(rgdal)
>>
>> library(RgoogleMaps)
>> > GetMap(markers =
>> '40.702147,-74.015794,blues%7C40.711614,-74.012318,greeng%7C40.718217,-73.998284,redc',
>> destfile = "MyTile1.png");
>>
>>
>> > tmp <- PlotOnStaticMap(lat = c(40.702147,40.711614,40.718217), lon =
>> c(-74.015794,-74.012318,-73.998284), destfile = "MyTile1.png",
>> cex=1.5,pch=20,col=c('red', 'blue', 'green'), add=F)
>> Read 1 item
>>
>

>  center, zoom:  40.71018 -74.00704 15
>> [1] "map Tile received"
>> tmp2:[1] -0.0007824726  1.0007824726 -0.0007824726  1.0007824726
>> par('usr')[1] -320  320 -320  320
>> List of 4
>>  $ : num 40.7
>>  $ : num -74
>>  $ : num 15
>>  $ : int [1:640, 1:640] 683 683 683 683 683 683 683 683 683 683 ...
>>   ..- attr(*, "COL")= chr [1:1047] "#00" "#0044DF" "#004EF4" "#0052FF"
>> ...
>>   ..- attr(*, "type")= chr "rgb"
>> NULL
>> [1] -204.0063  204.0063
>> [1] -246.9831  247.0129
>> Warning message:
>> *In readGDAL(destfile, silent = TRUE) : GeoTransform values not available
>> *
>>
>  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.


[R] error in map library

2010-03-18 Thread Nilza BARROS
 Dear Ruser,
>
>
> I am trying to use the map library. But unfortunately I am facing the
> warning message  above:
> Warning message:
> *In readGDAL(destfile, silent = TRUE) : GeoTransform values not available
> *

I want to use that library because I intend to plot some station in a
Brazilian map.

I really appreciate any help.

>
>
===here what I was testing

>  library(rgdal)
>
> library(RgoogleMaps)
> > GetMap(markers =
> '40.702147,-74.015794,blues%7C40.711614,-74.012318,greeng%7C40.718217,-73.998284,redc',
> destfile = "MyTile1.png");
> Read 1 item
> [1]
> "40.702147,-74.015794,blues%7C40.711614,-74.012318,greeng%7C40.718217,-73.998284,redc"
> [1] "
> http://maps.google.com/staticmap?size=640x640&maptype=terrain&format=png32&key=ABQIxI1cqe7mY9FLRX4CNqunWxR8LwkFvv97NF1lW-Y0LTl6YI7YUhQOrY33MnadojnlYov4VGE9c1Msrg&sensor=true&markers=40.702147,-74.015794,blues%7C40.711614,-74.012318,greeng%7C40.718217,-73.998284,redc
> "
>
>
> > tmp <- PlotOnStaticMap(lat = c(40.702147,40.711614,40.718217), lon =
> c(-74.015794,-74.012318,-73.998284), destfile = "MyTile1.png",
> cex=1.5,pch=20,col=c('red', 'blue', 'green'), add=F)
> Read 1 item
> [1] "
> http://maps.google.com/staticmap?center=40.710182,-74.007039&zoom=15&size=640x640&maptype=terrain&format=png32&key=ABQIxI1cqe7mY9FLRX4CNqunWxR8LwkFvv97NF1lW-Y0LTl6YI7YUhQOrY33MnadojnlYov4VGE9c1Msrg&sensor=true
> "
> center, zoom:  40.71018 -74.00704 15
> [1] "map Tile received"
> tmp2:[1] -0.0007824726  1.0007824726 -0.0007824726  1.0007824726
> par('usr')[1] -320  320 -320  320
> List of 4
>  $ : num 40.7
>  $ : num -74
>  $ : num 15
>  $ : int [1:640, 1:640] 683 683 683 683 683 683 683 683 683 683 ...
>   ..- attr(*, "COL")= chr [1:1047] "#00" "#0044DF" "#004EF4" "#0052FF"
> ...
>   ..- attr(*, "type")= chr "rgb"
> NULL
> [1] -204.0063  204.0063
> [1] -246.9831  247.0129
> Warning message:
> *In readGDAL(destfile, silent = TRUE) : GeoTransform values not available
> *
>



> >
>

[[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.


[R] In readGDAL(destfile, silent = TRUE) : GeoTransform values not available

2010-03-16 Thread Nilza BARROS
Dear Ruser,


I am trying to use the map library. But I have been problem the follow
message.
Warning message:
*In readGDAL(destfile, silent = TRUE) : GeoTransform values not available
*


library(rgdal)

library(RgoogleMaps)
> GetMap(markers =
'40.702147,-74.015794,blues%7C40.711614,-74.012318,greeng%7C40.718217,-73.998284,redc',
destfile = "MyTile1.png");
Read 1 item
[1]
"40.702147,-74.015794,blues%7C40.711614,-74.012318,greeng%7C40.718217,-73.998284,redc"
[1] "
http://maps.google.com/staticmap?size=640x640&maptype=terrain&format=png32&key=ABQIxI1cqe7mY9FLRX4CNqunWxR8LwkFvv97NF1lW-Y0LTl6YI7YUhQOrY33MnadojnlYov4VGE9c1Msrg&sensor=true&markers=40.702147,-74.015794,blues%7C40.711614,-74.012318,greeng%7C40.718217,-73.998284,redc
"


> tmp <- PlotOnStaticMap(lat = c(40.702147,40.711614,40.718217), lon =
c(-74.015794,-74.012318,-73.998284), destfile = "MyTile1.png",
cex=1.5,pch=20,col=c('red', 'blue', 'green'), add=F)
Read 1 item
[1] "
http://maps.google.com/staticmap?center=40.710182,-74.007039&zoom=15&size=640x640&maptype=terrain&format=png32&key=ABQIxI1cqe7mY9FLRX4CNqunWxR8LwkFvv97NF1lW-Y0LTl6YI7YUhQOrY33MnadojnlYov4VGE9c1Msrg&sensor=true
"
center, zoom:  40.71018 -74.00704 15
[1] "map Tile received"
tmp2:[1] -0.0007824726  1.0007824726 -0.0007824726  1.0007824726
par('usr')[1] -320  320 -320  320
List of 4
 $ : num 40.7
 $ : num -74
 $ : num 15
 $ : int [1:640, 1:640] 683 683 683 683 683 683 683 683 683 683 ...
  ..- attr(*, "COL")= chr [1:1047] "#00" "#0044DF" "#004EF4" "#0052FF"
...
  ..- attr(*, "type")= chr "rgb"
NULL
[1] -204.0063  204.0063
[1] -246.9831  247.0129
Warning message:
*In readGDAL(destfile, silent = TRUE) : GeoTransform values not available
*>



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.


Re: [R] Form using R

2010-03-15 Thread Nilza BARROS
I really appreciate the advices and suggestions.
But Gail`s information about google docs  it`s exactly what I need.
It`s amazing.
Thank you very much indeed.

Nilza Baroros
On Sun, Mar 14, 2010 at 9:33 PM, Farrel Buchinsky  wrote:

> Tal Galili  gmail.com> writes:
>
> >
> > Hi Nilza,
> > I just wrote a more detailed answer to your question in the following
> post:
> > Google spreadsheets + google forms + R = Easily collecting and importing
> > data for analysis<
> http://www.r-statistics.com/2010/03/google-spreadsheets-
> google-forms-r-easily-collecting-and-importing-data-for-analysis/>
>
> on Fri, Mar 12, 2010 at 4:49 PM, Nilza BARROS  gmail.com>
> wrote:
> >
> > > Hi, R users
> > >
> > > We can create a form using R?
> > > I would like to create a form where the information can be read by R.
> > > Itneeds to be updated daily because I have to tabulate the reasons for
> > > delays
> > > in the generation of numerical models products.
>
>
> There is also a package called RGoogleData that can import data from Google
> Spreadsheets (even when they are not public). It has one benefit over
> RGoogleDocs; RGoogleData can download a spreadsheet as a csv file to your
> harddrive. You can then read the csv file into R - read.csv(). Those steps
> can
> easily be written into a script so that you do not have to manually futz
> with
> them each time. The benefit of the csv download is that it is very fast.
> Both
> the RGoogleDocs and the RGoogleData are slow in reading the spreadsheet
> into R.
> I understand, but may be wrong, that Google Stores all the data as HTML and
> its
> API spits it out as xml which these r packages then need to parse out line
> by
> line. The csv treatment by comparison is instantaneous.
>
> Only one big problem. As of a few months ago, RGoogleData has stopped
> working
> for me. I think it is still working for its writer, Adrian Dragulescu.
> Adrian
> has been very generous with his time in trying to help me. He predicts that
> he
> will go back to exploring his package once Google updates their API.
>
> Try it out. I would love to hear what happens.
>
> http://r-forge.r-project.org/projects/rgoogledata/
>
> __
> 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.
>



-- 
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.


Re: [R] Form using R

2010-03-12 Thread Nilza BARROS
It would be a form that is filled daily, but some fields were tabulated and
other fields would be filled with only the opinions of users.

Currently, my form is a Word document that is the filling and printed. At
the end of every month they are analyzed and the reasons for delays are
tabulated and the graphs created. I wish the print was not necessary.
Furthermore,
the reasons would be tabulated automatically.
Please let me know if I were clear.
Thanks for you attention
Nilza Barros
On Fri, Mar 12, 2010 at 2:21 PM, Ista Zahn  wrote:

> HI Nilza,
> I don't think this question is well-specified. What kind of form are
> you talking about? An html form?
>
> -Ista
>
> On Fri, Mar 12, 2010 at 9:49 AM, Nilza BARROS 
> wrote:
> > Hi, R users
> >
> > We can create a form using R?
> > I would like to create a form where the information can be read by R.
> > Itneeds to be updated daily because I have to tabulate the reasons for
> > delays
> > in the generation of numerical models products.
> >
> >
> > I really appreciate any help,
> >
> >
> > Thanks in advance,
> > 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.
> >
>
>
>
> --
> Ista Zahn
> Graduate student
> University of Rochester
> Department of Clinical and Social Psychology
> http://yourpsyche.org
>



-- 
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.


[R] Form using R

2010-03-12 Thread Nilza BARROS
Hi, R users

We can create a form using R?
I would like to create a form where the information can be read by R.
Itneeds to be updated daily because I have to tabulate the reasons for
delays
in the generation of numerical models products.


I really appreciate any help,


Thanks in advance,
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.


Re: [R] manipulate missing dates in a graphics a vector

2010-02-10 Thread Nilza BARROS
Thank you !! That's exactly what I need.
Nilza Barros

On Tue, Feb 9, 2010 at 10:50 PM, Dennis Murphy  wrote:

> Hi:
>
> # Create a sequence of consecutive dates and assign to a data frame
>
> dates <- data.frame(day = seq(as.Date('2009-12-01'), by = 'days', length =
> 10))
>
> # Let's call your data frame (not vector) 'df'; to make sure that things
> are
> # compatible,
>
> names(df) <- c('day', 'y')
> df$day <- as.Date(df$day)
>
> # Then,
> > merge(dates, df, all.x =TRUE)
>   dayy
> 1  2009-12-01 26.8
>
> 2  2009-12-02   NA
> 3  2009-12-03 27.9
> 4  2009-12-04 25.6
> 5  2009-12-05 20.8
>
> 6  2009-12-06   NA
> 7  2009-12-07   NA
> 8  2009-12-08 20.8
> 9  2009-12-09   NA
> 10 2009-12-10   NA
>
>
> HTH,
> Dennis
>
>   On Tue, Feb 9, 2010 at 4:30 PM, Nilza BARROS wrote:
>
>>  Dear all,
>>
>> I am trying  to identify the days absent in a vector so as to be able to
>> display missing data in the  graphics in .It should be done  automatically
>> since  the graphics will be generated for different periods of the year.
>> I have been trying to do a function below but it did not work. I really
>> appreciate any help
>>
>> ordados <- function(datas,var)
>> {
>> ind <- !datas %in% var # find the missing date in var
>> miss <- datas[ind]
>> mat <- matrix(NA,length(miss),length(miss)) #insert  NA in the missing
>> date
>> mat[,1]<-miss
>> jundado <- rbind (mat,var)
>> jundado <- jundado[order(jundado[,1]),] # sort by dates
>> }
>> For instance:
>> If I have the vector below:
>>  2009-12-01 26.8
>>  2009-12-03     27.9
>>  2009-12-04 25.6
>> 2009-12-05 20.8
>> 2009-12-08 20.8
>> I will need a result like this one
>>
>> 2009-12-01 26.8
>> 2009-12-02 NA
>> 2009-12-03 27.9
>>  2009-12-04 25.6
>> 2009-12-05 20.8
>> 2009-12-06 NA
>> 2009-12-07 NA
>> 2009-12-08 20.8
>>
>> Bye and Best Regards
>> 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.
>>
>
>


-- 
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.


[R] manipulate missing dates in a graphics a vector

2010-02-09 Thread Nilza BARROS
Dear all,

I am trying  to identify the days absent in a vector so as to be able to
display missing data in the  graphics in .It should be done  automatically
since  the graphics will be generated for different periods of the year.
I have been trying to do a function below but it did not work. I really
appreciate any help

ordados <- function(datas,var)
{
ind <- !datas %in% var # find the missing date in var
miss <- datas[ind]
mat <- matrix(NA,length(miss),length(miss)) #insert  NA in the missing date
mat[,1]<-miss
jundado <- rbind (mat,var)
jundado <- jundado[order(jundado[,1]),] # sort by dates
}
For instance:
If I have the vector below:
 2009-12-01 26.8
 2009-12-03 27.9
 2009-12-04 25.6
2009-12-05 20.8
2009-12-08 20.8
I will need a result like this one

2009-12-01 26.8
2009-12-02 NA
2009-12-03 27.9
 2009-12-04 25.6
2009-12-05 20.8
2009-12-06 NA
2009-12-07 NA
2009-12-08 20.8

Bye and Best Regards
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.