[Rd] should the text for RIGHT_ASSIGN be -> in getParseData()?

2013-07-05 Thread Yihui Xie
Hi,

The text column for '->' becomes '<-' in the data frame returned by
getParseData():

> getParseData(parse(text='1->x'))
  line1 col1 line2 col2 id parenttoken terminal text
7 11 14  7  0 exprFALSE
1 11 11  1  2NUM_CONST TRUE1
2 11 11  2  7 exprFALSE
3 12 13  3  7 RIGHT_ASSIGN TRUE   <-
4 14 14  4  6   SYMBOL TRUEx
6 14 14  6  7 exprFALSE

Is that expected?

> sessionInfo()
R version 3.0.1 (2013-05-16)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=C LC_NAME=C
 [9] LC_ADDRESS=C   LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base

Regards,
Yihui
--
Yihui Xie 
Phone: 206-667-4385 Web: http://yihui.name
Fred Hutchinson Cancer Research Center, Seattle

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] Get the tail of a list in C

2013-07-05 Thread maxpar
Hi, 

I am write R extensions in C. Now I have a VECSXP variable, so how can I get
the tail of it (all but the first one) as a new VECSXP. I tried CDR(), but
it gives error. 

Thanks. 



--
View this message in context: 
http://r.789695.n4.nabble.com/Get-the-tail-of-a-list-in-C-tp4670900.html
Sent from the R devel mailing list archive at Nabble.com.

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] should the text for RIGHT_ASSIGN be -> in getParseData()?

2013-07-05 Thread Duncan Murdoch

On 13-07-05 3:31 AM, Yihui Xie wrote:

Hi,

The text column for '->' becomes '<-' in the data frame returned by
getParseData():


getParseData(parse(text='1->x'))

   line1 col1 line2 col2 id parenttoken terminal text
7 11 14  7  0 exprFALSE
1 11 11  1  2NUM_CONST TRUE1
2 11 11  2  7 exprFALSE
3 12 13  3  7 RIGHT_ASSIGN TRUE   <-
4 14 14  4  6   SYMBOL TRUEx
6 14 14  6  7 exprFALSE

Is that expected?


It's by design, but I agree it's not ideal.  The reason for it is that 
"1 -> x" is parsed as `<-`(x, 1).  I think the parser only does 
translations like this for -> and ->>.  Currently the parser shows the 
name of the binary operator as the text.


I'll look into adding special handling for translations like this.  We 
will still parse the assignment in the same way, but the getParseData 
text could be the true text.


Duncan Murdoch





sessionInfo()

