Grouping columns
untested because I don't have access to your data, but this should work.
b13.NEW <- b13[, c("Gesamt", "Wasser", "Boden", "Luft", "Abwasser",
"Gef?hrliche Abf?lle", "nicht gef?hrliche Abf?lle")]
Geophagus wrote:
*Hi @ all, I have a question concerning the possibilty of grouping the columns of a matrix. R groups the columns alphabetically. What can I do to group the columns in my specifications? The script is the following:*
#R-Skript: Anzahl xyz
#Quelldatei einlesen
b<-read.csv2("Z:/int/xyz.csv", header=TRUE)
#Teilmengen f?r die Einzeljahre generieren
b1<-subset(b,jahr=="2007")
b2<-subset(b,jahr=="2008")
b3<-subset(b,jahr=="2009")
#tapply f?r die Einzeljahre auf die jeweilige BranchenID
b1_1<-tapply(b1$betriebs_id,b1$umweltkompartiment,length)
b1_2<-tapply(b2$betriebs_id,b2$umweltkompartiment,length)
b1_3<-tapply(b3$betriebs_id,b3$umweltkompartiment,length)
#Verbinden der Ergebnisse
b11<-rbind(b1_1,b1_2,b1_3)
Gesamt<-apply(X=b11,MARGIN=1, sum)
b13<-cbind(Gesamt,b11)
b13
Gesamt Abwasser Boden Gef?hrliche Abf?lle Luft nicht gef?hrliche Abf?lle Wasser b1_1 9832 432 18 3147 2839 1592 1804 b1_2 10271 413 28 3360 2920 1715 1835 b1_3 9983 404 21 3405 2741 1691 1721 *Now I want to have the following order of the columns: Gesamt, Wasser, Boden, Luft, Abwasser, Gef?hrliche Abf?lle, nicht gef?hrliche Abf?lle Thanks a lot for your answers! Fak*
-- View this message in context: http://r.789695.n4.nabble.com/Grouping-columns-tp3681018p3681121.html Sent from the R help mailing list archive at Nabble.com.