- R Programming Fundamentals
- Kaelen Medeiros
- 154字
- 2021-07-23 16:58:21
Dataframes
A dataframe in R is a 2D object where the columns can contain data of different classes and types. This is very useful for practical data storage.
Dataframes can be created by using as.data.frame() on applicable objects or by column- or row-binding vectors using cbind.data.frame() or rbind.data.frame(). Here's an example where we can create a list of nested lists and turn it into a data frame:
list_for_df <- list(list(1:3), list(4:6), list(7:9))
example_df <- as.data.frame(list_for_df)
example_df will have three rows and three columns. We can set the column names just as we did with the matrix, though it isn't common practice in R to set the row names for most analyses. It can be demonstrated by the following code:
colnames(example_df) <- c("one", "two", "three")
We have covered a few of the key data structures in R in this section, and we have seen how to create and manipulate them. Let's try a few examples.
- TestStand工業自動化測試管理(典藏版)
- 來吧!帶你玩轉Excel VBA
- 深度學習中的圖像分類與對抗技術
- 數據庫原理與應用技術
- Hadoop Real-World Solutions Cookbook(Second Edition)
- Spark大數據技術與應用
- MATLAB/Simulink權威指南:開發環境、程序設計、系統仿真與案例實戰
- Excel 2007常見技法與行業應用實例精講
- 統計挖掘與機器學習:大數據預測建模和分析技術(原書第3版)
- Spatial Analytics with ArcGIS
- 人工智能:智能人機交互
- 單片機C51應用技術
- 分布式Java應用
- 輸送技術、設備與工業應用
- Hands-On Artificial Intelligence for Beginners