'(Keyword: Malformed Data Table) Fixing a data frame in R so the scriptwriter can rearrange the data frame's columns
Good day; I intend to rearrange a data frame's columns after uploading and combining multiple .xlsx spreadsheets (one sheet in each .xlsx) into one consolidated sheet (.xlsx).
Error in `[.data.table`(thirdintermediate.df, , c(10, 1, 5, 6, 4, 2, 8, :
Column 10 ['Status Date2'] is a data.frame or data.table; malformed data.table.
^this is the error message I received when running this bit of code (code leading up to the final line here (which is in its own paragraph) is for everyone's context):
intermediate.df <- rbindlist(df.list, idcol = FALSE,fill = FALSE)
secondintermediate.df <- mutate(intermediate.df, 'Status Date' = intermediate.df[,1])
thirdintermediate.df <- mutate(secondintermediate.df, 'Start Date Only' = secondintermediate.df[,9])
names(thirdintermediate.df)[names(thirdintermediate.df) == 'Status Date'] <- 'Status Date2'
thirdintermediate.df <- thirdintermediate.df[, c(10, 1, 5, 6, 4, 2, 8, 7, 9, 11 , 3)]
Here is the background information for everyone's understanding:
- A dataset of 9 variables (Classes from left to right read as follows: character/character/character/character/character/logic/character/character/character)
- Installed + Loaded packages are dplyr/readxl/data.table/lubridate
- I have decided to leave the date values as characters for now and modify them outside of R
Do advise me on what else I can do; I did a search of previous queries in this platform and the closest direction was to use unique attribute labels. I've modified one column (the 2 'similar labels' are originally differentiated by a space; I modified one such label anyway) -https://stackoverflow.com/questions/41106659/malformed-factor-error-in-melt-data-table <- is the closest I could find.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
