[Rd] cat with backspace and newline characters

2013-11-01 Thread Renaud Gaujoux
Hi,

when mixing newline and backspace characters I get the following output
(see below). In the second call, the backspace character is simply not
applied. Is this normal behaviour?
Thank you.

> cat("abc\b")
ab> cat("abc\b\n")
abc
>

[[alternative HTML version deleted]]

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


Re: [Rd] cat with backspace and newline characters

2013-11-01 Thread Renaud Gaujoux
I don't know what the normal behaviour is. I was expecting the remaining of
the line to be wiped out, but you must be right: the character 'c' is
already printed, the cursor moves back one position and go to the next
line, leaving the 'c' in place.
But what about this one:

> cat("abc\b\b\b")
> c

Here, I end up with the cursor being on the 'c', i.e. if I type something
it erase the 'c'.
It is strange that the 'c' appears _after_ the console prompt, isn't it?

Renaud




On 1 November 2013 13:41, Sean O'Riordain  wrote:

> Hi Renaud,
>
> Are you sure it's not applied? is \b a backspace i.e. just move the
> cursor back one space, or is it a delete the character to the left of
> the cursor?
>
> Kind regards,
> Sean
>
>
> On 1 November 2013 11:06, Renaud Gaujoux 
> wrote:
> > Hi,
> >
> > when mixing newline and backspace characters I get the following output
> > (see below). In the second call, the backspace character is simply not
> > applied. Is this normal behaviour?
> > Thank you.
> >
> >> cat("abc\b")
> > ab> cat("abc\b\n")
> > abc
> >>
> >
> > [[alternative HTML version deleted]]
> >
> > __
> > R-devel@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel
>
>

[[alternative HTML version deleted]]

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


Re: [Rd] Where to drop a python script?

2013-11-01 Thread Jonathan Greenberg
This was actually the little script I was going to include (prompting me to
ask the question): a test for the python version number.
Save this (between the ***s) as e.g. python_version.py:

***

import sys
print(sys.version_info)

***

I've done almost no python coding, so I was going to call this with a
system("/pathto/python /pathto/python_version.py",intern=TRUE) call and
post-process the one-line text output.

--j


On Thu, Oct 31, 2013 at 12:45 PM, Paul Gilbert wrote:

>
>
> On 13-10-31 01:16 PM, Prof Brian Ripley wrote:
>
>> On 31/10/2013 15:33, Paul Gilbert wrote:
>>
>>>
>>>
>>> On 13-10-31 03:01 AM, Prof Brian Ripley wrote:
>>>
 On 31/10/2013 00:40, Paul Gilbert wrote:

> The old convention was that it went in the exec/ directory, but as you
> can see at
> http://cran.at.r-project.org/**doc/manuals/r-devel/R-exts.**
> html#Non_002dR-scripts-in-**packages
>
>
>
>   it can be in inst/anyName/. A minor convenience of exec/ is that the
> directory has the same name in source and when installed, whereas
> inst/anyName gets moved to anyName/, so debugging can be a tiny bit
> easier with exec/.
>
> Having just put a package (TSjson) on CRAN with a python script, here
> are a few other pointers for getting it on CRAN:
>
> -SystemRequirements: should indicate if a particular version of python
> is needed, and any non-default modules that are needed. (My package
> does
> not work with Python 3 because some modules are not available.) Some of
> the libraries have changed, so it could be a bit tricky to make
> something work easily with both 2 and 3.
>
> -You need a README to explain how to install Python. (If you look at or
> use mine, please let me know if you find problems.)
>

 Better to describe exactly what you need: installation instructions go
 stale very easily.

  -The Linux and Sun CRAN test machines have Python 2 whereas winbuilder
> has Python 3. Be prepared to explain that the package will not work on
> one or the other.
>

 Not true.  Linux and Solaris (sic) have both: the Solaris machines have
 2.6 and 3.3.

>>>
>>> For an R package how does one go about specifying which should be used?
>>>
>>
>> You ask the user to tell you the path or at least the command name, e.g.
>> by an environment variable or R function argument.  Just like any other
>> external program such as GhostScript.
>>
>
> Yes, but since I don't have direct access to the CRAN test machines,
> specifically, on the CRAN test machines, how do I specify to use Python 2
> or Python 3? (That is, I think you are the user when CRAN tests are done on
> Solaris, so I am asking you.)
>
>
>
>>
>>>  Please do not spread misinformation about machines you do
 not have any access to.


