Good afternoon,
I am a beginner creating ShinyApps and I would really appreciate if someone could help me to solve the following problem:
The purpose of the App is to store the information that a football scout fills on the reports.
Every time a scout fills out the different items of the report, I would like to store/transfer this information in a new dataframe on my global environment in R Studio via the action button below called "Guardar". Any idea?
My e-mail is ivandiazramis8#gmail.com for any in inquiry.
Thank you!
library(shinyWidgets)
library(shinydashboard)
library(shinyauthr)
library(shinyjs)
library(sodium)
library(tibble)
library(dplyr)
library(DT)
#----------UI----------
ui <- dashboardPage(title = "Herramienta Scouting TFM", skin = "blue",
dashboardHeader(title = "Herramienta Scouting TFM",
titleWidth = "300px"),
dashboardSidebar(width = "300px",
sidebarMenu(menuItem(text = "Informe Tipo", icon = icon(name = "file-contract", lib = "font-awesome"),
menuSubItem("Informe",
tabName = "Informe_Tipo",
icon = icon("futbol"))))),
dashboardBody(
tabItems(
tabItem(tabName = "Informe_Tipo",
h1("INFORME TIPO"),
br(),
fluidRow(
column(width = 4,
box(title = "INFORMACIÓN DEL SCOUT ",
background = "light-blue",
width = 12),
box(status = "primary",
width = 12,
textInput(inputId = "Scout_1",
label = "Nombre Completo: ",
value = character(0)),
dateInput(inputId = "Fecha_Informe_1",
label = "Fecha de Realización del Informe: ",
value = Sys.Date(),
min = Sys.Date(),
max = Sys.Date(),
weekstart = 1,
language = "es")),
box(title = "INFORMACIÓN DEL JUGADOR ",
background = "light-blue",
width = 12),
box(status = "primary",
width = 12,
selectInput(inputId = "Competicion_1",
label = "Competición: ",
choices = c("Bundesliga 2", "Championship", "Liga Smartbank", "Ligue 2",
"Serie B")),
selectInput(inputId = "Equipo_1",
label = "Equipo: ",
choices = c("Jahn Regensburg", "Dynamo Dresden", "Nürnberg", "Ingolstadt",
"Hamburger SV", "Fortuna Düsseldorf", "Holstein Kiel", "Paderborn",
"Werder Bremen", "Heidenheim", "Darmstadt 98", "Schalke 04",
"Karlsruher SC", "Hannover 96", "Hansa Rostock", "Erzgebirge Aue",
"Sandhausen", "St, Pauli", "Nürnberg II", "Hatayspor", "Borussia Dortmund II",
"Werder Bremen U19", "Fortuna Düsseldorf II", "Schalke 04 II",
"Apollon Smirnis", "Hamburger SV U19", "Karlsruher SC U17", "Antwerp",
"Hallescher FC", "Union Berlin", "Freiburg", "Holstein Kiel II",
"Darmstadt 98 U19", "Verl", "Arminia Bielefeld", "Karlsruher SC U19",
"Vissel Kobe", "Werder Bremen II", "Norwich City", "Schalke 04 U19",
"Ingolstadt U19", "Waldhof Mannheim", "Hannover 96 II", "Mallorca",
"Sheffield United", "Swansea City", "West Bromwich Albion", "Blackburn Rovers",
"Arsenal", "Cardiff City", "Millwall", "Barnsley", "Nottingham Forest",
"Coventry City", "Blackpool", "Peterborough United", "Birmingham City",
"Bristol City", "Preston North End", "Queens Park Rangers", "Hull City",
"Luton Town", "Stoke City U23", "Stoke City", "Middlesbrough",
"Reading", "Derby County", "Middlesbrough U23", "Huddersfield Town",
"Reading U23", "Fulham", "Bournemouth", "Birmingham City U23",
"Swindon Town", "Derby County U23", "Portsmouth", "Guiseley",
"Sheffield United U23", "Cardiff City U23", "Northampton Town",
"Hearts", "Club Brugge", "Chelsea U23", "Nottingham Forest U23",
"Notts County", "West Bromwich Albion U23", "Barnsley U23", "Napoli",
"PAOK", "Grimsby Town", "Cesena", "Derby County U18", "Fleetwood Town",
"Accrington Stanley", "Fulham U23", "Hull City U18", "Huddersfield Town B",
"Olympiacos Piraeus", "Lincoln City", "Coventry City U23", "Ipswich Town",
"Shrewsbury Town", "Cheltenham Town", "Swansea City U18", "Portimonense",
"Charlton Athletic", "Hibernian", "Bristol City U23", "Millwall U23",
"Hull City U23", "Aris", "Gillingham", "Pisa", "Blackburn Rovers U23",
"Preston North End U18", "Oxford United", "Sheffield United U18",
"Millwall U18", "Ponferradina", "Girona", "Ibiza", "Burgos",
"Brentford", "Real Zaragoza", "Las Palmas", "Eibar", "Real Sociedad B",
"Huesca", "Leganés", "Alcorcón", "Málaga", "Fuenlabrada", "Sporting Gijón",
"Almería", "Lugo", "Real Oviedo", "Real Valladolid", "Tenerife",
"Cartagena", "Amorebieta", "Mirandés", "Real Sociedad", "Real Sociedad III",
"Las Palmas Atlético", "CD Calahorra", NA, "Sporting Gijón B",
"Tenerife B", "Cartagena B", "Girona II", "Valladolid Promesas",
"Getafe", "Real Oviedo Vetusta", "Málaga CF U17", "Alcorcón B",
"Racing Santander", "Fuenlabrada B", "Cádiz", "Elche", "Leganés B",
"Huesca B", "Dnipro-1", "Charlotte Independence", "Deportivo Alavés",
"Valencia", "Real Zaragoza B", "Barcelona", "Mirandés B", "Sabadell",
"Dunkerque", "Pau", "Young Boys", "Ajaccio", "Grenoble", "Dijon",
"Nancy", "Auxerre", "Guingamp", "Paris", "Bastia", "Valenciennes",
"Nîmes", "Rodez ", "Toulouse", "Nancy II", "Le Havre", "Sochaux",
"Niort", "Quevilly Rouen", "Amiens SC", "Caen", "Guingamp II",
"Le Havre U19", "Nîmes II", "Rizespor", "Dijon U19", "Lecce",
"Caen II", "Brescia", "Lech Poznan", "Besiktas", "Parma", "Paris II",
"Famalicão", "Dunkerque II", "Manisa BBSK", "Niort II", "Kayserispor",
"Ajaccio U19", "Quevilly Rouen II", "Dijon II", "Paris U19",
"Bayer Leverkusen", "Le Havre U17", "Nancy U18", "Paris U17",
"Spezia", "Warta Poznan", "Montpellier", "Valenciennes U19",
"U Craiova 1948", "Valenciennes II", "Sochaux U19", "Cosenza",
"Ternana", "Reggina", "Benevento", "SPAL", "Alessandria", "Como",
"Ascoli", "Cittadella", "Monza", "Frosinone", "Pordenone", "Crotone",
"Perugia", "Cremonese", "Vicenza", "Parma U19", "Renate", "Frosinone U19",
"Vålerenga", "ACN Siena", "Reggina U17", "Carrarese", "Salernitana",
"Imolese", "SPAL U19", "Pordenone U17", "Pisa U19", "Triestina",
"Pordenone U19", "Yeni Malatyaspor", "FeralpiSalò", "Vicenza U19",
"Alessandria U19", "Reggina U19", "Empoli", "Ascoli U19", "Crotone U19",
"Cosenza U19", "Benevento U19")),
selectInput(inputId = "Demarcación_1",
label = "Demarcación: ",
choices = c("Portero", "Central", "Lateral", "Mediocentro", "Extremo",
"Delantero")),
selectInput(inputId = "Nacionalidad_1",
label = "Nacionalidad: ",
choices = c("Germany", "Russia", "Austria", "Czech Republic", "Denmark",
"Sweden", "Bosnia and Herzegovina", "Poland", "Spain", "United States",
"Romania", "Finland", "Belgium", "France", "Switzerland", "England",
"Croatia", "Japan", "Slovenia", "Norway", "Mexico", "Serbia",
"Senegal", "Canada", "North Macedonia", "Georgia", "Nigeria",
"Brazil", "Netherlands", "Kosovo", "Curaçao", "Ghana", "Azerbaijan",
"Korea Republic", "Cameroon", "Dominican Republic", "Bulgaria",
"Australia", "Albania", "Luxembourg", "Slovakia", "Italy", "Iceland",
"Gambia", "Ukraine", "Sierra Leone", "Côte d'Ivoire", "Congo DR",
"New Zealand", "Sudan", "Guinea", "Congo", "Wales", "Scotland",
"Estonia", "Montenegro", "Republic of Ireland", "Argentina",
"Northern Ireland", "Portugal", "Saudi Arabia", "Namibia", "Iran",
"Paraguay", "Jamaica", "Guinea-Bissau", "Colombia", "Kenya",
"Cuba", "Angola", "Bermuda", "Ecuador", "Uruguay", "Morocco",
"Equatorial Guinea", "Venezuela", "Peru", "Panama", "Mali", "Egypt",
"Israel", "French Guiana", "Benin", "Gabon", "Cape Verde Islands",
"Guadeloupe", "Tunisia", "Haiti", "Comoros", "Réunion", "Martinique",
"Algeria", "Turkey", "South Africa", "Burkina Faso", "New Caledonia",
"Togo", "Zambia", "Lithuania", "Greece", "Hungary", "Uganda",
"Cyprus", "Moldova", "Madagascar", "Malta", "Chile", "Honduras",
"Latvia")),
selectInput(inputId = "Pie_Dominante_1",
label = "Pie Dominante: ",
choices = c("derecho", "izquierdo", "ambidiestro", NA, "unknown")),
sliderInput(inputId = "Edad_1",
label = "Edad: ",
min = 15,
max = 40,
value = 15,
ticks = FALSE)),
box(title = "INFORMACIÓN DEL PARTIDO ",
background = "light-blue",
width = 12),
box(status = "primary",
width = 12,
textInput(inputId = "Partido_1",
label = "Partido (Equipo Local) (X) - (X) (Equipo Visitante): ",
value = character(0)),
pickerInput(inputId = "Demarcación_Partido_1",
label = "Demarcación en el Partido: ",
choices = c("Portero", "Central", "Lateral", "Mediocentro", "Extremo",
"Delantero"),
selected = character(0),
multiple = TRUE,
options = list(`actions-box` = TRUE)),
sliderInput(inputId = "Minutos_Partido_1",
label = "Minutos Jugados: ",
min = 0,
max = 90,
value = 0,
ticks = FALSE))),
column(width = 8,
box(title = "VALORACIÓN DE LOS ÍTEMS ",
background = "light-blue",
width = 12),
box(title = "Capacidad de jugar con los pies: ",
status = "primary",
width = 12,
radioGroupButtons(inputId = "1_Valoración_1",
label = "Valoración: ",
choices = c("1", "2", "3", "4"),
selected = character(0),
status = "primary",
justified = TRUE),
textInput(inputId = "1_Comentario_1",
label = "Comentarios: ")),
box(title = "Capacidad de salida en balones divididos: ",
status = "primary",
width = 12,
radioGroupButtons(inputId = "1_Valoración_2",
label = "Valoración: ",
choices = c("1", "2", "3", "4"),
selected = character(0),
status = "primary",
justified = TRUE),
textInput(inputId = "1_Comentario_2",
label = "Comentarios: ")),
box(title = "Reflejos: ",
status = "primary",
width = 12,
radioGroupButtons(inputId = "1_Valoración_3",
label = "Valoración: ",
choices = c("1", "2", "3", "4"),
selected = character(0),
status = "primary",
justified = TRUE),
textInput(inputId = "1_Comentario_3",
label = "Comentarios: ")),
box(title = "Dominio del juego aéreo: ",
status = "primary",
width = 12,
radioGroupButtons(inputId = "1_Valoración_4",
label = "Valoración: ",
choices = c("1", "2", "3", "4"),
selected = character(0),
status = "primary",
justified = TRUE),
textInput(inputId = "1_Comentario_4",
label = "Comentarios: ")),
box(title = "Capacidad de comunicación: ",
status = "primary",
width = 12,
radioGroupButtons(inputId = "1_Valoración_5",
label = "Valoración: ",
choices = c("1", "2", "3", "4"),
selected = character(0),
status = "primary",
justified = TRUE),
textInput(inputId = "1_Comentario_5",
label = "Comentarios: ")))),
actionBttn(inputId = "boton",
label = "Guardar",
icon = icon("save", lib = "font-awesome"),
style = "jelly",
color = "primary",
size = "md")))
)
)
#----------SERVER----------
server <- function(input, output){}
#----------SHINYAPP----------
shinyApp(ui, server)
Although we could use the function assign to save a df into the .globalEnv. R session will still be busy (a shiny application is running), so the df will appear in the global environment only when the app stops. We can use downloadHandler instead.
Don't worry too much about what map/set_names and exec functions mean, I only used them here to avoid typing manually a data frame one input at a time. e.g data.frame(Nacionalidad_1 = input$Nacionalidad_1)
Now everytime the button "guardar" is pressed, a csv is downloaded that we can later read into R with read_csv.
#vector with the names of all the inputs in the app
inpt_nms <- c(
"sidebarItemExpanded", "1_Valoración_2", "1_Valoración_1",
"Nacionalidad_1", "1_Comentario_4", "1_Valoración_5", "1_Valoración_3",
"Partido_1", "1_Comentario_1", "1_Comentario_2", "Equipo_1",
"1_Comentario_3", "Competicion_1", "Pie_Dominante_1", "Minutos_Partido_1",
"sidebarCollapsed", "Scout_1", "Demarcación_Partido_1", "1_Comentario_5",
"1_Valoración_4", "boton", "Fecha_Informe_1", "Demarcación_1",
"Edad_1"
)
#server code with download handler
server <- function(input, output) {
output$boton <- downloadHandler(
filename = function() {
paste0("df_", input$Scout_1, ".csv")
},
content = function(file) {
map(inpt_nms, ~ input[[.x]]) %>%
set_names(inpt_nms) %>%
{
exec("tibble", !!!.)
} %>%
write_csv(file)
}
)
}
Full app:
library(shiny)
library(shinyWidgets)
library(shinydashboard)
library(shinyauthr)
library(shinyjs)
library(sodium)
library(tidyverse)
library(DT)
inpt_nms <- c(
"sidebarItemExpanded", "1_Valoración_2", "1_Valoración_1",
"Nacionalidad_1", "1_Comentario_4", "1_Valoración_5", "1_Valoración_3",
"Partido_1", "1_Comentario_1", "1_Comentario_2", "Equipo_1",
"1_Comentario_3", "Competicion_1", "Pie_Dominante_1", "Minutos_Partido_1",
"sidebarCollapsed", "Scout_1", "Demarcación_Partido_1", "1_Comentario_5",
"1_Valoración_4", "boton", "Fecha_Informe_1", "Demarcación_1",
"Edad_1"
)
#----------UI----------
ui <- dashboardPage(
title = "Herramienta Scouting TFM", skin = "blue",
dashboardHeader(
title = "Herramienta Scouting TFM",
titleWidth = "300px"
),
dashboardSidebar(
width = "300px",
sidebarMenu(menuItem(
text = "Informe Tipo", icon = icon(name = "file-contract", lib = "font-awesome"),
menuSubItem("Informe",
tabName = "Informe_Tipo",
icon = shiny::icon("futbol")
)
))
),
dashboardBody(
tabItems(
tabItem(
tabName = "Informe_Tipo",
h1("INFORME TIPO"),
br(),
fluidRow(
column(
width = 4,
box(
title = "INFORMACIÓN DEL SCOUT ",
background = "light-blue",
width = 12
),
box(
status = "primary",
width = 12,
textInput(
inputId = "Scout_1",
label = "Nombre Completo: ",
value = character(0)
),
dateInput(
inputId = "Fecha_Informe_1",
label = "Fecha de Realización del Informe: ",
value = Sys.Date(),
min = Sys.Date(),
max = Sys.Date(),
weekstart = 1,
language = "es"
)
),
box(
title = "INFORMACIÓN DEL JUGADOR ",
background = "light-blue",
width = 12
),
box(
status = "primary",
width = 12,
selectInput(
inputId = "Competicion_1",
label = "Competición: ",
choices = c(
"Bundesliga 2", "Championship", "Liga Smartbank", "Ligue 2",
"Serie B"
)
),
selectInput(
inputId = "Equipo_1",
label = "Equipo: ",
choices = c(
"Jahn Regensburg", "Dynamo Dresden", "Nürnberg", "Ingolstadt",
"Hamburger SV", "Fortuna Düsseldorf", "Holstein Kiel", "Paderborn",
"Werder Bremen", "Heidenheim", "Darmstadt 98", "Schalke 04",
"Karlsruher SC", "Hannover 96", "Hansa Rostock", "Erzgebirge Aue",
"Sandhausen", "St, Pauli", "Nürnberg II", "Hatayspor", "Borussia Dortmund II",
"Werder Bremen U19", "Fortuna Düsseldorf II", "Schalke 04 II",
"Apollon Smirnis", "Hamburger SV U19", "Karlsruher SC U17", "Antwerp",
"Hallescher FC", "Union Berlin", "Freiburg", "Holstein Kiel II",
"Darmstadt 98 U19", "Verl", "Arminia Bielefeld", "Karlsruher SC U19",
"Vissel Kobe", "Werder Bremen II", "Norwich City", "Schalke 04 U19",
"Ingolstadt U19", "Waldhof Mannheim", "Hannover 96 II", "Mallorca",
"Sheffield United", "Swansea City", "West Bromwich Albion", "Blackburn Rovers",
"Arsenal", "Cardiff City", "Millwall", "Barnsley", "Nottingham Forest",
"Coventry City", "Blackpool", "Peterborough United", "Birmingham City",
"Bristol City", "Preston North End", "Queens Park Rangers", "Hull City",
"Luton Town", "Stoke City U23", "Stoke City", "Middlesbrough",
"Reading", "Derby County", "Middlesbrough U23", "Huddersfield Town",
"Reading U23", "Fulham", "Bournemouth", "Birmingham City U23",
"Swindon Town", "Derby County U23", "Portsmouth", "Guiseley",
"Sheffield United U23", "Cardiff City U23", "Northampton Town",
"Hearts", "Club Brugge", "Chelsea U23", "Nottingham Forest U23",
"Notts County", "West Bromwich Albion U23", "Barnsley U23", "Napoli",
"PAOK", "Grimsby Town", "Cesena", "Derby County U18", "Fleetwood Town",
"Accrington Stanley", "Fulham U23", "Hull City U18", "Huddersfield Town B",
"Olympiacos Piraeus", "Lincoln City", "Coventry City U23", "Ipswich Town",
"Shrewsbury Town", "Cheltenham Town", "Swansea City U18", "Portimonense",
"Charlton Athletic", "Hibernian", "Bristol City U23", "Millwall U23",
"Hull City U23", "Aris", "Gillingham", "Pisa", "Blackburn Rovers U23",
"Preston North End U18", "Oxford United", "Sheffield United U18",
"Millwall U18", "Ponferradina", "Girona", "Ibiza", "Burgos",
"Brentford", "Real Zaragoza", "Las Palmas", "Eibar", "Real Sociedad B",
"Huesca", "Leganés", "Alcorcón", "Málaga", "Fuenlabrada", "Sporting Gijón",
"Almería", "Lugo", "Real Oviedo", "Real Valladolid", "Tenerife",
"Cartagena", "Amorebieta", "Mirandés", "Real Sociedad", "Real Sociedad III",
"Las Palmas Atlético", "CD Calahorra", NA, "Sporting Gijón B",
"Tenerife B", "Cartagena B", "Girona II", "Valladolid Promesas",
"Getafe", "Real Oviedo Vetusta", "Málaga CF U17", "Alcorcón B",
"Racing Santander", "Fuenlabrada B", "Cádiz", "Elche", "Leganés B",
"Huesca B", "Dnipro-1", "Charlotte Independence", "Deportivo Alavés",
"Valencia", "Real Zaragoza B", "Barcelona", "Mirandés B", "Sabadell",
"Dunkerque", "Pau", "Young Boys", "Ajaccio", "Grenoble", "Dijon",
"Nancy", "Auxerre", "Guingamp", "Paris", "Bastia", "Valenciennes",
"Nîmes", "Rodez ", "Toulouse", "Nancy II", "Le Havre", "Sochaux",
"Niort", "Quevilly Rouen", "Amiens SC", "Caen", "Guingamp II",
"Le Havre U19", "Nîmes II", "Rizespor", "Dijon U19", "Lecce",
"Caen II", "Brescia", "Lech Poznan", "Besiktas", "Parma", "Paris II",
"Famalicão", "Dunkerque II", "Manisa BBSK", "Niort II", "Kayserispor",
"Ajaccio U19", "Quevilly Rouen II", "Dijon II", "Paris U19",
"Bayer Leverkusen", "Le Havre U17", "Nancy U18", "Paris U17",
"Spezia", "Warta Poznan", "Montpellier", "Valenciennes U19",
"U Craiova 1948", "Valenciennes II", "Sochaux U19", "Cosenza",
"Ternana", "Reggina", "Benevento", "SPAL", "Alessandria", "Como",
"Ascoli", "Cittadella", "Monza", "Frosinone", "Pordenone", "Crotone",
"Perugia", "Cremonese", "Vicenza", "Parma U19", "Renate", "Frosinone U19",
"Vålerenga", "ACN Siena", "Reggina U17", "Carrarese", "Salernitana",
"Imolese", "SPAL U19", "Pordenone U17", "Pisa U19", "Triestina",
"Pordenone U19", "Yeni Malatyaspor", "FeralpiSalò", "Vicenza U19",
"Alessandria U19", "Reggina U19", "Empoli", "Ascoli U19", "Crotone U19",
"Cosenza U19", "Benevento U19"
)
),
selectInput(
inputId = "Demarcación_1",
label = "Demarcación: ",
choices = c(
"Portero", "Central", "Lateral", "Mediocentro", "Extremo",
"Delantero"
)
),
selectInput(
inputId = "Nacionalidad_1",
label = "Nacionalidad: ",
choices = c(
"Germany", "Russia", "Austria", "Czech Republic", "Denmark",
"Sweden", "Bosnia and Herzegovina", "Poland", "Spain", "United States",
"Romania", "Finland", "Belgium", "France", "Switzerland", "England",
"Croatia", "Japan", "Slovenia", "Norway", "Mexico", "Serbia",
"Senegal", "Canada", "North Macedonia", "Georgia", "Nigeria",
"Brazil", "Netherlands", "Kosovo", "Curaçao", "Ghana", "Azerbaijan",
"Korea Republic", "Cameroon", "Dominican Republic", "Bulgaria",
"Australia", "Albania", "Luxembourg", "Slovakia", "Italy", "Iceland",
"Gambia", "Ukraine", "Sierra Leone", "Côte d'Ivoire", "Congo DR",
"New Zealand", "Sudan", "Guinea", "Congo", "Wales", "Scotland",
"Estonia", "Montenegro", "Republic of Ireland", "Argentina",
"Northern Ireland", "Portugal", "Saudi Arabia", "Namibia", "Iran",
"Paraguay", "Jamaica", "Guinea-Bissau", "Colombia", "Kenya",
"Cuba", "Angola", "Bermuda", "Ecuador", "Uruguay", "Morocco",
"Equatorial Guinea", "Venezuela", "Peru", "Panama", "Mali", "Egypt",
"Israel", "French Guiana", "Benin", "Gabon", "Cape Verde Islands",
"Guadeloupe", "Tunisia", "Haiti", "Comoros", "Réunion", "Martinique",
"Algeria", "Turkey", "South Africa", "Burkina Faso", "New Caledonia",
"Togo", "Zambia", "Lithuania", "Greece", "Hungary", "Uganda",
"Cyprus", "Moldova", "Madagascar", "Malta", "Chile", "Honduras",
"Latvia"
)
),
selectInput(
inputId = "Pie_Dominante_1",
label = "Pie Dominante: ",
choices = c("derecho", "izquierdo", "ambidiestro", NA, "unknown")
),
sliderInput(
inputId = "Edad_1",
label = "Edad: ",
min = 15,
max = 40,
value = 15,
ticks = FALSE
)
),
box(
title = "INFORMACIÓN DEL PARTIDO ",
background = "light-blue",
width = 12
),
box(
status = "primary",
width = 12,
textInput(
inputId = "Partido_1",
label = "Partido (Equipo Local) (X) - (X) (Equipo Visitante): ",
value = character(0)
),
pickerInput(
inputId = "Demarcación_Partido_1",
label = "Demarcación en el Partido: ",
choices = c(
"Portero", "Central", "Lateral", "Mediocentro", "Extremo",
"Delantero"
),
selected = character(0),
multiple = TRUE,
options = list(`actions-box` = TRUE)
),
sliderInput(
inputId = "Minutos_Partido_1",
label = "Minutos Jugados: ",
min = 0,
max = 90,
value = 0,
ticks = FALSE
)
)
),
column(
width = 8,
box(
title = "VALORACIÓN DE LOS ÍTEMS ",
background = "light-blue",
width = 12
),
box(
title = "Capacidad de jugar con los pies: ",
status = "primary",
width = 12,
radioGroupButtons(
inputId = "1_Valoración_1",
label = "Valoración: ",
choices = c("1", "2", "3", "4"),
selected = character(0),
status = "primary",
justified = TRUE
),
textInput(
inputId = "1_Comentario_1",
label = "Comentarios: "
)
),
box(
title = "Capacidad de salida en balones divididos: ",
status = "primary",
width = 12,
radioGroupButtons(
inputId = "1_Valoración_2",
label = "Valoración: ",
choices = c("1", "2", "3", "4"),
selected = character(0),
status = "primary",
justified = TRUE
),
textInput(
inputId = "1_Comentario_2",
label = "Comentarios: "
)
),
box(
title = "Reflejos: ",
status = "primary",
width = 12,
radioGroupButtons(
inputId = "1_Valoración_3",
label = "Valoración: ",
choices = c("1", "2", "3", "4"),
selected = character(0),
status = "primary",
justified = TRUE
),
textInput(
inputId = "1_Comentario_3",
label = "Comentarios: "
)
),
box(
title = "Dominio del juego aéreo: ",
status = "primary",
width = 12,
radioGroupButtons(
inputId = "1_Valoración_4",
label = "Valoración: ",
choices = c("1", "2", "3", "4"),
selected = character(0),
status = "primary",
justified = TRUE
),
textInput(
inputId = "1_Comentario_4",
label = "Comentarios: "
)
),
box(
title = "Capacidad de comunicación: ",
status = "primary",
width = 12,
radioGroupButtons(
inputId = "1_Valoración_5",
label = "Valoración: ",
choices = c("1", "2", "3", "4"),
selected = character(0),
status = "primary",
justified = TRUE
),
textInput(
inputId = "1_Comentario_5",
label = "Comentarios: "
)
)
)
),
downloadButton(
outputId = "boton",
label = "Guardar",
icon = icon("save", lib = "font-awesome"),
style = "jelly",
color = "primary",
size = "md"
)
)
)
)
)
#----------SERVER----------
server <- function(input, output) {
output$boton <- downloadHandler(
filename = function() {
paste0("df_", input$Scout_1, ".csv")
},
content = function(file) {
map(inpt_nms, ~ input[[.x]]) %>%
set_names(inpt_nms) %>%
{
exec("tibble", !!!.)
} %>%
write_csv(file)
}
)
}
#----------SHINYAPP----------
shinyApp(ui, server)
I use the AWS EKS Quickstart to launch a cluster
I select "t4g.small" or "m6gd.xlarge" as the instance type and "General" as the instance family. But it looks like that is incorrect, is it supposed to be "ARM"? isn't it?
Can I have the "instance family" information from where?
I got an error while deploying the cloudformation stack
Parameter validation failed: assertion error: Valid instance types for the "Standard" instance family are: "t3a.nano", "t3.nano", "t2.nano", "t3a.micro", "t3.micro", "t2.micro", "t3a.small", "t1.micro", "t3.small", "t2.small", "t3a.medium", "t3.medium", "m1.small", "t2.medium", "m3.medium", "t3a.large", "c5a.large", "t3.large", "c5.large", "m5a.large", "c5ad.large", "m1.medium", "t2.large", "c5d.large", "m5.large", "c4.large", "m4.large", "m5ad.large", "c3.large", "c5n.large", "m5d.large", "r5a.large", "m5n.large", "r5.large", "c1.medium", "r5ad.large", "m3.large", "r4.large", "m5dn.large", "r5d.large", "r5n.large", "t3a.xlarge", "c5a.xlarge", "i3.large", "r3.large", "t3.xlarge", "r5dn.large", "c5.xlarge", "c5ad.xlarge", "m5a.xlarge", "m1.large", "t2.xlarge", "z1d.large", "m5.xlarge", "c5d.xlarge", "c4.xlarge", "m4.xlarge", "m5ad.xlarge", "c3.xlarge", "c5n.xlarge", "r5a.xlarge", "m5d.xlarge", "i3en.large", "m5n.xlarge", "m2.xlarge", "r5.xlarge", "r5ad.xlarge", "m3.xlarge", "r4.xlarge", "m5dn.xlarge", "r5d.xlarge", "r5n.xlarge", "t3a.2xlarge", "c5a.2xlarge", "i3.xlarge", "t3.2xlarge", "r3.xlarge", "r5dn.xlarge", "c5.2xlarge", "m5a.2xlarge", "c5ad.2xlarge", "m1.xlarge", "inf1.xlarge", "t2.2xlarge", "z1d.xlarge", "c5d.2xlarge", "m5.2xlarge", "c4.2xlarge", "m4.2xlarge", "m5ad.2xlarge", "c3.2xlarge", "c5n.2xlarge", "r5a.2xlarge", "m5d.2xlarge", "i3en.xlarge", "h1.2xlarge", "m5n.2xlarge", "m2.2xlarge", "r5.2xlarge", "c1.xlarge", "r5ad.2xlarge", "g4dn.xlarge", "r4.2xlarge", "m3.2xlarge", "m5dn.2xlarge", "r5d.2xlarge", "inf1.2xlarge", "r5n.2xlarge", "c5a.4xlarge", "i3.2xlarge", "g2.2xlarge", "r3.2xlarge", "r5dn.2xlarge", "c5.4xlarge", "m5a.4xlarge", "c5ad.4xlarge", "d2.xlarge", "z1d.2xlarge", "g3s.xlarge", "g4dn.2xlarge", "c5d.4xlarge", "m5.4xlarge", "c4.4xlarge", "m4.4xlarge", "m5ad.4xlarge", "x1e.xlarge", "c3.4xlarge", "i2.xlarge", "c5n.4xlarge", "p2.xlarge", "r5a.4xlarge", "i3en.2xlarge", "m5d.4xlarge", "h1.4xlarge", "m5n.4xlarge", "m2.4xlarge", "r5.4xlarge", "r5ad.4xlarge", "r4.4xlarge", "m5dn.4xlarge", "z1d.3xlarge", "g3.4xlarge", "r5d.4xlarge", "r5n.4xlarge", "g4dn.4xlarge", "c5a.8xlarge", "i3.4xlarge", "r3.4xlarge", "r5dn.4xlarge", "i3en.3xlarge", "m5a.8xlarge", "c5ad.8xlarge", "d2.2xlarge", "c5.9xlarge", "m5.8xlarge", "c4.8xlarge", "m5ad.8xlarge", "f1.2xlarge", "x1e.2xlarge", "c3.8xlarge", "i2.2xlarge", "c5d.9xlarge", "m5d.8xlarge", "r5a.8xlarge", "c5a.12xlarge", "h1.8xlarge", "m5n.8xlarge", "inf1.6xlarge", "c5n.9xlarge", "i3en.24xlarge", "i3en.metal", "p3.8xlarge", "f1.16xlarge", "x1.32xlarge", "x1e.16xlarge", "p2.16xlarge", "m4.10xlarge", "cc2.8xlarge", "r5.8xlarge", "c5.12xlarge", "c5ad.12xlarge", "m5a.12xlarge", "r5ad.8xlarge", "r4.8xlarge", "m5dn.8xlarge", "g4dn.8xlarge", "z1d.6xlarge", "g3.8xlarge", "m5.12xlarge", "c5d.12xlarge", "r5d.8xlarge", "r5n.8xlarge", "c5a.16xlarge", "m5ad.12xlarge", "i3.8xlarge", "g2.8xlarge", "r3.8xlarge", "r5dn.8xlarge", "r5a.12xlarge", "m5d.12xlarge", "i3en.6xlarge", "m5a.16xlarge", "c5ad.16xlarge", "d2.4xlarge", "m5n.12xlarge", "p3.16xlarge", "x1e.32xlarge", "r5.12xlarge", "p3.2xlarge", "c5.18xlarge", "m5.16xlarge", "r5ad.12xlarge", "m4.16xlarge", "m5dn.12xlarge", "m5ad.16xlarge", "f1.4xlarge", "x1e.4xlarge", "i2.4xlarge", "c5d.18xlarge", "r5d.12xlarge", "r5n.12xlarge", "m5d.16xlarge", "r5a.16xlarge", "c5a.24xlarge", "h1.16xlarge", "m5n.16xlarge", "c5n.18xlarge", "c5n.metal", "g4dn.12xlarge", "p3dn.24xlarge", "r5dn.12xlarge", "r5.16xlarge", "c5.24xlarge", "c5.metal", "c5ad.24xlarge", "m5a.24xlarge", "r5ad.16xlarge", "r4.16xlarge", "m5dn.16xlarge", "g4dn.16xlarge", "z1d.metal", "z1d.12xlarge", "g3.16xlarge", "m5.24xlarge", "m5.metal", "r5d.16xlarge", "c5d.24xlarge", "c5d.metal", "r5n.16xlarge", "m5ad.24xlarge", "i3.16xlarge", "i3.metal", "r5dn.16xlarge", "i3en.12xlarge", "m5d.metal", "m5d.24xlarge", "r5a.24xlarge", "d2.8xlarge", "m5n.24xlarge", "r5.24xlarge", "r5.metal", "r5ad.24xlarge", "m5dn.24xlarge", "x1.16xlarge", "x1e.8xlarge", "i2.8xlarge", "r5d.24xlarge", "r5d.metal", "r5n.24xlarge", "p2.8xlarge", "inf1.24xlarge", "g4dn.metal", "r5dn.24xlarge"
Edit to provide more infor:
a) the quickstart I used: https://aws-quickstart.github.io/quickstart-amazon-eks/
b) deploy a new VPC: https://us-east-2.console.aws.amazon.com/cloudformation/home?region=us-east-2#/stacks/create/template?stackName=Amazon-EKS&templateURL=https://s3.amazonaws.com/aws-quickstart/quickstart-amazon-eks/templates/amazon-eks-entrypoint-new-vpc.template.yaml
The R/exams package supports including TikZ graphics using its function include_tikz(), e.g., as shown in the automaton and logic exercises shipped with the package.
After getting include_tikz() to work for these exercises (see: Why are TikZ graphics rendered with exams2pdf but not with exams2moodle?) I tried to create my own exercise. However, so far this does not work yet. My code is:
```{r datos1, echo = FALSE, results = "hide"}
options(tinytex.verbose = TRUE)
options(scipen=999)
knitr::opts_chunk$set(echo = TRUE)
##opts_chunk$set(fig.cap="")
library(exams)
library(magick)
questions<-solutions<-explanations<-NULL
questions[1]<-paste("Graph 1.")
solutions[1]<-TRUE
explanations[1]<-"."
questions[2]<-paste("Graph 2.")
solutions[2]<-FALSE
explanations[2]<-"."
questions[3]<-paste("Graph 3.")
solutions[3]<-FALSE
explanations[3]<-"."
questions[4]<-paste("Graph 4.")
solutions[4]<-FALSE
explanations[4]<-"."
orden<-sample(1:4)
questions<-questions[orden]
solutions<-solutions[orden]
explanations<-explanations[orden]
graf01<-'
\\definecolor{uuuuuu}{rgb}{0.26,0.26,0.26};
\\definecolor{zzttqq}{rgb}{0.6,0.2,0};
\\definecolor{ududff}{rgb}{0.30,0.30,1};
\\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1cm,y=1cm]
\\clip(-0.1,-0.1) rectangle (5,5);
\\fill[line width=2pt,color=zzttqq,fill=zzttqq,fill opacity=0.10] (0,0) -- (4.68,-0.02) --
(4.7,4.66) -- (0.02,4.68) -- cycle;
\\draw (0.99,3.80) node[anchor=north west] {\\textbf{49}};
\\draw (3.44,3.80) node[anchor=north west] {\\textbf{12}};
\\draw (2.22,1.74) node[anchor=north west] {\\textbf{14}};
\\draw (2.22,3.00) node[anchor=north west] {\\textbf{5}};
\\draw (2.22,3.96) node[anchor=north west] {\\textbf{6}};
\\draw (1.40,2.53) node[anchor=north west] {\\textbf{8}};
\\draw (3.00,2.53) node[anchor=north west] {\\textbf{9}};
\\draw (3.85,1.39) node[anchor=north west] {\\textbf{}};
\\draw (0.35,4.57) node[anchor=north west] {\\textbf{DH}};
\\draw (3.97,4.57) node[anchor=north west] {\\textbf{CA}};
\\draw (2.31,0.72) node[anchor=north west] {\\textbf{R}};
\\draw [line width=2pt] (1.76,3.08) circle (1.3cm);
\\draw [line width=2pt] (3.05,3.13) circle (1.3cm);
\\draw [line width=2pt] (2.45,1.98) circle (1.3cm);
\\draw [line width=2pt,color=zzttqq] (0,0)-- (4.68,-0.02);
\\draw [line width=2pt,color=zzttqq] (4.68,-0.02)-- (4.7,4.66);
\\draw [line width=2pt,color=zzttqq] (4.7,4.66)-- (0.02,4.68);
\\draw [line width=2pt,color=zzttqq] (0.02,4.68)-- (0,0);
\\begin{scriptsize}
\\draw [fill=ududff] (0,0) circle (2.5pt);
\\draw [fill=ududff] (4.68,-0.02) circle (2.5pt);
\\draw [fill=uuuuuu] (4.7,4.66) circle (2.5pt);
\\draw [fill=uuuuuu] (0.02,4.68) circle (2.5pt);
\\end{scriptsize}
\\end{tikzpicture}
'
```
Question
========
An auto dealer sold 53 cars in a month; 33 of them had hydraulic steering (DH); 21 were
automatic gearboxes (CA); and 38 had radius (R); 4 had hydraulic steering, automatic gears
and radio; 3 had power steering and automatic shifts, but they had no radio; 13 had
automatic gears and radio, but did not have hydraulics and, 15 had hydraulics and radio, but
did not have automatic gears.
The graph that represents the information of the sale in the agency is
Graph 1:
```{r, echo = FALSE, results = "asis"}
include_tikz(graf01, name = "graf01", markup = "markdown",library = c("arrows"))
```
```{r questionlist, echo = FALSE, results = "asis"}
library(exams)
answerlist(questions, markup = "markdown")
```
In other exercises I have included the source code of this image created in TikZ, but outside the R chunks (from \begin{tikzpicture} to \end{tikzpicture}) so that it works with exams2pdf() (screenshot). But I could not get it to work with exams2moodle().
Essentially your code works and I did not have to make many modifications. What I did:
Omit setting the unnecessary options at the beginning of the initial R code chunk.
Omit the unnecessary semicolons at the end of the regular LaTeX commands in graf01 before the {tikzpicture}.
Add a call to match_exams_device() so that the type of graphic created by TikZ can be in the same format as the graphics created by the R/Markdown code chunks (PNG vs. PDF vs. SVG).
Improve the include_tikz() arguments to use the graphic type from the previous item and to include a fixed width.
Subsequently, the biggest change I made was to modify the Question section so that it is about a single graphic and add a corresponding Meta-information section. Doing so the exercise is self-contained and the complete source code for the file cardealer.Rmd is included at the end of this post. With this the following three commands all work:
exams2pdf("cardealer.Rmd") which renders the TikZ graphic into PDF format.
exams2html("cardealer.Rmd") which renders the TikZ graphic into PNG format.
exams2html("cardealer.Rmd", svg = TRUE) which renders the TikZ graphic into SVG format.
And given that exams2html() works the inclusion in exams2moodle() will also work because this internally also generates the same kind of HTML code. In all versions the output looks something like this:
Source code of cardealer.Rmd:
```{r tikzsource, echo = FALSE, results = "hide"}
typ <- match_exams_device()
graf01 <- '
\\definecolor{uuuuuu}{rgb}{0.26,0.26,0.26}
\\definecolor{zzttqq}{rgb}{0.6,0.2,0}
\\definecolor{ududff}{rgb}{0.30,0.30,1}
\\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1cm,y=1cm]
\\clip(-0.1,-0.1) rectangle (5,5);
\\fill[line width=2pt,color=zzttqq,fill=zzttqq,fill opacity=0.10] (0,0) -- (4.68,-0.02) -- (4.7,4.66) -- (0.02,4.68) -- cycle;
\\draw (0.99,3.80) node[anchor=north west] {\\textbf{49}};
\\draw (3.44,3.80) node[anchor=north west] {\\textbf{12}};
\\draw (2.22,1.74) node[anchor=north west] {\\textbf{14}};
\\draw (2.22,3.00) node[anchor=north west] {\\textbf{5}};
\\draw (2.22,3.96) node[anchor=north west] {\\textbf{6}};
\\draw (1.40,2.53) node[anchor=north west] {\\textbf{8}};
\\draw (3.00,2.53) node[anchor=north west] {\\textbf{9}};
\\draw (3.85,1.39) node[anchor=north west] {\\textbf{}};
\\draw (0.35,4.57) node[anchor=north west] {\\textbf{DH}};
\\draw (3.97,4.57) node[anchor=north west] {\\textbf{CA}};
\\draw (2.31,0.72) node[anchor=north west] {\\textbf{R}};
\\draw [line width=2pt] (1.76,3.08) circle (1.3cm);
\\draw [line width=2pt] (3.05,3.13) circle (1.3cm);
\\draw [line width=2pt] (2.45,1.98) circle (1.3cm);
\\draw [line width=2pt,color=zzttqq] (0,0)-- (4.68,-0.02);
\\draw [line width=2pt,color=zzttqq] (4.68,-0.02)-- (4.7,4.66);
\\draw [line width=2pt,color=zzttqq] (4.7,4.66)-- (0.02,4.68);
\\draw [line width=2pt,color=zzttqq] (0.02,4.68)-- (0,0);
\\begin{scriptsize}
\\draw [fill=ududff] (0,0) circle (2.5pt);
\\draw [fill=ududff] (4.68,-0.02) circle (2.5pt);
\\draw [fill=uuuuuu] (4.7,4.66) circle (2.5pt);
\\draw [fill=uuuuuu] (0.02,4.68) circle (2.5pt);
\\end{scriptsize}
\\end{tikzpicture}
'
```
Question
========
An auto dealer sold 103 cars in a month that had at least one of the following features:
hydraulic steering (DH), automatic gearbox (CA), radio (R). The following graph displays
how many cars had which combination of features:
```{r, echo = FALSE, results = "asis"}
include_tikz(graf01, name = "graf", format = typ, markup = "markdown",
library = "arrows", width = "5cm")
```
How many cars had all three features?
Meta-information
================
exname: car dealer
extype: num
exsolution: 5
Solved!
Thanks to the tireless accompaniment of Achim Zeileis. I share the corrected piece of code:
graf01<-c("\\definecolor{uuuuuu}{rgb}{0.26,0.26,0.26}",
"\\definecolor{zzttqq}{rgb}{0.6,0.2,0}",
"\\definecolor{ududff}{rgb}{0.30,0.30,1}",
"\\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1cm,y=1cm]",
"\\clip(-0.1,-0.1) rectangle (5,5);",
"\\fill[line width=2pt,color=zzttqq,fill=zzttqq,fill opacity=0.10] (0,0) -- (4.68,-0.02) -- (4.7,4.66) -- (0.02,4.68) -- cycle;",
"\\draw (0.99,3.80) node[anchor=north west] {\\textbf{49}};",
"\\draw (3.44,3.80) node[anchor=north west] {\\textbf{12}};",
"\\draw (2.22,1.74) node[anchor=north west] {\\textbf{14}};",
"\\draw (2.22,3.00) node[anchor=north west] {\\textbf{5}};",
"\\draw (2.22,3.96) node[anchor=north west] {\\textbf{6}};",
"\\draw (1.40,2.53) node[anchor=north west] {\\textbf{8}};",
"\\draw (3.00,2.53) node[anchor=north west] {\\textbf{9}};",
"\\draw (3.85,1.39) node[anchor=north west] {\\textbf{}};",
"\\draw (0.35,4.57) node[anchor=north west] {\\textbf{DH}};",
"\\draw (3.97,4.57) node[anchor=north west] {\\textbf{CA}};",
"\\draw (2.31,0.72) node[anchor=north west] {\\textbf{R}};",
"\\draw [line width=2pt] (1.76,3.08) circle (1.3cm);",
"\\draw [line width=2pt] (3.05,3.13) circle (1.3cm);",
"\\draw [line width=2pt] (2.45,1.98) circle (1.3cm);",
"\\draw [line width=2pt,color=zzttqq] (0,0)-- (4.68,-0.02);",
"\\draw [line width=2pt,color=zzttqq] (4.68,-0.02)-- (4.7,4.66);",
"\\draw [line width=2pt,color=zzttqq] (4.7,4.66)-- (0.02,4.68);",
"\\draw [line width=2pt,color=zzttqq] (0.02,4.68)-- (0,0);",
"\\begin{scriptsize}",
"\\draw [fill=ududff] (0,0) circle (2.5pt);",
"\\draw [fill=ududff] (4.68,-0.02) circle (2.5pt);",
"\\draw [fill=uuuuuu] (4.7,4.66) circle (2.5pt);",
"\\draw [fill=uuuuuu] (0.02,4.68) circle (2.5pt);",
"\\end{scriptsize}",
"\\end{tikzpicture}")
Then the chunk of code to invoke TicZ is:
```{r, echo = FALSE, results = "asis"}
include_tikz(graf01, name = "graf", markup = "markdown",format = typ,library =
c("arrows"),packages = "booktabs",width = "5cm")
```
The format = typ section is declared at the beginning of the code:
typ <- match_exams_device()
Thanks again, Achim. His work is commendable. Hopefully one day I can make contributions as great as yours in this community. Blessings!
I've added the following to my User model:
COUNTRIES = (
('AD', _('Andorra')),
('AE', _('United Arab Emirates')),
('AF', _('Afghanistan')),
('AG', _('Antigua & Barbuda')),
('AI', _('Anguilla')),
. . .
('YU', _('Yugoslavia')),
('ZA', _('South Africa')),
('ZM', _('Zambia')),
('ZR', _('Zaire')),
('ZW', _('Zimbabwe')),
('ZZ', _('Unknown or unspecified country')),
)
class CountryField(models.CharField):
def __init__(self, *args, **kwargs):
kwargs.setdefault('max_length', 2)
kwargs.setdefault('choices', COUNTRIES)
super(CountryField, self).__init__(*args, **kwargs)
def get_internal_type(self):
return "CharField"
class User(AbstractUser):
...
country = CountryField()
...
This is the migration created because of this change:
class Migration(migrations.Migration):
dependencies = [
('users', '0006_auto_20180207_1902'),
]
operations = [
migrations.AddField(
model_name='user',
name='country',
field=pulsemanager.users.models.CountryField(choices=[('AD', 'Andorra'), ('AE', 'United Arab Emirates'), ('AF', 'Afghanistan'), ('AG', 'Antigua & Barbuda'), ('AI', 'Anguilla'), ('AL', 'Albania'), ('AM', 'Armenia'), ('AN', 'Netherlands Antilles'), ('AO', 'Angola'), ('AQ', 'Antarctica'), ('AR', 'Argentina'), ('AS', 'American Samoa'), ('AT', 'Austria'), ('AU', 'Australia'), ('AW', 'Aruba'), ('AZ', 'Azerbaijan'), ('BA', 'Bosnia and Herzegovina'), ('BB', 'Barbados'), ('BD', 'Bangladesh'), ('BE', 'Belgium'), ('BF', 'Burkina Faso'), ('BG', 'Bulgaria'), ('BH', 'Bahrain'), ('BI', 'Burundi'), ('BJ', 'Benin'), ('BM', 'Bermuda'), ('BN', 'Brunei Darussalam'), ('BO', 'Bolivia'), ('BR', 'Brazil'), ('BS', 'Bahama'), ('BT', 'Bhutan'), ('BV', 'Bouvet Island'), ('BW', 'Botswana'), ('BY', 'Belarus'), ('BZ', 'Belize'), ('CA', 'Canada'), ('CC', 'Cocos (Keeling) Islands'), ('CF', 'Central African Republic'), ('CG', 'Congo'), ('CH', 'Switzerland'), ('CI', 'Ivory Coast'), ('CK', 'Cook Iislands'), ('CL', 'Chile'), ('CM', 'Cameroon'), ('CN', 'China'), ('CO', 'Colombia'), ('CR', 'Costa Rica'), ('CU', 'Cuba'), ('CV', 'Cape Verde'), ('CX', 'Christmas Island'), ('CY', 'Cyprus'), ('CZ', 'Czech Republic'), ('DE', 'Germany'), ('DJ', 'Djibouti'), ('DK', 'Denmark'), ('DM', 'Dominica'), ('DO', 'Dominican Republic'), ('DZ', 'Algeria'), ('EC', 'Ecuador'), ('EE', 'Estonia'), ('EG', 'Egypt'), ('EH', 'Western Sahara'), ('ER', 'Eritrea'), ('ES', 'Spain'), ('ET', 'Ethiopia'), ('FI', 'Finland'), ('FJ', 'Fiji'), ('FK', 'Falkland Islands (Malvinas)'), ('FM', 'Micronesia'), ('FO', 'Faroe Islands'), ('FR', 'France'), ('FX', 'France, Metropolitan'), ('GA', 'Gabon'), ('GB', 'United Kingdom (Great Britain)'), ('GD', 'Grenada'), ('GE', 'Georgia'), ('GF', 'French Guiana'), ('GH', 'Ghana'), ('GI', 'Gibraltar'), ('GL', 'Greenland'), ('GM', 'Gambia'), ('GN', 'Guinea'), ('GP', 'Guadeloupe'), ('GQ', 'Equatorial Guinea'), ('GR', 'Greece'), ('GS', 'South Georgia and the South Sandwich Islands'), ('GT', 'Guatemala'), ('GU', 'Guam'), ('GW', 'Guinea-Bissau'), ('GY', 'Guyana'), ('HK', 'Hong Kong'), ('HM', 'Heard & McDonald Islands'), ('HN', 'Honduras'), ('HR', 'Croatia'), ('HT', 'Haiti'), ('HU', 'Hungary'), ('ID', 'Indonesia'), ('IE', 'Ireland'), ('IL', 'Israel'), ('IN', 'India'), ('IO', 'British Indian Ocean Territory'), ('IQ', 'Iraq'), ('IR', 'Islamic Republic of Iran'), ('IS', 'Iceland'), ('IT', 'Italy'), ('JM', 'Jamaica'), ('JO', 'Jordan'), ('JP', 'Japan'), ('KE', 'Kenya'), ('KG', 'Kyrgyzstan'), ('KH', 'Cambodia'), ('KI', 'Kiribati'), ('KM', 'Comoros'), ('KN', 'St. Kitts and Nevis'), ('KP', "Korea, Democratic People's Republic of"), ('KR', 'Korea, Republic of'), ('KW', 'Kuwait'), ('KY', 'Cayman Islands'), ('KZ', 'Kazakhstan'), ('LA', "Lao People's Democratic Republic"), ('LB', 'Lebanon'), ('LC', 'Saint Lucia'), ('LI', 'Liechtenstein'), ('LK', 'Sri Lanka'), ('LR', 'Liberia'), ('LS', 'Lesotho'), ('LT', 'Lithuania'), ('LU', 'Luxembourg'), ('LV', 'Latvia'), ('LY', 'Libyan Arab Jamahiriya'), ('MA', 'Morocco'), ('MC', 'Monaco'), ('MD', 'Moldova, Republic of'), ('MG', 'Madagascar'), ('MH', 'Marshall Islands'), ('ML', 'Mali'), ('MN', 'Mongolia'), ('MM', 'Myanmar'), ('MO', 'Macau'), ('MP', 'Northern Mariana Islands'), ('MQ', 'Martinique'), ('MR', 'Mauritania'), ('MS', 'Monserrat'), ('MT', 'Malta'), ('MU', 'Mauritius'), ('MV', 'Maldives'), ('MW', 'Malawi'), ('MX', 'Mexico'), ('MY', 'Malaysia'), ('MZ', 'Mozambique'), ('NA', 'Namibia'), ('NC', 'New Caledonia'), ('NE', 'Niger'), ('NF', 'Norfolk Island'), ('NG', 'Nigeria'), ('NI', 'Nicaragua'), ('NL', 'Netherlands'), ('NO', 'Norway'), ('NP', 'Nepal'), ('NR', 'Nauru'), ('NU', 'Niue'), ('NZ', 'New Zealand'), ('OM', 'Oman'), ('PA', 'Panama'), ('PE', 'Peru'), ('PF', 'French Polynesia'), ('PG', 'Papua New Guinea'), ('PH', 'Philippines'), ('PK', 'Pakistan'), ('PL', 'Poland'), ('PM', 'St. Pierre & Miquelon'), ('PN', 'Pitcairn'), ('PR', 'Puerto Rico'), ('PT', 'Portugal'), ('PW', 'Palau'), ('PY', 'Paraguay'), ('QA', 'Qatar'), ('RE', 'Reunion'), ('RO', 'Romania'), ('RU', 'Russian Federation'), ('RW', 'Rwanda'), ('SA', 'Saudi Arabia'), ('SB', 'Solomon Islands'), ('SC', 'Seychelles'), ('SD', 'Sudan'), ('SE', 'Sweden'), ('SG', 'Singapore'), ('SH', 'St. Helena'), ('SI', 'Slovenia'), ('SJ', 'Svalbard & Jan Mayen Islands'), ('SK', 'Slovakia'), ('SL', 'Sierra Leone'), ('SM', 'San Marino'), ('SN', 'Senegal'), ('SO', 'Somalia'), ('SR', 'Suriname'), ('ST', 'Sao Tome & Principe'), ('SV', 'El Salvador'), ('SY', 'Syrian Arab Republic'), ('SZ', 'Swaziland'), ('TC', 'Turks & Caicos Islands'), ('TD', 'Chad'), ('TF', 'French Southern Territories'), ('TG', 'Togo'), ('TH', 'Thailand'), ('TJ', 'Tajikistan'), ('TK', 'Tokelau'), ('TM', 'Turkmenistan'), ('TN', 'Tunisia'), ('TO', 'Tonga'), ('TP', 'East Timor'), ('TR', 'Turkey'), ('TT', 'Trinidad & Tobago'), ('TV', 'Tuvalu'), ('TW', 'Taiwan, Province of China'), ('TZ', 'Tanzania, United Republic of'), ('UA', 'Ukraine'), ('UG', 'Uganda'), ('UM', 'United States Minor Outlying Islands'), ('US', 'United States of America'), ('UY', 'Uruguay'), ('UZ', 'Uzbekistan'), ('VA', 'Vatican City State (Holy See)'), ('VC', 'St. Vincent & the Grenadines'), ('VE', 'Venezuela'), ('VG', 'British Virgin Islands'), ('VI', 'United States Virgin Islands'), ('VN', 'Viet Nam'), ('VU', 'Vanuatu'), ('WF', 'Wallis & Futuna Islands'), ('WS', 'Samoa'), ('YE', 'Yemen'), ('YT', 'Mayotte'), ('YU', 'Yugoslavia'), ('ZA', 'South Africa'), ('ZM', 'Zambia'), ('ZR', 'Zaire'), ('ZW', 'Zimbabwe'), ('ZZ', 'Unknown or unspecified country')], default=django.utils.timezone.now, max_length=2),
preserve_default=False,
),
migrations.AlterField(
model_name='user',
name='last_name',
field=models.CharField(blank=True, max_length=150, verbose_name='last name'),
),
]
Python3 manager migrate produces this error:
django.db.utils.DataError: value too long for type character varying(2)
I did try changing max_length=150 in the alter above max_length=2, but it didn't help. So what am I doing wrong?