当我尝试使用
好的,我明白了,但我不知道该从哪里开始。我无法提供一个真正可重现的例子,因为我的数据框约有558,000行,而且这个问题不会在小的玩具示例上出现。例如,即使我取出数据的50,000行子集,
这是我正在转换的数据框的子集(其中一些变量的值为假值),接下来是我使用的转换函数。如果需要对其进行操作,我还在下面包含了一个小的数据段的
dcast
(来自reshape2
包)重塑特定数据框时,RStudio崩溃了。我发现崩溃实际上是在R本身中发生的,所以我在R.app中运行了我的转换代码,并得到了一种类型的错误,这就是这个网站的名字:Error: segfault from C stack overflow
。通过谷歌和SO的帮助,我了解到这是一种内存访问错误。好的,我明白了,但我不知道该从哪里开始。我无法提供一个真正可重现的例子,因为我的数据框约有558,000行,而且这个问题不会在小的玩具示例上出现。例如,即使我取出数据的50,000行子集,
dcast
也可以很好地工作。是否有一行特定的数据引起了问题?如果是这样,有人能建议我应该查找哪些可能导致我得到此类错误的特征吗?这是我正在转换的数据框的子集(其中一些变量的值为假值),接下来是我使用的转换函数。如果需要对其进行操作,我还在下面包含了一个小的数据段的
dput
函数。实际数据集有约700个 prog
值,15个 prog1
值和5个 fa.type
值。 id term yr nslds acad.lev prog prog1 fa.type amount
1 1 Fall 2009 2010 Graduate Graduate loan 1 Other Loans Loan 5000
2 1 Spring 2010 2010 Graduate Graduate loan 1 Other Loans Loan 5000
3 2 Fall 2009 2010 Graduate Graduate loan 2 Stafford Loan Loan 8781
4 2 Spring 2010 2010 Graduate Graduate loan 2 Stafford Loan Loan 8781
5 3 Fall 2007 2008 Graduate Graduate loan 3 Stafford Loan Loan 4250
6 3 Fall 2007 2008 Graduate Graduate grant 1 University Grant Grant 1707
fa.wide = dcast(id + term + yr + nslds + acad.lev ~ prog1 + fa.type , data=fa, value.var="amount", fun.aggregate=sum)
fa = structure(list(id = c(1, 1, 2, 2, 3, 3), term = structure(c(7L,
8L, 7L, 8L, 1L, 1L), .Label = c("Fall 2007", "Spring 2008", "Summer 2008",
"Fall 2008", "Spring 2009", "Summer 2009", "Fall 2009", "Spring 2010",
"Summer 2010", "Fall 2010", "Spring 2011", "Summer 2011", "Fall 2011",
"Spring 2012", "Summer 2012", "Fall 2012", "Spring 2013"), class = c("ordered",
"factor")), yr = c(2010L, 2010L, 2010L, 2010L, 2008L, 2008L),
nslds = structure(c(7L, 7L, 7L, 7L, 7L, 7L), .Label = c("1st Year, Never Attended",
"1st Year, Previously Attended", "2nd Year", "3rd Year",
"4th Year", "5th Year+", "Graduate"), class = c("ordered",
"factor")), acad.lev = structure(c(6L, 6L, 6L, 6L, 6L, 6L
), .Label = c("Freshman", "Sophomore", "Junior", "Senior",
"PB Undergrad", "Graduate"), class = c("ordered", "factor"
)), prog = c("loan 1", "loan 1", "loan 2", "loan 2", "loan 3",
"grant 1"), prog1 = c("Other Loans", "Other Loans", "Stafford Loan",
"Stafford Loan", "Stafford Loan", "University Grant"), fa.type = structure(c(3L,
3L, 3L, 3L, 3L, 2L), .Label = c("Athletic", "Grant", "Loan",
"Scholarship", "Waiver", "Work/Study"), class = "factor"),
amount = c(5000, 5000, 8781, 8781, 4250, 1707)), .Names = c("id",
"term", "yr", "nslds", "acad.lev", "prog", "prog1", "fa.type",
"amount"), row.names = c(NA, 6L), class = "data.frame")
rehshape
包中的cast
函数来重新整理我的数据,但我仍然想知道是什么导致了这个错误。如果@Hadley和他的团队在Github上报告了任何信息,我会在这里发布。 - eipi10