The following document shows various data analysis operations performed using both data.table and dplyr.



Note: If you wish to replicate the R code below, then you will need to copy and paste the following commands in R first (to make sure you have all the packages and their dependencies):

install.packages("install.load")
# install the install.load package

install.load::install_load("dplyr", "data.table", "NISTunits", "htmlTable")
# install and/or load the packages and their dependencies


This document was created with rmarkdown 1.2 using the following:



install.load::load_package("dplyr", "data.table", "NISTunits", "htmlTable")
# load needed packages using the load_package function from the install.load
# package (it is assumed that you have already installed these packages)


# using the mtcars data set
mtcars <- mtcars


# create the character vector names_mtcars to store the row.names of the
# mtcars data set for later use
names_mtcars <- c("Mazda RX4", "Mazda RX4 Wag", "Datsun 710", "Hornet 4 Drive", 
    "Hornet Sportabout", "Valiant", "Duster 360", "Merc 240D", "Merc 230", "Merc 280", 
    "Merc 280C", "Merc 450SE", "Merc 450SL", "Merc 450SLC", "Cadillac Fleetwood", 
    "Lincoln Continental", "Chrysler Imperial", "Fiat 128", "Honda Civic", "Toyota Corolla", 
    "Toyota Corona", "Dodge Challenger", "AMC Javelin", "Camaro Z28", "Pontiac Firebird", 
    "Fiat X1-9", "Porsche 914-2", "Lotus Europa", "Ford Pantera L", "Ferrari Dino", 
    "Maserati Bora", "Volvo 142E")


# view mtcars as an html table
htmlTable(mtcars, rnames = FALSE, align = "c", align.header = "c", css.cell = "padding-left: 0.5em; padding-right: 1.5em;")
mpg cyl disp hp drat wt qsec vs am gear carb
21 6 160 110 3.9 2.62 16.46 0 1 4 4
21 6 160 110 3.9 2.875 17.02 0 1 4 4
22.8 4 108 93 3.85 2.32 18.61 1 1 4 1
21.4 6 258 110 3.08 3.215 19.44 1 0 3 1
18.7 8 360 175 3.15 3.44 17.02 0 0 3 2
18.1 6 225 105 2.76 3.46 20.22 1 0 3 1
14.3 8 360 245 3.21 3.57 15.84 0 0 3 4
24.4 4 146.7 62 3.69 3.19 20 1 0 4 2
22.8 4 140.8 95 3.92 3.15 22.9 1 0 4 2
19.2 6 167.6 123 3.92 3.44 18.3 1 0 4 4
17.8 6 167.6 123 3.92 3.44 18.9 1 0 4 4
16.4 8 275.8 180 3.07 4.07 17.4 0 0 3 3
17.3 8 275.8 180 3.07 3.73 17.6 0 0 3 3
15.2 8 275.8 180 3.07 3.78 18 0 0 3 3
10.4 8 472 205 2.93 5.25 17.98 0 0 3 4
10.4 8 460 215 3 5.424 17.82 0 0 3 4
14.7 8 440 230 3.23 5.345 17.42 0 0 3 4
32.4 4 78.7 66 4.08 2.2 19.47 1 1 4 1
30.4 4 75.7 52 4.93 1.615 18.52 1 1 4 2
33.9 4 71.1 65 4.22 1.835 19.9 1 1 4 1
21.5 4 120.1 97 3.7 2.465 20.01 1 0 3 1
15.5 8 318 150 2.76 3.52 16.87 0 0 3 2
15.2 8 304 150 3.15 3.435 17.3 0 0 3 2
13.3 8 350 245 3.73 3.84 15.41 0 0 3 4
19.2 8 400 175 3.08 3.845 17.05 0 0 3 2
27.3 4 79 66 4.08 1.935 18.9 1 1 4 1
26 4 120.3 91 4.43 2.14 16.7 0 1 5 2
30.4 4 95.1 113 3.77 1.513 16.9 1 1 5 2
15.8 8 351 264 4.22 3.17 14.5 0 1 5 4
19.7 6 145 175 3.62 2.77 15.5 0 1 5 6
15 8 301 335 3.54 3.57 14.6 0 1 5 8
21.4 4 121 109 4.11 2.78 18.6 1 1 4 2
# create mtcars1 as a data.frame from mtcars (for use with dplyr)
mtcars1 <- mtcars


