Lists differ from atomic vectors because their elements can be of any type, incl
ID: 3336525 • Letter: L
Question
Lists differ from atomic vectors because their elements can be of any type, including lists, i.e., a lists is a recursive data structure. You construct lists by using list().
The first element of the list is a list with two elements given by [[1]][[1]] and [[1]][[2]]
The elements of the list can be named:
Now click the “Environment” tab on your R Studio and inspect the three objects in your “Global Environment”: l, l.recursive and l.named. Click the downward triangle icon to see the structure of l (and others). The same result is obtained by
Do the same for univ.data as you did for l:
How many elements are listed under univ.data?
Inspect univ.data$metadata. What is the structure of univ.data$metadata?
Notice that univ.data$results is a list of 3, and the first element has no name. Retrieve the first element and store it with a name results1.
List the names of elements within results1.
Explanation / Answer
How many elements are listed under univ.data?
Two elements are listed under univ.data.
1. metadata
2. results
Inspect univ.data$metadata. What is the structure of univ.data$metadata?
univ.data$metadata is a list of 3 elements
The structure of univ.data$metadata is shown below.
List of 3
$ total : int 3
$ page : int 0
$ per_page: int 20
List the names of elements within results1.
Using the command, to retrieve the first element and store it with a name results1.
results1 <- univ.data$results[[1]]
The names of 25 elements of results1 are -
2012, 2011, 2010, 2009, 1998, 2008, 1997, 2007, 1996, 2006, 2005, school, 2004, 2003, 2002, id, 1999, 2000, 2001, ope6_id, 2015, 2014, 2013, ope8_id, location
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.