getUniques: Trim Data.Frame To Unique Values Only

Description Usage Arguments Value Examples

Description

This function is used to remove any rows in a data.frame with repeated elements. It is necessary in grammaR because if we have two keys with the value "said" in the dictionary, one will override the other when we do things like spin a story up from plain text.

Usage

1
getUniques(df, colname = "val")

Arguments

df

The data.frame to check; should have a column named "val" or a character value in "colname" parameter.

colname

The name of the column to search and clean by.

Value

This function returns a data.frame with only unique values. It also removes any stray "|" symbols.

Examples

1
2
3
4
## removing uniques, cleaning out | symbols
sampleDf <- data.frame(key=c("<rubber>", "<joy>", "<hangar>"),
       val=c("farm", "farm", "toys |"), stringsAsFactors=F)
 getUniques(sampleDf)

ecology-rocks/grammaR documentation built on May 15, 2019, 7:58 p.m.