# create Car column with the automobile names (for use with dplyr)
mtcars1$Car <- names_mtcars


# create mtcars2 as a data.table from mtcars (for use with data.table)
mtcars2 <- mtcars
mtcars2 <- setDT(mtcars2)


# create Car column with the automobile names with data.table
mtcars2[, `:=`(Car, names_mtcars)]


# add in a column for the kilometers per Liter (kpL) using data.table
mtcars2[, `:=`(kpL, round(NISTmilePerGallonTOkmPerLiter(mpg), digits = 1))]

# add in a column for the kilometers per Liter (kpL) using dplyr's mutate
mtcars1 <- mutate(mtcars1, kPL = round(NISTmilePerGallonTOkmPerLiter(mpg), digits = 1))
# Source 2


# change the column order using data.table
setcolorder(mtcars2, c(12, 1, 13, 2:11))

# using dplyr
mtcars1 <- mtcars1 %>% select(Car, mpg, kPL, cyl:carb)
# Source 1


# view mtcars1 and mtcars2 as an html table
htmlTable(mtcars1, rnames = FALSE, align = "c", align.header = "c", css.cell = "padding-left: 0.5em; padding-right: 1.5em;")
Car mpg kPL cyl disp hp drat wt qsec vs am gear carb
Mazda RX4 21 8.9 6 160 110 3.9 2.62 16.46 0 1 4 4
Mazda RX4 Wag 21 8.9 6 160 110 3.9 2.875 17.02 0 1 4 4
Datsun 710 22.8 9.7 4 108 93 3.85 2.32 18.61 1 1 4 1
Hornet 4 Drive 21.4 9.1 6 258 110 3.08 3.215 19.44 1 0 3 1
Hornet Sportabout 18.7 8 8 360 175 3.15 3.44 17.02 0 0 3 2
Valiant 18.1 7.7 6 225 105 2.76 3.46 20.22 1 0 3 1
Duster 360 14.3 6.1 8 360 245 3.21 3.57 15.84 0 0 3 4
Merc 240D 24.4 10.4 4 146.7 62 3.69 3.19 20 1 0 4 2
Merc 230 22.8 9.7 4 140.8 95 3.92 3.15 22.9 1 0 4 2
Merc 280 19.2 8.2 6 167.6 123 3.92 3.44 18.3 1 0 4 4
Merc 280C 17.8 7.6 6 167.6 123 3.92 3.44 18.9 1 0 4 4
Merc 450SE 16.4 7 8 275.8 180 3.07 4.07 17.4 0 0 3 3
Merc 450SL 17.3 7.4 8 275.8 180 3.07 3.73 17.6 0 0 3 3
Merc 450SLC 15.2 6.5 8 275.8 180 3.07 3.78 18 0 0 3 3
Cadillac Fleetwood 10.4 4.4 8 472 205 2.93 5.25 17.98 0 0 3 4
Lincoln Continental 10.4 4.4 8 460 215 3 5.424 17.82 0 0 3 4
Chrysler Imperial 14.7 6.2 8 440 230 3.23 5.345 17.42 0 0 3 4
Fiat 128 32.4 13.8 4 78.7 66 4.08 2.2 19.47 1 1 4 1
Honda Civic 30.4 12.9 4 75.7 52 4.93 1.615 18.52 1 1 4 2
Toyota Corolla 33.9 14.4 4 71.1 65 4.22 1.835 19.9 1 1 4 1
Toyota Corona 21.5 9.1 4 120.1 97 3.7 2.465 20.01 1 0 3 1
Dodge Challenger 15.5 6.6 8 318 150 2.76 3.52 16.87 0 0 3 2
AMC Javelin 15.2 6.5 8 304 150 3.15 3.435 17.3 0 0 3 2
Camaro Z28 13.3 5.7 8 350 245 3.73 3.84 15.41 0 0 3 4
Pontiac Firebird 19.2 8.2 8 400 175 3.08 3.845 17.05 0 0 3 2
Fiat X1-9 27.3 11.6 4 79 66 4.08 1.935 18.9 1 1 4 1
Porsche 914-2 26 11.1 4 120.3 91 4.43 2.14 16.7 0 1 5 2
Lotus Europa 30.4 12.9 4 95.1 113 3.77 1.513 16.9 1 1 5 2
Ford Pantera L 15.8 6.7 8 351 264 4.22 3.17 14.5 0 1 5 4
Ferrari Dino 19.7 8.4 6 145 175 3.62 2.77 15.5 0 1 5 6
Maserati Bora 15 6.4 8 301 335 3.54 3.57 14.6 0 1 5 8
Volvo 142E 21.4 9.1 4 121 109 4.11 2.78 18.6 1 1 4 2
htmlTable(mtcars2, rnames = FALSE, align = "c", align.header = "c", css.cell = "padding-left: 0.5em; padding-right: 1.5em;")
Car mpg kpL cyl disp hp drat wt qsec vs am gear carb
Mazda RX4 21 8.9 6 160 110 3.9 2.62 16.46 0 1 4 4
Mazda RX4 Wag 21 8.9 6 160 110 3.9 2.875 17.02 0 1 4 4
Datsun 710 22.8 9.7 4 108 93 3.85 2.32 18.61 1 1 4 1
Hornet 4 Drive 21.4 9.1 6 258 110 3.08 3.215 19.44 1 0 3 1
Hornet Sportabout 18.7 8 8 360 175 3.15 3.44 17.02 0 0 3 2
Valiant 18.1 7.7 6 225 105 2.76 3.46 20.22 1 0 3 1
Duster 360 14.3 6.1 8 360 245 3.21 3.57 15.84 0 0 3 4
Merc 240D 24.4 10.4 4 146.7 62 3.69 3.19 20 1 0 4 2
Merc 230 22.8 9.7 4 140.8 95 3.92 3.15 22.9 1 0 4 2
Merc 280 19.2 8.2 6 167.6 123 3.92 3.44 18.3 1 0 4 4
Merc 280C 17.8 7.6 6 167.6 123 3.92 3.44 18.9 1 0 4 4
Merc 450SE 16.4 7 8 275.8 180 3.07 4.07 17.4 0 0 3 3
Merc 450SL 17.3 7.4 8 275.8 180 3.07 3.73 17.6 0 0 3 3
Merc 450SLC 15.2 6.5 8 275.8 180 3.07 3.78 18 0 0 3 3
Cadillac Fleetwood 10.4 4.4 8 472 205 2.93 5.25 17.98 0 0 3 4
Lincoln Continental 10.4 4.4 8 460 215 3 5.424 17.82 0 0 3 4
Chrysler Imperial 14.7 6.2 8 440 230 3.23 5.345 17.42 0 0 3 4
Fiat 128 32.4 13.8 4 78.7 66 4.08 2.2 19.47 1 1 4 1
Honda Civic 30.4 12.9 4 75.7 52 4.93 1.615 18.52 1 1 4 2
Toyota Corolla 33.9 14.4 4 71.1 65 4.22 1.835 19.9 1 1 4 1
Toyota Corona 21.5 9.1 4 120.1 97 3.7 2.465 20.01 1 0 3 1
Dodge Challenger 15.5 6.6 8 318 150 2.76 3.52 16.87 0 0 3 2
AMC Javelin 15.2 6.5 8 304 150 3.15 3.435 17.3 0 0 3 2
Camaro Z28 13.3 5.7 8 350 245 3.73 3.84 15.41 0 0 3 4
Pontiac Firebird 19.2 8.2 8 400 175 3.08 3.845 17.05 0 0 3 2
Fiat X1-9 27.3 11.6 4 79 66 4.08 1.935 18.9 1 1 4 1
Porsche 914-2 26 11.1 4 120.3 91 4.43 2.14 16.7 0 1 5 2
Lotus Europa 30.4 12.9 4 95.1 113 3.77 1.513 16.9 1 1 5 2
Ford Pantera L 15.8 6.7 8 351 264 4.22 3.17 14.5 0 1 5 4
Ferrari Dino 19.7 8.4 6 145 175 3.62 2.77 15.5 0 1 5 6
Maserati Bora 15 6.4 8 301 335 3.54 3.57 14.6 0 1 5 8
Volvo 142E 21.4 9.1 4 121 109 4.11 2.78 18.6 1 1 4 2
# Keep only those vehicles which exceed 15 mpg using data.table
mtcars2[mpg > 15, ]
##                   Car  mpg  kpL cyl  disp  hp drat    wt  qsec vs am gear
##  1:         Mazda RX4 21.0  8.9   6 160.0 110 3.90 2.620 16.46  0  1    4
##  2:     Mazda RX4 Wag 21.0  8.9   6 160.0 110 3.90 2.875 17.02  0  1    4
##  3:        Datsun 710 22.8  9.7   4 108.0  93 3.85 2.320 18.61  1  1    4
##  4:    Hornet 4 Drive 21.4  9.1   6 258.0 110 3.08 3.215 19.44  1  0    3
##  5: Hornet Sportabout 18.7  8.0   8 360.0 175 3.15 3.440 17.02  0  0    3
##  6:           Valiant 18.1  7.7   6 225.0 105 2.76 3.460 20.22  1  0    3
##  7:         Merc 240D 24.4 10.4   4 146.7  62 3.69 3.190 20.00  1  0    4
##  8:          Merc 230 22.8  9.7   4 140.8  95 3.92 3.150 22.90  1  0    4
##  9:          Merc 280 19.2  8.2   6 167.6 123 3.92 3.440 18.30  1  0    4
## 10:         Merc 280C 17.8  7.6   6 167.6 123 3.92 3.440 18.90  1  0    4
## 11:        Merc 450SE 16.4  7.0   8 275.8 180 3.07 4.070 17.40  0  0    3
## 12:        Merc 450SL 17.3  7.4   8 275.8 180 3.07 3.730 17.60  0  0    3
## 13:       Merc 450SLC 15.2  6.5   8 275.8 180 3.07 3.780 18.00  0  0    3
## 14:          Fiat 128 32.4 13.8   4  78.7  66 4.08 2.200 19.47  1  1    4
## 15:       Honda Civic 30.4 12.9   4  75.7  52 4.93 1.615 18.52  1  1    4
## 16:    Toyota Corolla 33.9 14.4   4  71.1  65 4.22 1.835 19.90  1  1    4
## 17:     Toyota Corona 21.5  9.1   4 120.1  97 3.70 2.465 20.01  1  0    3
## 18:  Dodge Challenger 15.5  6.6   8 318.0 150 2.76 3.520 16.87  0  0    3
## 19:       AMC Javelin 15.2  6.5   8 304.0 150 3.15 3.435 17.30  0  0    3
## 20:  Pontiac Firebird 19.2  8.2   8 400.0 175 3.08 3.845 17.05  0  0    3
## 21:         Fiat X1-9 27.3 11.6   4  79.0  66 4.08 1.935 18.90  1  1    4
## 22:     Porsche 914-2 26.0 11.1   4 120.3  91 4.43 2.140 16.70  0  1    5
## 23:      Lotus Europa 30.4 12.9   4  95.1 113 3.77 1.513 16.90  1  1    5
## 24:    Ford Pantera L 15.8  6.7   8 351.0 264 4.22 3.170 14.50  0  1    5
## 25:      Ferrari Dino 19.7  8.4   6 145.0 175 3.62 2.770 15.50  0  1    5
## 26:        Volvo 142E 21.4  9.1   4 121.0 109 4.11 2.780 18.60  1  1    4
##                   Car  mpg  kpL cyl  disp  hp drat    wt  qsec vs am gear
##     carb
##  1:    4
##  2:    4
##  3:    1
##  4:    1
##  5:    2
##  6:    1
##  7:    2
##  8:    2
##  9:    4
## 10:    4
## 11:    3
## 12:    3
## 13:    3
## 14:    1
## 15:    2
## 16:    1
## 17:    1
## 18:    2
## 19:    2
## 20:    2
## 21:    1
## 22:    2
## 23:    2
## 24:    4
## 25:    6
## 26:    2
##     carb
# using dplyr
filter(mtcars1, mpg > 15)
##                  Car  mpg  kPL cyl  disp  hp drat    wt  qsec vs am gear
## 1          Mazda RX4 21.0  8.9   6 160.0 110 3.90 2.620 16.46  0  1    4
## 2      Mazda RX4 Wag 21.0  8.9   6 160.0 110 3.90 2.875 17.02  0  1    4
## 3         Datsun 710 22.8  9.7   4 108.0  93 3.85 2.320 18.61  1  1    4
## 4     Hornet 4 Drive 21.4  9.1   6 258.0 110 3.08 3.215 19.44  1  0    3
## 5  Hornet Sportabout 18.7  8.0   8 360.0 175 3.15 3.440 17.02  0  0    3
## 6            Valiant 18.1  7.7   6 225.0 105 2.76 3.460 20.22  1  0    3
## 7          Merc 240D 24.4 10.4   4 146.7  62 3.69 3.190 20.00  1  0    4
## 8           Merc 230 22.8  9.7   4 140.8  95 3.92 3.150 22.90  1  0    4
## 9           Merc 280 19.2  8.2   6 167.6 123 3.92 3.440 18.30  1  0    4
## 10         Merc 280C 17.8  7.6   6 167.6 123 3.92 3.440 18.90  1  0    4
## 11        Merc 450SE 16.4  7.0   8 275.8 180 3.07 4.070 17.40  0  0    3
## 12        Merc 450SL 17.3  7.4   8 275.8 180 3.07 3.730 17.60  0  0    3
## 13       Merc 450SLC 15.2  6.5   8 275.8 180 3.07 3.780 18.00  0  0    3
## 14          Fiat 128 32.4 13.8   4  78.7  66 4.08 2.200 19.47  1  1    4
## 15       Honda Civic 30.4 12.9   4  75.7  52 4.93 1.615 18.52  1  1    4
## 16    Toyota Corolla 33.9 14.4   4  71.1  65 4.22 1.835 19.90  1  1    4
## 17     Toyota Corona 21.5  9.1   4 120.1  97 3.70 2.465 20.01  1  0    3
## 18  Dodge Challenger 15.5  6.6   8 318.0 150 2.76 3.520 16.87  0  0    3
## 19       AMC Javelin 15.2  6.5   8 304.0 150 3.15 3.435 17.30  0  0    3
## 20  Pontiac Firebird 19.2  8.2   8 400.0 175 3.08 3.845 17.05  0  0    3
## 21         Fiat X1-9 27.3 11.6   4  79.0  66 4.08 1.935 18.90  1  1    4
## 22     Porsche 914-2 26.0 11.1   4 120.3  91 4.43 2.140 16.70  0  1    5
## 23      Lotus Europa 30.4 12.9   4  95.1 113 3.77 1.513 16.90  1  1    5
## 24    Ford Pantera L 15.8  6.7   8 351.0 264 4.22 3.170 14.50  0  1    5
## 25      Ferrari Dino 19.7  8.4   6 145.0 175 3.62 2.770 15.50  0  1    5
## 26        Volvo 142E 21.4  9.1   4 121.0 109 4.11 2.780 18.60  1  1    4
##    carb
## 1     4
## 2     4
## 3     1
## 4     1
## 5     2
## 6     1
## 7     2
## 8     2
## 9     4
## 10    4
## 11    3
## 12    3
## 13    3
## 14    1
## 15    2
## 16    1
## 17    1
## 18    2
## 19    2
## 20    2
## 21    1
## 22    2
## 23    2
## 24    4
## 25    6
## 26    2
# Source 2


