为什么R不从绝对存在的csv文件中读取列?

时间:2018-11-26 15:41:23

标签: r

我运行的不是我写的长代码。整个代码中只有一个障碍,它破坏了整体输出。 代码行是:

>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"]

错误行显示:

  

[。data.frame(ppl_inventory_split_rates,“年”)中的错误:
  未定义的列已选择

,我的意思是csv文件Years中没有列ppl_inventory_split_rates,但确实存在。但是,当我打印ppl_inventory_split_rates时,它没有显示整齐的表格;标题和逗号分隔的行条目的逗号分隔行,如下所示。

>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.

这里似乎是什么问题?

对此,我将不胜感激。 (是R的新手,仍在弄清楚东西)

0 个答案:

没有答案