R version 3.0.1 (2013-05-16)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
  [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
  [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8
  [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8
  [7] LC_PAPER=C LC_NAME=C
  [9] LC_ADDRESS=C   LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base

Regards,
Yihui
--
Yihui Xie 
Phone: 206-667-4385 Web: http://yihui.name
Fred Hutchinson Cancer Research Center, Seattle

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel



__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] should the text for RIGHT_ASSIGN be -> in getParseData()?

2013-07-05 Thread peter dalgaard

On Jul 5, 2013, at 13:29 , Duncan Murdoch wrote:

> On 13-07-05 3:31 AM, Yihui Xie wrote:
>> Hi,
>> 
>> The text column for '->' becomes '<-' in the data frame returned by
>> getParseData():
>> 
>>> getParseData(parse(text='1->x'))
>>   line1 col1 line2 col2 id parenttoken terminal text
>> 7 11 14  7  0 exprFALSE
>> 1 11 11  1  2NUM_CONST TRUE1
>> 2 11 11  2  7 exprFALSE
>> 3 12 13  3  7 RIGHT_ASSIGN TRUE   <-
>> 4 14 14  4  6   SYMBOL TRUEx
>> 6 14 14  6  7 exprFALSE
>> 
>> Is that expected?
> 
> It's by design, but I agree it's not ideal.  The reason for it is that "1 -> 
> x" is parsed as `<-`(x, 1).  I think the parser only does translations like 
> this for -> and ->>.  Currently the parser shows the name of the binary 
> operator as the text.
> 
> I'll look into adding special handling for translations like this.  We will 
> still parse the assignment in the same way, but the getParseData text could 
> be the true text.

Just watch out for potential complications, e.g.

> `->`(x,1)
Error: could not find function "->"

so one needs to be sure that nothing will assume that the text column is a 
function name.

-- 
Peter Dalgaard, Professor
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@gmail.com

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] should the text for RIGHT_ASSIGN be -> in getParseData()?

2013-07-05 Thread Duncan Murdoch

On 13-07-05 7:40 AM, peter dalgaard wrote:


On Jul 5, 2013, at 13:29 , Duncan Murdoch wrote:


On 13-07-05 3:31 AM, Yihui Xie wrote:

Hi,

The text column for '->' becomes '<-' in the data frame returned by
getParseData():


getParseData(parse(text='1->x'))

   line1 col1 line2 col2 id parenttoken terminal text
7 11 14  7  0 exprFALSE
1 11 11  1  2NUM_CONST TRUE1
2 11 11  2  7 exprFALSE
3 12 13  3  7 RIGHT_ASSIGN TRUE   <-
4 14 14  4  6   SYMBOL TRUEx
6 14 14  6  7 exprFALSE

Is that expected?


It's by design, but I agree it's not ideal.  The reason for it is that "1 -> x" is parsed 
as `<-`(x, 1).  I think the parser only does translations like this for -> and ->>.  
Currently the parser shows the name of the binary operator as the text.

I'll look into adding special handling for translations like this.  We will 
still parse the assignment in the same way, but the getParseData text could be 
the true text.


Just watch out for potential complications, e.g.


`->`(x,1)

Error: could not find function "->"

so one needs to be sure that nothing will assume that the text column is a 
function name.



R itself doesn't make use of the text column, it's for display of code 
by highlighters etc.  So if anyone does assume text is a function name, 
it's their bug, not ours.  In fact, the bug is already there, because 
there is actually one other example which was being parsed properly, 
"**" is translated to "^".  There's no `**` function, but 2**3 works.


Duncan Murdoch

Duncan

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Get the tail of a list in C

2013-07-05 Thread romain

Le 2013-07-05 07:15, maxpar a écrit :

Hi,

I am write R extensions in C. Now I have a VECSXP variable, so how 
can I get
the tail of it (all but the first one) as a new VECSXP. I tried 
CDR(), but

it gives error.

Thanks.


Hello,

A VECSXP is actually an array of pointers, not a linked list. If you 
want the tail, you have to allocate new data.
For a simplistic version that does not deal with attributes, names, etc 
..., try something like this:


int n = length( x ) - 1  ;
SEXP taildata = PROTECT( allocVector( VECSXP, n ) ) ;
for( int i=0; ihttps://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] should the text for RIGHT_ASSIGN be -> in getParseData()?

2013-07-05 Thread Barry Rowlingson
On Fri, Jul 5, 2013 at 12:57 PM, Duncan Murdoch
 wrote:

> R itself doesn't make use of the text column, it's for display of code
> by highlighters etc.  So if anyone does assume text is a function name,
> it's their bug, not ours.  In fact, the bug is already there, because
> there is actually one other example which was being parsed properly,
> "**" is translated to "^".  There's no `**` function, but 2**3 works.

 Is there any reason right-assign with "->" still exists? How much
code on CRAN uses it, and how trivially could it be excised? Can we
also have 'up assign'  and "down assign" so I can do:

 > 3
 > x -^
 > x -v
 > 4

 - they make just as much sense.

 Okay, lets see all the edge cases.

Barry

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] should the text for RIGHT_ASSIGN be -> in getParseData()?

2013-07-05 Thread William Dunlap
>  Is there any reason right-assign with "->" still exists? How much
> code on CRAN uses it, and how trivially could it be excised?

I use '->' a lot when doing interactive work.  I often first run a command
to see its printed output then decide that I had better save its value.
The up-arrow key gives me the previous command line with the cursor placed at 
the
end of the line so adding '-> z' at the end of the line is convenient.
(Not using the up-arrow key and doing 'z <- .Last.value' also works, but
I don't like its context sensitivity.)

I never use '->' when writing code in a file, so you would have to search
my .Rhistory files, not my *.R files, for evidence of its usefulness to me.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com


> -Original Message-
> From: r-devel-boun...@r-project.org [mailto:r-devel-boun...@r-project.org] On 
> Behalf
> Of Barry Rowlingson
> Sent: Friday, July 05, 2013 9:29 AM
> To: Duncan Murdoch
> Cc: R-devel
> Subject: Re: [Rd] should the text for RIGHT_ASSIGN be -> in getParseData()?
> 
> On Fri, Jul 5, 2013 at 12:57 PM, Duncan Murdoch
>  wrote:
> 
> > R itself doesn't make use of the text column, it's for display of code
> > by highlighters etc.  So if anyone does assume text is a function name,
> > it's their bug, not ours.  In fact, the bug is already there, because
> > there is actually one other example which was being parsed properly,
> > "**" is translated to "^".  There's no `**` function, but 2**3 works.
> 
>  Is there any reason right-assign with "->" still exists? How much
> code on CRAN uses it, and how trivially could it be excised? Can we
> also have 'up assign'  and "down assign" so I can do:
> 
>  > 3
>  > x -^
>  > x -v
>  > 4
> 
>  - they make just as much sense.
> 
>  Okay, lets see all the edge cases.
> 
> Barry
> 
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] should the text for RIGHT_ASSIGN be -> in getParseData()?

2013-07-05 Thread peter dalgaard

On Jul 5, 2013, at 18:59 , William Dunlap wrote:

>> Is there any reason right-assign with "->" still exists? How much
>> code on CRAN uses it, and how trivially could it be excised?
> 
> I use '->' a lot when doing interactive work.  I often first run a command
> to see its printed output then decide that I had better save its value.
> The up-arrow key gives me the previous command line with the cursor placed at 
> the
> end of the line so adding '-> z' at the end of the line is convenient.
> (Not using the up-arrow key and doing 'z <- .Last.value' also works, but
> I don't like its context sensitivity.)

But up-arrow, ctrl-A then "z <-" is not much less convenient, is it? 

I have used in with multi-line input, occasionally, though. As in

replicate(1, {
   ysim <- rbinom(length(p), n, p)
   glm(cbind(ysim, n - ysim) ~ x, binomial)$deviance 
})

... and then you realize that you probably don't want to look at 1 
simulated deviances and add "-> simDev". 

> 
> I never use '->' when writing code in a file, so you would have to search
> my .Rhistory files, not my *.R files, for evidence of its usefulness to me.
> 
> Bill Dunlap
> Spotfire, TIBCO Software
> wdunlap tibco.com
> 
> 
>> -Original Message-
>> From: r-devel-boun...@r-project.org [mailto:r-devel-boun...@r-project.org] 
>> On Behalf
>> Of Barry Rowlingson
>> Sent: Friday, July 05, 2013 9:29 AM
>> To: Duncan Murdoch
>> Cc: R-devel
>> Subject: Re: [Rd] should the text for RIGHT_ASSIGN be -> in getParseData()?
>> 
>> On Fri, Jul 5, 2013 at 12:57 PM, Duncan Murdoch
>>  wrote:
>> 
>>> R itself doesn't make use of the text column, it's for display of code
>>> by highlighters etc.  So if anyone does assume text is a function name,
>>> it's their bug, not ours.  In fact, the bug is already there, because
>>> there is actually one other example which was being parsed properly,
>>> "**" is translated to "^".  There's no `**` function, but 2**3 works.
>> 
>> Is there any reason right-assign with "->" still exists? How much
>> code on CRAN uses it, and how trivially could it be excised? Can we
>> also have 'up assign'  and "down assign" so I can do:
>> 
>>>3
>>> x -^
>>> x -v
>>>4
>> 
>> - they make just as much sense.
>> 
>> Okay, lets see all the edge cases.
>> 
>> Barry
>> 
>> __
>> R-devel@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
> 
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@gmail.com

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] should the text for RIGHT_ASSIGN be -> in getParseData()?

2013-07-05 Thread William Dunlap
> But up-arrow, ctrl-A then "z <-" is not much less convenient, is it?

I didn't know that ctrl-A would bring me to the start of the line, nor
that ctrl-E would bring me to the end.  Thanks.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com


> -Original Message-
> From: peter dalgaard [mailto:pda...@gmail.com]
> Sent: Friday, July 05, 2013 11:25 AM
> To: William Dunlap
> Cc: Barry Rowlingson; R-devel
> Subject: Re: [Rd] should the text for RIGHT_ASSIGN be -> in getParseData()?
> 
> 
> On Jul 5, 2013, at 18:59 , William Dunlap wrote:
> 
> >> Is there any reason right-assign with "->" still exists? How much
> >> code on CRAN uses it, and how trivially could it be excised?
> >
> > I use '->' a lot when doing interactive work.  I often first run a command
> > to see its printed output then decide that I had better save its value.
> > The up-arrow key gives me the previous command line with the cursor placed 
> > at the
> > end of the line so adding '-> z' at the end of the line is convenient.
> > (Not using the up-arrow key and doing 'z <- .Last.value' also works, but
> > I don't like its context sensitivity.)
> 
> But up-arrow, ctrl-A then "z <-" is not much less convenient, is it?
> 
> I have used in with multi-line input, occasionally, though. As in
> 
> replicate(1, {
>ysim <- rbinom(length(p), n, p)
>glm(cbind(ysim, n - ysim) ~ x, binomial)$deviance
> })
> 
> ... and then you realize that you probably don't want to look at 1 
> simulated
> deviances and add "-> simDev".
> 
> >
> > I never use '->' when writing code in a file, so you would have to search
> > my .Rhistory files, not my *.R files, for evidence of its usefulness to me.
> >
> > Bill Dunlap
> > Spotfire, TIBCO Software
> > wdunlap tibco.com
> >
> >
> >> -Original Message-
> >> From: r-devel-boun...@r-project.org [mailto:r-devel-boun...@r-project.org] 
> >> On
> Behalf
> >> Of Barry Rowlingson
> >> Sent: Friday, July 05, 2013 9:29 AM
> >> To: Duncan Murdoch
> >> Cc: R-devel
> >> Subject: Re: [Rd] should the text for RIGHT_ASSIGN be -> in getParseData()?
> >>
> >> On Fri, Jul 5, 2013 at 12:57 PM, Duncan Murdoch
> >>  wrote:
> >>
> >>> R itself doesn't make use of the text column, it's for display of code
> >>> by highlighters etc.  So if anyone does assume text is a function name,
> >>> it's their bug, not ours.  In fact, the bug is already there, because
> >>> there is actually one other example which was being parsed properly,
> >>> "**" is translated to "^".  There's no `**` function, but 2**3 works.
> >>
> >> Is there any reason right-assign with "->" still exists? How much
> >> code on CRAN uses it, and how trivially could it be excised? Can we
> >> also have 'up assign'  and "down assign" so I can do:
> >>
> >>>3
> >>> x -^
> >>> x -v
> >>>4
> >>
> >> - they make just as much sense.
> >>
> >> Okay, lets see all the edge cases.
> >>
> >> Barry
> >>
> >> __
> >> R-devel@r-project.org mailing list
> >> https://stat.ethz.ch/mailman/listinfo/r-devel
> >
> > __
> > R-devel@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel
> 
> --
> Peter Dalgaard, Professor,
> Center for Statistics, Copenhagen Business School
> Solbjerg Plads 3, 2000 Frederiksberg, Denmark
> Phone: (+45)38153501
> Email: pd@cbs.dk  Priv: pda...@gmail.com
> 
> 
> 
> 
> 
> 
> 

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] should the text for RIGHT_ASSIGN be -> in getParseData()?

2013-07-05 Thread Brian Lee Yung Rowe
Here are two more standard emacs bindings that work:  Ctrl-K to cut and Ctrl-Y 
to paste. 

•
Brian Lee Yung Rowe
917 496 4583


On Jul 5, 2013, at 2:32 PM, William Dunlap  wrote:

>> But up-arrow, ctrl-A then "z <-" is not much less convenient, is it?
> 
> I didn't know that ctrl-A would bring me to the start of the line, nor
> that ctrl-E would bring me to the end.  Thanks.
> 
> Bill Dunlap
> Spotfire, TIBCO Software
> wdunlap tibco.com
> 
> 
>> -Original Message-
>> From: peter dalgaard [mailto:pda...@gmail.com]
>> Sent: Friday, July 05, 2013 11:25 AM
>> To: William Dunlap
>> Cc: Barry Rowlingson; R-devel
>> Subject: Re: [Rd] should the text for RIGHT_ASSIGN be -> in getParseData()?
>> 
>> 
>> On Jul 5, 2013, at 18:59 , William Dunlap wrote:
>> 
 Is there any reason right-assign with "->" still exists? How much
 code on CRAN uses it, and how trivially could it be excised?
>>> 
>>> I use '->' a lot when doing interactive work.  I often first run a command
>>> to see its printed output then decide that I had better save its value.
>>> The up-arrow key gives me the previous command line with the cursor placed 
>>> at the
>>> end of the line so adding '-> z' at the end of the line is convenient.
>>> (Not using the up-arrow key and doing 'z <- .Last.value' also works, but
>>> I don't like its context sensitivity.)
>> 
>> But up-arrow, ctrl-A then "z <-" is not much less convenient, is it?
>> 
>> I have used in with multi-line input, occasionally, though. As in
>> 
>> replicate(1, {
>>   ysim <- rbinom(length(p), n, p)
>>   glm(cbind(ysim, n - ysim) ~ x, binomial)$deviance
>> })
>> 
>> ... and then you realize that you probably don't want to look at 1 
>> simulated
>> deviances and add "-> simDev".
>> 
>>> 
>>> I never use '->' when writing code in a file, so you would have to search
>>> my .Rhistory files, not my *.R files, for evidence of its usefulness to me.
>>> 
>>> Bill Dunlap
>>> Spotfire, TIBCO Software
>>> wdunlap tibco.com
>>> 
>>> 
 -Original Message-
 From: r-devel-boun...@r-project.org [mailto:r-devel-boun...@r-project.org] 
 On
>> Behalf
 Of Barry Rowlingson
 Sent: Friday, July 05, 2013 9:29 AM
 To: Duncan Murdoch
 Cc: R-devel
 Subject: Re: [Rd] should the text for RIGHT_ASSIGN be -> in getParseData()?
 
 On Fri, Jul 5, 2013 at 12:57 PM, Duncan Murdoch
  wrote:
 
> R itself doesn't make use of the text column, it's for display of code
> by highlighters etc.  So if anyone does assume text is a function name,
> it's their bug, not ours.  In fact, the bug is already there, because
> there is actually one other example which was being parsed properly,
> "**" is translated to "^".  There's no `**` function, but 2**3 works.
 
 Is there any reason right-assign with "->" still exists? How much
 code on CRAN uses it, and how trivially could it be excised? Can we
 also have 'up assign'  and "down assign" so I can do:
 
>   3
> x -^
> x -v
>   4
 
 - they make just as much sense.
 
 Okay, lets see all the edge cases.
 
 Barry
 
 __
 R-devel@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-devel
>>> 
>>> __
>>> R-devel@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-devel
>> 
>> --
>> Peter Dalgaard, Professor,
>> Center for Statistics, Copenhagen Business School
>> Solbjerg Plads 3, 2000 Frederiksberg, Denmark
>> Phone: (+45)38153501
>> Email: pd@cbs.dk  Priv: pda...@gmail.com
> 
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] should the text for RIGHT_ASSIGN be -> in getParseData()?

2013-07-05 Thread Duncan Murdoch

On 05/07/2013 12:29 PM, Barry Rowlingson wrote:

On Fri, Jul 5, 2013 at 12:57 PM, Duncan Murdoch
 wrote:

> R itself doesn't make use of the text column, it's for display of code
> by highlighters etc.  So if anyone does assume text is a function name,
> it's their bug, not ours.  In fact, the bug is already there, because
> there is actually one other example which was being parsed properly,
> "**" is translated to "^".  There's no `**` function, but 2**3 works.

  Is there any reason right-assign with "->" still exists? How much
code on CRAN uses it, and how trivially could it be excised?


Dozens of packages on CRAN use it:  abc, abd, adabag, AdaptFitOS, bgeva, ...


Can we
also have 'up assign'  and "down assign" so I can do:

  > 3
  > x -^
  > x -v
  > 4

  - they make just as much sense.


I'll work on those; they sound easier than excising right-assign.

Duncan


  Okay, lets see all the edge cases.

Barry


__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] should the text for RIGHT_ASSIGN be -> in getParseData()?

