I have a df like this
month day x
1 1 1 84
2 1 2 43
3 1 3 49
4 1 4 67
5 1 5 59
......
366 12 31 97
The year should be 2019 from Oct-Dec and 2020 from Jan-Sep
I tried to use
df$year<-as.date(df,origin='2019-01-01')
But I am not sure how to make an argument.
I want the year column to get a date column and try then
df$date<-as.date(with(paste("???",month,day,sep="-"), %Y-%m-%d,origin ="2019-01-01")
but again I don't know how to make an argument for year
Please any help would save me a lot of time because doing it manually seems impossible
We could use an ifelse statement with the make_date function from lubridate:
library(dplyr)
library(lubridate)
df %>%
mutate(year= ifelse(month %in% c(10,11,12), 2019, 2020),
date = make_date(year, month, day))
output:
month day x year date
1 1 1 84 2020 2020-01-01
2 1 2 43 2020 2020-01-02
3 11 3 49 2019 2019-11-03
4 1 4 67 2020 2020-01-04
5 1 5 59 2020 2020-01-05
366 12 31 97 2019 2019-12-31
You could use something like below. If you need a fixed variable instead of 2019/2020 you can use something like var-1 when it is oct-dec and var when it is jan - sep.
library(dplyr)
library(lubridate)
df1 %>%
mutate(date = if_else(month %in% c(10:12),
ymd(paste(2019, df1$month, df1$day, sep = "-")),
ymd(paste(2020, df1$month, df1$day, sep = "-"))))
data:
df1 <- data.frame(month = c(1:12), day = 1, x = 5)
Using base features you could use rowSums to identify 31th of October, then ISOdate.
w <- which.max(rowSums(d[1:2]) == 31 + 10)
d$year <- c(rep(2020, w), rep(2019, 365 - w))
d$date <- do.call(\(year, month, day, ...) as.Date(ISOdate(year, month, day)), d)
Result
head(d, 3)
# month day x year date
# 1 1 1 58 2020 2020-01-01
# 2 1 2 74 2020 2020-01-02
# 3 1 3 43 2020 2020-01-03
tail(d, 3)
# month day x year date
# 363 12 29 46 2019 2019-12-29
# 364 12 30 82 2019 2019-12-30
# 365 12 31 63 2019 2019-12-31
Note:
R.version.string
# [1] "R version 4.1.1 (2021-08-10)"
Data:
d <- structure(list(month = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,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 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 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, 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, 12L, 12L, 12L, 12L, 12L, 12L, 12L,
12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L), day = 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, 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, 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, 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, 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,
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, 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, 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, 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, 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, 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, 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),
x = c(72L, 95L, 95L, 76L, 84L, 64L, 85L, 84L, 70L, 95L, 75L,
64L, 72L, 48L, 68L, 68L, 44L, 53L, 46L, 49L, 62L, 53L, 74L,
86L, 58L, 63L, 85L, 85L, 81L, 44L, 66L, 82L, 86L, 90L, 75L,
54L, 53L, 52L, 47L, 48L, 61L, 95L, 96L, 73L, 59L, 57L, 94L,
70L, 81L, 68L, 83L, 83L, 95L, 55L, 73L, 51L, 50L, 83L, 58L,
45L, 74L, 64L, 54L, 60L, 77L, 94L, 90L, 47L, 44L, 50L, 70L,
69L, 76L, 69L, 62L, 63L, 62L, 55L, 47L, 43L, 71L, 47L, 66L,
69L, 74L, 53L, 85L, 62L, 53L, 57L, 52L, 65L, 85L, 68L, 62L,
43L, 72L, 69L, 79L, 71L, 95L, 45L, 96L, 70L, 96L, 51L, 48L,
67L, 52L, 48L, 72L, 54L, 64L, 79L, 49L, 55L, 90L, 57L, 51L,
63L, 79L, 69L, 48L, 52L, 89L, 70L, 95L, 64L, 75L, 95L, 70L,
94L, 95L, 43L, 87L, 56L, 46L, 53L, 60L, 91L, 61L, 88L, 83L,
89L, 45L, 87L, 69L, 83L, 71L, 44L, 93L, 96L, 80L, 46L, 80L,
66L, 80L, 59L, 86L, 51L, 48L, 80L, 81L, 79L, 65L, 80L, 72L,
84L, 61L, 55L, 49L, 54L, 60L, 44L, 44L, 84L, 49L, 94L, 45L,
80L, 79L, 51L, 70L, 48L, 66L, 89L, 60L, 57L, 76L, 86L, 88L,
71L, 79L, 94L, 74L, 93L, 80L, 75L, 90L, 91L, 77L, 95L, 48L,
90L, 77L, 50L, 49L, 56L, 71L, 73L, 62L, 85L, 90L, 76L, 67L,
44L, 96L, 52L, 73L, 85L, 44L, 44L, 79L, 89L, 93L, 58L, 57L,
75L, 48L, 58L, 59L, 51L, 64L, 89L, 82L, 76L, 51L, 56L, 46L,
82L, 48L, 76L, 93L, 60L, 52L, 75L, 77L, 53L, 52L, 56L, 50L,
66L, 70L, 67L, 87L, 90L, 50L, 80L, 54L, 81L, 54L, 73L, 88L,
64L, 52L, 64L, 73L, 79L, 68L, 53L, 86L, 94L, 56L, 62L, 65L,
85L, 61L, 54L, 93L, 60L, 69L, 82L, 83L, 56L, 51L, 82L, 71L,
76L, 77L, 60L, 79L, 61L, 83L, 87L, 43L, 74L, 76L, 63L, 59L,
54L, 93L, 82L, 65L, 89L, 68L, 62L, 61L, 91L, 89L, 79L, 59L,
52L, 80L, 71L, 96L, 46L, 84L, 47L, 92L, 80L, 86L, 64L, 88L,
56L, 93L, 94L, 66L, 46L, 87L, 63L, 89L, 92L, 88L, 65L, 90L,
71L, 53L, 91L, 61L, 91L, 62L, 62L, 48L, 80L, 73L, 62L, 75L,
59L, 72L, 61L, 90L, 51L, 66L, 74L, 58L, 73L, 89L, 50L, 79L,
90L, 94L, 59L, 47L, 88L, 83L)), row.names = c(NA, -365L), class = "data.frame")
Base R option -
transform(df, date = as.Date(paste(ifelse(month %in% 10:12, 2019, 2020), month, day, sep = '-')))
# month day x date
#1 1 1 84 2020-01-01
#2 1 2 43 2020-01-02
#3 11 3 49 2019-11-03
#4 1 4 67 2020-01-04
#5 1 5 59 2020-01-05
I have a dataset with phosphorus concentrations for 17 separate days (concentrations are cumulative, so increase from Day1 to Day102 in all cases). There are 22 different treatments (column = Trmt). Each Trmt has 3 Levels (Level = X, Y, Z). 2 measurements per Level for a total of 6 per Trmt.
My goal is to plot a 3-line graph of Days (x-axis; numeric) by Concentration (y-axis) using ggplot2. Data should be grouped by Trmt, Level and day for a total of 51 measurements (3 lines x 17 days).
My data looks as follows:
structure(list(Trmt = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 4L, 4L, 4L, 4L, 4L, 4L, 3L, 3L, 3L, 3L, 3L, 3L, 6L, 6L, 6L, 6L, 6L, 6L, 5L, 5L, 5L, 5L, 5L, 5L, 8L, 8L, 8L, 8L, 8L, 8L, 7L, 7L, 7L, 7L, 7L, 7L, 10L, 10L, 10L, 10L, 10L, 10L, 9L, 9L, 9L, 9L, 9L, 9L, 12L, 12L, 12L, 12L, 12L, 12L, 11L, 11L, 11L, 11L, 11L, 11L, 14L, 14L, 14L, 14L, 14L, 14L, 13L, 13L, 13L, 13L, 13L, 13L, 16L, 16L, 16L, 16L, 16L, 16L, 15L, 15L, 15L, 15L, 15L, 15L, 18L, 18L, 18L, 18L, 18L, 18L, 17L, 17L, 17L, 17L, 17L, 17L, 20L, 20L, 20L, 20L, 20L, 20L, 19L, 19L, 19L, 19L, 19L, 19L, 22L, 22L, 22L, 22L, 22L, 22L, 21L, 21L, 21L, 21L, 21L, 21L), .Label = c("A01nF", "A01yT", "A02nF", "A02yT", "A03nF", "A03yT", "A04nF", "A04yT", "A05nF", "A05yT", "A06nF", "A06yT", "A07nF", "A07yT", "A08nF", "A08yT", "A10nF", "A10yT", "A11nF", "A11yT", "A13nF", "A13yT"), class = "factor"), Level = structure(c(1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L), .Label = c("X", "Y", "Z"), class = "factor"), Day1 = c(3L, 1L, 4L, 2L, 4L, 2L, 5L, 4L, 1L, 2L, 5L, 1L, 5L, 2L, 5L, 5L, 3L, 5L, 3L, 3L, 1L, 4L, 1L, 1L, 5L, 4L, 1L, 5L, 4L, 5L, 3L, 5L, 3L, 5L, 3L, 4L, 2L, 4L, 2L, 4L, 3L, 1L, 1L, 3L, 1L, 3L, 1L, 5L, 2L, 4L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, 15L, 14L, 15L, 12L, 14L, 11L, 13L, 15L, 11L, 12L, 13L, 11L, 15L, 11L, 13L, 11L, 11L, 14L, 12L, 14L, 15L, 11L, 12L, 15L, 12L, 13L, 12L, 14L, 12L, 11L, 13L, 12L, 12L, 11L, 15L, 13L, 12L, 11L, 12L, 13L, 14L, 14L, 14L, 13L, 12L, 15L, 12L, 15L, 15L, 12L, 13L, 12L, 12L, 12L, 14L, 13L, 13L, 14L, 11L, 12L, 11L, 15L, 11L, 11L, 11L, 14L, 11L, 12L, 15L, 15L, 11L, 12L, 14L, 15L, 14L, 14L, 12L, 14L, 13L, 15L, 15L, 14L, 13L, 12L, 15L, 15L, 11L, 13L, 12L, 11L, 13L, 12L, 14L), Day7 = c(19L, 17L, 17L, 20L, 17L, 19L, 18L, 19L, 17L, 20L, 16L, 20L, 19L, 18L, 20L, 19L, 17L, 16L, 18L, 18L, 17L, 18L, 19L, 18L, 17L, 19L, 17L, 20L, 19L, 20L, 19L, 20L, 17L, 18L, 20L, 19L, 20L, 18L, 18L, 20L, 18L, 20L, 17L, 19L, 17L, 19L, 17L, 17L, 20L, 18L, 18L, 17L, 16L, 18L, 20L, 16L, 17L, 19L, 16L, 19L, 16L, 17L, 16L, 20L, 16L, 19L, 19L, 17L, 17L, 17L, 20L, 19L, 18L, 16L, 20L, 17L, 19L, 16L, 18L, 19L, 16L, 19L, 20L, 20L, 16L, 16L, 18L, 17L, 16L, 18L, 16L, 17L, 16L, 18L, 20L, 16L, 16L, 20L, 20L, 16L, 20L, 18L, 17L, 19L, 18L, 18L, 19L, 19L, 16L, 18L, 19L, 19L, 17L, 17L, 18L, 18L, 20L, 18L, 20L, 20L, 18L, 19L, 19L, 16L, 16L, 17L, 20L, 16L, 17L, 18L, 16L, 20L), Day10 = c(24L, 23L, 23L, 21L, 21L, 23L, 21L, 21L, 22L, 25L, 21L, 23L, 21L, 25L, 25L, 25L, 24L, 22L, 25L, 24L, 21L, 23L, 24L, 23L, 23L, 22L, 23L, 22L, 22L, 25L, 25L, 22L, 21L, 24L, 25L, 23L, 23L, 23L, 24L, 23L, 25L, 23L, 21L, 23L, 22L, 24L, 22L, 23L, 24L, 22L, 25L, 23L, 23L, 21L, 25L, 24L, 24L, 25L, 25L, 25L, 22L, 23L, 21L, 22L, 24L, 22L, 23L, 22L, 24L, 22L, 21L, 22L, 23L, 21L, 25L, 25L, 22L, 21L, 25L, 24L, 22L, 21L, 25L, 24L, 21L, 24L, 25L, 22L, 23L, 22L, 24L, 23L, 25L, 25L, 23L, 25L, 22L, 23L, 23L, 23L, 22L, 25L, 22L, 23L, 24L, 25L, 22L, 21L, 21L, 22L, 23L, 24L, 21L, 24L, 23L, 23L, 25L, 24L, 25L, 23L, 22L, 25L, 25L, 25L, 21L, 22L, 23L, 21L, 24L, 24L, 25L, 21L), Day13 = c(29L, 29L, 26L, 27L, 30L, 30L, 30L, 26L, 30L, 29L, 30L, 27L, 26L, 29L, 28L, 26L, 30L, 28L, 29L, 27L, 28L, 26L, 29L, 28L, 30L, 26L, 27L, 30L, 26L, 29L, 26L, 28L, 29L, 28L, 29L, 28L, 27L, 27L, 28L, 26L, 26L, 27L, 27L, 29L, 27L, 29L, 27L, 30L, 26L, 27L, 30L, 26L, 29L, 29L, 27L, 29L, 26L, 29L, 28L, 28L, 29L, 30L, 28L, 30L, 30L, 30L, 28L, 29L, 28L, 27L, 28L, 27L, 27L, 28L, 27L, 30L, 27L, 30L, 27L, 28L, 29L, 27L, 30L, 29L, 30L, 30L, 26L, 30L, 29L, 30L, 27L, 26L, 27L, 27L, 28L, 26L, 30L, 28L, 30L, 30L, 30L, 30L, 26L, 28L, 27L, 26L, 29L, 26L, 29L, 26L, 30L, 29L, 30L, 26L, 27L, 30L, 29L, 30L, 27L, 30L, 28L, 26L, 30L, 27L, 30L, 26L, 28L, 29L, 26L, 28L, 28L, 26L), Day18 = c(32L, 31L, 32L, 31L, 31L, 34L, 32L, 34L, 32L, 33L, 31L, 34L, 35L, 34L, 34L, 32L, 33L, 35L, 32L, 35L, 31L, 31L, 33L, 33L, 32L, 31L, 32L, 31L, 32L, 34L, 33L, 33L, 34L, 31L, 35L, 35L, 31L, 34L, 32L, 32L, 34L, 33L, 34L, 33L, 33L, 35L, 35L, 31L, 35L, 31L, 33L, 34L, 31L, 33L, 34L, 32L, 32L, 33L, 31L, 32L, 35L, 34L, 31L, 32L, 34L, 35L, 34L, 31L, 34L, 33L, 35L, 35L, 31L, 32L, 35L, 34L, 31L, 32L, 32L, 33L, 32L, 35L, 32L, 32L, 35L, 33L, 34L, 32L, 34L, 35L, 34L, 33L, 33L, 31L, 31L, 31L, 35L, 34L, 33L, 32L, 33L, 33L, 33L, 35L, 34L, 33L, 31L, 34L, 34L, 34L, 34L, 33L, 33L, 31L, 31L, 31L, 33L, 33L, 35L, 32L, 32L, 31L, 31L, 32L, 33L, 32L, 34L, 34L, 31L, 35L, 31L, 35L), Day23 = c(39L, 40L, 38L, 37L, 37L, 38L, 37L, 36L, 37L, 36L, 36L, 38L, 40L, 38L, 37L, 36L, 36L, 40L, 40L, 40L, 40L, 39L, 40L, 36L, 38L, 36L, 36L, 37L, 38L, 37L, 36L, 37L, 39L, 39L, 38L, 38L, 37L, 40L, 36L, 38L, 37L, 40L, 36L, 37L, 39L, 38L, 38L, 38L, 40L, 38L, 37L, 36L, 38L, 36L, 36L, 36L, 39L, 40L, 39L, 37L, 39L, 39L, 37L, 36L, 37L, 39L, 39L, 37L, 36L, 37L, 40L, 36L, 39L, 40L, 39L, 40L, 39L, 38L, 39L, 40L, 37L, 40L, 38L, 38L, 38L, 40L, 40L, 36L, 39L, 39L, 39L, 39L, 38L, 37L, 37L, 36L, 37L, 39L, 37L, 40L, 40L, 40L, 38L, 38L, 39L, 38L, 36L, 37L, 36L, 36L, 40L, 39L, 39L, 39L, 36L, 39L, 38L, 40L, 36L, 37L, 38L, 38L, 36L, 37L, 39L, 36L, 40L, 40L, 39L, 38L, 37L, 38L), Day28 = c(42L, 43L, 43L, 44L, 44L, 44L, 42L, 42L, 43L, 42L, 45L, 43L, 43L, 43L, 42L, 44L, 42L, 44L, 45L, 44L, 44L, 45L, 44L, 41L, 41L, 42L, 44L, 44L, 44L, 45L, 43L, 42L, 43L, 42L, 41L, 44L, 43L, 43L, 42L, 42L, 44L, 42L, 42L, 42L, 45L, 44L, 45L, 42L, 43L, 45L, 45L, 44L, 41L, 42L, 42L, 41L, 44L, 44L, 44L, 44L, 42L, 45L, 41L, 42L, 45L, 43L, 44L, 45L, 44L, 42L, 41L, 43L, 41L, 44L, 43L, 41L, 45L, 42L, 45L, 41L, 45L, 41L, 45L, 42L, 45L, 42L, 45L, 45L, 41L, 41L, 43L, 41L, 41L, 42L, 43L, 41L, 42L, 44L, 43L, 45L, 41L, 41L, 44L, 41L, 44L, 43L, 43L, 45L, 44L, 41L, 44L, 43L, 42L, 45L, 45L, 41L, 45L, 42L, 41L, 44L, 41L, 41L, 41L, 43L, 41L, 41L, 45L, 41L, 42L, 45L, 41L, 44L), Day35 = c(50L, 50L, 50L, 50L, 48L, 46L, 50L, 46L, 48L, 50L, 50L, 50L, 46L, 49L, 46L, 47L, 49L, 49L, 48L, 49L, 46L, 47L, 49L, 46L, 49L, 50L, 49L, 46L, 49L, 50L, 46L, 48L, 50L, 46L, 50L, 48L, 46L, 48L, 50L, 50L, 47L, 47L, 47L, 47L, 47L, 49L, 48L, 46L, 46L, 48L, 50L, 46L, 49L, 48L, 46L, 49L, 50L, 49L, 48L, 48L, 48L, 50L, 49L, 47L, 48L, 50L, 50L, 46L, 47L, 46L, 48L, 48L, 48L, 47L, 49L, 48L, 49L, 46L, 47L, 50L, 47L, 50L, 47L, 47L, 46L, 46L, 47L, 50L, 49L, 49L, 48L, 47L, 46L, 50L, 46L, 50L, 50L, 46L, 47L, 47L, 49L, 50L, 50L, 46L, 47L, 50L, 47L, 48L, 46L, 50L, 49L, 46L, 46L, 50L, 50L, 49L, 46L, 49L, 46L, 46L, 46L, 48L, 47L, 47L, 50L, 47L, 46L, 48L, 50L, 48L, 46L, 46L), Day42 = c(52L, 51L, 53L, 53L, 54L, 55L, 55L, 54L, 52L, 51L, 55L, 51L, 54L, 53L, 53L, 55L, 54L, 55L, 51L, 51L, 55L, 54L, 54L, 53L, 55L, 53L, 52L, 53L, 53L, 51L, 54L, 54L, 55L, 53L, 54L, 55L, 51L, 51L, 54L, 52L, 51L, 51L, 55L, 54L, 54L, 52L, 52L, 55L, 55L, 51L, 55L, 52L, 55L, 51L, 53L, 52L, 53L, 54L, 51L, 54L, 54L, 55L, 52L, 54L, 52L, 52L, 51L, 52L, 55L, 52L, 54L, 51L, 52L, 55L, 51L, 52L, 55L, 54L, 52L, 53L, 53L, 52L, 55L, 51L, 51L, 55L, 52L, 55L, 55L, 55L, 53L, 52L, 53L, 54L, 52L, 52L, 52L, 52L, 53L, 51L, 54L, 54L, 51L, 53L, 55L, 51L, 54L, 54L, 54L, 53L, 53L, 54L, 54L, 55L, 52L, 52L, 54L, 51L, 52L, 51L, 51L, 55L, 52L, 51L, 51L, 53L, 54L, 51L, 51L, 54L, 55L, 52L), Day52 = c(59L, 57L, 56L, 58L, 59L, 59L, 57L, 59L, 57L, 56L, 58L, 58L, 60L, 59L, 56L, 56L, 60L, 57L, 60L, 57L, 59L, 56L, 60L, 59L, 59L, 56L, 60L, 58L, 60L, 57L, 57L, 60L, 56L, 57L, 59L, 60L, 56L, 58L, 57L, 57L, 58L, 58L, 59L, 56L, 58L, 56L, 57L, 60L, 58L, 59L, 58L, 56L, 56L, 57L, 60L, 59L, 60L, 58L, 59L, 60L, 57L, 60L, 59L, 57L, 60L, 56L, 57L, 56L, 58L, 60L, 56L, 58L, 56L, 60L, 57L, 57L, 57L, 60L, 58L, 59L, 58L, 60L, 59L, 58L, 56L, 56L, 58L, 57L, 60L, 56L, 58L, 56L, 57L, 58L, 58L, 60L, 59L, 60L, 59L, 59L, 59L, 57L, 57L, 60L, 59L, 57L, 57L, 58L, 59L, 57L, 59L, 58L, 60L, 59L, 56L, 57L, 57L, 56L, 57L, 60L, 58L, 57L, 56L, 59L, 59L, 59L, 57L, 57L, 58L, 56L, 58L, 60L), Day62 = c(67L, 65L, 68L, 65L, 69L, 70L, 69L, 66L, 65L, 70L, 70L, 65L, 67L, 68L, 65L, 67L, 65L, 66L, 66L, 68L, 68L, 66L, 65L, 67L, 66L, 69L, 69L, 69L, 68L, 67L, 66L, 69L, 65L, 65L, 69L, 66L, 69L, 68L, 69L, 67L, 65L, 69L, 69L, 69L, 70L, 67L, 65L, 65L, 65L, 66L, 66L, 69L, 68L, 66L, 67L, 66L, 70L, 70L, 70L, 69L, 70L, 70L, 67L, 66L, 65L, 69L, 67L, 66L, 70L, 70L, 70L, 65L, 66L, 67L, 66L, 66L, 67L, 68L, 70L, 67L, 69L, 66L, 67L, 65L, 70L, 65L, 70L, 66L, 66L, 69L, 68L, 65L, 65L, 67L, 68L, 67L, 69L, 68L, 69L, 66L, 68L, 70L, 69L, 68L, 70L, 66L, 69L, 66L, 66L, 67L, 65L, 69L, 69L, 67L, 70L, 65L, 70L, 69L, 66L, 68L, 67L, 68L, 66L, 65L, 67L, 70L, 66L, 67L, 66L, 67L, 67L, 70L), Day72 = c(74L, 74L, 71L, 75L, 74L, 71L, 75L, 71L, 75L, 71L, 72L, 72L, 75L, 73L, 75L, 74L, 74L, 74L, 71L, 74L, 72L, 71L, 71L, 74L, 74L, 73L, 72L, 73L, 71L, 71L, 75L, 72L, 73L, 74L, 75L, 73L, 71L, 71L, 74L, 71L, 73L, 75L, 75L, 74L, 71L, 75L, 74L, 72L, 72L, 71L, 72L, 75L, 73L, 74L, 71L, 75L, 75L, 73L, 72L, 73L, 73L, 72L, 75L, 72L, 71L, 72L, 73L, 72L, 72L, 74L, 72L, 72L, 73L, 75L, 74L, 75L, 73L, 74L, 75L, 72L, 75L, 73L, 71L, 71L, 72L, 74L, 72L, 75L, 71L, 71L, 71L, 73L, 72L, 71L, 75L, 75L, 74L, 73L, 71L, 71L, 72L, 71L, 71L, 74L, 72L, 73L, 71L, 75L, 74L, 75L, 74L, 73L, 73L, 73L, 72L, 75L, 73L, 71L, 71L, 72L, 72L, 71L, 71L, 71L, 72L, 73L, 75L, 75L, 72L, 73L, 75L, 75L), Day82 = c(76L, 78L, 78L, 78L, 79L, 77L, 78L, 77L, 80L, 79L, 80L, 76L, 76L, 80L, 80L, 80L, 78L, 78L, 78L, 78L, 80L, 78L, 76L, 79L, 76L, 77L, 76L, 79L, 78L, 76L, 76L, 79L, 79L, 77L, 77L, 77L, 78L, 78L, 80L, 77L, 77L, 76L, 77L, 79L, 78L, 78L, 78L, 80L, 79L, 76L, 79L, 77L, 76L, 80L, 78L, 77L, 79L, 80L, 77L, 80L, 78L, 79L, 78L, 76L, 76L, 79L, 77L, 77L, 78L, 78L, 79L, 78L, 78L, 78L, 80L, 79L, 78L, 77L, 78L, 78L, 78L, 79L, 80L, 77L, 77L, 80L, 77L, 80L, 77L, 76L, 77L, 76L, 77L, 77L, 80L, 79L, 77L, 78L, 80L, 80L, 79L, 80L, 79L, 79L, 78L, 76L, 76L, 79L, 79L, 80L, 79L, 78L, 76L, 79L, 77L, 77L, 76L, 76L, 78L, 78L, 79L, 78L, 76L, 78L, 79L, 76L, 77L, 78L, 76L, 79L, 78L, 77L), Day92 = c(85L, 84L, 85L, 85L, 83L, 82L, 83L, 82L, 85L, 85L, 82L, 85L, 85L, 85L, 81L, 81L, 84L, 81L, 85L, 82L, 85L, 84L, 81L, 82L, 83L, 82L, 84L, 84L, 81L, 85L, 83L, 85L, 82L, 81L, 83L, 83L, 85L, 83L, 81L, 83L, 82L, 84L, 83L, 83L, 82L, 85L, 85L, 82L, 82L, 82L, 85L, 81L, 81L, 82L, 82L, 84L, 81L, 85L, 81L, 82L, 81L, 81L, 85L, 83L, 81L, 83L, 83L, 84L, 83L, 85L, 85L, 83L, 81L, 85L, 81L, 84L, 83L, 83L, 85L, 83L, 82L, 82L, 82L, 83L, 82L, 83L, 81L, 84L, 83L, 84L, 82L, 83L, 81L, 83L, 81L, 82L, 82L, 82L, 85L, 85L, 84L, 81L, 81L, 81L, 84L, 81L, 84L, 81L, 81L, 84L, 84L, 83L, 83L, 82L, 82L, 81L, 85L, 85L, 82L, 83L, 81L, 83L, 82L, 84L, 83L, 82L, 84L, 81L, 83L, 82L, 84L, 85L), Day102 = c(89L, 88L, 88L, 90L, 88L, 90L, 87L, 88L, 89L, 87L, 90L, 86L, 86L, 89L, 86L, 89L, 90L, 88L, 87L, 88L, 88L, 87L, 90L, 86L, 90L, 87L, 88L, 89L, 88L, 90L, 88L, 87L, 89L, 90L, 88L, 87L, 89L, 88L, 87L, 86L, 90L, 86L, 89L, 89L, 90L, 88L, 90L, 86L, 88L, 88L, 90L, 89L, 88L, 88L, 90L, 87L, 88L, 88L, 87L, 90L, 89L, 87L, 90L, 90L, 86L, 87L, 86L, 90L, 88L, 87L, 86L, 88L, 90L, 86L, 89L, 90L, 87L, 87L, 88L, 86L, 86L, 89L, 89L, 86L, 87L, 86L, 86L, 88L, 88L, 88L, 89L, 90L, 88L, 86L, 88L, 88L, 87L, 88L, 90L, 89L, 89L, 86L, 90L, 89L, 89L, 88L, 90L, 88L, 86L, 90L, 90L, 87L, 89L, 90L, 90L, 88L, 88L, 89L, 90L, 88L, 90L, 90L, 87L, 89L, 90L, 90L, 90L, 89L, 86L, 88L, 89L, 88L)), class = "data.frame", row.names = c(NA, -132L))
Required libraries:
tidyr, plyr, ggplot2
The steps that I have taken so far are to:
Convert the data to long format (df = name of dataset):
Fig1 <- gather(df, day, phosphorus, Day1:Day102, factor_key=TRUE)
Change the factor day to numeric
df$day2 <-revalue(df$day, c("Day1"="1", "Day2"="2", "Day4"="4", "Day7"="7", "Day10"="10", "Day13"="13", "Day18"="18", "Day23" = "23","Day28" = "28", "Day35" = "35", "Day42" = "42", "Day52" = "52", "Day62" = "62", "Day72" = "72", "Day82" = "82", Day92" = "92", "Day102" = "102"))
and
df$day3 <- as.numeric(as.character(df$day2))
Group by Trmt, Level and day3
GroupedDF <- df %>% group_by(Trmt, Level, day3)
GroupedCO2M <- GroupedDF %>% summarise(disp = mean(phosphorus))
I would now like to subtract values by accounting for Trmt and Level, thus reducing the number of rows from 102 to 51. I would like to subtract 'yT' Trmt cases from respective 'nF' cases, uniquely for each Level (X, Y and Z). For example, subtract A01yT_X from A01nf_X, A01yT_Y from A01nf_Y, A01yT_Z from A01nf_Z etc. This should give a total of 51 points, 17 for each Level.
Here is a figure of what I have in mind:
Many thanks for any advice.
thanks for sharing the data. The data you have posted is a bit long, hence might not be able to totally copy and paste
Your data is in the wide format, and you need to find the average for each measurement between similar groups (defined by Day, Level, Treatment). So we can work on this in the wide format:
tmp <- Data %>% group_by(Trmt,Level) %>% summarise_all(mean)
> head(tmp)
# A tibble: 6 x 19
# Groups: Trmt [2]
Trmt Level Day1 Day2 Day4 Day7 Day10 Day13 Day18 Day23 Day28 Day35 Day42
<fct> <fct> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 A01nF X 3.5 8 12 19 23 29.5 32.5 36.5 42 50 53
2 A01nF Y 4.5 9.5 13 17.5 21 28 32.5 36 43.5 48 54.5
3 A01nF Z 1 8.5 13.5 18.5 22.5 28.5 33 37.5 43 49 51.5
4 A01yT X 2.5 8.5 11 19.5 22.5 28 31.5 38 43 50 52.5
5 A01yT Y 2.5 7.5 13.5 17 22 29.5 31 38.5 43.5 49 52.5
6 A01yT Z 3 7 14.5 18 23 28 33 38 43.5 48 54
This gives you the average for each Trmt,Level, and each column (Day) is average separately. Next step is to define the 2 subgroups under Trmt (nF and yT for A01,A02..), and for this we can introduce a subgroup called "site", which is Trmt without the nF,yT. Once you group your data.frame with this "site" and level, the first row will always be nF, and 2nd row yT, so taking the diff for all your Day columns within this grouping, will give you the difference. So we do it like this:
# need to ungroup Trmt to remove it later
tmp <- tmp%>% ungroup(Trmt) %>%
mutate(site = sub("[yn][TF]","",Trmt)) %>%
select(-Trmt) %>%
group_by(site,Level) %>%
summarize_all(diff)
Now you have the nF - yT values for each treatment, each level and each day
> head(tmp)
# A tibble: 6 x 19
# Groups: site [2]
site Level Day1 Day2 Day4 Day7 Day10 Day13 Day18 Day23 Day28 Day35 Day42
<chr> <fct> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 A01 X -1 0.5 -1 0.5 -0.5 -1.5 -1 1.5 1 0 -0.5
2 A01 Y -2 -2 0.5 -0.5 1 1.5 -1.5 2.5 0 1 -2
3 A01 Z 2 -1.5 1 -0.5 0.5 -0.5 0 0.5 0.5 -1 2.5
4 A02 X 1.5 1 1.5 1 -1 -1.5 2 -1.5 -1.5 -1 2
5 A02 Y 0.5 0 -1.5 -1 0.5 1.5 -0.5 -3 -1.5 0 1
6 A02 Z 4 2 1 0.5 1.5 0 2.5 0.5 0.5 1.5 0
Come the last part, which is to plot. We convert it to long and also make "Day", a numeric form of day.
plotdf <- gather(tmp, day, Diff, Day1:Day102, factor_key=TRUE) %>%
mutate(Day=as.numeric(sub("Day","",day)))
# and plot
ggplot(plotdf,aes(x=Day,y=Diff,col=Level,shape=Level)) + geom_line() + geom_point() + facet_wrap(~site) + scale_color_manual(values=c("grey10","grey40","grey80"))
Plot above shows the difference for each site. For diff that is the average across all sites:
meandf <- plotdf %>% group_by(Level,Day) %>% summarize(Diff=mean(Diff))
ggplot(meandf,aes(x=Day,y=Diff,col=Level,shape=Level)) + geom_line() + geom_point() + scale_color_manual(values=c("grey10","grey40","grey80"))
example dataset, subsetted for Day1, Day2 and Day4
Data <- structure(list(Trmt = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 1L,
1L, 1L, 1L, 1L, 1L, 4L, 4L, 4L, 4L, 4L, 4L, 3L, 3L, 3L, 3L, 3L,
3L, 6L, 6L, 6L, 6L, 6L, 6L, 5L, 5L, 5L, 5L, 5L, 5L, 8L, 8L, 8L,
8L, 8L, 8L, 7L, 7L, 7L, 7L, 7L, 7L, 10L, 10L, 10L, 10L, 10L,
10L, 9L, 9L, 9L, 9L, 9L, 9L, 12L, 12L, 12L, 12L, 12L, 12L, 11L,
11L, 11L, 11L, 11L, 11L, 14L, 14L, 14L, 14L, 14L, 14L, 13L, 13L,
13L, 13L, 13L, 13L, 16L, 16L, 16L, 16L, 16L, 16L, 15L, 15L, 15L,
15L, 15L, 15L, 18L, 18L, 18L, 18L, 18L, 18L, 17L, 17L, 17L, 17L,
17L, 17L, 20L, 20L, 20L, 20L, 20L, 20L, 19L, 19L, 19L, 19L, 19L,
19L, 22L, 22L, 22L, 22L, 22L, 22L, 21L, 21L, 21L, 21L, 21L, 21L
), .Label = c("A01nF", "A01yT", "A02nF", "A02yT", "A03nF", "A03yT",
"A04nF", "A04yT", "A05nF", "A05yT", "A06nF", "A06yT", "A07nF",
"A07yT", "A08nF", "A08yT", "A10nF", "A10yT", "A11nF", "A11yT",
"A13nF", "A13yT"), class = "factor"), Level = structure(c(1L,
2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L,
3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L,
1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L,
2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L,
3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L,
1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L,
2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L,
3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L,
1L, 2L, 3L), .Label = c("X", "Y", "Z"), class = "factor"), Day1 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 9L, 8L, 9L, 6L, 6L, 10L, 9L,
8L, 8L, 7L), Day4 = c(11L, 12L, 14L, 11L, 15L, 15L, 12L, 11L,
15L, 12L, 15L, 12L, 12L, 11L, 15L, 15L, 13L, 11L, 13L, 14L, 12L,
11L, 13L, 12L, 15L, 15L, 14L, 11L, 15L, 11L, 12L, 11L, 13L, 11L,
12L, 13L, 13L, 14L, 13L, 15L, 14L, 15L, 12L, 14L, 11L, 13L, 15L,
11L, 12L, 13L, 11L, 15L, 11L, 13L, 11L, 11L, 14L, 12L, 14L, 15L,
11L, 12L, 15L, 12L, 13L, 12L, 14L, 12L, 11L, 13L, 12L, 12L, 11L,
15L, 13L, 12L, 11L, 12L, 13L, 14L, 14L, 14L, 13L, 12L, 15L, 12L,
15L, 15L, 12L, 13L, 12L, 12L, 12L, 14L, 13L, 13L, 14L, 11L, 12L,
11L, 15L, 11L, 11L, 11L, 14L, 11L, 12L, 15L, 15L, 11L, 12L, 14L,
15L, 14L, 14L, 12L, 14L, 13L, 15L, 15L, 14L, 13L, 12L, 15L, 15L,
11L, 13L, 12L, 11L, 13L, 12L, 14L)), class = "data.frame", row.names = c(NA,
-132L))