[R] Lattice: How to draw curves from given formulae
Deepayan Sarkar
deepayan.sarkar at gmail.com
Tue Aug 5 02:33:18 CEST 2008
On Mon, Aug 4, 2008 at 1:39 PM, John Smith <zmring at gmail.com> wrote:
> I have another questions. How can I type specific names into strips of the
> resulting plot?
>
> For instance, in the resulting figure from the attached code, instead of
> 'umbrella(d)', I want have 'UMBRELLA' in the strip.
>
> library(lattice)
>
> flat <- function(d) 0 * d
> linear <- function(d) -(1.65/8) * d
> logistic <- function(d) 0.015 - 1.73 / (1 + exp(1.2 * (4-d)))
> umbrella <- function(d) -(1.65/3) * d + (1.65 / 36) * d^2
> emax <- function(d) -1.81 * d / (0.79 + d)
> sigmoid <- function(d) -1.70 * d^5 / (4^5 + d^5)
>
> xyplot(flat(d) + linear(d) + logistic(d) + umbrella(d) + emax(d) +
> sigmoid(d) ~ d,
> data = list(d = seq(0, 8, length = 101)),
> ylab='Expected change from baseline in VAS at Week 6', xlab='Dose',
> type = "l", outer = TRUE, )
Here's one solution.
xyplot(flat(d) + linear(d) + logistic(d) +
umbrella(d) + emax(d) + sigmoid(d) ~ d,
data = list(d = seq(0, 8, length = 101)),
ylab='Expected change from baseline in VAS at Week 6', xlab='Dose',
type = "l", outer = TRUE,
strip = strip.custom(factor.levels =
c("FLAT", "LINEAR", "LOGISTIC", "UMBRELLA", "EMAX", "SIGMOID")))
-Deepayan
More information about the R-help
mailing list