Re: [R] change frequency of wind data correctly

2020-12-06 Thread Stefano Sofia
This afternoon I will work on that. I am thinking to stick to Jim's algorithm, changing the hours related to 40 and 50 mins. If I add one hour to them, everything should work correctly, because wind data at 40, 50 and 00 would have exactly the same hours. This would not be elegant, but

[R] second legend in biplot

2020-12-06 Thread PIKAL Petr
Dear all I try to make fviz_pca_biplot with 2 (or more) legends. Below is data and the code, which gives one legend (colour) for coating variable and correctly shows triangles and circles for size variable. But this is not shown in the legend. Hopefully somebody could help. And before you ask, I

Re: [R] change frequency of wind data correctly

2020-12-06 Thread Jeff Newmiller
Beware of missing or extra records with these approaches. Also may be tricky to get the time aligned to the hour properly. On December 6, 2020 9:12:01 PM PST, Richard O'Keefe wrote: >To be honest, I would do this one of two ways. > >(1) Use ?decimate from library(signal), >decimating by a

Re: [R] change frequency of wind data correctly

2020-12-06 Thread Richard O'Keefe
To be honest, I would do this one of two ways. (1) Use ?decimate from library(signal), decimating by a factor of three. (2) Convert the variable to an (n/3)*3 matrix using as.matrix then use rowMeans or apply. On Thu, 3 Dec 2020 at 06:55, Stefano Sofia wrote: > Dear list users, > I

[R-es] Problemas con paqueterias "car" y "dplyr"

2020-12-06 Thread Ramiro Guzman
Buenas tardes, disculpen, estoy adecuando una base de datos en la cual, tengo variables que estoy convirtiendo a categóricas y dando diferentes atributos principalmente con la paqueteria "car" y la función "recode" para dar ciertos valores, y también tengo que eliminar algunos valores innecesarios

Re: [R] change frequency of wind data correctly

2020-12-06 Thread Ben Tupper
Hi, Perhaps this might work for you. It leverages findInterval() and a simple look-up-table of times to do the grouping. I made it return NA when computing the mean when there are fewer than the three observations. Cheers, Ben n <- 144 x <- data.frame( datetime = seq(from =

Re: [R] change frequency of wind data correctly

2020-12-06 Thread Jeff Newmiller
Sigh. Don't use integer division AND ceiling. ceiling_dtmN <- function( dtm, mins ) { tm_base <- as.POSIXct( trunc( min( dtm ), units = "days" ) ) x <- as.numeric( dtm - tm_base, units = "mins" ) xceil <- ceiling( x / mins ) * mins tm_base + as.difftime( xceil, units = "mins" ) } On

Re: [R] change frequency of wind data correctly

2020-12-06 Thread Mathew Guilfoyle
Hi Stefano I think either of these does what you need... 1: This gets the interval column as you want it, but utilises the lubridate package: library(lubridate) mydf$interval = ceiling_date(mydf$data_POSIX, unit="30 minutes”) 2: Alternative in base R is a bit more long winded: convert the

Re: [R] change frequency of wind data correctly

2020-12-06 Thread Jeff Newmiller
I usually roll my own: --- Sys.setenv( TZ = "GMT" ) ssdf$Dtm <- with( ssdf , as.POSIXct( paste( date_POSIX, time_POSIX ) ) ) ceiling_dtmN <- function( dtm, mins ) { tm_base <- as.POSIXct( trunc( min( dtm ), units = "days" ) ) x <- as.numeric( dtm -

Re: [R] change frequency of wind data correctly

2020-12-06 Thread Stefano Sofia
Hi Jim. I studied and implemented your solution in details. The idea is great, but after a sharp revision I came to the conclusion that unfortunately it des not work correctly: for the "am" side (10, 20, 30 minutes) it works well because the hour is exactly the same, while for the "pm" side

[R] Small R documentation bug in ?anyDuplicated

2020-12-06 Thread Bert Gunter
All: I did not want to bother R folks for an R Bugzilla account, so I'll just note what appears to be a documentation bug here In R version 4.0.3, ?anyDuplicated says: "anyDuplicated(.) is a “generalized” more efficient shortcut for any(duplicated(.)). However, anyDuplicated returns an integer