I've the following data from a data frame
我从数据框中得到以下数据
Name,JoiningDate,AmtPaid
Joe,12/31/09,1000
Amy,10/28/09,100
John,05/06/10,200
The Joining Date is coming in as a factor (when I sapply
). How can I convert this to date and then sort on JoiningDate
?
加入日期是一个因素(当我开心时)。如何将此转换为日期然后对JoiningDate进行排序?
1 个解决方案
#1
36
This should do it (where df is your dataframe)
这应该这样做(其中df是你的数据帧)
df$JoiningDate <- as.Date(df$JoiningDate , "%m/%d/%y")
df[order(df$JoiningDate ),]
#1
36
This should do it (where df is your dataframe)
这应该这样做(其中df是你的数据帧)
df$JoiningDate <- as.Date(df$JoiningDate , "%m/%d/%y")
df[order(df$JoiningDate ),]