Deloitte Interview Questions | What is reshaping in R?
Question
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
It will take less than 1 minute to register for lifetime. Bonus Tip - We don't send OTP to your email id Make Sure to use your own email id for free books and giveaways
Answers ( 2 )
Data Reshaping in R is about changing the way data is organized into rows and columns.
We can join multiple vectors to create a data frame using the cbind()function.
Also we can merge two data frames using rbind() function.
We can merge two data frames by using the merge() function. The data frames must have
same column names on which the merging happens.
You can also use melt() and cast() function to convert the features into values of a DataFrame
and vice versa.
The following tutorial gives code examples for all the above cases.
https://www.tutorialspoint.com/r/r_data_reshaping.htm#:~:text=Data%20Reshaping%20in%20R%20is,organized%20into%20rows%20and%20columns.&text=It%20is%20easy%20to%20extract,in%20which%20we%20received%20it.
Reshape function in R transforms the data from wide to long and also transforms back the data from long to wide. Reshape in R – reshape()
Reshape from wide to long using reshape(), gather() and melt() function
Reshape from long to wide using reshape(), spread() and dcast() function