楼主: 青衣默东行
1320 3

[问答] R中list结构变换 [推广有奖]

  • 1关注
  • 1粉丝

已卖:231份资源

硕士生

60%

还不是VIP/贵宾

-

威望
0
论坛币
2687 个
通用积分
0.3645
学术水平
2 点
热心指数
2 点
信用等级
2 点
经验
5470 点
帖子
92
精华
0
在线时间
217 小时
注册时间
2015-5-14
最后登录
2018-6-11

楼主
青衣默东行 发表于 2017-5-10 15:25:16 |AI写论文
10论坛币
在R中我想把这样一个list数据
> res$cond.ind
, , 1

          [,1]     
pair      Numeric,2
separator Numeric,0

, , 2

          [,1]     
pair      Numeric,2
separator Numeric,0

, , 3

          [,1]     
pair      Numeric,2
separator Numeric,0

, , 4

          [,1]     
pair      Numeric,2
separator Numeric,0

, , 5

          [,1]     
pair      Numeric,2
separator Numeric,0

, , 6

          [,1]     
pair      Numeric,2
separator Numeric,0

, , 7

          [,1]     
pair      Numeric,2
separator Numeric,0

, , 8

          [,1]     
pair      Numeric,2
separator 2        

, , 9

          [,1]     
pair      Numeric,2
separator 2        

, , 10

          [,1]     
pair      Numeric,2
separator 2        

, , 11

          [,1]     
pair      Numeric,2
separator 2        

, , 12

          [,1]     
pair      Numeric,2
separator 2        

, , 13

          [,1]     
pair      Numeric,2
separator 6        

, , 14

          [,1]     
pair      Numeric,2
separator 6        

, , 15

          [,1]     
pair      Numeric,2
separator 6        

, , 16

          [,1]     
pair      Numeric,2
separator 6        

, , 17

          [,1]     
pair      Numeric,2
separator Numeric,2

, , 18

          [,1]     
pair      Numeric,2
separator Numeric,2

, , 19

          [,1]     
pair      Numeric,2
separator Numeric,2

, , 20

          [,1]     
pair      Numeric,2
separator 2        
改成这样的list数据

[[1]]
[[1]][[1]]
NULL

[[1]][[2]]
NULL

[[1]][[3]]
[1] 2

[[1]][[4]]
integer(0)

[[1]][[5]]
[1] 2

[[1]][[6]]
NULL

[[1]][[7]]
[1] 6

[[1]][[8]]
NULL


[[2]]
[[2]][[1]]
NULL

[[2]][[2]]
NULL

[[2]][[3]]
NULL

[[2]][[4]]
integer(0)

[[2]][[5]]
NULL

[[2]][[6]]
[1] 1

[[2]][[7]]
[1] 1

[[2]][[8]]
[1] 1 5


[[3]]
[[3]][[1]]
NULL

[[3]][[2]]
NULL

[[3]][[3]]
NULL

[[3]][[4]]
integer(0)

[[3]][[5]]
[1] 2

[[3]][[6]]
[1] 1

[[3]][[7]]
integer(0)

[[3]][[8]]
[1] 2


[[4]]
[[4]][[1]]
NULL

[[4]][[2]]
NULL

[[4]][[3]]
NULL

[[4]][[4]]
NULL

[[4]][[5]]
integer(0)

[[4]][[6]]
integer(0)

[[4]][[7]]
integer(0)

[[4]][[8]]
integer(0)


[[5]]
[[5]][[1]]
NULL

[[5]][[2]]
NULL

[[5]][[3]]
NULL

[[5]][[4]]
NULL

[[5]][[5]]
NULL

[[5]][[6]]
NULL

[[5]][[7]]
[1] 6

[[5]][[8]]
NULL


[[6]]
[[6]][[1]]
NULL

[[6]][[2]]
NULL

[[6]][[3]]
NULL

[[6]][[4]]
NULL

[[6]][[5]]
NULL

[[6]][[6]]
NULL

[[6]][[7]]
NULL

[[6]][[8]]
[1] 1 5


[[7]]
[[7]][[1]]
NULL

[[7]][[2]]
NULL

[[7]][[3]]
NULL

[[7]][[4]]
NULL

[[7]][[5]]
NULL

[[7]][[6]]
NULL

[[7]][[7]]
NULL

[[7]][[8]]
[1] 6


[[8]]
[[8]][[1]]
NULL

[[8]][[2]]
NULL

[[8]][[3]]
NULL

[[8]][[4]]
NULL

[[8]][[5]]
NULL

[[8]][[6]]
NULL

[[8]][[7]]
NULL

[[8]][[8]]
NULL
应该怎么办?

关键词:list IST numeric Integer null

沙发
青衣默东行 发表于 2017-5-10 15:27:08
其实第一种结构中的pair就是第二种结构中的类似于元素下标的数据,而separate就是元素值。不知道能不能变换呢?

藤椅
青衣默东行 发表于 2017-6-19 19:28:07
我最后自己用R做了一个简单的循环,类似于把一个列向量转化成矩阵了,满足后面所需参数的结构就行了。

板凳
青衣默东行 发表于 2017-6-19 19:29:23
前面回答了,忘了申请奖励。

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

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2026-1-3 11:40