Pass multiple variables to ggtitle R

I have made several variables that I would like to pass to ggtitle. Here are the variables I made

ip_case_index <- paste("IP Only Case Index =",
                       round(mean(mdc5ip$case_index), digits = 2)
)
oa_case_index <- paste("OA Case Index",round(mean(edata$Std_Pmt_All_Clm / 
                                 edata$Pred_Amt_Renormal),
                            digits = 2)
)
sn_case_index <- paste("IP and SNF Only"
                       ,round(mean(mdc5sn$case_index), digits = 2)
)

I want to do something like

ggtitle(ip_case_index, oa_case_index, sn_case_index)

Which, of course, does not return the desired header format. How I would like it to appear in the title, this

ip_case_index
oa_case_index
sn_case_index

Where each variable is on its own header line. I tried to use \nto add a new line to no avail, I tried to use atop, which made each subsequent line smaller, so it was hard to see, because it treats each variable as subtitle, therefore subtitle subtitle is a subtitle.

paste() ggtitle, c(paste(), paste(), paste()), .

:

plot.title = c(ip_case_index, oa_case_index, sn_case_index)
ggtitle(plot.title)

.

, .

. ,

+4
1

, , , , .

dat=data.frame(x=rnorm(10), y=rnorm(10))

ip_case_index <- paste("IP Only Case Index =",
                       round(mean(rnorm(10)), digits = 2))
oa_case_index <- paste("OA Case Index",round(mean(rnorm(10)),
                                             digits = 2))
sn_case_index <- paste("IP and SNF Only"
                       ,round(mean(rnorm(10)), digits = 2))

ggplot(dat, aes(x,y)) + geom_point() + 
  ggtitle(paste0(ip_case_index,"\n", oa_case_index, "\n", sn_case_index))

enter image description here

+8

Source: https://habr.com/ru/post/1542228/


All Articles