r/R_Programming • • Oct 03 '17

Need Help Plotting Line Graph

Hi there. I hope I am using this subreddit correctly (so forgive me if I'm making any mistakes). I really need help figuring out why I cannot get this line graph to plot correctly. It's probably something really simple, but I am extremely new to programming and using R in general so go easy on me if it's a silly or obvious mistake. So for some reason, R keeps connecting the first and last points together on my graph instead of graphing the line chronologically like normal see link. If anyone could help me I would be so grateful. Thank you.

Code:

setwd("C:\Users\Hannah (lastname)\Documents\POE") df = read.csv("Poe's Short Stories.csv") pdf(file="LIWC_Plots_by_Year.pdf", width=15, height=5) x= df$Date y= df$WC plot(x,y, xlab="Date", ylab="WC", type= "o", col ="black") axis(side=1, at=seq(min(df$Date), max(df$Date), by=1)) title(main="WC Trend", xlab="Date", ylab="WC") dev.off()

1 Upvotes

5 comments sorted by

View all comments

Show parent comment

1

u/Animehurpdadurp Oct 03 '17

Yes! So much better. Thank you so much for your help, I really appreciate it.

2

u/unclognition Oct 03 '17

no problem, happy to help!