Skip to content

Instantly share code, notes, and snippets.

@brshallo
Created October 6, 2021 22:32
Show Gist options
  • Select an option

  • Save brshallo/d2e65aaaa04851ed8b799604c85b3592 to your computer and use it in GitHub Desktop.

Select an option

Save brshallo/d2e65aaaa04851ed8b799604c85b3592 to your computer and use it in GitHub Desktop.
example for R4DS answer
a <- list(c("20M1", "A1", "ACC1"), c("20M2", "A2", "ACC2"), c("20M3"))

mx <- max(lengths(a))

data.frame(lapply(a, `length<-`, mx))
#>   c..20M1....A1....ACC1.. c..20M2....A2....ACC2.. c..20M3...NA..NA.
#> 1                    20M1                    20M2              20M3
#> 2                      A1                      A2              <NA>
#> 3                    ACC1                    ACC2              <NA>

Created on 2021-10-06 by the reprex package (v2.0.0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment