Hints and pseudo code for Exercise 8.23.3 (Wilmes, unpublished)
forloop that processes all images using the function
getAreathat is provided in
CSB/r/solutions/getArea.R. The function accepts a single file name as argument, and returns the projected leaf area, measured in pixels. Your loop should record the leaf area for each image, and store it in the data frame
results. To loop over all files, you can use the function
list.filesalong with its pattern matching option, to produce a list of all the files with extension
.JPGin the directory
CSB/r/data/leafarea/. Work in your
sandboxor change paths in the
Plot the area of each plant as measured on time point 1 versus time point 2.
Determine if the plants significantly differ at time point 1 and 2 using a paired t-test.
- you will need to install the EBImage package and load it. You can use the code:
# install the EBImage package: run the following two commands source("http://bioconductor.org/biocLite.R") biocLite("EBImage") # note that to install EBImage, you might need to install other libraries # now load the library library(EBImage)
- create an empty
data.frameto record results
results <- data.frame(JPG = character(), area = numeric(), stringsAsFactors = FALSE)
list.filescan be used to list all the files in a directory
forloop and call the
getAreafunction for each file; store the area in the data frame.
to extract the information on time point and plant name, parse the file name
to run a t-test in
R, simply call