Convert dataframe to YAML.

df2yaml(
  df,
  key_col,
  val_col,
  val_sep = ";",
  key_sep = ":",
  rm_quote = TRUE,
  out_yaml = NULL
)

Arguments

df

Dataframe.

key_col

The columns used as keys.

val_col

The columns used as values, this column can contain key: value pairs.

val_sep

The separator used to seperate different key:value pairs in val_col. Default: ";".

key_sep

The separator used to seperate key and value. Default: ":".

rm_quote

Logical value, whether to remove single quotes. Default: TRUE.

out_yaml

Output YAML file. Default: NULL (return string).

Value

NULL (write YAML) or string (if out_yaml is NULL).

Examples

library(df2yaml) test_file <- system.file("extdata", "df2yaml_l3.txt", package = "df2yaml") test_data <- read.table(file = test_file, header = TRUE, sep = "\t") df2yaml(df = test_data, key_col = c("paras", "subcmd"), val_col = "values")
#> [1] "preseq: -r 100 -seg_len 100000000\nqualimap: --java-mem-size=20G -outformat HTML\nrseqc:\n mapq: 30\n percentile-floor: 5\n percentile-step: 5\npicard:\n insert_size:\n MINIMUM_PCT: 0.5\n markdup:\n CREATE_INDEX: true\n VALIDATION_STRINGENCY: SILENT\n"