Google News
logo
R - Interview Questions
What do you mean by casting? What is the use of cast() function?
It is used to get aggregate after melt(). So, now we have data arranged in some order, if we want to aggregate the columns with similar company_name and age, then we should use the cast() function.
 
Example :
Casted_data_set <- cast(new_data_set, company_name+age ~ variable, sum)
The function gives the aggregate salary and number of children with the same company and age.
Advertisement