Home > database >  How the wind rose varies by month: Package openair
How the wind rose varies by month: Package openair

Time:12-14

I have date for 8 years. Sample of my data:

structure(list(Data = c("1/1/2015", "1/2/2015", "1/3/2015", "1/4/2015", 
"1/5/2015", "1/6/2015", "1/7/2015", "1/8/2015", "1/9/2015", "1/10/2015", 
"1/11/2015", "1/12/2015", "1/13/2015", "1/14/2015", "1/15/2015", 
"1/16/2015", "1/17/2015", "1/18/2015", "1/19/2015", "1/20/2015", 
"1/21/2015", "1/22/2015", "1/23/2015", "1/24/2015", "1/25/2015", 
"1/26/2015", "1/27/2015", "1/28/2015", "1/29/2015", "1/30/2015", 
"1/31/2015"), no2 = c(3.56, 11.13, 11.84, 4.88, 6.16, 12.56, 
18.99, 24.74, 10.81, 12.7, 6.08, 7.34, 16.88, 16.65, 15.81, 20.78, 
15.03, 11.82, 15.18, 17, 15.21, 13.86, 10.28, 8.34, 11.89, 7.22, 
15.44, 10.55, 8.19, 5.04, 14.65), ws = c(10.84, 3.71, 2.08, 4.59, 
6.18, 2.97, 2.13, 1.22, 1.92, 2.07, 3.09, 4.75, 2.12, 1.8, 1.9, 
1.79, 1.58, 1.86, 1.58, 1.47, 1.7, 2.6, 2.67, 3.21, 1.78, 4.58, 
1.79, 3.1, 3.49, 6.15, 2.59), wd = c(90, 112.5, 112.5, 270, 90, 
135, 112.5, 112.5, 270, 315, 270, 112.5, 112.5, 135, 135, 112.5, 
292.5, 135, 270, 135, 112.5, 112.5, 270, 112.5, 112.5, 112.5, 
112.5, 112.5, 270, 270, 270)), class = "data.frame", row.names = c(NA, 
-31L))
library(openair)

windRose(nitrogen,
         key = list(header="Wind Rose Acri", footer="wind speed",
                    plot.style = c("ticks", "border"),
                    fit = "all", height = 1,
                    space = "top"))

pollutionRose(nitrogen, pollutant = "no2")

I want to show how the wind rose varies by month. The same problem (Wind rose with ggplot (R)?) but tried realised by function from Openair package.

CodePudding user response:

You could convert your Data column to a name called date with date format and specify type argument with "month". type according to documenation:

type determines how the data are split i.e. conditioned, and then plotted. The default is will produce a single plot using the entire data. Type can be one of the built-in types as detailed in cutData e.g. “season”, “year”, “weekday” and so on. For example, type = "season" will produce four plots --- one for each season.

It is also possible to choose type as another variable in the data frame. If that variable is numeric, then the data will be split into four quantiles (if possible) and labelled accordingly. If type is an existing character or factor variable, then those categories/levels will be used directly. This offers great flexibility for understanding the variation of different variables and how they depend on one another.

Type can be up length two e.g. type = c("season", "weekday") will produce a 2x2 plot split by season and day of the week. Note, when two types are provided the first forms the columns and the second the rows.

Please note you only provided one month:

library(openair)
# add month column
nitrogen$date <- as.POSIXct(nitrogen$Data, format = '%m/%d/%Y')
windRose(nitrogen,
         key = list(header="Wind Rose Acri", footer="wind speed",
                    plot.style = c("ticks", "border"),
                    fit = "all", height = 1,
                    space = "top"),
         type = 'month')

Created on 2022-12-13 with reprex v2.0.2


Here is an example with build-in data with type = 'month':

library(openair)
windRose(mydata, type = "month")

Created on 2022-12-13 with reprex v2.0.2

  • Related