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

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.

主站蜘蛛池模板: 济宁市| 喜德县| 临颍县| 得荣县| 汉源县| 成都市| 双城市| 九龙城区| 射阳县| 苍梧县| 囊谦县| 阳泉市| 木兰县| 四平市| 永泰县| 东山县| 铁岭市| 富宁县| 永平县| 上高县| 同仁县| 霍林郭勒市| 锦州市| 娄底市| 黄浦区| 兰考县| 白河县| 和硕县| 长治市| 清水河县| 眉山市| 蕲春县| 陈巴尔虎旗| 保靖县| 梅州市| 花垣县| 宜兴市| 日喀则市| 河北省| 定南县| 怀仁县|