AntoineSoetewey / statsandr

A blog on statistics and R aiming at helping academics and professionals working with data to grasp important concepts in statistics and to apply them in R. See www.statsandr.com
http://statsandr.com/
35 stars 15 forks source link

Error: object 'death' not found #3

Closed exclusivemekus closed 4 years ago

exclusivemekus commented 4 years ago

Hi There! Thank you very much for your tutorial. I am unable to replicate your code/results I get the following message: "Error: object 'death' not found" after running the following code segment:

%>% <- magrittr::%>%

extract the cumulative incidence

df <- coronavirus %>% dplyr::filter(Country.Region == "Belgium") %>% dplyr::group_by(date, type) %>% dplyr::summarise(total = sum(cases, na.rm = TRUE)) %>% tidyr::pivot_wider( names_from = type, values_from = total ) %>% dplyr::arrange(date) %>% dplyr::ungroup() %>% dplyr::mutate(active = confirmed - death - recovered) %>% dplyr::mutate( confirmed_cum = cumsum(confirmed), death_cum = cumsum(death), recovered_cum = cumsum(recovered), active_cum = cumsum(active) )

I am sure I am doing the right thing and also have relevant packages loaded. Please check. Thanks, Emmy

AntoineSoetewey commented 4 years ago

Hi Emmy,

I just tried on my side and it worked.

So are you sure the {coronavirus} package is properly installed and loaded? To check this, do you see the dataset when you run View(coronavirus)?

Let me know if this helps.

Best, Antoine

exclusivemekus commented 4 years ago

Hi Antoine,

Thank you very much for your quick response.

I did everything you advised, yet unable to get it to work directly from the embedded dataset. I went directly to the data source to download the dataset; it worked that way.

Thank you very much again.

I will be glad to see you do the advanced analysis you mentioned at the end of the text.

Cheers!

Emmy

AntoineSoetewey commented 4 years ago

Glad you fixed it! I'll try to write another blog post with more advanced analyses. Best, Antoine