1) long to wide question:
I have a dataset with 3 columns:
person, event, frequency.
If the frequency is zero, the row is not in the table. Is there a simple way using basic R functions or libraries to convert this table to wide format, with one row per person and one column per event with the frequency as the value in table.
2) rattle question:
On a related note, is this even necessary for Rattle to understand as an input?
I am trying to import some data into R to explore some of Rattle’s machine learning algorithms.
Thanks!
Patrick McCann
For the first part of your question, you can either use the
reshape()function that’s in base R or use thereshapepackage (with thecast()function).Here’s an example of using the
reshape()function (from the help file):Here’s a simple example of using
meltandcast(from the reshape help):