rigraphnse

How to quote() non-standard expressions, e.g. 2A-2B?


Or any other non-parseble expression as in igraph::graph_from_literal(1A +--+ 1B).

Function call quote(1A-2B) gives Error: unexpected symbol in quote(1A".

How to get a result similar to


Solution

  • Quote 2A +-+ 2B as quote("2A" +-+ "2B"). When an expression in quote(expr) contains non parsible object names, quote it.

    Examples.

    A2   <- 1       ## creates object "A2" with value `[1] 1`.
    2A   <- 1       ## fails because "2A" is a not syntactically valid R expression.
    "2A" <- 1       ## creates object "2A" with value `[1] 1`.
    assign("2B", 1) ## creates object "2B" with value `[1] 1`.
    if (require(igraph)) g <- graph_from_literal("1A" - "2A")
    A2; get("2A"); get("2B")
    ls()
    ## [1] "2A" "2B" "A2"