This week's book giveaway is in the NodeJS forum.
We're giving away four copies of Serverless Applications with Node.js and have Slobodan Stojanovic & Aleksandar Simovic on-line!
See this thread for details.
Win a copy of Serverless Applications with Node.js this week in the NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Ron McLeod
  • Tim Moores
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Vijitha Kumara

Access list elements in R  RSS feed

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to access list elements in R?
 
Saloon Keeper
Posts: 9997
208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With double bracket notation:
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Create a list containing a vector, a list and a matrix.

list_data <- list(c("Feb","Mar","Apr"))
list("white",13.4)), matrix(c(3,9,5,1,-2,8), nrow = 2)


For Example: Give names to the elements in the list:

Names(list_data) <- c(“1 st  Quarter”, “A Matrix”, “A Inner list”)
Access the first element of the list:
print(list_data[1])
Access the third element. As it also a list, all its elements will print:
Print(list_data[3])
By using the name of the element access the list elements:
Print(list_data$A Matrix)

It will produced the following result after executing the above code:
$”1 st  Quarter” [1] “Feb”, "Mar”, "Apr”
$A_Inner_list
$A_Inner_list[[1]]
[1] “White”
$A_Inner_list[[2]]
[1] 13.4
$ “A Matrix” [1]
[1]   [2]   [3]
[1]     3     5    -2
[2]     9     1     8
 
a wee bit from the empire
global solutions you can do at home or in your backyard
https://www.kickstarter.com/projects/paulwheaton/better-world-boo
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!