# Group cars by number of cylinders and the computed share of displacement
# using data.table
setkey(mtcars2, "cyl")
mtcars2[, .(disp, displace = round(disp/sum(disp), digits = 3)), by = cyl]
##     cyl  disp displace
##  1:   4 108.0    0.093
##  2:   4 146.7    0.127
##  3:   4 140.8    0.122
##  4:   4  78.7    0.068
##  5:   4  75.7    0.065
##  6:   4  71.1    0.061
##  7:   4 120.1    0.104
##  8:   4  79.0    0.068
##  9:   4 120.3    0.104
## 10:   4  95.1    0.082
## 11:   4 121.0    0.105
## 12:   6 160.0    0.125
## 13:   6 160.0    0.125
## 14:   6 258.0    0.201
## 15:   6 225.0    0.175
## 16:   6 167.6    0.131
## 17:   6 167.6    0.131
## 18:   6 145.0    0.113
## 19:   8 360.0    0.073
## 20:   8 360.0    0.073
## 21:   8 275.8    0.056
## 22:   8 275.8    0.056
## 23:   8 275.8    0.056
## 24:   8 472.0    0.095
## 25:   8 460.0    0.093
## 26:   8 440.0    0.089
## 27:   8 318.0    0.064
## 28:   8 304.0    0.061
## 29:   8 350.0    0.071
## 30:   8 400.0    0.081
## 31:   8 351.0    0.071
## 32:   8 301.0    0.061
##     cyl  disp displace
# Source 3

