设为首页收藏本站获取积分奖励

R语言中文网

 找回密码
 立即注册
查看: 6336|回复: 2

R语言中unlist是干嘛用的?—R-China小编问题(29)

[复制链接]
发表于 2013-3-2 22:44:42 | 显示全部楼层 |阅读模式
童鞋A:R中unlist是干嘛用的?
童鞋B:
“Given a list structure x, unlist simplifies it to produce a vector which contains all the atomic components which occur in x.”
童鞋A:
ok i see.  thx
还能不能用汉语解释一下,并给出个例子啥的,解释一下?
回复

使用道具 举报

发表于 2013-3-3 10:21:41 | 显示全部楼层
unlist()函数的作用,就是将list结构的数据,变成非list的数据,即将list数据变成字符串向量或者数字向量的形式。
例如
require(graphics)

# create a plotting structure
pts <- list(x=cars[,1], y=cars[,2])

ulist(pts)
大家可以再举例子说明
回复 支持 反对

使用道具 举报

发表于 2021-7-19 16:28:08 | 显示全部楼层
上面那位兄弟回答得挺好的了,补充个小例子吧

> list1 <- list(a=c(1,2,3),
+               b=c(5,7,8))
> unlist1 <- unlist(list1)
> unlist1
a1 a2 a3 b1 b2 b3
1  2  3  5  7  8
> class(unlist1)
[1] "numeric"
> unlist1+1
a1 a2 a3 b1 b2 b3
2  3  4  6  8  9
> names(unlist1)
[1] "a1" "a2" "a3" "b1" "b2" "b3"
> unlist1['a3']
a3
3
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Archiver|R语言中文网    

GMT+8, 2024-5-14 07:22 , Processed in 0.022325 second(s), 18 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表