The safest way is to check the length of the row.names attribute, e.g.
length(getAttrib(df, R_RowNamesSymbol)).
This protects you from both data.frames with zero columns, as well as
corrupted data.frames containing columns with different lengths, since
by definition the number of rows in a da
I didn't look at the names because I believe that would be incorrect
if the row names were stored internally in the compact form.
See ?.set_row_names (hat tip, Tim Hesterberg who showed me this years ago) :
'row.names' can be stored internally in compact form.
'.set_row_names(n)' genera
The Rf_length(dataframe) will provide the length of row names . So it
should be checked first. I found one edge case now
My dataframe has 0 rows and 0 columns
int num_rows = Rf_length(VECTOR_ELT(dataframe, 0)); > returns 1
,in stead of 0 . Not sure why.
Thanks
On Mon, Mar 31, 2014 at
I think it is actually better to check the length of the row names. In case
the data frame has zero columns. (FIXME, of course.)
Gabor
On Mon, Mar 31, 2014 at 8:04 PM, Murray Stokely wrote:
> The simplest case would be:
>
>int num_rows = Rf_length(VECTOR_ELT(dataframe, 0));
>int num_co
Hi Murray,
Thanks a lot . For things to work Its good enough . Its working
Thanks,
Sandip
On Mon, Mar 31, 2014 at 5:04 PM, Murray Stokely wrote:
> The simplest case would be:
>
>int num_rows = Rf_length(VECTOR_ELT(dataframe, 0));
>int num_columns = Rf_length(dataframe);
>
> There may
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, 20
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 ar