I was recently surprised to find that the following didn't work:
output<-array(1:10) names(output[1])<-"Foo"
As far as I can tell, this does not changes the name of output[1]. Is it possible to modify the names of the individual elements of an array like this? Or am I forced to write code that modifies the entire array, like names(output)<-c("foo",rep(NA,9))?
output[1]
names(output)<-c("foo",rep(NA,9))
You want to change the first name of an element, so [1] goes outside names(output):
[1]
names(output)
output<-array(1:10) names(output)[1]<-"Foo" names(output) #> [1] "Foo" NA NA NA NA NA NA NA NA NA
2.1m questions
2.1m answers
60 comments
57.0k users