Skip to content

printing levels as tuples

4 messages · Alexy Khrabrov, Gabor Grothendieck, Moshe Olshansky

#
I'm running rle() on a long vector, and get a result which looks like

 > uc
Run Length Encoding
   lengths: int [1:16753] 1 1 1 1 1 1 1 1 1 1 ...
   values : int [1:16753] 29462748 22596107 18322820 14323315  
12684505 9909036 7296916 6857692 5884755 5883697 ...


I can print uc$names or uc$levels separately.  Is there any way to  
print them together as tuples, looking like

(29462748, 1)   (22596107, 1) ...
(5883697, 1) ...
...

Cheers,
Alexy
#
Not the most efficient way would be to use a loop....

If x is your rel object, you can do the following:

for (i in 1:length(x$values)) 
{
cat("(",x$values[i],",",x$lengths[i],")  ")
if (i %% 10 == 0) cat("\n")
}
cat("\n")
--- Alexy Khrabrov <deliverable at gmail.com> wrote:

            
#
Try this:
[1] "a 2" "b 3"
On Nov 22, 2007 7:32 PM, Alexy Khrabrov <deliverable at gmail.com> wrote:
#
Or even

print(paste("(",y$values,",",y$lengths,")
",sep=""),quote=FALSE)

--- Gabor Grothendieck <ggrothendieck at gmail.com>
wrote: