[R] Separating columns, and sorting by rows
RagingJim
nowa0021 at flinders.edu.au
Wed Feb 17 01:25:16 CET 2010
Thanks for the help guys. This worked:
x<-sqlQuery(conn, "select to_char(lsd,'yyyy-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$yyyy<-substr(myDF$YR,5,8)
myDF$mm<-substr(myDF$YR,1,4)
myDF<-subset(myDF, select=c(yyyy,mm,R))
myDF.reshape<-reshape(myDF,v.names="R",idvar="yyyy",timevar="mm",direction="wide")
myDF.reshape
kent=myDF.reshape
library(zoo)
rows=nrow(myDF.reshape)
kent[,1]=as.numeric(as.character(kent[,1]))
ann=c(kent1[,2]+kent1[,3]+kent1[,4]+kent1[,5]+kent1[,6]+kent1[,7]+kent1[,8]+kent1[,9]+kent1[,10]+kent1[,11]+kent1[,12]+kent1[,13])
kent1=cbind(kent$yyyy,kent$R.Jan,kent$R.Feb,kent$R.Mar,kent$R.Apr,kent$R.May,kent$R.Jun,kent$R.Jul,kent$R.Aug,kent$R.Sep,kent$R.Oct,kent$R.Nov,kent$R.Dec,ann)
Still some cleaning up to do, but it now works as promised :)
All I ahve to figure out now is how to fix have a pop up for people to write
in a station number, and that station number then gets input into the query.
x<-sqlQuery(conn, "select to_char(lsd,'yyyy-mm') as yr,ttl_mo_prcp from
mo_rains where stn_num=23090")
Any ideas at all?
Cheers again!
--
View this message in context: http://n4.nabble.com/Separating-columns-and-sorting-by-rows-tp1555806p1558118.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list