I tried to reshape the data frame that converting the entries in one column to be the row names. Then I use cast () , but I gotta following error when I retrieved the data inside new data frame.
Here is original data frame:
ID Type rating
1 1 3.5
1 2 4.0
2 2 2.5
And the code:
r_mat <-cast(r_data,ID~type)
r_mat$1
unexpected numeric constant in r_mat$1
here is new data frame looks like:
ID 1 2
1 3.5 4.0
2 NA 2.5
Can anyone kindly help me coping with the error ? Thanks!