反应性 ggplot 与 Shiny-
Reactive ggplot with Shiny-
嗨社区
我正在尝试制作一个响应式 Shiny 应用程序。
当我select名字“Lugar”出现时剧情。我有每个需要的地块的代码,但不 运行 闪亮。
library(readxl)
library(tidyverse)
library(shiny)
server <- function(input, output, session) {
precip = read_excel("meses2.xlsx", sheet="F")
#Summarize Data and then Plot
data <- reactive({
req(input$sel_Lugar)
df <- precip %>% filter(Lugar %in% input$sel_Lugar) %>% group_by(Mes) %>% summarise(precip = sum(Medicion))
})
#Update SelectInput Dynamically
observe({
updateSelectInput(session, "sel_Lugar", choices = precip$Lugar)
})
#Plot
output$plot <- renderPlot({
ggplot(data(),aes(x=sel_Lugar, y=Medicion, fill=Mes,na.rm = TRUE)) +
geom_col() +
scale_fill_manual(values=c("#E23D2C","#BAA512","#512B9A","#21AB3F")) +
labs(title = "Distribución general de la precipitación",
caption= "Fuente: propia")+
ylab("Precipitación (mm)") +
theme_light()
})
}
ui <- basicPage(
h1("R Shiny Dynamically create Drop Down List"),
selectInput(inputId = "sel_Lugar",
label = "Choose Sales Rep",
"Names"),
plotOutput("plot")
)
shinyApp(ui = ui, server = server)
-
我需要在一个sheet中出现这个非反应性情节
在其他 sheet/tabs 我需要放置反应图。这是代码。我想要当 select “lugar”出现时的情节。是 4 个“Lugar”
d_New<-read_excel("meses2.xlsx", sheet="F")
ggplot(d_New, aes(x=Lugar, y=Medicion, fill=Mes,na.rm = TRUE)) +
geom_col() +
scale_fill_manual(values=c("#E23D2C","#BAA512","#512B9A","#21AB3F")) +
labs(title = "Distribución general de la precipitación",
caption= "Fuente: propia")+
ylab("Precipitación (mm)") +
theme_light()
应用程序 运行 并显示它。
示例数据
structure(list(Mes = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 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, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L), .Label = c("Marzo", "Abril", "Mayo"), class = "factor"),
Dia = c(17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
17, 18, 19, 29, 30, 31, 1, 2, 3, 4, 5, 6, 7, 8, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 16, 17, 18, 19, 20, 21, 22,
23, 24, 25, 26, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15), Medicion = c(50,
17, 13, 12, 3, 6, 0.3, NA, 13, 1, 4, 20, 3, NA, 0, 0, 0,
0, 20, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1, 0, 0, 5, 9,
0, 1, 0, 0, 0, 0, 2, 17, 58, 32, 0, 9, 0.5, 1, 25, 1, 0.5,
4, 10, 3, 3, 8, 36, 13, 1, 0.5, 0.5), Lugar = c("UNIAGRARIA",
"UNIAGRARIA", "UNIAGRARIA", "UNIAGRARIA", "UNIAGRARIA", "UNIAGRARIA",
"UNIAGRARIA", "UNIAGRARIA", "UNIAGRARIA", "UNIAGRARIA", "UNIAGRARIA",
"UNIAGRARIA", "UNIAGRARIA", "GRANADA NORTE", "GRANADA NORTE",
"GRANADA NORTE", "GRANADA NORTE", "GRANADA NORTE", "GRANADA NORTE",
"RIO FRIO", "RIO FRIO", "RIO FRIO", "RIO FRIO", "RIO FRIO",
"RIO FRIO", "RIO FRIO", "RIO FRIO", "CHICU", "CHICU", "CHICU",
"CHICU", "CHICU", "CHICU", "CHICU", "CHICU", "CHICU", "CHICU",
"CHICU", "RIO FRIO", "RIO FRIO", "RIO FRIO", "RIO FRIO",
"RIO FRIO", "RIO FRIO", "RIO FRIO", "RIO FRIO", "RIO FRIO",
"RIO FRIO", "RIO FRIO", "GRANADA NORTE", "GRANADA NORTE",
"GRANADA NORTE", "GRANADA NORTE", "GRANADA NORTE", "GRANADA NORTE",
"GRANADA NORTE", "GRANADA NORTE", "GRANADA NORTE", "GRANADA NORTE",
"GRANADA NORTE")), row.names = c(NA, -60L), class = c("tbl_df",
"tbl", "data.frame"))
谢谢
由于您想要 2 个选项卡(1 个用于固定图,1 个用于反应图),您需要使用 navbarPage
.
"sel_Lugar" 未找到,无法用于绘图,因为 data()
没有此列。您尝试获取数据的方式是为您提供一个包含“Mes”的列和另一个包含“precip”的列。
我不知道你为什么要summarise
,但如果你想画图,你需要删除这部分。
因此,您将能够在图中使用列“Lugar”、“Medicion”和“Mes”。
另一方面,您用来绘制反应图的代码是错误的。
ggplot(precip, aes(x=Lugar, y=Medicion, fill=Mes,na.rm = TRUE)) +
geom_col() +
scale_fill_manual(values=c("#E23D2C","#BAA512","#512B9A","#21AB3F")) +
labs(title = "Distribución general de la precipitación",
caption= "Fuente: propia")+
ylab("Precipitación (mm)") +
theme_light()
如果您想获得与照片中相同的输出(对于反应图),您需要更改 x(而不是“Lugar”,它必须是“Dia”)。此外,如果您想要包含“Dias”的音阶,我建议您使用 scale_x_continuous
。
就我而言,我使用了 scale_x_continuous(breaks=seq(from=0, to = max(precip$Dia), by=1))
seq(from=0, to = max(precip$Dia), by=1)
1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 3
我已经更改了显示地点的方式 (selectInput
),因为我已将选项保存到一个函数中。
但是,如果您有大量的选项列表,我建议您使用 selectizeInput
。给你一个 .
在我进行了所有更改之后,这就是您的应用程序的外观。
这里附上完整的代码。
请注意,我添加了一个 table,您可以在其中查看如何根据 selectInput
对数据进行子集化。
library(shinythemes)
library(shiny)
library(readxl)
library(shiny)
library(dplyr)
library(DT)
library(ggplot2)
# Since you want to have 1 tab for the "not reactive plot" and another tab for the "reactive plot", you will need to use navbarPage
ui <- fluidPage(
theme = shinytheme("flatly"), # this is to put some colors/themes
navbarPage(
title = "R Shiny Dynamically create Drop Down List",
collapsible = TRUE,
fluid = TRUE,
tabPanel(
title = "Not reactive plot",
sidebarLayout(
sidebarPanel = sidebarPanel(
),
mainPanel = mainPanel(
plotOutput("plot1")
)
)
),
tabPanel(
title = "Reactive plot",
sidebarLayout(
sidebarPanel = sidebarPanel(
uiOutput('selectUI'), # this is to have the list of places
),
mainPanel = mainPanel(
plotOutput("plot2"),
dataTableOutput("table")
)
)
),
)
)
server <- function(input, output, session) {
# this is your data without filtering
data <- reactive({
return(precip)
})
# this gives you the a vector of the choices of your original data
lugar_choices <- reactive({
choices <- levels(data()$Lugar)
return(choices)
})
# this will give you your choices.
output$selectUI <- renderUI({
selectInput(inputId = 'sel_Lugar', "Choose Sales Rep", choices = lugar_choices())
})
# this your new data according to your select Input.
data_filtered <- reactive({
req(input$sel_Lugar)
df <- data() %>%
filter(Lugar %in% input$sel_Lugar) %>%
group_by(Mes)
return(df)
})
# first plot (not reactive)
output$plot1 <- renderPlot({
ggplot(data(), aes(x=Lugar, y=Medicion, fill=Mes,na.rm = TRUE)) +
geom_col() +
scale_fill_manual(values=c("#E23D2C","#BAA512","#512B9A","#21AB3F")) +
labs(title = "Distribución general de la precipitación",
caption= "Fuente: propia")+
ylab("Precipitación (mm)") +
theme_light()
})
# second plot (reactive)
output$plot2 <- renderPlot({
ggplot(data_filtered(), aes(x=Dia, y=Medicion, fill=Mes,na.rm = TRUE)) +
geom_col() +
scale_fill_manual(values=c("#E23D2C","#BAA512","#512B9A","#21AB3F")) +
labs(title = "Distribución general de la precipitación",
caption= "Fuente: propia")+
ylab("Precipitación (mm)") +
scale_x_continuous(breaks=seq(from=0, to = max(data_filtered()$Dia), by=1))+
theme_light()
})
# this is the info that you are plotting
output$table <- renderDataTable(data_filtered())
}
shinyApp(ui, server)
数据:
precip = structure(list(Mes = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 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, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L), .Label = c("Marzo", "Abril", "Mayo"), class = "factor"),
Dia = c(17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
17, 18, 19, 29, 30, 31, 1, 2, 3, 4, 5, 6, 7, 8, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 16, 17, 18, 19, 20, 21, 22,
23, 24, 25, 26, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15), Medicion = c(50,
17, 13, 12, 3, 6, 0.3, NA, 13, 1, 4, 20, 3, NA, 0, 0, 0,
0, 20, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1, 0, 0, 5, 9,
0, 1, 0, 0, 0, 0, 2, 17, 58, 32, 0, 9, 0.5, 1, 25, 1, 0.5,
4, 10, 3, 3, 8, 36, 13, 1, 0.5, 0.5), Lugar = c("UNIAGRARIA",
"UNIAGRARIA", "UNIAGRARIA", "UNIAGRARIA", "UNIAGRARIA", "UNIAGRARIA",
"UNIAGRARIA", "UNIAGRARIA", "UNIAGRARIA", "UNIAGRARIA", "UNIAGRARIA",
"UNIAGRARIA", "UNIAGRARIA", "GRANADA NORTE", "GRANADA NORTE",
"GRANADA NORTE", "GRANADA NORTE", "GRANADA NORTE", "GRANADA NORTE",
"RIO FRIO", "RIO FRIO", "RIO FRIO", "RIO FRIO", "RIO FRIO",
"RIO FRIO", "RIO FRIO", "RIO FRIO", "CHICU", "CHICU", "CHICU",
"CHICU", "CHICU", "CHICU", "CHICU", "CHICU", "CHICU", "CHICU",
"CHICU", "RIO FRIO", "RIO FRIO", "RIO FRIO", "RIO FRIO",
"RIO FRIO", "RIO FRIO", "RIO FRIO", "RIO FRIO", "RIO FRIO",
"RIO FRIO", "RIO FRIO", "GRANADA NORTE", "GRANADA NORTE",
"GRANADA NORTE", "GRANADA NORTE", "GRANADA NORTE", "GRANADA NORTE",
"GRANADA NORTE", "GRANADA NORTE", "GRANADA NORTE", "GRANADA NORTE",
"GRANADA NORTE")), row.names = c(NA, -60L), class = c("tbl_df",
"tbl", "data.frame"))
# we transform the column into factors because we will need it for the choices (I will need the different levels)
precip$Lugar <- as.factor(precip$Lugar)
嗨社区 我正在尝试制作一个响应式 Shiny 应用程序。
当我select名字“Lugar”出现时剧情。我有每个需要的地块的代码,但不 运行 闪亮。
library(readxl)
library(tidyverse)
library(shiny)
server <- function(input, output, session) {
precip = read_excel("meses2.xlsx", sheet="F")
#Summarize Data and then Plot
data <- reactive({
req(input$sel_Lugar)
df <- precip %>% filter(Lugar %in% input$sel_Lugar) %>% group_by(Mes) %>% summarise(precip = sum(Medicion))
})
#Update SelectInput Dynamically
observe({
updateSelectInput(session, "sel_Lugar", choices = precip$Lugar)
})
#Plot
output$plot <- renderPlot({
ggplot(data(),aes(x=sel_Lugar, y=Medicion, fill=Mes,na.rm = TRUE)) +
geom_col() +
scale_fill_manual(values=c("#E23D2C","#BAA512","#512B9A","#21AB3F")) +
labs(title = "Distribución general de la precipitación",
caption= "Fuente: propia")+
ylab("Precipitación (mm)") +
theme_light()
})
}
ui <- basicPage(
h1("R Shiny Dynamically create Drop Down List"),
selectInput(inputId = "sel_Lugar",
label = "Choose Sales Rep",
"Names"),
plotOutput("plot")
)
shinyApp(ui = ui, server = server)
-
我需要在一个sheet中出现这个非反应性情节
在其他 sheet/tabs 我需要放置反应图。这是代码。我想要当 select “lugar”出现时的情节。是 4 个“Lugar”
d_New<-read_excel("meses2.xlsx", sheet="F")
ggplot(d_New, aes(x=Lugar, y=Medicion, fill=Mes,na.rm = TRUE)) +
geom_col() +
scale_fill_manual(values=c("#E23D2C","#BAA512","#512B9A","#21AB3F")) +
labs(title = "Distribución general de la precipitación",
caption= "Fuente: propia")+
ylab("Precipitación (mm)") +
theme_light()
应用程序 运行 并显示它。
示例数据
structure(list(Mes = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 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, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L), .Label = c("Marzo", "Abril", "Mayo"), class = "factor"),
Dia = c(17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
17, 18, 19, 29, 30, 31, 1, 2, 3, 4, 5, 6, 7, 8, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 16, 17, 18, 19, 20, 21, 22,
23, 24, 25, 26, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15), Medicion = c(50,
17, 13, 12, 3, 6, 0.3, NA, 13, 1, 4, 20, 3, NA, 0, 0, 0,
0, 20, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1, 0, 0, 5, 9,
0, 1, 0, 0, 0, 0, 2, 17, 58, 32, 0, 9, 0.5, 1, 25, 1, 0.5,
4, 10, 3, 3, 8, 36, 13, 1, 0.5, 0.5), Lugar = c("UNIAGRARIA",
"UNIAGRARIA", "UNIAGRARIA", "UNIAGRARIA", "UNIAGRARIA", "UNIAGRARIA",
"UNIAGRARIA", "UNIAGRARIA", "UNIAGRARIA", "UNIAGRARIA", "UNIAGRARIA",
"UNIAGRARIA", "UNIAGRARIA", "GRANADA NORTE", "GRANADA NORTE",
"GRANADA NORTE", "GRANADA NORTE", "GRANADA NORTE", "GRANADA NORTE",
"RIO FRIO", "RIO FRIO", "RIO FRIO", "RIO FRIO", "RIO FRIO",
"RIO FRIO", "RIO FRIO", "RIO FRIO", "CHICU", "CHICU", "CHICU",
"CHICU", "CHICU", "CHICU", "CHICU", "CHICU", "CHICU", "CHICU",
"CHICU", "RIO FRIO", "RIO FRIO", "RIO FRIO", "RIO FRIO",
"RIO FRIO", "RIO FRIO", "RIO FRIO", "RIO FRIO", "RIO FRIO",
"RIO FRIO", "RIO FRIO", "GRANADA NORTE", "GRANADA NORTE",
"GRANADA NORTE", "GRANADA NORTE", "GRANADA NORTE", "GRANADA NORTE",
"GRANADA NORTE", "GRANADA NORTE", "GRANADA NORTE", "GRANADA NORTE",
"GRANADA NORTE")), row.names = c(NA, -60L), class = c("tbl_df",
"tbl", "data.frame"))
谢谢
由于您想要 2 个选项卡(1 个用于固定图,1 个用于反应图),您需要使用 navbarPage
.
"sel_Lugar" 未找到,无法用于绘图,因为 data()
没有此列。您尝试获取数据的方式是为您提供一个包含“Mes”的列和另一个包含“precip”的列。
我不知道你为什么要summarise
,但如果你想画图,你需要删除这部分。
因此,您将能够在图中使用列“Lugar”、“Medicion”和“Mes”。
另一方面,您用来绘制反应图的代码是错误的。
ggplot(precip, aes(x=Lugar, y=Medicion, fill=Mes,na.rm = TRUE)) +
geom_col() +
scale_fill_manual(values=c("#E23D2C","#BAA512","#512B9A","#21AB3F")) +
labs(title = "Distribución general de la precipitación",
caption= "Fuente: propia")+
ylab("Precipitación (mm)") +
theme_light()
如果您想获得与照片中相同的输出(对于反应图),您需要更改 x(而不是“Lugar”,它必须是“Dia”)。此外,如果您想要包含“Dias”的音阶,我建议您使用 scale_x_continuous
。
就我而言,我使用了 scale_x_continuous(breaks=seq(from=0, to = max(precip$Dia), by=1))
seq(from=0, to = max(precip$Dia), by=1)
1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 3
我已经更改了显示地点的方式 (selectInput
),因为我已将选项保存到一个函数中。
但是,如果您有大量的选项列表,我建议您使用 selectizeInput
。给你一个
在我进行了所有更改之后,这就是您的应用程序的外观。
这里附上完整的代码。
请注意,我添加了一个 table,您可以在其中查看如何根据 selectInput
对数据进行子集化。
library(shinythemes)
library(shiny)
library(readxl)
library(shiny)
library(dplyr)
library(DT)
library(ggplot2)
# Since you want to have 1 tab for the "not reactive plot" and another tab for the "reactive plot", you will need to use navbarPage
ui <- fluidPage(
theme = shinytheme("flatly"), # this is to put some colors/themes
navbarPage(
title = "R Shiny Dynamically create Drop Down List",
collapsible = TRUE,
fluid = TRUE,
tabPanel(
title = "Not reactive plot",
sidebarLayout(
sidebarPanel = sidebarPanel(
),
mainPanel = mainPanel(
plotOutput("plot1")
)
)
),
tabPanel(
title = "Reactive plot",
sidebarLayout(
sidebarPanel = sidebarPanel(
uiOutput('selectUI'), # this is to have the list of places
),
mainPanel = mainPanel(
plotOutput("plot2"),
dataTableOutput("table")
)
)
),
)
)
server <- function(input, output, session) {
# this is your data without filtering
data <- reactive({
return(precip)
})
# this gives you the a vector of the choices of your original data
lugar_choices <- reactive({
choices <- levels(data()$Lugar)
return(choices)
})
# this will give you your choices.
output$selectUI <- renderUI({
selectInput(inputId = 'sel_Lugar', "Choose Sales Rep", choices = lugar_choices())
})
# this your new data according to your select Input.
data_filtered <- reactive({
req(input$sel_Lugar)
df <- data() %>%
filter(Lugar %in% input$sel_Lugar) %>%
group_by(Mes)
return(df)
})
# first plot (not reactive)
output$plot1 <- renderPlot({
ggplot(data(), aes(x=Lugar, y=Medicion, fill=Mes,na.rm = TRUE)) +
geom_col() +
scale_fill_manual(values=c("#E23D2C","#BAA512","#512B9A","#21AB3F")) +
labs(title = "Distribución general de la precipitación",
caption= "Fuente: propia")+
ylab("Precipitación (mm)") +
theme_light()
})
# second plot (reactive)
output$plot2 <- renderPlot({
ggplot(data_filtered(), aes(x=Dia, y=Medicion, fill=Mes,na.rm = TRUE)) +
geom_col() +
scale_fill_manual(values=c("#E23D2C","#BAA512","#512B9A","#21AB3F")) +
labs(title = "Distribución general de la precipitación",
caption= "Fuente: propia")+
ylab("Precipitación (mm)") +
scale_x_continuous(breaks=seq(from=0, to = max(data_filtered()$Dia), by=1))+
theme_light()
})
# this is the info that you are plotting
output$table <- renderDataTable(data_filtered())
}
shinyApp(ui, server)
数据:
precip = structure(list(Mes = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 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, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L), .Label = c("Marzo", "Abril", "Mayo"), class = "factor"),
Dia = c(17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
17, 18, 19, 29, 30, 31, 1, 2, 3, 4, 5, 6, 7, 8, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 16, 17, 18, 19, 20, 21, 22,
23, 24, 25, 26, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15), Medicion = c(50,
17, 13, 12, 3, 6, 0.3, NA, 13, 1, 4, 20, 3, NA, 0, 0, 0,
0, 20, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1, 0, 0, 5, 9,
0, 1, 0, 0, 0, 0, 2, 17, 58, 32, 0, 9, 0.5, 1, 25, 1, 0.5,
4, 10, 3, 3, 8, 36, 13, 1, 0.5, 0.5), Lugar = c("UNIAGRARIA",
"UNIAGRARIA", "UNIAGRARIA", "UNIAGRARIA", "UNIAGRARIA", "UNIAGRARIA",
"UNIAGRARIA", "UNIAGRARIA", "UNIAGRARIA", "UNIAGRARIA", "UNIAGRARIA",
"UNIAGRARIA", "UNIAGRARIA", "GRANADA NORTE", "GRANADA NORTE",
"GRANADA NORTE", "GRANADA NORTE", "GRANADA NORTE", "GRANADA NORTE",
"RIO FRIO", "RIO FRIO", "RIO FRIO", "RIO FRIO", "RIO FRIO",
"RIO FRIO", "RIO FRIO", "RIO FRIO", "CHICU", "CHICU", "CHICU",
"CHICU", "CHICU", "CHICU", "CHICU", "CHICU", "CHICU", "CHICU",
"CHICU", "RIO FRIO", "RIO FRIO", "RIO FRIO", "RIO FRIO",
"RIO FRIO", "RIO FRIO", "RIO FRIO", "RIO FRIO", "RIO FRIO",
"RIO FRIO", "RIO FRIO", "GRANADA NORTE", "GRANADA NORTE",
"GRANADA NORTE", "GRANADA NORTE", "GRANADA NORTE", "GRANADA NORTE",
"GRANADA NORTE", "GRANADA NORTE", "GRANADA NORTE", "GRANADA NORTE",
"GRANADA NORTE")), row.names = c(NA, -60L), class = c("tbl_df",
"tbl", "data.frame"))
# we transform the column into factors because we will need it for the choices (I will need the different levels)
precip$Lugar <- as.factor(precip$Lugar)