- 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.
- GNU-Linux Rapid Embedded Programming
- 我的J2EE成功之路
- Go Machine Learning Projects
- Hands-On Machine Learning on Google Cloud Platform
- 深度學(xué)習(xí)中的圖像分類與對(duì)抗技術(shù)
- Mastering Elastic Stack
- 系統(tǒng)安裝與重裝
- Windows Server 2008 R2活動(dòng)目錄內(nèi)幕
- 網(wǎng)絡(luò)服務(wù)搭建、配置與管理大全(Linux版)
- 自動(dòng)化生產(chǎn)線安裝與調(diào)試(三菱FX系列)(第二版)
- 人工智能:語言智能處理
- Excel 2010函數(shù)與公式速查手冊(cè)
- 基于ARM9的小型機(jī)器人制作
- Natural Language Processing and Computational Linguistics
- 計(jì)算機(jī)應(yīng)用基礎(chǔ)實(shí)訓(xùn)·職業(yè)模塊