All Questions
157
questions
2
votes
1
answer
51
views
Attaching infix operators
Benefit of attaching objects (you can skip this)
In a sourced script, it can be convenient to define our helper funcs like this:
f <- function() print('hi')
e <- new.env()
assign("f", ...
1
vote
1
answer
36
views
Conditional negation of T/F vector
Can the ! operator, or its opposite, be assigned dynamically to a variable then serve as a calculation input? There is a set of data.frames whose subsets I switch depending on a T/F condition. Here’s ...
0
votes
2
answers
44
views
Correct operator usage
I'm using IPUMS CPS data and created a binary variable for disability from the six different variables within IPUMS for disability (https://cps.ipums.org/cps-action/variables/group/core_dis)
bias <-...
0
votes
3
answers
466
views
"not like" operator
Is there a possibility to use filtering in dplyr and use negative of like operator? Something like (which does not work):
my_df %>%
filter(text !%like% "dirty talk")
3
votes
2
answers
66
views
Escaping Custom Operators in R
One may define a new binary operator...
`%my_op%` <- function(lhs, rhs) {
# ...
}
...and use it like so:
4 %my_op% 5
Experimentation shows that nearly any sequence of characters is valid, ...
1
vote
2
answers
615
views
Question about when to use "&" and "|" (OR) when using conditional operators "==" and "!=" in the dplyr::filter() function
I'm asking this question more out of curiosity. I was able to achieve my desired results using the filter() function but I'm interested in the explanation for the scenario below.
I wanted to use ...
0
votes
1
answer
66
views
What is the name of R Special Backtick and Parentheses Syntax?
I have recently encountered the following R syntax:
(`::`("ggplot","aes"))()
or
(`$`(mylist,"column"))
I understand what it does, but I struggle to find any ...
0
votes
1
answer
43
views
Why does ggplot change the position of the parameter values of data= and mapping= when using "pipe" operator?
hearted people who clicked in to see this question.I just started learning to use ggplot.
ggplot(mpg)
aes(x = displ) |>
ggplot(mpg)
The first command mpg is passed to ggplot as an argument to ...
1
vote
1
answer
33
views
unexpected behabiour of operator $ in R [duplicate]
It seems that the R operator $ looks for a field name similar to the requested one if it does not exist, which seems to me to be a totally inexperienced and very dangerous behaviour.
I have reproduced ...
2
votes
1
answer
38
views
Why logical operations in dataframe iteration doesn't return the right values?
I'm trying to perform a logic test on two dataframes. If zero is included in the delimited interval between dataframe elements, the label 'Not Significant' must be included, otherwise, if zero is not ...
0
votes
1
answer
52
views
HUGE processing speed difference in running apparently similar codes - resulted by using $ instead of a pipe?
R newbie here. So I'm running a big df (> 5.7m rows) in R. It has the following col_names() columns, and within day_of_week are values like "Fri", "Wed"...you know, the days.
[...
1
vote
1
answer
502
views
what does a colon (:) do in a linear mixed effects model analysis?
Let me clarify that I am a complete beginner at R.
I'm working on a problem and having a bit of trouble understanding a formula I'm supposed to use in a linear mixed effects model analysis of a ...
1
vote
1
answer
63
views
Print a matrix flattened by column using a separator
I have the following matrix made from a vector of vectors, which I want to print separated by the & operator.
vec1 <- c(1, 2, 3, 4)
vec2 <- c(5, 6, 7, 8)
vec3 <- c(9, 10, 11, 12)
...
0
votes
0
answers
50
views
non-numeric argument to binary operator error while my data are numeric
I have following code to filter my data which is a large csv file. Running the following code, gives the error:
Error in gedi_table[, col_index] - gedi_table$digital_elevation_model_srtm :
non-...
0
votes
1
answer
46
views
Can I assign an ALIAS to a help option?
In R, the I believe the core features such as "+" or "?" are called "operators" (they are I believe in most programming languages: an operator as a symbol to perform a ...