musaad
April 2, 2020, 7:14pm
1
Dears,
I've been trying to read CSV data and i have the following code:
d_recovered <- recovered %>%
pivot_longer(-c(Province.State
,Country.Region
, Lat, Long), names_to = "date" , values_to = "recovered_num") %>%
clean_names() %>%
mutate(
date = as.Date(date, format = "%m/%d/%y")
) %>%
group_by(date, country_region) %>%
summarise(recovered_num = sum(recovered_num))
the question here is that how can i get red of X and replace it with Zero in the date column as it appears when i tried to read the file.
The dataset looks like the following:
and because of the X letter appeared in the date column i got NA values
musaad
April 2, 2020, 7:20pm
2
And this is the result set i get because of the letter X in the date column:
Hi!
To help us help you, could you please prepare a repr oducible ex ample (reprex) illustrating your issue? Please have a look at this guide, to see how to create one:
A minimal reproducible example consists of the following items:
A minimal dataset, necessary to reproduce the issue
The minimal runnable code necessary to reproduce the issue, which can be run
on the given dataset, and including the necessary information on the used packages.
Let's quickly go over each one of these with examples:
Minimal Dataset (Sample Data)
You need to provide a data frame that is small enough to be (reasonably) pasted on a post, but big enough to reproduce your issue.
Let's say, as an example, that you are working with the iris data frame
head(iris)
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> 1 5.1 3.5 1.4 0.…
system
Closed
April 23, 2020, 8:27pm
4
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.