In R, the netgraph() function takes a cex.points argument that controls the appearance of the points in the plot. Is there a way to scale the size of points through a variable in my .excel?
Thank u all
I don't know the arguments
CodePudding user response:
It's not clear what you mean by "scaling the points by a variable in my Excel", and if you are unsure of the arguments, you could have a look at ?netgraph
.
Suppose you had a vector of point sizes like this:
my_point_sizes <- c(1, 1, 2, 1, 4, 1, 6, 2, 1, 1)
And a netmeta object like this:
library(netmeta)
load(system.file("/data/Senn2013.rda", package = "netmeta"))
net1 <- netmeta(TE, seTE, treat1, treat2, studlab,
data = Senn2013, sm = "MD", reference = "plac")
Then you can apply the sizes to the points like this:
netgraph(net1, points = TRUE, cex.points = my_point_sizes)
Created on 2022-04-03 by the reprex package (v2.0.1)
CodePudding user response:
Here is a way to plot the points with sizes defined by the data. Function netmeta
is a list of S3 class "netmeta"
and has two members treat1
and treat2
.
Base R function table
can compute the frequencies but since they are the frequencies of two vectors, the two vectors must be combined to a 1-dim vector. This is done with c()
.
suppressPackageStartupMessages(library(netmeta))
data(Senn2013)
net1 <- netmeta(TE, seTE, treat1, treat2, studlab,
data = Senn2013, sm = "MD", reference = "plac")
# points size proportional to data frequencies
pts_size <- table(c(net1$treat1, net1$treat2))
netgraph(net1, points = TRUE, cex.points = pts_size)
Created on 2022-04-03 by the reprex package (v2.0.1)