Displaying 20 results from an estimated 20000 matches similar to: "unary !"
2008 Mar 13
2
Making custom unary operators in R
Hello,
Is there a way to define a custom unary operator in R (other than making a
class and 'overloading' the normal unary operators in R)? The
documentation seems to suggest that only custom binary operators are
possible with the ``%abc%``construct but I was wondering whether any one
has done so. None of the RSiteSearch or RSeek queries I posed suggested
that this question had
2011 Nov 03
1
[LLVMdev] Why there is no unary operator in LLVM?
Hi llvmdev,
I've noticed that there is no unary operator in LLVM. For unary operator
such as Neg or Or operator, the IR builder just creates a binary operation
with one dummy operand,
01823 <http://llvm.org/doxygen/classllvm_1_1BinaryOperator.html#a073c092ce74a122e898e435e60e84599>
BinaryOperator <http://llvm.org/doxygen/classllvm_1_1BinaryOperator.html>
2017 Mar 16
2
Support for user defined unary functions
Gabe,
The unary functions have the same precedence as normal SPECIALS
(although the new unary forms take precedence over binary SPECIALS).
So they are lower precedence than unary + and -. Yes, both of your
examples are valid with this patch, here are the results and quoted
forms to see the precedence.
`%chr%` <- function(x) as.character(x)
`%identical%` <- function(x, y)
2017 Mar 17
2
Support for user defined unary functions
The unquoting discussion is IMHO separate from this proposal and as
you noted probably better served by a native operator with different
precedence.
I think the main benefit to providing user defined prefix operators is
it allows package authors to experiment with operator ideas and gauge
community interest. The current situation means any novel unary
semantics either need to co-opt existing
2005 Jan 07
1
Creating unary operators
Is it correct (by its lack of mention in the R-Language Definition
Manual) that it is impossible to create a user-defined unary operator?
Ex: (This doesn't work, but it's an example of what I'm looking for)
> "%PLUSONE%" <- function(x) x + 1
> %PLUSONE% 2
[1] 3
And if the above is impossible, am I limited to only the + - ~ ! unary
operators for overloading?
On
2017 Mar 16
2
Support for user defined unary functions
Martin,
Jim can speak directly to his motivations; I don't claim to be able to do
so. That said, I suspect this is related to a conversation on twitter about
wanting an infix "unquote" operator in the context of the non-standard
evaluation framework Hadley Wickham and Lionel Henry (and possibly others)
are working on.
They're currently using !!! and !! for things related to
2017 Mar 16
2
Support for user defined unary functions
I guess this would establish a separate "namespace" of symbolic prefix
operators, %*% being an example in the infix case. So you could have stuff
like %?%, but for non-symbolic (spelled out stuff like %foo%), it's hard to
see the advantage vs. foo(x).
Those examples you mention should probably be addressed (eventually) in the
core language, and it looks like people are already able
2006 Nov 20
1
a little help needed plotting chron object
Hello there,
Using R 2.4.0 on Solaris (Unix):
I am trying to control the X axis range on a simple time of day plot.
I made a test program (below) that gets file time stamp information from
the files in the directory where R starts. The goal of the test program is
to plot the time of day of file creation on an x axis that spans a
user-specified range (like 12:00:00 to 15:00:00).
If I allow
2017 Mar 17
2
Support for user defined unary functions
>After off list discussions with Jonathan Carrol and with
>Michael Lawrence I think it's doable, unambiguous,
>and even imo pretty intuitive for an "unquote" operator.
For those of us who are not CS/Lisp mavens, what is an
"unquote" operator? Can you expression quoting and unquoting
in R syntax and show a few examples where is is useful,
intuitive, and fits in to
2017 Mar 17
3
Support for user defined unary functions
I agree there is no reason they _need_ to be the same precedence, but
I think SPECIALS are already have the proper precedence for both unary
and binary calls. Namely higher than all the binary operators (except
for `:`), but lower than the other unary operators. Even if we gave
unary specials their own precedence I think it would end up in the
same place.
`%l%` <- function(x) tail(x, n =
2017 Mar 17
2
Support for user defined unary functions
Your example
x = 5
exp = parse(text="f(uq(x)) + y +z") # expression: f(uq(x)) +y + z
do_unquote(expr)
# -> the language object f(5) + y + z
could be done with the following wrapper for bquote
my_do_unquote <- function(language, envir = parent.frame()) {
if (is.expression(language)) {
# bquote does not go into expressions, only calls
2003 Mar 13
1
apply() and unary operators
Hi everyone.
What's going on here?
> a <- matrix(1:4,2,2)
> a
[,1] [,2]
[1,] 1 3
[2,] 2 4
> apply(a,2,sum)
[1] 3 7
> apply(a,2,"+")
[,1] [,2]
[1,] 1 3
[2,] 2 4
> apply(a,1,"+")
[,1] [,2]
[1,] 1 2
[2,] 3 4
>
help(apply) says that "+" should be quoted but is otherwise silent on
unary
2012 Oct 30
4
Error unary operator
Hi R - listers,
I am receiving an error. Does anyone know what this means? J
ggplot(subset(foo, Rayos != "Rayos.NA"), aes(x=HTL, y=DevelopIndex,
colour=TotalEggs)) +geom_point() +geom_jitter() +
facet_grid(Aeventexhumed ~ Rayos)
+ geom_smooth(method="lm", fill=NA) + ylim(c(0, 7))
Error in +geom_smooth(method = "lm", fill = NA) :
invalid argument to unary
2017 Mar 16
4
Support for user defined unary functions
R has long supported user defined binary (infix) functions, defined
with `%fun%`. A one line change [1] to R's grammar allows users to
define unary (prefix) functions in the same manner.
`%chr%` <- function(x) as.character(x)
`%identical%` <- function(x, y) identical(x, y)
%chr% 100
#> [1] "100"
%chr% 100 %identical% "100"
#> [1] TRUE
2010 Feb 03
1
Proposal unary - operator for factors
Hi all,
Why not make the unary minus operator return the factor with levels
reversed? This would make it much easier to sort factors in
descending order in part of an order statement.
Hadley
--
http://had.co.nz/
2017 Nov 29
2
binary form of is() contradicts its unary form
Yes, data.frame is not an S4 class but is(data.frame())
finds its super-classes anyway and without the need to wrap
it in asS4(). And "list' is one of the super-classes. Then
is(data.frame(), "list") contradicts this.
I'm not asking for a workaround. I already have one with
'class2 %in% is(object)' as reported in my original post.
'is(asS4(object), class2)'
2016 Mar 18
2
unary class union of an S3 class
Hi,
Short story
-----------
setClassUnion("ArrayLike", "array")
showClass("ArrayLike") # no slot
setClass("MyArrayLikeConcreteSubclass",
contains="ArrayLike",
representation(stuff="ANY")
)
showClass("MyArrayLikeConcreteSubclass") # 2 slots!!
That doesn't seem right.
Long story
----------
2011 Feb 22
1
[LLVMdev] unary floating point operations using clang
Hello,
Is there a way of generating unary floating point operations (like
ISD::FABS, ISD::FSIN, ...) from C code using clang? I am building a backend
for a machine that has hw support for these ops and I need a way to test
them.
Thanks,
Alex
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
2002 Aug 08
1
The unary - operator and matrix column labels
I am making some changes to the permax library (so that it will accept NA's). This function performs a permutation analysis to identify discriminating attributes distinguishing two groups of observations. It takes the form (at its most simplistic):
permax(data, ig1)
where ig1 is one group of interest. The other group (if not specified) is assumed to be the remaining observations, namely,
2016 Mar 19
2
unary class union of an S3 class
On 03/18/2016 03:28 PM, Michael Lawrence wrote:
>
> On Fri, Mar 18, 2016 at 2:53 PM, Herv? Pag?s <hpages at fredhutch.org
> <mailto:hpages at fredhutch.org>> wrote:
>
> Hi,
>
> Short story
> -----------
>
> setClassUnion("ArrayLike", "array")
>
> showClass("ArrayLike") # no slot
>
>