oliver
oliver

Reputation: 147

How do I plot the time series data in R?

If I have the following data set

How can I use the data above to draw a graph like the one below? Where the x-axis is for each year and the y-axis draws 10 data for each year and gives a qu shi of their data

enter image description here

Upvotes: 0

Views: 124

Answers (1)

br00t
br00t

Reputation: 1614

library(VGAM)
data(venice)

df_long <- reshape2::melt(data = venice, id.vars = 'year')
plot(value ~ year, data = df_long, bty = 'n', type = 'p', pch = 19) 

scatter plot 1

plot(value ~ year, data = df_long, bty = 'n', type = 'p', pch = '*') 
lines(venice[ , 1 ], venice[ , -1 ] |> rowMeans(), lwd = 2, col = 'blue')

scatter plot with rowMeans

Upvotes: 1

Related Questions