summarise from dplyr data return - r

I am using summarise to perform a calculation for each row of my data frame. Although the results are ok as shown in my console, I cant seem to be apple to insert them in the same data frame, or even create a new one. Any help? I am grouping them first based on a column (postcode) and then performing the calculation for all rows with the same postcode. Thank you in advance
my_data %>%
group_by(as.character(Postcode))%>%
summarise(wgt_inw_PC = sum(E_W_GEM))

We just need to assign it back to the object
library(dplyr)
my_data <- my_data %>%
group_by(Postcode = Postcode)%>%
summarise(wgt_inw_PC = sum(E_W_GEM, na.rm = TRUE))
Or another option is the compound assignment operator from magrittr (%<>%)
library(magrittr)
my_data %<>%
group_by(Postcode = Postcode)%<>%
summarise(wgt_inw_PC = sum(E_W_GEM, na.rm = TRUE))

I am not sure if this is what you're looking for (I recommend using reproducible examples when asking questions on SO), but here's a code for conducting a calculation in groups and then appending this to your data frame:
library(dplyr)
#>
#> Attaching package: 'dplyr'
mtcars %>%
group_by(cyl)%>%
mutate(wgt = sum(wt))
#> # A tibble: 32 x 12
#> # Groups: cyl [3]
#> mpg cyl disp hp drat wt qsec vs am gear carb wgt
#> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 21 6 160 110 3.9 2.62 16.5 0 1 4 4 21.8
#> 2 21 6 160 110 3.9 2.88 17.0 0 1 4 4 21.8
#> 3 22.8 4 108 93 3.85 2.32 18.6 1 1 4 1 25.1
#> 4 21.4 6 258 110 3.08 3.22 19.4 1 0 3 1 21.8
#> 5 18.7 8 360 175 3.15 3.44 17.0 0 0 3 2 56.0
#> 6 18.1 6 225 105 2.76 3.46 20.2 1 0 3 1 21.8
#> 7 14.3 8 360 245 3.21 3.57 15.8 0 0 3 4 56.0
#> 8 24.4 4 147. 62 3.69 3.19 20 1 0 4 2 25.1
#> 9 22.8 4 141. 95 3.92 3.15 22.9 1 0 4 2 25.1
#> 10 19.2 6 168. 123 3.92 3.44 18.3 1 0 4 4 21.8
#> # ... with 22 more rows

Related

Rolling average indexed on multiple variables

