我试图使用TraMineR(Version1.8.4) seqdef-funciton来定义序列对象,但是我总是收到这样的错误消息,这对我来说是没有意义的: error in row.names<-.data.frame(*tmp*,value = value):无效的'row.names‘长度
我的代码输入是:
sample.sts <- seqdef(sample, var=c("jan2005", "feb2005", "mar2005", "apr2005", "may2005",
"jun2005", "jul2005", "aug2005", "sep2005", "oct2005", "nov2005", "dec2005"),
alphabet=c("Employee (full-time)", "Employee (part-time)",
"Self-employed (full-time)", "Self-employed (part-time)", "unemployed", "Retired",
"Student", "Other inactive", "Compulsory military service"),
states=c("EF", "EP", "SF", "SP", "UE", "RE", "ST", "IA", "MS"), id="pidc")数据框架“示例”如下所示:
pidc jan2005 feb2005 ... dec2005 sex edufirst age05
--------------------------------------------------------------------------
1. 150163920001 . . ... . 1 5 62
2. 211518110003 . . ... . 2 2 17
3. 170295160002 . . ... . 2 1 47
4. 240386550002 2 2 ... 2 2 2 50
5. 320099920001 . . ... . 1 3 38
--------------------------------------------------------------------------
6. 200167850001 . . ... . 1 5 39
7. 340401190002 6 6 ... 6 1 3 61
8. 180501260002 . . ... . 1 3 29
9. 230083560001 . . ... . 1 3 61
10. 240335270002 3 3 ... 3 2 3 30 整个产出显示:
好了!在州代码中找到“-”字符,不推荐 >找到序列数据中的缺失值('NA') >制备3266序列 >用'%‘编码空元素,用'*’编写缺失值 好了!指数序列: 1,2,3,. >状态编码: 字母长标号 1名雇员(全职) EF 2名雇员(兼职) EP 3自营职业者(全职) 4自雇(兼职) SP 5个失业UE UE 6退休RE 7学生圣圣 8其他不活跃的IA IA 9义务兵役制 > 3266序列在数据集中 >最小/最大序列长度: 12/12
row.names<-.data.frame中的Fehler (*tmp*,value = value): 无效“row.names”长度
在没有"-“的状态重新贴上标签后,我重新试了一次,这不影响错误。也许,有人能帮我,知道是什么导致了这个错误?
发布于 2012-12-06 09:23:30
seqdef的"id“参数应该是包含每个序列一个条目的向量(即。id向量的长度应等于序列数)。尝试使用id=as.character(示例$pid)。您也可以尝试id=sample$pid (没有as.character)
sample.sts <- seqdef(sample, var=c("jan2005", "feb2005", "mar2005", "apr2005", "may2005", "jun2005", "jul2005", "aug2005", "sep2005", "oct2005", "nov2005", "dec2005", "jan2006", "feb2006", "mar2006", "apr2006", "may2006", "jun2006", "jul2006", "aug2006", "sep2006", "oct2006", "nov2006", "dec2006", "jan2007", "feb2007", "mar2007", "apr2007", "may2007", "jun2007", "jul2007", "aug2007", "sep2007", "oct2007", "nov2007", "dec2007", "jan2008", "feb2008", "mar2008", "apr2008", "may2008", "jun2008", "jul2008", "aug2008", "sep2008", "oct2008", "nov2008", "dec2008"), alphabet=c("Employee (full-time)", "Employee (part-time)", "Self-employed (full-time)", "Self-employed (part-time)", "unemployed", "Retired", "Student", "Other inactive", "Compulsory military service"), states=c("EF", "EP", "SF", "SP", "UE", "RE", "ST", "IA", "MS"), d=as.character(sample$pid))数据中的状态和字母表参数之间存在一些不匹配,因为"-“被”替换为“。您可能应该更改字母表参数(尝试使用seqstatl函数找出数据中存在标签的状态)。
https://stackoverflow.com/questions/13739666
复制相似问题