Hello list, I have the following data on "dm" table> dmGroup.1 V1 V2 V3 V4 V5 V6 V7 V8 1 C/L NA 15.5 732179 875270.6 -143091.46 1107270 1088300 18964.40 2 C/S NA 15.5 803926 850352.1 -46426.03 1395710 1312310 83403.30 3 D/D NA 15.5 751660 857828.2 -106168.17 1340360 1322790 17569.30 4 D/F NA 15.5 724924 969418.7 -244494.67 1181280 1160760 20519.20 5 D/I NA 15.5 755841 842130.5 -86289.48 1264250 1241750 22495.20 6 D/L NA 15.5 731904 875340.0 -143435.84 1107600 1087940 19657.30 7 D/S NA 15.5 798289 844102.0 -45812.85 1399840 1305000 94832.10 8 I/F NA 15.5 871670 1074136.3 -202466.58 1304290 1249006 55286.59 9 I/I NA 15.5 897718 1029579.0 -131861.35 1542810 1398716 144100.07 10 I/L NA 15.5 2628110 862466.8 1765645.67 2628110 1073510 1554610.00 11 I/S NA 15.5 2628110 831486.8 1796627.33 2475450 1282100 1193350.00> barchart (dm[,4] ~ dm[,1])For each value of Group.1 I want to draw 4 bars (v3,v4, v6 and v7). Can you suggest me a solution please barchat draws only one value. regards -- PhD candidate in Computer Science Address 3 avenue lamine, cité ezzahra, Sousse 4000 Tunisia tel: +216 97 246 706 (+33640302046 jusqu'au 15/6) fax: +216 71 391 166 [[alternative HTML version deleted]]
Start here dm <- read.table(text=" Group.1 V1 V2 V3 V4 V5 V6 V7 V8 1 C/L NA 15.5 732179 875270.6 -143091.46 1107270 1088300 18964.40 2 C/S NA 15.5 803926 850352.1 -46426.03 1395710 1312310 83403.30 3 D/D NA 15.5 751660 857828.2 -106168.17 1340360 1322790 17569.30 4 D/F NA 15.5 724924 969418.7 -244494.67 1181280 1160760 20519.20 5 D/I NA 15.5 755841 842130.5 -86289.48 1264250 1241750 22495.20 6 D/L NA 15.5 731904 875340.0 -143435.84 1107600 1087940 19657.30 7 D/S NA 15.5 798289 844102.0 -45812.85 1399840 1305000 94832.10 8 I/F NA 15.5 871670 1074136.3 -202466.58 1304290 1249006 55286.59 9 I/I NA 15.5 897718 1029579.0 -131861.35 1542810 1398716 144100.07 10 I/L NA 15.5 2628110 862466.8 1765645.67 2628110 1073510 1554610.00 11 I/S NA 15.5 2628110 831486.8 1796627.33 2475450 1282100 1193350.00 ", header=TRUE) library(reshape) dm.melt <- melt(dm[,c(1,4,5,6,7)], id="Group.1") barchart(value ~ variable | Group.1, data=dm.melt, origin=0) On Mon, Dec 9, 2013 at 9:19 AM, Adel ESSAFI <adelessafi at gmail.com> wrote:> Hello list, > I have the following data on "dm" table > >> dm > Group.1 V1 V2 V3 V4 V5 V6 V7 V8 > 1 C/L NA 15.5 732179 875270.6 -143091.46 1107270 1088300 18964.40 > 2 C/S NA 15.5 803926 850352.1 -46426.03 1395710 1312310 83403.30 > 3 D/D NA 15.5 751660 857828.2 -106168.17 1340360 1322790 17569.30 > 4 D/F NA 15.5 724924 969418.7 -244494.67 1181280 1160760 20519.20 > 5 D/I NA 15.5 755841 842130.5 -86289.48 1264250 1241750 22495.20 > 6 D/L NA 15.5 731904 875340.0 -143435.84 1107600 1087940 19657.30 > 7 D/S NA 15.5 798289 844102.0 -45812.85 1399840 1305000 94832.10 > 8 I/F NA 15.5 871670 1074136.3 -202466.58 1304290 1249006 55286.59 > 9 I/I NA 15.5 897718 1029579.0 -131861.35 1542810 1398716 144100.07 > 10 I/L NA 15.5 2628110 862466.8 1765645.67 2628110 1073510 1554610.00 > 11 I/S NA 15.5 2628110 831486.8 1796627.33 2475450 1282100 1193350.00 >> barchart (dm[,4] ~ dm[,1]) > > For each value of Group.1 I want to draw 4 bars (v3,v4, v6 and v7). > > Can you suggest me a solution please > > barchat draws only one value. > regards > > > > -- > PhD candidate in Computer Science > Address > 3 avenue lamine, cit? ezzahra, Sousse 4000 > Tunisia > tel: +216 97 246 706 (+33640302046 jusqu'au 15/6) > fax: +216 71 391 166 > > [[alternative HTML version deleted]] > > > ______________________________________________ > R-help at 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. >
The etiquette of this email list is to stay on the list. I am returning this email to the entire list. The line I sent earlier prints one Figure, with a different set of 4 bars in each panel. Here are three more options (and I repeat the first as well). Basic documentation for barchart is in ?xyplot. More detail is available in ?panel.barchart barchart(value ~ variable | Group.1, data=dm.melt, origin=0) barchart(value ~ Group.1 | variable, data=dm.melt, origin=0) barchart(value ~ variable, groups=Group.1, data=dm.melt, origin=0) barchart(value ~ Group.1, groups=variable, data=dm.melt, origin=0) On Mon, Dec 9, 2013 at 2:45 PM, Adel ESSAFI <adel.safi at imag.fr> wrote:> Thank you, it worked. However I want the bars to be displayed in the same > figure . > Actually, it prints each 4 bars in separates figures. > Regards > > > > > 2013/12/9 Richard M. Heiberger <rmh at temple.edu> > >> Start here >> >> dm <- read.table(text=" >> Group.1 V1 V2 V3 V4 V5 V6 V7 V8 >> 1 C/L NA 15.5 732179 875270.6 -143091.46 1107270 1088300 18964.40 >> 2 C/S NA 15.5 803926 850352.1 -46426.03 1395710 1312310 83403.30 >> 3 D/D NA 15.5 751660 857828.2 -106168.17 1340360 1322790 17569.30 >> 4 D/F NA 15.5 724924 969418.7 -244494.67 1181280 1160760 20519.20 >> 5 D/I NA 15.5 755841 842130.5 -86289.48 1264250 1241750 22495.20 >> 6 D/L NA 15.5 731904 875340.0 -143435.84 1107600 1087940 19657.30 >> 7 D/S NA 15.5 798289 844102.0 -45812.85 1399840 1305000 94832.10 >> 8 I/F NA 15.5 871670 1074136.3 -202466.58 1304290 1249006 55286.59 >> 9 I/I NA 15.5 897718 1029579.0 -131861.35 1542810 1398716 144100.07 >> 10 I/L NA 15.5 2628110 862466.8 1765645.67 2628110 1073510 1554610.00 >> 11 I/S NA 15.5 2628110 831486.8 1796627.33 2475450 1282100 1193350.00 >> ", header=TRUE) >> >> library(reshape) >> dm.melt <- melt(dm[,c(1,4,5,6,7)], id="Group.1") >> barchart(value ~ variable | Group.1, data=dm.melt, origin=0) >> >> >> On Mon, Dec 9, 2013 at 9:19 AM, Adel ESSAFI <adelessafi at gmail.com> wrote: >> > Hello list, >> > I have the following data on "dm" table >> > >> >> dm >> > Group.1 V1 V2 V3 V4 V5 V6 V7 >> > V8 >> > 1 C/L NA 15.5 732179 875270.6 -143091.46 1107270 1088300 >> > 18964.40 >> > 2 C/S NA 15.5 803926 850352.1 -46426.03 1395710 1312310 >> > 83403.30 >> > 3 D/D NA 15.5 751660 857828.2 -106168.17 1340360 1322790 >> > 17569.30 >> > 4 D/F NA 15.5 724924 969418.7 -244494.67 1181280 1160760 >> > 20519.20 >> > 5 D/I NA 15.5 755841 842130.5 -86289.48 1264250 1241750 >> > 22495.20 >> > 6 D/L NA 15.5 731904 875340.0 -143435.84 1107600 1087940 >> > 19657.30 >> > 7 D/S NA 15.5 798289 844102.0 -45812.85 1399840 1305000 >> > 94832.10 >> > 8 I/F NA 15.5 871670 1074136.3 -202466.58 1304290 1249006 >> > 55286.59 >> > 9 I/I NA 15.5 897718 1029579.0 -131861.35 1542810 1398716 >> > 144100.07 >> > 10 I/L NA 15.5 2628110 862466.8 1765645.67 2628110 1073510 >> > 1554610.00 >> > 11 I/S NA 15.5 2628110 831486.8 1796627.33 2475450 1282100 >> > 1193350.00 >> >> barchart (dm[,4] ~ dm[,1]) >> > >> > For each value of Group.1 I want to draw 4 bars (v3,v4, v6 and v7). >> > >> > Can you suggest me a solution please >> > >> > barchat draws only one value. >> > regards >> > >> > >> > >> > -- >> > PhD candidate in Computer Science >> > Address >> > 3 avenue lamine, cit? ezzahra, Sousse 4000 >> > Tunisia >> > tel: +216 97 246 706 (+33640302046 jusqu'au 15/6) >> > fax: +216 71 391 166 >> > >> > [[alternative HTML version deleted]] >> > >> > >> > ______________________________________________ >> > R-help at 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. >> > > > > > > -- > PhD in Computer Science > Address > > Avenue Taha Hussein Montfleury, 1008 Tunis > > t?l : +216 71 49 60 66 > fax: +216 71 39 11 66
On 12/10/2013 01:19 AM, Adel ESSAFI wrote:> Hello list, > I have the following data on "dm" table > >> dm > Group.1 V1 V2 V3 V4 V5 V6 V7 V8 > 1 C/L NA 15.5 732179 875270.6 -143091.46 1107270 1088300 18964.40 > 2 C/S NA 15.5 803926 850352.1 -46426.03 1395710 1312310 83403.30 > 3 D/D NA 15.5 751660 857828.2 -106168.17 1340360 1322790 17569.30 > 4 D/F NA 15.5 724924 969418.7 -244494.67 1181280 1160760 20519.20 > 5 D/I NA 15.5 755841 842130.5 -86289.48 1264250 1241750 22495.20 > 6 D/L NA 15.5 731904 875340.0 -143435.84 1107600 1087940 19657.30 > 7 D/S NA 15.5 798289 844102.0 -45812.85 1399840 1305000 94832.10 > 8 I/F NA 15.5 871670 1074136.3 -202466.58 1304290 1249006 55286.59 > 9 I/I NA 15.5 897718 1029579.0 -131861.35 1542810 1398716 144100.07 > 10 I/L NA 15.5 2628110 862466.8 1765645.67 2628110 1073510 1554610.00 > 11 I/S NA 15.5 2628110 831486.8 1796627.33 2475450 1282100 1193350.00 >> barchart (dm[,4] ~ dm[,1]) > > For each value of Group.1 I want to draw 4 bars (v3,v4, v6 and v7). > > Can you suggest me a solution please >Hi Adel, If you have no repeated values in Group.1, this might work: dmmat<-as.matrix(dm[,c(3,4,6,7)]) rownames(dmmat)<-as.character(dm$Group.1) library(plotrix) barp(t(dmmat),names.arg=rownames(dmmat)) Jim