O'Reilly logo

Learning Shiny by Hernán G. Resnizky

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

reshape2

reshape2 is a package that consists mainly of two functions: melt and dcast/acast. Generally, it could be said that melt() transforms one row to multiple and shorter rows while dcast() and acast() do exactly the opposite.

The melt() function, basically, transforms one row of data to many by pivoting a set of variables (the measure variables) over a set of other variables (the id variables). The function is called as follows:

melt(dataset,id.vars,measure.vars,variable_name)

The id variables are usually factors or characters while the measure variables are the numeric ones. In fact, this is the behavior by default if none of the arguments are specified. variable_name is the name that adopts the column where the variables are specified (

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required