[R] Selecting vector elements using other vectors
Dear R-Help, I have a data frame and a vector df=data.frame(Letter=c(Z,Q,R,A,E,F), Number=c(11,32,4,1,9,3)) v=c(C,Q,R,A,E) From df, I'd like to construct a subset of the field Number, with deletions dictated by the vector, v, of letters. I've succeeded in doing this for a single deletion (for example Letter=Q) with the following df$Number[df$Letter != v[2]] but am struggling do more than one at a time. For example, df$Number[df$Letter != v[2:5]] gives the error: Warning messages: 1: Is.na(e1) | is.na(e2) : longer object length is not a multiple of shorter object length 2: In. Perhaps there is a much easier way to approach this... Any help would be greatly appreciated! Alastair -- View this message in context: http://www.nabble.com/Selecting-vector-elements-using-other-vectors-tp23296130p23296130.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] timeSeries and aggregation() question
Hello, I've a time series, T, for an irregular sequence of days (data for bank holidays weekends have been removed). I would like to aggregate this series by into weeks using aggregate(x, by=weeks, FUN=mean). To do this, I think that x needs to be a timeSeries object, and when I try to call timeSeries(data=T, positions=irregular.sequence.of.days) I get lots of NAs in the resulting object. (Note: I've checked that length(T)=length(irregular.sequence of days). My dates are of the form dd/mm/ in case it's relevant.) Thanks in advance! -- View this message in context: http://www.nabble.com/timeSeries-and-aggregation%28%29-question-tp21584903p21584903.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] xreg in ARIMA modelling.
Hello, Does anyone know how the parameter estimates are calculated for xreg variables when called as part of an arima() command, or know of any literature that provides this info? In particular, I was wondering if there is a quick way to compare different combinations of xreg variables in the arima() fit in the same way that you would in multiple regression (using AIC R^2 etc.). Thanks very much! -- View this message in context: http://www.nabble.com/%22xreg%22-in-ARIMA-modelling.-tp20718058p20718058.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.