- Modern R Programming Cookbook
- Jaynal Abedin
- 150字
- 2021-07-08 09:48:35
How it works…
The conversion from a matrix to a data frame works simply by assigning column names and then assigning the class property as data.frame. Since a matrix only contains one data type, the resultant data frame also contains only one data type.
The conversion of a data frame to a matrix with heterogeneous data types works a bit differently. First, it converts all columns into higher and more general data types as follows:
- A combination of character and any other data type produces a character vector
- A combination of numeric and logical data type produces a numeric vector
- A combination of complex and numeric or logical data type produces a complex vector
Then, it keeps only one type of data because a matrix is restricted to only one data type. Also, during the conversion, it preserves the column names, which can be accessed by the colnames() function.
推薦閱讀
- C語言程序設(shè)計(jì)案例教程(第2版)
- Mastering Natural Language Processing with Python
- Microsoft Dynamics GP 2013 Reporting, Second Edition
- 人人都懂設(shè)計(jì)模式:從生活中領(lǐng)悟設(shè)計(jì)模式(Python實(shí)現(xiàn))
- Go并發(fā)編程實(shí)戰(zhàn)
- C專家編程
- 零基礎(chǔ)學(xué)Kotlin之Android項(xiàng)目開發(fā)實(shí)戰(zhàn)
- Learning AWS
- Unity Character Animation with Mecanim
- Java Web開發(fā)教程:基于Struts2+Hibernate+Spring
- Swift High Performance
- Visual Basic語言程序設(shè)計(jì)上機(jī)指導(dǎo)與練習(xí)(第3版)
- 美麗洞察力:從化妝品行業(yè)看顧客需求洞察
- jMonkeyEngine 3.0 Beginner’s Guide
- R語言數(shù)據(jù)分析從入門到實(shí)戰(zhàn)