For a dataset's custom_R_code, on data with one row per trait value. Every row whose value in values_column is one of original_values is reassigned to new_trait, by rewriting its traits_column. Values themselves are not changed.

move_values_to_new_trait_long(
  data,
  original_trait,
  new_trait,
  traits_column,
  values_column,
  original_values,
  to_lower = FALSE
)

Arguments

data

Data frame of the dataset, typically data.csv as read by the build

original_trait

Name of the trait the values are taken from. Not used for matching: see Details

new_trait

Name of the trait to move the matched rows to

traits_column

Name of the column holding trait names

values_column

Name of the column holding trait values

original_values

Values to move

to_lower

Match original_values ignoring case? Values are compared lower-cased but left as they are. Default FALSE.

Value

data, with the matched rows reassigned to new_trait

Details

Rows are matched on their value alone, whatever trait they belong to: original_trait is not used. It is kept so that existing calls, which pass it, still work, and so that a call reads as the trait the values are taken from.

See also

move_values_to_new_trait() for data with one column per trait

Examples

data <- tibble::tibble(
  trait = c("Texture", "Texture", "Texture"),
  value = c("plumose", "smooth", "Tomentose")
)

data %>%
  move_values_to_new_trait_long(
    "Texture", "seed_surface_hairs", "trait", "value",
    c("plumose", "tomentose"),
    to_lower = TRUE
  )
#> # A tibble: 3 × 2
#>   trait              value    
#>   <chr>              <chr>    
#> 1 seed_surface_hairs plumose  
#> 2 Texture            smooth   
#> 3 seed_surface_hairs Tomentose