From murray at stokely.org  Tue Apr  1 02:04:28 2014
From: murray at stokely.org (Murray Stokely)
Date: Mon, 31 Mar 2014 17:04:28 -0700
Subject: [Rd] C API to get numrow of data frame
In-Reply-To: <CAGSjAUBKaMh0gipxCvGCftDLPX8EfnVhp3vGY1D=mQ=i-P=YdA@mail.gmail.com>
References: <CAGSjAUBKaMh0gipxCvGCftDLPX8EfnVhp3vGY1D=mQ=i-P=YdA@mail.gmail.com>
Message-ID: <CAECWziL0EeJqHLSrr9fYzRT5bgPeGLzWX-4Kmwx+8jQL978ycQ@mail.gmail.com>

The simplest case would be:

   int num_rows = Rf_length(VECTOR_ELT(dataframe, 0));
   int num_columns = Rf_length(dataframe);

There may be edge cases for which this doesn't work; would need to
look into how the dim primitive is implemented to be sure.

               - Murray


On Mon, Mar 31, 2014 at 4:40 PM, Sandip Nandi <sannandi at umail.iu.edu> wrote:
> Hi ,
>
> Is there any C API to the R API  nrow of dataframe ?
>
> x<- data.frame()
> n<- nrow(x)
> print(n)
> 0
>
>
> Example :
> My C function which deals with data frame looks like and I don't to send
> the  number of rows of data frame .I want to detect it from the function
> itself, my function take data frame as argument and do some on it. I want
> API equivalent to nrow. I tried Rf_nrows,Rf_ncols . No much help.
>
> SEXP  writeRR(SEXP dataframe) {
>
> }
>
>
> Any help is very appreciated.
>
> Thanks,
> Sandip
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



[Rd] C API to get numrow of data frame
Murray Stokely