I am new to R. I just started 2 days ago, I was following along with my instructor on the topic of naming vectors. I had seen an example done, and decided to do on my own.
list('Chicago' = 1, 'New York' = 2, 'Los Angeles' = 3)
$Chicago
Ever y time I run this code I keep getting the error message Error: unexpected '' in " "
FJCC
July 1, 2022, 12:37pm
2
You have to store the value of the list() function in a variable. Compare these two versions of the code.
#first version
list('Chicago' = 1, 'New York' = 2, 'Los Angeles' = 3)
$Chicago
[1] 1
$`New York`
[1] 2
$`Los Angeles`
[1] 3
$Chicago
Error: unexpected '$' in "$"
#second version
MyList <- list('Chicago' = 1, 'New York' = 2, 'Los Angeles' = 3)
MyList$Chicago
[1] 1
system
Closed
July 8, 2022, 12:37pm
3
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed. If you have a query related to it or one of the replies, start a new topic and refer back with a link.