Replies: 8 comments
-
You can use text.pvalue <- display.statistical.result(
x = spearman.p,
statistic.type = 'p',
symbol = ' = '
);
text.label <- as.expression(
bquote(atop(rho == .(spearman.rho), .(as.character(text.pvalue))))
)
create.boxplot(
formula = age ~ ph.ecog.factor,
data = lung,
add.stripplot = TRUE,
add.text = TRUE,
text.labels = text.label,
text.x = 4,
text.y = max(lung$age, na.rm = TRUE) - 1,
text.fontface = 'plain'
) |
Beta Was this translation helpful? Give feedback.
-
I noticed you used For example:
How could you combine that with |
Beta Was this translation helpful? Give feedback.
-
Got it: text.pvalue <- display.statistical.result(
x = 0.00000000512,
statistic.type = 'p',
symbol = ' = '
);
text.label <- as.expression(
bquote(atop(rho == .(spearman.rho[[1]]), .(text.pvalue[[1]])))
)
create.boxplot(
formula = age ~ ph.ecog.factor,
data = lung,
add.stripplot = TRUE,
add.text = TRUE,
text.labels = text.label,
text.x = 4,
text.y = max(lung$age, na.rm = TRUE) - 1,
text.fontface = 'plain'
) |
Beta Was this translation helpful? Give feedback.
-
I might be misunderstanding, but take a look at how it's done for |
Beta Was this translation helpful? Give feedback.
-
Yup I think this is entirely avoidable, shouldn't need |
Beta Was this translation helpful? Give feedback.
-
I checked Another example is I see |
Beta Was this translation helpful? Give feedback.
-
Here's an example using library(survival);
library(BoutrosLab.plotting.general);
#> Loading required package: lattice
#> Loading required package: latticeExtra
#> Loading required package: cluster
#> Loading required package: hexbin
#> Loading required package: grid
#>
#> Attaching package: 'BoutrosLab.plotting.general'
#> The following object is masked from 'package:stats':
#>
#> dist
data(cancer);
lung$ph.ecog.factor <- factor(lung$ph.ecog);
# correlation
spearman <- cor.test(
x = as.numeric(lung$age),
y = lung$ph.ecog,
method = 'spearman',
use = 'complete.obs'
);
#> Warning in cor.test.default(x = as.numeric(lung$age), y = lung$ph.ecog, : Cannot
#> compute exact p-value with ties
spearman.p <- spearman$p.value;
spearman.rho <- round(spearman$estimate, 2);
names(spearman.rho) <- NULL;
text.pvalue <- display.statistical.result(
x = 0.00000000512,
statistic.type = 'p',
symbol = ' = '
);
text.rho <- as.expression(bquote(rho == .(spearman.rho[[1]])));
text.label <- as.expression(
bquote(atop(rho == .(spearman.rho[[1]]), .(text.pvalue[[1]])))
);
key.list <- c(text.rho, text.pvalue, expression(gamma))
key <- list(
text = list(
lab = key.list,
cex = 1
),
x = 0.7,
y = 1
);
create.boxplot(
formula = age ~ ph.ecog.factor,
data = lung,
add.stripplot = TRUE,
key = key
) Created on 2023-06-22 by the reprex package (v2.0.1) |
Beta Was this translation helpful? Give feedback.
-
@jarbet Since there doesn't seem to be an actual issue and you have a good solution now this is probably best as a discussion |
Beta Was this translation helpful? Give feedback.
-
For
create.boxplot
, I am trying to add 2 lines of math expressions: a p-value and Spearman correlation (since the group variable is ordinal).However, when I pass a vector of 2
expression
objects totext.labels
, it does not display both elements but instead displays the first element twice:Created on 2023-06-22 by the reprex package (v2.0.1)
Beta Was this translation helpful? Give feedback.
All reactions