r - 在 R 中选择 data.frame 的前 4 行

标签 r dataframe

如何选择 data.frame 的前 4 行:

              Weight Response
1   Control     59      0.0
2 Treatment     90      0.8
3 Treatment     47      0.1
4 Treamment    106      0.1
5   Control     85      0.7
6 Treatment     73      0.6
7   Control     61      0.2

最佳答案

使用head:

dnow <- data.frame(x=rnorm(100), y=runif(100))
head(dnow,4) ## default is 6

关于r - 在 R 中选择 data.frame 的前 4 行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2667673/

相关文章:

r - R中的apply()与sweep()

r - ggplot : How to retrieve values for axis labels?

r - 在因子变量上使用 nchar 函数

替换 R 数据框中变量中的特定字符

python - 使用带有参数的 Pandas groupby() + apply()

python - Pandas 中 DataFrame 列表的按行映射

python - Pandas 索引插值填充最后一个数据点之后的缺失值

python - 在具有不同索引的两个数据帧上进行 Pandas 计算

r - 如何在不同的数据框中找到共同的变量?

r - 如何在嵌套函数中将所有可能的内容传递给 i、j 和 by?