Skip to content

Commit

Permalink
Merge pull request #16 from wendtke/siqi_scratch
Browse files Browse the repository at this point in the history
Siqi_scratch
  • Loading branch information
wendtke authored Jun 11, 2019
2 parents 47a24e4 + 4a4522b commit 0e5a43f
Show file tree
Hide file tree
Showing 26 changed files with 400 additions and 507 deletions.
3 changes: 2 additions & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
^psyr\.Rproj$
^psyphr\.Rproj$
^\.Rproj\.user$
^LICENSE\.md$
^README\.Rmd$
9 changes: 5 additions & 4 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Generated by roxygen2: do not edit by hand

export(rename_hrv_editing_columns)
export(transform_editing_sheet)
export(transform_hrv_sheet)
export(transform_settings_sheet)
export(bare_name)
export(read_MW_EDA)
export(read_MW_workbook)
export(rename_hrv_stats_columns)
export(tidy_MW_EDA)
30 changes: 0 additions & 30 deletions R/editing.R

This file was deleted.

17 changes: 0 additions & 17 deletions R/example_file_grab.R

This file was deleted.

47 changes: 0 additions & 47 deletions R/files.R

This file was deleted.

10 changes: 0 additions & 10 deletions R/grab_files.R

This file was deleted.

10 changes: 0 additions & 10 deletions R/grab_sheets.R

This file was deleted.

148 changes: 67 additions & 81 deletions R/rename.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#' Rename sheet columns after the sheet has been transformed.
#'
#' Functions to change the column names to be easier to use by later analysis scripts.
#' Functions to change the column names to be easier to use by later analysis
#' scripts.
#' They should only be called after transform_* has already been used.
#'
#' TODO: add error handling in case this is run before transform_* has been run,
#' and the column names are not as expected. I.e., detect whether the second
#' column name is a number, and if so,
#' exit out gracefully with a message to run transform_* function first.
#' TODO: Add error handling in case this is run before transform_* has been run,
#' and the column names are not as expected - i.e., detect whether the second
#' column name is a number, and if so, exit out gracefully with a message
#' to run transform_* function first.
#'
#' @param sheet
#'
Expand All @@ -19,94 +20,79 @@
#' rename_eda_stats_columns(sheet_data)
#' rename_hrv_editing_columns(sheet_data)
#'
#'
#'



rename_hrv_stats_columns <- function(sheet){
sheet <- sheet %>%
dplyr::rename(segment = segment,
start_time = `Start Time`,
end_time = `End Time`,
seg_length = `Segment Duration`,
mean_hr = `Mean Heart Rate`,
rsa = RSA,
mean_ibi = `Mean IBI`,
r_peaks = `# of R's Found`,
resp_rate = `Respiration Rate`,
resp_amp = `Respiration Amplitude`,
resp_peak_freq = `Respiration Peak Frequency`,
resp_power = `Respiration Power`,
first_r_time = `First ECG R Time`,
last_r_time = `Last ECG R Time`,
r_r_duration = `First R to Last R Duration`,
sdnn = SDNN,
avnn = AVNN,
rmssd = RMSSD,
nn50 = NN50,
pnn50 = pNN50)

sheet

sheet %>%
dplyr::rename(segment = `Segment Number`,
start_time = `Start Time`,
end_time = `End Time`,
seg_length = `Segment Duration`,
mean_hr = `Mean Heart Rate`,
rsa = RSA,
mean_ibi = `Mean IBI`,
r_peaks = `# of R's Found`,
resp_rate = `Respiration Rate`,
resp_amp = `Respiration Amplitude`,
resp_peak_freq = `Respiration Peak Frequency`,
resp_power = `Respiration Power`,
first_r_time = `First ECG R Time`,
last_r_time = `Last ECG R Time`,
r_r_duration = `First R to Last R Duration`,
sdnn = SDNN,
avnn = AVNN,
rmssd = RMSSD,
nn50 = NN50,
pnn50 = pNN50)
}



