« first day (2410 days earlier)      last day (765 days later) » 

5:28 AM
@joran OP, at best, isn't making it clear what the question is.
So I'm a bit tempted to press a down-vote. A bit.
 
5:55 AM
Oh boy, installing a whole new universe of packages just to remove one column. I don't want to live on this planet anymore.
0
A: Principal Components Analysis:Error in colMeans(x, na.rm = TRUE) : 'x' must be numeric

Parth ChaudharyThe first column of the data frame is character. So you can recode it to row names as : library(tidyverse) data2 %>% remove_rownames %>% column_to_rownames(var="country") princ <- prcomp(data2) Alternatively as : data2 <- data2[,-1] rownames(data2) <- data2[,1] princ <- prcomp(data2)

 
 
4 hours later…
9:52 AM
@RomanLuštrik And it doesn't even make for easier to read code. In contrary actually. If you keep pulling up these questions, I'm on the way to get the same reputation as our beloved prof. dr. Ripley :-)
 
 
1 hour later…
10:59 AM
This was the last question, I promise.
 
 
5 hours later…
4:27 PM
Hmmm
library(RcppRoll); x <- 1:2; x[3:4] <- NA
roll_medianr(x = x,n = 5,na.rm = TRUE)
[1] NA NA NA NA 2 2 NA NA 7 8 9 10 11 12 13 14 15 16 17 18
Oops, that was supposed to be x <- 1:20 obviously
roll_meanr and roll_maxr both do what I'd expect in that case...
 
@joran I am now being comment spammed by this person. Always a good start when a noob tells you your answer is wrong but has failed to understand why their counterexample is wrong and that I was right all along.
 
@GavinSimpson Yeah, that user seems to have a hard time being a minimally self-sufficient learner.
 
5:39 PM
@joran Try package roll as well. Actively maintained.
 
@DirkEddelbuettel Thanks, doesn't look like roll does medians at the moment, tho.
 
Yeah :-./ That's a hard problem for dynamic updates / rolling computations, see eg stackoverflow.com/questions/1309263/…
 
Yeah, seems like there aren't many shortcuts, computationally, on that one.
I can make do with zoo for the moment.
 

« first day (2410 days earlier)      last day (765 days later) »