我是否需要重塑这些广泛的数据才能有效地使用ggplot2?

Gre*_*gor 10 r ggplot2

我有一个看起来像的data.frame

  Year Crustaceans       Cod       Tuna    Herring Scorpion.fishes
1 1950    58578630   2716706   69690537   87161396        15250015
2 1951    59194582   3861166   34829755   51215349        15454659
3 1952    47562941   4396174   31061481   13962479        12541484
4 1953    68432658   3901176   23225423   13229061         9524564
5 1954    64395489   4412721   20798126   25285539         9890656
6 1955    76111004   4774045   13992697   18910756         8446391
Run Code Online (Sandbox Code Playgroud)

还有几个物种(列),以及从1950年到2006年的几年.我想用ggplot2(我刚刚学习)来探索它.我是否需要转换这些数据,以便物种是有效使用ggplot2的因素?如果没有,我如何避免必须单独为每个物种创建一个层?如果是,(或实际上在任何一种情况下)使用reshapeplyr将列名转换为因子的快速指针将非常感激.

Ram*_*ath 9

使用melt(来自reshape/2包)的简单转换就足够了.我会做

library(reshape2)
qplot(Year, value, colour = variable, data = melt(df, 'Year'), geom = 'line')
Run Code Online (Sandbox Code Playgroud)