View source: R/utility_functions.R
rename_viewr_characters | R Documentation |
Quick utility function to use str_replace with mutate(across()) to batch- rename subjects via pattern detection.
rename_viewr_characters(
obj_name,
target_column = "subject",
pattern,
replacement = ""
)
obj_name |
The input viewr object; a tibble or data.frame with attribute
|
target_column |
The target column; defaults to "subject" |
pattern |
The (regex) pattern to be replaced |
replacement |
The replacement text. Must be a character |
A tibble or data frame in which subjects have been renamed according
to the pattern
and replacement
supplied by the user.
Vikram B. Baliga
Other data cleaning functions:
gather_tunnel_data()
,
get_full_trajectories()
,
quick_separate_trajectories()
,
redefine_tunnel_center()
,
relabel_viewr_axes()
,
rotate_tunnel()
,
select_x_percent()
,
separate_trajectories()
,
standardize_tunnel()
,
trim_tunnel_outliers()
,
visualize_frame_gap_choice()
## Import the example Motive data included in the package
motive_data <-
read_motive_csv(system.file("extdata", "pathviewr_motive_example_data.csv",
package = 'pathviewr'))
## Clean the file. It is generally recommended to clean up to the
## "gather" step before running rescale_tunnel_data().
motive_gathered <-
motive_data %>%
relabel_viewr_axes() %>%
gather_tunnel_data()
## See the subject names
unique(motive_gathered$subject)
## Now rename the subjects. We'll get rid of "device" and replace it
## with "subject"
motive_renamed <-
motive_gathered %>%
rename_viewr_characters(target_column = "subject",
pattern = "device",
replacement = "subject")
## See the new subject names
unique(motive_renamed$subject)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.