Description Usage Arguments Examples

View source: R/response_matrix.R

`response_matrix`

creates a response_matrix object, for use with
`gpirtMCMC`

; `is.response_matrix`

tests if its argument is
a `response_matrix`

object; `as.response_matrix`

attemps to turn
its argument into a `response_matrix`

.

1 2 3 4 5 6 7 8 9 10 11 | ```
response_matrix(
data,
response_codes = list(yea = 1:3, nay = 4:6, missing = c(0, 7:9, NA))
)
is.response_matrix(x)
as.response_matrix(
x,
response_codes = list(yea = 1:3, nay = 4:6, missing = c(0, 7:9, NA))
)
``` |

`data` |
A matrix or dataframe of responses |

`response_codes` |
A named list giving the mapping from recorded responses to -1, 1, NA. An element named "yea" gives the responses that should be coded as 1, an element named "nay" gives the repsonses that should be coded as -1, and an element named "missing" gives responses that should be NA |

`x` |
An R object |

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ```
## Data in {0, 1}
x <- c(1, 0, 1, 1, 0, NA)
ex1 <- matrix(x, nrow = 3)
ex2 <- data.frame(x1 = x[1:3], x2 = x[4:6])
response_matrix(ex1, response_codes = list(yea = 1, nay = 0, missing = NA))
response_matrix(ex2, response_codes = list(yea = 1, nay = 0, missing = NA))
## Multiple "yea" codes
x <- c(1, -1, 2, 3, -1, NA)
ex3 <- matrix(x, nrow = 3)
ex4 <- data.frame(x1 = x[1:3], x2 = x[4:6])
response_matrix(ex3, response_codes = list(yea = 1:3, nay = -1, missing = NA))
response_matrix(ex4, response_codes = list(yea = 1:3, nay = -1, missing = NA))
## Dataframe with factors
ex5 <- data.frame(x = factor(c("Yea", "Nay", "Yea")),
y = factor(c("Yea", "Nay", NA)))
y <- response_matrix(ex5, response_codes = list(yea = "Yea", nay = "Nay",
missing = NA))
is.response_matrix(ex5)
is.response_matrix(y)
as.response_matrix(ex5, response_codes = list(yea = "Yea", nay = "Nay",
missing = NA))
as.response_matrix(y, response_codes = list(yea = "Yea", nay = "Nay",
missing = NA))
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.