Displaying 20 results from an estimated 7000 matches similar to: "Generalised piping into operators"
2023 Apr 21
1
Generalised piping into operators
On 21/04/2023 4:35 a.m., Michael Milton wrote:
> I just checked out R-devel and noticed that the new "pipe extractor"
> capability coming in 4.3 only works for the 4 extractor operators, but no
> other standard operators like +, *, %*% etc, meaning that e.g. mtcars |>
> as.matrix() |> _ + 1 |> colMeans() is a syntax error. In addition, we are
> still subject to
2023 Apr 21
1
Generalised piping into operators
Thanks, this makes sense. Is there a similar precedence reasoning behind
why operator functions (`+` etc) can't be piped into?
On Fri, Apr 21, 2023 at 11:52?PM Duncan Murdoch <murdoch.duncan at gmail.com>
wrote:
> On 21/04/2023 4:35 a.m., Michael Milton wrote:
> > I just checked out R-devel and noticed that the new "pipe extractor"
> > capability coming in 4.3
2016 Apr 14
0
Bug in by() function which works for some FUN argument and does not work for others
I think you are not using the best function for what your intentions are.
Try:
> by(data=mtcars, INDICES=list(as.factor(mtcars$am)), FUN=colMeans)
: 0
mpg cyl disp hp drat wt
qsec vs
17.1473684 6.9473684 290.3789474 160.2631579 3.2863158 3.7688947
18.1831579 0.3684211
am gear carb
0.0000000
2016 Apr 17
0
Bug in by() function which works for some FUN argument and does not work for others
> On Apr 16, 2016, at 2:03 AM, Akhilesh Singh <akhileshsingh.igkv at gmail.com> wrote:
>
> Dear All,
>
> I have got your core message, that it is my responsibility to determine whether any particular function in my version of R satisfies the language requirements at the time of your use. Jim Albert and Maria Rizzo must have used their code, which was permitted in the R-code
2016 Apr 16
2
Bug in by() function which works for some FUN argument and does not work for others
Dear All,
I have got your core message, that it is my responsibility to determine
whether any particular function in my version of R satisfies the language
requirements at the time of your use. Jim Albert and Maria Rizzo must have
used their code, which was permitted in the R-code of their time (2012).
Therefore, I have now modified my R-code, as per R-3..2.4 version,
according to my requirement
2016 Apr 15
4
Bug in by() function which works for some FUN argument and does not work for others
Dear All,
Thanks for your help. However, I would like to draw your attention to the
following:
Actually, I was replicating the Example 2.3, using the dataset
"brainsize.txt" given in Section 2.3.3 ("Summarize by group") at page 55,
of a famous book "R by Example" written by "Jim Albert and Maria Rizzo"
published in Springers (2012) in a Use R! Series. The
2016 Apr 15
0
Bug in by() function which works for some FUN argument and does not work for others
> On Apr 15, 2016, at 1:16 AM, Akhilesh Singh <akhileshsingh.igkv at gmail.com> wrote:
>
> Dear All,
>
> Thanks for your help. However, I would like to draw your attention to the
> following:
>
> Actually, I was replicating the Example 2.3, using the dataset
> "brainsize.txt" given in Section 2.3.3 ("Summarize by group") at page 55,
> of a
2023 Apr 21
1
Generalised piping into operators
On 21/04/2023 11:33 a.m., Michael Milton wrote:
> Thanks, this makes sense. Is there a similar precedence reasoning behind
> why operator functions (`+` etc) can't be piped into?
Yes:
> identical(quote(1 + 1), quote(`+`(1, 1)))
[1] TRUE
Duncan Murdoch
2023 Apr 21
1
Generalised piping into operators
I'm afraid I don't understand. I know that parsing `+`(1, 1) returns a
result equivalent to `1 + 1`, but why does that impose a restriction on
parsing the pipe operator? What is the downside of allowing arbitrary RHS
functions?
[[alternative HTML version deleted]]
2023 Apr 21
2
Generalised piping into operators
On 21/04/2023 12:16 p.m., Michael Milton wrote:
> I'm afraid I don't understand. I know that parsing `+`(1, 1) returns a
> result equivalent to `1?+ 1`, but why does that impose a restriction on
> parsing the pipe operator? What is the downside of allowing arbitrary
> RHS functions?
I thought the decision to exclude "_ + 1" happens after enough parsing
has
2016 Apr 14
4
Bug in by() function which works for some FUN argument and does not work for others
Dear Sirs,
I am Professor at Indira Gandhi Krishi Vishwavidyalaya, Raipur,
Chhattisgarh, India.
While taking classes, I found the *by() *function producing following error
when I use FUN=mean or median and some other functions, however,
FUN=summary works.
Given below is the output of the example I used on a built-in dataset
"mtcars", along with error message reproduced herewith:
>
2012 Aug 30
2
Identifying and Removing NA Columns and factor Columns with more than x Levels
Hi,
How do you subset a dataframe so that you only have columns:
1. that contain one or more NAs?
2. that contain factors with greater than or equal to 32 levels?
How do you remove from a dataframe columns**
3. with one or more NA's?
4. that contain factors with greater than or equal to 32 levels?
** I know how to remove columns at a basic level but I am trying
2011 Apr 10
2
howto calculate column means in data frame
Long story short, I have a big iterative procedure that produces a long list of data.frames such as the one called
"results" here. Is there an easy way to produce a similar list of data.frames comprised of the mean of each of the
columns in results, such that it ends up like the one I've shown in "resultsmean" below?
I've tried apply and lapply, still not got the
2007 Oct 01
4
how to plot a graph with different pch
I am trying to plot a graph but the points on the graph should be
different symbols and colors. It should represent what is in the legend.
I tried using the points command but this does not work. Is there
another command in R that would allow me to use different symbols and
colors for the points?
Thank you kindly.
data(mtcars)
plot(mtcars$wt,mtcars$mpg,xlab= "Weight(lbs/1000)",
2011 Dec 13
1
How to add points to two plots parallelly ?
I am looking for ways to add points to three different plots in parallel.
I generate three scatter plots and name them as s3d1, s3d2 and s3d3
s3d1<-scatterplot3d(mtcars[,3],mtcars[,4],mtcars[,5],main="common",pch=20)
s3d2<-scatterplot3d(mtcars[,3],mtcars[,4],mtcars[,5],main="common",pch=20)
2008 Mar 16
1
stats/debugging question hotelling t-sq
Hi
I spent hours looking over my formula. Somehow I cant find the reason
why it gives me different answer.
help appreciated.
x = as.matrix(read.table("http://www.niehs.nih.gov/research/atniehs/core/microarrays/docs/heinloth.txt",1))
x = t(x) #now rows are subjects, cols are genes
x = x[order(rownames(x)),] #order by treatment group oxygen,
ultra-violet, gamma radiation
y =
2020 Apr 16
2
suggestion: "." in [lsv]apply()
I'm sure this exists elsewhere, but, as a trade-off, could you achieve
what you want with a separate helper function F(expr) that constructs
the function you want to pass to [lsv]apply()? Something that would
allow you to write:
sapply(split(mtcars, mtcars$cyl), F(summary(lm(mpg ~ wt,.))$r.squared))
Such an F() function would apply elsewhere too.
/Henrik
On Thu, Apr 16, 2020 at 9:30 AM
2012 Mar 15
2
Ggplot barchart drops factor levels: how to show them with zero counts?
Hello,
When plotting a barchart with ggplot it drops the levels of the factor for
which no counts are available.
For example:
library(ggplot)
mtcars$cyl<-factor(mtcars$cyl)
ggplot(mtcars[!mtcars$cyl==4,], aes(cyl))+geom_bar()
levels(mtcars[!mtcars$cyl==4,])
This shows my problem. Because no counts are available for factorlevel '4',
the label 4 dissapears from the plot. However, I
2013 Apr 12
3
Why copying columns of a data.frame becomes numeric?
Dear list,
I want the 1st, 2nd, 5th, and 6th columns of mtcars. After copying them,
the columns become numeric class rather than data frame.
But, when I copy rows, they data frame retains its class. Why is this? I
don't see why copying rows vs columns is so different.
> class(mtcars)
[1] "data.frame"
> head(mtcars)
mpg cyl disp hp drat wt qsec vs
2012 Feb 17
1
Dataframe subset - why doesn't this work?
data(mtcars)
mtcars[rownames(mtcars)!="Valiant",] # fails
mtcars[list(rownames(mtcars))!="Valiant",] # runs but I am not getting the expected result
With the latter statement, I expected all rows except the one where the name is "Valiant".
I must have got something simple wrong; what is it?
Thanks.
[[alternative HTML version deleted]]