An Empirical Percentile Transformation (percentize) is similar to taking the rank of a variable. The difference is that it is simpler to compare and interpret the transformed variables.

This is helpful for comparing several variables in a heatmap (e.g.: heatmaply).

percentize(x, ...)

Arguments

x

a vector or a data.frame.

...

Currently ignored.

Value

A vector (or data.frame) after ecdf was used on that vector. If x is a data.frame then only the numeric variables are transformed.

See also

Examples

# \dontrun{ x <- mtcars x <- data.frame(x) x$am <- factor(x$am) x$vs <- factor(x$vs) heatmaply(percentize(x))
#> Warning: 'heatmap' objects don't have these attributes: 'showlegend' #> Valid attributes include: #> 'type', 'visible', 'opacity', 'name', 'uid', 'ids', 'customdata', 'meta', 'hoverinfo', 'hoverlabel', 'stream', 'transforms', 'uirevision', 'z', 'x', 'x0', 'dx', 'y', 'y0', 'dy', 'text', 'hovertext', 'transpose', 'xtype', 'ytype', 'zsmooth', 'connectgaps', 'xgap', 'ygap', 'zhoverformat', 'hovertemplate', 'zauto', 'zmin', 'zmax', 'zmid', 'colorscale', 'autocolorscale', 'reversescale', 'showscale', 'colorbar', 'coloraxis', 'xcalendar', 'ycalendar', 'xaxis', 'yaxis', 'idssrc', 'customdatasrc', 'metasrc', 'hoverinfosrc', 'zsrc', 'xsrc', 'ysrc', 'textsrc', 'hovertextsrc', 'hovertemplatesrc', 'key', 'set', 'frame', 'transforms', '_isNestedKey', '_isSimpleKey', '_isGraticule', '_bbox'
x <- data.frame(a = 1:10, b = 11:20) x[4:6, 1:2] <- NA percentize(x)
#> a b #> 1 0.1428571 0.1428571 #> 2 0.2857143 0.2857143 #> 3 0.4285714 0.4285714 #> 4 NA NA #> 5 NA NA #> 6 NA NA #> 7 0.5714286 0.5714286 #> 8 0.7142857 0.7142857 #> 9 0.8571429 0.8571429 #> 10 1.0000000 1.0000000
percentize(x[,1])
#> [1] 0.1428571 0.2857143 0.4285714 NA NA NA 0.5714286 #> [8] 0.7142857 0.8571429 1.0000000
# }