Error using export.chdata in RMark

posts related to the RMark library, which may not be of general interest to users of 'classic' MARK

Error using export.chdata in RMark

Postby henrik » Fri Jun 19, 2009 2:54 pm

Dear all,

I wish to export a processed RMark dataset to an .inp file. I order to learn about the export.chdata function, I wanted to play around with the example in ?export.chdata. However, I received an error message:

> ?export.chdata
> data(dipper)
> dipper$numeric.sex=as.numeric(dipper$sex)-1
> dipper.processed=process.data(dipper,group="sex")
> export.chdata(dipper.processed, filename="dipper", covariates="numeric.sex")
Error in if (inherits(X[[j]], "data.frame") && ncol(xj) > 1L) X[[j]] <- as.matrix(X[[j]]) :
missing value where TRUE/FALSE needed

The example on p C-103 in the RMark manual v.17/6/09 (without the argument covariates="numeric.sex") gives the same error message.


Thanks in advance for any advice!

Best regards,

Henrik


> sessionInfo()
R version 2.9.0 (2009-04-17)
i386-pc-mingw32

locale:
LC_COLLATE=English_United Kingdom.1252;LC_CTYPE=English_United Kingdom.1252;LC_MONETARY=English_United Kingdom.1252;LC_NUMERIC=C;LC_TIME=English_United Kingdom.1252

attached base packages:
[1] stats graphics grDevices datasets tcltk utils methods base

other attached packages:
[1] RMark_1.9.0 svSocket_0.9-43 svMisc_0.9-46 TinnR_1.0.3 R2HTML_1.59-1 Hmisc_3.5-2

loaded via a namespace (and not attached):
[1] cluster_1.11.13 grid_2.9.0 lattice_0.17-22 tools_2.9.0
>
henrik
 
Posts: 5
Joined: Tue Jun 16, 2009 7:43 am

Postby jlaake » Fri Jun 19, 2009 3:09 pm

Upgrage your version of RMark to 1.9.1 and it will fix the problem which was introduced with release of R2.9.

--jeff
jlaake
 
Posts: 1479
Joined: Fri May 12, 2006 12:50 pm
Location: Escondido, CA

Postby henrik » Sat Jun 20, 2009 6:16 am

Thanks for your rapid reply!

The example works fine with RMark 1.9.1. However, when explicitly specifying more than one covariate, export.chdata causes a warning:

data(dipper)
# add fake covariates to dipper
dipper$treat <- as.factor(sample(x = c(0,1), size = 294, replace = TRUE))
dipper$treat2 <- as.factor(sample(x = c(0,1), size = 294, replace = TRUE))

# numeric version of covariates for MARK
dipper$sex.num <- as.numeric(dipper$sex) - 1
dipper$treat.num <- as.numeric(dipper$treat) - 1
dipper$treat2.num <- as.numeric(dipper$treat2) - 1


str(dipper)

# process data
dipper.processed <- process.data(data = dipper, group = c("sex", "treat", "treat2"))

# export data

# only one covariate
export.chdata(data = dipper.processed, filename = "dipper", covariates = "sex.num", replace = TRUE)
export.chdata(data = dipper.processed, filename = "dipper", covariates = "treat.num", replace = TRUE)
# no warnings

# two covariates
export.chdata(data = dipper.processed, filename = "dipper", covariates = c("sex.num", "treat2.num"), replace = TRUE)

Warning message:
In if (covariates == "all") zz = data.frame(cbind(zz, data$data[, :
the condition has length > 1 and only the first element will be used

# all three covariates using "all"
export.chdata(data = dipper.processed, filename = "dipper", covariates = "all", replace = TRUE)
# no warning

# all three covariates explicit, which should be equivalent to "all"
export.chdata(data = dipper.processed, filename = "dipper", covariates = c("sex.num", "treat.num", "treat2.num"), replace = TRUE)

Warning message:
In if (covariates == "all") zz = data.frame(cbind(zz, data$data[, :
the condition has length > 1 and only the first element will be used

What am I missing here?

Cheers,

Henrik
henrik
 
Posts: 5
Joined: Tue Jun 16, 2009 7:43 am


Return to RMark

Who is online

Users browsing this forum: No registered users and 1 guest