data.frame的名称是SELECT RequestID
, AgencyName
, Contact
, DeliveryAddress
, ContactPhone
, ContactEmailAddress
, RequestDate
, CASE WHEN RequestStatus=0 THEN 'Pending'
ELSE CASE WHEN RequestStatus=1 THEN 'Approved'
ELSE 'Denied'
END
END AS 'RequestStatus'
FROM tblRequest
WHERE RequestStatus = CASE WHEN @RequestStatus=-1 THEN RequestStatus
ELSE @RequestStatus
END
df
我想要这个:
`Level 4 AN` `Accounting Year` Month ActualCost
1 Pay 2013 1 48950305
2 Pay 2013 2 82147447
3 Pay 2013 3 64976400
请注意,我想将1 Pay 2013 April 48950305
2 Pay 2013 May 82147447
3 Pay 2013 June 64976400
替换为1
等
答案 0 :(得分:3)
R有几个存储的字符向量,包括month.name。
finMonth <- month.name[c(4:12, 1:3)]
finMont[1:4]
[1] "April" "May" "June" "July"
使用此功能,创建财务月份矢量,如下所示:
dat$month <- finMonth[dat$month]
然后,使用索引来分配替换列。
{{1}}
答案 1 :(得分:0)
i = 1:12
# OR you could do
#i = df$Month
month.name[ifelse(i == 9, 12, (i + 3) %% 12)]
# [1] "April" "May" "June" "July" "August" "September"
# [7] "October" "November" "December" "January" "February" "March"