Re: [R] Pipe operator

2023-01-04 Thread avi.e.gross
and subsequent arguments match up to. -Original Message- From: R-help On Behalf Of Richard O'Keefe Sent: Wednesday, January 4, 2023 1:56 AM To: Milan Glacier Cc: R-help Mailing List Subject: Re: [R] Pipe operator This is both true and misleading. The shell pipe operation came from functio

Re: [R] Pipe operator

2023-01-03 Thread Ivan Calandra
Maybe I missed it in the whole discussion, but since R 4.2.0 the base R pipe operator also has a placeholder '_' to specify where the result of the left-hand side should be used in the right-hand side (see https://stat.ethz.ch/pipermail/r-announce/2022/000683.html). So the only difference

Re: [R] Pipe operator

2023-01-03 Thread Richard O'Keefe
This is both true and misleading. The shell pipe operation came from functional programming. In fact the shell pipe operation is NOT "flip apply", which is what |> is, but it is functional composition. That is out = let out = command cmd1 | cmd2 = \x.cmd2(cmd1(x)). Pragmatically, the Unix shell

Re: [R] Pipe operator

2023-01-03 Thread Milan Glacier
With 50 years of programming experience, just think about how useful pipe operator is in shell scripting. The output of previous call becomes the input of next call... Genious idea from our beloved unix conversion... On 01/03/23 16:48, Sorkin, John wrote: I am trying to understand the reason

Re: [R] Pipe operator

2023-01-03 Thread Richard O'Keefe
does the same thing as %>%, or at my level of programing I > have not encountered a difference. > > Tim > > -Original Message- > From: R-help On Behalf Of Sorkin, John > Sent: Tuesday, January 3, 2023 11:49 AM > To: 'R-help Mailing List' > Subject: [R] Pipe op

Re: [R] Pipe operator

2023-01-03 Thread avi.e.gross
s complex in situations like this. Just use a simple assignment pre or post as meets your needs. -Original Message- From: Boris Steipe Sent: Tuesday, January 3, 2023 2:01 PM To: R-help Mailing List Cc: avi.e.gr...@gmail.com Subject: Re: [R] Pipe operator Working off Avi's example - would

Re: [R] Pipe operator

2023-01-03 Thread Richard O'Keefe
The simplest and best answer is "fashion". In FSharp, > (|>);; val it: ('a -> ('a -> 'b) -> 'b) The ability to turn f x y into y |> f x makes perfect sense in a programming language where Currying (representing a function of n arguments as a function of 1 argument that returns a function of n-1

Re: [R] Pipe operator

2023-01-03 Thread Sorkin, John
Jeff, Thank you for contributing important information to this thread. From: Jeff Newmiller Sent: Tuesday, January 3, 2023 2:07 PM To: r-help@r-project.org; Sorkin, John; Ebert,Timothy Aaron; 'R-help Mailing List' Subject: Re: [R] Pipe operator

Re: [R] Pipe operator

2023-01-03 Thread Jeff Newmiller
> R is a functional language, hence the pipe operator is not needed. Not factual... just opinion. Please be conscious of your biases and preface opinion with a disclaimer. I heard identical complaints from embedded assembly language programmers when C became all the rage... "don't need another

Re: [R] Pipe operator

2023-01-03 Thread Uwe Ligges
R is a functional language, hence the pipe operator is not needed. Also it makes the code unreadable as it is less obvious how a call stack looks like and what the arguments to the function calls are. It is relevant for a shell for piping text streams. If people cannot live without the pipe

Re: [R] Pipe operator

2023-01-03 Thread Ivan Calandra
Dear John, some more experienced users might give you a different and more helpful answer, but I was not really convinced by the pipe operator until I tried it out, for the same reasons as you. In my opinion, the pipe operator is there only to improve the readability of your code. Think

Re: [R] Pipe operator

2023-01-03 Thread Andrew Hart via R-help
-Original Message- From: R-help On Behalf Of Sorkin, John Sent: Tuesday, January 3, 2023 11:49 AM To: 'R-help Mailing List' Subject: [R] Pipe operator I am trying to understand the reason for existence of the pipe operator, %>%, and when one should use it. It is my understanding

Re: [R] Pipe operator

2023-01-03 Thread Rui Barradas
Às 19:14 de 03/01/2023, Rui Barradas escreveu: Às 17:35 de 03/01/2023, Greg Snow escreveu: To expand a little on Christopher's answer. The short answer is that having the different syntaxes can lead to more readable code (when used properly). Note that there are now 2 different (but somewhat

Re: [R] Pipe operator

2023-01-03 Thread Jeff Newmiller
nly selected rows and pipe that >> to a function that drops some of the columns and pipe that to a function >> that groups the items or sorts them and pipe that to a function that does a >> join with another object or generates a report or so many other things. >> >> So th

Re: [R] Pipe operator

2023-01-03 Thread Rui Barradas
Às 17:35 de 03/01/2023, Greg Snow escreveu: To expand a little on Christopher's answer. The short answer is that having the different syntaxes can lead to more readable code (when used properly). Note that there are now 2 different (but somewhat similar) pipes available in R (there could be

Re: [R] Pipe operator

2023-01-03 Thread Jeff Newmiller
graming I have not >encountered a difference. > >Tim > >-Original Message- >From: R-help On Behalf Of Sorkin, John >Sent: Tuesday, January 3, 2023 11:49 AM >To: 'R-help Mailing List' >Subject: [R] Pipe operator > >[External Email] > >I am trying to und

Re: [R] Pipe operator

2023-01-03 Thread Boris Steipe
s a report or so many other things. > > So the real answer is that piping is another WAY of doing things from a > programmers perspective. Underneath it all, it is mostly syntactic sugar and > the interpreter rearranges your code and performs the steps in what seems > like a differen

Re: [R] Pipe operator

2023-01-03 Thread avi.e.gross
Message- From: R-help On Behalf Of Ebert,Timothy Aaron Sent: Tuesday, January 3, 2023 12:08 PM To: Sorkin, John ; 'R-help Mailing List' Subject: Re: [R] Pipe operator The pipe shortens code and results in fewer variables because you do not have to save intermediate steps. Once you get used

Re: [R] Pipe operator

2023-01-03 Thread avi.e.gross
--Original Message- From: R-help On Behalf Of Sorkin, John Sent: Tuesday, January 3, 2023 11:49 AM To: 'R-help Mailing List' Subject: [R] Pipe operator I am trying to understand the reason for existence of the pipe operator, %>%, and when one should use it. It is my understanding that

Re: [R] Pipe operator

2023-01-03 Thread Greg Snow
To expand a little on Christopher's answer. The short answer is that having the different syntaxes can lead to more readable code (when used properly). Note that there are now 2 different (but somewhat similar) pipes available in R (there could be more in some package(s) that I don't know about,

Re: [R] Pipe operator

2023-01-03 Thread Ebert,Timothy Aaron
. Tim -Original Message- From: R-help On Behalf Of Sorkin, John Sent: Tuesday, January 3, 2023 11:49 AM To: 'R-help Mailing List' Subject: [R] Pipe operator [External Email] I am trying to understand the reason for existence of the pipe operator, %>%, and when one should use it

Re: [R] Pipe operator

2023-01-03 Thread Sorkin, John
-Original Message- From: R-help On Behalf Of Sorkin, John Sent: Tuesday, January 3, 2023 11:49 AM To: 'R-help Mailing List' Subject: [R] Pipe operator [External Email] I am trying to understand the reason for existence of the pipe operator, %>%, and when one should use it. It i

Re: [R] Pipe operator

2023-01-03 Thread Ebert,Timothy Aaron
I have not encountered a difference. Tim -Original Message- From: R-help On Behalf Of Sorkin, John Sent: Tuesday, January 3, 2023 11:49 AM To: 'R-help Mailing List' Subject: [R] Pipe operator [External Email] I am trying to understand the reason for existence of the pipe op

[R] Pipe operator

2023-01-03 Thread Sorkin, John
I am trying to understand the reason for existence of the pipe operator, %>%, and when one should use it. It is my understanding that the operator sends the file to the left of the operator to the function immediately to the right of the operator: c(1:10) %>% mean results in a value of 5.5

Re: [R] Pipe precedence

2021-05-23 Thread Duncan Murdoch
On 22/05/2021 8:26 p.m., Jeff Newmiller wrote: What is the precedence of the new |> pipe operator? I don't see it mentioned in ?Syntax, nor does it come up when I search the R Language Definition document. It's the same precedence as the %any% operators listed in the ?Syntax table, so it

Re: [R] Pipe precedence

2021-05-22 Thread Jeff Newmiller
R 4.1.0 was released this week with a new pipe operator and a new anonymous function shorthand (\(x) x^2). The pipe operator is not quite as flexible as the magrittr pipe, but it is faster (not that the magrittr pipe is noticably slow) and built-in. On May 22, 2021 8:07:27 PM PDT, Caitlin

Re: [R] Pipe precedence

2021-05-22 Thread Eric Berger
This is part of the R-4.1.0 release which came out a few days ago. See 1. https://stat.ethz.ch/pipermail/r-announce/2021/000670.html 2. https://www.jumpingrivers.com/blog/new-features-r410-pipe-anonymous-functions/ 3.

Re: [R] Pipe precedence

2021-05-22 Thread Caitlin Gibbons
I didn’t know R had a new pipe operator, but I have seen “|>” (without quotes) used in the Elixir language though. Are there now two? “%>%” from the magrittr package and “|>” which is built-in? > On May 22, 2021, at 5:26 PM, Jeff Newmiller wrote: > > What is the precedence of the new |> pipe

[R] Pipe precedence

2021-05-22 Thread Jeff Newmiller
What is the precedence of the new |> pipe operator? I don't see it mentioned in ?Syntax, nor does it come up when I search the R Language Definition document. -- Sent from my phone. Please excuse my brevity. __ R-help@r-project.org mailing list -- To

[R] pipe or system command

2013-04-04 Thread nalluri pratap
Hi,   In SAS I have something like   %let dirname = c:\work\raw_data_files; filename DIRLIST pipe dir /B dirname\*.txt;   Can someone help me to convert this to R. I tried with system and pipe, but It actually creates a file on the disk which I don't like. I just need to have a reference to the

Re: [R] pipe or system command

2013-04-04 Thread William Dunlap
Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of nalluri pratap Sent: Thursday, April 04, 2013 7:57 AM To: r-help@r-project.org Subject: [R] pipe or system command Hi, In SAS I have something like

Re: [R] Pipe

2010-05-26 Thread Joe Stuart
Thanks for the info. I'll give that a try. On May 25, 2010, at 5:36 PM, jim holtman jholt...@gmail.com wrote: readLines will read until it reached an end-of -file. try readLines(con, n=1) to read one line at a time an then process it. On Tue, May 25, 2010 at 2:07 PM, Joe Stuart

[R] Pipe

2010-05-25 Thread Joe Stuart
Hi, I'm trying to use the pipe function to read data from another process on my server. Here is the code I have tried. con - pipe(/var/matlab/scripts/stream.pl) while(con_read - readLines(con)) { print(con_read) } Problem is that the data from the perl script just keeps appending to con_read

Re: [R] Pipe

2010-05-25 Thread jim holtman
readLines will read until it reached an end-of -file. try readLines(con, n=1) to read one line at a time an then process it. On Tue, May 25, 2010 at 2:07 PM, Joe Stuart joe.stu...@gmail.com wrote: Hi, I'm trying to use the pipe function to read data from another process on my server. Here

[R] Pipe /shell - R does not wait

2010-02-01 Thread robbert blonk
Dear All, Within a large script, I try to invoke a second program (called e.g. XXX) from R using shell or pipe. e.g.: readLines(pipe(XXX)) or: shell(XXX,intern=TRUE, wait = TRUE) After running the program, the script reads a file with solutions produced by the second program (XXX.001).

Re: [R] Pipe /shell - R does not wait

2010-02-01 Thread Duncan Murdoch
robbert blonk wrote: Dear All, Within a large script, I try to invoke a second program (called e.g. XXX) from R using shell or pipe. e.g.: readLines(pipe(XXX)) or: shell(XXX,intern=TRUE, wait = TRUE) After running the program, the script reads a file with solutions

Re: [R] Pipe /shell - R does not wait

2010-02-01 Thread robbert blonk
Sorry, forgot to included the information. Working in Windows (although a try on linux gave the same problems) R 2.10.0 Do you suggest to update a newer version of R? regards, Robbert -- View this message in context: http://n4.nabble.com/Pipe-shell-R-does-not-wait-tp1458692p1458727.html

Re: [R] Pipe /shell - R does not wait

2010-02-01 Thread Duncan Murdoch
robbert blonk wrote: Sorry, forgot to included the information. Working in Windows (although a try on linux gave the same problems) R 2.10.0 Do you suggest to update a newer version of R? I don't think there were any changes to the system() code between 2.10.0 and 2.10.1, but there are

[R] pipe data from plot(). was: ROCR.plot methods, cross validation averaging

2009-09-24 Thread Tim Howard
All, I'm trying again with a slightly more generic version of my first question. I can extract the plotted values from hist(), boxplot(), and even plot.randomForest(). Observe: # get some data dat - rnorm(100) # grab histogram data hdat - hist(dat) hdat #provides details of the hist

Re: [R] pipe data from plot(). was: ROCR.plot methods, cross validation averaging

2009-09-24 Thread David Winsemius
On Sep 24, 2009, at 9:09 AM, Tim Howard wrote: All, I'm trying again with a slightly more generic version of my first question. I can extract the plotted values from hist(), boxplot(), and even plot.randomForest(). Observe: # get some data dat - rnorm(100) # grab histogram data hdat -

Re: [R] pipe data from plot(). was: ROCR.plot methods, cross validation averaging

2009-09-24 Thread Tim Howard
Whoops, sorry. Here is the full set with the missing lines: library(ROCR) data(ROCR.xval) pred - prediction(ROCR.xval$predictions, ROCR.xval$labels) perf - performance(pred,tpr,fpr) RCdat - plot(perf, avg=threshold) RCdat Thanks. Tim David Winsemius dwinsem...@comcast.net 9/24/2009 9:25 AM On

Re: [R] pipe data from plot(). was: ROCR.plot methods, cross validation averaging

2009-09-24 Thread David Winsemius
On Sep 24, 2009, at 9:09 AM, Tim Howard wrote: All, I'm trying again with a slightly more generic version of my first question. I can extract the plotted values from hist(), boxplot(), and even plot.randomForest(). Observe: # get some data dat - rnorm(100) # grab histogram data hdat -

Re: [R] pipe data from plot(). was: ROCR.plot methods, cross validation averaging

2009-09-24 Thread Tobias Sing
Tim, if I understand correctly, you are trying to get the numerical values of averaged cross-validation curves. Unfortunately the plot function of ROCR does not return anything in the current version (it's a good suggestion to change this). If you want a quick fix, you could change the

Re: [R] pipe data from plot(). was: ROCR.plot methods, cross validation averaging

2009-09-24 Thread Tim Howard
David, Thank you for your reply. Yes, I can access the y-values slot with p...@y-values but, note that in the cross-validation example (ROCR.xval), the plot function averages across the list of ten vectors in the y-values slot. I might be able to create a function to average across these ten

Re: [R] pipe data from plot(). was: ROCR.plot methods, cross validation averaging

2009-09-24 Thread Tim Howard
Yes, that's exactly what I am after. Thank you for clarifying my problem for me! I'll try to dive into the plot.performance function. Best, Tim Tobias Sing tobias.s...@gmail.com 9/24/2009 9:57 AM Tim, if I understand correctly, you are trying to get the numerical values of averaged

[R] pipe scan timeout

2007-11-06 Thread yoooooo
Hi all, Usually when I do a command in shell and have the output read from R, I like to do this: pp - pipe(cmd) sol - scan(pp, what=character, sep=\n) I prefer this one over read.table since read.table somewhere has a gc call and it's slow. However, sometimes