View source: R/merge.design.covariates.r
merge_design.covariates | R Documentation |
Adds new design data fields from a dataframe into a design data list
(ddl
) by matching via time and/or group field in the design data.
merge_design.covariates(ddl, df, bygroup = FALSE, bytime = TRUE)
ddl |
current design dataframe for a specific parameter and not the entire design data list (ddl); see example below |
df |
dataframe with time(occasion) and/or group-specific data |
bygroup |
logical; if TRUE, then a field named |
bytime |
logical; if TRUE, then a field named |
Design data can be added to the parameter specific design dataframes with R
commands. This function simplifies the process by enabling the merging of a
dataframe with a time and/or group field and one or more time and/or group
specific covariates into the design data list for a specific model
parameter. This is a replacement for the older function
merge.occasion.data
. Unlike the older function, it uses the R
function merge
but before merging it makes sure all of the
fields exist and that you are not merging data that already exists in the
design data. It also maintains the row names in the case where design data
have been deleted prior to merging the design covariate data.
If bytime=TRUE
,the dataframe df
must have a field named
time
that matches 1-1 for each value of time
in the design
data list (ddl
). All fields in df
(other than time/group) are
added to the design data. If you set bygroup=TRUE
and have a field
named group
in df
and its values match the group fields in the
design data then group-specific values can be assigned for each time if
bytime=TRUE
. If bygroup=TRUE
and bytime=FALSE
then it
matches by group and not by time.
Design dataframe (for a particular parameter) with new fields added.
See make.design.data
for a description of the design data list
structure. The return value is only one element in the list rather than the
entire list as with the older function merge.occasion.data
.
Jeff Laake
make.design.data
, process.data
,
add.design.data
data(dipper) dipper.proc=process.data(dipper) ddl=make.design.data(dipper.proc) df=data.frame(time=c(1:7),effort=c(10,5,2,8,1,2,3)) # note that the value for time 1 is superfluous for CJS but not for POPAN # the value 10 will not appear in the summary because there is no p for time 1 summary(ddl$p) ddl$p=merge_design.covariates(ddl$p,df) summary(ddl$p) # This example is excluded from testing to reduce package check time # # Assign group-specific values # dipper.proc=process.data(dipper,groups="sex") dipper.ddl=make.design.data(dipper.proc) df=data.frame(group=c(rep("Female",6),rep("Male",6)),time=rep(c(2:7),2), effort=c(10,5,2,8,1,2,3,20,10,4,16,2)) merge_design.covariates(dipper.ddl$p,df,bygroup=TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.