我有一个数据框df:
date values
Apr-15 86
Apr-16 80
Apr-17 60
Aug-14 88
Aug-15 52
Aug-16 76
我想要的输出应该是:
date values
Aug-14 88
Apr-15 86
Aug-15 52
Apr-16 80
Aug-16 76
Apr-17 60
我的日期格式不一样,所以我做不到。
答案 0 :(得分:3)
您可以通过粘贴任意日期值然后将order
df[order(as.Date(paste0("1-", df$date), "%d-%b-%y")), ]
# date values
#4 Aug-14 88
#1 Apr-15 86
#5 Aug-15 52
#2 Apr-16 80
#6 Aug-16 76
#3 Apr-17 60
或使用不需要日期的zoo::as.yearmon
df[order(zoo::as.yearmon(df$date, "%b-%y")), ]
数据
df <- structure(list(date = structure(1:6, .Label = c("Apr-15", "Apr-16",
"Apr-17", "Aug-14", "Aug-15", "Aug-16"), class = "factor"), values = c(86L,
80L, 60L, 88L, 52L, 76L)), class = "data.frame", row.names = c(NA, -6L))
答案 1 :(得分:1)
您可以尝试
const dotenv = require('dotenv');
const axios = require('axios');
const { expect } = require('chai');
dotenv.config({ silent: true });
const { BASE_URL } = process.env;
describe('Test ready link', () => {
it('Should return 204', async () => {
const res = await axios.get(`${BASE_URL}/ready`);
expect(res.status).to.be.equal(204);
expect(res.data).to.be.empty;
});
});
T