1
私のコードにエラーメッセージが表示されます。 Googleではいくつかの質問をGoogleから受け取りましたが、解決方法についてはまだ混乱しています。 私のコードをチェックしてこの問題を解決する手助けがあれば、非常に感謝します。 ありがとうございました。 私のコードは次のとおりです。行列のあなたdt <- do.call(rbind, dt)
結果ので、おそらくです<>内のエラー: 'closure'タイプのオブジェクトはサブセット化できません。それでも解決する方法がわかりません
rm(list = ls())
library(XLConnect)
setwd('C:/Users/YL1/Desktop/Air Qulaity/Power Plant/
NOx_SO2_Emission') # replace it with your own directory
file <- 'C:/Users/YL1/Desktop/Air Qulaity/
Power Plant/NOx_SO2_Emission/
Total Emission_2003-2015.xlsx'
wb <- loadWorkbook(file)
dt <- lapply(2003:2015, function(x) readWorksheet(wb, sheet = as.character(x)))
dt <- do.call(rbind, dt)
colnames(dt) <- c('State', 'Facility.Name', 'Facility.ID.ORISPL', 'Year',
'SO2.tons', 'NOx.tons')
dt.select.fun <- function(station) {
dt.select <- dt[dt$Facility.Name == station, ]
dt.select <- dt.select[order(-dt.select$Year), ]
write.csv(dt.select, paste0(station, '.csv'))
return(dt.select)
}
# change station to other values to extract the emission in other stations
dt.select.fun(station = 'Coffeen')
> Error in dt$Facility.Name : object of type 'closure' is not
> subsettable
感謝。しかし問題はまだそこにある。 –
ありがとうございました!これはうまくいくようですが、新しいエラーが発生します:dt.select.fun(dt、station = "898")のエラー:未使用の引数(dt)。詳細を知りたい場合は、あなたのレビューのために自分のコードとデータを送ることができます。メールをお送りください。どうもありがとう。 –
あなたの関数に引数を渡す必要があります 'dt.select.fun
user5249203