Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

Why is rle in R returning incorrect lengths?

$
0
0

I am using the function 'rle' to calculate how many consecutive values there are in my vector. The first part of my vector is: 16992 32 96 8 48 144 8 8 8 8 8 8 8 8 8 8 8

but rle returns lengths of '1 1 1 1 1 1 2 1 1 1 4 1 1'

and values '16992 32 96 8 48 144 8 8 8 8 8 8 8 '

There are clearly 11 consecutive 8s. Please can someone help? Thank you in advance.

Update: I used dput() to view my data and it showed: c(16992, 31.9999997615814, 96, 8, 48, 144, 8, 8, 8.00000023841858, 8, 7.99999976158142, 8, 8, 8, 8, 8.00000023841858, 7.99999976158142).

After seeing this, it looks like the values are sometimes just below or above 8, although this doesn't show when I View() the vector. Is this is the issue?

I am a bit confused as to why the values are not rounded to the nearest whole number. I applied the diff() function to these time points beforehand... c(1390456832, 1390473824, 1390473856, 1390473952, 1390473960, 1390474008, 1390474152, 1390474160, 1390474168, 1390474176, 1390474184, 1390474192, 1390474200, 1390474208, 1390474216, 1390474224, 1390474232)


Viewing all articles
Browse latest Browse all 201839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>