Learn R Programming

ACCLMA (version 1.0)

size: Counts the number of rows in a data set

Description

This function counts the number of rows in a data set by running over the first column and stops on the first blank value in this column it finds

Usage

size(mat)

Arguments

mat
Any data set

Value

Details

References

See Also

Examples

Run this code
d <- c(1,1,3,4)
e <- c(5,6,7,8)
f <- c(1,1,1,1)
mydata <- data.frame(d,e,f)
names(mydata) <- c("X","Y","Weight")
size(mydata)

## The function is currently defined as
function (mat) 
{
    i <- 1
    while (!is.na(mat[i, 1]) & !is.null(mat[i, 1])) {
        i = i + 1
    }
    return(i - 1)
  }

Run the code above in your browser using DataLab