Create Function to Safely Access Data Frame Columns or List Elements
Source:R/createAccessor.R
createAccessor.Rd
Create Function to Safely Access Data Frame Columns or List Elements
Examples
getcol <- createAccessor(data.frame(a = 1:2, b = 2:3))
getcol("a")
#> [1] 1 2
getcol("b")
#> [1] 2 3
getcol(c("b", "a"))
#> b a
#> 1 2 1
#> 2 3 2
# getcol("c") # error with info about existing columns