I have a dataframe
like this:
salesDat
id time amount
1 12 100
1 14 120
1 22 120
2 5 30
2 12 30
3 40 3
3 75 20
3 80 20
3 85 75
What do I want?
I want to find the max
time
value and only use that value so that the id
column is unique.
eg: the new dataframe
will look like this
salesDat
id time amount
1 22 120
2 12 30
3 85 75
What did I do?
I used reshape2
package
library(reshape2)
uniqueSalesDat <- dcast(salesDat,
id~time)
The code does not work. How do I fix it?