once_only: Efficiently find rows where a the value appears only once in...

Description Usage Arguments Details Value Examples

View source: R/once_only.R

Description

Returns a data frame of values which only appear once in a df column.

Usage

1
once_only(data_frame, column, return_column_only = TRUE)

Arguments

data_frame

a data frame to read in

column

the column in the data frame to check

return_column_only

should the function return the whole data frame or just the column?

Details

Returns only the rows from a data frame if there is only one instance of the value in the specified column. This method is more efficient than grouping by the column and then filtering for rows with a count == 1.

Setting the return_column_only = TRUE will return the data frame with all of the instances where the value of column appears more than once removed.

Value

A dataframe of values from the column which aren't duplicated.

Examples

1
2
3
4
5
mtcars$model <- rownames(mtcars)
# just the values from the column which appear only once
once_only(mtcars,"mpg")
# the rows for the values of the column appears once only
y <- once_only(mtcars,"mpg", return_column_only = FALSE )

MarkGoble/mishMashr documentation built on Oct. 12, 2020, 8:24 p.m.