decisionpatterns / formula.tools Goto Github PK
View Code? Open in Web Editor NEWUtilities for working with formulas, expressions, calls and other R objects
License: Other
Utilities for working with formulas, expressions, calls and other R objects
License: Other
Using 1.5.4 I notice this bug when trying to assign lhs()
in a one-sided formula:
f <- ~ A
lhs(f)
## NULL
lhs(f) <- quote(B)
f
## ~B
The expected result would be B ~ A
, but instead the right-hand side gets replaced. There are no such issues when there is already something in the left-hand side:
f2 <- ZZZ ~ A
lhs(f2) <- quote(B)
f2
## B ~ A
The following code in which left-hand side contains a function (e.g., log(Girth)
) returns a list while character vector is expected:
rez <- lhs.vars(log(Girth) ~ Volume, data = trees)
class(rez)
[1] "terms" "formula"
In the same situation get.vars()
returns a list that is also either unexpected (or undocumented).
Is this behavior caused by a bug?
A number of methods are defined for the "<-" class.
This breaks CRAN checks.
I'm not sure why this happens, but this throws an error only if the formula.tools package is loaded. I'm guessing it must be a bug in formula.tools:
library(formula.tools)
library(lmerTest)
m1 <- lmer(Informed.liking ~ Gender*Information +(1|Consumer), data=ham)
difflsmeans(m1, test.effs="Gender:Information")
The name formula.tools does not accurately reflect the extent of the package functionality since the tools work on expressions and list as well. Most of this package should become expression.tools with the few formula specific functions remaining in this package.
It would be nice to add this functionality into the package.
Perhaps through replace.call
and replace.name
functions
> check_doc()
Bad \usage lines found in documentation object 'formula.parts-methods':
<unescaped bksl>method{lhs}{<-}(x)
<unescaped bksl>S4method{op}{<-}(x)
<unescaped bksl>S4method{rhs}{<-}(x)
Bad \usage lines found in documentation object '.is.one.sided':
<unescaped bksl>S4method{is.one.sided}{<-}(x, ...)
<unescaped bksl>S4method{is.two.sided}{<-}(x)
Bad \usage lines found in documentation object 'op.type':
<unescaped bksl>S4method{op.type}{<-}(x)
The rhs.vars
function cannot identify correctly the variables whenever there is a minus sign on the right-hand side of the formula.
Example:
f1 <- x ~ a + b - c
rhs(f1) # Ok
> rhs(f1)
[1] a + b - c
rhs.vars(f1) # c is missing
> rhs.vars(f1)
[1] "a" "b"
I'm ran this code in a Windows machine, formula.tools
version 1.7.1.
It might be advantageous, long-term to refactor this package using the considerable less complex S3 Methods. Most of the functions do not need multiple dispatch. And this obviates some problems with CRAN/roxygen2 incompatibilities.
Fix a dependency on testthat which caused CRAN tests to fail.
Hi,
Love the package, thanks for sharing it.
I'm having problems with get.vars with signature NULL. This comes up in a situation like this
lhs.vars( ~ x)
which then calls get.vars
on lhs(~x)
. Since lhs(~x)
returns NULL this leads to get.vars being called with signature NULL
, NULL
and this throws an error.
In prior versions this would work and return NULL, which makes sense to me.
I tried to look in the NEWS to see if this was an expected change but there is no entry for 1.5.
Thanks for your time!
Best,
Paul
Loading the package breaks R's behaviour of as.character.default
, which is not too convenient.
as.character(.~.) # "~" "." "."
library(formula.tools)
as.character(.~.) # ". ~ ."
Do you see an easy way to avoid this?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.