encoding = "utf-8" require(aqp) require(RColorBrewer) require(latticeExtra) require(plyr) require(reshape) setwd("E:/R/soil/hill depressions") dat <- read.csv(paste(c(getwd(), "/Soil_Hole2.csv"), collapse=''), stringsAsFactors = FALSE, encoding = "UTF-8") str(dat) dat <- within(dat, label <- paste(name)) print(dat) depths(dat) <- id ~ top + bottom str(dat) class(dat) summary(dat) plot(dat, name = 'label') # add field for count of jasper flakes dat$jasper <- sample(1:15, nrow(dat), replace=TRUE) # a little function to compute the proportion of flakes in each horizon # (e.g 50% in Ap) dat$jasperpcnt <- unlist(sapply(split(dat, f = dat$id), function(x) (x$jasper/sum(x$jasper)*100), simplify=TRUE)) dat <- within(dat, jasperlabel <- paste(name, jasper, sep=" - ")) # see the data print(dat) depths(dat) <- id ~ top + bottom # plot with jasper quantity as color and lable with counts plot(dat, name = "label", color = "soil_color") # add overlay symbolizing the percent of jasper in each horizon addVolumeFraction(dat, "jasperpcnt")