官术网_书友最值得收藏!

Data frames

Data frames are special lists that can also store tabular values. However, there is a constraint on the length of elements in the lists: they all have to be of a similar length. You can consider every element in the list as columns, and their lengths can be considered as rows.

Just like lists, a data frame can have objects belonging to different classes in a column; this was not allowed in matrices.

Let's quickly create a data frame using the data.frame() function:

a <- c(1, 3, 5)
b <- c("red", "yellow", "blue")
c <- c(TRUE, FALSE, TRUE)
df <- data.frame(a, b, c)
df
## a b c
## 1 red TRUE
## 3 yellow FALSE
## 5 blue TRUE

You can see the headers of a table as a, b, and c; they are the column names. Every line of the table represents a row, starting with the name of each row.

主站蜘蛛池模板: 南投县| 定兴县| 巧家县| 田东县| 同德县| 新民市| 上林县| 黑水县| 镇原县| 元氏县| 闸北区| 松阳县| 郁南县| 年辖:市辖区| 遂川县| 金坛市| 柳河县| 荆门市| 东乌珠穆沁旗| 肇庆市| 香港| 乳源| 都匀市| 泗洪县| 五河县| 呈贡县| 涟水县| 西华县| 枝江市| 千阳县| 彩票| 肥东县| 改则县| 城步| 长乐市| 昌邑市| 彰武县| 定陶县| 理塘县| 镇安县| 高台县|