Do I need to reshape this wide data to effectively use ggplot2?

后端 未结 2 1103
不知归路
不知归路 2020-12-19 02:32

I have a data.frame that looks like

  Year Crustaceans       Cod       Tuna    Herring Scorpion.fishes
1 1950    58578630   2716706   69690537   87161396             


        
2条回答
  •  生来不讨喜
    2020-12-19 02:41

    A simple transformation using melt (from the reshape/2 package) would suffice. I would do

    library(reshape2)
    qplot(Year, value, colour = variable, data = melt(df, 'Year'), geom = 'line')
    

提交回复
热议问题