1

I am trying to plot this data frame on one line graph (with points) using ggplot2, i have managed it on excel easy enough but i would like to generate it in R.

Wakatobi <- read.table("Wakatobi SST.txt", header=T)
Wakatobi

Link To Data Frame in R Studio

Link to excel graph

Uwe
  • 41,420
  • 11
  • 90
  • 134
Matt G
  • 21
  • 2
  • Welcome to stack overflow . please read the following https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – Nico Coallier May 24 '17 at 13:51

1 Answers1

3

You need to first melt your data using reshape.

df <- data.frame(Month = c("Jan", "Feb", "Mar", "Apr"),
                 Var1 = rnorm(4),
                 Var2 = rnorm(4) + 1)

df2 <- melt(df, id.vars="Month", measure.vars=c("Var1", "Var2"))

ggplot(df2, aes(x=Month, y=value, group=variable, color=variable)) + geom_point() + geom_line()
klumbard
  • 165
  • 1
  • 7