# using dplyr
mtcars1 %>% group_by(cyl) %>% select(Car, disp) %>% mutate(displace = round(disp/sum(disp), 
    digits = 3))
## Source: local data frame [32 x 4]
## Groups: cyl [3]
## 
##      cyl               Car  disp displace
##    <dbl>             <chr> <dbl>    <dbl>
## 1      4         Mazda RX4 108.0    0.093
## 2      4     Mazda RX4 Wag 146.7    0.127
## 3      4        Datsun 710 140.8    0.122
## 4      4    Hornet 4 Drive  78.7    0.068
## 5      4 Hornet Sportabout  75.7    0.065
## 6      4           Valiant  71.1    0.061
## 7      4        Duster 360 120.1    0.104
## 8      4         Merc 240D  79.0    0.068
## 9      4          Merc 230 120.3    0.104
## 10     4          Merc 280  95.1    0.082
## # ... with 22 more rows
# Source 1 for use of select and Source 2



Sources used in the R code

Source 1
r - How does one reorder columns in a data frame? - Stack Overflow answered by dalloliogm on Jul 3 2012 and edited by gjabel on Feb 19 2015. See https://stackoverflow.com/questions/5620885/how-does-one-reorder-columns-in-a-data-frame.

Source 2
Introduction to dplyr, 2016-06-23, https://cran.rstudio.com/web/packages/dplyr/vignettes/introduction.html

