Related
Question: why is geom_line() not connecting through geom_point()?
I have:
Written with
ggplot(a,
aes(x = month, color = year, fill = year)) +
scale_color_manual(values = colsze) +
scale_fill_manual(values = alpha(colsze, .2)) +
scale_x_discrete(labels = c("January", "February", "March", "April", "May",
"June", "July", "August", "Septemer",
"October", "November", "December")) +
geom_point(aes(y = n), size = 4, shape=19) +
geom_line(aes(y = n)) +
scale_y_continuous(breaks = seq(0, 120, 10), limits = c(0, 120)) +
facet_wrap(.~year)
I cannot figure out why this does not work? E.g. following tutorials like this
geom_line() seems to appear in the legend but not in plot.
a <- structure(list(month = structure(c(4L, 1L, 4L, 7L, 1L, 9L, 2L,
8L, 8L, 10L, 7L, 10L, 9L, 9L, 9L, 2L, 10L, 7L, 4L, 2L, 2L, 3L,
11L, 11L, 12L, 9L, 12L, 10L, 10L, 10L, 11L, 5L, 10L, 10L, 10L,
10L, 10L, 12L, 11L, 7L, 12L, 6L, 9L, 9L, 9L, 7L, 9L, 4L, 12L,
12L, 11L, 3L, 3L, 11L, 11L, 11L, 7L, 11L, 12L, 12L, 12L, 2L,
4L, 1L, 11L, 11L, 1L, 4L, 8L, 2L, 10L, 5L, 5L, 6L, 7L, 11L, 11L,
11L, 11L, 11L, 12L, 11L, 10L, 7L, 12L, 9L, 9L, 7L, 10L, 8L, 8L,
5L, 9L, 10L, 9L, 3L, 8L, 10L, 10L, 8L), .Label = c("1", "2",
"3", "4", "5", "6", "7", "8", "9", "10", "11", "12"), class = "factor"),
year = structure(c(3L, 3L, 2L, 1L, 4L, 4L, 4L, 1L, 1L, 1L,
3L, 1L, 2L, 1L, 1L, 3L, 1L, 4L, 1L, 1L, 1L, 1L, 1L, 1L, 3L,
1L, 3L, 3L, 3L, 3L, 4L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 2L,
4L, 4L, 2L, 2L, 2L, 2L, 1L, 3L, 1L, 1L, 2L, 1L, 1L, 2L, 2L,
2L, 4L, 1L, 3L, 3L, 3L, 2L, 3L, 2L, 2L, 1L, 2L, 2L, 1L, 4L,
2L, 1L, 1L, 4L, 4L, 2L, 2L, 4L, 4L, 2L, 3L, 3L, 3L, 4L, 4L,
1L, 1L, 3L, 4L, 1L, 1L, 2L, 2L, 2L, 2L, 3L, 3L, 1L, 1L, 1L
), .Label = c("2017", "2018", "2019", "2020"), class = "factor"),
n = c(92L, 95L, 83L, 95L, 70L, 88L, 94L, 103L, 103L, 98L,
95L, 98L, 90L, 89L, 89L, 76L, 98L, 97L, 79L, 103L, 103L,
111L, 104L, 104L, 73L, 89L, 73L, 107L, 107L, 107L, 88L, 111L,
107L, 107L, 107L, 107L, 107L, 73L, 104L, 78L, 87L, 92L, 90L,
90L, 90L, 78L, 89L, 92L, 98L, 98L, 85L, 111L, 111L, 85L,
85L, 85L, 97L, 104L, 73L, 73L, 73L, 71L, 92L, 99L, 85L, 104L,
99L, 83L, 103L, 94L, 90L, 90L, 90L, 92L, 97L, 85L, 85L, 88L,
88L, 85L, 73L, 89L, 107L, 97L, 87L, 89L, 89L, 95L, 96L, 103L,
103L, 75L, 90L, 90L, 90L, 88L, 87L, 98L, 98L, 103L)), row.names = c(NA,
-100L), groups = structure(list(month = structure(c(1L, 1L, 1L,
2L, 2L, 2L, 2L, 3L, 3L, 4L, 4L, 4L, 5L, 5L, 5L, 6L, 7L, 7L, 7L,
7L, 8L, 8L, 9L, 9L, 9L, 10L, 10L, 10L, 10L, 11L, 11L, 11L, 11L,
12L, 12L, 12L), .Label = c("1", "2", "3", "4", "5", "6", "7",
"8", "9", "10", "11", "12"), class = "factor"), year = structure(c(2L,
3L, 4L, 1L, 2L, 3L, 4L, 1L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 4L, 1L,
2L, 3L, 4L, 1L, 3L, 1L, 2L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L,
1L, 3L, 4L), .Label = c("2017", "2018", "2019", "2020"), class = "factor"),
.rows = structure(list(c(64L, 67L), 2L, 5L, 20:21, 62L, 16L,
c(7L, 70L), c(22L, 52L, 53L), 96L, 19L, c(3L, 68L), c(1L,
48L, 63L), 72:73, 92L, 32L, c(42L, 74L), 4L, c(40L, 46L
), c(11L, 88L), c(18L, 57L, 75L, 84L), c(8L, 9L, 69L,
90L, 91L, 100L), 97L, c(14L, 15L, 26L, 47L, 86L, 87L),
c(13L, 43L, 44L, 45L, 93L, 95L), 6L, c(10L, 12L, 17L,
98L, 99L), c(71L, 94L), c(28L, 29L, 30L, 33L, 34L, 35L,
36L, 37L, 83L), 89L, c(23L, 24L, 39L, 58L, 66L), c(51L,
54L, 55L, 56L, 65L, 76L, 77L, 80L), 82L, c(31L, 78L,
79L), 49:50, c(25L, 27L, 38L, 59L, 60L, 61L, 81L), c(41L,
85L)), ptype = integer(0), class = c("vctrs_list_of",
"vctrs_vctr", "list"))), row.names = c(NA, 36L), class = c("tbl_df",
"tbl", "data.frame"), .drop = TRUE), class = c("grouped_df",
"tbl_df", "tbl", "data.frame"))
Try this:
ggplot(a,
aes(x = as.numeric(month), color = year, fill = year)) +
# scale_color_manual(values = colsze) +
# scale_fill_manual(values = alpha(colsze, .2)) +
scale_x_continuous(breaks = c(1,2,3,4,5,6,7,8,9,10,11,12),
labels = c("January", "February", "March", "April", "May",
"June", "July", "August", "Septemer",
"October", "November", "December")) +
geom_point(aes(y = n), size = 4, shape=19) +
geom_line(aes(y = n)) +
scale_y_continuous(breaks = seq(0, 120, 10), limits = c(0, 120)) +
facet_wrap(.~year)
I commented on those two lines because in your reproducible example there is no variable colsze.
The problem is that month is a factor and must first be converted to numeric. For a better visualization, evaluate whether to rotate the labels on the x axis by 45 °
so I have data about Sites, nested in Class. In each Site there is a Time (timepoint) variable. The data of interest is Count1, Total1, Count2, Total2.
I know there are whole duplicate sets within Class, across Sites for the values of Count1, Total1, Count2, Total2 for Time.
Here's what I mean - Let's say we have Class 1, with the first Site:
Class Site Time Count1 Total1 Count2 Total2
1 a0QjvO281o1 1 8 64 4 34
1 a0QjvO281o1 2 16 64 8 34
1 a0QjvO281o1 3 16 64 8 34
1 a0QjvO281o1 4 16 64 8 34
1 a0QjvO281o1 6 8 64 4 34
And, I've noticed there are several other Sites with this EXACT pattern (or other repeated patterns).
Class Site Time Count1 Total1 Count2 Total2
1 zlG1VmpE6QQ 1 8 64 4 34
1 zlG1VmpE6QQ 2 16 64 8 34
1 zlG1VmpE6QQ 3 16 64 8 34
1 zlG1VmpE6QQ 4 16 64 8 34
1 zlG1VmpE6QQ 6 8 64 4 34
I want to identify within Class how many Sites have the same pattern. Either marking them or reducing the data sets to the first unique site pattern, but I would like to be able to say how many Sites fit each found pattern.
So, here's the partial data:
df <-
structure(list(Class = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), Site = structure(c(3L,
3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 6L, 6L, 6L, 6L, 6L, 9L, 9L,
9L, 9L, 9L, 17L, 17L, 17L, 17L, 17L, 19L, 19L, 19L, 19L, 19L,
30L, 30L, 30L, 30L, 30L, 49L, 49L, 49L, 49L, 49L, 54L, 54L, 54L,
54L, 54L, 56L, 56L, 56L, 56L, 56L, 62L, 62L, 62L, 62L, 62L, 66L,
66L, 66L, 66L, 66L, 86L, 86L, 86L, 86L, 86L, 88L, 88L, 88L, 88L,
88L, 98L, 98L, 98L, 98L, 98L, 33L, 33L, 33L, 33L, 33L, 128L,
128L, 128L, 128L, 128L, 141L, 141L, 141L, 141L, 141L, 153L, 153L,
153L, 153L, 153L, 154L, 154L, 154L, 154L, 154L, 274L, 274L, 274L,
274L, 274L, 291L, 291L, 291L, 291L, 291L, 306L, 306L, 306L, 306L,
306L, 309L, 309L, 309L, 309L, 309L, 336L, 336L, 336L, 336L, 336L,
342L, 342L, 342L, 342L, 342L, 396L, 396L, 396L, 396L, 396L, 413L,
413L, 413L, 413L, 413L, 418L, 418L, 418L, 418L, 418L, 435L, 435L,
435L, 435L, 435L, 451L), .Label = c("~", "A0e3A15Lh1d", "a0QjvO281o1",
"A0R2gEqRbTv", "A4J3Jp6KNz2", "A757EHpLOya", "A8kkDgEvEZV", "ab5F7MfRxZW",
"AcjfpLUXjwt", "admxsO3fTtq", "aEBm7REs6XS", "AEZgWxwdbd9", "AezXCsZxd2U",
"AFjm1YmnfyO", "AFTwI0xBM6e", "aGw7PyLMEkl", "aHNXoYj7uNJ", "AibLRYCSE4P",
"aitNX6Qxkon", "ajEqsuhE9fV", "aJFDh98Iahb", "AKG4BvCUVsF", "AMtGkXGugJb",
"aNczAtKAJsv", "aoY0wrz6qBF", "aOz3ikxG7qM", "aPWuF0rDfuJ", "aQrGXlhzEJB",
"ARu0wnYDkam", "As7tGowP84e", "AsqolR3dfgv", "atj39UeK8N9", "atmjKVCRnzw",
"aUhP7zZ7LPU", "aUMEQzUKI0K", "AuP8NAgS7Th", "aUyy9i4fwhS", "AVFW2vlGxds",
"awoAlwC06Go", "awxCmxmeea2", "AWYFb5fwcYb", "Ax2Q16uPW55", "AXO6R085bth",
"Ay6W05BTgDV", "aZMeFIlkevS", "B08adcYOEl7", "b5MVFPi1inY", "B7fffQm5omx",
"ba3kFfcKXNk", "bCK7hWM4bnK", "BDlYKSCaOIG", "BE3TZDysXuQ", "bErpy9bSZAV",
"Beu6pmpSDJE", "BgfNJiJlDrF", "bGUeQEEpq7q", "bgWDDBsRLIL", "bHwo17fsILI",
"bifefa8JnfN", "bIQ3gsw51RH", "bisxDvmwluW", "biy6fHoOcZp", "bK7yQP8LNkJ",
"Bke0tWeJyBr", "bKMNhuIYaYW", "blkWvfFDVm6", "bnaDFC8EVAo", "BNDeQ6sJctI",
"Bokks2ESodd", "BoKlS77F7Il", "BqLRDDu69ic", "bqoZAzbsajz", "BRlA0HkkMGM",
"bT501IhkxV9", "BTliRZoJs4i", "bTTf1R7zgRn", "bTZAPQPXgI5", "BUtglXWCjkf",
"BvcJEyVWsGG", "bVHpRZguCL2", "BVymUZcbCuf", "BwkVolONMBn", "bWtq9NnOoCU",
"c2YR2oDyx7t", "c3dhvyZuPum", "c3LYcysugey", "c46Q9ExLocA", "C52gwcl9fmp",
"c5IYnQ3M7dj", "c6yCKEAemfr", "C8uv1qapHmC", "Ca2rjTu7g6A", "cAsHVMiIVHT",
"cB7mNM1MNm0", "Cbboq0XBHn1", "cbUfMWJl9sK", "ccixNtjWLkf", "ccL7Esacksn",
"CgmvbI2pkyK", "cGvhZR5kDxQ", "chFA8wLA953", "cIb00kbYPgm", "cjoj6MxgfxE",
"cJrxpXipqCm", "cMR1ECoHpE4", "CmRKRa25mZu", "cnCuI3VeJKt", "cNUlz8NllVu",
"CoySgwRgeRE", "CpZyeEzz39h", "CqIH5ytvqTS", "cRbK3weaIO6", "cs2MtDT1y17",
"CSVVXoe0xGC", "ctEZrxoEucg", "CxCDdfOd0Nj", "cXzO64qne5O", "CZq12nSSyn9",
"CzTmTRr0krx", "d3F3FBUFtWi", "d3f8P40FxnS", "d3thFMLEOGr", "d3UA2wZLHlM",
"D3wXzwwrBE7", "D4Bb0bZE5eK", "D5BprGY8EIU", "D5F054OKtW4", "D9nOWZAX3yT",
"DAcTRfO0CNG", "DbjU3iBZtGx", "Dd4sp3zIfSJ", "DDC8Dws74Zz", "DEFzmar1QtJ",
"dEoQWkLavTj", "deVhoPko4Bh", "DFBDO1gXQwf", "DfdvXXyNSoV", "dGCqYO3Zi6p",
"DGDkUV76OgX", "Dgt3VcFh8rl", "DHdEugYqcEI", "Dhku9zrZoJe", "dHokR5oLiIl",
"DhPZWGceA1Q", "DiKXevYOYNB", "DJIgnE1QQbB", "dkR7YOB6UT6", "dKy3aHycCap",
"dl9g8UYxk20", "DLmEBtWqO9S", "DLza3NSQYUI", "dmUHnTHgfYg", "dnRXJOdEzdw",
"doRK8OhG0kd", "DQaEryfraV6", "dQk8ubXxXLX", "dQOwWKXxFeq", "DrHlSXIHalR",
"DrLeENdZwxX", "DRUaAOrybxb", "dSJcUkmJWvZ", "dSuHNzaRaSf", "dtDftsTowRA",
"DVF2BNdSzV9", "DW7NajJs9ry", "dw94DZyrpUZ", "Dxa8RiDlXB6", "dXBB3LIqhd8",
"dY1ATXbywBu", "DY3V0E6pUYD", "dYIdx3HoWbL", "DZMyvdZEDeB", "dZrjKdqCi1w",
"e2cMNKCnHOw", "E2g3H9rUdML", "e59NHDOFTWC", "E6KoR8hXk7P", "E6vLBntf9QE",
"E8PnLO9QRcE", "e9NQxtBNruk", "e9QjFd6fZ4I", "EAdX1JPb4Dm", "eCGBeD0uz0D",
"ECHaJeidpTR", "edLdPyMjbaz", "EefeXxr8yDS", "ef6tzAcpMeF", "eFB6BfJ2BTY",
"EjFYleP5G9K", "eLGdmsoRjWn", "ElmgbenqYn7", "EM5PauW0KWg", "EmhBF1JUw3i",
"enR40fiMtoo", "EpxhEmcMVXh", "EQpPsVwWvqz", "EQtHhnAYjJp", "erfgs35WGXU",
"eRNEYF9OfA8", "ERqjIjzKnNm", "EsdcJsyJTJG", "ESNgljw6VvC", "eSZjKIwHPYi",
"etyPfIkrlrM", "Eu1JrO8bBkB", "euFWewBZ5Xr", "EVaNkH5nz1s", "eXgA6Zfn6KQ",
"EXIi96SW1Bm", "eYPdhvwFirr", "eZ2NazTVbb6", "EzN8D82lOTp", "F03oK0VRgyk",
"f0WCSs2fwvv", "F3CHKWYM2Pb", "f3FoF8cpKiH", "F42k81lXXMO", "F8ZvmoAy2bh",
"fd5zuIbL3Qd", "fDN9KAuRv2o", "FdqK3U8rDRX", "fG2ws21A6Lj", "fgDQSAYp5pj",
"FGjbxwib4q5", "FgLXwaIGGbn", "FiqXUXkRHXr", "fiuesJ8f3xw", "fJAqAOFzB2b",
"fJmQ6P38mHh", "fJy2O3xh1fV", "FjZuMxKuYvb", "FKe5fQHbu8l", "FKuw35vjqRz",
"FmAQ159jI3w", "FMGmKkEOmV4", "FmuzZuFFMzD", "FMX7RNQIwYu", "FNUYBvpbWaA",
"fnzDrz05g0T", "FO80di9Jxuk", "FOKfyVchS21", "fP0XmUTTfks", "fpCA3TMnMA3",
"FPkj0JvlmyK", "FPSoejJAWSU", "FqkwtkM7eXB", "FqlQZiGKxpr", "FThJa71HEEs",
"FVaQ3fSHtT5", "FvQrsd2gVeu", "fx7bCRgdYic", "FxrH3E1ge0f", "fYtsyMj84LY",
"G0EID1cpxEB", "g4jJZ1SNP4I", "g7AYmMzlRL5", "G7hnxrBDXd2", "GCQVHCnV25O",
"GcYMteoIkw9", "GDCM1IWa7Zh", "gdsUTJnwdzb", "Ge7oZ5R4iBk", "gEff10Pq35y",
"GFPi9bpW3sN", "ggMEnqgD9kD", "gKR0a28tTp5", "gKRGyOXbpzj", "glEuzcZNWIM",
"GlWdTuycHxs", "glyDmwEFzrr", "gmmjFqs7MFB", "GMWgNQ8JB1r", "gqFwQOY1wSE",
"gqNh2d7WJva", "grKa7EwswRX", "gsIY3JD3iHh", "GSWPAgMxhy2", "gsX0auFXP9m",
"Gtef53Qyxrj", "GTQqEhUUV1F", "guGv3PY445Z", "gUve5bZAut8", "gVZ58EQOH6K",
"GwXv8OX78AT", "GXIQmznIdQe", "GxIVLRDNmVF", "GziA2Vc0HX4", "h0RMK448nhs",
"H0vjaO76Wg8", "H1G7wWYemSm", "H3mOm6sbODE", "h4IQGhyYAQp", "H6LR8zRVQLW",
"hAoSAyLR3I6", "HB6ZBS6kyJ8", "HcKIEHFgpDb", "hCuRPOStRLU", "HdTW2XJg3IO",
"HdxFUpXFp2O", "hFwwNnFm1B8", "hHMHykeQBua", "HI3Z2eSmWYl", "hiRGzSqrLx5",
"hjeei4JLTiF", "HjwC2LDSWHK", "HlElMRh1t6W", "hlIZJlEsd7B", "hLwLFwQgUdb",
"HmIC1eI4aEQ", "HmuBn2Tdutx", "HN6AdgqShbf", "hoSu28MRYPv", "hq6x4qBOYsg",
"HQHoA9YKMAI", "hqvimuJJhKL", "hrpWiEmnynY", "hsLoXTDJDib", "htJFOM9EYmH",
"HU4RdTNlezp", "hWWRAoV26mI", "HXA0U1WlIhx", "hxckGietsww", "Hy4Uo9AjrnA",
"hy52ywnDIAM", "Hy5stTfQzCG", "HZd0k5dqZ9h", "hZV0CekLNni", "i0rzEGmhViY",
"i0UbyVCIMMY", "I21MUYJoVMy", "I2G30Bxw2BX", "I2tQnsS7wn6", "I3n104WlitM",
"i3UCGccuhCZ", "i4KTQ0RGK3T", "i5GWQwiObW1", "I5NWo4ucWB3", "I6v4GYaXpQC",
"i7xMMyJ6A6E", "IAvpgvgrG0f", "iBB477oQopG", "IBhZ0h4Ap4D", "IbltT4i4TK6",
"Icts0NC4qAd", "IesVnrPQeSZ", "IFINQSPg4YM", "IFTZCzzniHQ", "IFvY9G1PHAV",
"igDf6uUnTYe", "iHIs3hIFf0i", "IHWMvXnrYmQ", "Ii0xFlLHHXz", "iI2i5pPbl5B",
"Iiwy3Zv7iLb", "iJax0w1KHEN", "ijl4gbKzr3X", "IJwB2CRmy7D", "IKMMHGYtcDC",
"ikpa1wjF92j", "iL8UKqtpf9G", "ILiQ2JLmcLT", "ILJAF0UeEJj", "in5GYhicsOP",
"INcVgc44sm9", "ioVTytF5utn", "iPY8yPbKyA0", "IQIfv1gEqzC", "iqKq6QyUII5",
"iqopOI7y0N3", "ITafa9GjY9I", "ITzEvGOU2GR", "IuymlqNZCLI", "ivq1Bh0PvUd",
"iwrIeTg1XFz", "iWvqk82htTQ", "IxcUubx1fw5", "j2k93SJevE1", "j2X8kPMcchC",
"j6UnkDFKZc1", "j7218NqxjYe", "j8DdqpZn2qc", "j8FYrPT09Sd", "J9JOpPQB23Y",
"jaDbDaXw0Pc", "JcZ2R7KZzTq", "jdswhtT866l", "JE6sdkvuc9S", "JeSc2hThLHY",
"JEWdR4I9TIm", "jf0RxRXJQD0", "jFFOiUs7WoZ", "jhngb8KdYU1", "jiIV8o3C0qx",
"jJ1tYGFTuaR", "JJD60zjyHFp", "jKg6rpNATKH", "jlaaYySSxTv", "JlEPa3N6EgO",
"jlZ6LAYKEo9", "JMhFN7V0B1r", "JMr6AvPnW1M", "JnJtmnGCY95", "JnsP1SLvvsw",
"jOl9gZtASeV", "Jq4XG5c63t1", "JqfwjhLrHs7", "JrxejHLYDML", "JTNDUJAu3DA",
"jUtaZ7I8azt", "juWqrHQgdew", "jVb0CSg6sIR", "JVHpkK4exDw", "JVk9m9vVA1D",
"jWFefvuCwnA", "jXoQbHS18G7", "JYfu3Ld3AuN", "K2Lh8hkI6ST", "K3RIalye4fw",
"K3rIsFyLwv7", "k6fqIh47UYc", "K7re2lFVRfv", "K9HNTtT80IM", "kAQQIuh4eZr",
"KbEhvcWmvAf", "KBMxpwB6DCO", "KBybjbIp9VK", "kCdAI1b02G6", "KCPICjUZcE4",
"kCQMO6wkkV5", "KCtzRrOqmal", "kdDCRlEWqYr", "kdUL3XxL1bF", "kdXwwhZfS7V",
"kEeOSZheoND", "kEhPOqEXXk0", "kGE4jAoYn5L", "KHXn2gzpI0j", "KjMGcLd3XXd",
"kK6NYM3jZkd", "kKsL2QkNR4K", "kl6QWeL9RDW", "klThMLasoQV", "KmfuUMQ7T93",
"Kn9F1mXO0GV", "KNU8WQL2zSc", "KP6O1BkuoPX", "KPF6QKOADPR", "KpV6xl78isl",
"KqyKD3POUbS", "KQYxmgQNUSD", "KRQ61nuKa1b", "KtDVkM6bDeW", "ktTYjYLEW3v",
"kubDpNzUTG7", "KujnNfVcY2N", "kVJ0jf7P7Wf", "kWBZ1e0JH5h", "Kwts2m2rUUp",
"KxEa3dXzAYv", "kyGz0JzX3Z0", "kzHnYcum1wX", "L3iJ4hZ2ypn", "l7dBO27dhA6",
"l7RKRoGgmlq", "L7xlpOoRnWm", "LaH8j5yWJZ1", "lawU1EpVZVc", "LBEkbl9SzHf",
"lbvPWYrpTPw", "LcWVIO0Jsqj", "LDmpwdWKomn", "leQOMrPQiqf", "LFOfMnjCDvJ",
"lgEnN00o6mZ", "lGgWFnakeII", "LHie5mY8Uj8", "lIEtVHeJ086", "LiLYwGv2WWN",
"lJ41xkkb1jI", "LJFDVm4S9HF", "LJzqA45qmSZ", "llQAyMkWXID", "LmBKIXa2mSL",
"LmwBbNZehh2", "lnkTmWmupfH", "lPAr5SfstTF", "lpCdKHJgyDr", "lQfxQMSOVqP",
"lS1XvFsr6no", "lUDMkJxSxHL", "Lw70k8Wjzp4", "LXWKW1xwmoZ", "lYNYlzUvgos",
"LYZ27cymGw5", "LZ1OWhYhPiZ", "m4ue4ZOdIep", "m6E2SxuEKtc", "m7fmNp4WilZ",
"m8FGZ1tP0UE", "M8kI8XD6qF9", "Ma2YKDqULAr", "MA3CYGbUEaG", "MAk4KZRu1L9",
"MAtmMxsNpeZ", "mC01s0xdGEm", "MCE5Y33BYDN", "MCT0SGxhkuU", "MdmyzozNJ02",
"mDNJnXJ3Bap", "ME541MEplIz", "ME9FWjRMe4e", "mePQU0trYhJ", "MFT0CnzHbgk",
"MFy31o7euAb", "mfZwiJJpZcR", "MgptQftlksp", "mgUgOViogq7", "MI2vOsP8NSo",
"MjCkEceL336", "mJY0L6TiTId", "MkU5WMbgI4U", "mKYg307awDr", "MM5BhvP1qVK",
"MM5CMbf9hxl", "mnshKO7lVDt", "moicbsA41fH", "mOSub2ULY1O", "Mpi4Xzop4kw",
"mPQwmRVhsKK", "mpxTG4BSHvb", "mR9nchmQZXC", "mruhLKuBF86", "mVZB3R5M66F",
"MW1EtjyMl5d", "MXHQSQfyHl2", "My1mHzVMqV6", "Mynld4Vekod", "N1giIHXfzhb",
"N23VxXj21Wv", "N2gVM6xHjXX", "n33C6ztvpqu", "N3LQS3eat8p", "n46vbqoLchh",
"N4rlgJRGUs3", "n5H2FaL7kap", "N5PPLwwES0c", "N6CPQoLRnz6", "N8nfcWXZtit",
"NawPD8q2KC8", "nChFLgqqH0w", "NCqjtm01Y4E", "NdMiR2VVel6", "nfR5nCiNHMC",
"nfwoSSAiWjg", "nfWs6WgmRC2", "nG7qJqJR13Z", "NGHkoHvBwF0", "nH6JZBFhCXs",
"nhfdWznpsqJ", "nhnQpVPQ7zK", "nhsj9HCnhEs", "nHtTsUMZoVG", "nIhIdZmXLXS",
"NIsmtALRuS5", "nj2KML2oqvV", "NJKcpotvrAQ", "nkXtOreJnSJ", "NLBLC0uWFuB",
"nmdSUueCjti", "NP8pgYnty0q", "NQxDKw6jGTj", "NSZxDwLVCeC", "nUanptGavqT",
"Nv5WX50ktwr", "nvJQYEQIFFM", "nvXHNeXXvJ5", "nwbO0NqAg7S", "nWJFiQq1vDL",
"nx2J294i6hk", "nxgu0uT1tLT", "NxKCqlm0eTG", "NYEpdnELJ54", "nYIBsKHueFr",
"nYnOM20f4fb", "NZxaguajfAY", "O1U2KTQp7RW", "O2p0zdfIFmP", "o3nzTkLC1Pl",
"o3pKyi7ckFO", "o4gtcJidna5", "O4slz8eLLn6", "o79rSRM0UlM", "O7qGvpaAt2w",
"oByIGUGsrgx", "od9Sosf2Y0V", "oDTFc2FqImi", "OdyuvCVU9Hz", "oEFK7vjkTU0",
"oEXOZcbaHxA", "OgLIyzin181", "OHtxRBRAzYs", "oJNbeCd6bvb", "oJsgj7WMDkq",
"OLEt9ovMHrz", "OlkZe7ivV0p", "oN0anW8xCpq", "oNDzB1D5as4", "oNfV9ntBJ9u",
"oNttkuJFbwC", "ooElCfPc54o", "OpEVn6IiULE", "OQ3BQRswMx7", "oTB157EY3jY",
"otmVyzT3xRC", "oUWkMygGP2W", "owxf1XoQ3Lu", "oYgWYWUVt2h", "OYjhvD7DqIP",
"oZfnfo46pS4", "p1NV2hE2fCZ", "p25NocgpHkc", "P2eQdjxbuZo", "p3T3oB4tfNN",
"P3Uob5UKAoM", "p4hBFnI8WIp", "p5L7w9Tjay3", "p7C2DczQikw", "P8tFheT6TtS",
"P91Rf8wCj7Z", "p9J64kFu5Fd", "PDOfJJdpbob", "pdRTIO2JqPL", "PDWC7RxX4t9",
"pEAFBcOJIVF", "PEfq6d3TONP", "PeNS8yHqYH1", "pEvaEn24SR1", "pg9F69FU9fh",
"Pi6v7zcA26e", "PibIwh4xKHI", "PicYz4ZaEkF", "PIm96jtkVB5", "pIVjHCsQgJI",
"PJI3sARzQAG", "PK027w8aZ5K", "PKfz9RYfKzF", "pl8h1HdqpFW", "pl9IGnhmOJc",
"PlISiBPN3db", "pMiRPEvyleJ", "pMtEAU5iVTB", "PnB0GLiMdBm", "PPb3XMcCAf3",
"PSdLvfFlDRF", "pthlRKVLgNp", "PTZfXfOkUR1", "pWmPB9No5RJ", "PWXwPbUM2DB",
"pxPQCkuJZrl", "PxXh1I86blw", "Pz198xRjRHD", "q2UUKkPtvll", "q4hyZcb2pgA",
"q6ke2WlwbWr", "Q75pcfnDLwr", "Q86baYhZPOB", "q8fmqtJVDhh", "qBrBhSbFC0d",
"qc9eMgI8Y95", "QCY2lUMpt7f", "QDkCAOGVng6", "QdYKp8ivavV", "qeBFicifeNz",
"QeKGz2D6wNe", "qEt7nmwua6v", "QGJz6Rv3qHU", "Qgzh7S5pLc3", "qHaaYvuNGIB",
"qiBueINJbti", "qimfq5GL5mV", "qJsVouyMqE8", "qlnxDl1BOrw", "Qlt1DOyb7iP",
"qm0fcx7VGOQ", "QMT77ObrHQa", "QOyCdSRSUXL", "Qpj3LVa0kMf", "qQ84fCTxdGh",
"QRaKmOedEZx", "qs9EipoiiBD", "qsPQEZph59z", "QTFJClMfP8c", "QtJyTjN5faU",
"qU7z54bY9jA", "QvByLV2hsHo", "QVFUUfes7vc", "QvQ5bpVOJDj", "Qwzbgh4Flmx",
"qx2DdF2CKFL", "qXdueHJNqcv", "QxSfgx5QfT7", "qxuRrLWQmXL", "Qztk8cjmz1e",
"r0ehsy1jjxa", "r2w7bZu3FsL", "R3ac44RpwRG", "r4mXVpHUWC7", "r6p12UeHOyg",
"r9efDheFtk3", "rakWSnvNhWr", "rbBZoYFr4DM", "rBtlT7YCRKx", "RdbYAXOnm2S",
"RdM4hjZsFRg", "Re2M8SlCc98", "RfmkqgjDUPL", "rgAmPaAHmNU", "rGbQXTyOdmW",
"RHpQbDCZK5O", "rhxxSbYXZRR", "RiIZqF2hfqY", "rIR8cwAz0sf", "rJ3tipUjVQ4",
"rlAmYWNUTnR", "rLiYzJJRiBA", "rLOyzoOdZqC", "RMKAo2HcVkM", "rnGH1Q5IyIU",
"robJRJuEFfM", "RovRnV9RWFd", "rpmWXDmHjsq", "rPPdTvv1QoY", "RqLdtXwHdGO",
"rR1aDWav3z1", "RrjHJQJDQSr", "rrZEwHEjjy8", "rsM3sdDc3Lk", "RsmDQZSmpD7",
"RtK3aS9WP2H", "ru8BHTnYxI3", "RU8DlKBg48x", "rUysfjKrKqk", "Rv3o89GkqWH",
"rVC8KePJHu3", "RvCLp5qbvtz", "RvQqAbOcEfA", "RW617O0UjQJ", "RWvmueaioAl",
"RxADuUq1Ba1", "RxHTSbz8VN5", "RxND5KsxzvW", "RyRJf2UHJL1", "S1Rh4YnCAAZ",
"s28njgt1wYe", "s4eb8Spa5TC", "S6gaiIWGmh9", "S6X4d5WHA1H", "sAnH4cWV41G",
"SATZgjyfpdZ", "sAyk7hwXEbV", "sBu9GwU5IKe", "SdlDgZMNxqX", "SegMIAP4dhw",
"SfB5NwJXaot", "SfPGp94cYZa", "SG0QMcMgRRq", "sG2EfH7UYLQ", "SgK14sd0Fq1",
"sgNOxONNZIv", "sGXcrRdwzAk", "shkTq2LdpXw", "si6qmHhCV9F", "skR6XpFhu3u",
"skuXY545bae", "skVM9VC2v6H", "sLkylFDaonQ", "sLQ3GDMCRSz", "sMVuTESYbpd",
"soMCF3RbHqt", "sQhxc449PV4", "sRbFOoSk7qZ", "srTptJGYtcK", "SSS1hmwqHOR",
"StSjQheznIv", "SvLVieXqQT7", "SVR6pSBhbCb", "sWlH85siDIT", "SWTCBn32M8D",
"sYBdL54a73r", "t0V5NCdjdPi", "T15MpYA7f51", "t3snPDHuVBW", "T5LdflE3Peq",
"T6RUeMH9KP0", "T6VbSgxjG4o", "t9Fl7c8SJbm", "TafeAKXESCA", "TBMPJiR0PKA",
"tcjz9dmJW4y", "tDDh1EjIZkh", "TE62MxBLgne", "TE7dhvcKVwp", "tEiDKptkacd",
"tEr481bYdow", "tfEtbnUgkGv", "TgpNd1eUCH5", "tGV21Z1HgXN", "thQZhxRh887",
"TJp862VOKlS", "TK7P7QXIDOA", "TKb3FP8mXY0", "TL5cvVAN3cA", "TM31sX4CThP",
"tMpwPcDzIfU", "tNf8m963xKK", "tnR9XvFJ5d7", "tNu7AdZ5358", "tOEYJ1EgIkn",
"TqSXqCuyodR", "tRgUTgCKu4J", "troIuBzxemz", "TSQWaAvOer5", "TsSlV9eE7Mz",
"ttKnsfno2BN", "tvoTu4cpYbh", "TWJPFfCeHES", "twyDPmlDNjH", "TyjDUvHkCAx",
"TYYPCGssY7i", "tz00ETYw78Y", "TZ307ap3HvE", "TzPwGs1AcCL", "TZxEGcWjbdk",
"u0ezFwC4OLL", "U3DjjRVyEun", "u45lZujojLF", "U6Mo4GsQKwT", "U7jt55boMwC",
"U8feQBluEhj", "UBe2SLdSmxV", "uBjjsyieqtr", "UccWk7OAtZ2", "uDXFpf8Ko6P",
"uE4KejhmDyk", "uGfkThgxZsI", "Uih0KGtvZeo", "UIyI4hkq7Bx", "UjoXPWJKPXb",
"uKFFT93nPmp", "UKSoohp2vBC", "UL70316n0C2", "UlD5QNXAW40", "uLDFnAy4ro0",
"UNxoCz1KXnW", "uOmh6keHjf6", "uormVxMEerw", "Upe0kYdbeUy", "UPSbASHNQmU",
"UQ1K5VqXqcZ", "uQvg5rWo87I", "usFB6MgBB6t", "uTeZmtXQzSN", "utgv86YyClH",
"UTmdWR44H5x", "uUmAJIXkmsO", "UUsAfkqIPhV", "Uv6Baj6YaG1", "UV9ZR51T6Ts",
"UvVxiC7b1jZ", "UW4ZNlm05Jq", "UxEq7311Xzd", "UXhcOzwv9o5", "UXSSmcXoWR8",
"v15yxuZyGjR", "V1MbBFGqwbB", "V5LD5oYeZys", "v6BprVsEEt2", "V7Hl62C5Wgz",
"Vah8YYh5HI5", "vbDOTEMQjfW", "vBjsjEqsmWL", "vBym1l507tA", "vf1kkxsjkB1",
"vFSbE4W5Kg6", "VfZPt9kXxL9", "vGLQ19KWuBv", "VHK1T5sygmw", "VLuN2iZ9oZp",
"VmwVU8HFDBn", "vnaUuR9C4FH", "vniKeY4S1Ru", "vOu023c0Snx", "vOuGO9bkEUa",
"vrQvRBzXiLv", "vRRoviRJVgX", "VS1mxlo1mVx", "VsFXXXagVmp", "VSHfWQyhzUu",
"vugElbQMtcL", "vvaX4oKLyKo", "vw87QIZ7dhk", "VWLVmvtDCSI", "vxXQe9jxSPE",
"vy0hyVTrTom", "Vy1JFQbsNBB", "vzGc2nPWraO", "vzVRv2jtJxL", "w0aCC4wNNzW",
"W1wtZLbWuY0", "w2yXiR4CyWt", "w539HzekPQh", "w55gRgLikEN", "WBhss2tvLa8",
"WcPEy9epMgd", "WCSGolF5yhy", "wdcS5ORWZte", "WDyq0ryAjpn", "webeuXrveDi",
"WeSJR8GDPmC", "WFApCUf18Lp", "wfFCmvMEGOQ", "WFiPvuGJf9O", "WggRnJplCQI",
"wgqFTVU7Iky", "wIMmZwl1gpX", "WjCGPzMzLVr", "WJfiDULf7ZC", "wkl1yyAzga3",
"wlspYUyDoQM", "wm060hpEM7g", "wMPB6u0GZDL", "Wn07Tbv74qp", "wNha3idA7l6",
"WnZVpXq5XCO", "wOe4JHkqbUm", "Wog7gclb7TJ", "wq4bmXnJK45", "Wq4O1nlYk1C",
"wqUwUpMD2mJ", "wrGYa8E94Yc", "WSAfRmiEJOF", "wSP90pEfCng", "wSW662GVwZP",
"wtoXU3G9YIy", "WtPSqPwjH2f", "wtV2TtEPCCZ", "Wtw2jbyaHz2", "WUChzooYWJ1",
"WUFgPdTN02g", "wUQiuRjZxiO", "Ww9Rq2KLlqV", "WWabB2sc4B7", "wxKEHpSLvib",
"wXnoTA2MDy9", "WYk4A1fVYD7", "WYMXHupBG7P", "wzD83xmvR3b", "WzemydwRD0R",
"X4ZVDdDd2xa", "X6efCWparbb", "X6uv3PName4", "X7deWPhTiIy", "X8TsrtMQFiu",
"X8UmaBiq1yy", "xbJCVaOZWp5", "XbjRzgMPN24", "XbubJh2yjOw", "XcqBCAaLcq5",
"xd8LIlN7N8h", "XdKVljaiZ9j", "xeEUMp35d5m", "XeUDpg1CTKf", "xf9Q4yYDlq5",
"XFEHZnnEGkT", "xFO9GKAXi1n", "xfxtwRZ7Ejp", "xhOpIbHQy8I", "XjBkSXvZLOZ",
"xjfIPJ04cET", "XLt8l1uPicg", "xlYle4v5GZ8", "xmJNiAbmSfe", "XnkRi1jTMKr",
"XPhxWI0fDyq", "XqDQsrhQ7W5", "Xsd3yzbnFOf", "XTF6vymtG8J", "xuovzIjWZUG",
"Xv1I8z1cK76", "XvVmyn071HT", "XxBMueAFsnk", "xxVZKlzMYJJ", "xyr4dO4G3tW",
"y4rr2PbfufS", "yaa2uBLsdRa", "YBG39jGSV17", "yDcnCB4aZEX", "YDuoFIKpONe",
"YdWxRCaQR2D", "yfgSogitBGX", "YFi06xiFHWs", "YFi2V7qfmJf", "yfpM2zJ3Zuc",
"ygTl7hih5qi", "YGtrgJxKWiU", "yIcfnuZhejK", "YIxt0WtezdT", "yJ014QFEqru",
"yJO8QTnBF3o", "yKfdWuLsdDx", "ylMgcLnwgce", "YNy9ymD2A8p", "yONz8gph9A7",
"YowwYq8CIXJ", "YPsxC0bl7T2", "YQP6diqjJAl", "YqR6LoSk2Ed", "yqwh11CvYXU",
"YRemZ3p9bFA", "ySxRSgTOeqD", "yTvx2IJ0w0z", "ytwga9hKjVj", "YtyO06HBaVr",
"YvEkkZlNeCK", "yVFdJkYsLK5", "yvoQHXHGvbT", "YVT9zsaVBzp", "YWbmL6VK8R6",
"Ywm8eA9tZHe", "yXady1QV27H", "yY7MHufA6C9", "yYG52aLO1GK", "yYgG4h097xR",
"YyhPAO5yx22", "Yz5yhyHf7Ul", "z2cGjpx37Mw", "Z42m6cWsI9m", "z4DptoHrJnb",
"z4kLOdnL1Op", "z5tZes2s49Z", "z5WklS85YjT", "z6bId6qlNk4", "Z6ZZLw50mAM",
"z8MwD6T43n2", "z8UkGdr2xNs", "Z90jET09ZrD", "zaeb1Zos2Mu", "ZBkpY2KdibX",
"Zc0BcScQDBU", "zCjn57zZQVN", "ZcrdEBruDka", "ZCT4YbaBFUb", "ZdVIx83rdI7",
"zEQXA689E4a", "ZfjQmCjVKRF", "zfutn6ulVcO", "zFzYdXMnPoP", "zG4JqtM8wHO",
"ZGyAErBl5PS", "ZifoCg4OvIj", "ZJ6MAab9PJE", "ZKVzRmYkKzQ", "zlG1VmpE6QQ",
"zN6xXPgmzqK", "zOfDRrZmbQO", "zOGa9wLHDFE", "zQmuipEUYbz", "zR7UekDUG3X",
"zrs6iFpEtF1", "ZrUjQFzR1gM", "zTnxsAMqHRP", "Zu7gpmcwfqY", "zvOkAI9ewwE",
"zvv07VAowTS", "ZWAdop7zYgJ", "ZWAEE8DrywN", "zxIlF5RwQFi", "ZXONCt7P01p"
), class = "factor"), Time = c(1L, 2L, 3L, 4L, 6L, 1L, 2L, 3L,
4L, 6L, 1L, 2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, 8L, 16L, 16L, 16L, 8L, 8L, 16L, 16L, 16L,
8L, 8L, 16L, 16L, 16L, 8L, 8L, 16L, 16L, 16L, 8L, 8L, 16L,
16L, 16L, 8L, 8L, 16L, 16L, 16L, 8L, 8L, 16L, 16L, 16L, 8L,
8L), Total1 = c(64L, 64L, 64L, 64L, 64L, 96L, 96L, 96L, 96L,
96L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L,
64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L,
64L, 64L, 96L, 96L, 96L, 96L, 96L, 64L, 64L, 64L, 64L, 64L,
64L, 64L, 64L, 64L, 64L, 96L, 96L, 96L, 96L, 96L, 64L, 64L,
64L, 64L, 64L, 96L, 96L, 96L, 96L, 96L, 64L, 64L, 64L, 64L,
64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L,
64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L,
64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L,
64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L,
64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L,
64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L,
64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L), Count2 = c(4L,
8L, 8L, 8L, 4L, 4L, 8L, 8L, 8L, 4L, 3L, 7L, 8L, 8L, 4L, 4L,
8L, 8L, 8L, 4L, 3L, 8L, 8L, 8L, 4L, 3L, 7L, 8L, 8L, 4L, 2L,
4L, 4L, 4L, 2L, 3L, 5L, 8L, 8L, 4L, 4L, 8L, 8L, 8L, 4L, 4L,
8L, 8L, 8L, 4L, 4L, 8L, 8L, 8L, 4L, 3L, 6L, 8L, 8L, 4L, 4L,
8L, 8L, 8L, 4L, 3L, 4L, 6L, 6L, 2L, 2L, 4L, 4L, 4L, 2L, 4L,
8L, 8L, 8L, 4L, 4L, 8L, 8L, 8L, 4L, 4L, 8L, 8L, 8L, 4L, 4L,
8L, 8L, 8L, 4L, 4L, 8L, 8L, 8L, 4L, 4L, 8L, 8L, 8L, 4L, 4L,
8L, 8L, 8L, 4L, 4L, 8L, 8L, 8L, 4L, 4L, 8L, 8L, 8L, 4L, 4L,
8L, 8L, 8L, 4L, 3L, 8L, 8L, 8L, 4L, 4L, 8L, 8L, 8L, 4L, 3L,
8L, 8L, 8L, 4L, 3L, 5L, 7L, 8L, 3L, 4L, 8L, 8L, 8L, 4L, 4L
), Total2 = c(34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L,
34L, 32L, 32L, 32L, 32L, 32L, 34L, 34L, 34L, 34L, 34L, 33L,
33L, 33L, 33L, 33L, 32L, 32L, 32L, 32L, 32L, 16L, 16L, 16L,
16L, 16L, 30L, 30L, 30L, 30L, 30L, 34L, 34L, 34L, 34L, 34L,
34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L, 31L, 31L,
31L, 31L, 31L, 34L, 34L, 34L, 34L, 34L, 22L, 22L, 22L, 22L,
22L, 16L, 16L, 16L, 16L, 16L, 34L, 34L, 34L, 34L, 34L, 34L,
34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L,
34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L,
34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L,
34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L, 33L, 33L, 33L, 33L,
33L, 34L, 34L, 34L, 34L, 34L, 33L, 33L, 33L, 33L, 33L, 28L,
28L, 28L, 28L, 28L, 34L, 34L, 34L, 34L, 34L, 34L)), row.names = c(1L,
2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L,
16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L,
29L, 30L, 31L, 32L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L,
42L, 43L, 44L, 45L, 46L, 47L, 48L, 49L, 50L, 51L, 52L, 53L, 54L,
55L, 56L, 57L, 58L, 59L, 60L, 61L, 62L, 63L, 64L, 65L, 66L, 67L,
68L, 69L, 70L, 71L, 72L, 73L, 74L, 75L, 1041L, 1042L, 1043L,
1044L, 1045L, 1046L, 1047L, 1048L, 1049L, 1050L, 1051L, 1052L,
1053L, 1054L, 1055L, 1056L, 1057L, 1058L, 1059L, 1060L, 1061L,
1062L, 1063L, 1064L, 1065L, 1066L, 1067L, 1068L, 1069L, 1070L,
1071L, 1072L, 1073L, 1074L, 1075L, 1076L, 1077L, 1078L, 1079L,
1080L, 1081L, 1082L, 1083L, 1084L, 1085L, 1086L, 1087L, 1088L,
1089L, 1090L, 1091L, 1092L, 1093L, 1094L, 1095L, 1096L, 1097L,
1098L, 1099L, 1100L, 1101L, 1102L, 1103L, 1104L, 1105L, 1106L,
1107L, 1108L, 1109L, 1110L, 1111L, 1112L, 1113L, 1114L, 1115L,
1116L), class = "data.frame")
An option is to group by 'Class', 'Site', paste (str_c) the columns except 'Time' to a single string, then grouped by 'Class', 'Count1', ..., 'Total2', columns, get the group indices to create the 'ind' column and do a left_join with original dataset
library(dplyr)
library(stringr)
df %>%
group_by(Class, Site) %>%
summarise_at(vars(-Time), str_c, collapse="") %>%
group_by(Class, Count1, Total1, Count2, Total2) %>%
mutate(ind = group_indices()) %>%
ungroup %>%
select(Class, Site, ind) %>%
left_join(df)
Or a similar logic with data.table
library(data.table)
setDT(df)[df[, lapply(.SD, paste, collapse=""),
.(Class, Site), .SDcols = patterns('Count|Total')][,
ind := .GRP, by = c('Class', 'Count1', 'Total1', 'Count2', 'Total2')
][, .(Class, Site, ind)], on = .(Class, Site)]
In the past, I have used asreml-r to account for spatial auto-correlation in agricultural field trials that were laid out in a “row and range” design. It is relatively easy to use the asreml package to specify a spatial model (i.e. rcov=~at(LOCATION):ar1(ROW):ar1(RANGE))
Unfortunately, asreml-r is expensive and difficult to learn. My research group also prefers to rely on nlme and lmer for the majority of it’s analytical needs. So they are reluctant to either pay for asreml-r or consider using.
Several years ago a question was posted asking if an open-source alternative to asreml-r was available that could be used to construct a two-dimensional spatial model with error structure in both direction. The consensus at the time seemed to be that it wasn’t straight forward to do this in either lmer or nlme.
After spending a few hours searching, it’s not totally clear to me whether there has been any progress on addressing this. Can anyone refer me to a recent discussion regarding this type of analysis? Or can they offer advice on how to construct a mixed effects models that accounts for spatial correlation in nlme or lmer?
Please note that neither myself nor other members of our group are exactly statisticians or high-level r coders. It is also not practical to contract an outside group to analyze our data. We just want to apply the best methods we can to routine annual analyses of data.
An example of the data being analyzed:
my.data <- structure(list(ENTRY = structure(c(23L, 23L, 23L, 40L, 12L, 8L,
1L, 15L, 30L, 1L, 24L, 8L, 1L, 8L, 30L, 33L, 12L, 38L, 41L, 36L,
43L, 32L, 44L, 31L, 26L, 11L, 13L, 34L, 5L, 22L, 4L, 14L, 11L,
20L, 25L, 11L, 21L, 43L, 44L, 4L, 42L, 45L, 42L, 41L, 42L, 4L,
44L, 20L, 40L, 29L, 29L, 24L, 2L, 3L, 28L, 24L, 34L, 27L, 41L,
28L, 29L, 5L, 3L, 25L, 14L, 20L, 15L, 21L, 31L, 22L, 40L, 21L,
6L, 38L, 43L, 12L, 6L, 14L, 5L, 3L, 30L, 45L, 31L, 7L, 9L, 39L,
22L, 15L, 26L, 28L, 34L, 10L, 25L, 27L, 16L, 45L, 10L, 18L, 32L,
10L, 6L, 18L, 33L, 16L, 37L, 9L, 32L, 38L, 39L, 2L, 2L, 39L,
36L, 36L, 7L, 27L, 7L, 26L, 17L, 9L, 33L, 13L, 17L, 17L, 35L,
37L, 37L, 18L, 16L, 19L, 13L, 19L, 35L, 19L, 35L, 1L, 2L, 3L,
4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L,
18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L,
31L, 32L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L,
44L, 45L, 52L, 54L, 52L, 54L, 49L, 51L, 50L, 54L, 49L, 46L, 51L,
50L, 53L, 49L, 50L, 51L, 53L, 52L, 53L, 48L, 47L, 46L, 46L, 47L,
48L, 48L, 47L, 46L, 47L, 48L, 49L, 50L, 51L, 52L, 53L, 54L), .Label = c("20",
"112", "1478", "1495", "1521", "1522", "1590", "1608", "1657",
"1658", "1660", "1667", "1680", "1688", "1723", "1728", "1730",
"1731", "1743", "1745", "1748", "1751", "1766", "1778", "1802",
"1815", "1817", "1819", "1828", "1830", "1831", "1834", "1835",
"1836", "1837", "1838", "1839", "1840", "1841", "1842", "1843",
"1844", "1845", "1846", "1847", "3097", "3164", "3168", "3169",
"3170", "3178", "3180", "3181", "3182"), class = "factor"), BLOCK = structure(c(12L,
77L, 163L, 67L, 28L, 170L, 90L, 36L, 52L, 2L, 15L, 19L, 168L,
103L, 188L, 31L, 203L, 66L, 29L, 46L, 34L, 32L, 27L, 16L, 83L,
48L, 82L, 30L, 171L, 14L, 115L, 54L, 93L, 65L, 50L, 187L, 58L,
91L, 200L, 6L, 169L, 135L, 99L, 148L, 101L, 104L, 107L, 128L,
153L, 146L, 41L, 22L, 53L, 87L, 131L, 151L, 110L, 10L, 44L, 11L,
13L, 20L, 42L, 202L, 111L, 38L, 183L, 51L, 199L, 109L, 75L, 134L,
92L, 166L, 182L, 97L, 100L, 1L, 86L, 181L, 25L, 108L, 94L, 116L,
72L, 18L, 23L, 76L, 185L, 81L, 62L, 63L, 56L, 204L, 85L, 95L,
129L, 49L, 147L, 106L, 145L, 205L, 73L, 207L, 105L, 24L, 43L,
8L, 167L, 164L, 3L, 96L, 184L, 45L, 74L, 39L, 89L, 4L, 152L,
130L, 165L, 40L, 57L, 70L, 206L, 186L, 7L, 37L, 9L, 102L, 132L,
127L, 88L, 80L, 98L, 139L, 196L, 174L, 118L, 215L, 194L, 193L,
208L, 172L, 122L, 143L, 141L, 123L, 161L, 209L, 213L, 178L, 159L,
160L, 191L, 177L, 192L, 144L, 175L, 211L, 140L, 180L, 173L, 125L,
119L, 120L, 210L, 214L, 136L, 154L, 162L, 190L, 158L, 216L, 142L,
124L, 212L, 195L, 155L, 121L, 64L, 68L, 117L, 59L, 71L, 35L,
69L, 201L, 21L, 84L, 61L, 114L, 17L, 112L, 55L, 150L, 113L, 79L,
78L, 47L, 33L, 149L, 60L, 189L, 5L, 133L, 26L, 137L, 197L, 179L,
126L, 198L, 157L, 176L, 138L, 156L), .Label = c("101", "102",
"103", "104", "105", "106", "107", "108", "109", "110", "111",
"112", "113", "114", "115", "116", "117", "118", "201", "202",
"203", "204", "205", "206", "207", "208", "209", "210", "211",
"212", "213", "214", "215", "216", "217", "218", "301", "302",
"303", "304", "305", "306", "307", "308", "309", "310", "311",
"312", "313", "314", "315", "316", "317", "318", "401", "402",
"403", "404", "405", "406", "407", "408", "409", "410", "411",
"412", "413", "414", "415", "416", "417", "418", "501", "502",
"503", "504", "505", "506", "507", "508", "509", "510", "511",
"512", "513", "514", "515", "516", "517", "518", "601", "602",
"603", "604", "605", "606", "607", "608", "609", "610", "611",
"612", "613", "614", "615", "616", "617", "618", "701", "702",
"703", "704", "705", "706", "707", "708", "709", "710", "711",
"712", "713", "714", "715", "716", "717", "718", "801", "802",
"803", "804", "805", "806", "807", "808", "809", "810", "811",
"812", "813", "814", "815", "816", "817", "818", "901", "902",
"903", "904", "905", "906", "907", "908", "909", "910", "911",
"912", "913", "914", "915", "916", "917", "918", "1001", "1002",
"1003", "1004", "1005", "1006", "1007", "1008", "1009", "1010",
"1011", "1012", "1013", "1014", "1015", "1016", "1017", "1018",
"1101", "1102", "1103", "1104", "1105", "1106", "1107", "1108",
"1109", "1110", "1111", "1112", "1113", "1114", "1115", "1116",
"1117", "1118", "1201", "1202", "1203", "1204", "1205", "1206",
"1207", "1208", "1209", "1210", "1211", "1212", "1213", "1214",
"1215", "1216", "1217", "1218"), class = "factor"), PLOT = structure(c(3L,
1L, 2L, 3L, 3L, 2L, 3L, 3L, 3L, 1L, 3L, 1L, 2L, 3L, 2L, 3L, 2L,
3L, 3L, 3L, 3L, 3L, 1L, 3L, 3L, 3L, 3L, 3L, 2L, 3L, 2L, 3L, 1L,
3L, 3L, 2L, 1L, 1L, 2L, 1L, 2L, 2L, 1L, 2L, 3L, 3L, 3L, 2L, 2L,
2L, 1L, 1L, 3L, 3L, 2L, 2L, 2L, 3L, 1L, 3L, 3L, 1L, 1L, 2L, 2L,
1L, 2L, 3L, 2L, 2L, 1L, 2L, 1L, 2L, 2L, 1L, 3L, 1L, 3L, 2L, 1L,
3L, 1L, 2L, 3L, 3L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 2L, 3L, 1L, 2L,
3L, 2L, 3L, 2L, 2L, 1L, 2L, 3L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 2L,
1L, 1L, 1L, 3L, 1L, 2L, 2L, 2L, 1L, 1L, 3L, 2L, 2L, 1L, 1L, 1L,
3L, 2L, 2L, 3L, 1L, 1L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 3L, 3L, 2L, 1L, 3L, 3L, 3L, 2L, 1L, 3L, 1L, 2L, 3L,
2L, 1L, 2L, 2L, 1L, 1L, 3L, 3L, 2L, 1L, 2L, 1L, 2L, 1L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L), .Label = c("1", "2", "3", "4"), class = "factor"),
RANGE = structure(c(1L, 5L, 10L, 4L, 2L, 10L, 5L, 2L, 3L,
1L, 1L, 2L, 10L, 6L, 11L, 2L, 12L, 4L, 2L, 3L, 2L, 2L, 2L,
1L, 5L, 3L, 5L, 2L, 10L, 1L, 7L, 3L, 6L, 4L, 3L, 11L, 4L,
6L, 12L, 1L, 10L, 8L, 6L, 9L, 6L, 6L, 6L, 8L, 9L, 9L, 3L,
2L, 3L, 5L, 8L, 9L, 7L, 1L, 3L, 1L, 1L, 2L, 3L, 12L, 7L,
3L, 11L, 3L, 12L, 7L, 5L, 8L, 6L, 10L, 11L, 6L, 6L, 1L, 5L,
11L, 2L, 6L, 6L, 7L, 4L, 1L, 2L, 5L, 11L, 5L, 4L, 4L, 4L,
12L, 5L, 6L, 8L, 3L, 9L, 6L, 9L, 12L, 5L, 12L, 6L, 2L, 3L,
1L, 10L, 10L, 1L, 6L, 11L, 3L, 5L, 3L, 5L, 1L, 9L, 8L, 10L,
3L, 4L, 4L, 12L, 11L, 1L, 3L, 1L, 6L, 8L, 8L, 5L, 5L, 6L,
8L, 11L, 10L, 7L, 12L, 11L, 11L, 12L, 10L, 7L, 8L, 8L, 7L,
9L, 12L, 12L, 10L, 9L, 9L, 11L, 10L, 11L, 8L, 10L, 12L, 8L,
10L, 10L, 7L, 7L, 7L, 12L, 12L, 8L, 9L, 9L, 11L, 9L, 12L,
8L, 7L, 12L, 11L, 9L, 7L, 4L, 4L, 7L, 4L, 4L, 2L, 4L, 12L,
2L, 5L, 4L, 7L, 1L, 7L, 4L, 9L, 7L, 5L, 5L, 3L, 2L, 9L, 4L,
11L, 1L, 8L, 2L, 8L, 11L, 10L, 7L, 11L, 9L, 10L, 8L, 9L), .Label = c("1",
"2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"), class = "factor"),
ROW = structure(c(12L, 5L, 1L, 13L, 10L, 8L, 18L, 18L, 16L,
2L, 15L, 1L, 6L, 13L, 8L, 13L, 5L, 12L, 11L, 10L, 16L, 14L,
9L, 16L, 11L, 12L, 10L, 12L, 9L, 14L, 7L, 18L, 3L, 11L, 14L,
7L, 4L, 1L, 2L, 6L, 7L, 9L, 9L, 4L, 11L, 14L, 17L, 2L, 9L,
2L, 5L, 4L, 17L, 15L, 5L, 7L, 2L, 10L, 8L, 11L, 13L, 2L,
6L, 4L, 3L, 2L, 3L, 15L, 1L, 1L, 3L, 8L, 2L, 4L, 2L, 7L,
10L, 1L, 14L, 1L, 7L, 18L, 4L, 8L, 18L, 18L, 5L, 4L, 5L,
9L, 8L, 9L, 2L, 6L, 13L, 5L, 3L, 13L, 3L, 16L, 1L, 7L, 1L,
9L, 15L, 6L, 7L, 8L, 5L, 2L, 3L, 6L, 4L, 9L, 2L, 3L, 17L,
4L, 8L, 4L, 3L, 4L, 3L, 16L, 8L, 6L, 7L, 1L, 9L, 12L, 6L,
1L, 16L, 8L, 8L, 13L, 16L, 12L, 10L, 17L, 14L, 13L, 10L,
10L, 14L, 17L, 15L, 15L, 17L, 11L, 15L, 16L, 15L, 16L, 11L,
15L, 12L, 18L, 13L, 13L, 14L, 18L, 11L, 17L, 11L, 12L, 12L,
16L, 10L, 10L, 18L, 10L, 14L, 18L, 16L, 16L, 14L, 15L, 11L,
13L, 10L, 14L, 9L, 5L, 17L, 17L, 15L, 3L, 3L, 12L, 7L, 6L,
17L, 4L, 1L, 6L, 5L, 7L, 6L, 11L, 15L, 5L, 6L, 9L, 5L, 7L,
8L, 11L, 17L, 17L, 18L, 18L, 13L, 14L, 12L, 12L), .Label = c("1",
"2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12",
"13", "14", "15", "16", "17", "18"), class = "factor"), YIELD = c(7882.814724,
7641.976671, 7535.187491, 8462.821158, 6470.762695, 7086.39647,
7260.626003, 8374.363239, 8225.545799, 6870.562479, 7260.303179,
6472.786879, 6535.801894, 7335.468082, 8101.853381, 7544.810974,
5597.940891, 8144.903193, 8489.541356, 7420.247609, 8267.229308,
7388.809243, 8753.922873, 7675.2452, 7540.083649, 7459.719121,
7614.590404, 6910.577593, 7655.161236, 8086.00529, 6754.554032,
9141.060314, 7728.70075, 7210.881432, 8872.660416, 7341.942246,
8211.265337, 9030.218757, 8957.01212, 7134.079145, 8580.60533,
8901.807114, 9009.635596, 8972.04225, 8850.07798, 7244.08863,
9357.355395, 7693.962907, 9059.604638, 8115.135788, 8073.220877,
7694.865425, 7168.389384, 7931.776306, 8310.054831, 7743.358631,
7241.417998, 7887.710882, 8671.335868, 7900.074562, 7089.929401,
8252.964285, 8038.601576, 8749.99335, 7880.418003, 7227.593551,
9733.562528, 7715.095262, 6926.775409, 7770.203085, 9000.211927,
7808.710708, 8239.82626, 8252.964285, 9546.314331, 2801.654022,
7865.302917, 6472.037973, 11286.93314, 7698.702989, 8239.164252,
8391.871173, 7817.085477, 7987.7324, 8517.420004, 8286.027753,
8021.268999, 8605.836444, 8360.390812, 8408.648702, 6980.52271,
8484.391646, 7604.489488, 8047.32564, 6859.736888, 8211.744547,
8338.224508, 7549.875965, 7831.170315, 8002.372075, 8092.398475,
7233.303386, 7880.198456, 6431.676768, 8146.454012, 9012.217125,
7696.760712, 7916.314754, 8372.430545, 4552.305881, 4744.119616,
8072.706265, 8038.601576, 8070.612573, 7631.800415, 8124.412039,
7958.686488, 8565.578204, 7204.2532, 7782.851494, 8195.743097,
8075.444598, 7468.681342, 7376.4572, 7019.132415, 7450.186973,
7900.853201, 7077.396698, 6781.366002, 8195.304822, 7581.211378,
8155.600681, 7446.611537, 7887.710882, 6849.690117, 6384.206298,
6965.647058, 7732.576444, 7687.296996, 7887.710882, 8061.034883,
7861.831189, 6690.298381, 7982.777954, 8310.054831, 7476.530867,
5840.137517, 8012.816166, 9211.484507, 8906.076566, 7227.155276,
6795.608201, 6926.023806, 8026.998142, 7388.809243, 7700.812705,
7493.134187, 7397.470718, 6794.411986, 8475.249868, 8387.892097,
8503.435859, 7890.106874, 7631.800415, 8349.757061, 7852.912013,
7758.848165, 7580.919692, 6402.21648, 6920.804051, 8628.194894,
7489.137138, 7866.037678, 7311.596266, 8746.497033, 9147.374207,
9022.033508, 8475.348448, 8911.007949, 8961.95446, 8476.003123,
8932.837953, 8661.336305, 8949.625535, 9048.100379, 10684.87284,
8845.185424, 8182.999872, 8986.675848, 8136.137692, 10504.2443,
8848.254372, 7233.813327, 8707.732966, 8381.547529, 10471.33626,
7682.888263, 8071.666541, 7428.171461, 9736.360333, 9378.789551,
8294.552055, 8225.545799, 8874.930993, 8459.226077, 8749.99335,
9192.455984, 7875.820212, 8982.410256, 8642.199262, 8935.14394,
8480.821358, 10240.80452, 8746.68483, 7619.897735, 8417.475201
)), .Names = c("ENTRY", "BLOCK", "PLOT", "RANGE", "ROW",
"YIELD"), row.names = 372:587, class = "data.frame")
The spatial arrangement of the data:
library(reshape2)
dcast(my.data, RANGE ~ ROW, value.var ="YIELD")
Possible examples of models to analyze the data:
library(nlme)
fit1 = lme(fixed = YIELD ~ ENTRY, data = my.data,
random= ~1 | BLOCK,
method = "ML")
fit2 = lme(fixed = YIELD ~ ENTRY, data = my.data,
random= ~1 | BLOCK,
corr = corSpatial(form = ~RANGE+ROW),
method = "ML")
Finally run out of ideas and links I could find to try and explain this so I need some help!
I'm trying to add a step-function to a ggplot chart using the cumSeg package. I did this successfully in this previous question, so I'm used to the usage of the function etc.
When I made the plot in that thread, it was fairly simple, just using an x vs y barplot for the mean values of x, and I added on error bars myself afterwards (thus it was a 16 x 2 dataframe).
I want to re-create this plot, but using sequential boxplots instead of bars, which I have done, using the raw data this time, which is ~250 observations in 16 factors (same factors as before).
Now when I try to add a geom_line,path or step it's complaining about the dimensions of the data not matching, because even though there are 16 factors/boxplots, there are now no longer 16 observations (Error: Aesthetics must be either length 1 or the same as the data (249): x, y, colour, group, fill)
To calculate the step function, I give it the means of each of the 16, which returns a 16-member vector, not ~250 (obviously).
How can I add the step function on to the box plot so that it understands it should pertain to the 16 factor values? I can't work out if it's a problem with the dataframe or how I'm giving it to ggplot.
I tried specifying it in a second dataframe, and passing it as geom_path(data=df2) instead of inheriting the main plots data, as in this question, but it still complains (Error: Aesthetics must be either length 1 or the same as the data (16): x, y, colour, group (the code below is in this form still)
data.melt <- melt(t(infile)
operon_gc <- 0.408891366
opgc_stdev <- 0.015712091
genome_gc <- 0.425031611
gengc_stdev <- 0.007587437
stepfunc <- jumpoints(y=aggregate(melted_data$value~melted_data$Var1, simplify=TRUE, FUN="mean")$`melted_data$value`, k=1, output="1")
func_data <- data.frame(x = c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16), y = stepfunc$fitted.values)
# Make boxplot
bp <- ggplot(melted_data, aes(x=Var1, y=value*100, fill=Var1)) + theme_bw()
#bp <- bp + scale_x_discrete(name = "Locus") + scale_y_continuous(name="GC Content (%)")
bp <- bp + geom_rect(xmin=0, xmax=17,
ymin=(operon_gc-opgc_stdev)*100,
ymax=(operon_gc+opgc_stdev)*100,
fill = "grey79", alpha=0.05)
bp <- bp + geom_rect(xmin=0, xmax=17,
ymin=(genome_gc-gengc_stdev)*100,
ymax=(genome_gc+gengc_stdev)*100,
fill = "beige", alpha=.08)
bp <- bp + geom_abline(intercept=genome_gc*100, slope=0,
colour="gray14", linetype=3)
bp <- bp + geom_abline(intercept=operon_gc*100, slope=0,
colour="gray14", linetype=3)
bp <- bp + geom_boxplot(alpha = 0.7)
bp <- bp + scale_color_manual(values = c("GC Step Fit"="red"), guides(color="Regression"))
bp <- bp + geom_path(linetype=4, size=0.9, aes(x=func_data$x,
y=func_data$y,
color="GC Step Fit",
group=1))
bp <- bp + theme(legend.position="bottom",
legend.direction="horizontal",
axis.text.x = element_text(angle=45, hjust=1)) + guides(fill=guide_legend(title="", nrow = 1))
bp
Data
> dput(func_data)
structure(list(x = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
14, 15, 16), y = c(0.452456815737206, 0.452456815737206, 0.452456815737206,
0.452456815737206, 0.452456815737206, 0.452456815737206, 0.452456815737206,
0.452456815737206, 0.452456815737206, 0.452456815737206, 0.452456815737206,
0.375047391939972, 0.375047391939972, 0.375047391939972, 0.375047391939972,
0.375047391939972)), .Names = c("x", "y"), row.names = c(NA,
-16L), class = "data.frame")
> dput(melted_data)
structure(list(Var1 = structure(c(1L, 2L, 3L, 4L, 5L, 6L, 7L,
8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 1L, 2L, 3L, 4L, 5L,
6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 1L, 2L, 3L,
4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 1L,
2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L,
16L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L,
14L, 15L, 16L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L,
12L, 13L, 14L, 15L, 16L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L,
10L, 11L, 12L, 13L, 14L, 15L, 16L, 1L, 2L, 3L, 4L, 5L, 6L, 7L,
8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 1L, 2L, 3L, 4L, 5L,
6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 1L, 2L, 3L,
4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 1L,
2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L,
16L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L,
14L, 15L, 16L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L,
12L, 13L, 14L, 15L, 16L, 1L, 2L, 4L, 5L, 6L, 7L, 8L, 9L, 10L,
11L, 12L, 14L, 15L, 16L, 1L, 2L, 4L, 5L, 6L, 7L, 8L, 9L, 10L,
11L, 12L, 15L, 16L, 1L, 2L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L,
12L, 15L, 16L, 11L), .Label = c("PVC1", "PVC2", "PVC3", "PVC4",
"PVC5", "PVC6", "PVC7", "PVC8", "PVC9", "PVC10", "PVC11", "PVC12",
"PVC13", "PVC14", "PVC15", "PVC16"), class = "factor"), Var2 = c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 7L,
7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 8L,
8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L,
12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 13L, 13L, 13L, 13L, 13L,
13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 14L, 14L,
14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 15L,
15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 16L,
16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 17L
), value = c(0.404444444, 0.436329588, 0.46031746, 0.479318735,
0.466230937, 0.480874317, 0.476811594, 0.441558442, 0.449172577,
0.476525822, 0.452674897, 0.460918332, 0.368041912, 0.339160839,
0.415355269, 0.408163265, 0.401826484, 0.45411985, 0.468609865,
0.479735318, 0.464052288, 0.469945355, 0.476811594, 0.444032158,
0.453900709, 0.494004796, 0.467315716, 0.457805907, 0.387071651,
0.390737117, 0.408679065, 0.425170068, 0.355555556, 0.438069217,
0.423076923, 0.466666667, 0.450980392, 0.422222222, 0.469298246,
0.43196005, 0.416666667, 0.496402878, 0.428676201, 0.382113821,
0.349765258, 0.332280147, 0.373371925, 0.346448087, 0.415555556,
0.440508629, 0.435222672, 0.455833333, 0.446623094, 0.422222222,
0.463450292, 0.43258427, 0.425675676, 0.497584541, 0.422524565,
0.392592593, 0.362779741, 0.337552743, 0.379856115, 0.348888889,
0.391111111, 0.421004566, 0.426439232, 0.480367586, 0.472766885,
0.455555556, 0.495726496, 0.447565543, 0.424460432, 0.48441247,
0.435164835, 0.39600551, 0.3858393, 0.323655914, 0.383693046,
0.329988852, 0.395555556, 0.452380952, 0.454756381, 0.448129252,
0.496732026, 0.423728814, 0.502923977, 0.433832709, 0.41607565,
0.498800959, 0.399161736, 0.368421053, 0.386568387, 0.369901547,
0.398550725, 0.34006734, 0.406392694, 0.455840456, 0.458598726,
0.43792517, 0.501089325, 0.427777778, 0.49122807, 0.435081149,
0.416020672, 0.48441247, 0.40617284, 0.379298942, 0.402298851,
0.361462729, 0.396135266, 0.356666667, 0.353333333, 0.439182916,
0.469316597, 0.461868038, 0.490196078, 0.405555556, 0.505847953,
0.430529595, 0.406619385, 0.470023981, 0.395262768, 0.355072464,
0.373677249, 0.348008386, 0.382804995, 0.355481728, 0.415555556,
0.481481481, 0.4550036, 0.485074627, 0.501089325, 0.5, 0.51754386,
0.465043695, 0.438478747, 0.501199041, 0.457733481, 0.416815742,
0.360672976, 0.388285024, 0.397509579, 0.356589147, 0.384444444,
0.482917821, 0.452525253, 0.487864078, 0.501089325, 0.488888889,
0.513157895, 0.47627965, 0.475609756, 0.513189448, 0.471391657,
0.419797257, 0.38467433, 0.376081425, 0.396666667, 0.370985604,
0.42, 0.477777778, 0.436063218, 0.476782753, 0.490196078, 0.466666667,
0.51754386, 0.45505618, 0.44295302, 0.532374101, 0.460707635,
0.426019548, 0.35755814, 0.389842632, 0.388489209, 0.358730159,
0.422222222, 0.459610028, 0.473304473, 0.502487562, 0.509803922,
0.438888889, 0.516081871, 0.480024969, 0.457317073, 0.527577938,
0.460969293, 0.424148607, 0.386850153, 0.369161868, 0.397677794,
0.357696567, 0.433333333, 0.450704225, 0.429118774, 0.497031383,
0.505446623, 0.455555556, 0.492690058, 0.444444444, 0.409722222,
0.501199041, 0.444812362, 0.414860681, 0.361111111, 0.390096618,
0.394724221, 0.358803987, 0.426666667, 0.471837488, 0.495748299,
0.511982571, 0.45, 0.513157895, 0.465043695, 0.438478747, 0.498800959,
0.453200148, 0.409375, 0.329166667, 0.384172662, 0.38961039,
0.413333333, 0.406113537, 0.450728363, 0.435244161, 0.431693989,
0.441520468, 0.427745665, 0.378076063, 0.389671362, 0.427222222,
0.397905759, 0.423295455, 0.375268817, 0.391111111, 0.39893617,
0.461538462, 0.437367304, 0.448087432, 0.454678363, 0.421323057,
0.384787472, 0.394366197, 0.419141914, 0.401331931, 0.423768939,
0.368817204, 0.42680776)), .Names = c("Var1", "Var2", "value"
), row.names = c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L,
12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L,
25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L, 36L, 37L,
38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L, 47L, 48L, 49L, 50L,
51L, 52L, 53L, 54L, 55L, 56L, 57L, 58L, 59L, 60L, 61L, 62L, 63L,
64L, 65L, 66L, 67L, 68L, 69L, 70L, 71L, 72L, 73L, 74L, 75L, 76L,
77L, 78L, 79L, 80L, 81L, 82L, 83L, 84L, 85L, 86L, 87L, 88L, 89L,
90L, 91L, 92L, 93L, 94L, 95L, 96L, 97L, 98L, 99L, 100L, 101L,
102L, 103L, 104L, 105L, 106L, 107L, 108L, 109L, 110L, 111L, 112L,
113L, 114L, 115L, 116L, 117L, 118L, 119L, 120L, 121L, 122L, 123L,
124L, 125L, 126L, 127L, 128L, 129L, 130L, 131L, 132L, 133L, 134L,
135L, 136L, 137L, 138L, 139L, 140L, 141L, 142L, 143L, 144L, 145L,
146L, 147L, 148L, 149L, 150L, 151L, 152L, 153L, 154L, 155L, 156L,
157L, 158L, 159L, 160L, 161L, 162L, 163L, 164L, 165L, 166L, 167L,
168L, 169L, 170L, 171L, 172L, 173L, 174L, 175L, 176L, 177L, 178L,
179L, 180L, 181L, 182L, 183L, 184L, 185L, 186L, 187L, 188L, 189L,
190L, 191L, 192L, 193L, 194L, 195L, 196L, 197L, 198L, 199L, 200L,
201L, 202L, 203L, 204L, 205L, 206L, 207L, 208L, 209L, 210L, 212L,
213L, 214L, 215L, 216L, 217L, 218L, 219L, 220L, 222L, 223L, 224L,
225L, 226L, 228L, 229L, 230L, 231L, 232L, 233L, 234L, 235L, 236L,
239L, 240L, 241L, 242L, 244L, 245L, 246L, 247L, 248L, 249L, 250L,
251L, 252L, 255L, 256L, 267L), class = "data.frame")
I'm not exactly sure how I solved this. I can only assume I was making a really stupid mistake before, but here's the code that finally produced the desired outcome:
bp_gc <- ggplot(melted_data, aes(x=Var1, y=value*100)) + theme_bw()
bp_gc <- bp_gc + geom_rect(xmin=0, xmax=17,
ymin=(operon_gc-opgc_stdev)*100,
ymax=(operon_gc+opgc_stdev)*100,
fill = "grey79", alpha=0.05)
bp_gc <- bp_gc + geom_rect(xmin=0, xmax=17,
ymin=(genome_gc-gengc_stdev)*100,
ymax=(genome_gc+gengc_stdev)*100,
fill = "beige", alpha=.08)
bp_gc <- bp_gc + geom_abline(intercept=genome_gc*100, slope=0,
colour="gray14", linetype=3)
bp_gc <- bp_gc + geom_abline(intercept=operon_gc*100, slope=0,
colour="gray14", linetype=3)
bp_gc <- bp_gc + geom_boxplot(alpha = 0.7, fill="dodgerblue", color="gray11")
bp_gc <- bp_gc + ylab("GC Content (%)")
bp_gc <- bp_gc + xlab("Locus")
bp_gc <- bp_gc + theme(legend.position = "none",
axis.text.x = element_text(angle=45, hjust=1))
bp_gc <- bp_gc + coord_cartesian(ylim=c(30,60))
bp_gc <- bp_gc + geom_path(data=func_data, linetype=4, size=0.9, aes(x=x,y=y*100))
bp_gc
I'm not 100% clear on what you're trying to achieve. Is it like this?
ggplot(melted_df, aes(Var1, value)) +
geom_boxplot()
ggplot(df, aes(Var1, value)) +
stat_summary(fun.y = median, geom = "path", aes(group = 1)) +
geom_boxplot()
If you really want to compute your statistics outside the main dataframe, it's usually best to do it something like this:
ggplot(df1, aes(x, y)) + geom_point() +
geom_path(data = summarydf, aes(xmean, ymean))
I have a dataframe looking like this:
chr <- c(1,1,1,1,1)
b1 <- c('HP', 'HP', 'CP', 'CP', 'KP')
b2 <- c('HP', 'HP', 'CP', 'CP', 'KP')
b3 <- c('CP', 'KP', 'CP', 'HP', 'CP')
b4 <- c('CP', 'KP', 'CP', 'HP', 'CP')
b5 <- c('CP', 'CP', 'KP', 'KP', 'HP')
b6 <- c('CP', 'CP', 'KP', 'KP', 'HP')
b7 <- c('CP', 'KP', 'HP', 'CP', 'CP')
b8 <- c('CP', 'KP', 'HP', 'CP', 'CP')
df <- data.frame(chr, b1,b2,b3,b4,b5,b6,b7,b8)
I want to write a function that looks at each 'b' column and asks if it contains the value 'HP'. If it does, and the other six 'b' columns contain 'CP' or 'KP', I want to change the value 'HP' into 'CP' or 'KP' depending on which is the majority. If CP is the majority, change the HP to CP. If KP is the majority, change HP to KP.
(note that the value of b1 and b2, b3 and b4 etc is always the same, so really only 4 columns need to be looked at, b1, b3, b5, and b7).
To clarify, if the columns are e.g. HP HP CP CP CP CP KP KP, I want to change the two HPs into CPs (and leave the other columns the same).
So, the example I gave would become:
chr <- c(1,1,1,1,1)
b1 <- c('CP', 'KP', 'CP', 'CP', 'KP')
b2 <- c('CP', 'KP', 'CP', 'CP', 'KP')
b3 <- c('CP', 'KP', 'CP', 'CP', 'CP')
b4 <- c('CP', 'KP', 'CP', 'CP', 'CP')
b5 <- c('CP', 'CP', 'KP', 'KP', 'CP')
b6 <- c('CP', 'CP', 'KP', 'KP', 'CP')
b7 <- c('CP', 'KP', 'CP', 'CP', 'CP')
b8 <- c('CP', 'KP', 'CP', 'CP', 'CP')
df <- data.frame(chr, b1,b2,b3,b4,b5,b6,b7,b8)
df
I have written a function (just for df$b1) with if statements, but it doesn't work.
(note the rules for whether the HP changes to KP or CP depend on how many other CPs or KPs there are):
fun <- function(df){
if(df$b1 == 'HP' && df$b3 == 'CP' && df$b5 == 'CP' && df$b7 == 'CP') {df$b1 <- 'KP'}
if(df$b1 == 'HP' && df$b3 == 'KP' && df$b5 == 'CP' && df$b7 == 'CP') {df$b1 <- 'CP'}
if(df$b1 == 'HP' && df$b3 == 'CP' && df$b5 == 'KP' && df$b7 == 'CP') {df$b1 <- 'CP'}
if(df$b1 == 'HP' && df$b3 == 'CP' && df$b5 == 'CP' && df$b7 == 'KP') {df$b1 <- 'CP'}
if(df$b1 == 'HP' && df$b3 == 'KP' && df$b5 == 'KP' && df$b7 == 'CP') {df$b1 <- 'KP'}
if(df$b1 == 'HP' && df$b3 == 'KP' && df$b5 == 'CP' && df$b7 == 'KP') {df$b1 <- 'KP'}
if(df$b1 == 'HP' && df$b3 == 'CP' && df$b5 == 'KP' && df$b7 == 'KP') {df$b1 <- 'KP'}
if(df$b1 == 'HP' && df$b3 == 'KP' && df$b5 == 'KP' && df$b7 == 'KP') {df$b1 <- 'CP'}
df$b2 <-df$b1
}
Thanks very much for any help. I'm really stuck on this one.
EDIT: This is a sample of my actual data which is more complex than the example I gave above.
structure(list(chr = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L), pos_c = c(2373L, 2406L, 2418L, 2419L,
2447L, 2450L, 2468L, 2524L, 2533L, 2535L, 2536L, 2542L, 2623L,
2709L, 3942L, 11716L, 11893L, 11898L, 12190L, 12396L, 26639L,
26640L, 26643L, 26646L, 26655L, 26657L, 26661L, 26667L, 26670L,
26676L, 26679L, 26684L, 26685L, 26688L, 26694L, 26703L, 26710L,
26712L, 26713L, 26723L, 26733L, 26737L, 26738L, 26739L, 26742L,
26743L, 26748L, 26761L, 26765L, 26766L, 26778L, 26781L, 26790L,
26792L, 26796L, 26802L, 26805L, 26811L, 26814L, 26819L, 26820L,
26823L, 26829L, 26838L, 26846L, 26847L, 26848L, 26872L, 26873L,
26874L, 26877L, 26878L, 26883L, 26889L, 26901L, 26904L, 26907L,
26916L, 26923L, 26925L, 26927L, 26931L, 26937L, 26940L, 26946L,
26954L, 26958L, 26961L, 26963L, 26964L, 26970L, 26981L, 26982L,
26983L, 26991L, 26994L, 26997L, 27007L, 27008L, 27009L, 27012L,
27015L, 27018L, 27027L, 202471L, 203660L, 203668L, 203669L, 203670L,
203672L, 203678L, 203683L, 203686L, 203687L, 203690L, 203704L,
203705L, 203711L, 203714L, 203732L, 203749L, 203752L, 203754L,
203755L, 203903L, 203910L, 203911L, 203912L, 203913L, 203914L,
203915L, 203922L, 203924L, 203933L, 203937L, 203939L, 203945L,
203948L, 203951L, 203957L, 203960L, 203961L, 203963L, 203969L,
203972L, 203973L, 203974L, 203975L, 203981L, 203991L, 204220L,
204227L, 204230L, 204232L, 204242L, 204245L, 204262L, 204272L,
204278L, 204282L, 204290L), c1 = c(101L, 60L, 63L, 64L, 100L,
97L, 94L, 83L, 80L, 48L, 46L, 51L, 69L, 46L, 23L, 79L, 63L, 59L,
53L, 85L, 13L, 12L, 1L, 9L, 11L, 13L, 9L, 14L, 14L, 12L, 15L,
9L, 15L, 14L, 14L, 2L, 2L, 8L, 3L, 0L, 0L, 4L, 2L, 1L, 4L, 4L,
8L, 39L, 7L, 5L, 2L, 41L, 69L, 79L, 89L, 120L, 128L, 90L, 134L,
107L, 169L, 120L, 103L, 48L, 58L, 132L, 62L, 19L, 9L, 13L, 12L,
12L, 17L, 251L, 8L, 367L, 367L, 264L, 5L, 170L, 113L, 234L, 134L,
143L, 189L, 224L, 255L, 296L, 448L, 239L, 169L, 80L, 312L, 84L,
403L, 397L, 430L, 529L, 544L, 556L, 565L, 549L, 555L, 4L, 11L,
0L, 18L, 18L, 19L, 19L, 18L, 18L, 17L, 17L, 15L, 15L, 16L, 15L,
13L, 14L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 2L, 3L, 2L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 1L, 13L, 2L, 10L, 4L, 10L, 24L, 33L, 33L, 63L, 42L), c2 = c(101L,
60L, 63L, 64L, 100L, 97L, 94L, 83L, 80L, 48L, 46L, 51L, 69L,
46L, 23L, 79L, 63L, 59L, 53L, 85L, 13L, 12L, 1L, 9L, 11L, 13L,
9L, 14L, 14L, 12L, 15L, 9L, 15L, 14L, 14L, 2L, 2L, 8L, 3L, 0L,
0L, 4L, 2L, 1L, 4L, 4L, 8L, 39L, 7L, 5L, 2L, 41L, 69L, 79L, 89L,
120L, 128L, 90L, 134L, 107L, 169L, 120L, 103L, 48L, 58L, 132L,
62L, 19L, 9L, 13L, 12L, 12L, 17L, 251L, 8L, 367L, 367L, 264L,
5L, 170L, 113L, 234L, 134L, 143L, 189L, 224L, 255L, 296L, 448L,
239L, 169L, 80L, 312L, 84L, 403L, 397L, 430L, 529L, 544L, 556L,
565L, 549L, 555L, 4L, 11L, 0L, 18L, 18L, 19L, 19L, 18L, 18L,
17L, 17L, 15L, 15L, 16L, 15L, 13L, 14L, 0L, 1L, 0L, 0L, 0L, 0L,
0L, 2L, 3L, 2L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 13L, 2L, 10L, 4L, 10L, 24L,
33L, 33L, 63L, 42L), c3 = c(37L, 0L, 0L, 0L, 42L, 46L, 46L, 21L,
26L, 6L, 2L, 7L, 11L, 4L, 0L, 4L, 1L, 0L, 0L, 2L, 29L, 29L, 0L,
22L, 23L, 23L, 26L, 27L, 29L, 24L, 32L, 26L, 35L, 32L, 32L, 3L,
3L, 10L, 1L, 5L, 1L, 6L, 1L, 0L, 5L, 11L, 6L, 81L, 15L, 14L,
0L, 92L, 157L, 174L, 168L, 236L, 221L, 143L, 228L, 251L, 292L,
273L, 281L, 33L, 39L, 260L, 57L, 53L, 24L, 22L, 26L, 37L, 37L,
484L, 16L, 721L, 724L, 436L, 7L, 367L, 163L, 411L, 167L, 373L,
275L, 599L, 637L, 773L, 866L, 615L, 223L, 63L, 531L, 59L, 878L,
868L, 911L, 939L, 975L, 995L, 980L, 931L, 958L, 12L, 16L, 0L,
12L, 13L, 12L, 11L, 9L, 12L, 11L, 11L, 10L, 1L, 0L, 0L, 0L, 1L,
1L, 2L, 1L, 0L, 1L, 1L, 0L, 2L, 2L, 2L, 0L, 0L, 0L, 0L, 0L, 1L,
0L, 0L, 1L, 0L, 0L, 1L, 0L, 0L, 0L, 1L, 1L, 0L, 1L, 1L, 2L, 28L,
5L, 28L, 3L, 12L, 39L, 40L, 50L, 90L, 80L), c4 = c(37L, 0L, 0L,
0L, 42L, 46L, 46L, 21L, 26L, 6L, 2L, 7L, 11L, 4L, 0L, 4L, 1L,
0L, 0L, 2L, 29L, 29L, 0L, 22L, 23L, 23L, 26L, 27L, 29L, 24L,
32L, 26L, 35L, 32L, 32L, 3L, 3L, 10L, 1L, 5L, 1L, 6L, 1L, 0L,
5L, 11L, 6L, 81L, 15L, 14L, 0L, 92L, 157L, 174L, 168L, 236L,
221L, 143L, 228L, 251L, 292L, 273L, 281L, 33L, 39L, 260L, 57L,
53L, 24L, 22L, 26L, 37L, 37L, 484L, 16L, 721L, 724L, 436L, 7L,
367L, 163L, 411L, 167L, 373L, 275L, 599L, 637L, 773L, 866L, 615L,
223L, 63L, 531L, 59L, 878L, 868L, 911L, 939L, 975L, 995L, 980L,
931L, 958L, 12L, 16L, 0L, 12L, 13L, 12L, 11L, 9L, 12L, 11L, 11L,
10L, 1L, 0L, 0L, 0L, 1L, 1L, 2L, 1L, 0L, 1L, 1L, 0L, 2L, 2L,
2L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 0L, 0L, 1L, 0L, 0L, 0L,
1L, 1L, 0L, 1L, 1L, 2L, 28L, 5L, 28L, 3L, 12L, 39L, 40L, 50L,
90L, 80L), c5 = c(96L, 77L, 74L, 72L, 96L, 96L, 92L, 80L, 79L,
79L, 76L, 76L, 66L, 55L, 64L, 78L, 110L, 100L, 165L, 171L, 38L,
41L, 2L, 38L, 33L, 37L, 21L, 40L, 41L, 21L, 37L, 19L, 45L, 30L,
22L, 22L, 28L, 34L, 30L, 31L, 25L, 40L, 34L, 33L, 34L, 46L, 41L,
96L, 48L, 51L, 38L, 93L, 152L, 155L, 155L, 193L, 195L, 189L,
222L, 213L, 284L, 248L, 230L, 56L, 70L, 208L, 82L, 85L, 67L,
64L, 64L, 83L, 71L, 495L, 77L, 570L, 577L, 499L, 55L, 292L, 236L,
352L, 244L, 296L, 351L, 391L, 440L, 483L, 653L, 417L, 194L, 57L,
460L, 57L, 538L, 520L, 573L, 731L, 753L, 770L, 772L, 757L, 761L,
35L, 73L, 66L, 70L, 70L, 71L, 70L, 74L, 79L, 82L, 83L, 85L, 69L,
68L, 71L, 71L, 70L, 73L, 72L, 72L, 74L, 103L, 107L, 106L, 107L,
109L, 106L, 106L, 105L, 106L, 105L, 108L, 104L, 105L, 106L, 106L,
103L, 112L, 112L, 113L, 112L, 109L, 114L, 114L, 115L, 120L, 114L,
97L, 125L, 103L, 124L, 107L, 116L, 145L, 139L, 138L, 177L, 139L
), c6 = c(96L, 77L, 74L, 72L, 96L, 96L, 92L, 80L, 79L, 79L, 76L,
76L, 66L, 55L, 64L, 78L, 110L, 100L, 165L, 171L, 38L, 41L, 2L,
38L, 33L, 37L, 21L, 40L, 41L, 21L, 37L, 19L, 45L, 30L, 22L, 22L,
28L, 34L, 30L, 31L, 25L, 40L, 34L, 33L, 34L, 46L, 41L, 96L, 48L,
51L, 38L, 93L, 152L, 155L, 155L, 193L, 195L, 189L, 222L, 213L,
284L, 248L, 230L, 56L, 70L, 208L, 82L, 85L, 67L, 64L, 64L, 83L,
71L, 495L, 77L, 570L, 577L, 499L, 55L, 292L, 236L, 352L, 244L,
296L, 351L, 391L, 440L, 483L, 653L, 417L, 194L, 57L, 460L, 57L,
538L, 520L, 573L, 731L, 753L, 770L, 772L, 757L, 761L, 35L, 73L,
66L, 70L, 70L, 71L, 70L, 74L, 79L, 82L, 83L, 85L, 69L, 68L, 71L,
71L, 70L, 73L, 72L, 72L, 74L, 103L, 107L, 106L, 107L, 109L, 106L,
106L, 105L, 106L, 105L, 108L, 104L, 105L, 106L, 106L, 103L, 112L,
112L, 113L, 112L, 109L, 114L, 114L, 115L, 120L, 114L, 97L, 125L,
103L, 124L, 107L, 116L, 145L, 139L, 138L, 177L, 139L), c7 = c(28L,
3L, 1L, 1L, 52L, 50L, 60L, 49L, 50L, 3L, 2L, 2L, 37L, 11L, 0L,
1L, 2L, 2L, 0L, 1L, 28L, 30L, 1L, 17L, 23L, 28L, 11L, 30L, 32L,
13L, 32L, 19L, 39L, 18L, 17L, 23L, 29L, 46L, 37L, 25L, 21L, 42L,
32L, 29L, 30L, 41L, 44L, 141L, 72L, 64L, 25L, 93L, 219L, 234L,
218L, 294L, 277L, 184L, 294L, 273L, 382L, 293L, 280L, 131L, 132L,
386L, 157L, 99L, 77L, 75L, 68L, 66L, 88L, 615L, 55L, 746L, 740L,
685L, 27L, 305L, 158L, 511L, 151L, 326L, 371L, 605L, 650L, 727L,
886L, 623L, 314L, 170L, 734L, 162L, 937L, 908L, 987L, 964L, 997L,
1002L, 1007L, 960L, 980L, 28L, 75L, 61L, 96L, 98L, 97L, 96L,
93L, 101L, 99L, 100L, 98L, 91L, 90L, 90L, 89L, 87L, 76L, 75L,
75L, 76L, 88L, 92L, 87L, 86L, 88L, 87L, 85L, 87L, 87L, 83L, 86L,
87L, 86L, 86L, 89L, 83L, 83L, 84L, 84L, 86L, 83L, 86L, 88L, 87L,
88L, 84L, 81L, 118L, 90L, 120L, 90L, 101L, 127L, 134L, 140L,
172L, 160L), c8 = c(28L, 3L, 1L, 1L, 52L, 50L, 60L, 49L, 50L,
3L, 2L, 2L, 37L, 11L, 0L, 1L, 2L, 2L, 0L, 1L, 28L, 30L, 1L, 17L,
23L, 28L, 11L, 30L, 32L, 13L, 32L, 19L, 39L, 18L, 17L, 23L, 29L,
46L, 37L, 25L, 21L, 42L, 32L, 29L, 30L, 41L, 44L, 141L, 72L,
64L, 25L, 93L, 219L, 234L, 218L, 294L, 277L, 184L, 294L, 273L,
382L, 293L, 280L, 131L, 132L, 386L, 157L, 99L, 77L, 75L, 68L,
66L, 88L, 615L, 55L, 746L, 740L, 685L, 27L, 305L, 158L, 511L,
151L, 326L, 371L, 605L, 650L, 727L, 886L, 623L, 314L, 170L, 734L,
162L, 937L, 908L, 987L, 964L, 997L, 1002L, 1007L, 960L, 980L,
28L, 75L, 61L, 96L, 98L, 97L, 96L, 93L, 101L, 99L, 100L, 98L,
91L, 90L, 90L, 89L, 87L, 76L, 75L, 75L, 76L, 88L, 92L, 87L, 86L,
88L, 87L, 85L, 87L, 87L, 83L, 86L, 87L, 86L, 86L, 89L, 83L, 83L,
84L, 84L, 86L, 83L, 86L, 88L, 87L, 88L, 84L, 81L, 118L, 90L,
120L, 90L, 101L, 127L, 134L, 140L, 172L, 160L), k1 = c(39L, 64L,
68L, 69L, 38L, 38L, 41L, 51L, 54L, 84L, 83L, 84L, 57L, 50L, 43L,
58L, 72L, 71L, 29L, 35L, 0L, 0L, 10L, 1L, 1L, 0L, 3L, 0L, 0L,
1L, 0L, 3L, 0L, 0L, 0L, 14L, 14L, 9L, 15L, 18L, 24L, 20L, 20L,
27L, 28L, 10L, 28L, 27L, 59L, 64L, 73L, 43L, 19L, 7L, 27L, 5L,
23L, 30L, 29L, 65L, 10L, 46L, 27L, 160L, 168L, 95L, 175L, 255L,
265L, 271L, 270L, 76L, 269L, 77L, 14L, 12L, 11L, 118L, 382L,
204L, 220L, 181L, 290L, 290L, 114L, 209L, 89L, 159L, 7L, 144L,
95L, 9L, 180L, 411L, 105L, 125L, 97L, 19L, 3L, 3L, 2L, 12L, 1L,
540L, 1L, 32L, 14L, 14L, 13L, 13L, 15L, 14L, 12L, 11L, 12L, 11L,
12L, 13L, 13L, 9L, 18L, 17L, 8L, 18L, 6L, 2L, 1L, 2L, 1L, 2L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 3L, 3L, 4L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 1L, 0L, 2L, 1L, 21L, 28L, 49L, 50L, 54L, 45L,
44L), k2 = c(39L, 64L, 68L, 69L, 38L, 38L, 41L, 51L, 54L, 84L,
83L, 84L, 57L, 50L, 43L, 58L, 72L, 71L, 29L, 35L, 0L, 0L, 10L,
1L, 1L, 0L, 3L, 0L, 0L, 1L, 0L, 3L, 0L, 0L, 0L, 14L, 14L, 9L,
15L, 18L, 24L, 20L, 20L, 27L, 28L, 10L, 28L, 27L, 59L, 64L, 73L,
43L, 19L, 7L, 27L, 5L, 23L, 30L, 29L, 65L, 10L, 46L, 27L, 160L,
168L, 95L, 175L, 255L, 265L, 271L, 270L, 76L, 269L, 77L, 14L,
12L, 11L, 118L, 382L, 204L, 220L, 181L, 290L, 290L, 114L, 209L,
89L, 159L, 7L, 144L, 95L, 9L, 180L, 411L, 105L, 125L, 97L, 19L,
3L, 3L, 2L, 12L, 1L, 540L, 1L, 32L, 14L, 14L, 13L, 13L, 15L,
14L, 12L, 11L, 12L, 11L, 12L, 13L, 13L, 9L, 18L, 17L, 8L, 18L,
6L, 2L, 1L, 2L, 1L, 2L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 3L, 3L, 4L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 0L, 2L, 1L, 21L,
28L, 49L, 50L, 54L, 45L, 44L), k3 = c(84L, 122L, 120L, 120L,
92L, 88L, 90L, 107L, 98L, 114L, 120L, 117L, 91L, 64L, 59L, 100L,
113L, 109L, 56L, 136L, 1L, 0L, 29L, 7L, 4L, 6L, 5L, 6L, 6L, 9L,
7L, 11L, 7L, 10L, 9L, 44L, 46L, 38L, 51L, 60L, 79L, 75L, 80L,
83L, 80L, 41L, 97L, 61L, 133L, 135L, 180L, 100L, 50L, 28L, 75L,
18L, 79L, 94L, 100L, 117L, 47L, 74L, 68L, 393L, 390L, 191L, 416L,
504L, 532L, 545L, 545L, 181L, 556L, 175L, 19L, 24L, 19L, 312L,
766L, 389L, 416L, 418L, 639L, 475L, 239L, 293L, 70L, 135L, 37L,
122L, 84L, 42L, 408L, 886L, 93L, 115L, 65L, 67L, 35L, 37L, 47L,
50L, 54L, 942L, 9L, 43L, 29L, 29L, 29L, 29L, 28L, 27L, 25L, 25L,
26L, 32L, 33L, 32L, 33L, 30L, 26L, 23L, 24L, 23L, 8L, 1L, 2L,
2L, 2L, 2L, 2L, 4L, 4L, 4L, 4L, 3L, 4L, 3L, 3L, 3L, 3L, 3L, 3L,
4L, 4L, 3L, 3L, 4L, 3L, 2L, 2L, 0L, 7L, 3L, 65L, 73L, 111L, 98L,
133L, 107L, 64L), k4 = c(84L, 122L, 120L, 120L, 92L, 88L, 90L,
107L, 98L, 114L, 120L, 117L, 91L, 64L, 59L, 100L, 113L, 109L,
56L, 136L, 1L, 0L, 29L, 7L, 4L, 6L, 5L, 6L, 6L, 9L, 7L, 11L,
7L, 10L, 9L, 44L, 46L, 38L, 51L, 60L, 79L, 75L, 80L, 83L, 80L,
41L, 97L, 61L, 133L, 135L, 180L, 100L, 50L, 28L, 75L, 18L, 79L,
94L, 100L, 117L, 47L, 74L, 68L, 393L, 390L, 191L, 416L, 504L,
532L, 545L, 545L, 181L, 556L, 175L, 19L, 24L, 19L, 312L, 766L,
389L, 416L, 418L, 639L, 475L, 239L, 293L, 70L, 135L, 37L, 122L,
84L, 42L, 408L, 886L, 93L, 115L, 65L, 67L, 35L, 37L, 47L, 50L,
54L, 942L, 9L, 43L, 29L, 29L, 29L, 29L, 28L, 27L, 25L, 25L, 26L,
32L, 33L, 32L, 33L, 30L, 26L, 23L, 24L, 23L, 8L, 1L, 2L, 2L,
2L, 2L, 2L, 4L, 4L, 4L, 4L, 3L, 4L, 3L, 3L, 3L, 3L, 3L, 3L, 4L,
4L, 3L, 3L, 4L, 3L, 2L, 2L, 0L, 7L, 3L, 65L, 73L, 111L, 98L,
133L, 107L, 64L), k5 = c(0L, 14L, 14L, 14L, 1L, 0L, 0L, 8L, 7L,
5L, 5L, 5L, 0L, 3L, 0L, 8L, 2L, 3L, 18L, 15L, 0L, 2L, 38L, 3L,
5L, 1L, 18L, 1L, 2L, 2L, 3L, 21L, 2L, 15L, 1L, 26L, 22L, 17L,
27L, 33L, 41L, 39L, 42L, 45L, 51L, 14L, 50L, 31L, 82L, 84L, 108L,
55L, 24L, 16L, 51L, 33L, 44L, 55L, 54L, 87L, 15L, 20L, 27L, 285L,
297L, 151L, 293L, 343L, 363L, 374L, 376L, 57L, 382L, 24L, 25L,
10L, 8L, 103L, 551L, 301L, 320L, 276L, 364L, 340L, 49L, 272L,
171L, 195L, 24L, 180L, 161L, 11L, 254L, 663L, 188L, 229L, 158L,
26L, 3L, 3L, 6L, 10L, 6L, 708L, 0L, 9L, 0L, 3L, 0L, 1L, 0L, 2L,
0L, 0L, 1L, 9L, 9L, 9L, 10L, 10L, 6L, 6L, 1L, 6L, 2L, 0L, 5L,
3L, 2L, 3L, 4L, 2L, 3L, 2L, 2L, 1L, 3L, 0L, 0L, 4L, 1L, 0L, 1L,
5L, 2L, 0L, 1L, 2L, 0L, 2L, 5L, 1L, 3L, 3L, 43L, 50L, 78L, 75L,
87L, 78L, 59L), k6 = c(0L, 14L, 14L, 14L, 1L, 0L, 0L, 8L, 7L,
5L, 5L, 5L, 0L, 3L, 0L, 8L, 2L, 3L, 18L, 15L, 0L, 2L, 38L, 3L,
5L, 1L, 18L, 1L, 2L, 2L, 3L, 21L, 2L, 15L, 1L, 26L, 22L, 17L,
27L, 33L, 41L, 39L, 42L, 45L, 51L, 14L, 50L, 31L, 82L, 84L, 108L,
55L, 24L, 16L, 51L, 33L, 44L, 55L, 54L, 87L, 15L, 20L, 27L, 285L,
297L, 151L, 293L, 343L, 363L, 374L, 376L, 57L, 382L, 24L, 25L,
10L, 8L, 103L, 551L, 301L, 320L, 276L, 364L, 340L, 49L, 272L,
171L, 195L, 24L, 180L, 161L, 11L, 254L, 663L, 188L, 229L, 158L,
26L, 3L, 3L, 6L, 10L, 6L, 708L, 0L, 9L, 0L, 3L, 0L, 1L, 0L, 2L,
0L, 0L, 1L, 9L, 9L, 9L, 10L, 10L, 6L, 6L, 1L, 6L, 2L, 0L, 5L,
3L, 2L, 3L, 4L, 2L, 3L, 2L, 2L, 1L, 3L, 0L, 0L, 4L, 1L, 0L, 1L,
5L, 2L, 0L, 1L, 2L, 0L, 2L, 5L, 1L, 3L, 3L, 43L, 50L, 78L, 75L,
87L, 78L, 59L), k7 = c(0L, 36L, 42L, 44L, 0L, 0L, 0L, 3L, 3L,
49L, 50L, 51L, 0L, 0L, 0L, 0L, 0L, 0L, 31L, 158L, 0L, 1L, 28L,
14L, 11L, 9L, 27L, 14L, 12L, 14L, 14L, 28L, 14L, 32L, 19L, 41L,
37L, 26L, 39L, 57L, 85L, 75L, 82L, 87L, 87L, 37L, 91L, 54L, 124L,
138L, 206L, 150L, 44L, 18L, 92L, 38L, 76L, 95L, 101L, 155L, 20L,
90L, 48L, 375L, 344L, 135L, 379L, 519L, 537L, 549L, 563L, 67L,
557L, 91L, 43L, 30L, 35L, 125L, 784L, 491L, 519L, 324L, 627L,
503L, 215L, 296L, 68L, 203L, 42L, 173L, 58L, 43L, 222L, 812L,
64L, 98L, 36L, 65L, 36L, 45L, 42L, 50L, 43L, 962L, 0L, 36L, 0L,
0L, 0L, 1L, 1L, 0L, 0L, 0L, 1L, 15L, 17L, 15L, 13L, 12L, 25L,
27L, 8L, 26L, 7L, 2L, 5L, 5L, 4L, 5L, 5L, 5L, 5L, 6L, 5L, 4L,
6L, 0L, 0L, 5L, 0L, 1L, 0L, 5L, 3L, 0L, 0L, 4L, 0L, 1L, 4L, 2L,
9L, 3L, 59L, 77L, 123L, 107L, 144L, 119L, 79L), k8 = c(0L, 36L,
42L, 44L, 0L, 0L, 0L, 3L, 3L, 49L, 50L, 51L, 0L, 0L, 0L, 0L,
0L, 0L, 31L, 158L, 0L, 1L, 28L, 14L, 11L, 9L, 27L, 14L, 12L,
14L, 14L, 28L, 14L, 32L, 19L, 41L, 37L, 26L, 39L, 57L, 85L, 75L,
82L, 87L, 87L, 37L, 91L, 54L, 124L, 138L, 206L, 150L, 44L, 18L,
92L, 38L, 76L, 95L, 101L, 155L, 20L, 90L, 48L, 375L, 344L, 135L,
379L, 519L, 537L, 549L, 563L, 67L, 557L, 91L, 43L, 30L, 35L,
125L, 784L, 491L, 519L, 324L, 627L, 503L, 215L, 296L, 68L, 203L,
42L, 173L, 58L, 43L, 222L, 812L, 64L, 98L, 36L, 65L, 36L, 45L,
42L, 50L, 43L, 962L, 0L, 36L, 0L, 0L, 0L, 1L, 1L, 0L, 0L, 0L,
1L, 15L, 17L, 15L, 13L, 12L, 25L, 27L, 8L, 26L, 7L, 2L, 5L, 5L,
4L, 5L, 5L, 5L, 5L, 6L, 5L, 4L, 6L, 0L, 0L, 5L, 0L, 1L, 0L, 5L,
3L, 0L, 0L, 4L, 0L, 1L, 4L, 2L, 9L, 3L, 59L, 77L, 123L, 107L,
144L, 119L, 79L), b1 = structure(c(7L, 3L, 3L, 3L, 7L, 7L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 7L, 1L, 1L, 7L,
7L, 7L, 1L, 7L, 1L, 1L, 1L, 1L, 7L, 1L, 1L, 1L, 7L, 7L, 7L, 7L,
5L, 5L, 7L, 7L, 5L, 5L, 7L, 7L, 3L, 5L, 5L, 5L, 3L, 7L, 7L, 7L,
1L, 7L, 7L, 7L, 3L, 1L, 7L, 7L, 7L, 7L, 3L, 7L, 5L, 5L, 5L, 5L,
7L, 5L, 7L, 7L, 1L, 1L, 3L, 5L, 3L, 7L, 3L, 3L,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3L, 3L, 6L, 3L, 3L,
6L), .Label = c("CF", "CP", "HP", "KP", "NF", "NP"), class = "factor")), .Names = c("chr",
"pos_c", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "k1",
"k2", "k3", "k4", "k5", "k6", "k7", "k8", "b1", "b2", "b3", "b4",
"b5", "b6", "b7", "b8"), class = "data.frame", row.names = c(NA,
-161L))
You can try:
t(apply(df[,-1], 1, function(rg){
occ_rg <- table(rg)
rg[grep("HP",rg)] <- names(occ_rg)[which.max(occ_rg)]
return(rg)}))
So, to have your new df:
df <- data.frame(chr=df[, 1], t(apply(df[,-1], 1, function(rg){
occ_rg <- table(rg)
rg[grep("HP",rg)] <- names(occ_rg)[which.max(occ_rg)]
return(rg)})),
stringsAsFactors=F)
# chr b1 b2 b3 b4 b5 b6 b7 b8
#1 1 CP CP CP CP CP CP CP CP
#2 1 KP KP KP KP CP CP KP KP
#3 1 CP CP CP CP KP KP CP CP
#4 1 CP CP CP CP KP KP CP CP
#5 1 KP KP CP CP CP CP CP CP
EDIT
If you have other columns and the columns you want to change are the only ones beginning with "b", you can do :
df[, grepl("^b", colnames(df))] <- t(apply(df[, grepl("^b", colnames(df))],
1,
function(rg){
occ_rg <- table(rg)
rg[grep("HP",rg)] <- names(occ_rg)[which.max(occ_rg)]
return(rg)}))
Example:
With this df:
# chr c1 b1 b2 b3 b4 b5 b6 b7 b8 c2
#1 1 1 HP HP CP CP CP CP CP CP 11
#2 1 2 HP HP KP KP CP CP KP KP 12
#3 1 3 CP CP CP CP KP KP HP HP 13
#4 1 4 CP CP HP HP KP KP CP CP 14
#5 1 5 KP KP CP CP HP HP CP CP 15
You get:
# chr c1 b1 b2 b3 b4 b5 b6 b7 b8 c2
#1 1 1 CP CP CP CP CP CP CP CP 11
#2 1 2 KP KP KP KP CP CP KP KP 12
#3 1 3 CP CP CP CP KP KP CP CP 13
#4 1 4 CP CP CP CP KP KP CP CP 14
#5 1 5 KP KP CP CP CP CP CP CP 15
EDIT 2
If you have other values than "HP", "CP" and "KP" and want to replace "HP" by either "CP" or "KP", depending on which occurs the most, you can do:
df[, grepl("^b", colnames(df))] <- t(apply(df[, grepl("^b", colnames(df))],
1,
function(rg){
occ_rg <- table(rg)
occ_rg <- occ_rg[grepl("KP|CP", names(occ_rg))]
rg[grep("HP",rg)] <- names(occ_rg)[which.max(occ_rg)]
return(rg)}))
Explanation (for edit2):
df[, grepl("^b", colnames(df))] <- # only the columns beginning with b are considered (so the other ones will remain untouched)
t( # the results of apply will be transposed
apply(df[, grepl("^b", colnames(df))], # apply on df with only the columns beginning by b
1, # by row
function(rg){ # a function that takes a vector "rg" as input
occ_rg <- table(rg) # computes the table
occ_rg <- occ_rg[grepl("KP|CP", names(occ_rg))] # keep only the occurrences of either "KP" or "CP"
rg[grep("HP",rg)] <- names(occ_rg)[which.max(occ_rg)] # replace in the vector rg the "HP" elements by "KP" or "CP" depending on which occurs the most
return(rg) # finally returns the vector rg
}))