R/clinicalresponse

The aim of this package is to all clinics caring for patients with epilepsy to be able to calculate various response values using collected data. Currently this package calculates a seizure score, med score, and outcome and can be used to provide feedback to clinicians and caregivers on the seizure and med progress of patients receiving a therapy for epilepsy.

Before installing this package, you will need to ensure that two packages are installed into your R session: rJava and xlsx. If they are not, type this into your R console:

install.packages("rJava")
install.packages("xlsx")
library(xlsx)

Note that this package makes use of the rJava package in order to enable you to read Excel (xlsx) files into your R session and save Excel (xlsx) files onto your computer. You will need to ensure that you have Java installed on your computer and that the version of R or RStudio you are using matches the version of Java that you have (in RStudio, click on Tools -> Global Options -> General to change the version of R you are using if necessary).

Note: openxlsx package was updated to version 4 on 01/09/2017. This new version does not work with the package. To install the previous version, versio 3.0, please follow these instructions: 1. Type this into your console:

.libPaths()
  1. Navigate to the location of saved packages on your computer.
  2. Delete the openxlsx package (you will need to close out of R in order to do this)
  3. Go to this website https://cran.r-project.org/web/packages/openxlsx/index.html and download openxlsx_3.0.0.zip into the location of saved packages on your computer.
  4. Open R and type this into your console:
