Hi, have a look at `?melt` and the reshaping vignette:
https://github.com/Rdatatable/data.table/wiki/Getting-started
--
Arun
On 8 November 2015 at 20:42:05, Stefano Grioni ([email protected]) wrote:
Hello,
I am new to R and trying to understand how data manipulation works. I have a
CSV file which allows me to build a data table that looks like the following
(simplified example):
>db
names ages grade_spring_quarter grade_summer_quarter
1: John 24 A A+
2: Steve 16 B+ B
3: Peter 12 C B+
Now, my goal is to denormalize the data table in order to transform the last 2
columns in rows, therefore obtaining the following:
> db2
names ages quarter grades
1: John 24 spring A
2: Steve 16 spring B+
3: Peter 12 spring C
4: John 24 summer A+
5: Steve 16 summer B
6: Peter 12 summer B+
I think that I would be able to do it using for loops, but I doubt that's the
most efficient way. I have started looking into the Join functionality of data
table but so far didn't manage to build db2 from db that way.
Do you see how I could proceed?
Many thanks
Stefano
_______________________________________________
datatable-help mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help
_______________________________________________
datatable-help mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help