2016-12-14 1 views
2

I가 반환 다음 목록 listaValores이름 바꾸기 목록 항목

listaValores <- c() 
    for(valores in 1:numRepeticion){ 
    listaValores <- c(listaValores, readWorksheetFromFile(file = file.read,   
         sheet = sheet.read, 
         startRow = startRow.read+(12*(valores-1)), 
         startCol = startCol.read[i], 
         endRow = startRow.read+((12*valores)-1) , 
         endCol = startCol.read[i], header = FALSE)) 
    } 

:

$Col1 
[1] 32824 35646 34650 29328 27376 28548 35363 34740 49181 57960 55550 50626 

$Col1 
[1] 52610 55085 58576 51300 50968 58104 56585 38273 54216 59043 67487 58067 

$Col1 
[1] 59142 68593 77510 73434 83545 83483 79635 69269 85703 73080 

방법은 2014, 2015, 2016에 요소를의 이름을 변경하기 위해?

+1

고지,'listaValores'는 목록입니다. 따라서'colnames'가 아닌 슬롯 이름을 가지고 있습니다. – loki

답변

7

list입니다. 따라서 colnames이 아니라 names이 없습니다. 이처럼 편집 할 수 있습니다 : 당신이 R에서 다른 데이터 유형에 대한 자세한 내용을 알고 싶은 경우에, 나는 Hadley Wickham's summary을 추천 할 수

l <- list(col1 = c(123123, 12123, 123123), col1 = c(123123, 12123, 123123)) 
l 
# $col1 
# [1] 123123 12123 123123 
# 
# $col1 
# [1] 123123 12123 123123 

names(l) 
# [1] "col1" "col1" 

names(l) <- c("2014", "2015") 

l 

# $`2014` 
# [1] 123123 12123 123123 
# 
# $`2015` 
# [1] 123123 12123 123123 

.