length(x) length(x) <- value ## S3 method for class 'POSIXlt': length(x) lengths(x, use.names = TRUE)
x | any object. |
value | an integer. |
use.names | a logical value. If TRUE (the default), the names of x are copied to the output. |
length | returns a number that gives the length of the object (that is, the number of elements in the object). This is normally an integer, but it might be a floating point number if the object is long enough that its length does not fit in an integer. |
lengths | returns a vector of the lengths of the elements of x. |
z <- list(a=1,b=letters,c=1:5) length(z) # returns the value 3 length(z$c) # returns the value 5## POSIXlt (plt <- as.POSIXlt(c("1970-01-01 00:00:00", "2038-01-19 03:14:07"))) length(plt) length(unclass(plt))
lengths(list(1, a=1:3)) # returns c(1L, a=3L) lengths(list(1, a=1:3), use.names=FALSE) # returns c(1L, 3L)