Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FR: destructuring assignment in mutate #3373

Closed
t-kalinowski opened this issue Feb 22, 2018 · 2 comments
Closed

FR: destructuring assignment in mutate #3373

t-kalinowski opened this issue Feb 22, 2018 · 2 comments
Labels
feature a feature request or enhancement

Comments

@t-kalinowski
Copy link
Contributor

t-kalinowski commented Feb 22, 2018

Now that I'm getting used to zeallot, I find myself wishing I could use it in mutate.
A motivating example based on within. It would be nice if something similar could work within mutate.

library(purrr)
library(zeallot)
library(tibble)
# dummy data
(df <- tibble(id = paste0(sample(c("M", "F"), 6, T), ".", sample(20:50, 6, T) )))
#> # A tibble: 6 x 1
#>   id   
#>   <chr>
#> 1 M.34 
#> 2 F.32 
#> 3 M.41 
#> 4 F.26 
#> 5 F.27 
#> 6 M.21

within(df, c(sex, age) %<-% simplify_all(transpose(strsplit(id, ".", fixed =TRUE))))
#> # A tibble: 6 x 3
#>   id    age   sex  
#>   <chr> <chr> <chr>
#> 1 M.34  34    M    
#> 2 F.32  32    F    
#> 3 M.41  41    M    
#> 4 F.26  26    F    
#> 5 F.27  27    F    
#> 6 M.21  21    M

Created on 2018-02-22 by the reprex package (v0.2.0).

@krlmlr krlmlr added feature a feature request or enhancement data frame labels Feb 28, 2018
@romainfrancois
Copy link
Member

This is similar to #2326

@lock
Copy link

lock bot commented Oct 8, 2018

This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/

@lock lock bot locked and limited conversation to collaborators Oct 8, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature a feature request or enhancement
Projects
None yet
Development

No branches or pull requests

3 participants