Hi I am producing water quality boxplots for a river site for a variety of metals.
The number of metals (or data columns) can change for each site, so the code has determine the ncol(data1) to plot each metals column.
I have used a .csv to input the raw data to data1.csv
Al As Cu Mn Hg Zn
1 0.010 0.0010 0.0011 0.0010 0.00026 0.0049
2 0.010 0.0010 0.0010 0.0010 0.00005 0.0011
3 0.015 0.0012 0.0010 0.0049 0.00005 0.0071
4 0.018 0.0012 0.0010 0.0019 0.00005 0.0052
5 0.012 0.0014 0.0010 0.0030 0.00005 0.0039
6 0.010 0.0010 0.0010 0.0010 0.00005 0.0072
7 0.010 0.0010 0.0010 0.0011 0.00005 0.0027
8 0.010 0.0010 0.0010 0.0068 0.00005 0.0040
9 0.011 0.0010 0.0013 0.0027 0.00005 0.0066
10 0.010 0.0010 0.0010 0.0010 0.00005 0.0033
11 0.010 0.0010 0.0010 0.0010 0.00005 0.0039
I tried this R code for the boxplot and associated stripchart of the raw data but it only seems to add stripchart data to the last boxplot. I would like the raw data for each metal added to each of the metal boxplots.
choose a WQ data CSV (no DATE string -just data)
data1 <-read.csv(file.choose(), header=TRUE, check.names = FALSE,
na.strings = c(“”, “NA”,”NAN”,”99999″, “-“))
data1 <-data.frame(data1)
BOXPLOT with different boxplot for each parameter based on data
par(mfrow = c(1, ncol(data1)),cex.lab=2.0, cex.axis=1.5)
invisible(lapply(1:ncol(data1), function(i) boxplot(data1[, i], xlab=names(data1[i]))))
invisible(lapply(1:ncol(data1), function(j) stripchart(data1[, j], method = “jitter”,
pch = 21, add = TRUE, vertical= TRUE, col = “blue”)))
David Dettrick is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.