[R] reading surfer files

2010-02-23 Thread RagingJim
To the R experts, I am currently playing with a program which was designed so that the outputs are to be read in Surfer. I do not have the program, but the files, can but put into excel and graphed. I figured i could do the same thing with R. If I open the file with excel, and put the text into

Re: [R] reading surfer files

2010-02-23 Thread RagingJim
The problem is, if I use read.table I get Error in read.table(HeatLow_maphhs000.1994010101) : duplicate 'row.names' are not allowed if I try table-read.table(HeatLow_maphhs000.1994010101,sep= ) Then I get: Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, :

Re: [R] reading surfer files

2010-02-23 Thread RagingJim
Surprisingly in this case, the simplest solution was the best one. Using read.table(filename,skip=4) was all it took. Cheers :) -- View this message in context: http://n4.nabble.com/reading-surfer-files-tp1566943p1567003.html Sent from the R help mailing list archive at Nabble.com.

Re: [R] running means

2010-02-18 Thread RagingJim
Ok, took me a while, but I figured it out. Because my running mean had less years than my standard rainfall graph, when I overlaid the running mean onto the rainfall it was trying to stretch out. So I just plotted both onto the same graph., like so: barplot(Ann,main=title,

Re: [R] sql query variable

2010-02-18 Thread RagingJim
Thanks guys. I ended up doing as you suggested Dieter. Thanks for the idea :) -- View this message in context: http://n4.nabble.com/sql-query-variable-tp1558189p1561158.html Sent from the R help mailing list archive at Nabble.com. __

Re: [R] Separating columns, and sorting by rows

2010-02-16 Thread RagingJim
Thanks for the help guys. This worked: x-sqlQuery(conn, select to_char(lsd,'-mm') as yr,ttl_mo_prcp from mo_rains where stn_num=23090) myDF=x myDF[,1]=as.yearmon(myDF[,1]) myDF$R=myDF$TTL_MO_PRCP myDF[,-2] myDF$-substr(myDF$YR,5,8) myDF$mm-substr(myDF$YR,1,4) myDF-subset(myDF,

Re: [R] Using text put into a dialog box

2010-02-16 Thread RagingJim
Thanks Greg, the problem is I have no idea how to return and use what I have typed into the pop up. Add to that the complication that with this query x-sqlQuery(conn, select to_char(lsd,'-mm') as yr,ttl_mo_prcp from mo_rains where stn_num=23090) if I put anything other than a number into

[R] sql query variable

2010-02-16 Thread RagingJim
This is the very last thing I need to make everything work properly. My query: sqlQuery(conn, select to_char(lsd,'-mm') as yr,ttl_mo_prcp from mo_rains where stn_num=023000) Is there a way to may the stn_num in the query variable, ie make it so that whenever my script is run, the user must

Re: [R] Using text put into a dialog box

2010-02-16 Thread RagingJim
Thanks mate, awesome :) Everything is now working as ordered. Thanks to everyone who has chipped in and helped out this past week, much appreciated!!! -- View this message in context: http://n4.nabble.com/Using-text-put-into-a-dialog-box-tp1555761p1558278.html Sent from the R help mailing list

[R] Using text put into a dialog box

2010-02-14 Thread RagingJim
I have written in R this: require(tcltk) tt-tktoplevel() Name - tclVar() entry.Name -tkentry(tt,width=20,textvariable=Name) tkgrid(tklabel(tt,text=Please enter site number.)) tkgrid(entry.Name) OnOK - function() { NameVal - tclvalue(Name) use.this=NameVal tkdestroy(tt) }

[R] Separating columns, and sorting by rows

2010-02-14 Thread RagingJim
Dear anyone who knows more about R than me (so everyone). I have been bashing my head on the keyboard all day trying to do something with my table. I have some data, like so: -mm Rainfall(mm) 1 1977-0217.4 2 1977-0334.0 3 1977-0426.2 4 1977-05

Re: [R] Separating columns, and sorting by rows

2010-02-14 Thread RagingJim
the other alternative would be to edit my sql query so that that data is brought in from the database and put in to the correct format initially. sqlQuery(conn, select lsd,ttl_mo_prcp from mo_rains where stn_num=23090) That is my very basic query. I have also been given this for use in orcale

Re: [R] Barplot axis titles

2010-02-11 Thread RagingJim
Cheers Jim. However when I input: axis.ticks-seq(kent[1,2],kent[dimkent[34,2]],by=10) I get the error Error in dimkent[1,2] : incorrect number of dimensions What are these dimensions that I am meant to have in there? I have tried total dimensions of the table, dimension of the row that I

Re: [R] Barplot axis titles

2010-02-11 Thread RagingJim
ok, used the lapply function and now the Years column is the numeric type. However, I still get the same error as above. Replacing either kent[1,1] or kent[dimkent[1],1] with a number, gives me the same error. If both terms are replaced with a number, then it does not produce an error. It then

Re: [R] Barplot axis titles

2010-02-11 Thread RagingJim
To everyone else, it is going to look like I am talking to myself. Jim, I got your reply (to my post which I changed almost as soon as I posted it), and as.numeric(as.character(kent$Year)) is a god send. Worked a charm, and fixed all the problems. So thanks :) Last issue now (at least for this

Re: [R] Barplot axis titles

2010-02-11 Thread RagingJim
This worked: dimkent-dim(kent) axis.ticks-seq(kent[1,1],kent[dimkent[1],1],by=10) barplot(Ann,main=title, xlab=Year,ylab=Rainfall (mm), ylim=c(0,ymax),col=blue,space=0) axis(1,at=seq(1,rows,10),tcl=-0.5,labels=axis.ticks) Thanks Jim! You just saved my life. -- View this message in context:

Re: [R] running means

2010-02-11 Thread RagingJim
ok, solved it. Hoowever (there is always a however), I would like to centre the line plot of the rolling mean onto the centre of each bar in my bar plot. Currently, the lines aligns itself with the RHS of bars. I have tried this

Re: [R] prompts and running means

2010-02-10 Thread RagingJim
Thanks mate, will get the zoo package ASAP. I have been working on the file open/save part, and it works as planned except for one bit. When I save it, it does not save as the relevant file type. This is again my code: require(tcltk) fileName-tclvalue(tkgetSaveFile(filetypes={{PNG Files}

[R] Barplot axis titles

2010-02-10 Thread RagingJim
Now, I think I am making this harder than it seems, but... I am writing a script that will allow me to pull any csv file with annual rainfall and plot it into a bar plot. The problem I am facing is that the different sites have recorded data for a different number of years. This means that every

Re: [R] prompts and running means

2010-02-10 Thread RagingJim
Thanks Jim, however if I change png(fileName) to png(picture.png) then this: require(tcltk) fileName-tclvalue(tkgetSaveFile(filetypes={{PNG Files} {.png}} )) becomes obsolete. Assuming of course that is what you were referring to. Otherwise I completely missed your point. Cheers. -- View

[R] prompts and running means

2010-02-09 Thread RagingJim
G'day, I am new user to R, and have been thrown in the deep end with a something my company want me to write. my code is as follows: kenttemp=read.csv(mnowak.11.1.csv) rows=nrow(kenttemp)-5 kent=kenttemp[1:rows,] #have to remove the last 5 lines of the graph as they interfere with