You can
create an integer variable, by suffixing value with ‘L’.
Prevoius
Next
Home
>
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
No comments:
Post a Comment