Skip to content

Commit

Permalink
updated helper function netMetaNetgraph to use session key as data input
Browse files Browse the repository at this point in the history
  • Loading branch information
Rostu committed Dec 3, 2024
1 parent 98543b0 commit a3e66e8
Showing 1 changed file with 37 additions and 37 deletions.
74 changes: 37 additions & 37 deletions R/netMetaNetgraph.R
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
#' @title plot network graph
#' @description
#' Using the R package netmeta to to create and and return a network graph.
#' This indirect calling is needed since calling functions other than those from psychOpenCama package is blocked on the opencpu server for security reasons.
#' @param model
#' A netmeta model object
#' @param d
#' A \code{string} representing the dataset name that is used to extract the sequence and treatment parameter to be used of the netmeta::netgraph function
#' @return returns a network graph for a given netmeta model.
#' @author Robert Studtrucker
#' @export
netMetaNetgraph <- function(model,d) {

#load needed dependencies
requireNamespace("netmeta")


#load the in variable d defined dataset from the package
dat <- checkData(d)

#TE <- dat[,"TE"]
#seTE <- dat[,"seTE"]
#studlab<-dat[,"studlab"]
#treat1<-dat[,"treat1"]
#treat2<-dat[,"treat2"]

combined_treat<-c()
combined_treat<-c(combined_treat,dat["treat1"],recursive = TRUE,use.names=FALSE)
combined_treat<-c(combined_treat,dat["treat2"],recursive = TRUE,use.names=FALSE)

trts<-unique(combined_treat)[!is.na(unique(combined_treat))]

gr<-netmeta::netgraph(model, col="#0000CC", col.points="white", seq = trts)
print(gr)
# gc() # Force R to release memory it is no longer using

}
#' @title plot network graph
#' @description
#' Using the R package netmeta to to create and and return a network graph.
#' This indirect calling is needed since calling functions other than those from psychOpenCama package is blocked on the opencpu server for security reasons.
#' @param model
#' A netmeta model object
#' @param d
#' A \code{string} representing the dataset name that is used to extract the sequence and treatment parameter to be used of the netmeta::netgraph function
#' @return returns a network graph for a given netmeta model.
#' @author Robert Studtrucker
#' @export
netMetaNetgraph <- function(model,d) {

#load needed dependencies
requireNamespace("netmeta")


#load the in variable d defined dataset from the package
dat <- d

#TE <- dat[,"TE"]
#seTE <- dat[,"seTE"]
#studlab<-dat[,"studlab"]
#treat1<-dat[,"treat1"]
#treat2<-dat[,"treat2"]

combined_treat<-c()
combined_treat<-c(combined_treat,dat["treat1"],recursive = TRUE,use.names=FALSE)
combined_treat<-c(combined_treat,dat["treat2"],recursive = TRUE,use.names=FALSE)

trts<-unique(combined_treat)[!is.na(unique(combined_treat))]

gr<-netmeta::netgraph(model, col="#0000CC", col.points="white", seq = trts)
print(gr)
# gc() # Force R to release memory it is no longer using

}

0 comments on commit a3e66e8

Please sign in to comment.