Hi Team
I have a tibble like the below : class(us_counties) [1] "tbl_df" "tbl" "data.frame" head(us_counties) # A tibble: 6 x 8 date deaths Todays_deaths county state fips <date> <dbl> <dbl> <chr> <chr> <chr> 1 2020-03-19 0 0 Abbev~ Sout~ 45001 2 2020-03-20 0 0 Abbev~ Sout~ 45001 3 2020-03-21 0 0 Abbev~ Sout~ 45001 4 2020-03-22 0 0 Abbev~ Sout~ 45001 5 2020-03-23 0 0 Abbev~ Sout~ 45001 6 2020-03-24 0 0 Abbev~ Sout~ 45001 str(us_counties) tibble [1,082,715 x 8] (S3: tbl_df/tbl/data.frame) $ date : Date[1:1082715], format: "2020-03-19" ... $ deaths : num [1:1082715] 0 0 0 0 0 0 0 0 0 0 ... $ Todays_deaths: num [1:1082715] 0 0 0 0 0 0 0 0 0 0 ... $ county : chr [1:1082715] "Abbeville" "Abbeville" "Abbeville" "Abbeville" ... $ state : chr [1:1082715] "South Carolina" "South Carolina" "South Carolina" "South Carolina" ... $ fips : chr [1:1082715] "45001" "45001" "45001" "45001" ... $ cases : num [1:1082715] 1 1 1 1 1 1 3 4 4 4 ... $ Todays_cases : num [1:1082715] 0 0 0 0 0 0 0 0 0 0 ... - attr(*, "spec")= .. cols( .. date = col_date(format = ""), .. county = col_character(), .. state = col_character(), .. fips = col_character(), .. cases = col_double(), .. deaths = col_double() .. ) - attr(*, ".internal.selfref")=<externalptr> > Now when I display this in shiny UI using a simple command: # Generate an HTML table view of the data ---- output$ttable <- renderTable({ head(us_counties , n = input$obs) }) I get a display like the below datedeathsTodays_deathscountystatefipscasesTodays_cases 18679.00 34.00 0.00 Abbeville South Carolina 45001 2184.00 0.00 18680.00 34.00 0.00 Abbeville South Carolina 45001 2191.00 0.00 18681.00 34.00 0.00 Abbeville South Carolina 45001 2192.00 0.00 This is the change I made old code ======== #x <- getURL(" https://raw.githubusercontent.com/nytimes/covid-19-data/master/us-counties.csv ") #us_counties <- read.csv(text = x) # 855612 Rows , 6 columns class(us_counties) this stopped working, so I changed to below urlfile=" https://raw.githubusercontent.com/nytimes/covid-19-data/master/us-counties.csv " #GN added 3/3 us_counties<-read_csv(url(urlfile),col_types = list(date = col_date())) Please let me know how to correct this Regards Gayathri [[alternative HTML version deleted]] ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. |
Hello,
Your col_types argument is wrong, you only have col_date. library(tidyverse) urlfile <- "https://raw.githubusercontent.com/nytimes/covid-19-data/master/us-counties.csv" #GN added 3/3 cols_spec <- cols( date = col_date(format = ""), county = col_character(), state = col_character(), fips = col_character(), cases = col_double(), deaths = col_double() ) us_counties <- read_csv(url(urlfile), col_types = cols_spec) Hope this helps, Rui Barradas Às 15:24 de 03/03/21, Gayathri Nagarajan escreveu: > Hi Team > > I have a tibble like the below : > > class(us_counties) > [1] "tbl_df" "tbl" "data.frame" > > head(us_counties) > # A tibble: 6 x 8 > date deaths Todays_deaths county state fips > <date> <dbl> <dbl> <chr> <chr> <chr> > 1 2020-03-19 0 0 Abbev~ Sout~ 45001 > 2 2020-03-20 0 0 Abbev~ Sout~ 45001 > 3 2020-03-21 0 0 Abbev~ Sout~ 45001 > 4 2020-03-22 0 0 Abbev~ Sout~ 45001 > 5 2020-03-23 0 0 Abbev~ Sout~ 45001 > 6 2020-03-24 0 0 Abbev~ Sout~ 45001 > > str(us_counties) > tibble [1,082,715 x 8] (S3: tbl_df/tbl/data.frame) > $ date : Date[1:1082715], format: "2020-03-19" ... > $ deaths : num [1:1082715] 0 0 0 0 0 0 0 0 0 0 ... > $ Todays_deaths: num [1:1082715] 0 0 0 0 0 0 0 0 0 0 ... > $ county : chr [1:1082715] "Abbeville" "Abbeville" "Abbeville" > "Abbeville" ... > $ state : chr [1:1082715] "South Carolina" "South Carolina" "South > Carolina" "South Carolina" ... > $ fips : chr [1:1082715] "45001" "45001" "45001" "45001" ... > $ cases : num [1:1082715] 1 1 1 1 1 1 3 4 4 4 ... > $ Todays_cases : num [1:1082715] 0 0 0 0 0 0 0 0 0 0 ... > - attr(*, "spec")= > .. cols( > .. date = col_date(format = ""), > .. county = col_character(), > .. state = col_character(), > .. fips = col_character(), > .. cases = col_double(), > .. deaths = col_double() > .. ) > - attr(*, ".internal.selfref")=<externalptr> >> > > > > Now when I display this in shiny UI using a simple command: > > > # Generate an HTML table view of the data ---- > output$ttable <- renderTable({ > head(us_counties > , n = input$obs) > }) > > > I get a display like the below > > datedeathsTodays_deathscountystatefipscasesTodays_cases > 18679.00 34.00 0.00 Abbeville South Carolina 45001 2184.00 0.00 > 18680.00 34.00 0.00 Abbeville South Carolina 45001 2191.00 0.00 > 18681.00 34.00 0.00 Abbeville South Carolina 45001 2192.00 0.00 > > This is the change I made > > old code > ======== > #x <- getURL(" > https://raw.githubusercontent.com/nytimes/covid-19-data/master/us-counties.csv > ") > #us_counties <- read.csv(text = x) > # 855612 Rows , 6 columns class(us_counties) > > > this stopped working, so I changed to below > > > urlfile=" > https://raw.githubusercontent.com/nytimes/covid-19-data/master/us-counties.csv > " > #GN added 3/3 > us_counties<-read_csv(url(urlfile),col_types = list(date = col_date())) > > Please let me know how to correct this > > Regards > Gayathri > > [[alternative HTML version deleted]] > > ______________________________________________ > [hidden email] mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. |
Hi Rui
I have tried the same but this is not working. when I do head(us_counties), I clearly see this is a date,in R studio console head(us_counties) date deaths Todays_deaths county state fips 1: 2020-03-19 0 0 Abbeville South Carolina 45001 2: 2020-03-20 0 0 Abbeville South Carolina 45001 3: 2020-03-21 0 0 Abbeville South Carolina 45001 4: 2020-03-22 0 0 Abbeville South Carolina 45001 5: 2020-03-23 0 0 Abbeville South Carolina 45001 6: 2020-03-24 0 0 Abbeville South Carolina 45001 cases Todays_cases But the moment this appears in shiny UI, this displays like date deaths Todays_deaths county state fips cases Todays_cases 18340.00 0.00 0.00 Abbeville South Carolina 45001 1.00 0.00 18341.00 0.00 0.00 Abbeville South Carolina 45001 1.00 0.00 Regards Gayathri On Wed, 3 Mar 2021 at 08:25, Rui Barradas <[hidden email]> wrote: > Hello, > > Your col_types argument is wrong, you only have col_date. > > > library(tidyverse) > > urlfile <- > " > https://raw.githubusercontent.com/nytimes/covid-19-data/master/us-counties.csv > " > #GN added 3/3 > cols_spec <- cols( > date = col_date(format = ""), > county = col_character(), > state = col_character(), > fips = col_character(), > cases = col_double(), > deaths = col_double() > ) > > us_counties <- read_csv(url(urlfile), col_types = cols_spec) > > > Hope this helps, > > Rui Barradas > > Às 15:24 de 03/03/21, Gayathri Nagarajan escreveu: > > Hi Team > > > > I have a tibble like the below : > > > > class(us_counties) > > [1] "tbl_df" "tbl" "data.frame" > > > > head(us_counties) > > # A tibble: 6 x 8 > > date deaths Todays_deaths county state fips > > <date> <dbl> <dbl> <chr> <chr> <chr> > > 1 2020-03-19 0 0 Abbev~ Sout~ 45001 > > 2 2020-03-20 0 0 Abbev~ Sout~ 45001 > > 3 2020-03-21 0 0 Abbev~ Sout~ 45001 > > 4 2020-03-22 0 0 Abbev~ Sout~ 45001 > > 5 2020-03-23 0 0 Abbev~ Sout~ 45001 > > 6 2020-03-24 0 0 Abbev~ Sout~ 45001 > > > > str(us_counties) > > tibble [1,082,715 x 8] (S3: tbl_df/tbl/data.frame) > > $ date : Date[1:1082715], format: "2020-03-19" ... > > $ deaths : num [1:1082715] 0 0 0 0 0 0 0 0 0 0 ... > > $ Todays_deaths: num [1:1082715] 0 0 0 0 0 0 0 0 0 0 ... > > $ county : chr [1:1082715] "Abbeville" "Abbeville" "Abbeville" > > "Abbeville" ... > > $ state : chr [1:1082715] "South Carolina" "South Carolina" > "South > > Carolina" "South Carolina" ... > > $ fips : chr [1:1082715] "45001" "45001" "45001" "45001" ... > > $ cases : num [1:1082715] 1 1 1 1 1 1 3 4 4 4 ... > > $ Todays_cases : num [1:1082715] 0 0 0 0 0 0 0 0 0 0 ... > > - attr(*, "spec")= > > .. cols( > > .. date = col_date(format = ""), > > .. county = col_character(), > > .. state = col_character(), > > .. fips = col_character(), > > .. cases = col_double(), > > .. deaths = col_double() > > .. ) > > - attr(*, ".internal.selfref")=<externalptr> > >> > > > > > > > > Now when I display this in shiny UI using a simple command: > > > > > > # Generate an HTML table view of the data ---- > > output$ttable <- renderTable({ > > head(us_counties > > , n = input$obs) > > }) > > > > > > I get a display like the below > > > > datedeathsTodays_deathscountystatefipscasesTodays_cases > > 18679.00 34.00 0.00 Abbeville South Carolina 45001 2184.00 0.00 > > 18680.00 34.00 0.00 Abbeville South Carolina 45001 2191.00 0.00 > > 18681.00 34.00 0.00 Abbeville South Carolina 45001 2192.00 0.00 > > > > This is the change I made > > > > old code > > ======== > > #x <- getURL(" > > > https://raw.githubusercontent.com/nytimes/covid-19-data/master/us-counties.csv > > ") > > #us_counties <- read.csv(text = x) > > # 855612 Rows , 6 columns class(us_counties) > > > > > > this stopped working, so I changed to below > > > > > > urlfile=" > > > https://raw.githubusercontent.com/nytimes/covid-19-data/master/us-counties.csv > > " > > #GN added 3/3 > > us_counties<-read_csv(url(urlfile),col_types = list(date = > col_date())) > > > > Please let me know how to correct this > > > > Regards > > Gayathri > > > > [[alternative HTML version deleted]] > > > > ______________________________________________ > > [hidden email] mailing list -- To UNSUBSCRIBE and more, see > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > > > [[alternative HTML version deleted]] ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. |
In reply to this post by Gayathri Nagarajan
Hello,
This is a known issue with renderTable. Show the results with renderDataTable instead. Hope this helps, Rui Barradas Às 15:24 de 03/03/21, Gayathri Nagarajan escreveu: > Hi Team > > I have a tibble like the below : > > class(us_counties) > [1] "tbl_df" "tbl" "data.frame" > > head(us_counties) > # A tibble: 6 x 8 > date deaths Todays_deaths county state fips > <date> <dbl> <dbl> <chr> <chr> <chr> > 1 2020-03-19 0 0 Abbev~ Sout~ 45001 > 2 2020-03-20 0 0 Abbev~ Sout~ 45001 > 3 2020-03-21 0 0 Abbev~ Sout~ 45001 > 4 2020-03-22 0 0 Abbev~ Sout~ 45001 > 5 2020-03-23 0 0 Abbev~ Sout~ 45001 > 6 2020-03-24 0 0 Abbev~ Sout~ 45001 > > str(us_counties) > tibble [1,082,715 x 8] (S3: tbl_df/tbl/data.frame) > $ date : Date[1:1082715], format: "2020-03-19" ... > $ deaths : num [1:1082715] 0 0 0 0 0 0 0 0 0 0 ... > $ Todays_deaths: num [1:1082715] 0 0 0 0 0 0 0 0 0 0 ... > $ county : chr [1:1082715] "Abbeville" "Abbeville" "Abbeville" > "Abbeville" ... > $ state : chr [1:1082715] "South Carolina" "South Carolina" "South > Carolina" "South Carolina" ... > $ fips : chr [1:1082715] "45001" "45001" "45001" "45001" ... > $ cases : num [1:1082715] 1 1 1 1 1 1 3 4 4 4 ... > $ Todays_cases : num [1:1082715] 0 0 0 0 0 0 0 0 0 0 ... > - attr(*, "spec")= > .. cols( > .. date = col_date(format = ""), > .. county = col_character(), > .. state = col_character(), > .. fips = col_character(), > .. cases = col_double(), > .. deaths = col_double() > .. ) > - attr(*, ".internal.selfref")=<externalptr> >> > > > > Now when I display this in shiny UI using a simple command: > > > # Generate an HTML table view of the data ---- > output$ttable <- renderTable({ > head(us_counties > , n = input$obs) > }) > > > I get a display like the below > > datedeathsTodays_deathscountystatefipscasesTodays_cases > 18679.00 34.00 0.00 Abbeville South Carolina 45001 2184.00 0.00 > 18680.00 34.00 0.00 Abbeville South Carolina 45001 2191.00 0.00 > 18681.00 34.00 0.00 Abbeville South Carolina 45001 2192.00 0.00 > > This is the change I made > > old code > ======== > #x <- getURL(" > https://raw.githubusercontent.com/nytimes/covid-19-data/master/us-counties.csv > ") > #us_counties <- read.csv(text = x) > # 855612 Rows , 6 columns class(us_counties) > > > this stopped working, so I changed to below > > > urlfile=" > https://raw.githubusercontent.com/nytimes/covid-19-data/master/us-counties.csv > " > #GN added 3/3 > us_counties<-read_csv(url(urlfile),col_types = list(date = col_date())) > > Please let me know how to correct this > > Regards > Gayathri > > [[alternative HTML version deleted]] > > ______________________________________________ > [hidden email] mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. |
Hi Rui
Tried renderDatatable, but now my shiny UI shows Blank for my tibble. Not sure what Iam missing suddenly when this was working fine a day back. The one change I did was: x <- getURL(" https://raw.githubusercontent.com/nytimes/covid-19-data/master/us-counties.csv ") us_counties <- read.csv(text = x) Error in function (type, msg, asError = TRUE) : error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version Hence had to change this to : urlfile=" https://raw.githubusercontent.com/nytimes/covid-19-data/master/us-counties.csv " #GN added 3/3 #GN comment 3/4 #us_counties<-read_csv(url(urlfile),col_types = list(date = col_date())) #GN Add 3/4 #GN added 3/3 cols_spec <- cols( date = col_date(format = ""), county = col_character(), state = col_character(), fips = col_character(), cases = col_double(), deaths = col_double() ) us_counties <- read_csv(url(urlfile), col_types = cols_spec) =========================== Regards Gayathri On Thu, 4 Mar 2021 at 08:41, Rui Barradas <[hidden email]> wrote: > Hello, > > This is a known issue with renderTable. Show the results with > renderDataTable instead. > > Hope this helps, > > Rui Barradas > > Às 15:24 de 03/03/21, Gayathri Nagarajan escreveu: > > Hi Team > > > > I have a tibble like the below : > > > > class(us_counties) > > [1] "tbl_df" "tbl" "data.frame" > > > > head(us_counties) > > # A tibble: 6 x 8 > > date deaths Todays_deaths county state fips > > <date> <dbl> <dbl> <chr> <chr> <chr> > > 1 2020-03-19 0 0 Abbev~ Sout~ 45001 > > 2 2020-03-20 0 0 Abbev~ Sout~ 45001 > > 3 2020-03-21 0 0 Abbev~ Sout~ 45001 > > 4 2020-03-22 0 0 Abbev~ Sout~ 45001 > > 5 2020-03-23 0 0 Abbev~ Sout~ 45001 > > 6 2020-03-24 0 0 Abbev~ Sout~ 45001 > > > > str(us_counties) > > tibble [1,082,715 x 8] (S3: tbl_df/tbl/data.frame) > > $ date : Date[1:1082715], format: "2020-03-19" ... > > $ deaths : num [1:1082715] 0 0 0 0 0 0 0 0 0 0 ... > > $ Todays_deaths: num [1:1082715] 0 0 0 0 0 0 0 0 0 0 ... > > $ county : chr [1:1082715] "Abbeville" "Abbeville" "Abbeville" > > "Abbeville" ... > > $ state : chr [1:1082715] "South Carolina" "South Carolina" > "South > > Carolina" "South Carolina" ... > > $ fips : chr [1:1082715] "45001" "45001" "45001" "45001" ... > > $ cases : num [1:1082715] 1 1 1 1 1 1 3 4 4 4 ... > > $ Todays_cases : num [1:1082715] 0 0 0 0 0 0 0 0 0 0 ... > > - attr(*, "spec")= > > .. cols( > > .. date = col_date(format = ""), > > .. county = col_character(), > > .. state = col_character(), > > .. fips = col_character(), > > .. cases = col_double(), > > .. deaths = col_double() > > .. ) > > - attr(*, ".internal.selfref")=<externalptr> > >> > > > > > > > > Now when I display this in shiny UI using a simple command: > > > > > > # Generate an HTML table view of the data ---- > > output$ttable <- renderTable({ > > head(us_counties > > , n = input$obs) > > }) > > > > > > I get a display like the below > > > > datedeathsTodays_deathscountystatefipscasesTodays_cases > > 18679.00 34.00 0.00 Abbeville South Carolina 45001 2184.00 0.00 > > 18680.00 34.00 0.00 Abbeville South Carolina 45001 2191.00 0.00 > > 18681.00 34.00 0.00 Abbeville South Carolina 45001 2192.00 0.00 > > > > This is the change I made > > > > old code > > ======== > > #x <- getURL(" > > > https://raw.githubusercontent.com/nytimes/covid-19-data/master/us-counties.csv > > ") > > #us_counties <- read.csv(text = x) > > # 855612 Rows , 6 columns class(us_counties) > > > > > > this stopped working, so I changed to below > > > > > > urlfile=" > > > https://raw.githubusercontent.com/nytimes/covid-19-data/master/us-counties.csv > > " > > #GN added 3/3 > > us_counties<-read_csv(url(urlfile),col_types = list(date = > col_date())) > > > > Please let me know how to correct this > > > > Regards > > Gayathri > > > > [[alternative HTML version deleted]] > > > > ______________________________________________ > > [hidden email] mailing list -- To UNSUBSCRIBE and more, see > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > > > [[alternative HTML version deleted]] ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. |
Hello,
In us_counties <- read.csv(text = x) remove 'text=', you are reading from a url, not from a text string. Hope this helps, Rui Barradas ----- Mensagem de Gayathri Nagarajan <[hidden email]> --------- Data: Thu, 4 Mar 2021 21:51:05 -0800 De: Gayathri Nagarajan <[hidden email]> Assunto: Re: [R] A tibble with date column appears different in shiny Para: Rui Barradas <[hidden email]> > Hi Rui > > Tried renderDatatable, but now my shiny UI shows Blank for my > tibble. Not sure what Iam missing suddenly when this was working > fine a day back. > > The one change I did was: > > x <- > getURL("https://raw.githubusercontent.com/nytimes/covid-19-data/master/us-counties.csv") > > us_counties <- read.csv(text = x) > > Error in function (type, msg, asError = TRUE) : > > error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert > protocol version > > Hence had to change this to : > > > urlfile="https://raw.githubusercontent.com/nytimes/covid-19-data/master/us-counties.csv" > > #GN added 3/3 > > #GN comment 3/4 > > #us_counties<-read_csv(url(urlfile),col_types = list(date = col_date())) > > #GN Add 3/4 > > #GN added 3/3 > > cols_spec <- cols( > > date = col_date(format = ""), > > county = col_character(), > > state = col_character(), > > fips = col_character(), > > cases = col_double(), > > deaths = col_double() > > ) > > > > us_counties <- read_csv(url(urlfile), col_types = cols_spec) > > =========================== > > > > > > > > Regards > > Gayathri > > On Thu, 4 Mar 2021 at 08:41, Rui Barradas <[hidden email]> wrote: > >> Hello, >> >> >> >> This is a known issue with renderTable. Show the results with >> >> renderDataTable instead. >> >> >> >> Hope this helps, >> >> >> >> Rui Barradas >> >> >> >> Às 15:24 de 03/03/21, Gayathri Nagarajan escreveu: >> >> > Hi Team >> >> > >> >> > I have a tibble like the below : >> >> > >> >> > class(us_counties) >> >> > [1] "tbl_df" "tbl" "data.frame" >> >> > >> >> > head(us_counties) >> >> > # A tibble: 6 x 8 >> >> > date deaths Todays_deaths county state fips >> >> > <date> <dbl> <dbl> <chr> <chr> <chr> >> >> > 1 2020-03-19 0 0 Abbev~ Sout~ 45001 >> >> > 2 2020-03-20 0 0 Abbev~ Sout~ 45001 >> >> > 3 2020-03-21 0 0 Abbev~ Sout~ 45001 >> >> > 4 2020-03-22 0 0 Abbev~ Sout~ 45001 >> >> > 5 2020-03-23 0 0 Abbev~ Sout~ 45001 >> >> > 6 2020-03-24 0 0 Abbev~ Sout~ 45001 >> >> > >> >> > str(us_counties) >> >> > tibble [1,082,715 x 8] (S3: tbl_df/tbl/data.frame) >> >> > $ date : Date[1:1082715], format: "2020-03-19" ... >> >> > $ deaths : num [1:1082715] 0 0 0 0 0 0 0 0 0 0 ... >> >> > $ Todays_deaths: num [1:1082715] 0 0 0 0 0 0 0 0 0 0 ... >> >> > $ county : chr [1:1082715] "Abbeville" "Abbeville" "Abbeville" >> >> > "Abbeville" ... >> >> > $ state : chr [1:1082715] "South Carolina" "South >> Carolina" "South >> >> > Carolina" "South Carolina" ... >> >> > $ fips : chr [1:1082715] "45001" "45001" "45001" "45001" ... >> >> > $ cases : num [1:1082715] 1 1 1 1 1 1 3 4 4 4 ... >> >> > $ Todays_cases : num [1:1082715] 0 0 0 0 0 0 0 0 0 0 ... >> >> > - attr(*, "spec")= >> >> > .. cols( >> >> > .. date = col_date(format = ""), >> >> > .. county = col_character(), >> >> > .. state = col_character(), >> >> > .. fips = col_character(), >> >> > .. cases = col_double(), >> >> > .. deaths = col_double() >> >> > .. ) >> >> > - attr(*, ".internal.selfref")=<externalptr> >> >> >> >> >> > >> >> > >> >> > >> >> > Now when I display this in shiny UI using a simple command: >> >> > >> >> > >> >> > # Generate an HTML table view of the data ---- >> >> > output$ttable <- renderTable({ >> >> > head(us_counties >> >> > , n = input$obs) >> >> > }) >> >> > >> >> > >> >> > I get a display like the below >> >> > >> >> > datedeathsTodays_deathscountystatefipscasesTodays_cases >> >> > 18679.00 34.00 0.00 Abbeville South Carolina 45001 2184.00 0.00 >> >> > 18680.00 34.00 0.00 Abbeville South Carolina 45001 2191.00 0.00 >> >> > 18681.00 34.00 0.00 Abbeville South Carolina 45001 2192.00 0.00 >> >> > >> >> > This is the change I made >> >> > >> >> > old code >> >> > ======== >> >> > #x <- getURL(" >> >> > >> https://raw.githubusercontent.com/nytimes/covid-19-data/master/us-counties.csv >> >> > ") >> >> > #us_counties <- read.csv(text = x) >> >> > # 855612 Rows , 6 columns class(us_counties) >> >> > >> >> > >> >> > this stopped working, so I changed to below >> >> > >> >> > >> >> > urlfile=" >> >> > >> https://raw.githubusercontent.com/nytimes/covid-19-data/master/us-counties.csv >> >> > " >> >> > #GN added 3/3 >> >> > us_counties<-read_csv(url(urlfile),col_types = list(date = >> col_date())) >> >> > >> >> > Please let me know how to correct this >> >> > >> >> > Regards >> >> > Gayathri >> >> > >> >> > [[alternative HTML version deleted]] >> >> > >> >> > ______________________________________________ >> >> > [hidden email] mailing list -- To UNSUBSCRIBE and more, see >> >> > https://stat.ethz.ch/mailman/listinfo/r-help >> >> > PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> >> > and provide commented, minimal, self-contained, reproducible code. >> >> > ----- Fim da mensagem de Gayathri Nagarajan <[hidden email]> ----- [[alternative HTML version deleted]] ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. |
In reply to this post by Gayathri Nagarajan
Hi Rui
Alas, at last this worked and this is what I did : 1) I stopped debugging and started a fresh new table to display in shiny UI using this example-https://shiny.rstudio.com/gallery/basic-datatable.html 2) Now instead of the table mpg, I plugged in my us_counties above at first and it worked :-) I really don't have an answer as to how this was working fine till 2 days back with the reactive inputs I had in Shiny UI or the read.csv <https://stackoverflow.com/questions/14441729/read-a-csv-from-github-into-r> command for the .csv file in GITHUB. Thanks so much to you for your help as you tried to relentlessly help me out the past three days. *So the conclusion is - Starting afresh with DT::dataTableOutput solved the issue* *Code change* *===============* In UI.R: tabPanel(strong("Table"),DT::dataTableOutput("dumtable")) In Server.R output$dumtable <- DT::renderDataTable(DT::datatable({ data <- us_counties data <- data[data$state == input$state,] data <- data[data$county == input$county,] data <- data[data$date >= input$date2,] head(data,n=input$obs) })) ==================== Regards Gayathri On Thu, 4 Mar 2021 at 21:51, Gayathri Nagarajan < [hidden email]> wrote: > Hi Rui > > Tried renderDatatable, but now my shiny UI shows Blank for my tibble. Not > sure what Iam missing suddenly when this was working fine a day back. > > The one change I did was: > > x <- getURL(" > https://raw.githubusercontent.com/nytimes/covid-19-data/master/us-counties.csv > ") > us_counties <- read.csv(text = x) > > Error in function (type, msg, asError = TRUE) : > error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol > version > > Hence had to change this to : > > > urlfile=" > https://raw.githubusercontent.com/nytimes/covid-19-data/master/us-counties.csv > " > #GN added 3/3 > #GN comment 3/4 > #us_counties<-read_csv(url(urlfile),col_types = list(date = col_date())) > #GN Add 3/4 > #GN added 3/3 > cols_spec <- cols( > date = col_date(format = ""), > county = col_character(), > state = col_character(), > fips = col_character(), > cases = col_double(), > deaths = col_double() > ) > > us_counties <- read_csv(url(urlfile), col_types = cols_spec) > =========================== > > > Regards > Gayathri > > > On Thu, 4 Mar 2021 at 08:41, Rui Barradas <[hidden email]> wrote: > >> Hello, >> >> This is a known issue with renderTable. Show the results with >> renderDataTable instead. >> >> Hope this helps, >> >> Rui Barradas >> >> Às 15:24 de 03/03/21, Gayathri Nagarajan escreveu: >> > Hi Team >> > >> > I have a tibble like the below : >> > >> > class(us_counties) >> > [1] "tbl_df" "tbl" "data.frame" >> > >> > head(us_counties) >> > # A tibble: 6 x 8 >> > date deaths Todays_deaths county state fips >> > <date> <dbl> <dbl> <chr> <chr> <chr> >> > 1 2020-03-19 0 0 Abbev~ Sout~ 45001 >> > 2 2020-03-20 0 0 Abbev~ Sout~ 45001 >> > 3 2020-03-21 0 0 Abbev~ Sout~ 45001 >> > 4 2020-03-22 0 0 Abbev~ Sout~ 45001 >> > 5 2020-03-23 0 0 Abbev~ Sout~ 45001 >> > 6 2020-03-24 0 0 Abbev~ Sout~ 45001 >> > >> > str(us_counties) >> > tibble [1,082,715 x 8] (S3: tbl_df/tbl/data.frame) >> > $ date : Date[1:1082715], format: "2020-03-19" ... >> > $ deaths : num [1:1082715] 0 0 0 0 0 0 0 0 0 0 ... >> > $ Todays_deaths: num [1:1082715] 0 0 0 0 0 0 0 0 0 0 ... >> > $ county : chr [1:1082715] "Abbeville" "Abbeville" "Abbeville" >> > "Abbeville" ... >> > $ state : chr [1:1082715] "South Carolina" "South Carolina" >> "South >> > Carolina" "South Carolina" ... >> > $ fips : chr [1:1082715] "45001" "45001" "45001" "45001" ... >> > $ cases : num [1:1082715] 1 1 1 1 1 1 3 4 4 4 ... >> > $ Todays_cases : num [1:1082715] 0 0 0 0 0 0 0 0 0 0 ... >> > - attr(*, "spec")= >> > .. cols( >> > .. date = col_date(format = ""), >> > .. county = col_character(), >> > .. state = col_character(), >> > .. fips = col_character(), >> > .. cases = col_double(), >> > .. deaths = col_double() >> > .. ) >> > - attr(*, ".internal.selfref")=<externalptr> >> >> >> > >> > >> > >> > Now when I display this in shiny UI using a simple command: >> > >> > >> > # Generate an HTML table view of the data ---- >> > output$ttable <- renderTable({ >> > head(us_counties >> > , n = input$obs) >> > }) >> > >> > >> > I get a display like the below >> > >> > datedeathsTodays_deathscountystatefipscasesTodays_cases >> > 18679.00 34.00 0.00 Abbeville South Carolina 45001 2184.00 0.00 >> > 18680.00 34.00 0.00 Abbeville South Carolina 45001 2191.00 0.00 >> > 18681.00 34.00 0.00 Abbeville South Carolina 45001 2192.00 0.00 >> > >> > This is the change I made >> > >> > old code >> > ======== >> > #x <- getURL(" >> > >> https://raw.githubusercontent.com/nytimes/covid-19-data/master/us-counties.csv >> > ") >> > #us_counties <- read.csv(text = x) >> > # 855612 Rows , 6 columns class(us_counties) >> > >> > >> > this stopped working, so I changed to below >> > >> > >> > urlfile=" >> > >> https://raw.githubusercontent.com/nytimes/covid-19-data/master/us-counties.csv >> > " >> > #GN added 3/3 >> > us_counties<-read_csv(url(urlfile),col_types = list(date = >> col_date())) >> > >> > Please let me know how to correct this >> > >> > Regards >> > Gayathri >> > >> > [[alternative HTML version deleted]] >> > >> > ______________________________________________ >> > [hidden email] mailing list -- To UNSUBSCRIBE and more, see >> > https://stat.ethz.ch/mailman/listinfo/r-help >> > PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> > and provide commented, minimal, self-contained, reproducible code. >> > >> > [[alternative HTML version deleted]] ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. |
Free forum by Nabble | Edit this page |