I've created a loop in order to create 3 different graphs for 3 different dates in data collected. I want the title of each graph to be the date of data collection, but when I run the code, it gives me a string of numbers, not the date
par(mfrow = c(2,2))
for(i in unique(PAR_PC$Date)){
p <- subset(PAR_PC, Date == i)
plot(p$Average_Ground ~ p$Cover,
xlab = "Absolute Percent Cover", ylab = "Average Ground PAR",
main = i,
col = "blue",
xlim = c(0, 100),
ylim = c(0, 2000),
pch = 19)
text(p$Average_Ground ~ p$Cover, labels = Plot, data = PARpc, cex = 0.9, font = 2, pos = 3)
}
For example, one of the plots turns out like this.
I did this to my data frame:
PAR_PC$Date <- as.Date(PAR_PC$Date,
format = "%m/%d/%y")
Here is subset of my data frame:
dput(head(PAR_PC))
structure(list(Site = c("umbs", "umbs", "umbs", "umbs", "umbs",
"umbs"), Date = structure(c(18416, 18416, 18416, 18416, 18416,
18416), class = "Date"), Julian = c(NA, NA, NA, NA, NA, NA),
Plot = c("A1", "A2", "A3", "A4", "A5", "A6"), Above_Biomass = c(1761L,
1782L, 1776L, 1784L, 1632L, 1786L), Ground_1 = c(1413L, 918L,
1013L, 1282L, 807L, 1333L), Gound_2 = c(1496L, 962L, 1314L,
1230L, 908L, 1503L), Average_Ground = c(1454.5, 940, 1163.5,
1256, 857.5, 1418), Percent_Sunlight = c(0.826, 0.527, 0.655,
0.704, 0.525, 0.794), Cover = c(12L, 2L, 27L, 32L, 23L, 15L
), state = c("ambient", "warmed", "ambient", "warmed", "warmed",
"ambient"), treatment_key = c("A0", "WI", "AI", "W0", "W0",
"AI"), insecticide = c("no insects", "insects", "insects",
"no insects", "no insects", "insects")), row.names = c(NA,
6L), class = "data.frame")