我的数据集有4列和46行。但是,当使用read.csv将其拉入R时,它将创建额外的列和额外的行。 nrow(addr)返回1356行。
请告知!
这是 dput(addr [46:50,])
structure(list(STREET.ADDRESS = structure(c(1L, 1L, 1L, 1L, 1L
), .Label = c("", "102 HEARTLAND BLVD", "105 SANDSTONE DR", "1076 CORNERSTONE ST NE",
"12 EVANSFIELD CRES NW", "121 RANCHERS VIEW", "1305 HAINSTOCK WAY SW",
"1309 HAINSTOCK WAY SW", "13555 96 AVE", "146 DRAKE LANDING GDNS",
"16828 BOXWOOD DR", "19 MONT CLARE PL", "1989 36TH AVE E", "2 WATKISS WAY",
"20087 68 AVE", "20451 84 AVE", "22567 96 AVE NW", "239 WILLOW PL",
"255 MCNAUGHTON AVE", "2578 JAMES ST", "289 MOUNTAINVIEW DR",
"3020 GLADWIN RD", "316 SOUTH HARMONY DR", "350 LATORIA BLVD",
"3500 BURKE VILLAGE PROM", "361 RAVENSTERN LINK SE", "41360 SKYRIDGE PL",
"45545 KIPP AVE", "586 DUGGAN LANE", "6533 BUSWELL ST", "710 STOCKWELL AVE",
"713 TREANOR AVE", "77 RED EMBERS MANOR NE", "777 BATTLE ST",
"7828 GRANVILLE ST", "7908 15TH AVE", "809 VILLAGE DR", "9 CRESTBROOK WAY SW",
"9250 CORBOULD ST", "95 LEGACY CIR SE", "9812 224 ST NW", "9889 SEVENTH ST",
"CORNERSTONE BLVD NE", "GLENRIDDING BLVD SW", "LAKEVIEW DRIVE"
), class = "factor"), CITY = structure(c(1L, 1L, 1L, 1L, 1L), .Label = c("",
"ABBOTSFORD", "AIRDRIE", "BURNABY", "CALGARY", "CHILLIWACK",
"COCHRANE", "COQUITLAM", "EDMONTON", "KAMLOOPS", "KELOWNA", "LANGLEY",
"OKOTOKS", "PARKSVILLE", "PORT COQUITLAM", "PRINCE ALBERT", "QUESNEL",
"RICHMOND", "SQUAMISH", "ST ALBERT", "SURREY", "VANCOUVER", "VICTORIA"
), class = "factor"), PROVINCE = structure(c(1L, 1L, 1L, 1L,
1L), .Label = c("", "ALBERTA", "BRITISH COLUMBIA", "SASKATCHEWAN"
), class = "factor"), POSTAL.CODE = structure(c(1L, 1L, 1L, 1L,
1L), .Label = c("", "T1S0N2", "T1S0P9", "T1S5R7", "T1S5R9", "T2X0W9",
"T3B6G3", "T3N1G8", "T3N1H2", "T3N1K7", "T3P1J8", "T3Z0E5", "T4A0W5",
"T4C0W2", "T4C2P8", "T5T7B8", "T5T7K4", "T6W3B6", "T8N3Y1", "V1Y6V9",
"V2C2M6", "V2J0C3", "V2P0H4", "V2P0H5", "V2T0H4", "V2T0H8", "V2Y0X5",
"V2Y0Y2", "V3B0P6", "V3E0N2", "V3N0G6", "V3V0E4", "V4N6T2", "V5P1C7",
"V6P4Z2", "V6Y0J6", "V8B0Y6", "V8L2V8", "V8Z0E6", "V9B0X5", "V9C0M9",
"V9P1A5"), class = "factor"), X = c(NA, NA, NA, NA, NA), X.1 = c(NA,
NA, NA, NA, NA), X.2 = c(NA, NA, NA, NA, NA), X.3 = c(NA, NA,
NA, NA, NA), X.4 = c(NA, NA, NA, NA, NA), X.5 = c(NA, NA, NA,
NA, NA)), .Names = c("STREET.ADDRESS", "CITY", "PROVINCE", "POSTAL.CODE",
"X", "X.1", "X.2", "X.3", "X.4", "X.5"), row.names = 46:50, class = "data.frame")
答案 0 :(得分:1)
如果您已经知道索引,为什么不呢?
adr <- adr[1:46, 1:4]
还要检查? na.omit