unique_non_numerics: find all unique non-numeric values

Description Usage Arguments Details See Also Examples

View source: R/non_numerics.R

Description

find all unique non-numeric values

Usage

1

Arguments

x

vector to check on

na.rm

remove existing na values before checking

Details

This function is especially useful for figuring out what non-numeric unique values are in in a column that should be numeric so one can easily replace them with another flag. This function can work well with replace_char_flags instead of using nested ifelse statements

See Also

replace_values: to use to replace non-numeric values in a dataframe.

Examples

1
2
3
4
5
6
7
8
dv <- c(1, 2, 4, "88 (excluded)", "bql", "*")
unique_non_numerics(dv)
df <- tibble::data_frame(ID = 1:3, DV = c("BQL", 0.5, 9))
unique_non_numerics(df$DV)

#using dplyr
library(dplyr)
df %>% filter(!(DV %in% unique_non_numerics(DV)))

Example output

[1] "88 (excluded)" "bql"           "*"            
Warning message:
`data_frame()` is deprecated, use `tibble()`.
This warning is displayed once per session. 
[1] "BQL"

Attaching package: 'dplyr'

The following objects are masked from 'package:stats':

    filter, lag

The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union

# A tibble: 2 x 2
     ID DV   
  <int> <chr>
1     2 0.5  
2     3 9    

PKPDmisc documentation built on April 14, 2020, 5:49 p.m.