[R] Error with using windRose function from the open air package

Jim Lemon drjimlemon at gmail.com
Tue Feb 24 08:22:44 CET 2015


Hi Alexandra,
As Jeff mentioned, cbind is probably causing the conversion to factors. One
thing I would suggest is keeping the names:

windSFO<-data.frame(ws=ws,wd=wd,stn=stn,yearSite=yearSite)

as it looks like the windRose function expects the names to be there. If
the error persists after using the above, try:

windSFO$ws<-as.numeric(as.character(windSFO$ws))
windSFO$ww<-as.numeric(as.character(windSFO$ww))

Jim


On Tue, Feb 24, 2015 at 4:38 PM, Jeff Newmiller <jdnewmil at dcn.davis.ca.us>
wrote:

> I have no magic answer for you, just some suggestions until you can
> clarify your problem.
>
> Your description of loading one column in at a time is a bit odd... It is
> much more typical to use one of the read.table variants.
>
> Don't use cbind to make data frames. If you have any non-numeric columns
> then you will make them all into character or factor columns. That is
> almost never a good thing. In fact it is probably at the root of your
> current woes.
>
> windSFO <- data.frame(ws,wd,stn,yearSite)
>
> Learn to use the str function... e.g.
>
> str(windSFO)
>
> Not that we cannot tell how your data are stored given the way you gave
> supplied it to us. Read about the use of dput (e.g. [1]) and make your
> example reproducible (what package exactly are you talking about? package
> names don't have spaces in them).
>
> Note that the Posting Guide directs you to verify that your problem occurs
> when you use the latest version (3.1.2 at this time). If you want to keep
> old versions around for some reason, at least install the latest version
> and verify that your problem happens with it before posting.
>
> [1]
> http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
> ---------------------------------------------------------------------------
> Jeff Newmiller                        The     .....       .....  Go Live...
> DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live
> Go...
>                                       Live:   OO#.. Dead: OO#..  Playing
> Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
> /Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
> ---------------------------------------------------------------------------
> Sent from my phone. Please excuse my brevity.
>
> On February 23, 2015 11:13:20 AM PST, Alexandra Catena <amc5981 at gmail.com>
> wrote:
> >Hello All,
> >
> >I have a data frame called windSFO of four columns, wind speed, wind
> >direction, station number, and date (yyyymmdd).  I downloaded the gz
> >data from a site online and then unzipped it using readLines. I then
> >concatenated these four columns from the unzipped data into a
> >dataframe using cbind.
> >
> >windSFO = data.frame(cbind(ws,wd,stn,yearSite))
> >
> >Here are the first four rows as an example:
> >
> >       ws  wd          stn       yearSite
> >
> >1      36 290 724940-23234 20090101
> >
> >2      77 280 724940-23234 20090101
> >
> >3      72 290 724940-23234 20090101
> >
> >4      46 290 724940-23234 20090101
> >
> >
> >I'm trying to make a wind rose using the windRose function but I keep
> >getting an error that I don't understand. I type in:
> >
> >windRose(windSFO,ws='ws',wd='wd')
> >
> >I then get the error:
> >
> >Error in Summary.factor(c(27L, 35L, 34L, 29L, 28L, 25L, 25L, 24L, 24L,
> >:
> >  max not meaningful for factors
> >In addition: Warning messages:
> >1: In Ops.factor(mydata[[wd]], 10) : %% not meaningful for factors
> >2: In Ops.factor(mydata[[wd]], angle) : / not meaningful for factors
> >
> >Can anyone tell me what this means/what I'm doing wrong?
> >
> >Also, I have R version 3.1.1
> >
> >Thank you!
> >Alexandra
> >
> >______________________________________________
> >R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >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-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list