我在r base中绘制双轴图,我无法在辅助轴上添加标签。以下是我正在使用的内容:
out <- unlist(lapply(strsplit(example.stem, "[|]"), function(x){
lapply(x[2], function(y){
as.numeric(paste(x[1], unlist(strsplit(y, "")), sep = "."))
})
}))
> identical(solution, out)
[1] TRUE
我试图标记右轴,但dados = structure(list(IDADE = c(65L, 35L, 65L, 42L, 50L, 44L, 0L, 58L,
22L, 27L, 34L, 31L, 0L, 24L, 34L, 20L, 4L, 34L, 20L, 27L, 8L,
2L, 20L, 31L, 45L, 26L, 26L, 40L, 50L, 34L), ESTADO = c(1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 0L, 1L, 1L, 1L, 1L, 0L, 1L, 0L, 0L), TIPINT = c(3L,
1L, 3L, 2L, 3L, 2L, 2L, 3L, 1L, 1L, 1L, 1L, 2L, 1L, 2L, 1L, 2L,
3L, 2L, 2L, 2L, 3L, 3L, 2L, 2L, 1L, 3L, 2L, 3L, 1L), DIARIAS = c(2L,
2L, 4L, 1L, 1L, 1L, 10L, 1L, 2L, 2L, 2L, 3L, 3L, 1L, 2L, 3L,
6L, 10L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 3L, 6L, 1L, 1L, 2L)), .Names = c("IDADE",
"ESTADO", "TIPINT", "DIARIAS"), row.names = c(NA, 30L), class = "data.frame")
#Define boxplot base
bx = boxplot(dados$IDADE~dados$TIPINT,axes=F, xlab=NA,ylab=NA,col=heat.colors(3,0.6))
#Posiciona eixos
par(mar = c(5,5,2,5))
#Plota bar
barplot(table(dados$TIPINT),col=heat.colors(3,0.4),names=c("Tipo 1","Tipo 2","Tipo 3"),
ylab = "Quantidade de pacientes")
#Plota box
par(new=T)
bx2 = bxp(bx,boxwex = 0.50, at = c(0.9, 2,3.1),axes=F, xlab=NA, ylab="l",boxfill=heat.colors(3,0.7))
axis(side=4)
用于其他内容而axis(side=4,labels="labels")
无效。
由于