knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "README-"
)

Testing S4 inheritance

Travis-CI Build Status

I have a problem with basic inheritance of the [ operator for S4 objects that implement custom arguments. This is a working example from a stackoverflow post I created.

UPDATE

It was revealed as a bug in the callNextMethod() implementation and has been fixed in the upcoming version of R!

https://github.com/wch/r-source/commit/0c06db284ec6d026040d464c3bfea66cf56a09b7

Installation

You can install it via github, and it should work:

devtools::install_github("zkamvar/inheritest")

When it works

It works if the package is built to your system

library("inheritest")
foo <- new("foo", x = pi, y = 2)
foo["x"]
foo["y", foo = FALSE]
bar <- new("bar", x = pi, y = 2, distance = 0)
bar["x"]
bar["distance", bar = FALSE]

When it doesn't work

It doesn't work if the package is simply loaded:

In the shell:

git clone https://github.com/zkamvar/inheritest.git
cd inheritest

In R:

devtools::load_all(".")
foo <- new("foo", x = pi, y = 2)
foo["x"]
foo["y", foo = FALSE]
bar <- new("bar", x = pi, y = 2, distance = 0)
bar["x"]
bar["distance", bar = FALSE]


zkamvar/inheritest documentation built on May 4, 2019, 11:24 p.m.