I'm working with a dataframe that indexes values by three variables, date, campaign and country. Every other value is indexed according to these three values, as follows:
# Groups: date, campaign [1,325]
date campaign country cost clicks
<date> <dbl> <chr> <dbl> <dbl>
1 2021-03-01 10127671839 0 0.45 7
2 2021-03-01 10127671839 AD 0.47 10
3 2021-03-01 10127671839 AE 0.39 11
4 2021-03-01 10127671839 AF 0.27 2
5 2021-03-01 10127671839 AG 0 0
6 2021-03-01 10127671839 AI 1.28 2
7 2021-03-01 10127671839 AL 0.66 6
8 2021-03-01 10127671839 AM 0.33 2
9 2021-03-01 10127671839 AO 0 0
10 2021-03-01 10127671839 AR 0 0
# … with 335,215 more rows
What I'm trying to do is creating a moving average of those values (in the table above, "cost" and "clicks") that is still indexed on country, campaign and date.
Edit: I found a good function that works when there are only two index variables (in here: Rolling mean (moving average) by group/id with dplyr), but I am not skilled enough to tweak the code into working for three or more variables.
I think zoo::rollmean works well here, and dplyr::group_by can handle as many index variables as you need:
library(dplyr)
mtcars %>%
group_by(cyl, am, vs) %>%
mutate(across(c(mpg,disp), list(rm = ~ zoo::rollmeanr(., 2, fill = NA))))
# # A tibble: 32 x 13
# # Groups: cyl, am, vs [7]
# mpg cyl disp hp drat wt qsec vs am gear carb mpg_rm disp_rm
# <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
# 1 21 6 160 110 3.9 2.62 16.5 0 1 4 4 NA NA
# 2 21 6 160 110 3.9 2.88 17.0 0 1 4 4 21 160
# 3 22.8 4 108 93 3.85 2.32 18.6 1 1 4 1 NA NA
# 4 21.4 6 258 110 3.08 3.22 19.4 1 0 3 1 NA NA
# 5 18.7 8 360 175 3.15 3.44 17.0 0 0 3 2 NA NA
# 6 18.1 6 225 105 2.76 3.46 20.2 1 0 3 1 19.8 242.
# 7 14.3 8 360 245 3.21 3.57 15.8 0 0 3 4 16.5 360
# 8 24.4 4 147. 62 3.69 3.19 20 1 0 4 2 NA NA
# 9 22.8 4 141. 95 3.92 3.15 22.9 1 0 4 2 23.6 144.
# 10 19.2 6 168. 123 3.92 3.44 18.3 1 0 4 4 18.6 196.
# # ... with 22 more rows
The fill=NA argument means that the first in each series has no history to average on, so it is NA. If you prefer the first in a series to be an average of itself, you can instead use partial=TRUE (using rollapplyr instead):
mtcars %>%
group_by(cyl, am, vs) %>%
mutate(across(c(mpg,disp), list(rm = ~ zoo::rollapplyr(., 2, FUN = mean, partial = TRUE))))
# # A tibble: 32 x 13
# # Groups: cyl, am, vs [7]
# mpg cyl disp hp drat wt qsec vs am gear carb mpg_rm disp_rm
# <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
# 1 21 6 160 110 3.9 2.62 16.5 0 1 4 4 21 160
# 2 21 6 160 110 3.9 2.88 17.0 0 1 4 4 21 160
# 3 22.8 4 108 93 3.85 2.32 18.6 1 1 4 1 22.8 108
# 4 21.4 6 258 110 3.08 3.22 19.4 1 0 3 1 21.4 258
# 5 18.7 8 360 175 3.15 3.44 17.0 0 0 3 2 18.7 360
# 6 18.1 6 225 105 2.76 3.46 20.2 1 0 3 1 19.8 242.
# 7 14.3 8 360 245 3.21 3.57 15.8 0 0 3 4 16.5 360
# 8 24.4 4 147. 62 3.69 3.19 20 1 0 4 2 24.4 147.
# 9 22.8 4 141. 95 3.92 3.15 22.9 1 0 4 2 23.6 144.
# 10 19.2 6 168. 123 3.92 3.44 18.3 1 0 4 4 18.6 196.
# # ... with 22 more rows
I've used the align="right" variants of zoo's functions, assuming that your moving average is historical and that time increases in subsequent rows. If these assumptions are not true, make sure you intentionally choose between the align-variants.
I used dplyr::across here to handle an arbitrary number of columns in one step: Since I used a named list of "tilde-functions", it took the name of each function and appended it to the name of each of the column names. You can break it out into individual mutate assignments if you prefer, for readability, maintainability, or if you need different sets of arguments for each column.

Mutate a dynamic column name with conditions using other dynamic column names

