Saturday 13 June 2015

R : Integer Data type

You can create an integer variable, by suffixing value with ‘L’.

> class(num1)
[1] "numeric"
> num1<-10L
> class(num1)
[1] "integer"

You can convert a real value to integer, by using as.integer().

> num2 <- as.integer(2.34)
> num2
[1] 2

You can convert string to integer in same way.

> num2 <- as.integer("2.34")
> num2
[1] 2



Prevoius                                                 Next                                                 Home

No comments:

Post a Comment