Here is my code:
x<-c(1,2)
x
names(x)<- c(\"bob\",\"ed\")
x$ed
Why do I get the following error?
Error in x$ed
Because $ does not work on atomic vectors. Use [ or [[ instead. From the help file for $:
The default methods work somewhat differently for atomic vectors, matrices/arrays and for recursive (list-like, see is.recursive) objects. $ is only valid for recursive objects, and is only discussed in the section below on recursive objects.
x[["ed"]] will work.