Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read data in Chapter 4 #595

Open
benjamin-coppel opened this issue Nov 24, 2022 · 5 comments · May be fixed by #598
Open

Read data in Chapter 4 #595

benjamin-coppel opened this issue Nov 24, 2022 · 5 comments · May be fixed by #598

Comments

@benjamin-coppel
Copy link

benjamin-coppel commented Nov 24, 2022

When you want to download NEISS data, the url of the repo doesn´t work.

I think that the url was update.

You need to put this url in order to fix the download function

download <- function(name){ url <- "https://github.com/hadley/mastering-shiny/tree/master/neiss/" download.file(paste0(url, name), paste0("neiss/", name), quiet = TRUE) }

@benjamin-coppel
Copy link
Author

For some reason, when I download the data using the function and then read it, the data looks so weird.

I have to download manually

@jonthegeek jonthegeek linked a pull request Dec 12, 2022 that will close this issue
@nmolanog
Copy link

For some reason, when I download the data using the function and then read it, the data looks so weird.

I have to download manually

I have the same issue

@carehu
Copy link

carehu commented Feb 9, 2023

I have

For some reason, when I download the data using the function and then read it, the data looks so weird.
I have to download manually

I have the same issue

I have the same issue. Did you find a solution? when I run the code the data doesn't look like what is the book

This is what I get (my folder path is different but I think that shouldn't be an issue)
image

This is what is in the book
injuries <- vroom::vroom("neiss/injuries.tsv.gz")
injuries
#> # A tibble: 255,064 × 10
#> trmt_date age sex race body_part diag locat…¹ prod_…² weight narra…³
#>
#> 1 2017-01-01 71 male white Upper Trunk Contus… Other … 1807 77.7 71YOM …
#> 2 2017-01-01 16 male white Lower Arm Burns,… Home 676 77.7 16YOM …
#> 3 2017-01-01 58 male white Upper Trunk Contus… Home 649 77.7 58 YOM…
#> 4 2017-01-01 21 male white Lower Trunk Strain… Home 4076 77.7 21 YOM…
#> 5 2017-01-01 54 male white Head Inter … Other … 1807 77.7 54 YOM…
#> 6 2017-01-01 21 male white Hand Fractu… Home 1884 77.7 21 YOM…
#> # … with 255,058 more rows, and abbreviated variable names ¹​location,
#> # ²​prod_code, ³​narrative

@benjamin-coppel
Copy link
Author

@carehu My "non-fancy" solution was download manually the files, put them in a folder and then read the data from this new folder in order to follow the example in the book.

@carehu
Copy link

carehu commented Feb 10, 2023

@carehu My "non-fancy" solution was download manually the files, put them in a folder and then read the data from this new folder in order to follow the example in the book.

Thank you! For products & population data I did like you explained and is working. But for the injuries data it still doesn't work. I have used the R.utils package to unzip the file and if I open the unzipped file in notepad it doesn't look like what is in the book. For now I think I will just skip the examples in this chapter. Thanks.

library(R.utils)
gunzip("neiss/injuries.tsv.gz", remove=FALSE)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants