alisa alisa - 1 month ago 8
R Question

How to make a basic ggplot2 time series graph

I need to graph

sat -0.038685744
sun -0.004397419
mon -0.072163337
tue 0.123328564
wed 0.021875962
thu 0.005030862
fri 0.002869955


but the steps on r-graph-gallery are confusing, so can someone help me out with a simple graph that shows days of the week on the x axis in
ggplot2
?

Answer Source

Here's how I convert your sample data into a dataframe (though next time you really should use dput to share your data):

df = read.table(text = "
            sat -0.038685744            
            sun -0.004397419            
            mon -0.072163337            
            tue 0.123328564         
            wed 0.021875962         
            thu 0.005030862         
            fri 0.002869955 ")
colnames(df) = c("day", "thing")

And here's how I convert the dataframe into a bar chart:

library(ggplot2)
ggplot(df, aes(day, thing)) + geom_bar(stat = "identity")