rename_hrv_editing_columns <- function(sheet) {
sheet <- sheet %>%
dplyr::rename(segment = segment,
ecg_sec_cut = `ECG : Seconds Removed`,
ecg_perc_cut = `ECG : Percentage Removed`,
ecg_sec_est = `ECG : Seconds Estimated`,
ecg_perc_est = `ECG : Percentage Estimated`,
resp_sec_cut = `Resp : Seconds Removed`,
resp_perc_cut = `Resp : Percentage Removed`,
resp_sec_est = `Resp : Seconds Estimated`,
resp_perc_est = `Resp : Percentage Estimated`,
total_r_peaks = `Total Peaks`,
norm_r_peaks = `Normal Peaks`,
norm_r_perc = `% Normal Peaks`,
est_r_peaks = `Estimated Peaks`,
est_r_peaks_perc = `% Estimated Peaks`,
art_r_peaks = `Artifact Peaks`,
art_r_peaks_perc = `% Artifact Peaks`,
dur_est_r_r = `Duration of Estimated R-R Intervals`,
est_r_r_perc = `% of Estimated R-R Intervals`)

sheet

sheet %>%
dplyr::rename(segment = `Segment Number`,
ecg_sec_cut = `ECG : Seconds Removed`,
ecg_perc_cut = `ECG : Percentage Removed`,
ecg_sec_est = `ECG : Seconds Estimated`,
ecg_perc_est = `ECG : Percentage Estimated`,
resp_sec_cut = `Resp : Seconds Removed`,
resp_perc_cut = `Resp : Percentage Removed`,
resp_sec_est = `Resp : Seconds Estimated`,
resp_perc_est = `Resp : Percentage Estimated`,
total_r_peaks = `Total Peaks`,
norm_r_peaks = `Normal Peaks`,
norm_r_perc = `% Normal Peaks`,
est_r_peaks = `Estimated Peaks`,
est_r_peaks_perc = `% Estimated Peaks`,
art_r_peaks = `Artifact Peaks`,
art_r_peaks_perc = `% Artifact Peaks`,
dur_est_r_r = `Duration of Estimated R-R Intervals`,
est_r_r_perc = `% of Estimated R-R Intervals`)
}


rename_eda_stats_columns <- function(sheet){
sheet <- sheet %>%
dpylr::rename(segment = segment,
start_time = `Start Time`,
end_time = `End Time`,
seg_length = `Segment Duration`,
total_scr = `Total SCRs`,
er_scr = `ER-SCRs`,
ns_scrs = `NS-SCRs`,
tonic_scl = `Tonic SCL`,
mean_sc = `Mean SC`,
tonic_period = `Tonic Period`)

sheet

sheet %>%
dplyr::rename(segment = `Segment Number`,
start_time = `Start Time`,
end_time = `End Time`,
seg_length = `Segment Duration`,
total_scr = `Total SCRs`,
er_scr = `ER-SCRs`,
ns_scrs = `NS-SCRs`,
tonic_scl = `Tonic SCL`,
mean_sc = `Mean SC`,
tonic_period = `Tonic Period`)
}



rename_eda_editing_columns <- function(sheet){
sheet <- sheet %>%
dplyr::rename(segment = segment,
eda_sec_cut = `EDA : Seconds Removed`,
eda_perc_cut = `EDA : Percentage Removed`,
eda_sec_est = `EDA : Seconds Estimated`,
eda_perc_est = `EDA : Percentage Estimated`,
resp_sec_cut = `Resp : Seconds Removed`,
resp_perc_cut = `Resp : Percentage Removed`,
resp_sec_est = `Resp : Seconds Estimated`,
resp_perc_est = `Resp : Percentage Estimated`)
sheet %>%
dplyr::rename(segment = `Segment Number`,
eda_sec_cut = `EDA : Seconds Removed`,
eda_perc_cut = `EDA : Percentage Removed`,
eda_sec_est = `EDA : Seconds Estimated`,
eda_perc_est = `EDA : Percentage Estimated`,
resp_sec_cut = `Resp : Seconds Removed`,
resp_perc_cut = `Resp : Percentage Removed`,
resp_sec_est = `Resp : Seconds Estimated`,
resp_perc_est = `Resp : Percentage Estimated`)
}
23 changes: 0 additions & 23 deletions R/settings.R

This file was deleted.

29 changes: 0 additions & 29 deletions R/stats.R

This file was deleted.

Loading

0 comments on commit 0e5a43f

Please sign in to comment.