> Another option to system() is pipe()
>
> Paul
>
> On 13-10-30 03:15 PM, Dirk Eddelbuettel wrote:
>
>>
>> On 30 October 2013 at 13:54, Jonathan Greenberg wrote:
>> | R-developers:
>> |
>> | I have a small python script that I'd like to include in an R
>> package I'm
>> | developing, but I'm a bit unclear about which subfolder it should go
>> in.  R
>> | will be calling the script via a system() call.  Thanks!
>>
>> Up to you as you control the path. As "Writing R Extensions" explains,
>> everything below the (source) directory inst/ will get installed.  I
>> like
>> inst/extScripts/ (or similar) as it denotes that it is an external
>> script.
>>
>> As an example, the gdata package has Perl code for xls reading/writing
>> below a
>> directory inst/perl/ -- and I think there are more packages doing
>> this.
>>
>> Dirk
>>
>>
>>
> __**
> 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
>



-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
259 Computing Applications Building, MC-150
605 East Springfield Avenue
Champaign, IL  61820-6371
Phone: 217-300-1924
http://www.geog.illinois.edu/~jgrn/
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007

[[alternative HTML version deleted]]

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


Re: [Rd] cat with backspace and newline characters

2013-11-01 Thread Rui Barradas

Hello,

Can't reproduce it, there must be something with your console. I get

> cat("abc\b")
ab> cat("abc\b\n")
ab
>


Hope this helps,

Rui Barradas

Em 01-11-2013 11:06, Renaud Gaujoux escreveu:

Hi,

when mixing newline and backspace characters I get the following output
(see below). In the second call, the backspace character is simply not
applied. Is this normal behaviour?
Thank you.


cat("abc\b")

ab> cat("abc\b\n")
abc




