R Can';t可能存在的子集列
我试图更改一些列的名称,并删除其他与本用例无关的列 数据来源: 数据集列名称R Can';t可能存在的子集列,r,dataframe,R,Dataframe,我试图更改一些列的名称,并删除其他与本用例无关的列 数据来源: 数据集列名称 [1] "Permit.Number" [2] "Permit.Type" [3] "Permit.Type.Definition"
[1] "Permit.Number"
[2] "Permit.Type"
[3] "Permit.Type.Definition"
[4] "Permit.Creation.Date"
[5] "Block"
[6] "Lot"
[7] "Street.Number"
[8] "Street.Number.Suffix"
[9] "Street.Name"
[10] "Street.Suffix"
[11] "Unit"
[12] "Unit.Suffix"
[13] "Description"
[14] "Current.Status"
[15] "Current.Status.Date"
[16] "Filed.Date"
[17] "Issued.Date"
[18] "Completed.Date"
[19] "First.Construction.Document.Date"
[20] "Structural.Notification"
[21] "Number.of.Existing.Stories"
[22] "Number.of.Proposed.Stories"
[23] "Voluntary.Soft.Story.Retrofit"
[24] "Fire.Only.Permit"
[25] "Permit.Expiration.Date"
[26] "Estimated.Cost"
[27] "Revised.Cost"
[28] "Existing.Use"
[29] "Existing.Units"
[30] "Proposed.Use"
[31] "Proposed.Units"
[32] "Plansets"
[33] "TIDF.Compliance"
[34] "Existing.Construction.Type"
[35] "Existing.Construction.Type.Description"
[36] "Proposed.Construction.Type"
[37] "Proposed.Construction.Type.Description"
[38] "Site.Permit"
[39] "Supervisor.District"
[40] "Neighborhoods...Analysis.Boundaries"
[41] "Zipcode"
[42] "Location"
[43] "Record.ID"
[44] "SF.Find.Neighborhoods"
[45] "Current.Police.Districts"
[46] "Current.Supervisor.Districts"
[47] "Analysis.Neighborhoods"
[48] "DELETE...Zip.Codes"
[49] "DELETE...Fire.Prevention.Districts"
[50] "DELETE...Supervisor.Districts"
[51] "DELETE...Current.Police.Districts"
[52] "DELETE...Supervisorial_Districts_Waterline_data_from_7pkg_wer3"
数据列名称的长度:
length(colnames(data))
长度(colnames(数据))
[1] 五十二
删除列
colremove=c(“第一份施工文件日期”,
“结构通知”,
“现有故事数”,
“拟议故事数”,
“自愿软故事改造”,
“仅限消防许可证”、“现有单位”,
“拟议单位”、“平面图集”,
“TIDF合规性”、“现有施工类型”,
“拟定施工类型”、“现场许可证”,
“监管区”、“现有警区”,
“现任监管区”,
“当前状态日期”、“许可证创建日期”,
“分析社区”、“地块”、“位置”,
“SF查找社区”、“单位”、“街区”、“许可类型”,
“单位后缀”、“街道编号后缀”,
“现有施工类型说明”)
数据%select(-all_of(colremove))
此处显示错误:
错误:无法子集不存在的列。x列第一份施工文件日期
,结构通知
,现有层数
,拟建层数
,自愿软层改造
等不存在
我已经解决了我面临的问题
data <- data[1:47,!(names(data) %in% colremove)]
data如果你想继续使用dplyr
,你要找的选择助手是any\u of()
,而不是all\u of()
嗨,你为什么反复问,那是因为一个你应该先修复的特定原因关闭的?嘿,我错说了长度(colnames(data))=19
本应为52时。我回来后,话题就结束了。这就是我问这个问题的原因。是的,但我们需要一个答案来回答你的问题。好的。我正在编辑并添加它。
length(colnames(data))
colremove = c("First Construction Document Date",
"Structural Notification",
"Number of Existing Stories",
"Number of Proposed Stories",
"Voluntary Soft Story Retrofit",
"Fire Only Permit","Existing Units",
"Proposed Units","Plansets",
"TIDF Compliance","Existing Construction Type",
"Proposed Construction Type","Site Permit",
"Supervisor District","Current Police Districts",
"Current Supervisor Districts",
"Current Status Date", "Permit Creation Date",
"Analysis Neighborhoods","Lot","Location",
"SF Find Neighborhoods","Unit","Block", "Permit Type",
"Unit Suffix","Street Number Suffix",
"Existing Construction Type Description")
data <- data[colnames(data)[1:47]] %>% select(-all_of(colremove))
data <- data[1:47,!(names(data) %in% colremove)]