[R-pkg-devel] tibbles are not data frames

Pedro J. Aphalo pedro.aphalo at helsinki.fi
Tue Sep 26 14:02:30 CEST 2017


Hi,

But the point is that

inherits(x, "data.frame", TRUE) == 1

will not distinguish between tibbles and other classes derived from 
data.frame that do respect the original syntax. You cannot/want in most 
cases block the use of every class derived from data.frame. One would 
need to use a test that specifically disallows 'tibble', which is 
possible, but inelegant.

However, maybe the main thing is that packages like tibble and magrittr 
are changing the syntax of R. Maybe we are reaching a point where we 
need to define R++, with tibbles REPLACING data frames, etc. Then it 
would be clear that some porting is required, and with only one syntax 
and behaviour in use no confusion created.

Pedro.

On 2017-09-26 14:47, Iñaki Úcar wrote:
> 2017-09-26 13:41 GMT+02:00 Holger Hoefling <hhoeflin at gmail.com>:
>> Hi Thierry,
>>
>> You write:
>>
>> "If a package requires a data.frame, then it is up to the _user_ to
>> provide a data.frame (and a tibble is not a data.frame). "
>>
>> Actually, as pointed out before, calling
>>
>> is.data.frame
>>
>> on a tibble returns TRUE. So I think that R says - yes, a tibble is a data
>> frame. What would be the point of having a "is.data.frame" function, if you
>> can't trust its answer?
> is.data.frame is just a wrapper for inherits(x, "data.frame"). As
> Daniel pointed out before, inherits(x, "data.frame", TRUE) == 1
> returns TRUE for data frames and FALSE for tibbles.
>
> Iñaki
>
> ______________________________________________
> R-package-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel

-- 
------------------------------------------------------------------------
Pedro J. Aphalo
University Lecturer, Principal Investigator
(Office 4417, Biocenter 3, Viikinkaari 1)

Department of Biosciences
Plant Biology
P.O. Box 65
00014 University of Helsinki
Finland

e-mail: pedro.aphalo at helsinki.fi <mailto:pedro.aphalo at helsinki.fi>
Tel. (mobile) +358 50 4150623
Tel. (office) +358 2941 57897

------------------------------------------------------------------------
*Web sites and blogs*
Web site (research group): http://blogs.helsinki.fi/senpep-blog/
Web site (own teaching): http://www.helsinki.fi/people/pedro.aphalo/
Web site (using R in photobiology): http://www.r4photobiology.info/
------------------------------------------------------------------------
*Societies*
UV4Plants <http://www.uv4plants.org/> (communications officer), ESP 
<http://www.photobiology.eu/> (member) SEB <http://www.sebiology.org/> 
(member), BES <http://www.britishecologicalsociety.org/> (member), SPPS 
<http://www.spps.fi/> (member), SMS 
<http://www.metsatieteellinenseura.fi/english> (member), TUG 
<http://tug.org/> (member), FOAS <http://www.foastat.org/> (member).
------------------------------------------------------------------------

	[[alternative HTML version deleted]]



More information about the R-package-devel mailing list