[R] Superscript and subscrib R for legend x-axis and y-axis and colour different subjects in longitudinal data with different colours
Rosa Oliveira
rosita21 at gmail.com
Fri Jul 28 17:07:23 CEST 2017
I am trying to make a x-axis and y-axis titles with both a special character and a subscript. I am not being able to do this. I think its just a placing of my parenthesis, but I've tried (seemingly) everything.
Even more, when I try the blog users code it works.
Is it because I’m using longitudinal data?
Even more. Is it possible to colour each one of the 15 lines with a different colour?
library(ggplot2)
library(reshape)
library(lattice)
library(gtable)
library(grid)
attach(mtcars)
beta0 = rnorm (15, 1, .5)
beta1 = rnorm (15, -1, .5)
tempo = seq(1:5)
CRP7raw = matrix(NA, 15, 5)
CRP7 = matrix(NA, 15, 5)
CRP98raw = matrix(NA, 15, 5)
CRP98 = matrix(NA, 15, 5)
crp <- for (i in 1:15) {
CRP7raw[i,] = beta0[i] + beta1[i] * tempo
CRP7[i,] = CRP7raw[i,] + rnorm(5, 0, 2.14)
CRP98raw[i,] = beta0[i] + beta1[i] * tempo
CRP98[i,] = CRP98raw[i,] + rnorm(5, 0, .1)
}
# plot(c(1:5), CRP7raw[1,], type = "n", xlim=c(1,5), ylim=c(-10,5) ,
# xlab="Day in ICU",
# ylab="CRP (mg/dL)",
# sub = mtext(expression(paste(lambda)))
#
# CRP7graph <- apply(CRP7, 1, lines, col="gray")
# plot(c(1:5), CRP98raw[1,], type = "n", xlim=c(1,5), ylim=c(-10,5),
# xlab="Day in ICU",
# ylab="CRP (mg/dL)")
# CRP98graph <- apply(CRP98, 1, lines, col="gray")
par(mfrow=c(1,2))
plot(c(1:5), CRP7raw[1,], type = "n", xlim=c(1,5), ylim=c(-10,5) ,
xlab="t_i",
ylab="y_ij",
sub = "lambda = 0.7")
CRP7graph <- apply(CRP7, 1, lines, col="gray")
plot(c(1:5), CRP98raw[1,], type = "n", xlim=c(1,5), ylim=c(-10,5),
xlab="Day in ICU",
ylab="CRP (mg/dL",
sub = "lambda = 0.98")
CRP98graph <- apply(CRP98, 1, lines, col="gray")
[[alternative HTML version deleted]]
More information about the R-help
mailing list