2013-07-05 Thread William Dunlap
Ctrl-K is delete from here to end of line on Linux-comand-line and Windows-GUI 
R.
(My fingers are not nimble enough for emacs, I'll stick with vi.)

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com


> -Original Message-
> From: Brian Lee Yung Rowe [mailto:r...@muxspace.com]
> Sent: Friday, July 05, 2013 12:11 PM
> To: William Dunlap
> Cc: peter dalgaard; R-devel; Barry Rowlingson
> Subject: Re: [Rd] should the text for RIGHT_ASSIGN be -> in getParseData()?
> 
> Here are two more standard emacs bindings that work:  Ctrl-K to cut and 
> Ctrl-Y to paste.
> 
> •
> Brian Lee Yung Rowe
> 917 496 4583
> 
> 
> On Jul 5, 2013, at 2:32 PM, William Dunlap  wrote:
> 
> >> But up-arrow, ctrl-A then "z <-" is not much less convenient, is it?
> >
> > I didn't know that ctrl-A would bring me to the start of the line, nor
> > that ctrl-E would bring me to the end.  Thanks.
> >
> > Bill Dunlap
> > Spotfire, TIBCO Software
> > wdunlap tibco.com
> >
> >
> >> -Original Message-
> >> From: peter dalgaard [mailto:pda...@gmail.com]
> >> Sent: Friday, July 05, 2013 11:25 AM
> >> To: William Dunlap
> >> Cc: Barry Rowlingson; R-devel
> >> Subject: Re: [Rd] should the text for RIGHT_ASSIGN be -> in getParseData()?
> >>
> >>
> >> On Jul 5, 2013, at 18:59 , William Dunlap wrote:
> >>
>  Is there any reason right-assign with "->" still exists? How much
>  code on CRAN uses it, and how trivially could it be excised?
> >>>
> >>> I use '->' a lot when doing interactive work.  I often first run a command
> >>> to see its printed output then decide that I had better save its value.
> >>> The up-arrow key gives me the previous command line with the cursor 
> >>> placed at the
> >>> end of the line so adding '-> z' at the end of the line is convenient.
> >>> (Not using the up-arrow key and doing 'z <- .Last.value' also works, but
> >>> I don't like its context sensitivity.)
> >>
> >> But up-arrow, ctrl-A then "z <-" is not much less convenient, is it?
> >>
> >> I have used in with multi-line input, occasionally, though. As in
> >>
> >> replicate(1, {
> >>   ysim <- rbinom(length(p), n, p)
> >>   glm(cbind(ysim, n - ysim) ~ x, binomial)$deviance
> >> })
> >>
> >> ... and then you realize that you probably don't want to look at 1 
> >> simulated
> >> deviances and add "-> simDev".
> >>
> >>>
> >>> I never use '->' when writing code in a file, so you would have to search
> >>> my .Rhistory files, not my *.R files, for evidence of its usefulness to 
> >>> me.
> >>>
> >>> Bill Dunlap
> >>> Spotfire, TIBCO Software
> >>> wdunlap tibco.com
> >>>
> >>>
>  -Original Message-
>  From: r-devel-boun...@r-project.org 
>  [mailto:r-devel-boun...@r-project.org] On
> >> Behalf
>  Of Barry Rowlingson
>  Sent: Friday, July 05, 2013 9:29 AM
>  To: Duncan Murdoch
>  Cc: R-devel
>  Subject: Re: [Rd] should the text for RIGHT_ASSIGN be -> in 
>  getParseData()?
> 
>  On Fri, Jul 5, 2013 at 12:57 PM, Duncan Murdoch
>   wrote:
> 
> > R itself doesn't make use of the text column, it's for display of code
> > by highlighters etc.  So if anyone does assume text is a function name,
> > it's their bug, not ours.  In fact, the bug is already there, because
> > there is actually one other example which was being parsed properly,
> > "**" is translated to "^".  There's no `**` function, but 2**3 works.
> 
>  Is there any reason right-assign with "->" still exists? How much
>  code on CRAN uses it, and how trivially could it be excised? Can we
>  also have 'up assign'  and "down assign" so I can do:
> 
> >   3
> > x -^
> > x -v
> >   4
> 
>  - they make just as much sense.
> 
>  Okay, lets see all the edge cases.
> 
>  Barry
> 
>  __
>  R-devel@r-project.org mailing list
>  https://stat.ethz.ch/mailman/listinfo/r-devel
> >>>
> >>> __
> >>> R-devel@r-project.org mailing list
> >>> https://stat.ethz.ch/mailman/listinfo/r-devel
> >>
> >> --
> >> Peter Dalgaard, Professor,
> >> Center for Statistics, Copenhagen Business School
> >> Solbjerg Plads 3, 2000 Frederiksberg, Denmark
> >> Phone: (+45)38153501
> >> Email: pd@cbs.dk  Priv: pda...@gmail.com
> >
> > __
> > R-devel@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel
__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Get the tail of a list in C

2013-07-05 Thread maxpar
Thanks. Got it. I need differentiate pairlist and list.





--
View this message in context: 
http://r.789695.n4.nabble.com/Get-the-tail-of-a-list-in-C-tp4670900p4670958.html
Sent from the R devel mailing list archive at Nabble.com.

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] should the text for RIGHT_ASSIGN be -> in getParseData()?

2013-07-05 Thread Barry Rowlingson
On Fri, Jul 5, 2013 at 7:24 PM, peter dalgaard  wrote:

> I have used in with multi-line input, occasionally, though. As in
>
> replicate(1, {
>ysim <- rbinom(length(p), n, p)
>glm(cbind(ysim, n - ysim) ~ x, binomial)$deviance
> })
>
> ... and then you realize that you probably don't want to look at 1 
> simulated deviances and add "-> simDev".
>

 Yes, that's kinda cute, but then you realise you don't want to have
to type all that again and it would really be better off in a
function. Can you do something like:

replicate(1,{
  ysim <- rbinom(length(p), n, p)
glm(cbind(ysim, n - ysim) ~ x, binomial)$deviance
}) -> function()...

 - I don't think so. Once you've started typing, the only way to get
it into a function is going to involve sticking function() at the
start, at which point you can add the foo <-

I guess this is the point where Dirk gets upset and calls me a troll.
I'll shut up. You've convinced me its mostly harmless.

Barry

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] should the text for RIGHT_ASSIGN be -> in getParseData()?

