이름 배열이 있고이 이름을 데이터 프레임의 열 이름으로 사용하고 싶지만 오류가 발생합니다. 나는 이것을 정확히 어떻게 수행 할 지 모르겠다. 그러나 이것은 내가 지금까지 가지고있는 것이다.데이터 프레임 열 이름 배열 값
windspeeds = data.frame()
cities <- c("albuquerque_nm", "boston_ma", "charlotte_nc", "dallas_tx", "denver_co", "helena_mt", "louisville_ky", "pittsburgh_pa", "salt_lake_city_ut", "seattle_wa")
for(i in 1:10){
fastest <- read.delim(paste("http://www.itl.nist.gov/div898/winds/data/nondirectional/datasets/", cities[i], ".prn", sep=""), col.names=c("NULL", "fastest", "NULL", "NULL"), skip=4, header=F, sep="")$fastest
windspeeds$cities[i] = fastest
}
나는이 오류가 무엇입니까
: 나는 문자열이나 일정의 일부 유형의 배열을 변환해야
Error in `$<-.data.frame`(`*tmp*`, "cities", value = 59L) :
replacement has 1 rows, data has 0
In addition: Warning message:
In windspeeds$cities[i] = fastest :
number of items to replace is not a multiple of replacement length
를?
루프의 '데이터'개체는 무엇입니까? 아, 당신은 그것을 업데이트했습니다 ... – Ben