我正在尝试重命名R中的一列。我有一个列表,希望重命名该列表中数据帧的一列。
这是我控制台上的一段摘录。
> colnames(Prem[["TasNSW"]])
[1] "Master Client Number" "Master Client Name" "Policy Number" "State"
[5] "Policy Name" "Year" "Effective Date" "Expiry Date"
[9] "Estimate/Actual" "Total Wages" "Master Client Name "
> colnames(Prem[["TasNSW"]][10]) <- "Remuneration"
> colnames(Prem[["TasNSW"]])
[1] "Master Client Number" "Master Client Name" "Policy Number" "State"
[5] "Policy Name" "Year" "Effective Date" "Expiry Date"
[9] "Estimate/Actual" "Total Wages" "Master Client Name "
我希望看到的是
> colnames(Prem[["NSW"]])
[1] "Master Client Number" "Master Client Name" "Policy Number" "State"
[5] "Policy Name" "Year" "Effective Date" "Expiry Date"
[9] "Estimate/Actual" "Total Wages" "Master Client Name "
> colnames(Prem[["NSW"]][10]) <- "Remuneration"
> colnames(Prem[["NSW"]])
[1] "Master Client Number" "Master Client Name" "Policy Number" "State"
[5] "Policy Name" "Year" "Effective Date" "Expiry Date"
[9] "Estimate/Actual" "Remuneration" "Master Client Name "
我已经多次使用该代码,因此我认为问题是基于它在列表中的存在。我错过了什么?