Weird windRose error.

I keep getting this error when using my made up dataset. I am trying to fix this, so that I can ask another question latter.

#> Error in `[[<-.data.frame`(`*tmp*`, vars[i], value = numeric(0)): replacement has 0 rows, data has 11

I don't get this error when I use longer dataset.

Below is what I have so far, any suggestions?

library (openair)
library (tidyverse)

wind_rose <- data.frame("wind_speed(m/s)" = c(4.31, 6.73, 8.95, 6.68, 6.92, 7.14,1.11,2.34,6.07,5.06,4.11), 
                         "wind_direction(°)" = c(180,277,300,266,176,45,77,320,55,183,90))


windRose(wind_rose, ws="wind_speed(m/s)", wd="wind_direction(°)",
         breaks=c(0,2,5,8,11,17), 
         auto.text = FALSE, 
         paddle = FALSE, 
         annotate = FALSE, 
         grid.line = 2, 
         key = list(labels = c( "> 0 - 2 ",
                                " > 2 - 5 ",
                                " > 5 - 8")),
         theme(text = element_text(family = "Times")),
         key.footer = "Avg. Wind Speed Lake George Station (Ocala, Fl) 2006-2019 WSP (m/s)", 
         key.position = "bottom",
         par.settings = list(axis.line = list(col = "lightgray")),
         par.settings = list(fontsize=list(text=1000)),
         col = c("#A9A9A9", "#696969", "#363434")) 
#> Error in `[[<-.data.frame`(`*tmp*`, vars[i], value = numeric(0)): replacement has 0 rows, data has 11

you are posting about two errors, and they are not consistent...
the first implies that you havent run library(openair) so your session doesn't know windRose function.
the second implies you have run it, but you get an error from the variables you list not matching the variable names in the wind_rose frame.
you can always use names(my_dataframe) to find the names in your my_dataframe
the way you construct the data frame in this example does not directly honour your desired names but changes them, and this means names dont match,
look at this:


wind_rose <- data.frame("wind_speed(m/s)" = c(4.31, 6.73, 8.95, 6.68, 6.92, 7.14,1.11,2.34,6.07,5.06,4.11), 
                       "wind_direction(°)" = c(180,277,300,266,176,45,77,320,55,183,90))
names(wind_rose)
names(wind_rose) <- c("wind_speed(m/s)", "wind_direction(°)")
names(wind_rose)

wind_rose2<-
structure(list(`wind_speed(m/s)` = c(
  4.31, 6.73, 8.95, 6.68,
  6.92, 7.14, 1.11, 2.34, 6.07, 5.06, 4.11
), `wind_direction(°)` = c(
  180,
  277, 300, 266, 176, 45, 77, 320, 55, 183, 90
)), class = "data.frame", row.names = c(
  NA,
  -11L
))
names(wind_rose2)

Thank you for the help, it runs now.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.