Dear friends,
Hope you are doing well. I am currently using R version 3.6.2. I installed
and loaded package qcc by Mr. Luca Scrucca.
This is the structure of my data:
str(dataset2)
'data.frame': 140 obs. of 2 variables:
$ School: Factor w/ 140 levels "24 de Diciembre",..: 39 29 66 16 67 116 35
106 65 17 ...
$ Points: num 55 43 24 21 20 20 18 17 16 16 ...
I tried using the function pareto.chart from the qcc package, but the names
of the columns in the pareto chart are some codes that do not match the
school names in the School column of dataset2.
The graph is generated without any issues, it's just that I want the bars
to have the school labels, how can I accomplish this?
Below is the dput() of my dataset.
dput(dataset2)
structure(list(School = structure(c(39L, 29L, 66L, 16L, 67L,
116L, 35L, 106L, 65L, 17L, 12L, 55L, 136L, 8L, 24L, 140L, 123L,
114L, 22L, 15L, 98L, 4L, 107L, 110L, 20L, 76L, 19L, 25L, 93L,
14L, 46L, 7L, 104L, 121L, 23L, 88L, 74L, 41L, 103L, 59L, 96L,
95L, 30L, 109L, 117L, 132L, 47L, 21L, 137L, 79L, 115L, 101L,
125L, 2L, 129L, 71L, 73L, 58L, 127L, 131L, 78L, 18L, 50L, 100L,
80L, 37L, 38L, 108L, 40L, 85L, 86L, 45L, 138L, 126L, 34L, 135L,
5L, 1L, 31L, 82L, 87L, 63L, 105L, 68L, 28L, 72L, 111L, 49L, 112L,
32L, 70L, 10L, 3L, 118L, 44L, 133L, 57L, 48L, 64L, 97L, 43L,
99L, 56L, 9L, 119L, 61L, 77L, 81L, 51L, 11L, 52L, 42L, 60L, 53L,
134L, 122L, 124L, 128L, 94L, 130L, 92L, 33L, 6L, 26L, 113L, 27L,
69L, 36L, 75L, 102L, 83L, 84L, 120L, 13L, 54L, 62L, 89L, 90L,
91L, 139L), .Label = c("24 de Diciembre", "Achiote", "Aguadulce",
"Alcalde D?az", "Alto Boquete", "Amador", "Amelia Denis de Icaza",
"Anc?n", "Ant?n", "Arnulfo Arias", "Arosemena", "Arraij?n", "Bajo Boquete",
"Barrio Balboa", "Barrio Col?n", "Barrio Norte", "Barrio Sur",
"Bejuco", "Belisario Fr?as", "Belisario Porras", "Bella Vista",
"Betania", "Buena Vista", "Burunga", "Calidonia", "Ca?averal",
"Canto del Llano", "Capira", "Cativ?", "Cerme?o", "Cerro Silvestre",
"Chame", "Chepo", "Chic?", "Chilibre", "Chitr?", "Ciricito",
"Comarca Guna de Madugand?", "Crist?bal", "Crist?bal Este", "Curund?",
"David", "Don Bosco", "El Arado", "El Ca?o", "El Chorrillo",
"El Coco", "El Espino", "El Guabo", "El Harino", "El Higo", "El Llano",
"El Roble", "El Valle", "Ernesto C?rdoba Campos", "Escobal",
"Feuillet", "Garrote o Puerto Lindo", "Guadalupe", "Herrera",
"Hurtado", "Isla de Ca?as", "Isla Grande", "Iturralde", "Jos? Domingo
Espinar",
"Juan Dem?stenes Arosemena", "Juan D?az", "La Concepci?n", "La Ensenada",
"La Laguna", "La Mesa", "La Raya de Calobre", "La Represa", "Las Cumbres",
"Las Lajas", "Las Ma?anitas", "Las Ollas Arriba", "L?dice", "Lim?n",
"Los D?az", "Los Llanitos", "Mar?a Chiquita", "Mateo Iturralde",
"Miguel de la Borda", "Nombre de Dios", "Nueva Providencia",
"Nuevo Chagres", "Nuevo Emperador", "Obald?a", "Oc?", "Ol?",
"Omar Torrijos", "Pacora", "Pajonal", "Palmas Bellas", "Parque Lefevre",
"Pedas?", "Pedregal", "Penonom?", "Pi?a", "Playa Leona", "Pocr?",
"Portobelo", "Pueblo Nuevo", "Puerto Armuelles", "Puerto Caimito",
"Puerto Pil?n", "Punta Chame", "Rio Abajo", "R?o Abajo", "R?o Grande",
"R?o Hato", "R?o Indio", "Rufina Alfaro", "Sabanagrande", "Sabanitas",
"Sajalices", "Salamanca", "San Carlos", "San Felipe", "San Francisco",
"San Jos?", "San Juan", "San Juan Bautista", "San Mart?n", "San Mart?n de
Porres",
"Santa Ana", "Santa Clara", "Santa Fe", "Santa Isabel", "Santa Rita",
"Santa Rosa", "Santiago", "Santiago Este", "Tinajas", "Tocumen",
"Veracruz", "Victoriano Lorenzo", "Villa Rosario", "Vista Alegre"
), class = "factor"), Points = c(55, 43, 24, 21, 20, 20, 18,
17, 16, 16, 15, 13, 13, 12, 12, 11, 11, 11, 11, 11, 10, 9, 9,
9, 9, 9, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6,
6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2)), row.names = c(NA, -140L
), class = "data.frame")
Best regards,
Paul
Trouble getting labels for bars in Pareto Chart
3 messages · Paul Bernal, Rasmus Liland, Jim Lemon
Dear Paul, I answer inline:
On 2020-08-19 16:27 -0500, Paul Bernal wrote:
| | I tried using the function | pareto.chart from the qcc package, but | the names of the columns in the pareto | chart are some codes What codes? Can you please elaborate on this? | that do not match the school names in | the School column of dataset2. Does this mean there exists a third hidden vector not included in dataset2 which conflicts with dataset2$School? | The graph is generated without any | issues, Good! | it's just that I want the bars | to have the school labels, how can I | accomplish this? So as ?qcc::pareto.chart states, qcc::pareto.chart needs a vector of values, data, and names(data) can be used to label the bars, there are also some examples at the bottom. Just doing this makes the labels show up. points <- dataset2$Points names(points) <- dataset2$School qcc::pareto.chart(points, main="Pareto Chart for School Points") Was this what you were looking to do? Best, Rasmus -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20200820/2e6a7408/attachment.sig>
Hi Paul,
I ran this:
library(qcc)
pareto.chart(dataset2$Points)
and like you, got the chart. As you have 140 long labels, I thought at
first it might be the function trying to abbreviate some of them and
actually displaying about 1 in 5. Looking at the code for the
function, this is not the case. You can get the labels (sort of) by
specifying a very wide graphic device and setting the names of the
input vector to dataset2$School:
dpoints<-dataset2$Points
pdf("qcc_dataset2.pdf",width=20,height=5)
names(dpoints)<-dataset2$School
pareto.chart(dpoints)
dev.off()
The attached image shows what I mean.
Jim
On Thu, Aug 20, 2020 at 7:27 AM Paul Bernal <paulbernal07 at gmail.com> wrote:
Dear friends,
Hope you are doing well. I am currently using R version 3.6.2. I installed
and loaded package qcc by Mr. Luca Scrucca.
This is the structure of my data:
str(dataset2)
'data.frame': 140 obs. of 2 variables:
$ School: Factor w/ 140 levels "24 de Diciembre",..: 39 29 66 16 67 116 35
106 65 17 ...
$ Points: num 55 43 24 21 20 20 18 17 16 16 ...
I tried using the function pareto.chart from the qcc package, but the names
of the columns in the pareto chart are some codes that do not match the
school names in the School column of dataset2.
The graph is generated without any issues, it's just that I want the bars
to have the school labels, how can I accomplish this?
Below is the dput() of my dataset.
dput(dataset2)
structure(list(School = structure(c(39L, 29L, 66L, 16L, 67L,
116L, 35L, 106L, 65L, 17L, 12L, 55L, 136L, 8L, 24L, 140L, 123L,
114L, 22L, 15L, 98L, 4L, 107L, 110L, 20L, 76L, 19L, 25L, 93L,
14L, 46L, 7L, 104L, 121L, 23L, 88L, 74L, 41L, 103L, 59L, 96L,
95L, 30L, 109L, 117L, 132L, 47L, 21L, 137L, 79L, 115L, 101L,
125L, 2L, 129L, 71L, 73L, 58L, 127L, 131L, 78L, 18L, 50L, 100L,
80L, 37L, 38L, 108L, 40L, 85L, 86L, 45L, 138L, 126L, 34L, 135L,
5L, 1L, 31L, 82L, 87L, 63L, 105L, 68L, 28L, 72L, 111L, 49L, 112L,
32L, 70L, 10L, 3L, 118L, 44L, 133L, 57L, 48L, 64L, 97L, 43L,
99L, 56L, 9L, 119L, 61L, 77L, 81L, 51L, 11L, 52L, 42L, 60L, 53L,
134L, 122L, 124L, 128L, 94L, 130L, 92L, 33L, 6L, 26L, 113L, 27L,
69L, 36L, 75L, 102L, 83L, 84L, 120L, 13L, 54L, 62L, 89L, 90L,
91L, 139L), .Label = c("24 de Diciembre", "Achiote", "Aguadulce",
"Alcalde D?az", "Alto Boquete", "Amador", "Amelia Denis de Icaza",
"Anc?n", "Ant?n", "Arnulfo Arias", "Arosemena", "Arraij?n", "Bajo Boquete",
"Barrio Balboa", "Barrio Col?n", "Barrio Norte", "Barrio Sur",
"Bejuco", "Belisario Fr?as", "Belisario Porras", "Bella Vista",
"Betania", "Buena Vista", "Burunga", "Calidonia", "Ca?averal",
"Canto del Llano", "Capira", "Cativ?", "Cerme?o", "Cerro Silvestre",
"Chame", "Chepo", "Chic?", "Chilibre", "Chitr?", "Ciricito",
"Comarca Guna de Madugand?", "Crist?bal", "Crist?bal Este", "Curund?",
"David", "Don Bosco", "El Arado", "El Ca?o", "El Chorrillo",
"El Coco", "El Espino", "El Guabo", "El Harino", "El Higo", "El Llano",
"El Roble", "El Valle", "Ernesto C?rdoba Campos", "Escobal",
"Feuillet", "Garrote o Puerto Lindo", "Guadalupe", "Herrera",
"Hurtado", "Isla de Ca?as", "Isla Grande", "Iturralde", "Jos? Domingo
Espinar",
"Juan Dem?stenes Arosemena", "Juan D?az", "La Concepci?n", "La Ensenada",
"La Laguna", "La Mesa", "La Raya de Calobre", "La Represa", "Las Cumbres",
"Las Lajas", "Las Ma?anitas", "Las Ollas Arriba", "L?dice", "Lim?n",
"Los D?az", "Los Llanitos", "Mar?a Chiquita", "Mateo Iturralde",
"Miguel de la Borda", "Nombre de Dios", "Nueva Providencia",
"Nuevo Chagres", "Nuevo Emperador", "Obald?a", "Oc?", "Ol?",
"Omar Torrijos", "Pacora", "Pajonal", "Palmas Bellas", "Parque Lefevre",
"Pedas?", "Pedregal", "Penonom?", "Pi?a", "Playa Leona", "Pocr?",
"Portobelo", "Pueblo Nuevo", "Puerto Armuelles", "Puerto Caimito",
"Puerto Pil?n", "Punta Chame", "Rio Abajo", "R?o Abajo", "R?o Grande",
"R?o Hato", "R?o Indio", "Rufina Alfaro", "Sabanagrande", "Sabanitas",
"Sajalices", "Salamanca", "San Carlos", "San Felipe", "San Francisco",
"San Jos?", "San Juan", "San Juan Bautista", "San Mart?n", "San Mart?n de
Porres",
"Santa Ana", "Santa Clara", "Santa Fe", "Santa Isabel", "Santa Rita",
"Santa Rosa", "Santiago", "Santiago Este", "Tinajas", "Tocumen",
"Veracruz", "Victoriano Lorenzo", "Villa Rosario", "Vista Alegre"
), class = "factor"), Points = c(55, 43, 24, 21, 20, 20, 18,
17, 16, 16, 15, 13, 13, 12, 12, 11, 11, 11, 11, 11, 10, 9, 9,
9, 9, 9, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6,
6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2)), row.names = c(NA, -140L
), class = "data.frame")
Best regards,
Paul
[[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
-------------- next part -------------- A non-text attachment was scrubbed... Name: qcc_dataset2.pdf Type: application/pdf Size: 9274 bytes Desc: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20200820/ccdb61f2/attachment.pdf>