연습 할 때 간단한 데이터가 있고 각 시간의 최대, 최소 인구를 계산하려고했을 때 아래처럼, 나는 "In max (state $ time.population [look.at])와 같은 경고 메시지를 받았다. 나는 매번 "zone"을 수동으로 변경하여 루프를 하나씩 실행하려고 시도했다. 그 이유는 무엇인지 잘 모르겠습니다. 영역의 각 레벨마다 공백이 있기 때문에 그것이 원인인지 궁금합니다. 나는 그것을 캐릭터로 변경하려했으나 여전히 작동하지 않았습니다 ... 아무도이 문제를 해결할 수있는 방법을 알고 있습니까? 독특한 (주 $의 time.zone.1) the.zones < - -R의 factor 변수에 대한 루프의 경우 (레벨은 공백이있는 문자 임) 경고 메시지 "max에 누락 된 인수 없음"을 반환합니다.
state <- read.csv("states.csv")
state$population <- as.numeric(gsub("\\,","",state$population))
은/* < the.zones as.character (the.zones) */
/새 라인을/
state$time.zone.1 <- as.character(state$time.zone.1)
the.zones <- unique(state$time.zone.1)
low <- c()
high <-c()
for (zone in the.zones){
look.at <- state$time.zone.1 == zone
low <- append(low,min(state$population[look.at]))
high <-append(high,max(state$time.population[look.at]))
}
low
high
Result:
Warning messages:
1: In max(state$time.population[look.at]) :
no non-missing arguments to max; returning -Inf
2: In max(state$time.population[look.at]) :
no non-missing arguments to max; returning -Inf
3: In max(state$time.population[look.at]) :
no non-missing arguments to max; returning -Inf
4: In max(state$time.population[look.at]) :
no non-missing arguments to max; returning -Inf
5: In max(state$time.population[look.at]) :
no non-missing arguments to max; returning -Inf
6: In max(state$time.population[look.at]) :
no non-missing arguments to max; returning -Inf
기타 정보 : 시간대의 레벨 : 레벨 : 알래스카 표준시 (UTC-09) CST (UTC-6) EST (UTC-5) HST (UTC-10) MT (UTC-07) PT (UTC-8) 문자 변경 : "CST (UTC-6)" "AKST (UTC-09)" "MT (UTC-07)" "PT (UTC-8)" "EST (UTC-5)" "HST (UTC- 잠재적 인 이유는 두 가지입니다
name abbreviation capital most.populous.city population square.miles time.zone.1
1 ALABAMA AL Montgomery Birmingham 4,708,708 52,423 CST (UTC-6)
2 ALASKA AK Juneau Anchorage 698,473 656,425 AKST (UTC-09)
3 ARIZONA AZ Phoenix Phoenix 6,595,778 114,006 MT (UTC-07)
4 ARKANSAS AR Little Rock Little Rock 2,889,450 53,182 CST (UTC-6)
5 CALIFORNIA CA Sacramento Los Angeles 36,961,664 163,707 PT (UTC-8)
6 COLORADO CO Denver Denver 5,024,748 104,100 MT (UTC-07)
데이터를 읽는 방법에 대한 추가 정보가 없으면이 연습은 쓸모가 없습니다. 데이터 샘플을 읽고 해당 데이터를 파일 또는 인라인으로 실행되는 데이터 프레임으로 제공 할 준비가 된 MWE를 제공하십시오. – epsilone
그 데이터는 원본 csv 파일을 읽은 후에 인쇄 한 데이터입니다. 나는 수입 과정에 어떤 문제가 있다고 생각하지 않는다. – miaoxingren