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

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.

主站蜘蛛池模板: 韩城市| 西宁市| 清苑县| 苏尼特左旗| 通许县| 横山县| 和静县| 大姚县| 溧阳市| 岫岩| 天台县| 巴南区| 尚义县| 常熟市| 鄂伦春自治旗| 天峨县| 霍邱县| 南陵县| 汝南县| 驻马店市| 汤原县| 阿瓦提县| 察哈| 宁强县| 黎川县| 茂名市| 乌拉特前旗| 潼南县| 济南市| 杂多县| 普兰店市| 卫辉市| 大姚县| 进贤县| 江川县| 宁德市| 旬邑县| 静乐县| 泌阳县| 崇明县| 利辛县|