- 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
- iOS Game Programming Cookbook
- Learning ROS for Robotics Programming(Second Edition)
- OpenDaylight Cookbook
- oreilly精品圖書(shū):軟件開(kāi)發(fā)者路線(xiàn)圖叢書(shū)(共8冊(cè))
- INSTANT Yii 1.1 Application Development Starter
- H5+移動(dòng)營(yíng)銷(xiāo)設(shè)計(jì)寶典
- Clojure High Performance Programming(Second Edition)
- 3ds Max 2018從入門(mén)到精通
- Web前端測(cè)試與集成:Jasmine/Selenium/Protractor/Jenkins的最佳實(shí)踐
- 編程的原則:改善代碼質(zhì)量的101個(gè)方法
- 高質(zhì)量程序設(shè)計(jì)指南:C++/C語(yǔ)言
- The Applied Data Science Workshop
- 前端程序員面試算法寶典
- INSTANT Lift Web Applications How-to
- 微服務(wù)設(shè)計(jì)