相关疑难解决方法(0)

在图上添加回归线方程和R2

我想知道如何添加回归线方程和R ^ 2 ggplot.我的代码是

library(ggplot2)

df <- data.frame(x = c(1:100))
df$y <- 2 + 3 * df$x + rnorm(100, sd = 40)
p <- ggplot(data = df, aes(x = x, y = y)) +
            geom_smooth(method = "lm", se=FALSE, color="black", formula = y ~ x) +
            geom_point()
p
Run Code Online (Sandbox Code Playgroud)

任何帮助将受到高度赞赏.

r ggplot2 ggpmisc

207
推荐指数
8
解决办法
23万
查看次数

表达式()中的换行符?

我在R中有以下直方图:

hist(alpha,cex.main=2,cex.axis=1.2,cex.lab=1.2,
main=expression(paste("Histogram of ",hat(mu), ", Bootstrap samples, Allianz")))
Run Code Online (Sandbox Code Playgroud)

标题太长了,所以我想换线.根据这个线程,我试过

hist(alpha,cex.main=2,cex.axis=1.2,cex.lab=1.2,
main=expression(paste("Histogram of ",hat(mu), ",cat("\n") Bootstrap samples, Allianz")))
Run Code Online (Sandbox Code Playgroud)

要么

hist(alpha,cex.main=2,cex.axis=1.2,cex.lab=1.2,
main=expression(paste("Histogram of ",hat(mu), cat("\n"),", Bootstrap samples, Allianz")))
Run Code Online (Sandbox Code Playgroud)

但两者都不起作用,我怎样才能在paste()中获得换行符?

plot r line-breaks title plotmath

39
推荐指数
2
解决办法
2万
查看次数

ggplot2 facets: Different annotation text for each plot

I have the following generated data frame called Raw_Data:

    Time Velocity Type
1    10        1    a
2    20        2    a
3    30        3    a
4    40        4    a
5    50        5    a
6    10        2    b
7    20        4    b
8    30        6    b
9    40        8    b
10   50        9    b
11   10        3    c
12   20        6    c
13   30        9    c
14   40       11    c
15   50       13    c
Run Code Online (Sandbox Code Playgroud)

I plotted this data with ggplot2:

ggplot(Raw_Data, aes(x=Time, …
Run Code Online (Sandbox Code Playgroud)

r ggplot2

2
推荐指数
1
解决办法
2215
查看次数

标签 统计

r ×3

ggplot2 ×2

ggpmisc ×1

line-breaks ×1

plot ×1

plotmath ×1

title ×1