'What does $mix$a and $mix$b in R means?

we have been asked to do a small task. I am new to R programming and I don't understand what the $mix, $mix$a and $mix$b mean in the below question.

I know when the $ sign is used that means to extract a column from a dataframe or a matrix. But I don't understand what $mix$a and $mix$b means.

Can you please explain?

Thanks.. :)



Solution 1:[1]

We can use [[ for extraction

mydata[["mix"]]
$a
[1] "text"

$b
 first second  third 
    97     98     99 
mydata[["mix"]][["a"]]
[1] "text"

Or another option is pluck

library(purrr)
pluck(mydata, "mix", "a")
[1] "text"

data

mydata <- list("Some long text", 1:5, 
              mix = list(a = 'text', b = c(first = 97, second = 98, third = 99)))

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 akrun