convertDFT | R Documentation |
Change data.tables into data.frames with specified row.names or data.frames/matrices into data.tables, copying over row.names as the first column. If data.frame/matrix doesn't have row.names, then no columns will be added to data.table
TODO! Add description
convertDFT(data_dft, col_v = NA, newName_v = NULL, rmCol_v = T, split_v = NULL)
data_dft |
data in either data.table or data.frame format (can also be a matrix) |
col_v |
character or numeric vector. if converting from dt to df, column name or index of which column to use as row.names. NA (default) will use 1st column; NULL will not add rownames. NEW can also provide multiple columns here. The names and values will be pasted together with "_" to create one column to become the rownames. |
newName_v |
character vector. if converting from df/mat to dt, what to name new column. (default is "V1") if newName_v is already a column name, will paste "_2" to end of newName_v. |
rmCol_v |
boolean value indicating whether to remove the column used to make the rownames from the output table (T) or to leave it (F) |
split_v |
character vector. default = NULL. Used for converting TO data.table. If there are multiple columns' worth of data in the rownames, split on this and assign results to multiple columns. both the column names and the values by the provided delimiter. |
either a data.table or data.frame (opposite class of input)
# Data
my_df <- data.frame("A" = 1:10, "B" = LETTERS[1:10], "C" = letters[11:20])
my_df2 <- my_df; rownames(my_df2) <- paste0("Row", 1:10)
my_mat <- as.matrix(my_df); my_mat2 <- as.matrix(my_df2)
my_dt <- data.table("AA" = 10:1, "BB" = LETTERS[5:14], "CC" = letters[20:11])
convertDFT(data_dft = my_df)
convertDFT(data_dft = my_df2)
convertDFT(data_dft = my_df2, newName_v = "Test")
convertDFT(data_dft = my_mat2, newName_v = "MatTest")
convertDFT(data_dft = my_dt)
convertDFT(data_dft = my_dt, col_v = NULL)
convertDFT(data_dft = my_dt, col_v = "BB")
convertDFT(data_dft = my_dt, col_v = 3, rmCol_v = F)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.