I'm trying to use dplyr::mutate to change a dynamic column with conditions using other columns dynamically.
I've got this bit of code:
d <- mtcars %>% tibble
fld_name <- "mpg"
other_fld_name <- "cyl"
d <- d %>% mutate(!!fld_name := ifelse(!!other_fld_name < 5,NA,!!fld_name))
which sets mpg to
mpg
<chr>
1 mpg
2 mpg
3 mpg
4 mpg
5 mpg
6 mpg
7 mpg
8 mpg
9 mpg
10 mpg
it seems to select the field on the LHS of assignment operator, but just pastes the field name on the RHS.
Removing the unquotes on the RHS yields the same result.
Any help is much appreciated.
use get to retreive column value instead
library(tidyverse)
d <- mtcars %>% tibble
fld_name <- "mpg"
other_fld_name <- "cyl"
d %>% mutate(!!fld_name := ifelse(get(other_fld_name) < 5 ,NA, get(fld_name)))
#> # A tibble: 32 x 11
#> mpg cyl disp hp drat wt qsec vs am gear carb
#> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 21 6 160 110 3.9 2.62 16.5 0 1 4 4
#> 2 21 6 160 110 3.9 2.88 17.0 0 1 4 4
#> 3 NA 4 108 93 3.85 2.32 18.6 1 1 4 1
#> 4 21.4 6 258 110 3.08 3.22 19.4 1 0 3 1
#> 5 18.7 8 360 175 3.15 3.44 17.0 0 0 3 2
#> 6 18.1 6 225 105 2.76 3.46 20.2 1 0 3 1
#> 7 14.3 8 360 245 3.21 3.57 15.8 0 0 3 4
#> 8 NA 4 147. 62 3.69 3.19 20 1 0 4 2
#> 9 NA 4 141. 95 3.92 3.15 22.9 1 0 4 2
#> 10 19.2 6 168. 123 3.92 3.44 18.3 1 0 4 4
#> # ... with 22 more rows
Created on 2021-06-22 by the reprex package (v2.0.0)
We can also use ensym function to quote variable name stored as string and unquote it with !! like the following:
library(rlang)
d <- mtcars %>% tibble
fld_name <- "mpg"
other_fld_name <- "cyl"
d %>%
mutate(!!ensym(fld_name) := ifelse(!!ensym(other_fld_name) < 5, NA, !!ensym(fld_name)))
# A tibble: 32 x 11
mpg cyl disp hp drat wt qsec vs am gear carb
<dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 21 6 160 110 3.9 2.62 16.5 0 1 4 4
2 21 6 160 110 3.9 2.88 17.0 0 1 4 4
3 NA 4 108 93 3.85 2.32 18.6 1 1 4 1
4 21.4 6 258 110 3.08 3.22 19.4 1 0 3 1
5 18.7 8 360 175 3.15 3.44 17.0 0 0 3 2
6 18.1 6 225 105 2.76 3.46 20.2 1 0 3 1
7 14.3 8 360 245 3.21 3.57 15.8 0 0 3 4
8 NA 4 147. 62 3.69 3.19 20 1 0 4 2
9 NA 4 141. 95 3.92 3.15 22.9 1 0 4 2
10 19.2 6 168. 123 3.92 3.44 18.3 1 0 4 4
# ... with 22 more rows
We could also use .data
library(dplyr)
d %>%
mutate(!! fld_name := case_when(.data[[other_fld_name]] >=5 ~
.data[[fld_name]]))
-output
# A tibble: 32 x 11
mpg cyl disp hp drat wt qsec vs am gear carb
<dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 21 6 160 110 3.9 2.62 16.5 0 1 4 4
2 21 6 160 110 3.9 2.88 17.0 0 1 4 4
3 NA 4 108 93 3.85 2.32 18.6 1 1 4 1
4 21.4 6 258 110 3.08 3.22 19.4 1 0 3 1
5 18.7 8 360 175 3.15 3.44 17.0 0 0 3 2
6 18.1 6 225 105 2.76 3.46 20.2 1 0 3 1
7 14.3 8 360 245 3.21 3.57 15.8 0 0 3 4
8 NA 4 147. 62 3.69 3.19 20 1 0 4 2
9 NA 4 141. 95 3.92 3.15 22.9 1 0 4 2
10 19.2 6 168. 123 3.92 3.44 18.3 1 0 4 4
# … with 22 more rows
data
d <- mtcars %>%
as_tibble
fld_name <- "mpg"
other_fld_name <- "cyl"

Why is `select_if(., is_double)` returning dates? [duplicate]

