Reputation: 519
Below is the code that I was using when I only conditioned on a single variable. Using index.cond as below worked for switching the order of the panels in the final graph. However, now that I am conditioning on two variables the below code does not work to switch positions of the different panels. How do I modify index.cond to work? Here is my code and below is a picture of the graph and sample data:
libs <- c('lattice', 'latticeExtra', 'gridExtra', 'MASS', 'colorspace', 'plyr', 'Hmisc', 'scales')
lapply(libs, require, character.only = T)
conversion_test <- read.table("Desktop/FAST/convert_test/Results/fasconvert_Results", sep="\t", header=TRUE)
scatter.lattice <- xyplot(Time.to.Completion..s. ~ Number.of.Sequences | Length * Conversion, data = conversion_test, ylab = "Time to Completion (s)", xlab = "Number of Sequences", index.cond=list(c(2,1,4,3)), pch=16,
panel = function(x, y, ...) {
panel.xyplot(x, y, ...)
lm1 <- lm(y ~ x)
lm1sum <- summary(lm1)
r2 <- lm1sum$adj.r.squared
panel.abline(a = lm1$coefficients[1],
b = lm1$coefficients[2])
panel.text(labels =
bquote(italic(R)^2 ==
.(format(r2,
digits = 5))),
x = 500000, y = 10)
},
xscale.components = xscale.components.subticks,
yscale.components = yscale.components.subticks,
as.table = TRUE)
scatter.lattice
I would like to switch the order of the columns.
Here is an example dataset:
Numberofseq timetoCompletion Length Conversion
25000 9.3 100bp ClustalW
250000 45 100bp ClustalW
25000 9.3 100bp Fasta
250000 45 100bp Fasta
25000 9.3 1000bp ClustalW
250000 45 1000bp ClustalW
25000 9.3 1000bp Fasta
250000 45 1000bp Fasta
Upvotes: 3
Views: 2054
Reputation: 206167
From the ?xyplot
help page, under index.cond
,
If index.cond is a list, it has to be as long as the number of conditioning variables, and the i-th component has to be a valid indexing vector for levels(g_i), where g_i is the i-th conditioning variable in the plot
So since you have two conditioning variables, you should have a list of length two. Each of your variables has two levels. I still don't understand how you are numbering these plots, but depending on how your factors are leveled, try some form of
index.cond = list(2:1, 2:1)
#or
index.cond = list(2:1, 1:2)
but using this along with as.table
seems a bit odd.
Upvotes: 3