Back
In R programming, the instance on the help page for the dataset provides a plot using matplot. For something slightly more pleasing, you can try ggplot.
library(tidyr) # For pivoting the data into long-form library(tibble) # For converting the rownames (Year) to a columnlibrary(scales) # For scaling the y-axis and labelslibrary(ggplot2) # For the plotWorldPhones %>% as.data.frame() %>% rownames_to_column("Year") %>% pivot_longer(cols=-Year, names_to="Country", values_to="Users") %>% ggplot(aes(Year, Users, group=Country, col=Country)) + geom_line() + scale_y_log10(n.breaks=5, labels = trans_format("log10", math_format(10^.x))) + theme_minimal()
library(tidyr) # For pivoting the data into long-form
library(tibble) # For converting the rownames (Year) to a column
library(scales) # For scaling the y-axis and labels
library(ggplot2) # For the plot
WorldPhones %>%
as.data.frame() %>%
rownames_to_column("Year") %>%
pivot_longer(cols=-Year, names_to="Country", values_to="Users") %>%
ggplot(aes(Year, Users, group=Country, col=Country)) +
geom_line() +
scale_y_log10(n.breaks=5, labels = trans_format("log10", math_format(10^.x))) +
theme_minimal()
31k questions
32.8k answers
501 comments
693 users