Re: [R] aggregate wind direction data with wind speed required

2023-06-10 Thread Stefano Sofia
direction data with wind speed required I think that using complex numbers to represent the wind velocity makes this simpler. You would need to write some simple conversion functions since wind directions are typically measured clockwise from north and the argument of a complex number is measured

Re: [R] aggregate wind direction data with wind speed required

2023-05-13 Thread Jeff Newmiller
You don't have to bother with the subtracting from pi/2 bit ... just assume the cartesian complex values are (y,x) instead of (x,y). On May 13, 2023 1:38:51 PM PDT, Bill Dunlap wrote: >I think that using complex numbers to represent the wind velocity makes >this simpler. You would need to

Re: [R] aggregate wind direction data with wind speed required

2023-05-13 Thread Bill Dunlap
I think that using complex numbers to represent the wind velocity makes this simpler. You would need to write some simple conversion functions since wind directions are typically measured clockwise from north and the argument of a complex number is measured counterclockwise from east. E.g.,

Re: [R] aggregate wind direction data with wind speed required

2023-05-13 Thread Bert Gunter
Sorry Rui; if you run your code you will get: Error in FUN(X[[i]], ...) : object 'ws' not found Moreover, even if you did this: aggregate(wd ~ day + month, data=df, FUN = my_fun, ws1 = df$ws) the answer would be wrong is you need to include only the subsets of ws1 corresponding to the split

Re: [R] aggregate wind direction data with wind speed required

2023-05-13 Thread Rui Barradas
Às 15:51 de 13/05/2023, Stefano Sofia escreveu: Dear list users, I have to aggregate wind direction data (wd) using a function that requires also a second input variable, wind speed (ws). This is the function that I need to use: my_fun <- function(wd1, ws1){ u_component <-

[R] aggregate wind direction data with wind speed required

2023-05-13 Thread Stefano Sofia
Dear list users, I have to aggregate wind direction data (wd) using a function that requires also a second input variable, wind speed (ws). This is the function that I need to use: my_fun <- function(wd1, ws1){ u_component <- -ws1*sin(2*pi*wd1/360) v_component <- -ws1*cos(2*pi*wd1/360)