Transpose data table

Hey there,

I have the following data table and I want to transpose it that way:

image

Result:
image

I tried by usind soming like this, but it doesn't work:

dt.data <- data.table("date" = rep(dt.diff$date, ncol(dt.diff)-1), 
                         "daysAhead" = names(dt.diff)[-1], 
                         "deviation" = t(dt.diff[, 2:ncol(dt.diff)]))

Thank you :slight_smile:

Fast melt for data.table — melt.data.table • data.table (rdatatable.gitlab.io)

Thanks, it works with:

melt(dt.data, id.vars = 1:1)

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.