이것은 매우 기본적인 것이지만, 지금 당분간 붙어 있습니다.관측치 제거하기
hitters <- hitters[!hitters$Colname == "-Steve Sax",]
또는
hitters <- hitters[hitters$AtBat != "-Steve Sax", ]
: 내가 사용했을 첫 번째 열의 이름을 알았다면
> dput(hitters[280:290,])
structure(list(AtBat = c(439L, 453L, 528L, 633L, 16L, 562L, 281L,
593L, 687L, 368L, 263L), Hits = c(96L, 103L, 122L, 210L, 2L,
169L, 76L, 152L, 213L, 103L, 70L), HmRun = c(0L, 8L, 1L, 6L,
0L, 17L, 3L, 23L, 10L, 3L, 1L), Runs = c(44L, 53L, 67L, 91L,
1L, 88L, 42L, 69L, 91L, 48L, 26L), RBI = c(36L, 33L, 45L, 56L,
0L, 73L, 25L, 75L, 65L, 28L, 23L), Walks = c(65L, 52L, 51L, 59L,
0L, 53L, 20L, 53L, 27L, 54L, 30L), Years = c(4L, 2L, 4L, 6L,
2L, 8L, 8L, 6L, 4L, 8L, 4L), CAtBat = c(711L, 507L, 1716L, 3070L,
28L, 3181L, 2658L, 2765L, 1518L, 1897L, 888L), CHits = c(148L,
123L, 403L, 872L, 4L, 841L, 657L, 686L, 448L, 493L, 220L), CHmRun = c(1L,
8L, 12L, 19L, 0L, 61L, 48L, 133L, 15L, 9L, 9L), CRuns = c(68L,
63L, 211L, 420L, 1L, 450L, 324L, 369L, 196L, 207L, 83L), CRBI = c(56L,
39L, 146L, 230L, 0L, 342L, 300L, 384L, 137L, 162L, 82L), CWalks = c(99L,
58L, 155L, 274L, 0L, 373L, 179L, 321L, 89L, 198L, 86L), League = structure(c(2L,
1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 2L), .Label = c("A", "N"), class = "factor"),
Division = structure(c(1L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 1L,
2L, 1L), .Label = c("E", "W"), class = "factor"), PutOuts = c(229L,
289L, 209L, 367L, 247L, 351L, 106L, 315L, 294L, 209L, 81L
), Assists = c(406L, 407L, 372L, 432L, 4L, 442L, 144L, 10L,
445L, 246L, 147L), Errors = c(22L, 6L, 17L, 16L, 8L, 17L,
7L, 6L, 13L, 3L, 4L), Salary = c(150, 105, 350, 90, NA, 530,
341.667, 940, 350, 326.667, 250), NewLeague = structure(c(2L,
1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 2L), .Label = c("A",
"N"), class = "factor")), .Names = c("AtBat", "Hits", "HmRun",
"Runs", "RBI", "Walks", "Years", "CAtBat", "CHits", "CHmRun",
"CRuns", "CRBI", "CWalks", "League", "Division", "PutOuts", "Assists",
"Errors", "Salary", "NewLeague"), row.names = c("-Steve Jeltz",
"-Steve Lombardozzi", "-Spike Owen", "-Steve Sax", "-Tony Armas",
"-Tony Bernazard", "-Tom Brookens", "-Tom Brunansky", "-Tony Fernandez",
"-Tim Flannery", "-Tom Foley"), class = "data.frame")
:
나는 데이터 집합 hitters.txt
에서 관찰 -Steven Sax
를 제거 원하는
하지만 k는 없습니다. 이제 첫 번째 열의 이름 :
. 나는 시도했다 : read.table("hitters.txt", head = F)
`와
read.table("hitters.txt", head = F)
내 질문
은을 :이-
?
- 왜
head = T
가 작동하지 않았습니까?
당신은'이름 (타자)를 사용하여 열 이름을 얻을 수있는' – G5W
당신은 타자 '로 첫 번째 열을 호출 할 수 있습니다 [1]'당신은 이름을 모르는 경우 . 그럼에도 불구하고, 당신은 우리에게 '타자'클래스의 대상과 그 차원을 말하고 '머리 (타자)'가 당신에게주는 것을 인쇄 할 수 있습니까? – R18
@Danke'head' 함수와'header' 매개 변수를 혼동하지 마십시오. 'header = T'를 제일 먼저 써야합니다. – Smich7