Title: | Miscellaneous Functions |
---|---|
Description: | The Author's personal R Package that contains miscellaneous functions. The current version of package contains miscellaneous functions for brain data to compute Asymmetry Index (AI) and bilateral (L+R) measures and reshape the data. |
Authors: | Yoo Ri Hwang [aut, cre] |
Maintainer: | Yoo Ri Hwang <[email protected]> |
License: | GPL (>= 2) |
Version: | 0.1.0 |
Built: | 2024-11-12 03:24:30 UTC |
Source: | https://github.com/yrhwang90/ymisc |
AI formula = [(left-right)/(left+right)]. compute_AI() creates new columns that are AIs of the brain measures using the most widely-used formula.
compute_AI( data = sample_data, left_hemisphere = "lh", right_hemisphere = "rh", separator = "_", ID = "ID", hemisphere = "prefix", start, end )
compute_AI( data = sample_data, left_hemisphere = "lh", right_hemisphere = "rh", separator = "_", ID = "ID", hemisphere = "prefix", start, end )
data |
The wide format data |
left_hemisphere |
The prefix or suffix that indicates the left hemisphere in the variable names |
right_hemisphere |
The prefix or suffix string that indicates the right hemisphere in the variable names |
separator |
A character vector that separates characters in the variable names. |
ID |
The column of identifiers. |
hemisphere |
The character vector that indicates whether a hemisphere indicator in the variable names is a prefix or suffix. |
start |
The column that specifies the starting point of a set of variables to calculate the AIs. |
end |
The column that specifies the endpoint of a set of variables to calculate the AIs. |
The data with AIs.
data(sample_data) compute_AI(sample_data, left_hemisphere = "lh", right_hemisphere = "rh", separator="_", ID="ID", hemisphere="prefix", start="lh_Thalamus", end="rh_AccumbensArea")
data(sample_data) compute_AI(sample_data, left_hemisphere = "lh", right_hemisphere = "rh", separator="_", ID="ID", hemisphere="prefix", start="lh_Thalamus", end="rh_AccumbensArea")
compute_total() creates new columns that are the bilateral (Left + Right) measures.
compute_total( data = sample_data, left_hemisphere = "lh", right_hemisphere = "rh", separator = "_", ID = "ID", hemisphere = "prefix", start, end )
compute_total( data = sample_data, left_hemisphere = "lh", right_hemisphere = "rh", separator = "_", ID = "ID", hemisphere = "prefix", start, end )
data |
The wide format data |
left_hemisphere |
The prefix or suffix that indicates the left hemisphere in the variable names |
right_hemisphere |
The prefix or suffix string that indicate the right hemisphere in the variable names |
separator |
A character vector that separates characters in the variable names. |
ID |
The column of identifiers. |
hemisphere |
The character vector that indicates whether a hemisphere indicator in the variable names is a prefix or suffix. |
start |
The column that specifies the starting point of a set of variables to calculate the bilateral (L+R) measures. |
end |
The column that specifies the endpoint of a set of variables to calculate the bilateral (L+R) measures. |
The data with the bilateral (L+R) measures.
data(sample_data) compute_total(sample_data, left_hemisphere="lh", right_hemisphere="rh", separator="_", ID="ID", hemisphere="prefix", start="lh_Thalamus", end="rh_AccumbensArea")
data(sample_data) compute_total(sample_data, left_hemisphere="lh", right_hemisphere="rh", separator="_", ID="ID", hemisphere="prefix", start="lh_Thalamus", end="rh_AccumbensArea")
Long Format Sample Data
long
long
A long format data frame.
The regional brain measures from left and right hemisphere, attention check, and ID
long2wide() is data-reshaping function for long format data. This function mainly targets the brain structure data that contains the data from the left and right hemispheres
long2wide(data, ID = "ID", separator = "_", hemisphere = "prefix", start, end)
long2wide(data, ID = "ID", separator = "_", hemisphere = "prefix", start, end)
data |
The long format data. |
ID |
The column of identifiers. |
separator |
A character vector that separates characters in the variable names. |
hemisphere |
The character vector that indicates whether a hemisphere indicator in the variable names is the prefix or suffix. At this point, only a "prefix" option is available. |
start |
The column that specifies the starting point of a set of variables to be reshaped. |
end |
The column that specifies the endpoint of a set of variables to be reshaped. |
The wide format data
data(long) long2wide( data=long, ID="ID", separator="_", hemisphere="prefix", start="region", end="rh")
data(long) long2wide( data=long, ID="ID", separator="_", hemisphere="prefix", start="region", end="rh")
Wide Format Sample Data
sample_data
sample_data
A wide format data frame.
The regional brain measures from left and right hemisphere, attention check, and ID.
wide2long() function is data-reshaping function for wide format data. This function mainly targets the brain structure data that contains the data from the left and right hemispheres
wide2long(data, ID = "ID", separator = "_", hemisphere = "prefix", start, end)
wide2long(data, ID = "ID", separator = "_", hemisphere = "prefix", start, end)
data |
The wide format data. |
ID |
The column of identifiers. |
separator |
A character vector that separates characters in the variable names. |
hemisphere |
Whether a hemisphere indicator in the variable names is a prefix or suffix. At this point, only the "prefix" option is available. |
start |
The column that specifies the starting point of a set of variables to be reshaped |
end |
The column that specifies the endpoint of a set of variables to be reshaped |
The long format data
data(sample_data) long<-wide2long( data=sample_data, ID="ID", separator="_", start="lh_Thalamus", end="rh_AccumbensArea", hemisphere="prefix" )
data(sample_data) long<-wide2long( data=sample_data, ID="ID", separator="_", start="lh_Thalamus", end="rh_AccumbensArea", hemisphere="prefix" )