This question already has answers here:
Why is Date is being returned as type 'double'?
(2 answers)
Closed 2 years ago.
When using is_double with select_if, the return value includes columns of lubridate's date data type. Why is this?
Here is a simple example using the today() function.
library(tidyverse)
library(lubridate)
mtcars %>%
as_tibble() %>% # Convert to tibble
mutate(today = today()) %>% # Create a date column
select_if(is_double) # Select double columns
Output:
# A tibble: 32 x 12
mpg cyl disp hp drat wt qsec vs am gear carb today
<dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <date>
1 21 6 160 110 3.9 2.62 16.5 0 1 4 4 2020-06-25
2 21 6 160 110 3.9 2.88 17.0 0 1 4 4 2020-06-25
3 22.8 4 108 93 3.85 2.32 18.6 1 1 4 1 2020-06-25
4 21.4 6 258 110 3.08 3.22 19.4 1 0 3 1 2020-06-25
5 18.7 8 360 175 3.15 3.44 17.0 0 0 3 2 2020-06-25
6 18.1 6 225 105 2.76 3.46 20.2 1 0 3 1 2020-06-25
7 14.3 8 360 245 3.21 3.57 15.8 0 0 3 4 2020-06-25
8 24.4 4 147. 62 3.69 3.19 20 1 0 4 2 2020-06-25
9 22.8 4 141. 95 3.92 3.15 22.9 1 0 4 2 2020-06-25
10 19.2 6 168. 123 3.92 3.44 18.3 1 0 4 4 2020-06-25
# ... with 22 more rows
Hopefully I'm missing something simple, are dates recognized as type double?
Because, date is internally stored as double
typeof(today())
#[1] "double"
though its class is 'Date'
class(today())
#[1] "Date"
An option is to add another condition in select_if
library(dplyr)
mtcars %>%
as_tibble %>%
mutate(today = today()) %>%
select_if(~ is_double(.) && !inherits(., "Date"))
# A tibble: 32 x 10
# mpg disp hp drat wt qsec vs am gear carb
# <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
# 1 21 160 110 3.9 2.62 16.5 0 1 4 4
# 2 21 160 110 3.9 2.88 17.0 0 1 4 4
# 3 22.8 108 93 3.85 2.32 18.6 1 1 4 1
# 4 21.4 258 110 3.08 3.22 19.4 1 0 3 1
# 5 18.7 360 175 3.15 3.44 17.0 0 0 3 2
# 6 18.1 225 105 2.76 3.46 20.2 1 0 3 1
# 7 14.3 360 245 3.21 3.57 15.8 0 0 3 4
# 8 24.4 147. 62 3.69 3.19 20 1 0 4 2
# 9 22.8 141. 95 3.92 3.15 22.9 1 0 4 2
#10 19.2 168. 123 3.92 3.44 18.3 1 0 4 4
# … with 22 more rows
In the dplyr 1.0.0, we can also use where with select
mtcars %>%
as_tibble %>%
mutate(today = today()) %>%
select(where(~is_double(.) && !inherits(., "Date")))

Replacing group_by_at(NULL) using across

