Change the formatting of data in column(s) of a dataframe to either human readable or numeric

to_df(
  df,
  col_names = NULL,
  transform_type = "human",
  family = "number",
  errors = "raise",
  ...
)

Arguments

df

dataframe, dataframe to apply formatting

col_names

str or vector, column names to apply formatting (default is all columns)

transform_type

str, type of transformation (e.g. human, num)

family

str, family of suffix, numeric or filesize

errors

'raise', 'coerce', default 'raise' If 'raise', then invalid parsing will raise an exception. If 'coerce', then invalid parsing will return NA.

...

Additional formatting arguments separated by commas, e.g. 'prec'. See full documentation for more details.

Value

dataframe with formatting applied

Examples

df <- data.frame(A = c(1000, 10000), B = c(1000000, 100000)) to_df(df, col_names = c("A", "B"), transform_type = "human")
#> A B #> 1 1K 1M #> 2 10K 100K