library(openxlsx")

To install the package, type these lines of code into your R console:

install.packages("devtools")
devtools::install_github("borumlab/response")

If the package installs without errors (if this is the case, you should see * DONE (clinicalresponse) displayed on the console), type this into the console to load the package:

library(clinicalresponse)

Data Dictionary

There are various Excel tables that will be needed to run the scripts in this package, and each script will give some output, to include Excel files and for some scripts, at least one graph (line plots and bar graphs created using the ggplot2 package). A description of each file needed to run the scripts, as well as the output Excel files, can be found in the DATA_DICTIONARY.xlsx file that is included in this package.

The blank excel sheets for you to populate your patient data with are located https://github.com/borumlab/response/Source Sheets. Please save this excel sheets on your computer.

Example Data

Upon installing and loading this package, there will an example dataset loaded into your R session. These files are named as follows:

Each of these files will exist within your R session as data frames. You can view these data frames by typing the name of the data frame, as listed above, into your R console:

``` {r eval=FALSE} MED_RANKING_SOURCE

``` {r echo=FALSE}
table <- openxlsx::read.xlsx("G:/MySQL Database/Response/Example patient for package/MED_RANKING_SOURCE.xlsx",sheet=1,detectDates=TRUE)
table

Your data will need to be organized as these tables are in order for the scripts to function properly. For the tables with prefix "PATIENT1", each individual patient will have a file of that type storing that data that is unique to them, replacing "PATIENT1" with the identifier that you wish to use for that patient. There will be only one of the other three table: the MED_RANKING_SOURCE.xlsx file will be the same for all patients, whereas the CLINIC_VISIT_SOURCE.xlsx and the DEMOGRAPHICS_SOURCE.xlsx files will store data for all patients within the same files. When you create your Excel files, they will all need to have the same name as given to the Example data frames seen here, with the exception of replacing "PATIENT1" with each patient's unique identifier. For more information about creating your files and on entering data, please read the README DATA ENTRY word document in this package folder.

You may also find the excel sheets in https://github.com/borumlab/response/Example Patient excel sheets folder and save them to your local drive so that you may test the package. Make sure you do not save these files in a zip folder.

Calculating seizure score values

The first step in calculating seizure score values will be to obtain the seizure load. In this process, seizure load is defined as sum of ranking points for seizure characteristics (seizure type, seizure length, seizure severity, other seizure variables) per seizur per day. Also of interest is seizure number or seizure frequency, which is the number of seizures that a patient has per day. These values will be needed in order to calculate seizure score values.

To calculate daily seizure loads and seizure numbers, type this into your R console:

``` {r eval=FALSE} calculate_seizure_load()

First, the function will prompt you to enter some unique identifier (e.g. FiLa, denoting the first two letters
of the patient's first name and the first two letters of the patient's last name) that signifies the patient you wish to run the script on. Note that identifier must exactly match the identifier found in that patient's Excel file names.

``` {r echo=FALSE}
print("Input the identifier that signify the patient we are doing calculations for")
print("Example: FILA")
patient <- readline(prompt="Enter here: PATIENT1")

Next, you will be asked to set the working directory in which the SEIZURE_DATA_SOURCE.xlsx file can be found in. To set the working directory, navigate to the folder where you saved the patient Source Sheets and copy the file path. Paste the file path into the R console when prompted. Pay special attention to the direction of the slashes. Typically, when you paste the file path into the console the forward slashes will need to be changed to backward slashes. Once the location of this file has been set, the script will look for a file named [PATIENT1]_SEIZURE_DATA_SOURCE.xlsx and read it into R.

``` {r echo=FALSE} print("Input the directory that you wish to draw this patient's SEIZURE_DATA_SOURCE file from") print("Example: C:/Folder_Name/") directory <- readline(prompt="Enter here: C:/Desktop/Patient Folder/PATIENT1/Data/")

Then, R will need to load in the SEIZURE_RANKING_SOURCE.xlsx file. You will be asked whether this file exists in the same folder as the SEIZURE_DATA_SOURCE.xlsx file or not. If so, type 'yes'. If not, type 'no', and you will be prompted to specify the folder in which this file can be found on your computer.

``` {r echo=FALSE}
print("Type 'yes' if this patient's SEIZURE_RANKING_SOURCE file can be found in the same folder as the SEIZURE_DATA_SOURCE table. Type 'no' if it is in a different folder")
answer <- readline(prompt="Enter here: no")
print("Input the directory that you wish to draw this patient's SEIZURE_RANKING_SOURCE file from")
print("Example: C:/Folder_Name/")
directory <- readline(prompt="Enter here: C:/Desktop/Patient Folder/PATIENT1/Ranking/")

Once the seizure raw data table and the seizure ranking table have been loaded into R, the calculation of seizure load will begin. As each step is done, you will see the following output in your console:

``` {r echo=FALSE} print("Calculating ranks. Please wait...") print("Calculating sums for missing days. Please wait...") print("Now calculating daily seizure loads. Please wait...")

Once daily seizure loads have been calculated, you will be asked if you wish to save PATIENT1_SEIZURE_LOAD.xlsx on your computer. 

``` {r echo=FALSE}
print("Would you like to save a temporary file to look at the seizure loads?")
print("Type 'YES' to save a file to look at, type 'NO' to move onto next step")
answer <- readline(prompt="Enter here: yes")

If you were to type no here, we would skip this step and move on to the calculation of seizure score. If you typed yes, you will be asked where you would like to save the file.

``` {r echo=FALSE} print("Input the directory that you wish to save this patient's SEIZURE_LOAD file in") print("Example: C:/Folder_Name/") directory <- readline(prompt="Enter here: C:/Desktop/Patient Folder/PATIENT1/Data/") print(paste("Saving seizure load table as PATIENT1_SEIZURE_LOAD.xlsx in directory C:/Desktop/Patient Folder/PATIENT1/Data/"))

And then you will be given the chance to open and view your file for review. If you are satisfied and would like to move on to seizure response calculation, type 'OKAY', otherwise, you can type 'QUIT' to end the script.

``` {r echo=FALSE}
print("Type 'OKAY' whenever you are ready to move on to the next step")
print("Or type 'QUIT' if you would like to exit")
answer <- readline(prompt="Enter here: OKAY")

Next, you will use the daily seizure loads in order to calculate seizure response values. These values include seizure score per day (percent change in seizure load for seizure days from baseline to a day on therapy), seizure score per 30 day period (percent change in seizure load for seizure free and seizure days from baseline to a 30 day time period on therapy), and seizure number score per day (percent change in seizure number for seizure days from baseline to a day on therapy) and seizure score per 30 day period (percent change in seizure number for seizure days and seizure fre days from baseline to a 30 day time period on therapy). The formulas used to calculate these values can be found in the EQUATIONS word document. Note that this process will only occur if the patient has days classified as therapy days.

``` {r echo=FALSE} print("The percentage of baseline days with no seizures is: [number]%") print("Scores have been calculated")

If the patient has a baseline day with seizure load greater than 0 and has been on therapy,  then a line graph of the seizure score per day and seizure score per 30 days will be created. You will first be asked where the DEMOGRAPHICS_SOURCE.xlsx file is (this is so that the patient's name can be drawn from the file and displayed on the graphs).

``` {r echo=FALSE} 
print("Input the directory that you wish to draw the DEMOGRAPHICS_SOURCE file from")
print("Example: C:/Folder_Name/")
directory <- readline(prompt="Enter here:  C:/Desktop/Patient Folder/PATIENT1/Demographics/")

You will then be asked if you would like the graphs to be saved in the same folder as the SEIZURE_LOAD.xlsx file. Type 'yes' if you do, or type 'no' if you would like to save it somewhere else. If you type 'no', you will be asked where you would like this file to be saved.

``` {r echo=FALSE} print("Type 'yes' if you wish to save all graphs in the same folder as this patient's SEIZURE_LOAD file. Type 'no' if you would like for them to be in a different folder") answer <- readline(prompt="Enter here: no") print("Input the directory that you wish to save this patient's seizure graphs in") print("Example: C:/Folder_Name/") directory <- readline(prompt="Enter here: C:/Desktop/Patient Folder/PATIENT1/Data/")

Then your graphs will be created and saved.

``` {r echo=FALSE}
print("PATIENT1_SEIZURE_DAILY_GRAPH.png created and saved in the patient folder")
print("PATIENT1_SEIZURE_SCORE_GRAPH.png created and saved in the patient folder")

``` {r echo=FALSE,include=FALSE} library(png)

``` {r echo=FALSE}
img <- readPNG("G:/MySQL Database/Response/Example patient for package/PATIENT1_SEIZURE_DAILY_GRAPH.PNG",native=TRUE)
plot(1:3,type='n',xlab="",ylab="",axes=FALSE)
rasterImage(img,xleft=1,ybottom=1,xright=3,ytop=3)
img <- readPNG("G:/MySQL Database/Response/Example patient for package/PATIENT1_SEIZURE_SCORE_GRAPH.png",native=TRUE)
plot(1:3,type='n',xlab="",ylab="",axes=FALSE)
rasterImage(img,xleft=1,ybottom=1,xright=3,ytop=3)

Finally, the seizure score values will be saved to your computer. You will be asked if you would like this file to be saved in the same folder as the SEIZURE_LOAD.xlsx file. Type 'yes' if you do, or type 'no' if you would like to save it somewhere else. If you type 'no', you will be asked where you would like this file to be saved.

``` {r echo=FALSE} print("Type 'yes' if you wish to save this patient's SEIZURE_DATA_CLINICAL file in the same folder as this patient's SEIZURE_LOAD file. Type 'no' if you would like for it to be in a different folder") answer <- readline(prompt="Enter here: no") print("Input the directory that you wish to save this patient's SEIZURE_DATA_CLINICAL file in") print("Example: C:/Folder_Name/") directory <- readline(prompt="Enter here: C:/Desktop/Patient Folder/PATIENT1/Data/") print("Saving seizure clinical outcome table as PATIENT1_SEIZURE_DATA_CLINICAL in directory C:/Desktop/Patient Folder/PATIENT1/Data/")

If your patient does not have any days labeled as therapy days, then this will print on your console:

``` {r echo=FALSE}
print("No therapy days, therefore response and score values will not be calculated")

In this case, you will not be given any seizure score output.

Calculating med score values

Similarly to seizure score, the first step in calculating med score values will be to obtain the med load. In this process, med load is defined as the sum of prescribed med dose divided by minimum med dose (from clinical pharmacology) per patient weight (kg) per med per day. Also of interest is med number or med frequency, which is the number of meds prescribed to a patient per day. These values will be needed in order to calculate med response values.

To calculate daily med loads and med numbers, type this into your R console:

``` {r eval=FALSE} calculate_med_load()

First, the function will prompt you to enter some unique identifier (e.g. FiLa, denoting the first two letters
of the patient's first name and the first two letters of the patient's last name) that signifies the patient
you wish to run the script on.

``` {r echo=FALSE}
print("Input the identifier that signify the patient we are doing calculations for")
print("Example: FILA")
patient <- readline(prompt="Enter here: PATIENT1")

Next, you will be asked to set the work directory in which the DEMOGRAPHICS_SOURCE.xlsx file can be found in. Once the location of this file has been set, the script will look for a file named DEMOGRAPHICS_SOURCE.xlsx and read it into R.

``` {r echo=FALSE} print("Input the directory that you wish to draw this patient's DEMOGRAPHICS_SOURCE file from") print("Example: C:/Folder_Name/") directory <- readline(prompt="Enter here: C:/Desktop/Patient Folder/PATIENT1/Demographics/")

Then, R will need to load in the MED_RANKING_SOURCE.xlsx file. You will be asked whether this file exists in the same folder as the DEMOGRAPHICS_SOURCE.xlsx file or not. If so, type 'yes'. If not, type 'no', and you will be prompted to specify the folder in which this file can be found on your computer.

``` {r echo=FALSE}
print("Type 'yes' if the MED_RANKING_SOURCE file can be found in the same folder as the DEMOGRAPHICS_SOURCE table. Type 'no' if it is in a different folder")
answer <- readline(prompt="Enter here: no")
print("Input the directory that you wish to draw this patient's MED_RANKING_SOURCE file from")
print("Example: C:/Folder_Name/")
directory <- readline(prompt="Enter here: C:/Desktop/Patient Folder/PATIENT1/Ranking/")

Then, R will need to load in the ANTHROPOMETRICS_SOURCE.xlsx file. Since med load requires milligrams of medication per kilogram weight of the patient, weight data needs to be incorporated into the med load calculations. You will be asked whether this file exists in the same folder as the MED_RANKING_SOURCE.xlsx file or not. If so, type 'yes'. If not, type 'no', and you will be prompted to specify the folder in which this file can be found on your computer.

``` {r echo=FALSE} print("Type 'yes' if this patient's ANTHROPOMETRICS_SOURCE file can be found in the same folder as the MED_RANKING_SOURCE table. Type 'no' if it is in a different folder") answer <- readline(prompt="Enter here: no") print("Input the directory that you wish to draw this patient's ANTHROPOMETRICS_SOURCE file from") print("Example: C:/Folder_Name/") directory <- readline(prompt="Enter here: C:/Desktop/Patient Folder/PATIENT1/Anthropometrics/")

Lastly, R will need to load in the MED_DATA_SOURCE.xlsx file. You will be asked whether this file exists in the same folder as the ANTHROPOMETRICS_SOURCE.xlsx file or not. If so, type 'yes'. If not, type 'no', and you will be prompted to specify the folder in which this file can be found on your computer.

``` {r echo=FALSE}
print("Type 'yes' if this patient's MED_DATA_SOURCE file can be found in the same folder as this patient's ANTHROPOMETRICS_SOURCE table. Type 'no' if it is in a different folder")
answer <- readline(prompt="Enter here: no")
print("Input the directory that you wish to draw this patient's MED_DATA_SOURCE file from")
print("Example: C:/Folder_Name/")
directory <- readline(prompt="Enter here: C:/Desktop/Patient Folder/PATIENT1/Data/")

Once the med raw data table, the med ranking table, the anthropometrics table, and the demographics table have been loaded into R, the calculation of med load will begin. As each step is done, you will see the following output in your console:

``` {r echo=FALSE} print("Calculating med intake in mg/kg/day, please wait...") print("Calculating minimum dose in mg/kg/day, please wait...") print("Calculating med load per day, please wait...")

Once daily med loads have been calculated, you will see that a med load graph was saved to the file location. 

``` {r echo=FALSE}
print("PATIENT1_MED_LOAD_GRAPH.png created and saved in the patient folder")
img <- readPNG("G:/MySQL Database/Response/Example patient for package/PATIENT1_MED_LOAD_GRAPH.png",native=TRUE)
plot(1:3,type='n',xlab="",ylab="",axes=FALSE)
rasterImage(img,xleft=1,ybottom=1,xright=3,ytop=3)

Once the med load graph has been saved, you will be asked if you wish to save a PATIENT1_MED_LOAD.xlsx file on your computer.

``` {r echo=FALSE} print("Would you like to save a temporary file to look at the med loads?") print("Type 'YES' to save a file to look at, type 'NO' to move onto next step") answer <- readline(prompt="Enter here: yes")

If you were to type no here, we would skip this step and move on to the calculation of med score. If you typed yes, you will be asked where you would like to save the file.

``` {r echo=FALSE}
print("Type 'yes' if you wish to save the MED_LOAD file in the same folder as this patient's MED_DATA_SOURCE table. Type 'no' if it is in a different folder")
answer <- readline(prompt="Enter here: no")
print("Input the directory that you wish to save this patient's MED_LOAD file from")
print("Example: C:/Folder_Name/")
directory <- readline(prompt="Enter here: C:/Desktop/Patient Folder/PATIENT1/Data/")
print(paste("Saving med load table as PATIENT1_MED_LOAD.xlsx in directory C:/Desktop/Patient Folder/PATIENT1/Data/"))

And then you will be given the chance to open and view your file for review. If you are satisfied and would like to move on to seizure response calculation, type 'OKAY', otherwise, you can type 'QUIT' to end the script.

``` {r echo=FALSE} print("Type 'OKAY' whenever you are ready to move on to the next step") print("Or type 'QUIT' if you would like to exit") answer <- readline(prompt="Enter here: OKAY")

Next, you will use the daily med loads in order to calculate med score values. These values include med score per day (percent change in med load for med days from baseline to a day on therapy), med score per 30 day period (percent change in med load for med free and med days from baseline to a 30 day time period on therapy), and med number score per day (percent change in med number for med days from baseline to a day on therapy), and med score per 30 day period (percent change in med number for med free and med days from baseline to a 30 day time period on therapy). The formulas used to calculate these values can be found in the EQUATIONS word document. Note that this process will only occur if the patient has days classified as therapy days.

``` {r echo=FALSE}
print("Scores have been calculated")

You will be asked if you would like the graphs to be saved in the same folder as the MED_LOAD.xlsx file. Type 'yes' if you do, or type 'no' if you would like to save it somewhere else. If you type 'no', you will be asked where you would like this file to be saved.

``` {r echo=FALSE} print("Type 'yes' if you wish to save all graphs in the same folder as this patient's MED_LOAD file. Type 'no' if you would like for them to be in a different folder") answer <- readline(prompt="Enter here: no") print("Input the directory that you wish to save this patient's med graphs in") print("Example: C:/Folder_Name/") directory <- readline(prompt="Enter here: C:/Desktop/Patient Folder/PATIENT1/Data/")

Then the graphs will be created and saved.

``` {r echo=FALSE}
print("PATIENT1_MED_DAILY_GRAPH.png created and saved")
print("PATIENT1_MED_SCORE_GRAPH.png created and saved")
img <- readPNG("G:/MySQL Database/Response/Example patient for package/PATIENT1_MED_DAILY_GRAPH.png",native=TRUE)
plot(1:3,type='n',xlab="",ylab="",axes=FALSE)
rasterImage(img,xleft=1,ybottom=1,xright=3,ytop=3)
img <- readPNG("G:/MySQL Database/Response/Example patient for package/PATIENT1_MED_SCORE_GRAPH.png",native=TRUE)
plot(1:3,type='n',xlab="",ylab="",axes=FALSE)
rasterImage(img,xleft=1,ybottom=1,xright=3,ytop=3)

Finally, the med score values will be saved to your computer. You will be asked if you would like this file to be saved in the same folder as the MED_LOAD.xlsx file. Type 'yes' if you do, or type 'no' if you would like to save it somewhere else. If you type 'no', you will be asked where you would like this file to be saved.

``` {r echo=FALSE} print("Type 'yes' if you wish to save this patient's MED_DATA_CLINICAL file in the same folder as this patient's MED_LOAD file. Type 'no' if you would like for it to be in a different folder") answer <- readline(prompt="Enter here: no") print("Input the directory that you wish to save this patient's MED_DATA_CLINICAL file in") print("Example: C:/Folder_Name/") directory <- readline(prompt="Enter here: C:/Desktop/Patient Folder/PATIENT1/Data/") print("Saving med clinical outcome table as PATIENT1_MED_DATA_CLINICAL in directory C:/Desktop/Patient Folder/PATIENT1/Data/")

#### Calculating outcome score values

The final step is calculating outcome, which is defined as the average of the seizure score and med score, which will give you a description of a patient's general state concerning seizures and anti-epileptic medications at a given point in time. The specific formula used to calculate outcome can be found in the EQUATIONS word document. 

Note that calculation of outcome cannot be done unless you have had both the SEIZURE_DATA_CLINICAL.xlsx and the MED_DATA_CLINICAL.xlsx files for that patient created by the seizure and med scripts.

To calculate outcome per 30 day period of time, type this into your R console:

``` {r eval=FALSE}
calculate_outcome()

First, the function will prompt you to enter the unique identifier (e.g. FiLa, denoting the first two letters of the patient's first name and the first two letters of the patient's last name) that signifies the patient you wish to run the script on.

``` {r echo=FALSE} print("Input the identifier that signify the patient we are doing calculations for") print("Example: FILA") patient <- readline(prompt="Enter here: PATIENT1")

Next, you will be asked to set the work directory in which the CLINIC_VISIT_SOURCE.xlsx file can be found in. 
Once the location of this file has been set, the script will look for a file named CLINIC_VISIT_SOURCE.xlsx and read it into R.

``` {r echo=FALSE}
print("Input the directory that you wish to draw the CLINIC_VISIT_SOURCE file from")
print("Example: C:/Folder_Name/")
directory <- readline(prompt="Enter here: C:/Desktop/Patient Folder/PATIENT1/Clinic_Visit/")

Then, R will need to load in the DEMOGRAPHICS_SOURCE.xlsx file. You will be asked whether this file exists in the same folder as the CLINIC_VISIT_SOURCE.xlsx file or not. If so, type 'yes'. If not, type 'no', and you will be prompted to specify the folder in which this file can be found on your computer.

``` {r echo=FALSE} print("Type 'yes' if the DEMOGRAPHICS_SOURCE file can be found in the same folder as the CLINIC_VISIT_SOURCE table. Type 'no' if it is in a different folder") answer <- readline(prompt="Enter here: no") print("Input the directory that you wish to draw the DEMOGRAPHICS_SOURCE file from") print("Example: C:/Folder_Name/") directory <- readline(prompt="Enter here: C:/Desktop/Patient Folder/PATIENT1/Demographics/")

Then, R will need to load in the SEIZURE_DATA_CLINICAL.xlsx file. You will be asked whether this file exists in the same folder as the DEMOGRAPHICS_SOURCE.xlsx file or not. If so, type 'yes'. If not, type 'no', and you will be prompted to specify the folder in which this file can be found on your computer.

``` {r echo=FALSE}
print("Type 'yes' if this patient's SEIZURE_DATA_CLINICAL file can be found in the same folder as the DEMOGRAPHICS_SOURCE table. Type 'no' if it is in a different folder")
answer <- readline(prompt="Enter here: no")
print("Input the directory that you wish to draw this patient's SEIZURE_DATA_CLINCAL file from")
print("Example: C:/Folder_Name/")
directory <- readline(prompt="Enter here: C:/Desktop/Patient Folder/PATIENT1/Data/")

Lastly, R will need to load in the MED_DATA_CLINICAL.xlsx file. You will be asked whether this file exists in the same folder as the SEIZURE_DATA_CLINICAL.xlsx file or not. If so, type 'yes'. If not, type 'no', and you will be prompted to specify the folder in which this file can be found on your computer.

``` {r echo=FALSE} print("Type 'yes' if this patient's MED_DATA_CLINICAL file can be found in the same folder as this patient's SEIZURE_DATA_CLINICAL table. Type 'no' if it is in a different folder") answer <- readline(prompt="Enter here: no") print("Input the directory that you wish to draw this patient's MED_DATA_CLINCAL file from") print("Example: C:/Folder_Name/") directory <- readline(prompt="Enter here: C:/Desktop/Patient Folder/PATIENT1/Data/")

Once the outcome values are calculated, you will be asked if you would like to save the OUTCOME_DATA_CLINICAL.xlsx file in the same location as the MED_DATA_CLINICAL.xlsx table. If so, type 'yes'. If not, type 'no' and you will be asked where you would like to save the file.

``` {r echo=FALSE}
print("Type 'yes' if you wish to save the OUTCOME_DATA_CLINICAL file in the same folder as this patient's MED_DATA_CLINICAL table. Type 'no' if you would like for it to be in a different folder")
answer <- readline(prompt="Enter here: no")
print("Input the directory that you wish to save this patient's OUTCOME_DATA_CLINICAL file in")
print("Example: C:/Folder_Name/")
directory <- readline(prompt="Enter here: C:/Desktop/Patient Folder/PATIENT1/Data/")
print("Saving data clinical outcome table as PATIENT1_OUTCOME_DATA_CLINICAL.xlsx in directory C:/Desktop/Patient Folder/PATIENT1/Data/")

R will then create for you three bar graphs: one for seizures, one for meds, and one for outcome. These graphs will show you the percentage of each clinic period that were 0-10% of what was observed during baseline, 10-80% of what was observed during baseline, or >80% than what was observed during baseline. Additionally, a table storing the values used to make each of those three graphs will be created and saved.

You will be asked where you would like to save these graphs and this file.

``` {r echo=FALSE} print("Type 'yes' if you wish to save all graphs in the same folder as this patient's OUTCOME_DATA_CLINICAL file. Type 'no' if you would like for it to be in a different folder") answer <- readline(prompt="Enter here: no") print("Input the directory that you wish to save this patient's graphs and MED_SEIZURE_OUTCOME_BAR_TABLE file in") print("Example: C:/Folder_Name/") directory <- readline(prompt="Enter here: C:/Desktop/Patient Folder/PATIENT1/Data/")

Then the graphs will be created and saved.

``` {r echo=FALSE}
print("Seizure bar graph created and saved")
print("Med bar graph created and saved")
print("Outcome bar graph created and saved")
img <- readPNG("G:/MySQL Database/Response/Example patient for package/PATIENT1_SEIZURE_BAR_GRAPH.png",native=TRUE)
plot(1:3,type='n',xlab="",ylab="",axes=FALSE)
rasterImage(img,xleft=1,ybottom=1,xright=3,ytop=3)
img <- readPNG("G:/MySQL Database/Response/Example patient for package/PATIENT1_MED_BAR_GRAPH.png",native=TRUE)
plot(1:3,type='n',xlab="",ylab="",axes=FALSE)
rasterImage(img,xleft=1,ybottom=1,xright=3,ytop=3)
img <- readPNG("G:/MySQL Database/Response/Example patient for package/PATIENT1_OUTCOME_BAR_GRAPH.png",native=TRUE)
plot(1:3,type='n',xlab="",ylab="",axes=FALSE)
rasterImage(img,xleft=1,ybottom=1,xright=3,ytop=3)

And then the MED_SEIZURE_OUTCOME_BAR_TABLE.xlsx file will be saved for you. You will be asked where you would like for this to be saved beforehand.

{r echo=FALSE} print("Type 'yes' if you wish to save this patient's MED_SEIZURE_OUTCOME_BAR_TABLE file in the same folder as this patient's OUTCOME_DATA_CLINICAL file. Type 'no' if you would like for it to be in a different folder") answer <- readline(prompt="Enter here: no") print("Input the directory that you wish to save this patient's MED_SEIZURE_OUTCOME_BAR_TABLE file in") print("Example: C:/Folder_Name/") directory <- readline(prompt="Enter here: C:/Desktop/Patient Folder/PATIENT1/Data/") print("Saving med/seizure/outcome bar table as PATIENT1_MED_SEIZURE_OUTCOME_BAR_TABLE.xlsx in directory C:/Desktop/Patient Folder/PATIENT1/Data")



borumlab/response documentation built on May 13, 2019, 12:36 a.m.