Search
 
SCRIPT & CODE EXAMPLE
 

R

r - split the data in queal ranges

library(mltools)

# Resulting bins have an equal number of observations in each group
das[, "wt2"] <- bin_data(das$wt, bins=3, binType = "quantile")

# Resulting bins are equally spaced from min to max
das[, "wt3"] <- bin_data(das$wt, bins=3, binType = "explicit")

# Or if you'd rather define the bins yourself
das[, "wt4"] <- bin_data(das$wt, bins=c(-Inf, 250, 322, Inf), binType = "explicit")

das
   anim    wt                                  wt2                                  wt3         wt4
1     1 181.0              [179, 200.333333333333)              [179, 250.666666666667) [-Inf, 250)
2     2 179.0              [179, 200.333333333333)              [179, 250.666666666667) [-Inf, 250)
3     3 180.5              [179, 200.333333333333)              [179, 250.666666666667) [-Inf, 250)
4     4 201.0 [200.333333333333, 245.466666666667)              [179, 250.666666666667) [-Inf, 250)
5     5 201.5 [200.333333333333, 245.466666666667)              [179, 250.666666666667) [-Inf, 250)
6     6 245.0 [200.333333333333, 245.466666666667)              [179, 250.666666666667) [-Inf, 250)
7     7 246.4              [245.466666666667, 394]              [179, 250.666666666667) [-Inf, 250)
8     8 189.3              [179, 200.333333333333)              [179, 250.666666666667) [-Inf, 250)
9     9 301.0              [245.466666666667, 394] [250.666666666667, 322.333333333333)  [250, 322)
10   10 354.0              [245.466666666667, 394]              [322.333333333333, 394]  [322, Inf]
11   11 369.0              [245.466666666667, 394]              [322.333333333333, 394]  [322, Inf]
12   12 205.0 [200.333333333333, 245.466666666667)              [179, 250.666666666667) [-Inf, 250)
13   13 199.0              [179, 200.333333333333)              [179, 250.666666666667) [-Inf, 250)
14   14 394.0              [245.466666666667, 394]              [322.333333333333, 394]  [322, Inf]
15   15 231.3 [200.333333333333, 245.466666666667)              [179, 250.666666666667) [-Inf, 250)
Comment

PREVIOUS NEXT
Code Example
R :: r performance matrix for confusion matrix 
R :: Edit axis labels R 
R :: colorblind-friendly palette in r 
R :: faceted bar chart in r 
R :: geom_jitter transparency 
R :: how to upload multiple excel files r 
R :: add column value based on row index r 
R :: r produce 10 alphabet 
R :: change the font of the title in a plot in r 
R :: Convert Values in Column into Row Names of DataFrame in R 
R :: r - if value in a df is between two number then add 1 
Rust :: hello world rust 
Rust :: create thread in rust 
Rust :: making a web server in rust 
Rust :: 2d vector rust 
Rust :: rust file extension 
Rust :: enum rust 
Rust :: armanriazi•rust•pattern•design•interior•mutability 
Rust :: rust new tuple 
Rust :: rust loop vector by size 
Rust :: armanriazi•rust•generic•monomorphization 
Rust :: rust return the result with trait exit status 
Rust :: Vector with multiple types in rust 
Rust :: execution duration 
Lua :: print table lua 
Lua :: luau make region3 
Lua :: roblox loop all players 
Lua :: keywords in lua 
Lua :: glua varargs 
Lua :: lua insert table into table 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =