I have a large data set around 3 columns and 600000 rows. After pivoting it will convert to 1000 columns and 600 rows.
Subset of input data
Date Id Price
2014/12/03 Id1 100
2014/12/03 Id2 120
2014/12/03 Id3 110
2014/12/03 Id4 105
2014/12/02 Id1 150
2014/12/02 Id2 115
2014/12/02 Id3 140
2014/12/02 Id4 135
2014/12/01 Id1 165
2014/12/01 Id2 155
2014/12/01 Id3 185
2014/12/01 Id4 195
2014/11/30 Id1 160
2014/11/30 Id2 170
2014/11/30 Id3 180
2014/11/30 Id4 190
Output data after pivoting
Date Id1 Id2 Id3 Id4
2014/12/03 100 120 110 105
2014/12/02 150 115 140 135
2014/12/01 165 155 185 195
2014/11/30 160 170 180 190
As data set will be large, which will be more performance efficient?
1. Pivot in SQL and return to R
2. Return original dataset to R and perform pivot in R
I am using RODBC to fetch data from MSSQL server. Any suggestion regarding this?