R: Shiny and Ggplot2 show different plot with same code - r
Have data for everyday of dicember 2014. want to plot a barchart according to the selection of dates:
Original data:
structure(list(date = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L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, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L,
8L, 8L, 8L, 8L, 8L, 8L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 12L, 12L, 12L, 12L, 12L,
12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L,
12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L,
12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L,
12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L,
12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 13L, 13L, 13L, 13L,
13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L,
13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L,
13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L,
13L, 13L, 13L, 13L, 13L, 13L, 14L, 14L, 14L, 14L, 14L, 14L, 14L,
14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L,
14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L,
14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L,
14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L,
14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L,
15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L,
15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L,
15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L,
15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L,
15L, 15L, 15L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L,
16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L,
16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L,
16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L,
16L, 16L, 16L, 16L, 16L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L,
17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L,
17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L,
17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L,
17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L,
17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L,
17L, 17L, 17L, 17L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L,
18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L,
18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L,
18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 19L, 19L,
19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L,
19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L,
19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L,
19L, 19L, 19L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L,
20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L,
20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L,
20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L,
20L, 20L, 20L, 20L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L,
21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L,
21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L,
21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L,
21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 22L, 22L, 22L, 22L, 22L,
22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L,
22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L,
22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L,
22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 23L, 23L, 23L, 23L, 23L,
23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L,
23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L,
23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 24L, 24L, 24L, 24L,
24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L,
24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L,
24L, 24L, 24L, 24L, 24L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L,
25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L,
25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L,
25L, 25L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L,
26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L,
26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L,
26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L,
26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 27L, 27L, 27L, 27L,
27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L,
27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L,
27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L,
27L, 27L, 27L, 27L, 27L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L,
28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L,
28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L,
28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 29L, 29L,
29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L,
29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L,
29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L,
29L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L,
30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L,
30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L,
30L, 30L, 30L, 30L, 30L, 30L, 31L, 31L, 31L, 31L, 31L, 31L, 31L,
31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L,
31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L), .Label = c("2014-12-01",
"2014-12-02", "2014-12-03", "2014-12-04", "2014-12-05", "2014-12-06",
"2014-12-07", "2014-12-08", "2014-12-09", "2014-12-10", "2014-12-11",
"2014-12-12", "2014-12-13", "2014-12-14", "2014-12-15", "2014-12-16",
"2014-12-17", "2014-12-18", "2014-12-19", "2014-12-20", "2014-12-21",
"2014-12-22", "2014-12-23", "2014-12-24", "2014-12-25", "2014-12-26",
"2014-12-27", "2014-12-28", "2014-12-29", "2014-12-30", "2014-12-31"
), class = "factor"), sessions = c(197L, 1L, 7L, 13L, 1L, 1L,
10L, 1L, 3L, 3L, 5L, 3L, 566L, 1L, 27L, 159L, 7L, 1L, 6L, 1L,
1L, 4L, 1L, 6L, 10L, 129L, 1L, 7L, 2L, 1L, 10L, 1L, 5L, 6L, 9L,
1L, 28L, 1L, 7L, 386L, 1L, 146L, 1L, 89L, 41L, 9L, 1L, 1L, 1L,
6L, 3L, 4L, 182L, 1L, 5L, 8L, 2L, 1L, 1L, 4L, 1L, 1L, 2L, 3L,
2L, 524L, 4L, 26L, 1L, 152L, 4L, 2L, 3L, 1L, 2L, 2L, 1L, 5L,
10L, 142L, 1L, 1L, 8L, 1L, 3L, 1L, 1L, 1L, 1L, 7L, 4L, 13L, 3L,
375L, 3L, 2L, 147L, 1L, 101L, 29L, 4L, 1L, 1L, 2L, 3L, 1L, 1L,
2L, 1L, 7L, 5L, 5L, 224L, 3L, 12L, 1L, 7L, 2L, 1L, 4L, 141L,
4L, 632L, 2L, 2L, 32L, 1L, 138L, 1L, 1L, 9L, 5L, 1L, 1L, 1L,
2L, 1L, 6L, 3L, 139L, 4L, 1L, 9L, 1L, 1L, 5L, 9L, 8L, 36L, 1L,
537L, 1L, 2L, 5L, 3L, 174L, 1L, 106L, 39L, 9L, 2L, 2L, 2L, 3L,
1L, 6L, 3L, 2L, 689L, 1L, 14L, 2L, 2L, 35L, 1L, 15L, 1L, 1L,
1L, 3L, 20L, 465L, 1L, 3269L, 1L, 2L, 1L, 9L, 1L, 32L, 6L, 2L,
293L, 1L, 3L, 1L, 11L, 2L, 1L, 9L, 10L, 1L, 1L, 1L, 1L, 1L, 2L,
7L, 2L, 433L, 1L, 4L, 1L, 1L, 3L, 19L, 1L, 2L, 1L, 1L, 12L, 1L,
4L, 1L, 1L, 3L, 37L, 10L, 88L, 6L, 1808L, 5L, 4L, 451L, 5L, 219L,
112L,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, 5L, 6L, 7L, 3L, 6L, 4L,
6L, 5L, 5L, 5L, 7L, 5L, 1L, 6L, 7L, 5L, 5L, 4L, 5L, 5L, 4L, 5L,
5L, 5L, 6L, 7L, 3L, 6L, 6L, 6L, 5L, 5L, 5L, 5L, 6L, 5L, 5L, 5L,
5L, 4L, 5L, 2L, 5L, 5L, 5L, 5L, 6L, 3L, 5L, 4L, 4L, 6L, 4L, 5L,
5L, 5L, 7L, 6L, 5L, 5L, 4L, 5L, 5L, 4L, 4L, 5L, 5L, 5L, 3L, 6L,
6L, 5L, 5L, 7L, 6L, 5L, 5L, 5L, 5L, 7L, 5L, 4L, 2L, 5L, 5L, 5L,
5L, 5L, 6L, 7L, 3L, 4L, 6L, 5L, 5L, 4L, 5L, 5L, 7L, 1L, 6L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 4L, 4L, 5L, 6L, 3L, 6L, 6L, 6L, 5L, 5L,
5L, 5L, 7L, 6L, 5L, 5L, 5L, 5L, 5L, 5L, 6L, 3L, 6L, 4L, 6L, 5L,
5L, 7L, 7L, 5L, 6L, 5L, 5L, 5L, 5L), .Label = c("Adwords", "Campañas",
"Directo", "Email", "Referencias", "SEO", "Social Media"), class = "factor")), .Names = c("date",
"sessions", "Fuentes"), class = "data.frame", row.names = c(NA,
-1724L))
My data after the summarise function:
Fuentes sessions
1 Adwords 71
2 Campa�as 280
3 Directo 11610
4 Email 437
5 Referencias 13143
6 SEO 39837
7 Social Media 5981
Howcome my shiny code does not print right my plot?
1) when used within Shiny, the label appears like blured:
do a summarise before plotting (see code below):
server.R file:
library(ggplot2)
library(dplyr)
require(scales)
Visitas_Por_Fuente <- read.csv("D:\\RCoursera\\Movistar-App-2\\Visitas_Por_Fuente_Dic.csv")
labelsF = c("Directo", "Email", "Referencias", "SEO", "Social Media", "Campañas", "Adwords")
Visitas_Por_Fuente$date <- as.Date(Visitas_Por_Fuente$date)
shinyServer(
function(input, output) {
output$VisitasFuente <- renderPlot({
# Filter the data based on user selection month
date_seq <- seq(input$dates[1], input$dates[2], by = "day")
VisitasData <- filter(Visitas_Por_Fuente, date %in% date_seq & Fuentes %in% labelsF)
VisitasData %>% group_by(Fuentes) %>%
summarise(sessions = sum(sessions))
ggplot(VisitasData, aes(factor(Fuentes), sessions, fill = Fuentes)) +
geom_bar(stat="identity", position = "dodge") +
geom_text(aes(label = comma(sessions)), position=position_dodge(width=0.9), vjust=-0.25) +
scale_fill_manual(breaks = c("0", "1", "3", "6", "9", "12", "15"),
labels = labelsF,
values = c("#E69F00", "#56B4E9", "#009E73",
"#F0E442", "#0072B2", "#A082F8", "#F072A2"))
})
})
2) Then i use the same code, but not within shiny, just ggplot2 code:
ggplot(VisitasData, aes(factor(Fuentes), sessions, fill = Fuentes)) +
geom_bar(stat="identity", position = "dodge") +
geom_text(aes(label = comma(sessions)), position=position_dodge(width=0.9), vjust=-0.25) +
scale_fill_manual(breaks = c("0", "1", "3", "6", "9", "12", "15"),
labels = labelsF,
values = c("#E69F00", "#56B4E9", "#009E73",
"#F0E442", "#0072B2", "#A082F8", "#F072A2"))
And get what i need:
I also tried, using a reactive function (as recommended in comments), but got:
Error : ggplot2 doesn't know how to deal with data of class reactive
Googled that and found:
http://stackoverflow.com/questions/27771691/many-error-signs-when-running-ggplot-in-render-plot-shiny-in-general
But now,prints a blank sheet:
This is my code with the reactive function:
function(input, output) {
dataSeq <- reactive({
date_seq <- seq(input$dates[1], input$dates[2], by = "day")
})
VisitasData <- reactive({
VisitasData <- filter(Visitas_Por_Fuente, date %in% dataSeq & Fuentes %in% labelsF)
VisitasData %>% group_by(Fuentes) %>%
summarise(sessions = sum(sessions))
})
output$VisitasFuente <- renderPlot({
# Bar graph using ggplot2 library
ggplot(ggplot(selectedData(VisitasData), aes(factor(VisitasData$Fuentes), VisitasData$sessions,
fill = Fuentes)) +
geom_bar(stat="identity", position = "dodge") +
geom_text(aes(label = comma(sessions)), position=position_dodge(width=0.9), vjust=-0.25) +
scale_fill_manual(breaks = c("0", "1", "3", "6", "9", "12", "15"),
labels = labelsF,
values = c("#E69F00", "#56B4E9", "#009E73",
"#F0E442", "#0072B2", "#A082F8", "#F072A2"))
})
})
Assuming you want those numbers that showed up in your first call
Fuentes sessions
1 Adwords 71
2 Campa�as 280
3 Directo 11610
4 Email 437
5 Referencias 13143
6 SEO 39837
7 Social Media 5981
You just made a little mistake here:
VisitasData %>% group_by(Fuentes) %>%
summarise(sessions = sum(sessions))
You made a new dataframe, but you didn't assign it to anything. What you want is:
VisitasData <- VisitasData %>% group_by(Fuentes) %>%
summarise(sessions = sum(sessions))
Then you don't need to do a reactive thing, just used the code you did when you first posted it above.
library(ggplot2)
library(dplyr)
require(scales)
Visitas_Por_Fuente <- read.csv("D:\\RCoursera\\Movistar-App-2\\Visitas_Por_Fuente_Dic.csv")
labelsF = c("Directo", "Email", "Referencias", "SEO", "Social Media", "Campañas", "Adwords")
Visitas_Por_Fuente$date <- as.Date(Visitas_Por_Fuente$date)
shinyServer(
function(input, output) {
output$VisitasFuente <- renderPlot({
# Filter the data based on user selection month
date_seq <- seq(input$dates[1], input$dates[2], by = "day")
VisitasData <- filter(Visitas_Por_Fuente, date %in% date_seq & Fuentes %in% labelsF)
VisitasData <- VisitasData %>% group_by(Fuentes) %>%
summarise(sessions = sum(sessions))
# Bar graph using ggplot2 library
ggplot(VisitasData, aes(factor(Fuentes), sessions, fill = Fuentes)) +
geom_bar(stat="identity", position = "dodge") +
geom_text(aes(label = comma(sessions)), position=position_dodge(width=0.9), vjust=-0.25) +
scale_fill_manual(breaks = c("0", "1", "3", "6", "9", "12", "15"),
labels = labelsF,
values = c("#E69F00", "#56B4E9", "#009E73",
"#F0E442", "#0072B2", "#A082F8", "#F072A2"))
})
})
Is this what you intended?
Related
How to create histograms for each unique combination of levels from two factors?
I cannot figure out how to use a loop to plot one histogram for each unique combination of levels from TWO factors. Here is my data: https://www.dropbox.com/sh/exsjhu23fnpwf4r/AABvitLBN1nRMpXcyYMVIOIDa?dl=0 # perhaps need to have factors df$freq <- as.factor(df$freq) df$time <- as.factor(df$time) I learned how to use a loop to plot histograms for ONE factor levels: # space for plots windows(width=19, height=10) par(las=1, cex.lab=0.75, cex.axis=0.6, bty="n", mgp=c(1, 0.6, 0), oma=c(2, 4, 2, 0) + 0.1, mar=c(4, 0, 3, 3) + 0.1) a <- layout(matrix(c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21), nrow=3, ncol=7, byrow=T)) layout.show(a) # loop for (i in 1:length(unique(df$freq))) { value <- subset(df, freq == unique (df$freq)[i]) hist(value$thr, main=paste0("freq: ", unique(df$freq)[i])) } I tried variations of this loop for TWO factors but that unfortunately does not work: for (i in 1:length(unique(df[c("freq", "time")]))) { value <- subset(df, freq == unique (df$freq)[i] & time == unique(df$time)[i]) hist(value$thr, main=paste0("freq: ", unique(df$freq)[i])) } I would also like to learn how to label each histogram based on the levels of TWO factors (not just one)...
It's more convenient to use by here. For the titles we prefer characters to factors. df1[c("freq", "time")] <- lapply(df1[c("freq", "time")], as.character) Then open windows, windows(width=19, height=10) par(las=1, cex.lab=0.75, cex.axis=0.6, bty="n", mgp=c(1, 0.6, 0), oma=c(2, 4, 2, 0) + 0.1, mar=c(4, 0, 3, 3) + 0.1) a <- layout(matrix(1:21, 3, 7)) layout.show(a) and plot. by(df1, df1[c("freq", "time")], function(x) hist(x$thr, main=paste("freq:", paste(x[1, c(1, 3)], collapse=",")))) Result Edit To get the specific order we probably have to do some more stuff. df1[c("freq", "time")] <- lapply(df1[c("freq", "time")], as.character) windows(width=19, height=10) par(las=1, cex.lab=0.75, cex.axis=0.6, bty="n", mgp=c(1, 0.6, 0), oma=c(2, 4, 2, 0) + 0.1, mar=c(4, 0, 3, 3) + 0.1) a <- layout(matrix(1:21, 3, 7, byrow=TRUE)) # with byrow layout.show(a) l <- split(df1, df1[c("freq", "time")]) m <- t(sapply(l, function(x) x[1, c(1, 3)])) # matrix of first rows of each subset m[, 2] <- sub("m", "", m[, 2]) # use the values... m <- apply(m, 1:2, as.numeric) # ... make numeric Now we obtain the histograms within a lapply over the list ordered by m. lapply(l[order(m[, 2], m[, 1])], function(x) hist(x$thr, main=paste("freq:", paste(x[1, c(1, 3)], collapse=",")))) New Result Data df1 <- structure(list(freq = structure(c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L), .Label = c("4", "8", "12.5", "16", "20", "25", "31.5"), class = "factor"), thr = c(60L, 25L, 20L, 15L, 15L, 30L, 35L, 60L, 25L, 10L, 15L, 15L, 30L, 35L, 55L, 30L, 15L, 15L, 10L, 25L, 40L, 50L, 25L, 15L, 10L, 15L, 20L, 40L, 50L, 30L, 10L, 15L, 15L, 20L, 25L, 50L, 25L, 10L, 10L, 10L, 20L, 25L, 45L, 20L, 10L, 10L, 10L, 20L, 25L, 45L, 15L, 10L, 10L, 10L, 20L, 30L, 60L, 30L, 10L, 10L, 10L, 15L, 30L, 50L, 25L, 10L, 10L, 10L, 20L, 30L, 45L, 25L, 15L, 10L, 15L, 30L, 35L, 50L, 25L, 15L, 10L, 15L, 25L, 35L, 60L, 25L, 10L, 10L, 15L, 20L, 30L, 60L, 25L, 5L, 5L, 10L, 20L, 30L, 45L, 20L, 5L, 10L, 10L, 20L, 30L, 45L, 20L, 10L, 10L, 10L, 20L, 30L, 60L, 30L, 15L, 10L, 15L, 25L, 30L, 55L, 25L, 10L, 10L, 10L, 20L, 30L, 55L, 35L, 10L, 10L, 10L, 20L, 30L, 60L, 35L, 15L, 10L, 10L, 15L, 25L, 50L, 30L, 10L, 10L, 10L, 20L, 25L, 55L, 25L, 10L, 10L, 15L, 25L, 25L, 65L, 30L, 10L, 10L, 15L, 20L, 30L, 60L, 30L, 15L, 15L, 15L, 15L, 30L, 55L, 35L, 15L, 15L, 15L, 25L, 35L, 55L, 35L, 15L, 15L, 15L, 25L, 35L, 60L, 35L, 15L, 15L, 15L, 25L, 35L, 60L, 30L, 10L, 10L, 15L, 25L, 35L, 55L, 30L, 15L, 10L, 10L, 25L, 30L, 50L, 25L, 10L, 10L, 10L, 20L, 30L, 55L, 30L, 10L, 10L, 15L, 20L, 30L, 55L, 30L, 10L, 15L, 20L, 25L, 35L, 55L, 25L, 15L, 15L, 15L, 25L, 40L, 50L, 20L, 10L, 10L, 20L, 30L, 40L, 45L, 25L, 10L, 10L, 10L, 20L, 30L, 50L, 25L, 10L, 10L, 10L, 20L, 25L, 55L, 20L, 10L, 10L, 15L, 25L, 35L, 50L, 20L, 10L, 10L, 15L, 25L, 30L, 45L, 20L, 15L, 10L, 10L, 20L, 30L, 50L, 20L, 15L, 15L, 15L, 20L, 30L, 60L, 35L, 15L, 10L, 15L, 25L, 30L, 60L, 35L, 15L, 15L, 15L, 30L, 35L, 55L, 25L, 10L, 15L, 15L, 25L, 35L, 50L, 30L, 10L, 15L, 15L, 25L, 35L, 55L, 25L, 20L, 15L, 15L, 25L, 30L, 55L, 25L, 15L, 15L, 15L, 30L, 35L), time = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L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322L), class = "data.frame")
Put a title of plot inside a for loop
I have a code with a nested for loop that runs perfect and gives me 4X4 plots in a page. I need to insert the title in each plot. Below is my code. What I wanted to do is create a vector and assign my titles inside it, as shown in code and then read it inside loop. For that, I need to convert the index i into number and use the position of second vector. This is my approach which may not be that good so either you can use mine or give your own idea. You can play with any random datasets and use simple plot/histogram. The vectors represent the day of week and time of day respectively. #set dimension par(mfcol=c(4,4)) #vector definition days<-c(1,2,3,4) hours<-c(8,14,18,22) #Title vector D1<-c("Monday (7-8 am)","Monday (1-2 pm)","Monday (5-6 pm)", "Monday (9-10 pm)") D2<-c("Wednesday (7-8 am)","Wednesday (1-2 pm)","Wednesday (5-6 pm)", "Wednesday (9-10 pm)") D3<-c("Friday (7-8 am)","Friday (1-2 pm)","Friday (5-6 pm)", "Friday (9-10 pm)") D4<-c("Saturday (7-8 am)","Saturday (1-2 pm)","Saturday (5-6 pm)", "Saturday (9-10 pm)") #Loop for (i in days) { for (j in hours) { # set positioning of the histogram par("plt" = c(0.2,0.95,0.35,0.84)) # plot the histogram hist(path$TT[path$days==i & path$hours==j], breaks = seq(0,60,by=3), xlab="Travel Time", ylab="Number of paths",col="blue", **main=D??**, mgp=c(2.5,1,0)) } } here is data sample-> dput(path) structure(list(days = c(1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 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13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L), TT = c(34.82720833, 34.13870083, 30.59218805, 35.1616205, 34.87982204, 30.74262596, 35.19981237, 35.14235172, 31.6716496, 29.84148401, 31.32268062, 30.58250275, 35.26514263, 33.55230269, 34.97001136, 31.09735713, 29.90509108, 33.78335499, 33.08419061, 33.9702478, 32.68267307, 32.88848951, 30.16693345, 32.85994732, 30.83277565, 34.62568305, 34.13923292, 33.50498645, 31.31095608, 34.31001321, 33.99902318, 33.7909643, 34.33340843, 32.30046602, 34.74999297, 29.87097318, 32.91255436, 30.37869556, 35.22453148, 33.91415576, 30.87027627, 34.32036758, 34.14405484, 32.52770687, 30.63412371, 30.69590367, 34.10350198, 33.51383263, 31.19792969, 35.26664132, 33.79975778, 30.9254123, 33.58382797, 32.47180323, 35.07275967, 30.97518331, 34.09754282, 31.30283331, 35.03617718, 35.0447385, 34.48088429, 34.93546837, 30.97837093, 31.14469741, 30.92743268, 34.10879646, 30.4886625, 35.00307314, 31.41065689, 31.82113768, 30.38511722, 30.39628127, 31.89778508, 31.5036342, 30.78847263, 30.63294595, 34.40494811, 32.57036077, 31.96399169, 33.90064885, 31.64029012, 34.1366935, 35.24047602, 30.50038163, 35.26178882, 30.67850437, 31.28041078, 31.13586861, 34.03564851, 30.45301463, 31.46075363, 32.79463877, 34.37256141, 31.14590299, 32.98806056, 34.61871373, 34.50000295, 33.64822723, 31.79305995, 32.95337037, 31.97535842, 33.01756184, 30.27499142, 31.52636985, 33.88390737, 29.86033691, 33.10717421, 31.13912362, 34.03308637, 29.82060846, 30.29160216, 30.68720702, 32.21043532, 32.38637581, 29.87286573, 31.91229798, 33.07799897, 30.41662694, 32.24261367, 35.3258724, 29.81198078, 29.87369792, 29.5469277, 31.07479327, 29.93749303, 31.32897414, 32.11042476, 31.74139691, 29.35309499, 31.91510643, 28.43111183, 30.64316778, 28.82045246, 31.2966231, 32.88217249, 28.85142648, 32.61772627, 28.89998879, 29.09439029, 31.17275104, 30.14374991, 32.54361297, 30.50674627, 32.01595442, 30.50549694, 30.92120556, 28.56600115, 32.6272292, 32.01189691, 32.48467475, 32.63696512, 30.92335971, 31.05045202, 30.7754939, 31.40027579, 29.12356583, 31.77973836, 28.78119827, 31.44082345, 30.73383322, 32.04126499, 30.09865077, 32.23577216, 29.08265343, 30.49423226, 31.46262176, 29.84828538, 30.18785884, 29.51834908, 29.37202672, 31.50806652, 32.40830835, 30.48030326, 31.25898945, 28.36670284, 31.28059981, 29.34232677, 30.09806882, 32.11127774, 29.59171523, 30.61713837, 29.76958526, 31.85824615, 32.16215903, 29.84655136, 31.07721122, 28.65494456, 30.9843114, 32.54863022, 31.46634971, 31.89779842, 32.82481805, 32.14782935, 32.08964421, 31.60785849, 32.91857557, 31.71183437, 31.81246841, 32.98599723, 28.95747656, 28.84662181, 31.71611474, 31.62086303, 32.53920721, 30.42499004, 28.99300588, 29.61203445, 32.4920689, 29.36255767, 32.6194317, 31.04202451, 28.75123245, 30.13704325, 30.92045914, 32.57753631, 30.83279548, 28.8546849, 30.74245368, 29.03716971, 28.37275181, 30.86814322, 30.61960665, 30.42719574, 30.27684903, 32.91275304, 29.80632759, 29.50108563, 32.6131215, 30.03530353, 30.24898855, 29.97890411, 29.91508311, 30.66431902, 29.44062756, 30.78040092, 30.42641885, 32.52252736, 32.02849124, 28.44168133, 28.77193919, 32.3661733, 32.50081923, 30.78754405, 29.31429942, 29.25319403, 29.41670938, 34.79250707, 28.45292865, 33.30658009, 36.95793072, 31.1241599, 29.47446652, 37.93368226, 29.99169743, 34.53286071, 33.30080173, 32.07298455, 34.59538339, 33.19895485, 32.39419483, 31.37985584, 33.10293436, 29.39098815, 29.6792889, 35.03296983, 37.90584009, 30.95003357, 33.20300797, 37.19244019, 35.17202829, 33.36301054, 35.45811104, 32.30603702, 35.90719466, 32.53788221, 32.98462237, 34.40384647, 34.60599035, 36.12782575, 34.22463048, 29.98624712, 35.806683, 36.85504472, 35.98104837, 35.97362738, 35.43026929, 29.52289309, 29.0544412, 28.38438112, 29.31043103, 34.55714132, 31.35110246, 35.45463173, 32.52063466, 29.64833452, 31.74827447, 31.19599864, 35.86874035, 31.36035725, 30.90048731, 36.67327499, 30.0504123, 37.41148645, 33.68205359, 29.2592527, 28.82514246, 30.62364715, 37.55578321, 32.25899523, 34.31735337, 37.1286007, 30.09667053, 37.77301539, 37.28325032, 33.82381014, 33.64911154, 32.23733708, 35.36476734, 31.19880018, 29.1404291, 30.72636631, 34.77003685, 37.31098961, 31.55246022, 28.51524079, 35.97250119, 35.08409392, 36.5458489, 37.35540297, 30.23406879, 29.17387163, 33.74088357, 29.40765925, 29.98726349, 29.58959745, 31.96605073, 31.94788415, 33.60347166, 28.43148601, 29.65454367, 36.06816061, 29.96597865, 31.90935292, 28.59771444, 32.44428733, 31.50734498, 30.23029062, 32.7213003, 33.17963215, 30.84546259, 35.61594726, 31.1375163, 33.58903731, 36.3755896, 30.15521544, 32.64832733, 29.75419547, 32.87727257, 32.86349263, 30.87051665, 34.99052692, 29.32459293, 29.75063939, 29.31336196, 30.26155711, 37.78471798, 29.29637466, 33.63983534, 29.0707227, 37.23740461, 30.46483145, 32.5191104, 32.38759822, 35.67256593, 31.96392716, 33.3250217, 35.46341363, 28.75439972, 33.2611733, 30.02014914, 35.78496489, 32.96781502, 31.43534921, 35.07596123, 34.52762462, 30.26655854, 35.32014083, 37.55183466, 34.14971103, 36.29105196, 32.40044715, 36.0587327, 31.83769864, 33.92873059, 34.70263617, 30.80816039, 30.68630199, 31.01802064, 30.80777532, 35.05333618, 27.06058834, 27.79241831, 27.33752079, 27.77903509, 26.947812, 27.8862964, 27.39365377, 27.9236377, 26.78983708, 27.98767273, 27.93024624, 27.84690108, 27.32830243, 26.81574528, 27.11055277, 27.39296015, 28.00610613, 27.71688355, 27.62271524, 27.69926561, 26.77071774, 26.75407601, 27.54772857, 26.85613667, 27.43762662, 27.45478206, 27.70204762, 27.66985159, 27.46593956, 28.00153523, 27.85391116, 26.78324156, 27.51476443, 27.54375831, 27.45536832, 27.25299275, 27.42563343, 27.35861323, 27.89703515, 27.94359525, 27.02701474, 28.01213784, 27.05632904, 27.219231, 28.00160216, 27.06621867, 26.83356071, 26.85138171, 26.9857268, 26.84488214, 27.04212578, 27.90226659, 26.88270484, 27.36445874, 27.98903653, 26.74879158, 27.91409337, 27.04442553, 27.76393403, 26.97261286, 26.82558533, 27.40286709, 26.90959192, 27.61358064, 27.67649126, 27.98923329, 27.27538051, 27.93429854, 27.24070111, 27.79609001, 27.51659686, 27.60029289, 26.85518925, 27.31821322, 27.1642527, 27.27570585, 27.67152235, 26.96014272, 27.89962397, 27.84824436)), .Names = c("days", "hours", "TT"), class = "data.frame", row.names = c(NA, -480L ))
It seems like you have 4*4=16 plots, with 16 titles in 4 vectors. Try this argument in your function, main=get(paste0("D",i))[which(hours==j)] get()function can get the object with the given object name. I use some simulated data, just to check the titles. Looks good, Sample codes: x<-rnorm(50)#my simulated data for (i in days) { for (j in hours) { hist(x,xlab="Travel Time", ylab="Number of paths",col="blue", main=get(paste0("D",i))[which(hours==j)], mgp=c(2.5,1,0)) } }
This is revised to match the data that was provided. The main idea here is to make a matrix of the titles and simply access the matrix each time you print. The code in the question looped through hours and days. Because I want to know the index, I have change this to looping through the indices, 1:4. That means that where the original code used the loop variable (hours or days) I use the index to select elements from hours or days. I am assuming that we already have the data.frame and the OP's lists D1, D2, D3 and D4. LabelMat = matrix(c(D1, D2, D3, D4), nrow=4) for (i in 1:4) { for (j in 1:4) { # set positioning of the histogram par("plt" = c(0.2,0.95,0.35,0.84)) # plot the histogram hist(path$TT[path$days==days[i] & path$hours==hours[j]], breaks = seq(0,60,by=3), xlab="Travel Time", ylab="Number of paths", col="blue", main = LabelMat[i,j], mgp=c(2.5,1,0)) } }
R: Shiny - How to subset and then make a bargraph based on daterangeInput
i've this data frame: date sessions Fuentes 1 2014-12-01 197 Directo 2 2014-12-01 1 Referencias 3 2014-12-01 7 Social Media 4 2014-12-01 13 SEO 5 2014-12-01 1 Email 6 2014-12-01 1 Referencias This is the data after using dput(): structure(list(date = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 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11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 28L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 29L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L), .Label = c("2014-12-01", "2014-12-02", "2014-12-03", "2014-12-04", "2014-12-05", "2014-12-06", "2014-12-07", "2014-12-08", "2014-12-09", "2014-12-10", "2014-12-11", "2014-12-12", "2014-12-13", "2014-12-14", "2014-12-15", "2014-12-16", "2014-12-17", "2014-12-18", "2014-12-19", "2014-12-20", "2014-12-21", "2014-12-22", "2014-12-23", "2014-12-24", "2014-12-25", "2014-12-26", "2014-12-27", "2014-12-28", "2014-12-29", "2014-12-30", "2014-12-31" ), class = "factor"), sessions = c(197L, 1L, 7L, 13L, 1L, 1L, 10L, 1L, 3L, 3L, 5L, 3L, 566L, 1L, 27L, 159L, 7L, 1L, 6L, 1L, 1L, 4L, 1L, 6L, 10L, 129L, 1L, 7L, 2L, 1L, 10L, 1L, 5L, 6L, 9L, 1L, 28L, 1L, 7L, 386L, 1L, 146L, 1L, 89L, 41L, 9L, 1L, 1L, 1L, 6L, 3L, 4L, 182L, 1L, 5L, 8L, 2L, 1L, 1L, 4L, 1L, 1L, 2L, 3L, 2L, 524L, 4L, 26L, 1L, 152L, 4L, 2L, 3L, 1L, 2L, 2L, 1L, 5L, 10L, 142L, 1L, 1L, 8L, 1L, 3L, 1L, 1L, 1L, 1L, 7L, 4L, 13L, 3L, 375L, 3L, 2L, 147L, 1L, 101L, 29L, 4L, 1L, 1L, 2L, 3L, 1L, 1L, 2L, 1L, 7L, 5L, 5L, 224L, 3L, 12L, 1L, 7L, 2L, 1L, 4L, 141L, 4L, 632L, 2L, 2L, 32L, 1L, 138L, 1L, 1L, 9L, 5L, 1L, 1L, 1L, 2L, 1L, 6L, 3L, 139L, 4L, 1L, 9L, 1L, 1L, 5L, 9L, 8L, 36L, 1L, 537L, 1L, 2L, 5L, 3L, 174L, 1L, 106L, 39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, 5L, 4L, 2L, 5L, 5L, 5L, 4L, 4L, 5L, 5L, 4L, 6L, 3L, 6L, 6L, 6L, 5L, 5L, 5L, 5L, 7L, 5L, 6L, 5L, 5L, 7L, 5L, 5L, 5L, 2L, 2L, 5L, 5L, 5L, 5L, 5L, 6L, 3L, 6L, 4L, 4L, 5L, 4L, 5L, 6L, 5L, 5L, 5L, 4L, 5L, 5L, 5L, 5L, 4L, 2L, 5L, 5L, 4L, 4L, 6L, 3L, 6L, 6L, 5L, 5L, 5L, 7L, 6L, 5L, 5L, 5L, 5L, 5L, 4L, 2L, 5L, 5L, 5L, 5L, 5L, 6L, 7L, 3L, 6L, 4L, 6L, 5L, 5L, 5L, 7L, 5L, 1L, 6L, 7L, 5L, 5L, 4L, 5L, 5L, 4L, 5L, 5L, 5L, 6L, 7L, 3L, 6L, 6L, 6L, 5L, 5L, 5L, 5L, 6L, 5L, 5L, 5L, 5L, 4L, 5L, 2L, 5L, 5L, 5L, 5L, 6L, 3L, 5L, 4L, 4L, 6L, 4L, 5L, 5L, 5L, 7L, 6L, 5L, 5L, 4L, 5L, 5L, 4L, 4L, 5L, 5L, 5L, 3L, 6L, 6L, 5L, 5L, 7L, 6L, 5L, 5L, 5L, 5L, 7L, 5L, 4L, 2L, 5L, 5L, 5L, 5L, 5L, 6L, 7L, 3L, 4L, 6L, 5L, 5L, 4L, 5L, 5L, 7L, 1L, 6L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 4L, 4L, 5L, 6L, 3L, 6L, 6L, 6L, 5L, 5L, 5L, 5L, 7L, 6L, 5L, 5L, 5L, 5L, 5L, 5L, 6L, 3L, 6L, 4L, 6L, 5L, 5L, 7L, 7L, 5L, 6L, 5L, 5L, 5L, 5L), .Label = c("Adwords", "Campañas", "Directo", "Email", "Referencias", "SEO", "Social Media"), class = "factor")), .Names = c("date", "sessions", "Fuentes"), class = "data.frame", row.names = c(NA, -1724L)) In a Shiny App, want to plot bars for Fuentes, acording to a data range specified by the user. I use daterangeInput in my ui.R, but cannot get it to plot what I need. My ui.R library(shiny) # Define the overall UI shinyUI( # Use a fluid Bootstrap layout fluidPage( # Give the page a title br(), br(), titlePanel("Visitas por fuente"), # Generate a row with a sidebar sidebarLayout( # Define the sidebar with one input sidebarPanel( dateRangeInput("dates", label = h3("Date range"), start = "2014-12-01", end = "2014-12-31") ), # Create a spot for the barplot mainPanel( plotOutput("VisitasFuente") ) ) ) ) My server.R ### Edited - Now can plot, but labels appeare as a blur from botton to top. library(ggplot2) library(dplyr) require(scales) Visitas_Por_Fuente <- read.csv("D:\\RCoursera\\Movistar- App-2\\Visitas_Por_Fuente_Dic.csv") labels = c("Directo", "Email", "Referencias", "SEO", "Social Media") Visitas_Por_Fuente$date <- as.Date(Visitas_Por_Fuente$date) shinyServer( function(input, output) { output$VisitasFuente <- renderPlot({ # Filter the data based on user selection month date_seq <- seq(input$dates[1], input$dates[2], by = "day") #VisitasData <- filter(Visitas_Por_Fuente, date >= input$dates[1], # date <= input$dates[2]) VisitasData <- filter(Visitas_Por_Fuente, date %in% date_seq & Fuentes %in% labels) # Bar graph using ggplot2 library ggplot(VisitasData, aes(factor(Fuentes), sessions, fill = Fuentes)) + geom_bar(stat="identity", position = "dodge") + geom_text(aes(label = comma(sessions)), position=position_dodge(width=0.9), vjust=-0.25) + scale_fill_manual(breaks = c("0", "1", "3", "6", "9"), labels = c("Directo", "Email", "References", "SEO", "Social Media"), values = c("#E69F00", "#56B4E9", "#009E73", "#F0E442", "#0072B2")) }) }) This was fixied by loading the corresponded packages Thanks to #goodtimeslim, i've made the recomendations you gave me. But now i get: Error in match(x, table, nomatch = 0L) : 'match' requires vector arguments What could it be? Thanks again. #
Okay, first thing, you need to tell R that Visitas_Por_Fuente$date is a date, with Visitas_Por_Fuente$date <- as.Date(Visitas_Por_Fuente$date) . You can do this right after you import your data at the beginning. Now you want to create a range of dates, in your server file, using the date inputs, like so: date_seq <- seq(input$dates[1], input$dates[2], by = "day") Now you just need to change your filter, so that the date is in that sequence, like so: VisitasData <- filter(Visitas_Por_Fuente, date %in% date_seq) Now I admit that doesn't solve everything, I was getting some weird errors with your ggplot code, but this will solve the subsetting issue. This issue with your ggplot is that your data has 7 variables, but you're only giving it information for 5. If you just want those 5 variables, then at the top (right after you import your data), write this: labels = c("Directo", "Email", "References", "SEO", "Social Media") and then, for your plot, get rid of the scale_manual line and replace it with: scale_x_discrete(limit = labels) That'll force those 5 on there, and at the moment, it'll do it in whatever color R wants. I'll let you figure out the rest if you want to change it. Let me know if this is clear enough or if you just want the whole server.r code. edit: Okay, I fixed it. You had an error in your code, you have "References", but in your data, it's "Referencias". So now, assuming you still want those five variables only, and not all 7, do this: change labels (at the top) like so: labels = c("Directo", "Email", "Referencias", "SEO", "Social Media") Change your filter like so: VisitasData <- filter(Visitas_Por_Fuente, date %in% date_seq & Fuentes %in% labels) Then you can get rid of that scale_x_discrete line I had, and put your line back in. It should all work now. (Except edit your labels in the manual_scale part to reflect the proper "Referencias". edit 2: Here's the full server.r that runs just fine on my computer. I've made some slight changes for consistency/clarity, but otherwise it's mostly the same. library(ggplot2) Visitas_Por_Fuente <- read.csv("visitas.csv") ## put your path here labelsF = c("Directo", "Email", "Referencias", "SEO", "Social Media") Visitas_Por_Fuente$date <- as.Date(Visitas_Por_Fuente$date) shinyServer( function(input, output) { output$VisitasFuente <- renderPlot({ # Filter the data based on user selection month date_seq <- seq(input$dates[1], input$dates[2], by = "day") #VisitasData <- filter(Visitas_Por_Fuente, date >= input$dates[1], # date <= input$dates[2]) VisitasData <- filter(Visitas_Por_Fuente, date %in% date_seq & Fuentes %in% labelsF) # Bar graph using ggplot2 library ggplot(VisitasData, aes(factor(Fuentes), sessions, fill = Fuentes)) + geom_bar(stat="identity", position = "dodge") + scale_fill_manual(breaks = c("0", "1", "3", "6", "9"), labels = labelsF, values = c("#E69F00", "#56B4E9", "#009E73", "#F0E442", "#0072B2")) }) })
Use dplyr to find genotype frequency across SNPs
To find genotype frequency across SNPs I need to find the proportion of a certain genotype (XX, YX, or YY) in the total number of samples (XX, YX, and YY). I think I would need to start my dplyr statement with dat %>% group_by(Assay) %>% but I don't know how to finish it. The data, dat, provided below and dput at the bottom. Source: local data frame [143 x 3] Groups: Assay Assay Final n 1 One_apoe-83 Invalid 2 2 One_apoe-83 No Call 9 3 One_apoe-83 NTC 2 4 One_apoe-83 XX 4 5 One_apoe-83 YX 41 6 One_apoe-83 YY 134 7 One_CD9-269 Invalid 2 8 One_CD9-269 No Call 5 9 One_CD9-269 NTC 2 10 One_CD9-269 XX 99 .. ... ... ... I could use a for loop across SNPs to get what I'm looking for with boolean patterning for each genotype but that would be very verbose. for(i in seq(levels(dat$Assay))) { storage_df[i,1] <- dat[dat$Assay == levels(dat$Assay)[i],]$XX / (dat[dat$Assay == levels(dat$Assay)[i],]$XX + dat[dat$Assay == levels(dat$Assay)[i],]$YX + dat[dat$Assay == levels(dat$Assay)[i],]$XY) ... You get the point. How would I do this in dplyr? The whole object is below. dat <- structure(list(Assay = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L, 8L, 8L, 9L, 9L, 9L, 9L, 9L, 9L, 10L, 10L, 10L, 10L, 10L, 10L, 11L, 11L, 11L, 11L, 11L, 11L, 12L, 12L, 12L, 12L, 12L, 12L, 13L, 13L, 13L, 13L, 13L, 13L, 14L, 14L, 14L, 14L, 14L, 14L, 15L, 15L, 15L, 15L, 15L, 15L, 16L, 16L, 16L, 16L, 16L, 16L, 17L, 17L, 17L, 17L, 17L, 17L, 18L, 18L, 18L, 18L, 18L, 18L, 19L, 19L, 19L, 19L, 19L, 19L, 20L, 20L, 20L, 20L, 20L, 20L, 21L, 21L, 21L, 21L, 21L, 21L, 22L, 22L, 22L, 22L, 22L, 22L, 23L, 23L, 23L, 23L, 23L, 23L, 24L, 24L, 24L, 24L, 24L, 24L), .Label = c("One_apoe-83", "One_CD9-269", "One_Cytb_26", "One_E2", "One_ghsR-66", "One_IL8r-362", "One_KPNA-422", "One_lpp1-44", "One_MHC2_190", "One_MHC2_251", "One_Prl2", "One_redd1-414", "One_STC-410", "One_STR07", "One_sys1-230", "One_U1004-183", "One_U1105", "One_U1201-492", "One_U1203-175", "One_U1209-111", "One_U1212-106", "One_U401-224", "One_vamp5-255", "One_ZNF-61"), class = "factor"), Final = structure(c(1L, 2L, 3L, 4L, 5L, 6L, 1L, 2L, 3L, 4L, 5L, 6L, 1L, 2L, 3L, 4L, 6L, 1L, 2L, 3L, 4L, 5L, 6L, 1L, 2L, 3L, 4L, 5L, 6L, 1L, 2L, 3L, 4L, 5L, 6L, 1L, 2L, 3L, 4L, 5L, 6L, 1L, 2L, 3L, 4L, 5L, 6L, 1L, 2L, 3L, 4L, 5L, 6L, 1L, 2L, 3L, 4L, 5L, 6L, 1L, 2L, 3L, 4L, 5L, 6L, 1L, 2L, 3L, 4L, 5L, 6L, 1L, 2L, 3L, 4L, 5L, 6L, 1L, 2L, 3L, 4L, 5L, 6L, 1L, 2L, 3L, 4L, 5L, 6L, 1L, 2L, 3L, 4L, 5L, 6L, 1L, 2L, 3L, 4L, 5L, 6L, 1L, 2L, 3L, 4L, 5L, 6L, 1L, 2L, 3L, 4L, 5L, 6L, 1L, 2L, 3L, 4L, 5L, 6L, 1L, 2L, 3L, 4L, 5L, 6L, 1L, 2L, 3L, 4L, 5L, 6L, 1L, 2L, 3L, 4L, 5L, 6L, 1L, 2L, 3L, 4L, 5L, 6L), .Label = c("Invalid", "No Call", "NTC", "XX", "YX", "YY"), class = "factor"), n = c(2L, 9L, 2L, 4L, 41L, 134L, 2L, 5L, 2L, 99L, 75L, 9L, 2L, 7L, 2L, 110L, 71L, 2L, 8L, 2L, 110L, 59L, 11L, 2L, 6L, 2L, 67L, 86L, 29L, 2L, 3L, 2L, 152L, 28L, 5L, 2L, 4L, 2L, 78L, 81L, 25L, 2L, 4L, 2L, 115L, 62L, 7L, 2L, 17L, 2L, 80L, 62L, 29L, 2L, 13L, 2L, 59L, 68L, 48L, 2L, 7L, 2L, 48L, 86L, 47L, 2L, 7L, 2L, 42L, 87L, 52L, 2L, 3L, 2L, 47L, 81L, 57L, 2L, 9L, 2L, 40L, 85L, 54L, 2L, 8L, 2L, 52L, 86L, 42L, 2L, 7L, 2L, 9L, 39L, 133L, 2L, 8L, 2L, 101L, 71L, 8L, 2L, 13L, 2L, 20L, 82L, 73L, 2L, 11L, 2L, 27L, 75L, 75L, 2L, 6L, 2L, 3L, 40L, 139L, 2L, 13L, 2L, 59L, 82L, 34L, 2L, 19L, 2L, 20L, 84L, 65L, 2L, 11L, 2L, 119L, 47L, 11L, 2L, 8L, 2L, 51L, 100L, 29L)), class = "data.frame", .Names = c("Assay", "Final", "n"), row.names = c(NA, -143L))
Hope I am not misunderstanding. Are you looking for below: Assume the data structure is: df <- structure(list(Assay = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L), .Label = c("One_apoe-83", "One_CD9-269"), class = "factor"), Final = structure(c(1L, 2L, 3L, 4L, 5L, 6L, 1L, 2L, 3L, 4L ), .Label = c("Invalid", "No Call", "NTC", "XX", "YX", "YY" ), class = "factor"), n = c(2L, 9L, 2L, 4L, 41L, 134L, 2L, 5L, 2L, 99L)), .Names = c("Assay", "Final", "n"), class = "data.frame", row.names = c("1", "2", "3", "4", "5", "6", "7", "8", "9", "10")) Code df %>% group_by(Assay) %>% mutate(n_percent = n/sum(n)*100) # Assay Final n n_percent # 1 One_apoe-83 Invalid 2 1.041667 # 2 One_apoe-83 No Call 9 4.687500 # 3 One_apoe-83 NTC 2 1.041667 # 4 One_apoe-83 XX 4 2.083333 # 5 One_apoe-83 YX 41 21.354167 # 6 One_apoe-83 YY 134 69.791667 # 7 One_CD9-269 Invalid 2 1.851852 # 8 One_CD9-269 No Call 5 4.629630 # 9 One_CD9-269 NTC 2 1.851852 # 10 One_CD9-269 XX 99 91.666667 Option 2 Here is the code based on the comment. A line is added to filter out the elements you don't want. df %>% filter(! Final %in% c("Invalid", "No Call", "NTC")) %>% group_by(Assay) %>% mutate(n_percent = n/sum(n)*100) # Source: local data frame [4 x 4] # Groups: Assay # # Assay Final n n_percent # 1 One_apoe-83 XX 4 2.234637 # 2 One_apoe-83 YX 41 22.905028 # 3 One_apoe-83 YY 134 74.860335 # 4 One_CD9-269 XX 99 100.000000
Ggplot2 geom_line error
I have a daaset which consists of data points over a time series for the proportion of people living in urban/rural areas for a number of countries. Sadly, not all countries have data for the same years. I have been trying to produce a simple line plot to show the different proportions of people living in different locations by year, but as each country has a different number of data points I am running into trouble. I think this is because some of the countries only have data for a single year and using geom_line from ggplot2 throws the following error: geom_path: Each group consist of only one observation. Do you need to adjust the group aesthetic? I was hoping that there would be some way to override this, or perhaps just plot a single point where a COUNTRY only has data for a single year. Does anyone know if this is possible, or indeed, if this is actually what this error means?!!? Any help greatly appreciated!!! Thanks Here is my data: structure(list(COUNTRY = structure(c(1L, 2L, 2L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 5L, 5L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 9L, 9L, 9L, 9L, 9L, 10L, 11L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 13L, 13L, 13L, 13L, 14L, 14L, 14L, 14L, 1L, 2L, 2L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 5L, 5L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 9L, 9L, 9L, 9L, 9L, 10L, 11L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 13L, 13L, 13L, 13L, 14L, 14L, 14L, 14L, 1L, 2L, 2L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 5L, 5L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 9L, 9L, 9L, 9L, 9L, 10L, 11L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 13L, 13L, 13L, 13L, 14L, 14L, 14L, 14L, 1L, 2L, 2L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 5L, 5L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 9L, 9L, 9L, 9L, 9L, 10L, 11L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 13L, 13L, 13L, 13L, 14L, 14L, 14L, 14L, 1L, 2L, 2L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 5L, 5L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 9L, 9L, 9L, 9L, 9L, 10L, 11L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 13L, 13L, 13L, 13L, 14L, 14L, 14L, 14L, 1L, 2L, 2L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 5L, 5L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 9L, 9L, 9L, 9L, 9L, 10L, 11L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 13L, 13L, 13L, 13L, 14L, 14L, 14L, 14L, 1L, 2L, 2L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 5L, 5L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 9L, 9L, 9L, 9L, 9L, 10L, 11L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 13L, 13L, 13L, 13L, 14L, 14L, 14L, 14L), class = "factor", .Label = c("Comoros", "Eritrea", "Ethiopia", "Kenya", "Lesotho", "Madagascar", "Malawi", "Namibia", "Rwanda", "South Africa", "Swaziland", "Tanzania", "Zambia", "Zimbabwe")), Year = structure(c(5L, 12L, 4L, 25L, 16L, 9L, 22L, 13L, 7L, 2L, 23L, 15L, 22L, 14L, 6L, 1L, 24L, 15L, 9L, 1L, 13L, 6L, 19L, 9L, 1L, 24L, 21L, 16L, 9L, 1L, 7L, 19L, 24L, 13L, 8L, 5L, 1L, 18L, 10L, 4L, 20L, 11L, 5L, 1L, 24L, 17L, 8L, 3L, 5L, 12L, 4L, 25L, 16L, 9L, 22L, 13L, 7L, 2L, 23L, 15L, 22L, 14L, 6L, 1L, 24L, 15L, 9L, 1L, 13L, 6L, 19L, 9L, 1L, 24L, 21L, 16L, 9L, 1L, 7L, 19L, 24L, 13L, 8L, 5L, 1L, 18L, 10L, 4L, 20L, 11L, 5L, 1L, 24L, 17L, 8L, 3L, 5L, 12L, 4L, 25L, 16L, 9L, 22L, 13L, 7L, 2L, 23L, 15L, 22L, 14L, 6L, 1L, 24L, 15L, 9L, 1L, 13L, 6L, 19L, 9L, 1L, 24L, 21L, 16L, 9L, 1L, 7L, 19L, 24L, 13L, 8L, 5L, 1L, 18L, 10L, 4L, 20L, 11L, 5L, 1L, 24L, 17L, 8L, 3L, 5L, 12L, 4L, 25L, 16L, 9L, 22L, 13L, 7L, 2L, 23L, 15L, 22L, 14L, 6L, 1L, 24L, 15L, 9L, 1L, 13L, 6L, 19L, 9L, 1L, 24L, 21L, 16L, 9L, 1L, 7L, 19L, 24L, 13L, 8L, 5L, 1L, 18L, 10L, 4L, 20L, 11L, 5L, 1L, 24L, 17L, 8L, 3L, 5L, 12L, 4L, 25L, 16L, 9L, 22L, 13L, 7L, 2L, 23L, 15L, 22L, 14L, 6L, 1L, 24L, 15L, 9L, 1L, 13L, 6L, 19L, 9L, 1L, 24L, 21L, 16L, 9L, 1L, 7L, 19L, 24L, 13L, 8L, 5L, 1L, 18L, 10L, 4L, 20L, 11L, 5L, 1L, 24L, 17L, 8L, 3L, 5L, 12L, 4L, 25L, 16L, 9L, 22L, 13L, 7L, 2L, 23L, 15L, 22L, 14L, 6L, 1L, 24L, 15L, 9L, 1L, 13L, 6L, 19L, 9L, 1L, 24L, 21L, 16L, 9L, 1L, 7L, 19L, 24L, 13L, 8L, 5L, 1L, 18L, 10L, 4L, 20L, 11L, 5L, 1L, 24L, 17L, 8L, 3L, 5L, 12L, 4L, 25L, 16L, 9L, 22L, 13L, 7L, 2L, 23L, 15L, 22L, 14L, 6L, 1L, 24L, 15L, 9L, 1L, 13L, 6L, 19L, 9L, 1L, 24L, 21L, 16L, 9L, 1L, 7L, 19L, 24L, 13L, 8L, 5L, 1L, 18L, 10L, 4L, 20L, 11L, 5L, 1L, 24L, 17L, 8L, 3L), class = "factor", .Label = c("1992", "1993", "1994", "1995", "1996", "1997", "1998", "1999", "2000", "2000/1", "2001/2", "2002", "2003", "2003/4", "2004", "2005", "2005/6", "2006", "2006/7", "2007", "2007/8", "2008/9", "2009", "2010", "2011")), location = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L), .Label = c("Urban", "Rural", "Total", "Capital.City", "Other.Cities.towns", "Urban.Non.slum", "Urban.Slum"), class = "factor"), percent = c(63.0434782608696, 93.8, 87, 79.5642604795185, 65.4240807416892, 63.0791092522326, 90.448386469558, 85.9419999774024, 92.7603614781794, 84.0437368780105, 89.9792286718626, 91.0916571421351, 87.1132950026762, 73.8624315865239, 60.8311005575454, 66.7, 96, 86.8, 90.6243926153181, 90.6911141749493, 90.7602286016099, 93.0377175475414, 86.073106379954, 84.253722056373, 77.8178199148702, 97.3, 91.8332260789258, 89.612164524266, 89.9070989918367, 94.9, 85.1351949905457, 94.8358752154967, 92.9, 89.656599879838, 90.2634019334124, 94.4, 91.6241263241579, 76.7337303943862, 68.4233513070184, 74.15601627144, 88.4802888646634, 85.4643913454376, 89.7457528950664, 81.3025210084024, 83.0579155525397, 71.5857386620092, 86.2324062094295, 87.687478493975, 63.5379061371841, 78.5, 40.7, 51.7763728811622, 32.2441768813334, 22.3138981723172, 83.3699691175754, 69.6742912391579, 76.0526239692028, 83.7290062290807, 77.4758329101792, 83.8081963934296, 67.5805226154664, 55.8951299980461, 41.9921451192584, 52.2, 92.5, 77.6, 82.0322170392223, 85.2850090044269, 70.8031150919282, 47.108593681531, 82.2215412952297, 78.3643348536815, 74.4253468485616, 94.8, 90.1711142192198, 85.0338348718722, 86.3134329333052, 90.4, 79.2813256726705, 90.7077549957666, 82.5, 77.7236217339155, 75.3278238729086, 77.7, 78.4592126267142, 67.1145693585691, 55.3459024734839, 57.8463881286199, 83.5604620304044, 83.9259722574938, 84.4589780509803, 73.3992444632325, 77.544833952707, 63.0503715222555, 75.6808008503601, 85.6943513045284, 63.4, 84.2, 51, 55.7151220012609, 34.9, 26.6, 85, 72.5, 79.2, 83.8, 80.3, 84.9, 69.6, 59, 46, 54, 93, 78.7, 83.2, 85.9, 76.7, 57.5, 83.8, 80.4, 75.6, 95, 90.4, 85.6, 86.9, 90.6, 82.2, 91.5, 84.5, 79.9, 78.1, 80.9, 81.2, 68.1, 56.8, 59.6, 84.9, 84.4, 86.5, 77, 79.1337842548663, 65.6, 79.1, 86.3, 68.421052631579, 96.1, 93.3, 93.461209969107, 82.2712525836501, 88.2708936990495, 87.6298001816506, 87.6386027991385, 93.1818181818183, 86.6666666666668, 88.1030398041979, 90.4761904761904, 83.4297434324662, 86.3744073211853, 83.6107223166148, 78.3, NA, 72.8, 80.952380952381, 87.5, 96.9073193030442, 99.1348508752745, 85.5297651573129, 86.4793919321843, 79.4520547945208, 98.2, 92.4613307718678, 85.4590408924955, 83.9378238341966, 92.1, 81.1594202898552, 96.0232554251852, NA, 88.0377726639494, 83.690767555447, 93.4, 90.0349966633017, 71.2508707571865, 72, 79.4082828804656, 91.8032786885246, 84.5238095238095, 87.8787878787881, 75.6097560975609, 81.0643061692494, 68.4708412135189, 84.9056603773584, 89.5522388059702, 61.6438356164384, 91.7, 79.5, 77.0004220956012, 61.061381883032, 58.756042602018, 91.2594694272412, 85.20149612163, 92.4956062313464, 82.622382662868, 91.4036416540165, 91.6169313256523, 89.2957214499669, 67.6757501795213, 48.1479760952102, NA, NA, 94.2, 94.3553068539161, 91.8799748693178, 89.3739230258784, 92.1418739343887, 86.4757947454868, 81.0102236379536, 77.0100025126874, NA, 91.3720851411616, 92.2, 92.5003150086683, 97.8260869565219, 87.1461797069698, 93.5168077834096, NA, 90.1780793791367, 92.9758067301415, 94.9, 91.8829499602467, 81.749280834314, 65.1853441661798, 69.0503609949116, 87.2562445664681, 85.8298270239758, 90.6673511683335, 83.2861189801694, 84.9006282245266, 73.65452177457, 87.3075692692965, 85.5310215524833, 83.3333333333333, NA, NA, 98.5990187756088, 84.4640706359058, NA, 93.9158337759274, 91.5744358611439, 100, NA, NA, NA, 88.7824144772468, 85.1972665683085, 89.54493171236, NA, NA, 89.8, NA, 100, 97.6261376125643, 96.3196943955923, 92.0952338262334, 87.9266080431752, 80.9429968520701, NA, NA, 92.8, 95.2886158200472, 100, 86.4199793410402, NA, NA, 89.9001648604344, NA, NA, 91.5033109800214, 83.8918470610424, 73.9339911532972, 88.6921281548131, 94.309068022859, 85.3299585067346, 93.7362934447331, 86.5384615384618, 83.7424288707868, NA, 86.3836615391687, 88.1866796344726, 58.1081081081081, NA, NA, 75.7976468146464, 62.1289432084197, NA, 88.1488735873722, 84.2108238885019, 89.8335978405451, NA, NA, NA, 86.9222656846515, 70.3584041024493, 70.9023609260137, NA, NA, 85.9, NA, 89.8689917369566, 90.3864925686512, 92.628169473785, 80.9468895007753, 78.7885741638367, 75.4005791241575, NA, NA, 88.4, 87.7139456942162, 92.3809523809525, 83.7645232075473, NA, NA, 89.567507133125, NA, NA, 91.6433898994358, 73.6225283043976, 65.9223049858496, 72.3148320483822, 86.2596215693035, 85.6224026570651, 87.4940330171337, 78.7499999999997, 81.9949404453665, NA, 84.5563115043796, 87.0190820047277)), .Names = c("COUNTRY", "Year", "location", "percent"), row.names = c(NA, -336L), class = "data.frame") I want to produce a simple plot with ggplot2 that is facetted by COUNTRY. I can do this fine using geom_point: ggplot(meas_melt, aes(Year, percent, colour=location))+ geom_point() + facet_wrap(~COUNTRY) However, if I try and produce a line plot with geom_line (ggplot(meas_melt, aes(Year, percent, colour=location))+ geom_line() + facet_wrap(~COUNTRY)) I get the following error: geom_path: Each group consist of only one observation. Do you need to adjust the group aesthetic? I had thought that this could be because a couple of the countries have only one year's worth of data so I subsetted the date to remove these three countries like so: ggplot(meas_melt, aes(Year, percent, colour=location))+ geom_line(data=meas_melt[!meas_melt$COUNTRY %in% c('Comoros','South Africa','Swaziland'),]) + facet_wrap(~COUNTRY) However, I get the same error!
#Sven's answer is correct but fixes only part of the problem. Note how there's no plot for Comoros, South Africe, or Swaziland. This is because in your data, sometimes year is, e.g., 2006 or 2007, and sometimes it is "2006/7". data[meas_melt$COUNTRY=="Swaziland",] COUNTRY Year location percent 32 Swaziland 2006/7 Urban 94.83588 80 Swaziland 2006/7 Rural 90.70775 128 Swaziland 2006/7 Total 91.50000 176 Swaziland 2006/7 Capital.City 96.02326 224 Swaziland 2006/7 Other.Cities.towns 93.51681 272 Swaziland 2006/7 Urban.Non.slum NA 320 Swaziland 2006/7 Urban.Slum NA Those countries really have only one "year" (hence, no line). More importantly, these odd year designations distort your x-axis. You can see that using the scales="free" argument to facet_wrap(...): ggplot(meas_melt, aes(x=Year,y=percent, color=location)) + geom_line(aes(group=location)) +facet_wrap(~COUNTRY, scales="free") + theme(axis.text.x=element_text(angle=90, vjust=0.5, size=8), legend.position="bottom") Which produces this:
You have to specify aes(group = location) inside geom_line: library(ggplot2) ggplot(meas_melt, aes(Year, percent, colour=location)) + geom_line(aes(group = location)) + facet_wrap(~COUNTRY)