mimR-ReadingData {mimR} | R Documentation |
Different methods for creation of gmData objects. Depending on taste gmData can be taken as meaning 'graphical model data' or 'graphical meta data'
gmData(name, letter = NULL, factor = rep(FALSE, length(name)), vallabels=NULL, data=NULL) as.gmData (data, letter=NULL) description(x) "description<-"(tmp, value) latent(x) "latent<-"(tmp, value) vallabels(x) "vallabels<-"(tmp, value) observations(x) "observations<-"(tmp, value)
name |
~~Describe name here~~ |
factor |
~~Describe factor here~~ |
data |
a dataframe |
letter |
A specification of letters which can subsequently be used as short hand for the variable names |
x |
A gmData object |
tmp |
A gmData object |
value |
The value to entered into the object |
vallabels |
A list containing labels of the levels of the discrete variables (not currently used) |
as.mimData is just a wrapper for as.gmData (kept in the package for historical reasons). as.mimData only works for data frames.
A dataframe containing the link between the names in the dataframe and the names (and labels) and the coding of factors in MIM
If only a subset of a dataframe is used, then it may be necessary to recode the levels of factors in the dataframe. Otherwise one can end up with slices of the table in MIM with no observations in it. The easiest way to recode the levels is to use the function 'factor()', see examples below.
Before using mimR, make sure that the MIM program is runnning.
Søren Højsgaard, sorenh@agrsci.dk
David Edwards, An Introduction to Graphical Modelling, Second Edition, Springer Verlag, 2000
# A meta data object (without data) gmd.rats.nodata <- gmData(c("Sex","Drug","W1","W2"), factor=c(2,3,FALSE,FALSE), vallabels=list("Sex"=c("M","F"), "Drug"=c("D1","D2","D3"))) # Note care should be taken to be consistent when specifying vallabels manually: #This works nt1 <- gmData(c("Sex","Drug","W1","W2"),factor=c(2,3,FALSE,FALSE)) vallabels(nt1) #This works nt12 <- gmData(c("Sex","Drug","W1","W2"),factor=c(2,3,FALSE,FALSE), vallabels=list("Sex"=c(1,2), "Drug"=c(1,2,3))) vallabels(nt1) ## Not run: #This will not work nt1 <- gmData(c("Sex","Drug","W1","W2"),factor=c(2,3,FALSE,FALSE), vallabels=list("Sex"=c(1,2,3), "Drug"=c(1,2,3))) vallabels(nt1) #This will not work nt1 <- gmData(c("Sex","Drug","W1","W2"),factor=c(2,3,FALSE,FALSE), vallabels=list("Sex"=c(1,2,3))) vallabels(nt1) ## End(Not run) data(rats) #NOTE: This works, but it should not because names in 'data' is not checked for consistency with what is specified nt1 <- gmData(c("Sex","Drug","W1","W2"),factor=c(2,3,FALSE,FALSE), vallabels=list("Sex"=c(1,2), "Drug"=c(1,2,3)), data=rats) vallabels(nt1) # Sending a data frame to MIM gm.rats <- as.gmData(rats) toMIM(gm.rats)