#Give a scalar number(which is a vector of length 1 in R terminology), determine if the number has an integer value.
x=34.8
{#
if (x==trunc(x))
{
int.val=TRUE
}
else
{
int.val=FALSE
}
}#
int.val
int.val=(x==trunc(x))
int.val
#also work on vector
No comments:
Post a Comment