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 (I believe): my $query = "select to_char(stn_num,'00009') as stn, to_char(lsd,'yyyy') as yr, nvl(max(decode(to_char(lsd,'MON'),'JAN',ttl_mo_prcp)),-9999) jan, nvl(max(decode(to_char(lsd,'MON'),'FEB',ttl_mo_prcp)),-9999) feb, nvl(max(decode(to_char(lsd,'MON'),'MAR',ttl_mo_prcp)),-9999) mar, nvl(max(decode(to_char(lsd,'MON'),'APR',ttl_mo_prcp)),-9999) apr, nvl(max(decode(to_char(lsd,'MON'),'MAY',ttl_mo_prcp)),-9999) may, nvl(max(decode(to_char(lsd,'MON'),'JUN',ttl_mo_prcp)),-9999) jun, nvl(max(decode(to_char(lsd,'MON'),'JUL',ttl_mo_prcp)),-9999) jul, nvl(max(decode(to_char(lsd,'MON'),'AUG',ttl_mo_prcp)),-9999) aug, nvl(max(decode(to_char(lsd,'MON'),'SEP',ttl_mo_prcp)),-9999) sep, nvl(max(decode(to_char(lsd,'MON'),'OCT',ttl_mo_prcp)),-9999) oct, nvl(max(decode(to_char(lsd,'MON'),'NOV',ttl_mo_prcp)),-9999) nov, nvl(max(decode(to_char(lsd,'MON'),'DEC',ttl_mo_prcp)),-9999) dec from mo_rains where (stn_num in ($stns)) group by stn_num, to_char(lsd,'yyyy') order by to_char(lsd,'yyyy') desc;"; But I think that sorts by station number, as it is designed for multiple stations at a time, whereas mine is for one station only. Yet if I plug it into R just to see what happens, I get a plethora of extraordinarily long errors which I can post if needed. -- View this message in context: http://n4.nabble.com/Separating-columns-and-sorting-by-rows-tp1555806p1555813.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ 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.