Last data update: 2014.03.03

R: Counts the number of rows in a data set
sizeR Documentation

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

An integer representing the number of rows in the data set

Author(s)

Tal Carmi, Liat Gaziel

Examples

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)
  }

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(ACCLMA)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/ACCLMA/size.Rd_%03d_medium.png", width=480, height=480)
> ### Name: size
> ### Title: Counts the number of rows in a data set
> ### Aliases: size
> ### Keywords: ~kwd1 ~kwd2
> 
> ### ** Examples
> 
> 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)
[1] 4
> 
> ## 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)
+   }
function (mat) 
{
    i <- 1
    while (!is.na(mat[i, 1]) & !is.null(mat[i, 1])) {
        i = i + 1
    }
    return(i - 1)
}
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>