1

I am using windRose in openair package in R (3.2.1), using R studio.

library(openair)
mydata = read.csv("sample.csv")
windRose(mydata)

Whether I use my own data (sample.csv):

date,ws,wd
14/10/2014 09:00,1.4,357
14/10/2014 10:00,1.5,49
14/10/2014 11:00,0.1,274
14/10/2014 12:00,0.3,77
14/10/2014 13:00,1,38
14/10/2014 14:00,1,351
14/10/2014 15:00,1,59
14/10/2014 16:00,1.4,23
14/10/2014 17:00,1,47
14/10/2014 18:00,0.9,3
14/10/2014 19:00,1.3,3
14/10/2014 20:00,2.3,146
14/10/2014 21:00,2.5,151
14/10/2014 22:00,1.5,176
14/10/2014 23:00,2.7,163
15/10/2014 00:00,2.4,174
15/10/2014 01:00,2.5,157
15/10/2014 02:00,2.8,152
15/10/2014 03:00,4.7,155
15/10/2014 04:00,3.4,164
15/10/2014 05:00,3.4,158
15/10/2014 06:00,3.9,153
15/10/2014 07:00,3.6,148
15/10/2014 08:00,3.2,147
15/10/2014 09:00,3.2,141
15/10/2014 10:00,3.7,136
15/10/2014 11:00,2.9,130
15/10/2014 12:00,3.6,123

or the sample data from the openair website, I get the same error:

Error in Summary.factor(1:28, na.rm = FALSE) : 
‘min’ not meaningful for factors

I have uninstalled and re-installed the packages: openair, png, dplyr, maps, lazyeval, using, for example:

remove.packages("dplyr")
install.packages("dplyr", dependencies = TRUE)

I have changed the date format in 'sample.csv', from YYYY/MM/DD to as shown, I have filled in any missing entries in 'sample.csv' I have made sure there are no zeros

This is the first thing I have attempted using openair

I am not sure what else to try here. Can you help? Thanks!

zx8754
  • 52,746
  • 12
  • 114
  • 209
lost in R
  • 55
  • 11
  • Did you remember to convert your date column to the actual Date class? – Hong Ooi Aug 11 '15 at 01:16
  • Could you explain? I tried to match the format in the openair example file.... 'date,ws,wd,nox,no2,o3,pm10,so2,co,pm25' '01/01/1998 00:00,0.6,280,285,39,1,29,4.7225,3.3725,' – lost in R Aug 11 '15 at 01:18
  • You can use `colClasses` argument in `read.csv`, to specify the first column to be of class `Date`. –  Aug 11 '15 at 01:21

2 Answers2

1

Thanks Hong Ooi,

I used:

mydata$date <- as.POSIXct((strptime(mydata$date,format = "%d/%m/%Y %H:%M")))

now it works!

lost in R
  • 55
  • 11
  • Yes. Compare `sapply(mydata, class)` on `mydata` from `openair` and your `mydata`. –  Aug 11 '15 at 01:41
1

Use argument colClasses in read.csv to turn the first column into Date class:

library(openair)

mydata = read.csv("sample.csv", colClasses = c("Date", "numeric", "integer"))

windRose(mydata)