I am running a long code not written by me. There is only one snag in the entire code and it is ruining the overall output. The line of code is:
>ppl_inventory_split_rates <- read.csv(file=ppl_inventory_split, header=TRUE, sep=" ")
>for (i in 1:rows) {
>if (ren_ppl[i, "year"] >= start_year && ren_ppl[i, "year"]<= end_year) {
+ y = paste('X',as.character(ren_ppl_split4[i, "year"]), sep = '', collapse= NULL)
# The split rate from ppl_inventory_split_rates is used to split values between PP_EX_OTH and PP_NEW
rateDC_PP_EX_OTH = ppl_inventory_split_rates[ppl_inventory_split_rates["Years"]==ren_ppl_split4[i, "year"] &
ppl_inventory_split_rates["Act_abb_ppl"]=="DC","PP_EX_OTH_ppl"]
rateOS1_PP_EX_OTH = ppl_inventory_split_rates[ppl_inventory_split_rates["Years"]==ren_ppl_split4[i, "year"] &
ppl_inventory_split_rates["Act_abb_ppl"]=="OS1","PP_EX_OTH_ppl"]
The line of error says:
Error in [.data.frame(ppl_inventory_split_rates, "Years") :
undefined columns selected
which I take to mean that the column Years
is not present in the csv file ppl_inventory_split_rates
, but it is indeed present. When I print ppl_inventory_split_rates
though, it does not show a neat table; rather a comma-separated line for headings and comma separated row entries, as below.
>Years.Act_abb_ppl.Power..2000.PP_EX_WB.PP_EX_OTH_ppl..PP_NEW_ppl.PP_IGCC.Total.PP_EX_OTH_ppl...2000.PP_EX_WB.PP_EX_OTH_number.PP_NEW_number.PP_IGCC..Total..PP_TOTAL...........
>1 >
1990,BC1,0,,0,0,0,0,0,0,0,,,BC1,0,0,0,0,,0,,0,,,,,,,,,,,
>2 1990,BC2,0,,0,0,0,0,0,0,0,,,BC2,0,0,0,0,,0,,0,,,,,,,,,,,
>3 1990,HC1,0,,0,0,0,0,0,0,0,,,HC1,0,0,0,0,,0,,0,,,,,,,,,,,
>4 1990,HC2,0,,0,0,0,0,0,0,0,,,HC2,0,0,0,0,,0,,0,,,,,,,,,,,
#and so on for 201 rows.
What seems to be the problem here?
I would be grateful for any help on this. (new to R and still figuring stuff out)