2013-07-05 Thread Brian Lee Yung Rowe
That is a more accurate statement regarding Ctrl-K. Nonetheless whatever is 
killed can be yanked back via Ctrl-Y, so the effect emulates cutting and 
pasting. I am also a vi user, but these four basic emacs bindings seem to 
perennially haunt numerous terminal apps. 

•
Brian Lee Yung Rowe
917 496 4583


On Jul 5, 2013, at 3:53 PM, William Dunlap  wrote:

> Ctrl-K is delete from here to end of line on Linux-comand-line and 
> Windows-GUI R.
> (My fingers are not nimble enough for emacs, I'll stick with vi.)
> 
> Bill Dunlap
> Spotfire, TIBCO Software
> wdunlap tibco.com
> 
> 
>> -Original Message-
>> From: Brian Lee Yung Rowe [mailto:r...@muxspace.com]
>> Sent: Friday, July 05, 2013 12:11 PM
>> To: William Dunlap
>> Cc: peter dalgaard; R-devel; Barry Rowlingson
>> Subject: Re: [Rd] should the text for RIGHT_ASSIGN be -> in getParseData()?
>> 
>> Here are two more standard emacs bindings that work:  Ctrl-K to cut and 
>> Ctrl-Y to paste.
>> 
>> •
>> Brian Lee Yung Rowe
>> 917 496 4583
>> 
>> 
>> On Jul 5, 2013, at 2:32 PM, William Dunlap  wrote:
>> 
 But up-arrow, ctrl-A then "z <-" is not much less convenient, is it?
>>> 
>>> I didn't know that ctrl-A would bring me to the start of the line, nor
>>> that ctrl-E would bring me to the end.  Thanks.
>>> 
>>> Bill Dunlap
>>> Spotfire, TIBCO Software
>>> wdunlap tibco.com
>>> 
>>> 
 -Original Message-
 From: peter dalgaard [mailto:pda...@gmail.com]
 Sent: Friday, July 05, 2013 11:25 AM
 To: William Dunlap
 Cc: Barry Rowlingson; R-devel
 Subject: Re: [Rd] should the text for RIGHT_ASSIGN be -> in getParseData()?
 
 
 On Jul 5, 2013, at 18:59 , William Dunlap wrote:
 
>> Is there any reason right-assign with "->" still exists? How much
>> code on CRAN uses it, and how trivially could it be excised?
> 
> I use '->' a lot when doing interactive work.  I often first run a command
> to see its printed output then decide that I had better save its value.
> The up-arrow key gives me the previous command line with the cursor 
> placed at the
> end of the line so adding '-> z' at the end of the line is convenient.
> (Not using the up-arrow key and doing 'z <- .Last.value' also works, but
> I don't like its context sensitivity.)
 
 But up-arrow, ctrl-A then "z <-" is not much less convenient, is it?
 
 I have used in with multi-line input, occasionally, though. As in
 
 replicate(1, {
  ysim <- rbinom(length(p), n, p)
  glm(cbind(ysim, n - ysim) ~ x, binomial)$deviance
 })
 
 ... and then you realize that you probably don't want to look at 1 
 simulated
 deviances and add "-> simDev".
 
> 
> I never use '->' when writing code in a file, so you would have to search
> my .Rhistory files, not my *.R files, for evidence of its usefulness to 
> me.
> 
> Bill Dunlap
> Spotfire, TIBCO Software
> wdunlap tibco.com
> 
> 
>> -Original Message-
>> From: r-devel-boun...@r-project.org 
>> [mailto:r-devel-boun...@r-project.org] On
 Behalf
>> Of Barry Rowlingson
>> Sent: Friday, July 05, 2013 9:29 AM
>> To: Duncan Murdoch
>> Cc: R-devel
>> Subject: Re: [Rd] should the text for RIGHT_ASSIGN be -> in 
>> getParseData()?
>> 
>> On Fri, Jul 5, 2013 at 12:57 PM, Duncan Murdoch
>>  wrote:
>> 
>>> R itself doesn't make use of the text column, it's for display of code
>>> by highlighters etc.  So if anyone does assume text is a function name,
>>> it's their bug, not ours.  In fact, the bug is already there, because
>>> there is actually one other example which was being parsed properly,
>>> "**" is translated to "^".  There's no `**` function, but 2**3 works.
>> 
>> Is there any reason right-assign with "->" still exists? How much
>> code on CRAN uses it, and how trivially could it be excised? Can we
>> also have 'up assign'  and "down assign" so I can do:
>> 
>>>  3
>>> x -^
>>> x -v
>>>  4
>> 
>> - they make just as much sense.
>> 
>> Okay, lets see all the edge cases.
>> 
>> Barry
>> 
>> __
>> R-devel@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
> 
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
 
 --
 Peter Dalgaard, Professor,
 Center for Statistics, Copenhagen Business School
 Solbjerg Plads 3, 2000 Frederiksberg, Denmark
 Phone: (+45)38153501
 Email: pd@cbs.dk  Priv: pda...@gmail.com
>>> 
>>> __
>>> R-devel@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-devel

__
R-devel@r-project.org mailing list
https

Re: [Rd] should the text for RIGHT_ASSIGN be -> in getParseData()?

2013-07-05 Thread Peter Meilstrup
For these programs that use GNU readline, hit Alt-Control-J to switch into 
vi-like bindings. 

On Jul 5, 2013, at 16:42, Brian Lee Yung Rowe  wrote:

> That is a more accurate statement regarding Ctrl-K. Nonetheless whatever is 
> killed can be yanked back via Ctrl-Y, so the effect emulates cutting and 
> pasting. I am also a vi user, but these four basic emacs bindings seem to 
> perennially haunt numerous terminal apps. 
> 
> •
> Brian Lee Yung Rowe
> 917 496 4583
> 
> 
> On Jul 5, 2013, at 3:53 PM, William Dunlap  wrote:
> 
>> Ctrl-K is delete from here to end of line on Linux-comand-line and 
>> Windows-GUI R.
>> (My fingers are not nimble enough for emacs, I'll stick with vi.)
>> 
>> Bill Dunlap
>> Spotfire, TIBCO Software
>> wdunlap tibco.com
>> 
>> 
>>> -Original Message-
>>> From: Brian Lee Yung Rowe [mailto:r...@muxspace.com]
>>> Sent: Friday, July 05, 2013 12:11 PM
>>> To: William Dunlap
>>> Cc: peter dalgaard; R-devel; Barry Rowlingson
>>> Subject: Re: [Rd] should the text for RIGHT_ASSIGN be -> in getParseData()?
>>> 
>>> Here are two more standard emacs bindings that work:  Ctrl-K to cut and 
>>> Ctrl-Y to paste.
>>> 
>>> •
>>> Brian Lee Yung Rowe
>>> 917 496 4583
>>> 
>>> 
>>> On Jul 5, 2013, at 2:32 PM, William Dunlap  wrote:
>>> 
> But up-arrow, ctrl-A then "z <-" is not much less convenient, is it?
 
 I didn't know that ctrl-A would bring me to the start of the line, nor
 that ctrl-E would bring me to the end.  Thanks.
 
 Bill Dunlap
 Spotfire, TIBCO Software
 wdunlap tibco.com
 
 
> -Original Message-
> From: peter dalgaard [mailto:pda...@gmail.com]
> Sent: Friday, July 05, 2013 11:25 AM
> To: William Dunlap
> Cc: Barry Rowlingson; R-devel
> Subject: Re: [Rd] should the text for RIGHT_ASSIGN be -> in 
> getParseData()?
> 
> 
> On Jul 5, 2013, at 18:59 , William Dunlap wrote:
> 
>>> Is there any reason right-assign with "->" still exists? How much
>>> code on CRAN uses it, and how trivially could it be excised?
>> 
>> I use '->' a lot when doing interactive work.  I often first run a 
>> command
>> to see its printed output then decide that I had better save its value.
>> The up-arrow key gives me the previous command line with the cursor 
>> placed at the
>> end of the line so adding '-> z' at the end of the line is convenient.
>> (Not using the up-arrow key and doing 'z <- .Last.value' also works, but
>> I don't like its context sensitivity.)
> 
> But up-arrow, ctrl-A then "z <-" is not much less convenient, is it?
> 
> I have used in with multi-line input, occasionally, though. As in
> 
> replicate(1, {
> ysim <- rbinom(length(p), n, p)
> glm(cbind(ysim, n - ysim) ~ x, binomial)$deviance
> })
> 
> ... and then you realize that you probably don't want to look at 1 
> simulated
> deviances and add "-> simDev".
> 
>> 
>> I never use '->' when writing code in a file, so you would have to search
>> my .Rhistory files, not my *.R files, for evidence of its usefulness to 
>> me.
>> 
>> Bill Dunlap
>> Spotfire, TIBCO Software
>> wdunlap tibco.com
>> 
>> 
>>> -Original Message-
>>> From: r-devel-boun...@r-project.org 
>>> [mailto:r-devel-boun...@r-project.org] On
> Behalf
>>> Of Barry Rowlingson
>>> Sent: Friday, July 05, 2013 9:29 AM
>>> To: Duncan Murdoch
>>> Cc: R-devel
>>> Subject: Re: [Rd] should the text for RIGHT_ASSIGN be -> in 
>>> getParseData()?
>>> 
>>> On Fri, Jul 5, 2013 at 12:57 PM, Duncan Murdoch
>>>  wrote:
>>> 
 R itself doesn't make use of the text column, it's for display of code
 by highlighters etc.  So if anyone does assume text is a function name,
 it's their bug, not ours.  In fact, the bug is already there, because
 there is actually one other example which was being parsed properly,
 "**" is translated to "^".  There's no `**` function, but 2**3 works.
>>> 
>>> Is there any reason right-assign with "->" still exists? How much
>>> code on CRAN uses it, and how trivially could it be excised? Can we
>>> also have 'up assign'  and "down assign" so I can do:
>>> 
 3
 x -^
 x -v
 4
>>> 
>>> - they make just as much sense.
>>> 
>>> Okay, lets see all the edge cases.
>>> 
>>> Barry
>>> 
>>> __
>>> R-devel@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-devel
>> 
>> __
>> R-devel@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
> 
> --
> Peter Dalgaard, Professor,
> Center for Statistics, Copenhagen Business School
> Solbjerg Plads 3, 2000 Frederiksberg, Denm

Re: [Rd] R-devel Digest, Vol 125, Issue 2

2013-07-05 Thread Simon Urbanek
On Jul 4, 2013, at 3:53 AM, gianluca mastrantonio wrote:

> I'm just a beginner, so i can make some stupid error.
> I use the "-l cov.model.h -l util.h" because i need to load another two c++ 
> programs (cov.model.cpp and util.cpp)
> 

Well,then you probably meant

R CMD SHLIB   SpTempWrapC.cpp cov.model.cpp util.cpp

Cheers,
S



> Il giorno 04/lug/2013, alle ore 09:44, peter dalgaard  ha 
> scritto:
> 
>> -I
> 
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
> 
> 

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Cross-platform linking of a simple front-end

2013-07-05 Thread Simon Urbanek
Jon,

On Jul 4, 2013, at 10:52 AM, Jon Clayden wrote:

> Dear all,
> 
> I have a simple front-end program which uses the APIs described in section
> 8 of "Writing R Extensions" to deviate from the standard R behaviour in
> fairly minor ways. However, I'm having some difficulty getting it to link
> reliably across different platforms.
> 
> R CMD LINK seemed like it would help, but I've had difficulty finding many
> real-world examples online. I've tried
> 
>  R CMD LINK $(R CMD config CC) $(R CMD config --cppflags) $(R CMD config
> --ldflags) -o ../bin/exec/tractor tractor.c
> 
> and this works on one of my test platforms (OS X.8.4, R 3.0.1), but not the
> other (Ubuntu 12.04 LTS, R 2.14.1). In the latter case I get the error
> 
>  /usr/bin/ld: /tmp/ccmKf57E.o: undefined reference to symbol 'log10@
> @GLIBC_2.0'
>  /usr/bin/ld: note: 'log10@@GLIBC_2.0' is defined in DSO
> /lib/i386-linux-gnu/libm.so.6 so try adding it to the linker command line
>  /lib/i386-linux-gnu/libm.so.6: could not read symbols: Invalid operation
>  collect2: ld returned 1 exit status
> 
> I can correct this by adding "-lm" manually to the command, but I'm not
> sure how portable that will itself be.
> 

My guess would be that you did not use --enable-R-shlib when compiling R on 
Ubuntu so you don't have a shared version of the R library to link against 
(which is needed to resolve the dependencies). Could that be the case?

Cheers,
Simon


> Could anyone advise on the best way to make this work portably, please? For
> this application I'm not concerned about Windows compatibility -
> portability across Unix-alikes is sufficient. The source code is at <
> https://github.com/jonclayden/tractor/blob/master/src/tractor.c>, if that
> is useful.
> 
> All the best,
> Jon
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
> 
> 

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Cross-platform linking of a simple front-end

2013-07-05 Thread Prof Brian Ripley

On 06/07/2013 03:19, Simon Urbanek wrote:

Jon,

On Jul 4, 2013, at 10:52 AM, Jon Clayden wrote:


Dear all,

I have a simple front-end program which uses the APIs described in section
8 of "Writing R Extensions" to deviate from the standard R behaviour in
fairly minor ways. However, I'm having some difficulty getting it to link
reliably across different platforms.

R CMD LINK seemed like it would help, but I've had difficulty finding many
real-world examples online. I've tried

  R CMD LINK $(R CMD config CC) $(R CMD config --cppflags) $(R CMD config
--ldflags) -o ../bin/exec/tractor tractor.c

and this works on one of my test platforms (OS X.8.4, R 3.0.1), but not the
other (Ubuntu 12.04 LTS, R 2.14.1). In the latter case I get the error

  /usr/bin/ld: /tmp/ccmKf57E.o: undefined reference to symbol 'log10@
@GLIBC_2.0'
  /usr/bin/ld: note: 'log10@@GLIBC_2.0' is defined in DSO
/lib/i386-linux-gnu/libm.so.6 so try adding it to the linker command line
  /lib/i386-linux-gnu/libm.so.6: could not read symbols: Invalid operation
  collect2: ld returned 1 exit status

I can correct this by adding "-lm" manually to the command, but I'm not
sure how portable that will itself be.



My guess would be that you did not use --enable-R-shlib when compiling R on 
Ubuntu so you don't have a shared version of the R library to link against 
(which is needed to resolve the dependencies). Could that be the case?


I was able to reproduce this on Fedora: that is not the error if R was 
not built as a shared library.


I would simply copy how R does it (for R.bin in src/main).  libtool 
(used by R CMD LINK) is not coming up with the same flags.  On my system 
R is not using -lm:


gcc -std=gnu99 -Wl,--export-dynamic -fopenmp  -L/usr/local/lib64 -o 
R.bin Rmain.o  -L../../lib -lR -lRblas



Adding -lm is not portable (some OSes do not have a separate libm and 
some always add it when linking via $(CC)), but there is a LIBM macro in 
etc/Makeconf which tells you if configure found one.





Cheers,
Simon



Could anyone advise on the best way to make this work portably, please? For
this application I'm not concerned about Windows compatibility -
portability across Unix-alikes is sufficient. The source code is at <
https://github.com/jonclayden/tractor/blob/master/src/tractor.c>, if that
is useful.

All the best,
Jon




--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel