fix_numerics {clickR}R Documentation

Fix numeric data

Description

Fixes numeric data. In many cases, numeric data are not recognized by R because there are data inconsistencies (wrong decimal separator, whitespaces, typos, thousand separator, etc.). fix_numerics detects and corrects these variables, making them numeric again.

Usage

fix_numerics(
  x,
  k = 8,
  max.NA = 0.2,
  select = 1:ncol(x),
  track = TRUE,
  parallel = TRUE
)

Arguments

x

A data.frame

k

Minimum number of different values a variable has to have to be considered numerical

max.NA

Maximum allowed proportion of NA values created by coercion. If the coercion to numeric creates more NA values than those specified in max.NA, then all changes will be reverted and the variable will remain unchanged.

select

Numeric vector with the positions (all by default) to be affected by the function

track

Keep track of changes?

parallel

Should the computations be performed in parallel? Set up strategy first with future::plan()

Examples

mydata<-data.frame(Numeric1=c(7.8, 9.2, "5.4e+2", 3.3, "6,8", "3..3"),
                   Numeric2=c(3.1, 1.2, "3.4s", "48,500.04 $", 7, "$  6.4"))
descriptive(mydata)
descriptive(fix_numerics(mydata, k=5))

[Package clickR version 0.9.39 Index]