I have the following code:
set.seed(123)
CIS_data_5 <- data.frame(
CIS$P20,
CIS$P3
)
CIS$P3 <- factor(CIS$P3, labels = c("Mejor", "(NO LEER) Igual", "Peor", "N.S.", "N.C."))
n <- as.numeric(c(CIS$P20))
P20 <- sample(n, 2787, replace = TRUE, prob = NULL)
P20labs <- c("16-29", "30-44", "45-64", ">65", "N.C.")
cut_points <- c(16, 30, 45, 65, Inf)
i <- findInterval(P20, cut_points)
P20_fac <- P20labs[i]
P20_fac[is.na(P20)] <- P20labs[length(P20labs)]
P20_fac <- factor(P20_fac, levels = P20labs)
where P3 has 5 categories, indicating the socioeconomic perception of a sample of Spanish population, and P20_fac has 5 other categories that indicate the age of the respondents.
My desired outcome would be to have 5 joint graphs, in which the socioeconomic situation (P3) is reflected according to the age of the respondents (P20_fac).
I have been stuck on thinking how I can possibly represent this graphically, and after many an hour spent, I have completely run out of ideas (though I think that it can somehow be done by means of facet_wrap() or facet_grid()).
Any help would be much appreciated!
Many thanks in advance!
EDIT
Regarding what is my question, I have already stated that "My desired outcome would be to have 5 (grouped together) graphs, in which the socioeconomic situation (P3) is represented based on the age of the respondents (P20_fac)."
If I knew how to answer it, I most surely would not be making this question on this forum.
UPDATE
The closest that I've got to the desired result is by running the following code:
plot(CIS$P3 ~ P20_fac, data = CIS)
However, it only gets me the graphical results for the first age interval ("16-29") and in vertical instead of horizontal form.
dput(CIS_data_5)
> dput(CIS_data_5)
structure(list(CIS.P20 = structure(c(48L, 33L, 28L, 36L, 32L,
24L, 27L, 50L, 55L, 34L, 48L, 22L, 37L, 24L, 35L, 35L, 19L, 57L,
32L, 45L, 13L, 23L, 24L, 5L, 8L, 34L, 2L, 52L, 66L, 43L, 54L,
24L, 27L, 40L, 40L, 64L, 29L, 12L, 52L, 7L, 26L, 40L, 59L, 19L,
24L, 44L, 19L, 62L, 26L, 16L, 40L, 31L, 14L, 15L, 29L, 24L, 41L,
33L, 41L, 3L, 39L, 4L, 44L, 39L, 1L, 28L, 40L, 8L, 49L, 59L,
50L, 8L, 8L, 9L, 41L, 35L, 35L, 65L, 40L, 38L, 29L, 24L, 54L,
40L, 21L, 29L, 3L, 27L, 45L, 50L, 27L, 50L, 60L, 50L, 41L, 56L,
57L, 33L, 45L, 31L, 58L, 3L, 16L, 43L, 25L, 40L, 32L, 17L, 58L,
46L, 15L, 40L, 22L, 28L, 11L, 38L, 50L, 22L, 25L, 47L, 17L, 32L,
36L, 49L, 40L, 23L, 17L, 34L, 8L, 37L, 67L, 37L, 52L, 60L, 5L,
55L, 45L, 40L, 36L, 46L, 50L, 13L, 73L, 31L, 33L, 47L, 58L, 37L,
55L, 16L, 38L, 32L, 15L, 45L, 33L, 9L, 47L, 10L, 9L, 33L, 41L,
31L, 31L, 21L, 28L, 26L, 68L, 15L, 63L, 38L, 59L, 30L, 47L, 21L,
36L, 50L, 40L, 30L, 14L, 54L, 16L, 60L, 8L, 44L, 49L, 68L, 33L,
24L, 58L, 27L, 34L, 33L, 47L, 50L, 52L, 15L, 21L, 16L, 47L, 59L,
37L, 34L, 11L, 37L, 50L, 9L, 41L, 51L, 31L, 35L, 26L, 5L, 24L,
51L, 6L, 27L, 52L, 68L, 8L, 39L, 33L, 51L, 41L, 53L, 39L, 60L,
43L, 10L, 51L, 26L, 41L, 51L, 54L, 35L, 33L, 35L, 39L, 28L, 48L,
5L, 31L, 50L, 8L, 45L, 50L, 41L, 53L, 54L, 32L, 43L, 65L, 22L,
32L, 24L, 35L, 40L, 34L, 41L, 19L, 48L, 46L, 35L, 24L, 12L, 35L,
19L, 8L, 30L, 58L, 55L, 16L, 37L, 17L, 1L, 35L, 40L, 50L, 50L,
53L, 50L, 42L, 37L, 29L, 54L, 4L, 29L, 47L, 51L, 58L, 10L, 29L,
36L, 16L, 9L, 54L, 36L, 19L, 49L, 59L, 39L, 6L, 35L, 25L, 52L,
3L, 47L, 52L, 51L, 26L, 65L, 23L, 35L, 45L, 55L, 45L, 9L, 19L,
32L, 49L, 47L, 45L, 7L, 31L, 24L, 7L, 21L, 45L, 52L, 57L, 37L,
56L, 39L, 26L, 46L, 35L, 35L, 4L, 20L, 21L, 45L, 23L, 20L, 41L,
23L, 33L, 33L, 32L, 60L, 43L, 27L, 56L, 38L, 44L, 35L, 14L, 58L,
50L, 29L, 25L, 15L, 10L, 57L, 61L, 46L, 43L, 23L, 29L, 57L, 24L,
32L, 36L, 33L, 34L, 31L, 60L, 4L, 42L, 43L, 41L, 51L, 29L, 10L,
29L, 48L, 29L, 37L, 62L, 17L, 37L, 45L, 17L, 47L, 53L, 10L, 35L,
8L, 25L, 32L, 51L, 46L, 39L, 46L, 48L, 4L, 35L, 34L, 37L, 3L,
6L, 74L, 13L, 60L, 36L, 1L, 33L, 13L, 23L, 42L, 60L, 39L, 66L,
49L, 50L, 57L, 41L, 16L, 23L, 28L, 6L, 45L, 53L, 21L, 26L, 40L,
21L, 34L, 37L, 6L, 50L, 48L, 28L, 62L, 50L, 48L, 28L, 14L, 31L,
44L, 17L, 26L, 46L, 17L, 11L, 55L, 24L, 33L, 30L, 52L, 22L, 40L,
43L, 29L, 36L, 60L, 5L, 45L, 33L, 44L, 35L, 32L, 19L, 51L, 19L,
29L, 24L, 35L, 28L, 42L, 6L, 42L, 63L, 19L, 11L, 56L, 48L, 8L,
12L, 30L, 12L, 48L, 56L, 20L, 54L, 32L, 64L, 42L, 44L, 28L, 26L,
42L, 48L, 33L, 46L, 46L, 23L, 28L, 64L, 25L, 19L, 26L, 3L, 31L,
49L, 40L, 65L, 28L, 20L, 47L, 24L, 71L, 13L, 34L, 48L, 27L, 43L,
1L, 28L, 56L, 24L, 25L, 29L, 43L, 54L, 55L, 29L, 38L, 56L, 27L,
72L, 47L, 25L, 34L, 23L, 15L, 37L, 18L, 55L, 49L, 39L, 32L, 54L,
14L, 34L, 14L, 21L, 3L, 56L, 24L, 32L, 38L, 50L, 68L, 44L, 12L,
30L, 29L, 58L, 31L, 51L, 33L, 38L, 48L, 27L, 55L, 62L, 12L, 29L,
71L, 38L, 61L, 48L, 45L, 55L, 23L, 58L, 37L, 55L, 5L, 51L, 20L,
10L, 30L, 60L, 39L, 40L, 21L, 44L, 16L, 25L, 15L, 47L, 18L, 53L,
48L, 54L, 36L, 62L, 33L, 15L, 16L, 59L, 15L, 37L, 33L, 61L, 17L,
17L, 57L, 54L, 22L, 56L, 42L, 22L, 27L, 15L, 27L, 64L, 31L, 40L,
68L, 25L, 54L, 55L, 34L, 50L, 39L, 23L, 67L, 38L, 44L, 52L, 20L,
21L, 18L, 45L, 50L, 15L, 48L, 24L, 25L, 10L, 32L, 67L, 28L, 41L,
61L, 58L, 36L, 63L, 27L, 65L, 64L, 30L, 51L, 25L, 42L, 34L, 49L,
44L, 38L, 47L, 33L, 46L, 62L, 46L, 45L, 46L, 12L, 27L, 21L, 22L,
17L, 12L, 49L, 55L, 39L, 37L, 37L, 59L, 35L, 18L, 11L, 48L, 32L,
4L, 25L, 42L, 42L, 52L, 36L, 74L, 51L, 35L, 66L, 36L, 60L, 31L,
44L, 58L, 10L, 22L, 53L, 49L, 51L, 38L, 42L, 41L, 25L, 50L, 49L,
39L, 51L, 35L, 60L, 30L, 51L, 54L, 50L, 51L, 54L, 13L, 34L, 34L,
54L, 26L, 26L, 43L, 20L, 30L, 35L, 43L, 33L, 4L, 46L, 36L, 35L,
2L, 36L, 41L, 45L, 16L, 33L, 59L, 64L, 19L, 15L, 29L, 6L, 57L,
50L, 59L, 52L, 24L, 49L, 9L, 44L, 39L, 56L, 31L, 50L, 50L, 29L,
11L, 69L, 29L, 40L, 50L, 15L, 55L, 31L, 58L, 13L, 36L, 18L, 21L,
46L, 27L, 58L, 75L, 28L, 22L, 61L, 2L, 46L, 27L, 23L, 48L, 54L,
34L, 44L, 50L, 40L, 18L, 27L, 28L, 40L, 35L, 50L, 39L, 34L, 51L,
28L, 39L, 30L, 65L, 5L, 12L, 27L, 48L, 38L, 54L, 41L, 37L, 31L,
41L, 35L, 1L, 59L, 65L, 49L, 60L, 1L, 46L, 7L, 55L, 42L, 18L,
11L, 32L, 31L, 50L, 52L, 50L, 43L, 45L, 36L, 35L, 10L, 24L, 53L,
19L, 43L, 40L, 38L, 28L, 27L, 46L, 55L, 29L, 37L, 53L, 53L, 55L,
39L, 38L, 46L, 25L, 11L, 17L, 42L, 31L, 33L, 17L, 8L, 15L, 39L,
39L, 47L, 25L, 46L, 37L, 37L, 40L, 62L, 42L, 25L, 21L, 30L, 18L,
54L, 8L, 20L, 32L, 38L, 41L, 16L, 19L, 75L, 19L, 38L, 63L, 23L,
49L, 22L, 32L, 35L, 62L, 38L, 36L, 31L, 31L, 23L, 24L, 52L, 25L,
27L, 36L, 39L, 11L, 16L, 45L, 61L, 8L, 38L, 50L, 18L, 52L, 4L,
53L, 24L, 13L, 34L, 39L, 47L, 59L, 22L, 39L, 9L, 29L, 20L, 73L,
55L, 71L, 34L, 55L, 52L, 35L, 50L, 58L, 37L, 3L, 20L, 3L, 57L,
51L, 29L, 10L, 30L, 46L, 7L, 47L, 64L, 58L, 60L, 47L, 39L, 43L,
46L, 62L, 59L, 38L, 34L, 32L, 28L, 59L, 39L, 25L, 15L, 56L, 37L,
12L, 48L, 51L, 43L, 59L, 19L, 10L, 50L, 42L, 19L, 39L, 58L, 24L,
49L, 27L, 9L, 15L, 16L, 39L, 11L, 49L, 29L, 30L, 30L, 47L, 57L,
59L, 49L, 20L, 51L, 43L, 46L, 19L, 51L, 47L, 47L, 25L, 5L, 52L,
40L, 21L, 36L, 6L, 64L, 35L, 29L, 40L, 63L, 26L, 39L, 39L, 39L,
51L, 43L, 27L, 41L, 19L, 49L, 52L, 61L, 50L, 37L, 42L, 50L, 47L,
41L, 32L, 26L, 23L, 37L, 52L, 27L, 60L, 29L, 22L, 37L, 38L, 15L,
37L, 24L, 21L, 50L, 60L, 36L, 39L, 48L, 59L, 46L, 73L, 35L, 31L,
34L, 25L, 75L, 41L, 20L, 36L, 55L, 10L, 39L, 44L, 62L, 40L, 14L,
29L, 49L, 45L, 59L, 54L, 52L, 41L, 40L, 35L, 36L, 32L, 2L, 51L,
24L, 49L, 22L, 49L, 57L, 28L, 12L, 35L, 5L, 31L, 7L, 6L, 51L,
33L, 24L, 6L, 51L, 25L, 10L, 52L, 54L, 75L, 12L, 55L, 42L, 17L,
15L, 39L, 52L, 29L, 6L, 11L, 59L, 40L, 36L, 17L, 14L, 27L, 14L,
56L, 33L, 59L, 55L, 31L, 31L, 27L, 29L, 39L, 7L, 20L, 50L, 8L,
2L, 31L, 59L, 39L, 71L, 24L, 32L, 8L, 60L, 24L, 21L, 37L, 17L,
24L, 42L, 33L, 25L, 32L, 12L, 38L, 46L, 31L, 40L, 37L, 12L, 19L,
21L, 44L, 20L, 30L, 38L, 45L, 2L, 30L, 60L, 15L, 23L, 34L, 6L,
35L, 23L, 25L, 31L, 18L, 42L, 59L, 40L, 42L, 16L, 46L, 71L, 21L,
36L, 18L, 37L, 38L, 31L, 65L, 34L, 55L, 59L, 34L, 66L, 29L, 31L,
7L, 8L, 58L, 14L, 23L, 65L, 29L, 16L, 52L, 35L, 7L, 20L, 14L,
15L, 46L, 9L, 61L, 45L, 26L, 27L, 59L, 26L, 38L, 29L, 14L, 32L,
47L, 36L, 40L, 57L, 39L, 31L, 25L, 34L, 46L, 39L, 59L, 11L, 26L,
21L, 9L, 13L, 47L, 37L, 43L, 45L, 19L, 52L, 42L, 53L, 26L, 49L,
37L, 33L, 50L, 28L, 25L, 35L, 6L, 55L, 25L, 11L, 16L, 53L, 32L,
20L, 20L, 41L, 55L, 22L, 12L, 50L, 13L, 71L, 22L, 5L, 56L, 33L,
44L, 57L, 52L, 53L, 44L, 18L, 32L, 60L, 59L, 24L, 48L, 29L, 45L,
16L, 53L, 55L, 13L, 41L, 6L, 72L, 30L, 22L, 31L, 32L, 8L, 41L,
34L, 4L, 1L, 34L, 9L, 20L, 33L, 67L, 9L, 48L, 72L, 31L, 40L,
38L, 56L, 50L, 45L, 63L, 18L, 31L, 11L, 35L, 51L, 55L, 57L, 21L,
48L, 50L, 28L, 55L, 39L, 33L, 2L, 35L, 6L, 30L, 25L, 18L, 17L,
30L, 40L, 38L, 31L, 46L, 69L, 36L, 14L, 35L, 42L, 32L, 66L, 55L,
25L, 13L, 76L, 54L, 57L, 24L, 17L, 24L, 35L, 32L, 27L, 56L, 5L,
54L, 30L, 53L, 62L, 41L, 38L, 30L, 2L, 69L, 35L, 46L, 44L, 36L,
33L, 30L, 57L, 61L, 42L, 63L, 30L, 44L, 34L, 17L, 53L, 53L, 15L,
46L, 58L, 43L, 21L, 36L, 27L, 21L, 32L, 28L, 10L, 15L, 8L, 53L,
63L, 43L, 10L, 64L, 41L, 58L, 7L, 36L, 26L, 19L, 26L, 52L, 14L,
36L, 4L, 49L, 20L, 42L, 35L, 9L, 23L, 57L, 5L, 43L, 40L, 31L,
26L, 49L, 31L, 41L, 3L, 13L, 45L, 29L, 42L, 41L, 57L, 67L, 37L,
50L, 25L, 47L, 25L, 52L, 60L, 38L, 49L, 40L, 43L, 45L, 45L, 42L,
50L, 63L, 10L, 42L, 31L, 26L, 26L, 60L, 54L, 9L, 3L, 57L, 63L,
44L, 45L, 31L, 61L, 48L, 3L, 55L, 41L, 40L, 32L, 22L, 23L, 37L,
39L, 30L, 6L, 25L, 2L, 41L, 3L, 15L, 35L, 50L, 48L, 17L, 30L,
55L, 40L, 24L, 39L, 47L, 49L, 48L, 16L, 14L, 5L, 31L, 29L, 32L,
60L, 34L, 55L, 58L, 51L, 30L, 48L, 47L, 52L, 30L, 35L, 65L, 7L,
54L, 9L, 23L, 59L, 25L, 19L, 47L, 38L, 56L, 73L, 70L, 47L, 64L,
43L, 30L, 40L, 45L, 3L, 40L, 35L, 50L, 10L, 35L, 49L, 33L, 28L,
8L, 6L, 60L, 37L, 46L, 65L, 48L, 47L, 27L, 23L, 13L, 39L, 40L,
44L, 55L, 35L, 21L, 21L, 51L, 33L, 49L, 11L, 25L, 25L, 44L, 6L,
25L, 30L, 22L, 45L, 31L, 23L, 56L, 37L, 47L, 20L, 25L, 48L, 23L,
58L, 47L, 46L, 45L, 31L, 28L, 13L, 68L, 18L, 42L, 22L, 33L, 33L,
11L, 47L, 50L, 21L, 2L, 22L, 48L, 38L, 39L, 32L, 29L, 52L, 10L,
35L, 45L, 43L, 2L, 41L, 23L, 3L, 41L, 29L, 39L, 44L, 11L, 44L,
68L, 36L, 27L, 27L, 54L, 44L, 39L, 58L, 24L, 19L, 57L, 22L, 16L,
64L, 25L, 3L, 60L, 51L, 46L, 50L, 32L, 6L, 52L, 43L, 59L, 36L,
36L, 7L, 14L, 49L, 22L, 69L, 40L, 51L, 56L, 44L, 10L, 30L, 46L,
53L, 30L, 17L, 32L, 37L, 36L, 9L, 41L, 2L, 34L, 57L, 27L, 25L,
25L, 55L, 48L, 40L, 36L, 25L, 36L, 7L, 41L, 44L, 22L, 55L, 38L,
31L, 49L, 62L, 15L, 48L, 13L, 23L, 20L, 48L, 21L, 50L, 33L, 23L,
67L, 30L, 39L, 34L, 41L, 32L, 43L, 43L, 26L, 24L, 27L, 10L, 20L,
77L, 22L, 56L, 54L, 67L, 52L, 14L, 38L, 24L, 50L, 33L, 39L, 40L,
67L, 33L, 44L, 51L, 72L, 39L, 47L, 9L, 43L, 54L, 5L, 35L, 52L,
16L, 37L, 45L, 22L, 27L, 35L, 61L, 51L, 2L, 59L, 49L, 45L, 22L,
44L, 31L, 49L, 35L, 22L, 35L, 35L, 44L, 48L, 38L, 39L, 41L, 59L,
27L, 47L, 25L, 28L, 8L, 40L, 37L, 50L, 75L, 16L, 39L, 42L, 52L,
31L, 36L, 43L, 19L, 66L, 21L, 22L, 64L, 38L, 26L, 43L, 64L, 56L,
1L, 3L, 27L, 28L, 10L, 33L, 35L, 38L, 30L, 38L, 39L, 57L, 24L,
55L, 23L, 42L, 35L, 5L, 53L, 71L, 40L, 12L, 37L, 37L, 8L, 7L,
24L, 37L, 31L, 59L, 44L, 50L, 50L, 63L, 42L, 24L, 61L, 2L, 56L,
36L, 48L, 41L, 27L, 10L, 16L, 71L, 33L, 24L, 40L, 16L, 45L, 64L,
45L, 59L, 12L, 26L, 42L, 54L, 52L, 37L, 53L, 43L, 47L, 8L, 51L,
43L, 59L, 14L, 44L, 48L, 3L, 51L, 27L, 3L, 48L, 57L, 31L, 23L,
17L, 52L, 11L, 62L, 39L, 40L, 57L, 43L, 53L, 38L, 31L, 14L, 53L,
43L, 39L, 20L, 56L, 31L, 11L, 37L, 31L, 49L, 36L, 35L, 50L, 19L,
47L, 28L, 53L, 30L, 17L, 27L, 35L, 48L, 34L, 32L, 36L, 23L, 17L,
14L, 24L, 56L, 28L, 58L, 40L, 48L, 32L, 28L, 32L, 21L, 24L, 43L,
44L, 67L, 18L, 63L, 30L, 31L, 29L, 57L, 44L, 35L, 40L, 30L, 32L,
16L, 45L, 27L, 36L, 28L, 23L, 38L, 35L, 30L, 43L, 59L, 57L, 50L,
23L, 16L, 64L, 44L, 50L, 43L, 40L, 21L, 41L, 59L, 22L, 32L, 15L,
22L, 49L, 60L, 29L, 44L, 58L, 40L, 24L, 23L, 34L, 25L, 41L, 14L,
16L, 32L, 37L, 51L, 45L, 54L, 40L, 43L, 24L, 56L, 67L, 47L, 48L,
41L, 47L, 26L, 25L, 25L, 57L, 66L, 47L, 4L, 32L, 48L, 26L, 2L,
24L, 40L, 43L, 30L, 34L, 30L, 29L, 53L, 22L, 19L, 31L, 58L, 3L,
18L, 30L, 31L, 35L, 64L, 59L, 17L, 4L, 42L, 32L, 75L, 31L, 13L,
59L, 12L, 31L, 49L, 34L, 13L, 30L, 1L, 16L, 34L, 35L, 17L, 19L,
50L, 52L, 25L, 33L, 50L, 10L, 23L, 22L, 47L, 43L, 54L, 5L, 41L,
28L, 13L, 46L, 44L, 9L, 24L, 22L, 33L, 58L, 17L, 59L, 29L, 44L,
34L, 10L, 30L, 24L, 15L, 40L, 42L, 5L, 39L, 34L, 28L, 6L, 40L,
44L, 25L, 50L, 57L, 40L, 53L, 37L, 41L, 48L, 48L, 23L, 55L, 20L,
8L, 41L, 46L, 27L, 39L, 51L, 20L, 36L, 45L, 33L, 71L, 3L, 15L,
49L, 21L, 34L, 5L, 42L, 2L, 40L, 35L, 13L, 13L, 2L, 42L, 17L,
7L, 53L, 30L, 27L, 11L, 37L, 49L, 23L, 45L, 32L, 30L, 16L, 21L,
32L, 20L, 40L, 29L, 3L, 46L, 34L, 56L, 46L, 21L, 46L, 25L, 14L,
15L, 15L, 53L, 31L, 27L, 34L, 67L, 29L, 62L, 37L, 51L, 36L, 32L,
10L, 50L, 44L, 43L, 40L, 34L, 26L, 62L, 24L, 63L, 50L, 13L, 42L,
43L, 49L, 29L, 30L, 9L, 40L, 11L, 61L, 67L, 37L, 20L, 49L, 66L,
49L, 34L, 25L, 30L, 58L, 45L, 15L, 18L, 32L, 29L, 17L, 18L, 43L,
72L, 54L, 40L, 29L, 18L, 39L, 35L, 16L, 37L, 18L, 1L, 43L, 22L,
38L, 57L, 23L, 25L, 26L, 46L, 25L, 15L, 36L, 26L, 32L, 15L, 57L,
33L, 25L, 63L, 35L, 44L, 25L, 13L, 26L, 56L, 30L, 39L, 35L, 39L,
20L, 47L, 44L, 22L, 45L, 23L, 7L, 30L, 47L, 7L, 54L, 47L, 5L,
52L, 21L, 72L, 23L, 41L, 43L, 30L, 28L, 32L, 43L, 35L, 66L, 70L,
37L, 44L, 33L, 11L, 51L, 26L, 48L, 41L, 10L, 50L, 31L, 39L, 41L,
43L, 20L, 27L, 29L, 17L, 47L, 25L, 48L, 15L, 49L, 50L, 34L, 16L,
26L, 32L, 27L, 71L, 41L, 30L, 34L, 36L, 47L, 32L, 17L, 19L, 33L,
26L, 17L, 25L, 22L, 35L, 42L, 25L, 37L, 6L, 46L, 3L, 53L, 39L,
29L, 10L, 41L, 45L, 10L, 31L, 43L, 35L, 43L, 30L, 6L, 12L, 28L,
18L, 40L, 35L, 37L, 23L, 29L, 8L, 32L, 55L, 53L, 12L, 16L, 35L,
23L, 27L, 51L, 32L, 36L, 9L, 43L, 26L, 28L, 36L, 46L, 56L, 21L,
21L, 19L, 16L, 21L, 16L, 8L, 12L, 44L, 4L, 21L, 26L, 66L, 64L,
9L, 38L, 34L, 50L, 20L, 36L, 37L, 31L, 55L, 37L, 60L, 20L, 61L,
28L, 65L, 44L, 33L, 50L, 53L, 34L, 43L, 27L, 17L, 30L, 55L, 20L,
43L, 46L, 50L, 44L, 27L, 44L, 43L, 23L, 26L, 52L, 23L, 52L, 27L,
40L, 17L, 50L, 8L, 21L, 36L, 68L, 19L, 26L, 45L, 47L, 30L, 27L,
42L, 22L, 38L, 36L, 16L, 15L, 27L, 47L, 26L, 51L, 17L, 54L, 60L,
38L, 23L, 19L, 30L, 44L, 42L, 7L, 33L, 56L, 14L, 45L, 54L, 47L,
64L, 64L, 18L, 55L, 67L, 36L, 51L, 30L, 12L, 59L, 33L, 12L, 33L,
17L, 13L, 44L, 24L, 46L, 41L, 25L, 41L, 33L, 27L, 1L, 14L, 29L,
29L, 29L, 8L, 48L, 22L, 39L, 59L, 36L, 34L, 37L, 13L, 38L, 32L,
22L, 3L, 30L, 21L, 51L, 38L, 4L, 8L, 50L, 38L, 30L, 31L, 22L,
37L, 62L, 46L, 45L, 26L, 13L, 51L, 54L, 38L, 13L, 22L, 25L, 28L,
22L, 33L, 24L, 22L, 52L, 26L, 11L, 46L, 18L, 27L, 32L, 56L, 2L,
36L, 13L, 71L, 56L, 43L, 37L, 5L, 63L, 34L, 51L, 34L, 38L, 29L,
35L, 44L, 68L, 18L, 30L, 41L, 50L, 58L, 48L, 43L, 16L, 33L, 43L,
46L, 61L, 29L, 46L, 73L, 8L, 21L, 19L, 12L, 35L, 25L, 21L, 34L,
44L, 52L, 3L, 36L, 5L, 51L, 9L, 50L, 60L, 24L, 3L, 31L, 13L,
36L, 42L, 67L, 44L, 18L, 8L, 20L, 60L, 38L, 69L, 65L, 23L, 44L,
52L, 45L, 29L, 51L, 22L, 23L, 27L, 58L, 61L, 32L, 33L, 58L, 31L,
30L, 50L, 64L, 24L, 4L, 45L, 43L, 46L, 53L, 35L, 51L, 51L, 45L,
37L, 30L, 2L, 58L, 41L, 35L, 30L, 35L, 40L, 33L, 60L, 60L, 55L,
37L, 27L, 10L, 21L, 27L, 17L, 33L, 46L, 28L, 36L, 53L, 34L, 26L,
36L, 59L, 9L, 30L, 55L, 45L, 57L, 17L, 19L, 2L, 31L, 41L, 26L,
29L, 16L, 47L, 52L, 44L, 29L, 61L, 25L, 55L, 8L, 5L, 56L, 45L,
51L, 25L, 11L, 26L, 35L, 33L, 41L, 71L, 35L, 63L, 38L, 32L, 53L,
31L, 52L, 44L, 34L, 50L, 40L, 21L, 36L, 76L, 40L, 23L, 42L, 25L,
14L, 58L, 38L, 37L, 69L, 46L, 46L, 49L, 42L, 28L, 55L, 13L, 45L,
12L, 42L, 32L, 11L, 32L, 36L, 61L, 19L, 28L, 31L, 35L, 22L, 15L,
50L, 64L, 32L, 59L, 33L, 24L, 19L, 49L, 36L, 26L, 57L, 57L, 34L,
29L, 7L, 30L, 42L, 47L, 53L, 55L, 55L, 35L, 26L, 20L, 55L, 61L,
43L, 31L, 30L, 52L, 27L, 63L, 25L, 47L, 63L, 23L, 2L, 47L, 12L,
37L, 34L, 46L, 30L, 62L, 52L, 27L, 3L, 59L, 50L, 5L, 34L, 23L
), levels = c("16", "17", "18", "19", "20", "21", "22", "23",
"24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34",
"35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45",
"46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56",
"57", "58", "59", "60", "61", "62", "63", "64", "65", "66", "67",
"68", "69", "70", "71", "72", "73", "74", "75", "76", "77", "78",
"79", "80", "81", "82", "83", "84", "85", "86", "87", "88", "89",
"90", "91", "93", "N.C. "), class = "factor"), CIS.P3 = structure(c(3L,
3L, 3L, 3L, 3L, 2L, 1L, 3L, 2L, 3L, 3L, 3L, 3L, 1L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 1L, 2L, 3L, 3L, 3L, 3L, 2L, 2L, 2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L, 2L, 3L,
3L, 3L, 3L, 3L, 1L, 3L, 3L, 3L, 2L, 3L, 2L, 2L, 2L, 3L, 2L, 3L,
3L, 3L, 2L, 3L, 2L, 2L, 3L, 3L, 2L, 2L, 2L, 3L, 2L, 3L, 3L, 2L,
1L, 3L, 3L, 2L, 3L, 3L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 1L, 3L, 3L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L,
3L, 3L, 3L, 3L, 2L, 3L, 3L, 1L, 1L, 2L, 2L, 3L, 2L, 2L, 1L, 2L,
2L, 3L, 3L, 2L, 2L, 3L, 3L, 2L, 3L, 1L, 2L, 3L, 3L, 3L, 3L, 1L,
2L, 2L, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 2L, 3L, 3L, 2L, 4L, 3L, 3L,
2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 3L, 3L, 1L, 3L,
3L, 3L, 2L, 2L, 1L, 2L, 2L, 3L, 1L, 3L, 2L, 2L, 3L, 1L, 3L, 2L,
2L, 3L, 3L, 3L, 1L, 2L, 2L, 1L, 2L, 2L, 1L, 3L, 1L, 3L, 2L, 3L,
3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 2L, 1L, 3L, 1L, 2L, 2L, 2L, 2L,
2L, 1L, 2L, 3L, 2L, 3L, 2L, 3L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 1L,
1L, 1L), levels = c("Mejor", "(NO LEER) Igual", "Peor", "N.S.",
"N.C."), class = "factor")), class = "data.frame", row.names = c(NA,
-2787L))
Maybe you want something like this using facet_wrap:
set.seed(123)
CIS_data_5 <- data.frame(
CIS$CIS.P20,
CIS$CIS.P3
)
CIS$P3 <- factor(CIS$CIS.P3, labels = c("Mejor", "(NO LEER) Igual", "Peor", "N.S.", "N.C."))
n <- as.numeric(c(CIS$CIS.P20))
P20 <- sample(n, 2787, replace = TRUE, prob = NULL)
P20labs <- c("16-29", "30-44", "45-64", ">65", "N.C.")
cut_points <- c(16, 30, 45, 65, Inf)
i <- findInterval(P20, cut_points)
P20_fac <- P20labs[i]
P20_fac[is.na(P20)] <- P20labs[length(P20labs)]
P20_fac <- factor(P20_fac, levels = P20labs)
library(dplyr)
library(ggplot2)
data.frame(P3 = CIS$P3,
P20_fac = P20_fac) %>%
ggplot(aes(x = P20_fac)) +
geom_bar() +
coord_flip() +
facet_wrap(~P3)
Created on 2022-09-25 with reprex v2.0.2
I have a time series data set and each time series has datapoint of 30-year from different/same species. I am developing a forecasting model using the first 23 years of data from each time series data point and I am using the rest 7 years as test set to know the predictive ability of model but the nonlinear model (Model 6 and Model 7) don't give succinct result?
Data:
DD <- structure(list(Plot = structure(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, 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, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L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L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L), .Label = c("BD", "BG"), class = "factor"), Year = c(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, 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, 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, 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, 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, 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, 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), Count = c(81L, 45L, 96L, 44L, 24L, 8L, 28L, 32L, 39L, 29L,
40L, 17L, 4L, 12L, 18L, 11L, 63L, 98L, 78L, 76L, 67L, 36L, 56L,
43L, 81L, 8L, 14L, 20L, 25L, 19L, 135L, 91L, 171L, 88L, 59L,
1L, 1L, 1L, 2L, 1L, 11L, 9L, 34L, 15L, 32L, 21L, 33L, 43L, 39L,
20L, 6L, 3L, 9L, 9L, 28L, 16L, 15L, 2L, 1L, 1L, 34L, 16L, 19L,
35L, 32L, 7L, 2L, 30L, 29L, 25L, 28L, 11L, 31L, 31L, 28L, 27L,
34L, 110L, 87L, 103L, 72L, 19L, 46L, 43L, 107L, 32L, 26L, 31L,
12L, 29L, 23L, 40L, 50L, 23L, 34L, 11L, 9L, 4L, 24L, 55L, 14L,
16L, 51L, 43L, 2L, 13L, 8L, 96L, 52L, 118L, 32L, 1L, 8L, 17L,
34L, 29L, 38L, 15L, 4L, 38L, 2L, 1L, 1L, 1L, 1L, 1L, 3L, 3L,
4L, 6L, 4L, 4L, 10L, 6L, 7L, 9L, 15L, 30L, 25L, 36L, 13L, 17L,
43L, 36L, 60L, 50L, 26L, 13L, 13L, 27L, 18L, 56L, 96L, 16L, 54L,
2L, 2L, 9L, 5L, 5L, 6L, 2L, 6L, 2L, 3L, 4L, 3L, 136L, 71L, 116L,
28L, 23L, 76L, 64L, 98L, 58L, 26L, 13L, 13L, 13L, 18L, 19L, 24L,
18L, 17L, 3L, 23L, 19L, 9L, 11L, 13L, 20L, 29L, 29L, 17L, 20L,
26L, 71L, 63L, 53L, 54L, 20L, 22L, 18L, 93L, 50L, 18L, 12L, 12L,
31L), LogCount = c(1.908385019, 1.653212514, 1.982271233, 1.643462676,
1.380211242, 0.903089987, 1.447158031, 1.505109978, 1.591064607,
1.462397998, 1.602059991, 1.230448921, 0.602059991, 1.079181206,
1.255272505, 1.041392685, 1.799340549, 1.991226076, 1.892094603,
1.880813592, 1.826074803, 1.556302501, 1.748188027, 1.633468456,
1.908485019, 0.903089987, 1.146128035, 1.301029996, 1.397940009,
1.278753601, 2.130333768, 1.95904139, 2.2329961, 1.94448267,
1.770852012, 0, 0, 0, 0.30102999, 0, 1.0411392685, 0.954242509,
1.531478917, 1.176031259, 1.505149978, 1.322219295, 1.51851394,
1.6334684456, 1.591064607, 1.301029996, 0.77815125, 0.477121255,
0.954242509, 0.954242509, 1.447158031, 1.204119983, 1.176091259,
0.301029996, 0, 0, 1.531478917, 1.204119983, 1.278753501, 1.544068044,
1.505149978, 0.084509804, 0.301029996, 1.477121255, 1.462397998,
1.397940009, 1.447158031, 1.041392685, 1.491361694, 1.491361694,
1.447158031, 1.431363754, 1.531478917, 2.041392685, 1.939519253,
2.012837225, 1.857332495, 1.278753601, 1.662757382, 1.633468456,
2.029383778, 1.505149978, 1.414973348, 1.491361594, 1.079181245,
1.462397998, 1.361727835, 1.602059991, 1.698970004, 1.361727836,
1.531478917, 1.041392685, 0.954242509, 0.602059991, 1.380211242,
1.740362689, 1.146128036, 1.204119983, 1.707570176, 1.633468456,
0.301029996, 1.113943352, 0.903089987, 1.982271233, 1.716003344,
2.071882007, 1.50514997, 0, 0.903089987, 1.230448921, 1.53147891,
1.2397998, 1.57978359, 1.176091259, 0.602059991, 1.57978359,
0.301029996, 0, 0, 0, 0, 0, 0.477121255, 0.477121255, 0.602059991,
0.77815125, 0.602059991, 0.602059991, 1, 0.77815125, 0.84509804,
0.95424509, 1.176091259, 1.477121255, 1.39790009, 1.555302501,
1.113943352, 1.230448921, 1.633468456, 1.555302501, 1.77815125,
1.698970004, 1.414973348, 1.113943352, 1.113943352, 1.431353754,
1.255272505, 1.748188027, 1.982271233, 1.204119983, 1.73239376,
1.431363754, 1.361727835, 0.954242509, 0.698970004, 0.698970004,
0.77815125, 0.301029996, 0.77815125, 0.301029996, 0.477121255,
0.602059991, 0.477121255, 2.133538908, 1.851258349, 2.064457989,
1.447158031, 1.361727836, 1.880813592, 1.806179974, 1.991226076,
1.763427994, 1.414973348, 1.113943352, 1.113943352, 1.113943352,
1.255272505, 1.278753601, 1.380211242, 1.255272505, 1.230446921,
0.477121255, 1.361727835, 1.278753601, 0.954242509, 1.0411392685,
1.113943352, 1.301029996, 1.462397998, 1.462397998, 1.230448921,
1.301029995, 1.414973348, 1.851258349, 1.799340549, 1.72427587,
1.73239376, 1.301029996, 1.342422681, 1.255272505, 1.968482949,
1.698970004, 1.255272505, 1.079181246, 1.079181246, 1.491361694
), Diff = c(-0.255272505, 0.329058719, -0.338818557, -0.263241434,
-0.077121255, 0.544068044, 0.057991947, 0.085910629, -0.128666609,
0.139661993, -0.37161107, -0.62838893, 0.477121255, 0.176091259,
-0.21387982, 0.757947864, 0.191885527, -0.099131473, -0.011281011,
-0.054738789, -0.269772302, 0.191885526, -0.114719571, 0.275016563,
-1.005395032, 0.243038049, 0.15490196, 0.096910013, -0.119186408,
NA, -0.171292376, 0.273954718, -0.288513438, -0.17363066, -1.770852012,
0, 0, 0.301029996, -0.301029996, 1.041392685, -0.087150176, 0.577235408,
-0.355387658, 0.329058719, -0.182930683, 0.196294545, 0.110954516,
-0.042403849, -0.290034611, -0.522878746, -0.301029995, 0.477121254,
0, 0.492915522, -0.243038048, -0.028028724, -0.875061263, -0.301029996,
0, 1.531078917, -0.32735893, 0.070633618, 0.265310043, -0.038918066,
-0.660051938, -0.544068044, 1.176091259, -0.014723257, -0.064457989,
0.049218022, -0.405765346, 0.449969009, 0, -0.044203663, -0.015794267,
0.100115153, 0.509913768, -0.101873432, 0.073317972, -0.155504729,
-0.578578895, 0.384054231, -0.029289376, 0.395915322, -0.5202338,
-0.09017663, 0.076388346, -0.412180448, 0.383216752, -0.100670162,
0.240332155, 0.096910013, -0.337242168, 0.169751081, -0.490086232,
-0.087150176, -0.352182518, 0.778151251, 0.360151447, -0.594234653,
0.057991947, 0.503450193, -0.07410172, -1.33243846, 0.812913356,
-0.210853365, 1.079181246, -0.266267889, 0.355878663, -0.566732029,
-1.505149978, 0.903089987, 0.327358934, 0.301029996, -0.069080919,
0.117385599, -0.403692338, -0.574031268, 0.977723606, -1.278753601,
-0.301029996, 0, 0, 0, 0, 0.477121255, 0, 0.124938736, 0.176091259,
-0.176091259, 0, 0.397490009, -0.2218485, 0.06690679, 0.10914469,
0.22184875, 0.301029996, -0.079181206, 0.158362092, -0.442359149,
0.116505569, 0.403019535, -0.077165955, 0.221848749, -0.079181206,
-0.283996656, -0.301029996, 0, 0.317420412, -0.176091259, 0.492915522,
0.23483206, -0.77815125, 0.528273777, -0.301029996, -0.069635928,
-0.407485327, -0.255272505, 0, 0.079181246, -0.477121254, 0.477121254,
-0.477121254, 0.176091259, 0.124938736, -0.124938736, 1.656417653,
-0.282280559, 0.21319964, -0.617299958, -0.085430195, 0.5191085756,
-0.074533518, 0.185045102, -0.227798082, -0.348454546, -0.301029996,
0, 0, 0.141329153, 0.023481096, 0.101457641, -0.124938737, -0.024823584,
-0.753327666, 0.884606581, -0.082974235, -0.324511092, 0.087150176,
0.072550667, 0.187086644, 0.161368002, 0, -0.231949077, 0.070581075,
0.113903352, 0.436285001, -0.00519178, -0.075054679, 0.00811789,
-0.431363764, 0.041392685, -0.087150176, 0.713210444, -0.269512945,
-0.443697499, -0.176091259, 0, 0.412180448, -0.148939013)), class = "data.frame", row.names = c(NA,
-210L))
Code:
for(f in 1:11){
for(b in 1:5){
for (c in 1:5){
#To select test sets 1,2,3,4, and 5 years beyond the training set:
#Calculate the mean of abundance for the training set years.
Model1<-lm(mean~1, data=DD1)
#
Output2:
2 3 0.676209994477288 1.9365051784348e-09 4.44089209850063e-16
3 53 11.9236453578109 2.06371097988267e-09 1.13686837721616e-13
4 31 1.94583877614293 1.11022302462516e-15 1.99840144432528e-15
5 4 8.06660449042397 1.48071350736245e-08 3.19744231092045e-14
6 5 10.5321102149558 9.31706267692789e-10 1.4210854715202e-14
..
First, please see the time series graph of counts for different species and plots below.
library(ggplot2)
ggplot(DD, aes(Year, Count)) +
geom_point() +
geom_line() +
facet_grid(Plot ~ Species) +
scale_y_log10()
It is seen that there is no obvious trend which can be fitted by power or log-power function using nls.
Second, as I understand you are trying to use nls to predict outside the training data set. Usually it is not quite an effective to use least square models because of auto-correlated nature of time-series.
Third, the simplest prediction algorithm is Holt-Winters (see "dirty" implementation below). You can use as well a ton of other algorithms like ARIMA, exponential smoothing state space etc.
x <- ts(DD[DD$Species == "BG" & DD$Plot == "elq1a3", ]$LogCount)
m <- HoltWinters(x, gamma = FALSE)
library(forecast)
f <- forecast(m, 2)
plot(f, main = "elq1a3 at BG")
Fourth, about your algorithm in question, it throws
Error in qr.solve(QR.B, cc) : singular matrix 'a' in solve.
The reason is that in the first step of for-loop (at f = b = c = 1 DD2 data frame contains just one row. And executing
Model6<-nls(Diff~1+Count^T,start=list(T=1),trace=TRUE,algorithm ="plinear",data=DD2)
means that you are trying to fit a curve using only one data point, which is impossible.
However if you change f value in for-loop from 1:11 to 2:11 another error thrown:
Error in nls(Diff ~ 1 + Count^T, start = list(T = 1), trace = TRUE,
algorithm = "plinear", : step factor 0.000488281 reduced below
minFactor 0.000976562.
In this case you cannot use "naive" approach used by plinear algorithm with self-starting inital value and, e.g. nls.control(min.factor = 1e-5). You must feed all initial coefficients explicitely with default Gauss-Newton algorithm. Quite exausting, please try yourself :)
I have a dataframe of results. There are multiple comparisons for Cruise_Strata. I have two columns of cruise_strata (Cruise1_Strata1 and Cruise2_Strata2). The problem I found is that there are "duplicate" records in the dataframe. For example one row will have
Cruise_Strata1 Cruise_Strata2
201501.35 201502.35
and another row will have
Cruise_Strata1 Cruise_Strata2
201502.35 201501.35
The rows have the same results for the remaining columns. I would like to be able to identify rows where this happens and remove one row from the dataset, but do not know how to go about it. I cant use duplicate because they are not duplicates.
Any help would be appreciated.
Here is the dataframe.
dput(result5)
structure(list(Cruise_Strata1 = structure(c(1L, 1L, 2L, 2L, 3L,
3L, 4L, 4L, 5L, 5L, 6L, 6L, 7L, 7L, 8L, 8L, 9L, 9L, 10L, 10L,
11L, 11L, 12L, 12L, 13L, 13L, 14L, 14L, 15L, 15L, 16L, 16L, 17L,
17L, 18L, 18L, 19L, 19L, 20L, 20L, 21L, 21L, 22L, 22L, 23L, 23L,
24L, 24L, 25L, 25L, 26L, 26L, 27L, 27L, 28L, 28L, 29L, 29L, 30L,
30L, 31L, 31L, 32L, 32L, 33L, 33L, 34L, 34L, 35L, 35L, 36L, 36L,
37L, 37L, 38L, 38L, 39L, 39L, 40L, 40L, 41L, 41L, 42L, 42L, 43L,
43L, 44L, 44L, 45L, 45L, 46L, 46L, 47L, 47L, 48L, 48L, 49L, 49L,
50L, 50L, 51L, 51L, 52L, 52L, 53L, 53L, 54L, 54L, 55L, 55L, 56L,
56L, 57L, 57L, 58L, 58L, 59L, 59L, 60L, 60L, 61L, 61L, 62L, 62L,
63L, 63L, 64L, 64L, 65L, 65L, 66L, 66L), .Label = c("201501.10",
"201501.11", "201501.13", "201501.14", "201501.15", "201501.17",
"201501.18", "201501.19", "201501.21", "201501.22", "201501.23",
"201501.24", "201501.25", "201501.26", "201501.27", "201501.29",
"201501.30", "201501.31", "201501.33", "201501.34", "201501.35",
"201501.9", "201502.10", "201502.11", "201502.13", "201502.14",
"201502.15", "201502.17", "201502.18", "201502.19", "201502.21",
"201502.22", "201502.23", "201502.24", "201502.25", "201502.26",
"201502.27", "201502.29", "201502.30", "201502.31", "201502.33",
"201502.34", "201502.35", "201502.9", "201503.10", "201503.11",
"201503.13", "201503.14", "201503.15", "201503.17", "201503.18",
"201503.19", "201503.21", "201503.22", "201503.23", "201503.24",
"201503.25", "201503.26", "201503.27", "201503.29", "201503.30",
"201503.31", "201503.33", "201503.34", "201503.35", "201503.9"
), class = "factor"), Cruise_Strata2 = structure(c(23L, 45L,
24L, 46L, 25L, 47L, 26L, 48L, 27L, 49L, 28L, 50L, 29L, 51L, 30L,
52L, 31L, 53L, 32L, 54L, 33L, 55L, 34L, 56L, 35L, 57L, 36L, 58L,
37L, 59L, 38L, 60L, 39L, 61L, 40L, 62L, 41L, 63L, 42L, 64L, 43L,
65L, 44L, 66L, 1L, 45L, 2L, 46L, 3L, 47L, 4L, 48L, 5L, 49L, 6L,
50L, 7L, 51L, 8L, 52L, 9L, 53L, 10L, 54L, 11L, 55L, 12L, 56L,
13L, 57L, 14L, 58L, 15L, 59L, 16L, 60L, 17L, 61L, 18L, 62L, 19L,
63L, 20L, 64L, 21L, 65L, 22L, 66L, 1L, 23L, 2L, 24L, 3L, 25L,
4L, 26L, 5L, 27L, 6L, 28L, 7L, 29L, 8L, 30L, 9L, 31L, 10L, 32L,
11L, 33L, 12L, 34L, 13L, 35L, 14L, 36L, 15L, 37L, 16L, 38L, 17L,
39L, 18L, 40L, 19L, 41L, 20L, 42L, 21L, 43L, 22L, 44L), .Label = c("201501.10",
"201501.11", "201501.13", "201501.14", "201501.15", "201501.17",
"201501.18", "201501.19", "201501.21", "201501.22", "201501.23",
"201501.24", "201501.25", "201501.26", "201501.27", "201501.29",
"201501.30", "201501.31", "201501.33", "201501.34", "201501.35",
"201501.9", "201502.10", "201502.11", "201502.13", "201502.14",
"201502.15", "201502.17", "201502.18", "201502.19", "201502.21",
"201502.22", "201502.23", "201502.24", "201502.25", "201502.26",
"201502.27", "201502.29", "201502.30", "201502.31", "201502.33",
"201502.34", "201502.35", "201502.9", "201503.10", "201503.11",
"201503.13", "201503.14", "201503.15", "201503.17", "201503.18",
"201503.19", "201503.21", "201503.22", "201503.23", "201503.24",
"201503.25", "201503.26", "201503.27", "201503.29", "201503.30",
"201503.31", "201503.33", "201503.34", "201503.35", "201503.9"
), class = "factor"), P_value = c(0.63, 0.6793, 0.0319, 0.0289,
0.9516, 0.8128, 0.9967, 0.3071, 0.9641, 0.0246, 0.7967, 0.2551,
0.2329, 0.3725, 0.0269, 0.3796, 0.0245, 0.5562, 0.9952, 0.5176,
0.5596, 0.9966, 0.32, 0.6402, 0.7691, 0.9671, 0.9396, 0.9, 0.9024,
0.3624, 0.0433, 0.3402, 0.5302, 0.787, 0.0295, 0.3638, 0.006,
0.701, 0.6323, 0.0366, 2e-04, 0.0011, 0.8849, 0.3, 0.63, 0.9738,
0.0319, 0.5197, 0.9516, 0.7369, 0.9967, 0.2276, 0.9641, 0.0158,
0.7967, 0.6332, 0.2329, 0.0322, 0.0269, 0.3013, 0.0245, 0.0129,
0.9952, 0.795, 0.5596, 0.7277, 0.32, 0.747, 0.7691, 0.3817, 0.9396,
0.7961, 0.9024, 0.4164, 0.0433, 0.0028, 0.5302, 0.2864, 0.0295,
0.7036, 0.006, 0, 0.6323, 0.002, 2e-04, 0.9548, 0.8849, 0.0546,
0.6793, 0.9738, 0.0289, 0.5197, 0.8128, 0.7369, 0.3071, 0.2276,
0.0246, 0.0158, 0.2551, 0.6332, 0.3725, 0.0322, 0.3796, 0.3013,
0.5562, 0.0129, 0.5176, 0.795, 0.9966, 0.7277, 0.6402, 0.747,
0.9671, 0.3817, 0.9, 0.7961, 0.3624, 0.4164, 0.3402, 0.0028,
0.787, 0.2864, 0.3638, 0.7036, 0.701, 0, 0.0366, 0.002, 0.0011,
0.9548, 0.3, 0.0546), Cruise1 = structure(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, 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, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L), .Label = c("201501",
"201502", "201503"), class = "factor"), Cruise1_Strata1 = structure(c(1L,
1L, 2L, 2L, 3L, 3L, 4L, 4L, 5L, 5L, 6L, 6L, 7L, 7L, 8L, 8L, 9L,
9L, 10L, 10L, 11L, 11L, 12L, 12L, 13L, 13L, 14L, 14L, 15L, 15L,
16L, 16L, 17L, 17L, 18L, 18L, 19L, 19L, 20L, 20L, 21L, 21L, 22L,
22L, 1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L, 5L, 5L, 6L, 6L, 7L, 7L,
8L, 8L, 9L, 9L, 10L, 10L, 11L, 11L, 12L, 12L, 13L, 13L, 14L,
14L, 15L, 15L, 16L, 16L, 17L, 17L, 18L, 18L, 19L, 19L, 20L, 20L,
21L, 21L, 22L, 22L, 1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L, 5L, 5L, 6L,
6L, 7L, 7L, 8L, 8L, 9L, 9L, 10L, 10L, 11L, 11L, 12L, 12L, 13L,
13L, 14L, 14L, 15L, 15L, 16L, 16L, 17L, 17L, 18L, 18L, 19L, 19L,
20L, 20L, 21L, 21L, 22L, 22L), .Label = c("10", "11", "13", "14",
"15", "17", "18", "19", "21", "22", "23", "24", "25", "26", "27",
"29", "30", "31", "33", "34", "35", "9"), class = "factor"),
Cruise2 = structure(c(2L, 3L, 2L, 3L, 2L, 3L, 2L, 3L, 2L,
3L, 2L, 3L, 2L, 3L, 2L, 3L, 2L, 3L, 2L, 3L, 2L, 3L, 2L, 3L,
2L, 3L, 2L, 3L, 2L, 3L, 2L, 3L, 2L, 3L, 2L, 3L, 2L, 3L, 2L,
3L, 2L, 3L, 2L, 3L, 1L, 3L, 1L, 3L, 1L, 3L, 1L, 3L, 1L, 3L,
1L, 3L, 1L, 3L, 1L, 3L, 1L, 3L, 1L, 3L, 1L, 3L, 1L, 3L, 1L,
3L, 1L, 3L, 1L, 3L, 1L, 3L, 1L, 3L, 1L, 3L, 1L, 3L, 1L, 3L,
1L, 3L, 1L, 3L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L,
2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L,
1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L,
2L, 1L, 2L), .Label = c("201501", "201502", "201503"), class = "factor"),
Cruise2_Strata2 = structure(c(1L, 1L, 2L, 2L, 3L, 3L, 4L,
4L, 5L, 5L, 6L, 6L, 7L, 7L, 8L, 8L, 9L, 9L, 10L, 10L, 11L,
11L, 12L, 12L, 13L, 13L, 14L, 14L, 15L, 15L, 16L, 16L, 17L,
17L, 18L, 18L, 19L, 19L, 20L, 20L, 21L, 21L, 22L, 22L, 1L,
1L, 2L, 2L, 3L, 3L, 4L, 4L, 5L, 5L, 6L, 6L, 7L, 7L, 8L, 8L,
9L, 9L, 10L, 10L, 11L, 11L, 12L, 12L, 13L, 13L, 14L, 14L,
15L, 15L, 16L, 16L, 17L, 17L, 18L, 18L, 19L, 19L, 20L, 20L,
21L, 21L, 22L, 22L, 1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L, 5L, 5L,
6L, 6L, 7L, 7L, 8L, 8L, 9L, 9L, 10L, 10L, 11L, 11L, 12L,
12L, 13L, 13L, 14L, 14L, 15L, 15L, 16L, 16L, 17L, 17L, 18L,
18L, 19L, 19L, 20L, 20L, 21L, 21L, 22L, 22L), .Label = c("10",
"11", "13", "14", "15", "17", "18", "19", "21", "22", "23",
"24", "25", "26", "27", "29", "30", "31", "33", "34", "35",
"9"), class = "factor"), adjuste_p = c(1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.792, 1, 1, 1, 0.0264,
0.1452, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.3696, 1,
1, 1, 1, 0.792, 0, 1, 0.264, 0.0264, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 0.3696, 1, 1, 1, 1, 1, 0, 1, 0.264,
0.1452, 1, 1, 1)), .Names = c("Cruise_Strata1", "Cruise_Strata2",
"P_value", "Cruise1", "Cruise1_Strata1", "Cruise2", "Cruise2_Strata2",
"adjuste_p"), row.names = c(1453L, 2905L, 1520L, 2972L, 1587L,
3039L, 1654L, 3106L, 1721L, 3173L, 1788L, 3240L, 1855L, 3307L,
1922L, 3374L, 1989L, 3441L, 2056L, 3508L, 2123L, 3575L, 2190L,
3642L, 2257L, 3709L, 2324L, 3776L, 2391L, 3843L, 2458L, 3910L,
2525L, 3977L, 2592L, 4044L, 2659L, 4111L, 2726L, 4178L, 2793L,
4245L, 2860L, 4312L, 23L, 2927L, 90L, 2994L, 157L, 3061L, 224L,
3128L, 291L, 3195L, 358L, 3262L, 425L, 3329L, 492L, 3396L, 559L,
3463L, 626L, 3530L, 693L, 3597L, 760L, 3664L, 827L, 3731L, 894L,
3798L, 961L, 3865L, 1028L, 3932L, 1095L, 3999L, 1162L, 4066L,
1229L, 4133L, 1296L, 4200L, 1363L, 4267L, 1430L, 4334L, 45L,
1497L, 112L, 1564L, 179L, 1631L, 246L, 1698L, 313L, 1765L, 380L,
1832L, 447L, 1899L, 514L, 1966L, 581L, 2033L, 648L, 2100L, 715L,
2167L, 782L, 2234L, 849L, 2301L, 916L, 2368L, 983L, 2435L, 1050L,
2502L, 1117L, 2569L, 1184L, 2636L, 1251L, 2703L, 1318L, 2770L,
1385L, 2837L, 1452L, 2904L), class = "data.frame")
R Info
R version 3.2.1 (2015-06-18)
Platform: i386-w64-mingw32/i386 (32-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
Does this give you your desired result?
duplicated(apply(cbind(result5$Cruise_Strata1, df$Cruise_Strata2), 1,
function(x) paste(min(x), max(x))))
You can use the resulting logical vector to subset your data.
First you create a vector pasting the values in Cruise_Strata1 and Cruise_Strata2. Doing this you move the smaller of the two to the front and the larger one to the end (or you could do it vice versa). This is just a trick so that you can apply the duplicated function and recognize the duplicates.
Note: this approach will remove duplicates of the form:
Cruise_Strata1 Cruise_Strata2
x y
y x
As well as (if this is not desired let me know):
Cruise_Strata1 Cruise_Strata2
x y
x y
For a generic data frame df with duplicated values in Cruise_Strata1 and Cruise_Strata2:
df$dupe <- 0
for(i in 1:(length(df$Cruise_Strata1)-1))
{
for(j in (i+1):length(df$Cruise_Strata1))
if(df$Cruise_Strata1[i]==df$Cruise_Strata2[j])
{print(df[c(i,j),]); df$dupe[i] = 1;break}
}
df[df$dupe != 1,]