Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

An R function to return TRUE if the length of 3 objects is the same

Tags:

function

r

I was wondering how I could test to see if the length of 3 R objects are the same or not?

Here is a simple example and what I have tried with no success:

a = c(2, 3) ; b = 2 ; c = "hi"

is.df = function(x, y, z) length(x) != length(y) != length(z) ## gives error
like image 926
rnorouzian Avatar asked Jan 23 '26 07:01

rnorouzian


1 Answers

foo = function(...){
    length(unique(lengths(list(...)))) == 1
}
foo(a, b, c)
#[1] FALSE
like image 125
d.b Avatar answered Jan 25 '26 20:01

d.b



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!