Package 'Ymisc'

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

Help Index


The brain asymmetry index (AI)

Description

AI formula = [(left-right)/(left+right)]. compute_AI() creates new columns that are AIs of the brain measures using the most widely-used formula.

Usage

compute_AI(
  data = sample_data,
  left_hemisphere = "lh",
  right_hemisphere = "rh",
  separator = "_",
  ID = "ID",
  hemisphere = "prefix",
  start,
  end
)

Arguments

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.

Value

The data with AIs.

Examples

data(sample_data)

compute_AI(sample_data,
left_hemisphere = "lh",
right_hemisphere = "rh",
separator="_",
ID="ID",
hemisphere="prefix",
start="lh_Thalamus",
end="rh_AccumbensArea")

the bilateral (Left + Right) measures.

Description

compute_total() creates new columns that are the bilateral (Left + Right) measures.

Usage

compute_total(
  data = sample_data,
  left_hemisphere = "lh",
  right_hemisphere = "rh",
  separator = "_",
  ID = "ID",
  hemisphere = "prefix",
  start,
  end
)

Arguments

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.

Value

The data with the bilateral (L+R) measures.

Examples

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

Description

Long Format Sample Data

Usage

long

Format

A long format data frame.

The regional brain measures from left and right hemisphere, attention check, and ID


Reshapes the data

Description

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

Usage

long2wide(data, ID = "ID", separator = "_", hemisphere = "prefix", start, end)

Arguments

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.

Value

The wide format data

Examples

data(long)

long2wide(
data=long,
ID="ID",
separator="_",
hemisphere="prefix",
start="region",
end="rh")

Wide Format Sample Data

Description

Wide Format Sample Data

Usage

sample_data

Format

A wide format data frame.

The regional brain measures from left and right hemisphere, attention check, and ID.


Reshapes the data

Description

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

Usage

wide2long(data, ID = "ID", separator = "_", hemisphere = "prefix", start, end)

Arguments

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

Value

The long format data

Examples

data(sample_data)

long<-wide2long(
data=sample_data,
ID="ID",
separator="_",
start="lh_Thalamus",
end="rh_AccumbensArea",
hemisphere="prefix"
)