Description Usage Arguments Details Value Examples
View source: R/pedigree_transformation_tbl_df.R
Changing certain variables or fields (columns in tbl_df) of a given set of records is done by a combination of dplyr::mutate to change the variables and dplyr::if_else() to specify in which rows the variables should be changed. The re-factoring work to integrate this operation into a function is done based on the material available at http://dplyr.tidyverse.org/articles/programming.html
1 | set_field_na(ptbl_pedigree, pvec_rec_pk, ps_field_name, ps_pk_name)
|
ptbl_pedigree |
pedigree as tbl_df |
pvec_rec_pk |
vector of primary keys identifying the records |
ps_field_name |
column name in ptbl_pedigree where certain fields must be set to NA |
ps_pk_name |
column name where primary keys can be found |
When previous functions were working with column indices to identify the variables or fields in the tbl_df, this function here switched to the use of column names. For a given pedigree, we have to define utility functions that return the column name for certain record fields.
tbl_pedigree_result pedigree with given fields set to NA
1 2 3 4 5 6 | s_ped_file <- system.file(file.path("extdata","KLDAT_20170524_10000.txt"),
package = "PedigreeFromTvdData")
tbl_ped <- laf_open_fwf_tvd_input(ps_input_file = s_ped_file)
vec_rec_tbd_pk <- c("CH120001976905", "CH120006405592", "CH120001807094", "CH120003434748")
tbl_ped_vna <- set_field_na(tbl_ped, vec_rec_pk, V5, V12)
tbl_ped_vna %>% filter(V12 %in% vec_rec_pk) %>% select(V5,V11,V12,V16)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.