Give name to list variable

前端 未结 3 767
無奈伤痛
無奈伤痛 2020-12-06 06:37

so we know that R have list() variable, and also know that R has function call names() to give names for variable. For example :

a=         


        
3条回答
  •  无人及你
    2020-12-06 07:29

    Since @akrun doesn't need any more points, here is an example showing how you can assign names to a list:

    lst <- list(a="one", b="two", c=c(1:3))
    names(lst)
    [1] "a" "b" "c"
    names(lst) <- c("x", "y", "z")
    
    > lst
    $x
    [1] "one"
    
    $y
    [1] "two"
    
    $z
    [1] 1 2 3
    

提交回复
热议问题