안녕하세요 여러분, 제가 전에 알고있는 모든 게시물을 본 적이 있습니다. 그러나 어떤 이유로 든 제가 시도한 조언이 전혀 효과가 없었습니다. 본질적으로 내가하려는 것은 dd/mm/yyyy 형식의 "Production.Period.End.Date"라는 변수에서 날짜를 가져 와서이 날짜의 각 부분을 분석 할 개별 객체로 변환하는 것입니다. 내가 이것을하는 이유는 "Period_kWh_Production"이라고 표시된 연간 평균 킬로와트 생산량을 취하고 그 초과 근무 시간의 변화를 추적하기 위해서입니다. 그 코드가 내가 도움이된다면 아래에 두었습니다.문제가 올해 별도의 개체로 변하기 시작했습니다
setwd ("C : \ 사용자 \ fredd \ 드롭 박스 \ Grad_Life \ Spring_2017 \ AFM \ Final_Paper \")
KWTProd.df = read.csv("Merge1//Kwht_Production_07-15.csv", header=T)
##Did this to verify "Production.Period.End.Date"
names(KWTProd.df)
##
names(KWTProd.df)
[1] "Application.Number"
[2] "Program.Administrator"
[3] "Program"
[4] "Total.Cost"
[5] "System.Owner.Sector"
[6] "Host.Customer.Sector"
[7] "Host.Customer.Physical.Address.City"
[8] "Host.Customer.Physical.Address.County"
[9] "Host.Customer.Physical.Address.Zip.Code"
[10] "PBI.Payment.."
[11] "Production.Period.End.Date"
[12] "Period_kWh_Production" <-IT EXISTS ##
##
##Did this to plot changes of Period_kWh_Production over time##
plot(Period_kWh_Production ~ Production.Period.End.Date, data = KWTProd.df)
##Tried to do this to aggregate data in average##
aggregate(Period_kWh_Production~Production.Period.End.Date,KWTProd.df,mean)
##Still too noisy and can't find the mean by year :C##
as.date(Production.Period.End.Date, data = KWTProd.df)
##Says "Production.Period.End.Date" Not found BUT IT EXISTS##
##Tried this to group and summarise by year but it says: Error in UseMethod("mutate_") :
no applicable method for 'mutate_' applied to an object of class "function" ##
summary <- df %>%
mutate(dates = dmy(Production.Period.End.Date),
year = year(Production.Period.End.Date)) %>%
group_by(year) %>%
summarise(mean = mean(x, na.rm = TRUE),
sd = sd(x, na.rm = TRUE))
##Trying this but have no clue how I am supposed to use this##
regexpr("<dd>")
코드에 대해 잘 모르겠지만, 정규식은 '\ d 개입니다 {2}/\ D {2}/\ D {4}' – sln