- Modern R Programming Cookbook
- Jaynal Abedin
- 172字
- 2021-07-08 09:48:34
How it works…
The list() function works just like the concatenation function c(). It places each of the elements next to each other, while preserving their original data types and names of the objects. To get access to the component of a list, the simplest way is to use the double-square brackets along with a sequential index number of the element position as follows:
listA[[1]]
The preceding function will give the output of the first element of the list, which is a character vector of four elements, as follows:
[1] "Cricket" "Football" "Basetball" "Rugby"
You can use the dollar $ operator next to the name of the list object to extract elements from the list. However, the list object must be a named list; otherwise the $ operator will not work. For example, to extract the data frame from listB, execute the following code snippet:
listB$data1
> listB$data1
ID hourSpetOnInternet GENDER
1 1 5 M
2 2 3 F
3 3 4 F
4 4 1 M
5 5 2 F
- Go Web編程
- 零基礎搭建量化投資系統:以Python為工具
- 青少年美育趣味課堂:XMind思維導圖制作
- Java FX應用開發教程
- Functional Programming in JavaScript
- 單片機應用與調試項目教程(C語言版)
- Spring Boot企業級項目開發實戰
- RealSenseTM互動開發實戰
- 新一代SDN:VMware NSX 網絡原理與實踐
- Service Mesh實戰:基于Linkerd和Kubernetes的微服務實踐
- Visual Studio 2015高級編程(第6版)
- Struts 2.x權威指南
- 玩轉.NET Micro Framework移植:基于STM32F10x處理器
- Go語言入門經典
- Arduino電子設計實戰指南:零基礎篇