I am new to R. I just started 2 days ago, I was following along with my instructor on the topic of naming list. I had seen an example done, and decided to do on my own.
list('Chicago' = 1, 'New York' = 2, 'Los Angeles' = 3)
$Chicago
Every time I run this code I keep getting the error message Error: unexpected '$' in "$" I was trying to print out 1, the numeric stored in Chicago
CodePudding user response:
You should assign your list to a name to access it again.
mylist <- list('Chicago' = 1, 'New York' = 2, 'Los Angeles' = 3)
mylist$Chicago
# [1] 1