Site icon R-bloggers

#2 Data Classes (CloudStat)

[This article was first published on CloudStat, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

As stated in CloudStat Intro, we know that CloudStat is based on R Language, an object orientated language, everything in R is an object. Each object has a class. The simplest data objects are one-dimensional arrays called vectors, consisting of any number of elements. For example, the calculation:

Input:

1+1

Output

> 1+1

[1] 2

results in a vector, from the numeric class (as it contains a number), with just one element. Note that the command “1+1” is itself and object of the expression class

The simplest elements produce vectors of the following classes:

Example: #2 Data Classes Example

> 1+1

[1] 2

> 

> T; F #Logical

[1] TRUE

[1] FALSE

> 

> 2; -5 #Integer

[1] 2

[1] -5

> 2; -5 #Whole number

[1] 2

[1] -5

> 2.38; -23.125 #Decimal fractions

[1] 2.38

[1] -23.125

> 2.38e57; 23e-98 #Scientific notation

[1] 2.38e+57

[1] 2.3e-97

> 5 + 4.67i #Complex number

[1] 5+4.67i

> "CloudStat"; "data analysis" #Character

[1] "CloudStat"

[1] "data analysis"

> 

Two other elements which are particularly useful are:

#2 Data Classes Example

Source: An Introduction to R: Examples for Actuaries by Nigel De Silva

To leave a comment for the author, please follow the link and comment on their blog: CloudStat.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.