replaceByCondition | R Documentation |
Replace Values in Column in Rows Matching Condition
replaceByCondition(df, file = NULL, group = NULL, config = NULL, dbg = TRUE)
df |
data frame in which to do substitutions |
file |
path to CSV file with columns |
group |
group name. If given, only rows in |
config |
optional. Data frame containing the configuration as being read
from |
dbg |
if |
# Create a very simple data frame df <- data.frame(a = 1:3) # Create a very simple configuration config <- read.table(sep = ",", header = TRUE, text = c( "group,target,condition,replacement", "g1,a,a==2,22", "g2,a,a==3,33" )) # Write the configuration to a temporary file file <- tempfile() write.csv(config, file) # Apply all replacements configured in the file ... replaceByCondition(df, file) # ... or in the configuration replaceByCondition(df, config = config) # Apply selected replacements replaceByCondition(df, file, group = "g1") replaceByCondition(df, file, group = "g2")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.