ajusting imports of dependicies

This commit is contained in:
AG Damsbo 2022-11-28 09:36:04 +01:00
parent aaf08d824f
commit 2187cd026f
5 changed files with 35 additions and 12 deletions

View File

@ -11,12 +11,19 @@ export(plot_olr)
export(quantile_cut) export(quantile_cut)
export(source_lines) export(source_lines)
import(ggplot2) import(ggplot2)
import(stats)
import(tidyr)
importFrom(MASS,polr) importFrom(MASS,polr)
importFrom(dplyr,filter)
importFrom(dplyr,mutate) importFrom(dplyr,mutate)
importFrom(dplyr,select) importFrom(dplyr,select)
importFrom(gtsummary,add_overall) importFrom(gtsummary,add_overall)
importFrom(gtsummary,tbl_summary) importFrom(gtsummary,tbl_summary)
importFrom(rankinPlot,grottaBar) importFrom(rankinPlot,grottaBar)
importFrom(stats,as.formula)
importFrom(stats,coef)
importFrom(stats,confint)
importFrom(stats,formula)
importFrom(stats,lm)
importFrom(stats,quantile)
importFrom(stats,reorder)
importFrom(tidyr,all_of)
importFrom(tidyr,ends_with)
importFrom(tidyr,pivot_longer)

View File

@ -17,6 +17,13 @@ utils::globalVariables(c("vname"))
#' #'
#' @import ggplot2 #' @import ggplot2
#' @importFrom MASS polr #' @importFrom MASS polr
#' @importFrom stats as.formula
#' @importFrom stats coef
#' @importFrom stats confint
#' @importFrom stats formula
#' @importFrom stats lm
#' @importFrom stats quantile
#' @importFrom stats reorder
#' #'
#' @examples #' @examples
#' data(talos) #' data(talos)

View File

@ -12,23 +12,26 @@ utils::globalVariables(c("name","value","facet"))
#' #'
#' @return ggplot element #' @return ggplot element
#' #'
#' @import ggplot2 tidyr #' @import ggplot2
#' @importFrom dplyr mutate #' @importFrom dplyr mutate
#' @importFrom dplyr select #' @importFrom dplyr select
#' @importFrom dplyr filter #' @importFrom tidyr pivot_longer
#' @importFrom tidyr all_of
#' @importFrom tidyr ends_with
#' #'
#' @export #' @export
#' #'
#' @examples #' @examples
#' data(score) #' index_plot(score[score$event=="A",])
#' index_plot(score |> dplyr::filter(event=="A"))
index_plot <- function(ds,id="id",sub_plot="_is",scores=c("_is","_lo","_up","_per"),dom_names=c("immediate","visuospatial","verbal","attention","delayed","total"),facet.by=NULL){ index_plot <- function(ds,id="id",sub_plot="_is",scores=c("_is","_lo","_up","_per"),dom_names=c("immediate","visuospatial","verbal","attention","delayed","total"),facet.by=NULL){
if (length(facet.by)>1){stop("facet.by can be NULL or of length 1 only.")}
df_plot<-ds|> df_plot<-ds|>
dplyr::select(c(id, dplyr::select(c(id,
facet.by, facet.by,
ends_with(scores)))|> tidyr::ends_with(scores)))|>
tidyr::pivot_longer(cols=-c(id,facet.by))|> tidyr::pivot_longer(cols=-c(id,tidyr::all_of(facet.by)))|>
subset(grepl(sub_plot,name))|> subset(grepl(sub_plot,name))|>
dplyr::mutate(value=as.numeric(value), dplyr::mutate(value=as.numeric(value),
name=factor(name,labels = dom_names)) name=factor(name,labels = dom_names))

View File

@ -16,9 +16,16 @@ utils::globalVariables(c("or","ord","lo","up"))
#' @return gg object #' @return gg object
#' @keywords forest plot #' @keywords forest plot
#' #'
#' @import ggplot2 stats #' @import ggplot2
#' #'
#' @importFrom MASS polr #' @importFrom MASS polr
#' @importFrom stats as.formula
#' @importFrom stats coef
#' @importFrom stats confint
#' @importFrom stats formula
#' @importFrom stats lm
#' @importFrom stats quantile
#' @importFrom stats reorder
#' #'
#' @export #' @export
#' #'

View File

@ -33,6 +33,5 @@ ggplot element
Plot index scores from five dimensional cognitive testing. Includes option to facet. Plot index scores from five dimensional cognitive testing. Includes option to facet.
} }
\examples{ \examples{
data(score) index_plot(score[score$event=="A",])
index_plot(score |> dplyr::filter(event=="A"))
} }