Combining pipes and the magrittr dot (.) placeholder

后端 未结 2 448
谎友^
谎友^ 2020-12-19 06:37

I am fairly new to R and I am trying to understand the %>% operator and the usage of the \" .\" (dot) placeholder. As a simple example the follo

2条回答
  •  死守一世寂寞
    2020-12-19 06:46

    This is the problem:

    . = data.frame(x = 5)
    a = data.frame(x = 5)
    
    a %>% is.data.frame
    #[1] TRUE
    . %>% is.data.frame
    #Functional sequence with the following components:
    #
    # 1. is.data.frame(.)
    #
    #Use 'functions' to extract the individual functions. 
    

    Looks like a bug to me, but dplyr experts can chime in.

    A simple workaround in your expression is to do .[] %>% is.data.frame.

提交回复
热议问题