Given a data frame with a defined response variable, this function creates a unique representation of the covariates in the data frame, vector (matrix) of responses, and a pointer vector, connecting the responses with the corresponding covariates.
cro(dat, response = 1)
| dat | A data frame |
|---|---|
| response | The column(s) where the response resides. |
A list with components
The response.
A data frame with unique rows of covariates.
Pointers from y to
covar, connecting each response with its covariate vector.
The rows in the data frame are converted to text strings with paste
and compared with match.
This function is based on suggestions by Anne York and Brian Ripley.
Göran Broström
#> $y #> [1] 1.1 2.3 0.7 #> #> $covar #> x1 x2 #> 1 1 0 #> 2 0 1 #> #> $keys #> [1] 1 2 1 #>