Source 3
r - data.table - Group data.table result by multiple columns with rounding - Stack Overflow answered by Psidom on November 9 2016. See https://stackoverflow.com/questions/40518608/r-data-table-group-data-table-result-by-multiple-columns-with-rounding.



LS0tCnRpdGxlOiAiRGF0YSBBbmFseXNpcyBXaXRoIFIgVXNpbmcgZGF0YS50YWJsZSBhbmQgZHBseXIiCmF1dGhvcjogIklydWNrYSBFbWJyeSwgRS5JLlQuIgpkYXRlOiAiYHIgU3lzLkRhdGUoKWAiCm91dHB1dDoKaHRtbF9kb2N1bWVudDoKbWF0aGpheDogZGVmYXVsdAotLS0KCjxiciAvPgo8YnIgLz4KClRoZSBmb2xsb3dpbmcgZG9jdW1lbnQgc2hvd3MgdmFyaW91cyBkYXRhIGFuYWx5c2lzIG9wZXJhdGlvbnMgcGVyZm9ybWVkIHVzaW5nIGJvdGggYGRhdGEudGFibGVgIGFuZCBgZHBseXJgLgoKPGJyIC8+CjxiciAvPgoKTm90ZTogSWYgeW91IHdpc2ggdG8gcmVwbGljYXRlIHRoZSBSIGNvZGUgYmVsb3csIHRoZW4geW91IHdpbGwgbmVlZCB0byBjb3B5IGFuZCBwYXN0ZSB0aGUgZm9sbG93aW5nIGNvbW1hbmRzIGluIFIgZmlyc3QgKHRvIG1ha2Ugc3VyZSB5b3UgaGF2ZSBhbGwgdGhlIHBhY2thZ2VzIGFuZCB0aGVpciBkZXBlbmRlbmNpZXMpOgoKYGBge3IgZXZhbCA9IEZBTFNFfQppbnN0YWxsLnBhY2thZ2VzKCJpbnN0YWxsLmxvYWQiKQojIGluc3RhbGwgdGhlIGluc3RhbGwubG9hZCBwYWNrYWdlCgppbnN0YWxsLmxvYWQ6Omluc3RhbGxfbG9hZCgiZHBseXIiLCAiZGF0YS50YWJsZSIsICJOSVNUdW5pdHMiLCAiaHRtbFRhYmxlIikKIyBpbnN0YWxsIGFuZC9vciBsb2FkIHRoZSBwYWNrYWdlcyBhbmQgdGhlaXIgZGVwZW5kZW5jaWVzCmBgYAoKPGJyIC8+CgpUaGlzIGRvY3VtZW50IHdhcyBjcmVhdGVkIHdpdGggcm1hcmtkb3duIDEu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