Before, I used group_by_at to group by a vector of strings or by NULL:
library(tidyverse)
grouping_1 <- c("cyl", "vs")
grouping_2 <- NULL
mtcars %>% group_by_at(grouping_1)
mtcars %>% group_by_at(grouping_2)
The help of group_by_at indicates that the function is superseded and that across should be used instead. But, grouping by NULL gives an error
mtcars %>% group_by(across(grouping_1)) # this works
mtcars %>% group_by(across(grouping_2)) # this gives an error
For me, group_by_at used in the way described has been useful because in my functions I can use the same code without checking every time whether the grouping argument is empty (NULL) or not.
It is still ok to use syms to splice strings into group_by using !!!.
library(tidyverse)
grouping_1 <- c("cyl", "vs")
grouping_2 <- NULL
sym_gr_1 <- syms(grouping_1)
sym_gr_2 <- syms(grouping_2)
mtcars %>% group_by(!!! sym_gr_1) # this works
#> # A tibble: 32 x 11
#> # Groups: cyl, vs [5]
#> mpg cyl disp hp drat wt qsec vs am gear carb
#> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 21 6 160 110 3.9 2.62 16.5 0 1 4 4
#> 2 21 6 160 110 3.9 2.88 17.0 0 1 4 4
#> 3 22.8 4 108 93 3.85 2.32 18.6 1 1 4 1
#> 4 21.4 6 258 110 3.08 3.22 19.4 1 0 3 1
#> 5 18.7 8 360 175 3.15 3.44 17.0 0 0 3 2
#> 6 18.1 6 225 105 2.76 3.46 20.2 1 0 3 1
#> 7 14.3 8 360 245 3.21 3.57 15.8 0 0 3 4
#> 8 24.4 4 147. 62 3.69 3.19 20 1 0 4 2
#> 9 22.8 4 141. 95 3.92 3.15 22.9 1 0 4 2
#> 10 19.2 6 168. 123 3.92 3.44 18.3 1 0 4 4
#> # … with 22 more rows
mtcars %>% group_by(!!! sym_gr_2) # this works
#> # A tibble: 32 x 11
#> mpg cyl disp hp drat wt qsec vs am gear carb
#> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 21 6 160 110 3.9 2.62 16.5 0 1 4 4
#> 2 21 6 160 110 3.9 2.88 17.0 0 1 4 4
#> 3 22.8 4 108 93 3.85 2.32 18.6 1 1 4 1
#> 4 21.4 6 258 110 3.08 3.22 19.4 1 0 3 1
#> 5 18.7 8 360 175 3.15 3.44 17.0 0 0 3 2
#> 6 18.1 6 225 105 2.76 3.46 20.2 1 0 3 1
#> 7 14.3 8 360 245 3.21 3.57 15.8 0 0 3 4
#> 8 24.4 4 147. 62 3.69 3.19 20 1 0 4 2
#> 9 22.8 4 141. 95 3.92 3.15 22.9 1 0 4 2
#> 10 19.2 6 168. 123 3.92 3.44 18.3 1 0 4 4
#> # … with 22 more rows
Created on 2020-06-20 by the reprex package (v0.3.0)
Using dplyr::across() another option (on top of the official way to do with all_of as posted in the answer below) is to wrap the strings containing the variable names in c(). This even works, when the object is NULL. However, results in a note, reminding use to better use all_of.
grouping_1 <- c("cyl", "vs")
grouping_2 <- NULL
mtcars %>% group_by(across(c(grouping_1)))
#> Note: Using an external vector in selections is ambiguous.
#> ℹ Use `all_of(grouping_1)` instead of `grouping_1` to silence this message.
#> ℹ See <https://tidyselect.r-lib.org/reference/faq-external-vector.html>.
#> This message is displayed once per session.
#> # A tibble: 32 x 11
#> # Groups: cyl, vs [5]
#> mpg cyl disp hp drat wt qsec vs am gear carb
#> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 21 6 160 110 3.9 2.62 16.5 0 1 4 4
#> 2 21 6 160 110 3.9 2.88 17.0 0 1 4 4
#> 3 22.8 4 108 93 3.85 2.32 18.6 1 1 4 1
#> 4 21.4 6 258 110 3.08 3.22 19.4 1 0 3 1
#> 5 18.7 8 360 175 3.15 3.44 17.0 0 0 3 2
#> 6 18.1 6 225 105 2.76 3.46 20.2 1 0 3 1
#> 7 14.3 8 360 245 3.21 3.57 15.8 0 0 3 4
#> 8 24.4 4 147. 62 3.69 3.19 20 1 0 4 2
#> 9 22.8 4 141. 95 3.92 3.15 22.9 1 0 4 2
#> 10 19.2 6 168. 123 3.92 3.44 18.3 1 0 4 4
#> # … with 22 more rows
mtcars %>% group_by(across(c(grouping_2)))
#> Note: Using an external vector in selections is ambiguous.
#> ℹ Use `all_of(grouping_2)` instead of `grouping_2` to silence this message.
#> ℹ See <https://tidyselect.r-lib.org/reference/faq-external-vector.html>.
#> This message is displayed once per session.
#> # A tibble: 32 x 11
#> mpg cyl disp hp drat wt qsec vs am gear carb
#> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 21 6 160 110 3.9 2.62 16.5 0 1 4 4
#> 2 21 6 160 110 3.9 2.88 17.0 0 1 4 4
#> 3 22.8 4 108 93 3.85 2.32 18.6 1 1 4 1
#> 4 21.4 6 258 110 3.08 3.22 19.4 1 0 3 1
#> 5 18.7 8 360 175 3.15 3.44 17.0 0 0 3 2
#> 6 18.1 6 225 105 2.76 3.46 20.2 1 0 3 1
#> 7 14.3 8 360 245 3.21 3.57 15.8 0 0 3 4
#> 8 24.4 4 147. 62 3.69 3.19 20 1 0 4 2
#> 9 22.8 4 141. 95 3.92 3.15 22.9 1 0 4 2
#> 10 19.2 6 168. 123 3.92 3.44 18.3 1 0 4 4
#> # … with 22 more rows
Created on 2021-05-30 by the reprex package (v0.3.0)
Using all_of:
library(tidyverse)
mtcars %>% group_by(across(all_of(grouping_1))) # this works
mtcars %>% group_by(across(all_of(grouping_2))) # this works

