Data Slice in R
来源:互联网 发布:乐视mac码 编辑:程序博客网 时间:2024/06/01 14:24
1. Data Frame
A data frame is a combination of different vectors.
> x = c(1, 2, 3)> y = c("a", "b", "c")> z = c(TRUE, FALSE, TRUE)> co = data.frame(x, y, z)
2. Column Slice
Numeric Indexing
> co[2] y1 a2 b3 c
Name Indexing
> co["y"] y1 a2 b3 c
3. Row Slice
Numeric Indexing
> co[2,] x y z2 2 b FALSETo retrieve more than one rows at one time
> co[c(2,1),] x y z2 2 b FALSE1 1 a TRUE
Name Index
Row Slice also could be retrieved by name indexing.
Logical Indexing
> L[1] FALSE TRUE FALSE> co[L,"x"][1] 2
4. Subset
subset() function could return subsets of vectors, matrices or data frames which meet conditions.
> co1 <- subset(co, select = y)> co1 y1 a2 b3 cselect indicating columns to select in a data frame
> co2 <- subset(co, x > 1, select = y)> co2 y2 b3 c
subset logical expression indicating elements or row to keep.
5. Statistic of a data set
To get the number of row and columns, nrow() , ncol() , NROW(), NCOL() could be used.
nrow() and ncol() could count for vector, array or data frame, NROW() NCOL() count for 1-column matrix.
> NROW(co$x)[1] 3> nrow(co)[1] 3
0 0
- Data Slice in R
- Data in R
- Reshape Data Form in R
- Best packages for data manipulation in R
- Managing Spark data handles in R
- [R] Mean of columns in a data file
- SDM (slice data model) 即将诞生
- How to Get the Frequency Table of a Categorical Variable as a Data Frame in R
- R and SAS in the curriculum: getting students to "think with data"
- R Programming -- data frames
- R data Manipulation
- R Manage Data
- Slice vs Tile in H.265
- slice operation of consequence in python
- The study of slice in Python(20170911)
- slice
- slice
- [].slice
- 【Hibernate】SessionFactory中的getCurrentSession()和openSession()的区别
- 个人笔记 js 05 关闭子页面的方法
- WebSocket初探
- php重视问题1
- 深入理解网络技术内幕 阅读笔记(五)
- Data Slice in R
- 基于appelt+jasper的web浏览器打印功能
- 如何使用CocoaPods
- Android定时器
- iOS 类簇及越界处理
- nyoj57 6147问题
- Java项目经验——程序员成长的关键
- const char*, char const*, char*const的区别
- 个人笔记 js 06 子页面获取父页面的元素的方法