[[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] Where to drop a python script?

2013-11-01 Thread Brian Lee Yung Rowe
If that's all you want to do, you can ignore the headache by just calling 
system("python -V").

Then you don't need to save any python scripts.


On Nov 1, 2013, at 10:17 AM, Jonathan Greenberg  wrote:

> This was actually the little script I was going to include (prompting me to
> ask the question): a test for the python version number.
> Save this (between the ***s) as e.g. python_version.py:
> 
> ***
> 
> import sys
> print(sys.version_info)
> 
> ***
> 
> I've done almost no python coding, so I was going to call this with a
> system("/pathto/python /pathto/python_version.py",intern=TRUE) call and
> post-process the one-line text output.
> 
> --j
> 
> 
> On Thu, Oct 31, 2013 at 12:45 PM, Paul Gilbert wrote:
> 
>> 
>> 
>> On 13-10-31 01:16 PM, Prof Brian Ripley wrote:
>> 
>>> On 31/10/2013 15:33, Paul Gilbert wrote:
>>> 
 
 
 On 13-10-31 03:01 AM, Prof Brian Ripley wrote:
 
> On 31/10/2013 00:40, Paul Gilbert wrote:
> 
>> The old convention was that it went in the exec/ directory, but as you
>> can see at
>> http://cran.at.r-project.org/**doc/manuals/r-devel/R-exts.**
>> html#Non_002dR-scripts-in-**packages
>> 
>> 
>> 
>>  it can be in inst/anyName/. A minor convenience of exec/ is that the
>> directory has the same name in source and when installed, whereas
>> inst/anyName gets moved to anyName/, so debugging can be a tiny bit
>> easier with exec/.
>> 
>> Having just put a package (TSjson) on CRAN with a python script, here
>> are a few other pointers for getting it on CRAN:
>> 
>> -SystemRequirements: should indicate if a particular version of python
>> is needed, and any non-default modules that are needed. (My package
>> does
>> not work with Python 3 because some modules are not available.) Some of
>> the libraries have changed, so it could be a bit tricky to make
>> something work easily with both 2 and 3.
>> 
>> -You need a README to explain how to install Python. (If you look at or
>> use mine, please let me know if you find problems.)
>> 
> 
> Better to describe exactly what you need: installation instructions go
> stale very easily.
> 
> -The Linux and Sun CRAN test machines have Python 2 whereas winbuilder
>> has Python 3. Be prepared to explain that the package will not work on
>> one or the other.
>> 
> 
> Not true.  Linux and Solaris (sic) have both: the Solaris machines have
> 2.6 and 3.3.
> 
 
 For an R package how does one go about specifying which should be used?
 
>>> 
>>> You ask the user to tell you the path or at least the command name, e.g.
>>> by an environment variable or R function argument.  Just like any other
>>> external program such as GhostScript.
>>> 
>> 
>> Yes, but since I don't have direct access to the CRAN test machines,
>> specifically, on the CRAN test machines, how do I specify to use Python 2
>> or Python 3? (That is, I think you are the user when CRAN tests are done on
>> Solaris, so I am asking you.)
>> 
>> 
>> 
>>> 
 Please do not spread misinformation about machines you do
> not have any access to.
> 
> 
>> Another option to system() is pipe()
>> 
>> Paul
>> 
>> On 13-10-30 03:15 PM, Dirk Eddelbuettel wrote:
>> 
>>> 
>>> On 30 October 2013 at 13:54, Jonathan Greenberg wrote:
>>> | R-developers:
>>> |
>>> | I have a small python script that I'd like to include in an R
>>> package I'm
>>> | developing, but I'm a bit unclear about which subfolder it should go
>>> in.  R
>>> | will be calling the script via a system() call.  Thanks!
>>> 
>>> Up to you as you control the path. As "Writing R Extensions" explains,
>>> everything below the (source) directory inst/ will get installed.  I
>>> like
>>> inst/extScripts/ (or similar) as it denotes that it is an external
>>> script.
>>> 
>>> As an example, the gdata package has Perl code for xls reading/writing
>>> below a
>>> directory inst/perl/ -- and I think there are more packages doing
>>> this.
>>> 
>>> Dirk
>>> 
>>> 
>>> 
>> __**
>> 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
>> 
> 
> 
> 
> -- 
> Jonathan A. Greenberg, PhD
> Assistant Professor
> Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
> Department of Geography and Geographic Information Science
> University of Illinois at Urbana-Champaign
> 259 Computing Applicati

Re: [Rd] Where to drop a python script?

2013-11-01 Thread Paul Gilbert

Jonathan

Below is a python script I have been playing with for extracing some 
system information and additional information about modules that I need 
to import in my TSjson package. My intention is to put R code in tests/ 
that will check this before going on to do other tests, but I have not 
yet done that. The reason for this is that error message are not 
especially enlightening when other tests fail because python is not 
working as needed.


Please let me know if you find improvements.

Paul
__

def test():

try:
import sys
have_sys = True
except:
have_sys = False

if sys.version_info >= (3, 0): return dict( error=
"TSjson requires Python 2. Running "+ str(sys.version_info))
# mechanize is not (yet) available for Python 3,
# Also, urllib2 is split into urllib.request, urllib.error in Python 3


try:
import urllib2
have_urllib2 = True
except:
have_urllib2 = False

try:
import re
have_re = True
except:
have_re = False

try:
import csv
have_csv = True
except:
have_csv = False

try:
import mechanize
have_mechanize = True
except:
have_mechanize = False

if (have_sys & have_urllib2 & have_re & have_csv & have_mechanize):
err = 0
else:
err = 1

return dict(
 exit=err,
 have_sys=have_sys, have_urllib2=have_urllib2,
 have_re = have_re, have_csv = have_csv,
 have_mechanize = have_mechanize)


try:
import json
print(json.JSONEncoder().encode(test()))
except:
print(dict(exit=1, have_json = False))



On 13-11-01 10:17 AM, Jonathan Greenberg wrote:

This was actually the little script I was going to include (prompting me
to ask the question): a test for the python version number.
Save this (between the ***s) as e.g. python_version.py:

***

import sys
print(sys.version_info)

***

I've done almost no python coding, so I was going to call this with a
system("/pathto/python /pathto/python_version.py",intern=TRUE) call and
post-process the one-line text output.

--j


On Thu, Oct 31, 2013 at 12:45 PM, Paul Gilbert mailto:pgilbert...@gmail.com>> wrote:



On 13-10-31 01 :16 PM, Prof Brian Ripley wrote:

On 31/10/2013 15:33, Paul Gilbert wrote:



On 13-10-31 03 :01 AM, Prof Brian Ripley
wrote:

On 31/10/2013 00:40, Paul Gilbert wrote:

The old convention was that it went in the exec/
directory, but as you
can see at

http://cran.at.r-project.org/__doc/manuals/r-devel/R-exts.__html#Non_002dR-scripts-in-__packages





   it can be in inst/anyName/. A minor convenience
of exec/ is that the
directory has the same name in source and when
installed, whereas
inst/anyName gets moved to anyName/, so debugging
can be a tiny bit
easier with exec/.

Having just put a package (TSjson) on CRAN with a
python script, here
are a few other pointers for getting it on CRAN:

-SystemRequirements: should indicate if a particular
version of python
is needed, and any non-default modules that are
needed. (My package
does
not work with Python 3 because some modules are not
available.) Some of
the libraries have changed, so it could be a bit
tricky to make
something work easily with both 2 and 3.

-You need a README to explain how to install Python.
(If you look at or
use mine, please let me know if you find problems.)


Better to describe exactly what you need: installation
instructions go
stale very easily.

-The Linux and Sun CRAN test machines have Python 2
whereas winbuilder
has Python 3. Be prepared to explain that the
package will not work on
one or the other.


Not true.  Linux and Solaris (sic) have both: the
Solaris machines have
2.6 and 3.3.


For an R package how does one go about specifying which
should be used?


You ask the user to tell you the path or at least the command
name, e.g.
by an environment variable or R function argument.  Just like
any other
external program such as GhostScript.


Yes, but since