- R Programming Fundamentals
- Kaelen Medeiros
- 227字
- 2021-07-23 16:58:19
Variable Types
Variable types exist in all programming languages and will tell the computer how to store and access a variable.
First, know that all variables created in R will have a class and a type. You can look at the class or type of anything in R using the class() and typeof() functions, respectively.
The class of an object is a broad designation, for example, character, numeric, integer, and date. These are very broad categories, and type elaborates more specifically on what type of variable it is, for example, a variable of class date can be of type character or POSIXct, depending on how it is stored. Type drills down into the details of a variable and how it's been stored in R, though sometimes class and type can be the same. For example, integers are of class and type integer, and character strings are of type and class character. Let's examine the following code snippet:
x <- 4.2
class(x)
typeof(x)
The preceding code provides the following output:

In this snippet, x has a class numeric, because it is a number, but also has a type double because it is a decimal number. This is because all numeric data in R is of type double unless the object has been explicitly declared to be an integer. Let's look at some examples of different classes and types.
- 高效能辦公必修課:Word圖文處理
- 基于LabWindows/CVI的虛擬儀器設計與應用
- 蕩胸生層云:C語言開發修行實錄
- MCSA Windows Server 2016 Certification Guide:Exam 70-741
- 深度學習中的圖像分類與對抗技術
- 數據挖掘方法及天體光譜挖掘技術
- Visual C++編程全能詞典
- JavaScript典型應用與最佳實踐
- 網絡安全管理實踐
- 面向對象程序設計綜合實踐
- R Machine Learning Projects
- 學練一本通:51單片機應用技術
- C#求職寶典
- 傳感器原理及實用技術
- Effective Business Intelligence with QuickSight