I'm trying to use nse with model.matrix . This is my reprex:
library(tidyverse)
test.df <- data.frame(someoutcome = rnorm(5), test2 = rnorm(5), somethingelse3 = rnorm(5))
str1 <- 'some'
test.df %>% model.matrix(data = ., someoutcome ~ . -1) # this works
#> test2 somethingelse3
#> 1 0.46570249 1.6787597
#> 2 1.32546861 -1.4879579
#> 3 0.07072583 1.1094165
#> 4 -1.03257283 0.8443111
#> 5 1.26892823 1.4716239
#> attr(,"assign")
#> [1] 1 2
test.df %>% model.matrix(data = ., !!rlang::sym(glue::glue('{str1}outcome')) ~ . -1)
#> Error in !rlang::sym(glue::glue("{str1}outcome")): invalid argument type
Created on 2019-01-10 by the reprex package (v0.2.1)
Why do I get invalid argument type ??