knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
Load in data. cgms contains raw data. census contains info on each subject and trial
library(dplyr) # Data preprocessing ##### #Load in census census <- rio::import("~/cgms_analysis/cleaned data/visitinfo.tsv") #fix datatypes cgms <- rio::import("~/cgms_analysis/cleaned data/cgms.csv")
Use 2cgmsdf to combine census and cgms together and tidy the data for analysis. This is the datafrane object other functions use.
cgms.df <- cgms.analysis::tocgmsdf(cgms,census) print(head(cgms.df))
These cgms.df objects can and should be filtered to the subjects and runs that are relevant to your question. We use the nulldist function to add a nulldistribution to the dataframe. There are several to chose from depending on what You need your null distribution to be.
cgms.df.2124.V2PV8P <- cgms.df %>% filter(projno == 2124) %>% filter(visit %in% c("V2_P","V8_P")) %>% cgms.analysis::addnulldist()
From here, You can plot visualize all the runs for your cgms.df object, or calculate the sliding sample entropy using one of the entropy functions
cgms.analysis::plotruns(cgms.df.2124.V2PV8P,"/Users/samuelhamilton/cgms_analysis","name") cgms.analysis::CalcEn(df = cgms.df.2124.V2PV8P,varlist = c("Group")) cgms.analysis::CalcEnSlide(df = cgms.df.2124.V2PV8P,varlist = c("Group")) head(cgms.analysis::CalcEnSlideDist(df = cgms.df.2124.V2PV8P,varlist = c("Group")))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.