0

Im trying to get a simple plot of a data set with countries and their total amount of covid cases, however my plot is not giving the largest numerical value of cases the largest bar.

Data = read.csv("covid_worldwide.csv")
Data = Data[c("Country", "Total.Cases", "Total.Deaths", "Total.Recovered","Active.Cases", "Total.Test",    "Population")]    
df_subset = Data[1:5, ]

Plot = ggplot(df_subset, aes(x = Country, y = Total.Cases)) +
  geom_bar(stat = "identity", fill = "steelblue") +
  labs(title = "Total Cases by Country", x = "Country", y = "Total Cases")

For example the us has over one hundred million cases but has the smallest bar in the plot when it should be the largest.

The plot in question

any help appreciated

r2evans
  • 141,215
  • 6
  • 77
  • 149
HMG343
  • 1
  • Can you [edit] your question and add the output from `dput(head(Data,20))`? – r2evans Mar 22 '23 at 16:55
  • 4
    Your `Total.Cases` is getting read in as text ("character"), presumably because the CSV has some values that look like text. Either convert to numeric (e.g. with `readr::parse_number`) or better yet, specify the right type at import: https://stackoverflow.com/a/8185739/6851825 – Jon Spring Mar 22 '23 at 16:55

0 Answers0