| as.ms | R Documentation |
The internal representation is as a numeric matrix with 0 when a level is not present and the non-zero rank or score when it is present. The data.frame and matrix methods uses the numeric values of x, and by default set NA values to 'not present'. The list method takes a list with a character vector for each observation and uses the position in the list as the rank/score. The character method splits the string at the separators to give a list and uses the list method.
The mr method uses a score of 1 whenever the level is present.
as.ms(x, ...)
## S3 method for class 'list'
as.ms(x,...,levels=NULL)
## S3 method for class 'data.frame'
as.ms(x,...,na.rm=TRUE)
## S3 method for class 'matrix'
as.ms(x,...,na.rm=TRUE)
## S3 method for class 'mr'
as.ms(x,...)
## S3 method for class 'character'
as.ms(x,sep=", ", ...,levels=NULL)
x |
object to be converted |
... |
for compatibility; not used. |
levels |
Optional character vector giving the permitted levels |
na.rm |
Convert |
sep |
Regular expression for splitting the character string |
Object of class ms
nzbirds_list<-list(c("kea","tui"), c("kea","ruru","kaki"), c("ruru"),
c("tui","ruru"), c("tui","kea","ruru"), c("tauhou","kea"))
nzbirds_list
(msbirds<-as.ms(nzbirds_list))
(bird_mat <- unclass(msbirds))
as.ms(bird_mat)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.