- 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
- Banana Pi Cookbook
- ADI DSP應(yīng)用技術(shù)集錦
- Jupyter數(shù)據(jù)科學(xué)實戰(zhàn)
- Learning Concurrent Programming in Scala
- Lighttpd源碼分析
- 智能搜索和推薦系統(tǒng):原理、算法與應(yīng)用
- OpenCV with Python By Example
- Angular應(yīng)用程序開發(fā)指南
- 創(chuàng)意UI Photoshop玩轉(zhuǎn)移動UI設(shè)計
- 虛擬現(xiàn)實建模與編程(SketchUp+OSG開發(fā)技術(shù))
- Java程序設(shè)計教程
- Spring Boot從入門到實戰(zhàn)
- Java網(wǎng)絡(luò)編程實用精解
- PhoneGap 3.x Mobile Application Development Hotshot
- R for Data Science Cookbook