[datatable-help] Data shape from wide to long

Lask_Linz ulrich.spiess at gmx.at
Mon Apr 10 15:44:42 CEST 2017


I have 9 different daily variables (share price, bid price, ask price, shares
outstanding, etc...) for appr. 900 companies over 2 years. In the first
column is the date, and then the following 9 columns are the 9 variables for
the first firm (price1, bid price1, ask price1,...), followed by the
variables for the 2nd firm (price2, bid price2, ask price2,...) etc...

I want to shape the data into the long format with the first column as the
date, second column as the firm number and then the 9 variables.

I have already tried it with the gather() function and have 4 columns now
with the date, firm number, variable and the value. But I don´t know how to
shape it that I get the 9 variables into 9 columns?

Thanks a lot for any help.



--
View this message in context: http://r.789695.n4.nabble.com/Data-shape-from-wide-to-long-tp4731342.html
Sent from the datatable-help mailing list archive at Nabble.com.


More information about the datatable-help mailing list