Skip to content
Prev 201368 / 398502 Next

how to change the class of a group of objects

Ben, 

In general, when you define a, b, and c as below, the c() wrapper is not needed, since the : operator returns a vector anyway.  Also, best not to name variables 'c' to avoid confusion with the function you're using. 

Regarding your actual question, lapply(list(a, b, c), "class<-", "dist") might work, but your objects in your example don't seem to be able to be coerced to dist objects.  E.g., as.dist(b) gives an error.  If you have data that can actually work as dist objects, you might try the above line though.

Erik