use assign() inside purrr:walk()

I have a number of dataframes and a series of changes I want to make to each of them. For this example, let to the desired change be simply making each data frame a tibble using as_tibble. I know there are various ways of doing this, but I'd like to do this using purrr:walk.
For data frames df1 and df2,
df1 <- mtcars
df2 <- mtcars
I'd like to do the equivalent of
df1 %<>% as_tibble
df2 %<>% as_tibble
using walk. My attempt:
library(tidyverse)
walk(c(df1, df2), ~ assign(deparse(substitute(.)), as_tibble(.)))
This runs but does not make the desired change:
is_tibble(df1)
#> [1] FALSE
Here is how you can combine assign with walk (see the comments the code for more explanation)-
library(tidyverse)
# data
df1 <- mtcars
df2 <- mtcars
# creating tibbles
# this creates a list of objects with names ("df1", "df2")
tibble::lst(df1, df2) %>%
purrr::walk2(
.x = names(.), # names to assign
.y = ., # object to be assigned
.f = ~ assign(x = .x,
value = tibble::as.tibble(.y),
envir = .GlobalEnv)
)
# checking the newly created tibbles
df1
#> # A tibble: 32 x 11
#> mpg cyl disp hp drat wt qsec vs am gear carb
#> * <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 21 6 160 110 3.9 2.62 16.5 0 1 4 4
#> 2 21 6 160 110 3.9 2.88 17.0 0 1 4 4
#> 3 22.8 4 108 93 3.85 2.32 18.6 1 1 4 1
#> 4 21.4 6 258 110 3.08 3.22 19.4 1 0 3 1
#> 5 18.7 8 360 175 3.15 3.44 17.0 0 0 3 2
#> 6 18.1 6 225 105 2.76 3.46 20.2 1 0 3 1
#> 7 14.3 8 360 245 3.21 3.57 15.8 0 0 3 4
#> 8 24.4 4 147. 62 3.69 3.19 20 1 0 4 2
#> 9 22.8 4 141. 95 3.92 3.15 22.9 1 0 4 2
#> 10 19.2 6 168. 123 3.92 3.44 18.3 1 0 4 4
#> # ... with 22 more rows
df2
#> # A tibble: 32 x 11
#> mpg cyl disp hp drat wt qsec vs am gear carb
#> * <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 21 6 160 110 3.9 2.62 16.5 0 1 4 4
#> 2 21 6 160 110 3.9 2.88 17.0 0 1 4 4
#> 3 22.8 4 108 93 3.85 2.32 18.6 1 1 4 1
#> 4 21.4 6 258 110 3.08 3.22 19.4 1 0 3 1
#> 5 18.7 8 360 175 3.15 3.44 17.0 0 0 3 2
#> 6 18.1 6 225 105 2.76 3.46 20.2 1 0 3 1
#> 7 14.3 8 360 245 3.21 3.57 15.8 0 0 3 4
#> 8 24.4 4 147. 62 3.69 3.19 20 1 0 4 2
#> 9 22.8 4 141. 95 3.92 3.15 22.9 1 0 4 2
#> 10 19.2 6 168. 123 3.92 3.44 18.3 1 0 4 4
#> # ... with 22 more rows
Created on 2018-11-13 by the reprex package (v0.2.1)

Resources