-
-
Save jcquiroz/1565291 to your computer and use it in GitHub Desktop.
Plotting fisheries data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(ggplot2) | |
library(reshape) | |
p <- ggplot(subset(reclas)) | |
p1 <- p + geom_bar(aes(factor(length), obs), stat = "identity") | |
p2 <- p1 + facet_wrap(~year) | |
p3 <- p2 + geom_line(aes(factor(length), pre, group = 1)) | |
p4 <- p3 + opts(axis.text.x = theme_text(hjust = 0)) | |
p4 | |
reclas <- structure(list(length = structure(c(1L, 1L, 1L, 1L, 2L, 2L, 2L, | |
2L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, | |
6L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L, 9L, 9L, 9L, 9L, 10L, 10L, | |
10L, 10L, 11L, 11L, 11L, 11L, 12L, 12L, 12L, 12L, 13L, 13L, 13L, | |
13L, 14L, 14L, 14L, 14L, 15L, 15L, 15L, 15L, 16L, 16L, 16L, 16L, | |
17L, 17L, 17L, 17L, 18L, 18L, 18L, 18L, 19L, 19L, 19L, 19L, 20L, | |
20L, 20L, 20L, 21L, 21L, 21L, 21L, 22L, 22L, 22L, 22L, 23L, 23L, | |
23L, 23L, 24L, 24L, 24L, 24L, 25L, 25L, 25L, 25L, 26L, 26L, 26L, | |
26L, 27L, 27L, 27L, 27L, 28L, 28L, 28L, 28L, 29L, 29L, 29L, 29L, | |
30L, 30L, 30L, 30L, 31L, 31L, 31L, 31L), .Label = c("3", "4", | |
"5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", | |
"16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", | |
"27", "28", "29", "30", "31", "32", "33"), class = "factor"), | |
pre = c(7.07942e-08, 1.48385e-09, 1.37764e-07, 2.51423e-22, | |
8.8929e-07, 4.77746e-08, 2.06149e-06, 8.9741e-20, 8.81656e-06, | |
1.08146e-06, 2.32079e-05, 2.18853e-17, 6.89867e-05, 1.72118e-05, | |
0.000196563, 3.64662e-15, 0.000426032, 0.000192597, 0.00125249, | |
4.1515e-13, 0.00207649, 0.00151523, 0.00600423, 3.2292e-11, | |
0.0079878, 0.00838129, 0.0216545, 1.71618e-09, 0.0242513, | |
0.0325949, 0.0587557, 6.23167e-08, 0.0581104, 0.0891238, | |
0.119939, 1.54605e-06, 0.109896, 0.171334, 0.184195, 2.6207e-05, | |
0.16403, 0.231579, 0.212817, 0.000303521, 0.193229, 0.220069, | |
0.184988, 0.00240179, 0.179653, 0.147036, 0.120973, 0.0129855, | |
0.131827, 0.069071, 0.0595175, 0.0479686, 0.0763461, 0.0228125, | |
0.0220297, 0.121069, 0.0348965, 0.0052973, 0.00613454, 0.208777, | |
0.0125897, 0.000864852, 0.00128522, 0.245986, 0.00358683, | |
9.92774e-05, 0.000202725, 0.198023, 0.000810879, 8.03068e-06, | |
2.44258e-05, 0.108918, 0.00015143, 5.25075e-07, 2.82031e-06, | |
0.0409333, 3.01187e-05, 2.08946e-07, 9.02987e-07, 0.0105131, | |
1.11646e-05, 3.74547e-07, 5.79382e-07, 0.00184755, 6.13641e-06, | |
5.30819e-07, 2.90277e-07, 0.00022402, 2.97316e-06, 5.45341e-07, | |
9.88818e-08, 1.98773e-05, 1.10668e-06, 4.05607e-07, 2.26754e-08, | |
1.79336e-06, 3.101e-07, 2.18399e-07, 3.49909e-09, 2.94731e-07, | |
6.52419e-08, 8.5134e-08, 3.6423e-10, 6.37593e-08, 1.03221e-08, | |
2.4025e-08, 2.60293e-11, 1.15123e-08, 1.24972e-09, 4.9083e-09, | |
1.41963e-12, 1.57387e-09, 1.32176e-10, 7.2595e-10, 8.54712e-14, | |
1.61022e-10, 2.02569e-11, 7.77303e-11, 7.12195e-15, 1.2314e-11 | |
), obs = c(0, 0, 0, 0, 0, 0, 0, 0.00303996, 0.0189291, 0, | |
0, 0.00440769, 0.0533164, 0, 0, 0.0100206, 0.196706, 0.00385726, | |
0.000233203, 0.00791579, 0.42849, 0.0271767, 0.00130644, | |
0.0022906, 0.207947, 0.135696, 0.0151972, 0.00125069, 0.0681185, | |
0.0859799, 0.0638548, 0.00130542, 0.0211904, 0.0590357, 0.170654, | |
0.00242685, 0.00483193, 0.0551546, 0.217956, 0.00134443, | |
0.00035545, 0.08681, 0.221795, 0.059601, 7.05e-05, 0.0945243, | |
0.112974, 4.48e-05, 0, 0.12881, 0.0964208, 0.00013683, 2.48e-05, | |
0.140455, 0.0304691, 0.00214853, 0, 0.114135, 0.00203758, | |
0.00201403, 2.03e-05, 0.0480033, 4.65e-06, 0.00372412, 0, | |
0.0133173, 0.000928663, 0.019441, 0, 0.00393934, 0.00136552, | |
0.0404762, 0, 0.00136864, 0.00406985, 0.0682941, 0, 1.57e-05, | |
0.00290267, 0.0707, 0, 0, 0.00628835, 0.0678004, 0, 0.000594094, | |
0.00739727, 0.0415376, 0, 0.000152097, 0.0167815, 0.0221677, | |
0, 0.000244221, 0.00694563, 0.00650439, 0, 0.000226842, 0.00753204, | |
0.00403388, 0, 0.00045938, 0.00793488, 0.00126874, 0, 3.44e-05, | |
0.00328576, 0.00723105, 0, 1.06e-05, 0.00166612, 0.254962, | |
0, 0, 0, 0.226637, 0, 0, 0, 0.0614899, 0, 0, 0, 0.00578473 | |
), year = c(2008, 2009, 2010, 2011, 2008, 2009, 2010, 2011, | |
2008, 2009, 2010, 2011, 2008, 2009, 2010, 2011, 2008, 2009, | |
2010, 2011, 2008, 2009, 2010, 2011, 2008, 2009, 2010, 2011, | |
2008, 2009, 2010, 2011, 2008, 2009, 2010, 2011, 2008, 2009, | |
2010, 2011, 2008, 2009, 2010, 2011, 2008, 2009, 2010, 2011, | |
2008, 2009, 2010, 2011, 2008, 2009, 2010, 2011, 2008, 2009, | |
2010, 2011, 2008, 2009, 2010, 2011, 2008, 2009, 2010, 2011, | |
2008, 2009, 2010, 2011, 2008, 2009, 2010, 2011, 2008, 2009, | |
2010, 2011, 2008, 2009, 2010, 2011, 2008, 2009, 2010, 2011, | |
2008, 2009, 2010, 2011, 2008, 2009, 2010, 2011, 2008, 2009, | |
2010, 2011, 2008, 2009, 2010, 2011, 2008, 2009, 2010, 2011, | |
2008, 2009, 2010, 2011, 2008, 2009, 2010, 2011, 2008, 2009, | |
2010, 2011, 2008, 2009, 2010, 2011)), row.names = c(NA, -124L | |
), .Names = c("length", "pre", "obs", "year"), class = "data.frame") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(ggplot2) | |
library(reshape) | |
p <- ggplot(subset(reclas)) | |
p1 <- p + geom_bar(aes(factor(length), obs), stat = "identity") | |
p2 <- p1 + facet_wrap(~year) | |
p3 <- p2 + geom_line(aes(factor(length), pre, group = 1)) | |
p4 <- p3 + opts(axis.text.x = theme_text(hjust = 0)) | |
p4 | |
reclas <- structure(list(length = structure(c(1L, 1L, 1L, 1L, 2L, 2L, 2L, | |
2L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, | |
6L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L, 9L, 9L, 9L, 9L, 10L, 10L, | |
10L, 10L, 11L, 11L, 11L, 11L, 12L, 12L, 12L, 12L, 13L, 13L, 13L, | |
13L, 14L, 14L, 14L, 14L, 15L, 15L, 15L, 15L, 16L, 16L, 16L, 16L, | |
17L, 17L, 17L, 17L, 18L, 18L, 18L, 18L, 19L, 19L, 19L, 19L, 20L, | |
20L, 20L, 20L, 21L, 21L, 21L, 21L, 22L, 22L, 22L, 22L, 23L, 23L, | |
23L, 23L, 24L, 24L, 24L, 24L, 25L, 25L, 25L, 25L, 26L, 26L, 26L, | |
26L, 27L, 27L, 27L, 27L, 28L, 28L, 28L, 28L, 29L, 29L, 29L, 29L, | |
30L, 30L, 30L, 30L, 31L, 31L, 31L, 31L), .Label = c("3", "4", | |
"5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", | |
"16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", | |
"27", "28", "29", "30", "31", "32", "33"), class = "factor"), | |
pre = c(7.07942e-08, 1.48385e-09, 1.37764e-07, 2.51423e-22, | |
8.8929e-07, 4.77746e-08, 2.06149e-06, 8.9741e-20, 8.81656e-06, | |
1.08146e-06, 2.32079e-05, 2.18853e-17, 6.89867e-05, 1.72118e-05, | |
0.000196563, 3.64662e-15, 0.000426032, 0.000192597, 0.00125249, | |
4.1515e-13, 0.00207649, 0.00151523, 0.00600423, 3.2292e-11, | |
0.0079878, 0.00838129, 0.0216545, 1.71618e-09, 0.0242513, | |
0.0325949, 0.0587557, 6.23167e-08, 0.0581104, 0.0891238, | |
0.119939, 1.54605e-06, 0.109896, 0.171334, 0.184195, 2.6207e-05, | |
0.16403, 0.231579, 0.212817, 0.000303521, 0.193229, 0.220069, | |
0.184988, 0.00240179, 0.179653, 0.147036, 0.120973, 0.0129855, | |
0.131827, 0.069071, 0.0595175, 0.0479686, 0.0763461, 0.0228125, | |
0.0220297, 0.121069, 0.0348965, 0.0052973, 0.00613454, 0.208777, | |
0.0125897, 0.000864852, 0.00128522, 0.245986, 0.00358683, | |
9.92774e-05, 0.000202725, 0.198023, 0.000810879, 8.03068e-06, | |
2.44258e-05, 0.108918, 0.00015143, 5.25075e-07, 2.82031e-06, | |
0.0409333, 3.01187e-05, 2.08946e-07, 9.02987e-07, 0.0105131, | |
1.11646e-05, 3.74547e-07, 5.79382e-07, 0.00184755, 6.13641e-06, | |
5.30819e-07, 2.90277e-07, 0.00022402, 2.97316e-06, 5.45341e-07, | |
9.88818e-08, 1.98773e-05, 1.10668e-06, 4.05607e-07, 2.26754e-08, | |
1.79336e-06, 3.101e-07, 2.18399e-07, 3.49909e-09, 2.94731e-07, | |
6.52419e-08, 8.5134e-08, 3.6423e-10, 6.37593e-08, 1.03221e-08, | |
2.4025e-08, 2.60293e-11, 1.15123e-08, 1.24972e-09, 4.9083e-09, | |
1.41963e-12, 1.57387e-09, 1.32176e-10, 7.2595e-10, 8.54712e-14, | |
1.61022e-10, 2.02569e-11, 7.77303e-11, 7.12195e-15, 1.2314e-11 | |
), obs = c(0, 0, 0, 0, 0, 0, 0, 0.00303996, 0.0189291, 0, | |
0, 0.00440769, 0.0533164, 0, 0, 0.0100206, 0.196706, 0.00385726, | |
0.000233203, 0.00791579, 0.42849, 0.0271767, 0.00130644, | |
0.0022906, 0.207947, 0.135696, 0.0151972, 0.00125069, 0.0681185, | |
0.0859799, 0.0638548, 0.00130542, 0.0211904, 0.0590357, 0.170654, | |
0.00242685, 0.00483193, 0.0551546, 0.217956, 0.00134443, | |
0.00035545, 0.08681, 0.221795, 0.059601, 7.05e-05, 0.0945243, | |
0.112974, 4.48e-05, 0, 0.12881, 0.0964208, 0.00013683, 2.48e-05, | |
0.140455, 0.0304691, 0.00214853, 0, 0.114135, 0.00203758, | |
0.00201403, 2.03e-05, 0.0480033, 4.65e-06, 0.00372412, 0, | |
0.0133173, 0.000928663, 0.019441, 0, 0.00393934, 0.00136552, | |
0.0404762, 0, 0.00136864, 0.00406985, 0.0682941, 0, 1.57e-05, | |
0.00290267, 0.0707, 0, 0, 0.00628835, 0.0678004, 0, 0.000594094, | |
0.00739727, 0.0415376, 0, 0.000152097, 0.0167815, 0.0221677, | |
0, 0.000244221, 0.00694563, 0.00650439, 0, 0.000226842, 0.00753204, | |
0.00403388, 0, 0.00045938, 0.00793488, 0.00126874, 0, 3.44e-05, | |
0.00328576, 0.00723105, 0, 1.06e-05, 0.00166612, 0.254962, | |
0, 0, 0, 0.226637, 0, 0, 0, 0.0614899, 0, 0, 0, 0.00578473 | |
), year = c(2008, 2009, 2010, 2011, 2008, 2009, 2010, 2011, | |
2008, 2009, 2010, 2011, 2008, 2009, 2010, 2011, 2008, 2009, | |
2010, 2011, 2008, 2009, 2010, 2011, 2008, 2009, 2010, 2011, | |
2008, 2009, 2010, 2011, 2008, 2009, 2010, 2011, 2008, 2009, | |
2010, 2011, 2008, 2009, 2010, 2011, 2008, 2009, 2010, 2011, | |
2008, 2009, 2010, 2011, 2008, 2009, 2010, 2011, 2008, 2009, | |
2010, 2011, 2008, 2009, 2010, 2011, 2008, 2009, 2010, 2011, | |
2008, 2009, 2010, 2011, 2008, 2009, 2010, 2011, 2008, 2009, | |
2010, 2011, 2008, 2009, 2010, 2011, 2008, 2009, 2010, 2011, | |
2008, 2009, 2010, 2011, 2008, 2009, 2010, 2011, 2008, 2009, | |
2010, 2011, 2008, 2009, 2010, 2011, 2008, 2009, 2010, 2011, | |
2008, 2009, 2010, 2011, 2008, 2009, 2010, 2011, 2008, 2009, | |
2010, 2011, 2008, 2009, 2010, 2011)), row.names = c(NA, -124L | |
), .Names = c("length", "pre", "obs", "year"), class = "data.frame") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment