Hello! Is this ok? I have not been using R Studio Community for a while. But with these commands I now have the label row in both 1st and last row. In the real data I made column names a key row but I need to have the original labels below as 1st row.
What you are trying to do does not really make any sense. You are adding characters to numeric columns, but if you really need to add the label vector before the other rows:
TEST_DT_NEW <- rbind(as.list(LABEL), TEST_DT)
# or using data.table's function:
TEST_DT_NEW <- rbindlist(list(as.list(LABEL), TEST_DT))
But of course now I see the problem now in the test data. The LABEL row should be character and the rest numeric and factors. Is that even possible?
I have 10 tables with different labels for variables and I made keys to harmonise, but I would like to keep the original labels below as well.
The whole idea turned out to be wrong. Character LABEL row below key column names does not work, because rest of the column values are numeric or factor values. I just thought it would be good to have original labels below key labels.
You can probably just rethink how you wanted to collect your data by flipping the rows and columns. How data is stored is separate from how you may wish to present it for output if that is why you came up with your original set-up.
This has already been quite a task. Sample collections are from 1992 to 2017 and made with different programs, regex and so on. I have to do some rethinking. Anyway, all the information, keys and original labels will be in codebook. I just want to be absolutely sure that everything matches correct.