What is the difference between sym() and parse_expr() in the rlang package?

前端 未结 2 855
感动是毒
感动是毒 2021-01-19 15:55

Using the rlang package, I wonder what is the difference between sym() and parse_expr(). Consider for example the following expressions:

         


        
2条回答
  •  野性不改
    2021-01-19 16:53

    To augment the previous answer, note that ex5 and ex6 are not in fact identical.

    a <- 5
    b <- 3
    eval_tidy(ex6)
    # [1] 2
    eval_tidy(ex5)
    # Error in eval_tidy(ex5) : object 'a - b' not found
    `a - b` <- pi
    eval_tidy(ex5)
    # [1] 3.141593
    

提交回复
热议问题