Hi and thanks to all R developers and helpers, I wanrt to take the 1 and 3 dimensions of this object to create a new one without the years and with the next functions to do some specific calculations:
> str(PMpa) num [1:499105, 1:60, 1:12] 29.8 55.8 29.7 25.1 25 ... - attr(*, "dimnames")=List of 3 ..$ punt: NULL ..$ any : chr [1:60] "1950" "1951" "1952" "1953" ... ..$ mes : chr [1:12] "Gener" "Febrer" "Març" "Abril" ... I'm writing a function where appears the next error message: Error en model.frame.default(formula = x ~ c("1950:2009"), drop.unused.levels = TRUE) : variable lengths differ (found for 'c (1950:2009)') Script: library(robustbase) load("PMpa.Rdat") R2 <- function(x) var(predict(x))/var(predict(x)+resid(x)) TPMEN<-t(apply(PMpa,c(1,3),function(x){ kk<-lmrob(x~c("1950:2009")); c(kk$coefficients[2],R2(kk), (1-summary(kk)$coefficients[2,4])*100, (confint(kk,level=.95)*10)[2,])})) dimnames(TPMEN)[[3]][1:3]<-c("Pendent","R2","Significancia") save(TPMEN,file="TPMEN.Rdat") working: > TPMEN<-t(apply(PMpa,c(1,3),function(x){ + kk<-lmrob(x~c("1950:2009")); + c(kk$coefficients[2],R2(kk),(1-summary(kk)$coefficients[2,4])*100,(confint(kk,level=.95)*10)[2,])})) Error en model.frame.default(formula = x ~ c("1950:2009"), drop.unused.levels = TRUE) : las longitudes de las variables son diferentes (encontrada para 'c("1950:2009")') Thanks to all for your time and help. [[alternative HTML version deleted]]
______________________________________________ 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.