powered by
Try to convert a string to a table, by first creating a data frame using read.table. This can then be coerced to a matrix first, and subsequently to a table. The names of the dimensions can be specified.
read.table
TextToTable(x, dimnames = NULL, check.names = FALSE, ...)
a table
the string to be interpreted as table.
the names of the dimensions.
passed on to read.table and determines, if invalid column names should be adapted to valid ones. The default here is changed to FALSE.
FALSE
the dots will be passed to the function read.table and can be used for example to specify header, sep and row.names arguments.
header
sep
row.names
Andri Signorell <andri@signorell.net>
read.table, as.table, as.matrix
as.table
as.matrix
txt <- " Democrat, Independent, Republican M, 762, 327, 468 F, 484, 239, 477" (tab <- TextToTable(txt, header=TRUE, sep=",", dimnames=c("gender", "party")))
Run the code above in your browser using DataLab