Attachment | Size |
---|---|
errorDemonstrationScript.R [6] | 552 bytes |
ExampleData2.csv [7] | 329 bytes |
Hi Everyone,
Using metaSEM and loving it. But, I've encountered a problem using metaSEM with a data frame after I have deleted rows from that data frame -- or created a new data frame that is a subset of the rows in the original data frame. Fortunately, I've also discovered a work around - but the error is an odd one. I have attached the relevant files, but I'll describe it in detail here.
Imagine I have a data set then runs fine in metaSEM. If I create new data frame that is a subset of the original data frame the new data frame will not run in metaSEM. I've tried various ways of creating the new data frame, but the results is always the same. I get the following error:
Error in $<-.data.frame
(*tmp*
, "time", value = c(1L, 0L, 1L, 2L, 3L, :
replacement has 19 rows, data has 17
Oddly, I've found that if I take the data frame that will not run, save it to disk, load it, and run it, everything is fine.
Looks like a fix may possibly be needed in metaSEM or OpenMx - since the particular data doesn't seem to be the issue here.
Cheers,
David
library(OpenMx)
library(metaSEM)
testData=read.csv("ExampleData2.csv")
testDataSubset=testData[testData$GRP!="A",]
print("Running: All Data")
m1=meta3(y=r,v=va,cluster=GRP,data=testData)
if you uncomment this next bit, the program will crash with the above error
print("Running Subset Data: Error")
m3=meta3(y=r,v=va,cluster=GRP,data=testDataSubset)
This work around save the day though...
write.table(testDataSubset,"testDataSubsetTemp",row.names=T)
testDataSubsetLoad=read.table("testDataSubsetTemp")
print("Running Subset Data: saved and reloaded")
m2=meta3(y=r,v=va,cluster=GRP,data=testDataSubsetLoad)