0

I am trying to plot a line graph in R with multiple variables as the following data frame: Data Frame

I would like to get a plot as the next one: Plot

I have tried different methods but not being able to get this done, any suggestion?

Gregor Thomas
  • 136,190
  • 20
  • 167
  • 294
  • 2
    Hi Carlos, you should have a read of [this thread](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) so people have the best chance of being able to help you. On first glance however, I'd question why you want a line graph for your data. A bar chart might be more suitable. – Michael Bird Aug 03 '17 at 14:47
  • Thank you so much for your support, I already had a look and your suggestion makes sense. – Carlos Eduardo Castillo Garzón Aug 03 '17 at 23:33

1 Answers1

0

This should get you started, but I would tend to agree with Michael that a line plot may not be the way to go.

test <- data.frame(Name = c('M','D','T','H','P'),
                   Ball_Control = c(48,31,23,34,22),
                   Dribbling = c(30,13,13,10,12),
                   Marking = c(10,13,11,12,11),
                   Sliding_Tackle = c(11,13,16,18,12))
library(ggplot2)
library(tidyr)

df.gathered <- gather(test,key = 'Parameter',value = 'Value',2:5)

ggplot(df.gathered, aes(x = Parameter, y = Value, group = Name, col = Name))+geom_line()+
  scale_y_continuous(limits = c(0,60), breaks = seq(0,60,10))
Balter
  • 1,085
  • 6
  • 12