Answers ( 2 )

  1. Unlist function flattens out the list.
    Given a list structure x, unlist simplifies it to produce a vector which contains all the
    atomic components which occur in x. This function will also unlist all lists within the list as well.

    test1 unlist(test1)
    [1] “3” “a” “15” “b”
    > test2 test2
    $v1
    [1] 5

    $v2
    $v2[[1]]
    [1] 2983

    $v2[[2]]
    [1] 1890

    $v3
    [1] 3 119

    > unlist(test2)
    v1 v21 v22 v31 v32
    5 2983 1890 3 119

  2. unlist function in R, simply converts the list to vector with all the atomic components are being preserved
    Syntax for unlist function in R:

    unlist(x, recursive = TRUE, use.names = TRUE)

Leave an answer

Browse
Browse