私は知っている誰も私はこれの前にこのような記事を見たことがあるが、何らかの理由で私が試したアドバイスのどれも働いていない。本質的に私がしようとしているのは、 "Production.Period.End.Date"という名前の変数から日付を取ってdd/mm/yyyyという形式にして、これらの日付の各部分を別のオブジェクトに変換して分析することです。私がこれをやっている理由は、 "Period_kWh_Production"という年平均キロワット生産を取り、その残業の変化を追跡するためです。私がこれまでに書いたコードを貼り付けておけば助けになる。別のオブジェクトに苦しんでいる年
setwd( "C:\ Users \ユーザーfredd \ Dropboxが\ Grad_Life \ Spring_2017 \ AFM \ Final_Paper \")このコードはdplyrとlubridateパッケージに依存すべき
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>")
私はそれを試してみましたが、何らかの理由で、私は入れません{4} ' – sln