Posted on Categories Administrativia, StatisticsTags , , , , , ,

My recent BARUG talk: Parametric Programming in R with replyr

I want to share an edited screencast of my rehearsal for my recent San Francisco Bay Area R Users Group talk:



5 thoughts on “My recent BARUG talk: Parametric Programming in R with replyr”

  1. Great stuff. You can eliminate the temporary column name in your lazyeval::interp example, though it requires nesting: d %>% mutate_(.dots = stats::setNames(lazyeval::interp(~ is.na(VAR), VAR = as.name(cname)), rname))

    1. Thanks, I appreciate the support and the info.

      I tried it in the source of vignette('ParametricExample', package= 'replyr'), and for me that sets the result column to “is.na(x)” (an improvement), not exactly to “x_isNA” (my goal in that vignette). My packageVersion('lazyeval') is 0.2.0 (current CRAN version as of Feb 28, 2017).

      
      library("dplyr")
      d <- data.frame(x= c(1,NA))
      cname <- 'x'
      rname <- paste(cname, 'isNA', sep= '_')
      print(rname)
      
       # [1] "x_isNA"
      
      d <- d %>% 
        mutate_(.dots = stats::setNames(
          lazyeval::interp(~ is.na(VAR), 
                           VAR = as.name(cname)), rname))
      print(d)
      
       # x is.na(x)
       # 1  1    FALSE
       # 2 NA     TRUE
      
  2. Oops I forgot you should surround the interp() call with list().

    library("dplyr")
    d <- data.frame(x= c(1,NA))
    cname <- 'x'
    rname <- paste(cname, 'isNA', sep= '_')
    print(rname)
    
     # [1] "x_isNA"
    
    d %>%
      mutate_(.dots = stats::setNames(list(
        lazyeval::interp(~ is.na(VAR),
                         VAR = as.name(cname))), rname))
     # x x_isNA
     # 1  1  FALSE
     # 2 NA   TRUE
    

Leave a Reply