First, let's use some available data to all of us in order to reproduce the code. In this case, they are wind speed and direction from openair
package, quite similar to fluid current speed and direction you are using
library(openair)
library(circular)
# Using "mydata" dataset from openair package as an example
data <- data.frame("Speed" = mydata$ws, "Direction"=mydata$wd)
windrose(x = circular(data$Direction, template = 'geographics', units = "degrees"),
y = data$Speed,
increment = 25,
fill.col = rainbow(12),
label.freq = T,
xlim = c(-2.1, 2.1),
ylim = c(-2.1, 2.1))
Not sure which openair
package version are you using (mine is 2.1.5) but your function call does not match the signature in the help (the parameter names are different). You can check them out in the help using:
help(windRose)
Having said that, I would also suggest to split your code in 2 steps:
1) Create the dataset. windRose
function looks for variable names ws
(Wind Speed [m/s]) and wd
(Wind Direction [deg from North]), you can use them. Make sure the data frame contains the correct values and units. Visualize by using head(data2)
or str(data2)
. Note that data
here is your own dataset.
data2 <- data.frame("ws" = as.numeric(circular(data$Direction, template = 'geographics', units = "degrees")),
"wd" = data$Direction)
2) Plot the data frame with ws
and wd
variable names.
data <- data.frame("Speed" = mydata$ws, "Direction"=mydata$wd)
data2 <- data.frame("ws"=data$Speed, "wd"=data$Direction)
head(data2)
ws wd
1 0.60 280
2 2.16 230
3 2.76 190
4 2.16 170
5 2.40 180
6 3.00 190
windRose(data2)
