Hi Bayan,
Your question seems to imply that the "age" column contains floating
point numbers, e.g.
df
height weight age
170 72 21.5
...
If this is so, you will only find an integer in diff(age) if two
adjacent numbers happen to have the same decimal fraction _and_ the
subtraction d
Hi Bayan,
In your code, 'a' is a vector and is.integer(a) is a logical of length 1 -
most likely FALSE if even one element of a is not an integer. (Since R will
coerce all the elements of a to the same type.)
You need to decide whether something "close enough" to an integer is to be
considered an i
Hi
I want to clean my data frame, based on the age column, whereas i want to
delete the rows that the difference between its elements (i+1)-i= integer. i
used
a <- diff(df$age)
for(i in a){if(is.integer(a) == true){df <- df[-a,]
}}
but, it doesn’t work, any ideas
Thanks in advance
Bayan
___
3 matches
Mail list logo