I want to produce histograms using by(), how can I access the values of the factors, to include in histogram headings, for example…
a <- runif(500, 0, 10)
b <- LETTERS[1:5]
c <- c("Condition1", "Condition2")
x <- data.frame("Variable1" = b, "Variable2"= c, "Value"=a)
head(x)
by(x$Value, x$Variable2, hist)
or using two variables
by(x$Value, list(x$Variable2, x$Variable1), hist)
Is there a way of passing the variable value (eg Condition1) to the title of the histogram using the options within hist(), eg putting function(x) hist(x, main=...) into by()?
Pass the split up dataframe rather than just the Values. Then you will have more to work with:
Produced two plots labled
Condition1,Condition2