Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有同名的行,我想将它们转换为保留列主名称的列,并根据存在的列数添加 1 或 2 等。
我用它来制作它:
setDT(df)[, N:= 1:.N, maincol] df <- dcast(df, url~N, value.var=c("stock"))
我期望的是有stock_1、stock_2 等名称。但是每列只有数字1,2 等。我该如何修改它?