R ggplot的刻面标题中的部分斜体
我想知道是否有任何方法可以重命名刻面标题,使其包含部分斜体和部分非斜体 这里是一些玩具数据R ggplot的刻面标题中的部分斜体,r,ggplot2,R,Ggplot2,我想知道是否有任何方法可以重命名刻面标题,使其包含部分斜体和部分非斜体 这里是一些玩具数据 library(Hmisc) library(dplyr) # Plot power vs. n for various odds ratios n <- seq(10, 1000, by=10) # candidate sample sizes OR <- as.numeric(sort(c(seq(1/0.90,1/0.13,length.out = 9),2.9))) # cand
library(Hmisc)
library(dplyr)
# Plot power vs. n for various odds ratios
n <- seq(10, 1000, by=10) # candidate sample sizes
OR <- as.numeric(sort(c(seq(1/0.90,1/0.13,length.out = 9),2.9))) # candidate ORs
alpha <- c(.001, .01, .05) # alpha significance levels
# put all of these into a dataset and calculate power
powerDF <- data.frame(expand.grid(OR, n, alpha)) %>%
rename(OR = Var1, num = Var2, alph = Var3) %>%
arrange(OR) %>%
mutate(power = as.numeric(bpower(p1=.29, odds.ratio=OR, n=num, alpha = alph))) %>%
transform(OR = factor(format(round(OR,2),nsmall=2)),
alph = factor(ifelse(alph == 0.001, "p=0.001",
ifelse(alph == 0.01, "p=0.01", "p=0.05"))))
pPower <- ggplot(powerDF, aes(x = num, y = power, colour = factor(OR))) +
geom_line() +
facet_grid(factor(alph)~.) +
labs(x = "sample size") +
scale_colour_discrete(name = "Odds Ratio") +
scale_x_continuous(breaks = seq(0,1000,100)) +
scale_y_continuous(breaks = seq(0,1,.1), sec.axis = sec_axis(trans=I, breaks=NULL, name="Significance Level")) + # this is the second axis label
theme_light() +
theme(axis.title.x = element_text(size = 12, face = "bold"),
axis.title.y = element_text(size = 12, face = "bold"),
axis.text = element_text(size = 11),
panel.grid.minor = element_blank(),
panel.grid.major.y = element_line(colour = "gray95"),
panel.grid.major.x = element_line(colour = "gray95"),
strip.text = element_text(colour = 'black', face = 'bold', size = 12),
legend.text = element_text(size = 12),
legend.title = element_text(size = 12, face = "bold"))
pPower
库(Hmisc)
图书馆(dplyr)
#绘制不同优势比下的功率与n
n%
变换(或=因子(格式(圆形(或,2),nsmall=2)),
alph=系数(如果其他(alph==0.001,“p=0.001”),
ifelse(alph==0.01,“p=0.01”,“p=0.05”))
pPower似乎给出了一个答案。即使用级别(powerDF$alph)神奇@user20650!把它放在一个答案里,不管多小,我都会接受。很高兴它在我的问题上起了作用。我把这个问题作为另一个问题的重复来解决,因为它只是使用了解决方案,对你的问题做了一些小的调整。如果你不同意并希望自己发布一个答案,我将重新打开。很高兴你关闭,尽管我很高兴你回答了这个问题,因为我怀疑我是否能够从那篇文章中的大量代码中提取出至关重要的labeller函数。我可以自己回答这个问题。