Re: [R] Vary an equation using values from a sequence

2018-03-14 Thread Jake William Andrae
Thank you, I�ll give it a try.
Jake

Get Outlook for iOS

From: Bert Gunter 
Sent: Thursday, March 15, 2018 3:23:18 PM
To: Jake William Andrae
Cc: R-help
Subject: Re: [R] Vary an equation using values from a sequence

I thnk what you want is ?outer. e.g.:

outer(Data -min(Data),value,FUN = "+")

Whether this works for your real task, however, may depend on details and 
complexities that you have omitted.

Cheers,
Bert



Bert Gunter

"The trouble with having an open mind is that people keep coming along and 
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Wed, Mar 14, 2018 at 9:14 PM, Jake William Andrae 
> wrote:
Hi All,

I have a vector of data on which I am operating. The equation with which I want 
to operate on the vector has a value k. I want to run the equation and output a 
new vector, each time replacing k with each value from the sequence I defined. 
I have thought about using for loops and such, but this seems like overkill. I 
am wondering if there is a simple solution that would allow me to accomplish 
this.


The code I am using is outlined below.


Data <- c(1:10) #Data
value <- seq(from = 0, to = 100 , by = 0.01) #Sequence
Data - min(Data) + k # Equation

Thanks,
Jake


Jake Andrae
PhD Candidate
Geology & Geophysics � Sprigg Geobiology Centre
Department of Earth Science
School of Physical Sciences
The University of Adelaide, AUSTRALIA 5005
Phone: 0407701565
Email: jake.and...@adelaide.edu.au


[[alternative HTML version deleted]]


__
R-help@r-project.org mailing list -- To 
UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Vary an equation using values from a sequence

2018-03-14 Thread Bert Gunter
I thnk what you want is ?outer. e.g.:

outer(Data -min(Data),value,FUN = "+")

Whether this works for your real task, however, may depend on details and
complexities that you have omitted.

Cheers,
Bert



Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Wed, Mar 14, 2018 at 9:14 PM, Jake William Andrae <
jake.and...@adelaide.edu.au> wrote:

> Hi All,
>
> I have a vector of data on which I am operating. The equation with which I
> want to operate on the vector has a value k. I want to run the equation and
> output a new vector, each time replacing k with each value from the
> sequence I defined. I have thought about using for loops and such, but this
> seems like overkill. I am wondering if there is a simple solution that
> would allow me to accomplish this.
>
>
> The code I am using is outlined below.
>
>
> Data <- c(1:10) #Data
> value <- seq(from = 0, to = 100 , by = 0.01) #Sequence
> Data - min(Data) + k # Equation
>
> Thanks,
> Jake
>
>
> Jake Andrae
> PhD Candidate
> Geology & Geophysics – Sprigg Geobiology Centre
> Department of Earth Science
> School of Physical Sciences
> The University of Adelaide, AUSTRALIA 5005
> Phone: 0407701565
> Email: jake.and...@adelaide.edu.au
>
>
> [[alternative HTML version deleted]]
>
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Vary an equation using values from a sequence

2018-03-14 Thread Jake William Andrae
Hi All,

I have a vector of data on which I am operating. The equation with which I want 
to operate on the vector has a value k. I want to run the equation and output a 
new vector, each time replacing k with each value from the sequence I defined. 
I have thought about using for loops and such, but this seems like overkill. I 
am wondering if there is a simple solution that would allow me to accomplish 
this.


The code I am using is outlined below.


Data <- c(1:10) #Data
value <- seq(from = 0, to = 100 , by = 0.01) #Sequence
Data - min(Data) + k # Equation

Thanks,
Jake


Jake Andrae
PhD Candidate
Geology & Geophysics � Sprigg Geobiology Centre
Department of Earth Science
School of Physical Sciences
The University of Adelaide, AUSTRALIA 5005
Phone: 0407701565
Email: jake.and...@adelaide.edu.au


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Fwd: Learning advanced R

2018-03-14 Thread Albrecht Kauffmann
I've found the solution to compile the adv-r-book from source: After doing some 
settings (see: 
https://travis-ci.org/hadley/adv-r/jobs/353347080/config ) 
and installation of netlify-cli, the command-line is:
Rscript -e 'bookdown::render_book("index.Rmd","bookdown::pdf_book")'

This works fine. Thank you for all hints!

Best, Albrecht

-- 
  Albrecht Kauffmann
  alkau...@fastmail.fm

Am Mi, 14. Mär 2018, um 19:24, schrieb Albrecht Kauffmann:
> I've found two problems in interpreting adv-r-master/book/build-book.r:
> 
> 1. All pathes in build-book.r refer to the starting-directory "adv-r-
> master". However, the script build-book.r is located in the directory 
> "book", which is located in directory "adv-r-master". Therefore, pathes 
> starting at "." are wrong (should start at "..").
> 
> 2. Some file names have endings "Rmd", but e.g. in the line "chapters <- 
> dir(".", pattern = "\\.rmd$")"  these endings are named "rmd". 
> Therefore, the files (e.g. "base-types.Rmd") cannot be found.
> 
> Pandoc I have installed. Maybe there will arise further problems, but 
> still I am experimenting with pathes.
> 
> Best,
> Albrecht
> 
> -- 
>   Albrecht Kauffmann
>   alkau...@fastmail.fm
> 
> Am Mi, 14. Mär 2018, um 18:56, schrieb Rich Shepard:
> > On Wed, 14 Mar 2018, Jeff Newmiller wrote:
> > 
> > > Nothing you have said tells me you have LaTeX working (a binary install of
> > > R does not depend on it), but if you actually know it is installed and
> > > available to R then that isn't the problem. Since you have not said what
> > > you actually did or what errors you encountered I can only shrug and
> > > suggest that that the website is a complete rendering of the book and the
> > > for-sale version makes a worthwhile contribution to the author and the
> > > community.
> > 
> > Jeff,
> > 
> >Downloading the site as a .zip file and reading the README.md tells us
> > that pandoc is required. This is a format converter, apparently based on
> > Haskell given the large number of dependencies to build it. But, pandoc will
> > convert from markdown to LaTeX. I don't know the exact procedure as I've not
> > yet taken the time to install all dependencies to pandoc and build it. The
> > pandoc website has documentation.
> > 
> > Regards,
> > 
> > Rich
> > 
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Revolutions blog: February 2018 roundup

2018-03-14 Thread David Smith (CDA) via R-help
Since 2008, Microsoft staff and guests have written about R at the Revolutions
blog (http://blog.revolutionanalytics.com) and every month I post a summary of
articles from the previous month of particular interest to readers of r-help.

In case you missed them, here are some articles related to R from the
month of February:

The R Consortium opens a new round of grant applications for R-related user
groups and projects
http://blog.revolutionanalytics.com/2018/02/r-consortium-sponsorships.html and
has granted US$0.5M for projects to date
http://blog.revolutionanalytics.com/2018/02/r-consortium-milestone.html

Microsoft R Client 3.4.3 and Microsoft ML Server 9.3, both built with R 3.4.3,
have been released: http://blog.revolutionanalytics.com/2018/02/mrclient343.html

An 8-step, 5-minute tutorial for setting up a cluster in Azure for use with
the sparklyr package: 
http://blog.revolutionanalytics.com/2018/02/aztk-sparklyr.html

A smartphone app uses R and the keras package to identify "spells" using
accelerometer data
http://blog.revolutionanalytics.com/2018/02/accelerometers.html

"Machine Learning with R and Tensorflow", JJ Allaire's keynote presentation at
RStudio::conf http://blog.revolutionanalytics.com/2018/02/r-with-tensorflow.html

A guide to styling base graphics in R:
http://blog.revolutionanalytics.com/2018/02/pretty-base-graphics.html

A list of applications, open source projects, and extensions from Microsoft
related to R:
http://blog.revolutionanalytics.com/2018/02/what-does-microsoft-do-with-r.html

Several upcoming R conferences offer diversity scholarships:
http://blog.revolutionanalytics.com/2018/02/diversity-scholarships.html

Introducing the DataExplorer package, for quick data summaries and
visualizations: http://blog.revolutionanalytics.com/2018/02/dataexplorer.html

A video overview of the Data Science Virtual Machine, featuring R:
http://blog.revolutionanalytics.com/2018/02/dsvm-on-ai-show.html

"Asking the right questions about AI", an essay about the ethical implications
of predictions
http://blog.revolutionanalytics.com/2018/02/how-ai-works-and-fails.html

And some general interest stories (not necessarily related to R):

*  A sci-fi short about faster-than-light travel:
   
http://blog.revolutionanalytics.com/2018/02/because-its-friday-faster-than-light.html

* A robot holds a door open so another robot can pass:
  
http://blog.revolutionanalytics.com/2018/02/because-its-friday-hold-the-door.html

* SpaceX launches a car into space:
  
http://blog.revolutionanalytics.com/2018/02/because-its-friday-bon-voyage-starman.html

* A bizarre CGI short film, Time for Sushi:
  
http://blog.revolutionanalytics.com/2018/02/because-its-friday-time-for-sushi.html

As always, thanks for the comments and please keep sending suggestions to
me at david...@microsoft.com or via Twitter (I'm @revodavid).

Cheers,
# David

-- 
David M Smith 
Developer Advocate, Microsoft Cloud & Enterprise 
Tel: +1 (312) 9205766 (Chicago IL, USA)
Twitter: @revodavid | Blog:  http://blog.revolutionanalytics.com

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Problem with reading data from an UTF-16 database

2018-03-14 Thread Duncan Murdoch

On 14/03/2018 7:15 AM, Thierry Onkelinx wrote:

Dear all,

We have a problem with reading some characters correctly from an UTF-16
encoded database. The code below givens the correct characters on Ubuntu
with the_driver = {ODBC Driver 13 for SQL Server}. On Windows (with
the_driver = {SQL Server}), special characters like '♂' and '♀' are
returned as '?'. I've added the sessionInfo() output from both machines.

Any suggestions on how to fix the problem?


I haven't tried it, but the RODBC package includes an argument 
DBMSencoding in the odbcDriverConnect function.  So maybe you could use 
that instead of DBI and odbc.


Duncan Murdoch


Best regards,

Thierry

library(DBI)
con <- dbConnect(odbc::odbc(), .connection_string =
"Driver=the_drive;Server=our_server;Database=the_database;Trusted_Connection=Yes;")
dbGetQuery(con, sql_statement)


R version 3.4.2 (2017-09-28)
Platform: i386-w64-mingw32/i386 (32-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

Matrix products: default

locale:
[1] LC_COLLATE=Dutch_Belgium.1252  LC_CTYPE=Dutch_Belgium.1252
LC_MONETARY=Dutch_Belgium.1252 LC_NUMERIC=C
[5] LC_TIME=Dutch_Belgium.1252

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

other attached packages:
[1] RODBC_1.3-15 DBI_0.8

loaded via a namespace (and not attached):
  [1] Rcpp_0.12.14R6_2.2.2odbc_1.1.5  magrittr_1.5
pillar_1.1.0rlang_0.2.0 testthat_2.0.0
  [8] blob_1.1.0  drat_0.1.3  fortunes_1.5-4  tools_3.4.2
  bit64_0.9-7 bit_1.1-12  hms_0.4.0
[15] yaml_2.1.14 compiler_3.4.2  pkgconfig_2.0.1 tibble_1.4.2


R version 3.4.3 (2017-11-30)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.4 LTS

Matrix products: default
BLAS: /usr/lib/libblas/libblas.so.3.6.0
LAPACK: /usr/lib/lapack/liblapack.so.3.6.0

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

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

other attached packages:
[1] DBI_0.7

loaded via a namespace (and not attached):
  [1] drat_0.1.3 bit_1.1-12 odbc_1.1.2 compiler_3.4.3 hms_0.3
 tools_3.4.3pillar_1.2.1   tibble_1.4.2
  [9] yaml_2.1.17Rcpp_0.12.14   bit64_0.9-7blob_1.1.0
  rlang_0.2.0fortunes_1.5-4



ir. Thierry Onkelinx
Statisticus / Statistician

Vlaamse Overheid / Government of Flanders
INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE AND
FOREST
Team Biometrie & Kwaliteitszorg / Team Biometrics & Quality Assurance
thierry.onkel...@inbo.be
Havenlaan 88 bus 73, 1000 Brussel
www.inbo.be

///
To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to say
what the experiment died of. ~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data. ~ Roger Brinner
The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey
///



[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Problem with reading data from an UTF-16 database

2018-03-14 Thread Thierry Onkelinx
Dear all,

We have a problem with reading some characters correctly from an UTF-16
encoded database. The code below givens the correct characters on Ubuntu
with the_driver = {ODBC Driver 13 for SQL Server}. On Windows (with
the_driver = {SQL Server}), special characters like '♂' and '♀' are
returned as '?'. I've added the sessionInfo() output from both machines.

Any suggestions on how to fix the problem?

Best regards,

Thierry

library(DBI)
con <- dbConnect(odbc::odbc(), .connection_string =
"Driver=the_drive;Server=our_server;Database=the_database;Trusted_Connection=Yes;")
dbGetQuery(con, sql_statement)


R version 3.4.2 (2017-09-28)
Platform: i386-w64-mingw32/i386 (32-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

Matrix products: default

locale:
[1] LC_COLLATE=Dutch_Belgium.1252  LC_CTYPE=Dutch_Belgium.1252
LC_MONETARY=Dutch_Belgium.1252 LC_NUMERIC=C
[5] LC_TIME=Dutch_Belgium.1252

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

other attached packages:
[1] RODBC_1.3-15 DBI_0.8

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.14R6_2.2.2odbc_1.1.5  magrittr_1.5
pillar_1.1.0rlang_0.2.0 testthat_2.0.0
 [8] blob_1.1.0  drat_0.1.3  fortunes_1.5-4  tools_3.4.2
 bit64_0.9-7 bit_1.1-12  hms_0.4.0
[15] yaml_2.1.14 compiler_3.4.2  pkgconfig_2.0.1 tibble_1.4.2


R version 3.4.3 (2017-11-30)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.4 LTS

Matrix products: default
BLAS: /usr/lib/libblas/libblas.so.3.6.0
LAPACK: /usr/lib/lapack/liblapack.so.3.6.0

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

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

other attached packages:
[1] DBI_0.7

loaded via a namespace (and not attached):
 [1] drat_0.1.3 bit_1.1-12 odbc_1.1.2 compiler_3.4.3 hms_0.3
tools_3.4.3pillar_1.2.1   tibble_1.4.2
 [9] yaml_2.1.17Rcpp_0.12.14   bit64_0.9-7blob_1.1.0
 rlang_0.2.0fortunes_1.5-4



ir. Thierry Onkelinx
Statisticus / Statistician

Vlaamse Overheid / Government of Flanders
INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE AND
FOREST
Team Biometrie & Kwaliteitszorg / Team Biometrics & Quality Assurance
thierry.onkel...@inbo.be
Havenlaan 88 bus 73, 1000 Brussel
www.inbo.be

///
To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to say
what the experiment died of. ~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data. ~ Roger Brinner
The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey
///



[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Fwd: Learning advanced R

2018-03-14 Thread Albrecht Kauffmann
I've found two problems in interpreting adv-r-master/book/build-book.r:

1. All pathes in build-book.r refer to the starting-directory "adv-r-master". 
However, the script build-book.r is located in the directory "book", which is 
located in directory "adv-r-master". Therefore, pathes starting at "." are 
wrong (should start at "..").

2. Some file names have endings "Rmd", but e.g. in the line "chapters <- 
dir(".", pattern = "\\.rmd$")"  these endings are named "rmd". Therefore, the 
files (e.g. "base-types.Rmd") cannot be found.

Pandoc I have installed. Maybe there will arise further problems, but still I 
am experimenting with pathes.

Best,
Albrecht

-- 
  Albrecht Kauffmann
  alkau...@fastmail.fm

Am Mi, 14. Mär 2018, um 18:56, schrieb Rich Shepard:
> On Wed, 14 Mar 2018, Jeff Newmiller wrote:
> 
> > Nothing you have said tells me you have LaTeX working (a binary install of
> > R does not depend on it), but if you actually know it is installed and
> > available to R then that isn't the problem. Since you have not said what
> > you actually did or what errors you encountered I can only shrug and
> > suggest that that the website is a complete rendering of the book and the
> > for-sale version makes a worthwhile contribution to the author and the
> > community.
> 
> Jeff,
> 
>Downloading the site as a .zip file and reading the README.md tells us
> that pandoc is required. This is a format converter, apparently based on
> Haskell given the large number of dependencies to build it. But, pandoc will
> convert from markdown to LaTeX. I don't know the exact procedure as I've not
> yet taken the time to install all dependencies to pandoc and build it. The
> pandoc website has documentation.
> 
> Regards,
> 
> Rich
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Fwd: Learning advanced R

2018-03-14 Thread Rich Shepard

On Wed, 14 Mar 2018, Jeff Newmiller wrote:


Nothing you have said tells me you have LaTeX working (a binary install of
R does not depend on it), but if you actually know it is installed and
available to R then that isn't the problem. Since you have not said what
you actually did or what errors you encountered I can only shrug and
suggest that that the website is a complete rendering of the book and the
for-sale version makes a worthwhile contribution to the author and the
community.


Jeff,

  Downloading the site as a .zip file and reading the README.md tells us
that pandoc is required. This is a format converter, apparently based on
Haskell given the large number of dependencies to build it. But, pandoc will
convert from markdown to LaTeX. I don't know the exact procedure as I've not
yet taken the time to install all dependencies to pandoc and build it. The
pandoc website has documentation.

Regards,

Rich

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Learning advanced R

2018-03-14 Thread Spencer Graves



On 2018-03-14 11:52, Rich Shepard wrote:

On Wed, 14 Mar 2018, Duncan Murdoch wrote:

I'm all for learning more languages and using the one that's best for 
each
job, but for people who don't know Python, it would be helpful to 
list the

aspects in which it excels. When should an R user choose to write
something in Python instead?


Duncan,

  "Best" is subjective, but my view is the language most comfortable and
familiar to the developer/analyst should be the one used.

  In my environmental consulting business I use both R and Python. While
Python has support for many statistical models I'm more comfortable 
with the
ones available in R. For spatial analyses (separate from spatial 
statistics)
I've used GRASS for > 20 years and it heavily uses Python. I also use 
Python
(along with emacs, awk, sed, and grep) for cleaning and organizing 
data. For

writing, I use LaTeX (a markup language) and the LyX GUI front end.

  Python has a lot of support for scientific and financial analyses, 
as does

R. Considering there are a gazillion programming languages available (and
used for essential applications, such as GnuCash (written in guile, a 
scheme

variant) which I use for business and personal bookkeeping, picking the
"best" one is strictly a personal matter. I prefer emacs, my system and
network admin friends prefer vi. In linux, at least, there are so many
options for doing a task that sometimes it's difficult to decide which to
use in a given situation.

  If the languages you know do all you need then learn a new one only if
it's to scratch an itch. :-)



  My software development productivity increased by a factor of 
maybe 30 by using first S-Plus then R, including writing R packages, 
then RStudio and writing Rmarkdown vignettes.



        1.  I started writing Fortran in 1963.  I've written 
assembly language for multiple machines, Cobol, Lisp, and other 
language.  I started using S-Plus in the early 1990s and abandoned it 
for R when I needed "debug" for some S-Plus code.  Developing R packages 
improved my software development productivity by a factor of 10, because 
the discipline of creating unit tests in "\examples" made it so much 
easier to debug and maintain -- AND share with others.



        2.  I've also written some Python, though not much.  I used 
Emacs until I found RStudio.  Vi and Emacs are not tools you can give to 
someone, who is only marginally computer literate and expect them to be 
productive in a reasonable period of time.  By contrast, if someone 
knows enough to be able to install R and RStudio, I can give them some R 
code and be confident that they will get something useful from the 
experience in a relatively short period of time.  You can't do that with 
vi and Emacs unless they already know those applications.



        3.  Recently, I've started writing RMarkdown vignettes, and 
that further increased my productivity.



          3.1.  Two years ago, I told I client I was going to 
prepare and Rmarkdown vignette to document what I did with their data.  
My sales guy said absolutely, we were NOT going to give the client an 
Rmarkdown vignette.  I spent a week analyzing the data and 6 months 
answering questions from the team mostly by pointing them to certain 
lines in the vignette, occasionally by extending it.  In the middle of 
that, we learned that the client required our analysis to be 
verifiable.  After that, the vignette became a primary deliverable.



          3.2.  More recently, another client asked me to 
explain principal components.  This client was moderately facile with 
software but not with R nor vector spaces.  I gave him an Rmarkdown 
vignette that included a principal components on some data he gave me 
done both with a single command and step by step supplemented with a 
simple discussion of a one-dimensional subspace of two-dimensional 
space.  He was happy.



        4.  I invite all to review and improve the discussion in 
the Wikipedia article on "Software repository".  This a table with a 
discussion of "Selected repositories", much of which I wrote 8 years 
ago.  It's heavily biased toward CRAN, because that's what I know the 
best, and I've so far been unable to find anyone with the expertise and 
interest in improving it.  This article averaged 290 views per day over 
the past 90 days, over 26,000 in the past 3 months.  If you can improve 
that article, an audience that size might be worth talking to.



   Spencer Graves



Best regards,

Rich

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html

and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see

Re: [R] Fwd: Learning advanced R

2018-03-14 Thread Jeff Newmiller
Nothing you have said tells me you have LaTeX working (a binary install of R 
does not depend on it), but if you actually know it is installed and available 
to R then that isn't the problem. Since you have not said what you actually did 
or what errors you encountered I can only shrug and suggest that that the 
website is a complete rendering of the book and the for-sale version makes a 
worthwhile contribution to the author and the community.
-- 
Sent from my phone. Please excuse my brevity.

On March 14, 2018 9:58:38 AM PDT, Albrecht Kauffmann  
wrote:
>Dear Jeff, 
>
>Latex is also required for the R-manuals in the base R installation,
>and for this it works fine on my PC.
>
>Best, 
>Albrecht

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Fwd: Learning advanced R

2018-03-14 Thread Albrecht Kauffmann
Dear Jeff, 

Latex is also required for the R-manuals in the base R installation, and for 
this it works fine on my PC.

Best, 
Albrecht

-- 
  Albrecht Kauffmann
  alkau...@fastmail.fm

Am Mi, 14. Mär 2018, um 17:50, schrieb Jeff Newmiller:
> I recommend reading it directly via the website, or buying the book. 
> 
> If you are trying to build a PDF, then the "obvious" question is whether 
> you have LaTeX installed, which is an operating-system-dependent 
> procedure handled outside of R.
> -- 
> Sent from my phone. Please excuse my brevity.
> 
> On March 14, 2018 9:39:53 AM PDT, Eric Berger  wrote:
> >Hi Albrecht,
> >I am forwarding your reply to the full group.
> >
> >It's been a while since I did this and I don't remember the details.
> >Maybe
> >someone else can comment. (I am a bit busy at the moment.)
> >If no one supplies the information in a few days I will try to take a
> >look.
> >
> >In the meantime you can start your reading on-line. :-)
> >
> >Regards,
> >Eric
> >
> >
> >Dear Eric,
> >
> >I downloaded the material from   https://github.com/hadley/adv-r as a
> >zip
> >file and decompressed it.  But, how to build the book from this? The
> >directory book contains a R-script buildbook.R. I downloaded all
> >packages
> >that are required, but the script does not run. Is there an additional
> >script required?
> >
> >Best,
> >Albrecht
> >
> >--
> >  Albrecht Kauffmann
> >  alkau...@fastmail.fm
> >
> >Am Mi, 14. Mär 2018, um 09:13, schrieb Eric Berger:
> >> Bert's suggestion is good as a pointer to a variety of resources.
> >> Sticking to the book format there are two of Hadley Wickham's books,
> >which
> >> have the advantage that they are freely available.
> >> You can either read them online or download the source from github
> >and
> >> create your own copy (which you can then print, if desired.)
> >> 1. "R for Data Science"
> >>  online: http://r4ds.had.co.nz/
> >>  github: https://github.com/hadley/r4ds
> >> 2. "Advanced R"
> >>  online: https://adv-r.hadley.nz/
> >>  github: https://github.com/hadley/adv-r
> >>
> >> Best,
> >> Eric
> >>
> >>
> >>
> >> On Wed, Mar 14, 2018 at 12:13 AM, Rich Shepard
> >
> >> wrote:
> >>
> >> > On Tue, 13 Mar 2018, Mark Leeds wrote:
> >> >
> >> > See Hadley's advanced R
> >> >>
> >> >
> >> >   +1 A very well writte, highly useful book. Recommended.
> >> >
> >> > Rich
> >> >
> >> >
> >> > __
> >> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >> > https://stat.ethz.ch/mailman/listinfo/r-help
> >> > PLEASE do read the posting guide http://www.R-project.org/posti
> >> > ng-guide.html
> >> > and provide commented, minimal, self-contained, reproducible code.
> >> >
> >>
> >>   [[alternative HTML version deleted]]
> >>
> >> __
> >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >> https://stat.ethz.ch/mailman/listinfo/r-help
> >> PLEASE do read the posting guide http://www.R-project.org/
> >posting-guide.html
> >> and provide commented, minimal, self-contained, reproducible code.
> >
> > [[alternative HTML version deleted]]
> >
> >__
> >R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >https://stat.ethz.ch/mailman/listinfo/r-help
> >PLEASE do read the posting guide
> >http://www.R-project.org/posting-guide.html
> >and provide commented, minimal, self-contained, reproducible code.
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Learning advanced R

2018-03-14 Thread Rich Shepard

On Wed, 14 Mar 2018, Duncan Murdoch wrote:


I'm all for learning more languages and using the one that's best for each
job, but for people who don't know Python, it would be helpful to list the
aspects in which it excels. When should an R user choose to write
something in Python instead?


Duncan,

  "Best" is subjective, but my view is the language most comfortable and
familiar to the developer/analyst should be the one used.

  In my environmental consulting business I use both R and Python. While
Python has support for many statistical models I'm more comfortable with the
ones available in R. For spatial analyses (separate from spatial statistics)
I've used GRASS for > 20 years and it heavily uses Python. I also use Python
(along with emacs, awk, sed, and grep) for cleaning and organizing data. For
writing, I use LaTeX (a markup language) and the LyX GUI front end.

  Python has a lot of support for scientific and financial analyses, as does
R. Considering there are a gazillion programming languages available (and
used for essential applications, such as GnuCash (written in guile, a scheme
variant) which I use for business and personal bookkeeping, picking the
"best" one is strictly a personal matter. I prefer emacs, my system and
network admin friends prefer vi. In linux, at least, there are so many
options for doing a task that sometimes it's difficult to decide which to
use in a given situation.

  If the languages you know do all you need then learn a new one only if
it's to scratch an itch. :-)

Best regards,

Rich

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Fwd: Learning advanced R

2018-03-14 Thread Jeff Newmiller
I recommend reading it directly via the website, or buying the book. 

If you are trying to build a PDF, then the "obvious" question is whether you 
have LaTeX installed, which is an operating-system-dependent procedure handled 
outside of R.
-- 
Sent from my phone. Please excuse my brevity.

On March 14, 2018 9:39:53 AM PDT, Eric Berger  wrote:
>Hi Albrecht,
>I am forwarding your reply to the full group.
>
>It's been a while since I did this and I don't remember the details.
>Maybe
>someone else can comment. (I am a bit busy at the moment.)
>If no one supplies the information in a few days I will try to take a
>look.
>
>In the meantime you can start your reading on-line. :-)
>
>Regards,
>Eric
>
>
>Dear Eric,
>
>I downloaded the material from   https://github.com/hadley/adv-r as a
>zip
>file and decompressed it.  But, how to build the book from this? The
>directory book contains a R-script buildbook.R. I downloaded all
>packages
>that are required, but the script does not run. Is there an additional
>script required?
>
>Best,
>Albrecht
>
>--
>  Albrecht Kauffmann
>  alkau...@fastmail.fm
>
>Am Mi, 14. Mär 2018, um 09:13, schrieb Eric Berger:
>> Bert's suggestion is good as a pointer to a variety of resources.
>> Sticking to the book format there are two of Hadley Wickham's books,
>which
>> have the advantage that they are freely available.
>> You can either read them online or download the source from github
>and
>> create your own copy (which you can then print, if desired.)
>> 1. "R for Data Science"
>>  online: http://r4ds.had.co.nz/
>>  github: https://github.com/hadley/r4ds
>> 2. "Advanced R"
>>  online: https://adv-r.hadley.nz/
>>  github: https://github.com/hadley/adv-r
>>
>> Best,
>> Eric
>>
>>
>>
>> On Wed, Mar 14, 2018 at 12:13 AM, Rich Shepard
>
>> wrote:
>>
>> > On Tue, 13 Mar 2018, Mark Leeds wrote:
>> >
>> > See Hadley's advanced R
>> >>
>> >
>> >   +1 A very well writte, highly useful book. Recommended.
>> >
>> > Rich
>> >
>> >
>> > __
>> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> > https://stat.ethz.ch/mailman/listinfo/r-help
>> > PLEASE do read the posting guide http://www.R-project.org/posti
>> > ng-guide.html
>> > and provide commented, minimal, self-contained, reproducible code.
>> >
>>
>>   [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/
>posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
>   [[alternative HTML version deleted]]
>
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Fwd: Learning advanced R

2018-03-14 Thread Eric Berger
Hi Albrecht,
I am forwarding your reply to the full group.

It's been a while since I did this and I don't remember the details. Maybe
someone else can comment. (I am a bit busy at the moment.)
If no one supplies the information in a few days I will try to take a look.

In the meantime you can start your reading on-line. :-)

Regards,
Eric


Dear Eric,

I downloaded the material from   https://github.com/hadley/adv-r as a zip
file and decompressed it.  But, how to build the book from this? The
directory book contains a R-script buildbook.R. I downloaded all packages
that are required, but the script does not run. Is there an additional
script required?

Best,
Albrecht

--
  Albrecht Kauffmann
  alkau...@fastmail.fm

Am Mi, 14. Mär 2018, um 09:13, schrieb Eric Berger:
> Bert's suggestion is good as a pointer to a variety of resources.
> Sticking to the book format there are two of Hadley Wickham's books, which
> have the advantage that they are freely available.
> You can either read them online or download the source from github and
> create your own copy (which you can then print, if desired.)
> 1. "R for Data Science"
>  online: http://r4ds.had.co.nz/
>  github: https://github.com/hadley/r4ds
> 2. "Advanced R"
>  online: https://adv-r.hadley.nz/
>  github: https://github.com/hadley/adv-r
>
> Best,
> Eric
>
>
>
> On Wed, Mar 14, 2018 at 12:13 AM, Rich Shepard 
> wrote:
>
> > On Tue, 13 Mar 2018, Mark Leeds wrote:
> >
> > See Hadley's advanced R
> >>
> >
> >   +1 A very well writte, highly useful book. Recommended.
> >
> > Rich
> >
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posti
> > ng-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
>
>   [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/
posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Fwd: the same function returning different values when called differently..

2018-03-14 Thread Martin Maechler
> Eric Berger 
> on Wed, 14 Mar 2018 18:27:38 +0200 writes:

> Hi Akshay, (Please include r-help when replying)

> You have learned that PFC.NS and snl[[159]] are not
> identical. Now you have to figure out why they
> differ. This could also point to a bug or a logic error in
> your program.  Figuring out how two objects differ can be
> a bit tricky, but with experience it becomes easier. (Some
> others may even have some suggestions for good ways to do
> it.)  Basically you would work your way down. At the top
> level is the class of each, which you already tested and
> they are identical.

> Now try:

>> str(PFC.NS)

> and compare it to

>> str(snl[[159]]

Note further the

 all.equal(obj1, obj2)

maybe a good start to find differences between R objects 'obj1' and 'obj2',
as all.equal() is generic and has a list method
(which works recursively) the "output may be huge, but then if there
is huge number of differences you would have found yourself
anyway, and will not need all.equal()

Martin Maechler
ETH Zurich and R Core


> Look closely at the two outputs to try to detect
> differences. If they are the same then you will have to
> examine the sub-objects described by str().  You didn't
> mention what type of objects they are. Suppose they are
> both "numeric" vectors. Then you can check whether their
> lengths are equal.  And you can compare their values,
> etc. etc. No short cut that I can think of without more
> information.

> It definitely takes work to find discrepancies. Think of
> it as a challenge and perhaps write functions that you can
> use to automate this kind of comparison in the future.
> (Again, other people on this list might be able to point
> to tools that help with this for objects of specific
> type.)

> Good luck, Eric




> dear Eric,

>Bulls eye...! identical(PFC.NS,
> snl[[159]])) is resulting false..but class(PFC.NS) and
> class(snl[[159]]) are same...

> I want snl[[159]] to be equal to PFC.NS...how do I effect
> it? create a list with some other element list... for
> example snl[[200]] == PFC.NS?


> very many thanks for your time and effort...


> yours sincerely,

> AKSHAY M KULKARNI




> --
> *From:* Eric Berger  *Sent:*
> Wednesday, March 14, 2018 5:22 PM *To:* akshay kulkarni
> *Cc:* R help Mailing list *Subject:* Re: [R] the same
> function returning different values when called
> differently..

> Hi Akshay, Presumably PFC.NS and snl[[159]] are not
> exactly the same.  You can start by trying to determine if
> (and then how) they differ.  e.g.
>> identical(PFC.NS, snl[[159]])
> presumably this will result in FALSE

> then compare
>> class(PFC.NS) class(snl[[159]])

> etc

> HTH, Eric


> On Wed, Mar 14, 2018 at 1:42 PM, akshay kulkarni
>  wrote:

> dear members,

>  I have a function ygrpc which acts on the daily price
> increments of a stock. It returns the following values:


>  ygrpc(PFC.NS,"h") [1] 2.149997 1.875000 0.75 0.349991
> 2.16 0.17 4.00 2.574996 0.50 0.34
> 1.50 0.71 [13] 0.50 1.33 0.449997 2.83
> 2.724998 66.150002 0.550003 0.050003 1.224991 4.84
> 1.375000 1.574997 [25] 1.649994 0.449997 0.975006 2.475006
> 0.125000 2.625000 3.649994 0.34 1.33 2.074997
> 1.025001 0.125000 [37] 3.84 0.025002 0.824997 1.75
> 1.67 1.75 1.67 0.275002 2.33 0.349998
> 0.75 0.224998 [49] 0.125000 1.475006 1.58 0.125000
> 0.50 0.75 1.08 0.225006 1.274997 1.33
> 3.00 0.33 [61] 0.724999 3.67 2.424995 8.425003
> 1.01 2.025009 0.850006 4.00 1.724991 0.949997
> 1.825012 2.799988 [73] 0.425003 1.75 5.75 2.125000
> 0.125000 4.00 2.350006 1.524994 1.25 0.33
> 0.949997 0.449997 [85] 1.84 1.75 1.150009 0.849998
> 2.449997 5.33 0.1

> I also have a list of stocks called "snl" with snl[[159]]
> pointing to PFC.NS (above): tail(snl[[159]]) PFC.NS.Open
> PFC.NS.High PFC.NS.Low PFC.NS.Close PFC.NS.Volume
> PFC.NS.Adjusted 2018-03-07 98.40 98.45 95.1 95.30 7854861
> 95.30 2018-03-08 94.90 94.95 89.3 91.90 12408061 91.90
> 2018-03-09 92.00 94.50 91.9 93.10 7680222 93.10 2018-03-12
> 93.40 93.85 86.1 88.25 12617833 88.25 2018-03-13 89.20
> 91.85 86.2 89.85 12792630 89.85 2018-03-14 88.65 89.30
> 86.1 86.70 16406495 86.70

> But ygrpc(snl[[159]],"h") returns : ygrpc(snl[[159]],"h")
> [1] 1

> Can you please shed some light on what is happening?

> Very many thanks for your time and effort

> Yours sincerely AKSHAY M KULKARNI







> 

[R] Fwd: the same function returning different values when called differently..

2018-03-14 Thread Eric Berger
Hi Akshay,

(Please include r-help when replying)

You have learned that PFC.NS and snl[[159]] are not identical. Now you have
to figure out why they differ. This could also point to a bug or a logic
error in your program.
Figuring out how two objects differ can be a bit tricky, but with
experience it becomes easier. (Some others may even have some suggestions
for good ways to do it.)
Basically you would work your way down. At the top level is the class of
each, which you already tested and they are identical.

Now try:

> str(PFC.NS)

and compare it to

> str(snl[[159]]

Look closely at the two outputs to try to detect differences. If they are
the same then you will have to examine the sub-objects described by str().
You didn't mention what type of objects they are. Suppose they are both
"numeric" vectors. Then you can check whether their lengths are equal.
And you can compare their values, etc. etc. No short cut that I can think
of without more information.

It definitely takes work to find discrepancies. Think of it as a challenge
and perhaps write functions that you can use to automate this kind of
comparison in the future.
(Again, other people on this list might be able to point to tools that help
with this for objects of specific type.)

Good luck,
Eric




dear Eric,

   Bulls eye...! identical(PFC.NS, snl[[159]])) is
resulting false..but class(PFC.NS) and class(snl[[159]]) are same...

I want snl[[159]] to be equal to PFC.NS...how do I effect it? create a list
with some other element list... for example snl[[200]] == PFC.NS?


very many thanks for your time and effort...


yours sincerely,

AKSHAY M KULKARNI




--
*From:* Eric Berger 
*Sent:* Wednesday, March 14, 2018 5:22 PM
*To:* akshay kulkarni
*Cc:* R help Mailing list
*Subject:* Re: [R] the same function returning different values when called
differently..

Hi Akshay,
Presumably PFC.NS and snl[[159]] are not exactly the same.
You can start by trying to determine if (and then how) they differ.
e.g.
> identical(PFC.NS, snl[[159]])
presumably this will result in FALSE

then compare
> class(PFC.NS)
> class(snl[[159]])

etc

HTH,
Eric


On Wed, Mar 14, 2018 at 1:42 PM, akshay kulkarni 
wrote:

dear members,

 I have a function ygrpc which acts on the daily price increments of a
stock. It returns the following values:


 ygrpc(PFC.NS,"h")
 [1]  2.149997  1.875000  0.75  0.349991  2.16  0.17  4.00
2.574996  0.50  0.34  1.50  0.71
[13]  0.50  1.33  0.449997  2.83  2.724998 66.150002  0.550003
0.050003  1.224991  4.84  1.375000  1.574997
[25]  1.649994  0.449997  0.975006  2.475006  0.125000  2.625000  3.649994
0.34  1.33  2.074997  1.025001  0.125000
[37]  3.84  0.025002  0.824997  1.75  1.67  1.75  1.67
0.275002  2.33  0.349998  0.75  0.224998
[49]  0.125000  1.475006  1.58  0.125000  0.50  0.75  1.08
0.225006  1.274997  1.33  3.00  0.33
[61]  0.724999  3.67  2.424995  8.425003  1.01  2.025009  0.850006
4.00  1.724991  0.949997  1.825012  2.799988
[73]  0.425003  1.75  5.75  2.125000  0.125000  4.00  2.350006
1.524994  1.25  0.33  0.949997  0.449997
[85]  1.84  1.75  1.150009  0.849998  2.449997  5.33  0.1

I also have a list of stocks called "snl" with snl[[159]] pointing to
PFC.NS (above):
tail(snl[[159]])
   PFC.NS.Open PFC.NS.High PFC.NS.Low PFC.NS.Close PFC.NS.Volume
PFC.NS.Adjusted
2018-03-07   98.40   98.45   95.195.30   7854861
   95.30
2018-03-08   94.90   94.95   89.391.90  12408061
   91.90
2018-03-09   92.00   94.50   91.993.10   7680222
   93.10
2018-03-12   93.40   93.85   86.188.25  12617833
   88.25
2018-03-13   89.20   91.85   86.289.85  12792630
   89.85
2018-03-14   88.65   89.30   86.186.70  16406495
   86.70

But ygrpc(snl[[159]],"h") returns :
ygrpc(snl[[159]],"h")
[1] 1

Can you please shed some light on what is happening?

Very many thanks for your time and effort

Yours sincerely
AKSHAY M KULKARNI







[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
R-help -- Main R Mailing List: Primary help - Homepage - SfS

stat.ethz.ch
The main R mailing list, for announcements about the development of R and
the availability of new code, questions and answers about problems and
solutions using R ...


PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

[[alternative HTML version deleted]]


Re: [R] Learning advanced R

2018-03-14 Thread Duncan Murdoch

On 14/03/2018 12:07 PM, Rich Shepard wrote:

On Wed, 14 Mar 2018, Barry Rowlingson wrote:


Depending on your application, I'm not sure there's much point in being an
"advanced R programmer" these days. Become an adequate R programmer, and
learn C++ and Rcpp. Do basic data mashing in R, then do all your intensive
stuff in C++ with Rcpp. Eventually you'll probably get to the point where
you can express yourself in C++ as fast as you can in interpreted R, with
the bonus of C++ speed, type-safety etc.


Barry,

Allow me to offer an alternative to C++: Python. Compiled languages are
faster than interpreted ones, but unless you're doing time-critical
computations it really does not matter. R and Python provide proven
abilities in a broad range of applications and with today's hardware the
analytical/modeling code is not likely to be the limiting factor.



I'm all for learning more languages and using the one that's best for 
each job, but for people who don't know Python, it would be helpful to 
list the aspects in which it excels.  When should an R user choose to 
write something in Python instead?


Duncan Murdoch

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Learning advanced R

2018-03-14 Thread Rich Shepard

On Wed, 14 Mar 2018, Barry Rowlingson wrote:


Depending on your application, I'm not sure there's much point in being an
"advanced R programmer" these days. Become an adequate R programmer, and
learn C++ and Rcpp. Do basic data mashing in R, then do all your intensive
stuff in C++ with Rcpp. Eventually you'll probably get to the point where
you can express yourself in C++ as fast as you can in interpreted R, with
the bonus of C++ speed, type-safety etc.


Barry,

  Allow me to offer an alternative to C++: Python. Compiled languages are
faster than interpreted ones, but unless you're doing time-critical
computations it really does not matter. R and Python provide proven
abilities in a broad range of applications and with today's hardware the
analytical/modeling code is not likely to be the limiting factor.

Regards,

Rich

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Learning advanced R

2018-03-14 Thread Barry Rowlingson
Depending on your application, I'm not sure there's much point in being an
"advanced R programmer" these days. Become an adequate R programmer, and
learn C++ and Rcpp. Do basic data mashing in R, then do all your intensive
stuff in C++ with Rcpp. Eventually you'll probably get to the point where
you can express yourself in C++ as fast as you can in interpreted R, with
the bonus of C++ speed, type-safety etc.



On Wed, Mar 14, 2018 at 8:13 AM, Eric Berger  wrote:

> Bert's suggestion is good as a pointer to a variety of resources.
> Sticking to the book format there are two of Hadley Wickham's books, which
> have the advantage that they are freely available.
> You can either read them online or download the source from github and
> create your own copy (which you can then print, if desired.)
> 1. "R for Data Science"
>  online: http://r4ds.had.co.nz/
>  github: https://github.com/hadley/r4ds
> 2. "Advanced R"
>  online: https://adv-r.hadley.nz/
>  github: https://github.com/hadley/adv-r
>
> Best,
> Eric
>
>
>
> On Wed, Mar 14, 2018 at 12:13 AM, Rich Shepard 
> wrote:
>
> > On Tue, 13 Mar 2018, Mark Leeds wrote:
> >
> > See Hadley's advanced R
> >>
> >
> >   +1 A very well writte, highly useful book. Recommended.
> >
> > Rich
> >
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posti
> > ng-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Warning for LC_CTYPE when R is ran through ssh

2018-03-14 Thread Jeff Newmiller
I don't think that warning is originating from R... LC_TYPE is an environment 
variable that the standard C library pays attention to, so could be either ssh 
on your local computer or ssh on the remote computer in response to something 
the local ssh is doing.

IMO this question belongs in a forum about Ubuntu or ssh, or possibly 
R-sig-debian.

-- 
Sent from my phone. Please excuse my brevity.

On March 14, 2018 2:17:20 AM PDT, Marc Girondot via R-help 
 wrote:
>Dear member,
>
>When I run a code on a computer B from a computer A through shh using 
>for example:
>
>system("ssh login@IPadress \"R -e 'print(1)'\"")
>[Note that I don't need indicate password because
>~/.ssh/authorized_keys 
>is used]
>
>I get a warning:
>During startup - Warning message:
>Setting LC_CTYPE failed, using "C"
>
>The code is working (it prints 1) but I don't like get a warning.
>
>R 3.4.3 is installed on the IPadress computer under Ubuntu 16.04
>
>In this computer, I tried to add in .Rprofile this line:
>Sys.setlocale(category = "LC_CTYPE", locale = "en_US.UTF-8")
>
>it is recognized but I get always the same warning when the code is ran
>
>through ssh:
>
> > system("ssh login@IPadress \"R -e 'print(1)'\"")
>
>R version 3.4.3 (2017-11-30) -- "Kite-Eating Tree"
>Copyright (C) 2017 The R Foundation for Statistical Computing
>Platform: x86_64-pc-linux-gnu (64-bit)
>
> some messages are removed for simplicity
>
>[1] "en_US.UTF-8"
>[Previously saved workspace restored]
>
>During startup - Warning message:
>Setting LC_CTYPE failed, using "C"
> > print(1)
>[1] 1
>
>If I run the same in the local terminal, I don't get the warning:
>
>~$ R -e "print(1)"
>
>R version 3.4.3 (2017-11-30) -- "Kite-Eating Tree"
>Copyright (C) 2017 The R Foundation for Statistical Computing
>Platform: x86_64-pc-linux-gnu (64-bit)
>
> some messages are removed for simplicity
>
>
>[1] "en_US.UTF-8"
>[Previously saved workspace restored]
>
> > print(1)
>[1] 1
>
>
>Has someone a solution to not get this warning when a code is ran 
>through ssh ?
>
>Thanks
>
>Marc Girondot
>
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] R crashing with a segmentation fault: how to locate the cause

2018-03-14 Thread Eric Berger
I have a littler script which is crashing with a segmentation fault.
I tried to find out why by running it through valgrind, which produced the
output below.
I am not sure how to proceed from here (other than binary search with print
statements).
Any help would be appreciated.

Thanks,
Eric

==12589== Invalid read of size 1
==12589==at 0x4C2F1B1: strcmp (in
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==12589==by 0x4F71AC1: Rf_inherits (in /usr/lib/R/lib/libR.so)
==12589==by 0x11AFED3A: dplyr::subset_visitor_vector(SEXPREC*)
(subset_visitor_impl.h:51)
==12589==by 0x11AFF58C: dplyr::subset_visitor(SEXPREC*,
dplyr::SymbolString const&) (subset_visitor_impl.h:21)
==12589==by 0x11AFEC18:
dplyr::DataFrameSubsetVisitors::DataFrameSubsetVisitors(Rcpp::DataFrame_Impl
const&) (DataFrameSubsetVisitors.h:33)
==12589==by 0x11B1F773: subset
> (DataFrameSubsetVisitors.h:120)
==12589==by 0x11B1F773:
filter_ungrouped(Rcpp::DataFrame_Impl,
dplyr::NamedQuosure const&) (filter.cpp:89)
==12589==by 0x11B1FD89:
filter_impl(Rcpp::DataFrame_Impl,
dplyr::NamedQuosure) (filter.cpp:106)
==12589==by 0x11AD45CB: _dplyr_filter_impl (RcppExports.cpp:192)
==12589==by 0x4F0DBAC: ??? (in /usr/lib/R/lib/libR.so)
==12589==by 0x4F50E50: Rf_eval (in /usr/lib/R/lib/libR.so)
==12589==by 0x4F534FF: ??? (in /usr/lib/R/lib/libR.so)
==12589==by 0x4F50C28: Rf_eval (in /usr/lib/R/lib/libR.so)
==12589==  Address 0x2c is not stack'd, malloc'd or (recently) free'd
==12589==
==12589==
==12589== Process terminating with default action of signal 11 (SIGSEGV)
==12589==  Access not within mapped region at address 0x2C
==12589==at 0x4C2F1B1: strcmp (in
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==12589==by 0x4F71AC1: Rf_inherits (in /usr/lib/R/lib/libR.so)
==12589==by 0x11AFED3A: dplyr::subset_visitor_vector(SEXPREC*)
(subset_visitor_impl.h:51)
==12589==by 0x11AFF58C: dplyr::subset_visitor(SEXPREC*,
dplyr::SymbolString const&) (subset_visitor_impl.h:21)
==12589==by 0x11AFEC18:
dplyr::DataFrameSubsetVisitors::DataFrameSubsetVisitors(Rcpp::DataFrame_Impl
const&) (DataFrameSubsetVisitors.h:33)
==12589==by 0x11B1F773: subset
> (DataFrameSubsetVisitors.h:120)
==12589==by 0x11B1F773:
filter_ungrouped(Rcpp::DataFrame_Impl,
dplyr::NamedQuosure const&) (filter.cpp:89)
==12589==by 0x11B1FD89:
filter_impl(Rcpp::DataFrame_Impl,
dplyr::NamedQuosure) (filter.cpp:106)
==12589==by 0x11AD45CB: _dplyr_filter_impl (RcppExports.cpp:192)
==12589==by 0x4F0DBAC: ??? (in /usr/lib/R/lib/libR.so)
==12589==by 0x4F50E50: Rf_eval (in /usr/lib/R/lib/libR.so)
==12589==by 0x4F534FF: ??? (in /usr/lib/R/lib/libR.so)
==12589==by 0x4F50C28: Rf_eval (in /usr/lib/R/lib/libR.so)
==12589==  If you believe this happened as a result of a stack
==12589==  overflow in your program's main thread (unlikely but
==12589==  possible), you can try to increase the size of the
==12589==  main thread stack using the --main-stacksize= flag.
==12589==  The main thread stack size used in this run was 8388608.
==12589==
==12589== HEAP SUMMARY:
==12589== in use at exit: 224,025,975 bytes in 111,522 blocks
==12589==   total heap usage: 1,104,400 allocs, 992,878 frees, 625,925,991
bytes allocated
==12589==
==12589== LEAK SUMMARY:
==12589==definitely lost: 0 bytes in 0 blocks
==12589==indirectly lost: 0 bytes in 0 blocks
==12589==  possibly lost: 18,724 bytes in 47 blocks
==12589==still reachable: 224,007,251 bytes in 111,475 blocks
==12589== suppressed: 0 bytes in 0 blocks
==12589== Rerun with --leak-check=full to see details of leaked memory
==12589==
==12589== For counts of detected and suppressed errors, rerun with: -v
==12589== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
Segmentation fault (core dumped)

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] the same function returning different values when called differently..

2018-03-14 Thread Eric Berger
Hi Akshay,
Presumably PFC.NS and snl[[159]] are not exactly the same.
You can start by trying to determine if (and then how) they differ.
e.g.
> identical(PFC.NS, snl[[159]])
presumably this will result in FALSE

then compare
> class(PFC.NS)
> class(snl[[159]])

etc

HTH,
Eric


On Wed, Mar 14, 2018 at 1:42 PM, akshay kulkarni 
wrote:

> dear members,
>
>  I have a function ygrpc which acts on the daily price increments of a
> stock. It returns the following values:
>
>
>  ygrpc(PFC.NS,"h")
>  [1]  2.149997  1.875000  0.75  0.349991  2.16  0.17
> 4.00  2.574996  0.50  0.34  1.50  0.71
> [13]  0.50  1.33  0.449997  2.83  2.724998 66.150002
> 0.550003  0.050003  1.224991  4.84  1.375000  1.574997
> [25]  1.649994  0.449997  0.975006  2.475006  0.125000  2.625000
> 3.649994  0.34  1.33  2.074997  1.025001  0.125000
> [37]  3.84  0.025002  0.824997  1.75  1.67  1.75
> 1.67  0.275002  2.33  0.349998  0.75  0.224998
> [49]  0.125000  1.475006  1.58  0.125000  0.50  0.75
> 1.08  0.225006  1.274997  1.33  3.00  0.33
> [61]  0.724999  3.67  2.424995  8.425003  1.01  2.025009
> 0.850006  4.00  1.724991  0.949997  1.825012  2.799988
> [73]  0.425003  1.75  5.75  2.125000  0.125000  4.00
> 2.350006  1.524994  1.25  0.33  0.949997  0.449997
> [85]  1.84  1.75  1.150009  0.849998  2.449997  5.33  0.1
>
> I also have a list of stocks called "snl" with snl[[159]] pointing to
> PFC.NS (above):
> tail(snl[[159]])
>PFC.NS.Open PFC.NS.High PFC.NS.Low PFC.NS.Close PFC.NS.Volume
> PFC.NS.Adjusted
> 2018-03-07   98.40   98.45   95.195.30   7854861
>  95.30
> 2018-03-08   94.90   94.95   89.391.90  12408061
>  91.90
> 2018-03-09   92.00   94.50   91.993.10   7680222
>  93.10
> 2018-03-12   93.40   93.85   86.188.25  12617833
>  88.25
> 2018-03-13   89.20   91.85   86.289.85  12792630
>  89.85
> 2018-03-14   88.65   89.30   86.186.70  16406495
>  86.70
>
> But ygrpc(snl[[159]],"h") returns :
> ygrpc(snl[[159]],"h")
> [1] 1
>
> Can you please shed some light on what is happening?
>
> Very many thanks for your time and effort
>
> Yours sincerely
> AKSHAY M KULKARNI
>
>
>
>
>
>
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Documenting R package with Rd file

2018-03-14 Thread Duncan Murdoch

On 14/03/2018 6:10 AM, Steven Yen wrote:

I have trouble documenting an R package. In my .Rd file (sixth line below), I 
have
uhat<-m%*%y

but when the package is built (successfully), the matrix multiplication part 
does not show up in the documentation. The line become (missing %*% y)


Generally questions about writing packages should be in R-devel or 
R-package-devel, but this one is easy, so I'll answer here.


The % symbol marks a comment in an Rd file.  You need to escape them. 
See below...


uhat<-m

===

\examples{
x<-c(1,2,3,4,5)
y<-c(1,1,2,2,4)
x<-cbind(1,x)
m<-mmat(x)
uhat<-m%*%y


Should be "uhat <- m \%*\% y"

Duncan Murdoch


dstat(uhat)
}

   --
st...@ntu.edu.tw (S.T. Yen)


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Documenting R package with Rd file

2018-03-14 Thread Steven Yen
I have trouble documenting an R package. In my .Rd file (sixth line below), I 
have
uhat<-m%*%y

but when the package is built (successfully), the matrix multiplication part 
does not show up in the documentation. The line become (missing %*% y)

uhat<-m

===

\examples{
x<-c(1,2,3,4,5)
y<-c(1,1,2,2,4)
x<-cbind(1,x)
m<-mmat(x)
uhat<-m%*%y
dstat(uhat)
}

  --
st...@ntu.edu.tw (S.T. Yen)


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Warning for LC_CTYPE when R is ran through ssh

2018-03-14 Thread Marc Girondot via R-help

Dear member,

When I run a code on a computer B from a computer A through shh using 
for example:


system("ssh login@IPadress \"R -e 'print(1)'\"")
[Note that I don't need indicate password because ~/.ssh/authorized_keys 
is used]


I get a warning:
During startup - Warning message:
Setting LC_CTYPE failed, using "C"

The code is working (it prints 1) but I don't like get a warning.

R 3.4.3 is installed on the IPadress computer under Ubuntu 16.04

In this computer, I tried to add in .Rprofile this line:
Sys.setlocale(category = "LC_CTYPE", locale = "en_US.UTF-8")

it is recognized but I get always the same warning when the code is ran 
through ssh:


> system("ssh login@IPadress \"R -e 'print(1)'\"")

R version 3.4.3 (2017-11-30) -- "Kite-Eating Tree"
Copyright (C) 2017 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

 some messages are removed for simplicity

[1] "en_US.UTF-8"
[Previously saved workspace restored]

During startup - Warning message:
Setting LC_CTYPE failed, using "C"
> print(1)
[1] 1

If I run the same in the local terminal, I don't get the warning:

~$ R -e "print(1)"

R version 3.4.3 (2017-11-30) -- "Kite-Eating Tree"
Copyright (C) 2017 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

 some messages are removed for simplicity


[1] "en_US.UTF-8"
[Previously saved workspace restored]

> print(1)
[1] 1


Has someone a solution to not get this warning when a code is ran 
through ssh ?


Thanks

Marc Girondot

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Possible Improvement to sapply

2018-03-14 Thread Doran, Harold
Well thanks, Martin, and glad to see there is some potential here. This
wasn¹t reported as a bug, but as you note really as a question originally
and with an invitation to critique my code.

On 3/14/18, 5:11 AM, "Martin Maechler"  wrote:

>> Henrik Bengtsson 
>> on Tue, 13 Mar 2018 10:12:55 -0700 writes:
>
>> FYI, in R devel (to become 3.5.0), there's isFALSE() which will cut
>> some corners compared to identical():
>
>> > microbenchmark::microbenchmark(identical(FALSE, FALSE),
>>isFALSE(FALSE))
>> Unit: nanoseconds
>> expr min   lqmean median uq   max neval
>>  identical(FALSE, FALSE) 984 1138 1694.13 1218.0 1337.5 13584   100
>>   isFALSE(FALSE) 713  761 1133.53  809.5  871.5 18619   100
>
>> > microbenchmark::microbenchmark(identical(TRUE, FALSE), isFALSE(TRUE))
>> Unit: nanoseconds
>>expr  min lqmean median   uq   max neval
>>  identical(TRUE, FALSE) 1009 1103.5 2228.20 1170.5 1357 14346   100
>>   isFALSE(TRUE)  718  760.0 1298.98  798.0  898 17782   100
>
>> > microbenchmark::microbenchmark(identical("array", FALSE),
>>isFALSE("array"))
>> Unit: nanoseconds
>>   expr min lqmean median uq  max neval
>>  identical("array", FALSE) 975 1058.5 1257.95 1119.5 1250.0 9299   100
>>   isFALSE("array") 409  433.5  658.76  446.0  476.5 9383   100
>
>Thank you Henrik!
>
>The speed of the new isTRUE() and isFALSE() is indeed amazing
>compared to identical() which was written to be fast itself.
>
>Note that the new code goes back to a proposal by  Hervé Pagès
>(of Bioconductor fame) in a thread with R core in April 2017.
>The goal of the new code actually *was*  to allow call like
>
>  isTRUE(c(a = TRUE))
>
>to become TRUE rather than improving speed.
>The new source code is at the end of  R/src/library/base/R/identical.R
>
>## NB:  is.logical(.) will never dispatch:
>## -- base::is.logical(x)  <==>  typeof(x) == "logical"
>isTRUE  <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && x
>isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x
>
>and one *reason* this is so fast is that all  6  functions which
>are called are primitives :
>
>> sapply(codetools::findGlobals(isTRUE), function(fn)
>>is.primitive(get(fn)))
> ! && == is.logical  is.na length
>  TRUE   TRUE   TRUE   TRUE   TRUE   TRUE
>
>and a 2nd reason is probably with the many recent improvements of the
>byte compiler.
>
>
>> That could probably be used also is sapply().  The difference is that
>> isFALSE() is a bit more liberal than identical(x, FALSE), e.g.
>
>> > isFALSE(c(a = FALSE))
>> [1] TRUE
>> > identical(c(a = FALSE), FALSE)
>> [1] FALSE
>
>> Assuming the latter is not an issue, there are 69 places in base R
>> where isFALSE() could be used:
>
>> $ grep -E "identical[(][^,]+,[ ]*FALSE[)]" -r --include="*.R" | grep -F
>>"/R/" | wc
>>  69 3265472
>
>> and another 59 where isTRUE() can be used:
>
>> $ grep -E "identical[(][^,]+,[ ]*TRUE[)]" -r --include="*.R" | grep -F
>>"/R/" | wc
>>  59 3075021
>
>Beautiful use of  'grep' -- thank you for those above, as well.
>It does need a quick manual check, but if I use the above grep
>from Emacs (via  'M-x grep')  or even better via a TAGS table
>and M-x tags-query-replace  I should be able to do the changes
>pretty quickly... and will start looking into that later today.
>
>Interestingly and to my great pleasure, the first part of the
>'Subject' of this mailing list thread, "Possible Improvement",
>*has* become true after all --
>
>-- thanks to Henrik !
>
>Martin Maechler
>ETH Zurich
>
>
>
>> On Tue, Mar 13, 2018 at 9:21 AM, Doran, Harold  wrote:
>> > Quite possibly, and I¹ll look into that. Aside from the work I was
>>doing, however, I wonder if there is a way such that sapply could avoid
>>the overhead of having to call the identical function to determine the
>>conditional path.
>> >
>> >
>> >
>> > From: William Dunlap [mailto:wdun...@tibco.com]
>> > Sent: Tuesday, March 13, 2018 12:14 PM
>> > To: Doran, Harold 
>> > Cc: Martin Morgan ;
>>r-help@r-project.org
>> > Subject: Re: [R] Possible Improvement to sapply
>> >
>> > Could your code use vapply instead of sapply?  vapply forces you to
>>declare the type and dimensions
>> > of FUN's output and stops if any call to FUN does not match the
>>declaration.  It can use much less
>> > memory and time than sapply because it fills in the output array as
>>it goes instead of calling lapply()
>> > and seeing how it could be simplified.
>> >
>> > Bill Dunlap
>> > TIBCO Software
>> > wdunlap tibco.com
>> >
>> > On Tue, Mar 13, 2018 at 7:06 AM, Doran, Harold
>>> wrote:
>> > Martin
>> >
>> > In terms of context of the actual problem, sapply is 

Re: [R] Possible Improvement to sapply

2018-03-14 Thread Martin Maechler
> Henrik Bengtsson 
> on Tue, 13 Mar 2018 10:12:55 -0700 writes:

> FYI, in R devel (to become 3.5.0), there's isFALSE() which will cut
> some corners compared to identical():

> > microbenchmark::microbenchmark(identical(FALSE, FALSE), isFALSE(FALSE))
> Unit: nanoseconds
> expr min   lqmean median uq   max neval
>  identical(FALSE, FALSE) 984 1138 1694.13 1218.0 1337.5 13584   100
>   isFALSE(FALSE) 713  761 1133.53  809.5  871.5 18619   100

> > microbenchmark::microbenchmark(identical(TRUE, FALSE), isFALSE(TRUE))
> Unit: nanoseconds
>expr  min lqmean median   uq   max neval
>  identical(TRUE, FALSE) 1009 1103.5 2228.20 1170.5 1357 14346   100
>   isFALSE(TRUE)  718  760.0 1298.98  798.0  898 17782   100

> > microbenchmark::microbenchmark(identical("array", FALSE), isFALSE("array"))
> Unit: nanoseconds
>   expr min lqmean median uq  max neval
>  identical("array", FALSE) 975 1058.5 1257.95 1119.5 1250.0 9299   100
>   isFALSE("array") 409  433.5  658.76  446.0  476.5 9383   100

Thank you Henrik!

The speed of the new isTRUE() and isFALSE() is indeed amazing
compared to identical() which was written to be fast itself.

Note that the new code goes back to a proposal by  Hervé Pagès
(of Bioconductor fame) in a thread with R core in April 2017.
The goal of the new code actually *was*  to allow call like

  isTRUE(c(a = TRUE))   

to become TRUE rather than improving speed.
The new source code is at the end of  R/src/library/base/R/identical.R

## NB:  is.logical(.) will never dispatch:
## -- base::is.logical(x)  <==>  typeof(x) == "logical"
isTRUE  <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && x
isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x

and one *reason* this is so fast is that all  6  functions which
are called are primitives :

> sapply(codetools::findGlobals(isTRUE), function(fn) is.primitive(get(fn)))
 ! && == is.logical  is.na length 
  TRUE   TRUE   TRUE   TRUE   TRUE   TRUE 

and a 2nd reason is probably with the many recent improvements of the
byte compiler.


> That could probably be used also is sapply().  The difference is that
> isFALSE() is a bit more liberal than identical(x, FALSE), e.g.

> > isFALSE(c(a = FALSE))
> [1] TRUE
> > identical(c(a = FALSE), FALSE)
> [1] FALSE

> Assuming the latter is not an issue, there are 69 places in base R
> where isFALSE() could be used:

> $ grep -E "identical[(][^,]+,[ ]*FALSE[)]" -r --include="*.R" | grep -F "/R/" 
> | wc
>  69 3265472

> and another 59 where isTRUE() can be used:

> $ grep -E "identical[(][^,]+,[ ]*TRUE[)]" -r --include="*.R" | grep -F "/R/" 
> | wc
>  59 3075021

Beautiful use of  'grep' -- thank you for those above, as well.
It does need a quick manual check, but if I use the above grep
from Emacs (via  'M-x grep')  or even better via a TAGS table
and M-x tags-query-replace  I should be able to do the changes
pretty quickly... and will start looking into that later today.

Interestingly and to my great pleasure, the first part of the
'Subject' of this mailing list thread, "Possible Improvement",
*has* become true after all --

-- thanks to Henrik !

Martin Maechler
ETH Zurich



> On Tue, Mar 13, 2018 at 9:21 AM, Doran, Harold  wrote:
> > Quite possibly, and I’ll look into that. Aside from the work I was doing, 
> > however, I wonder if there is a way such that sapply could avoid the 
> > overhead of having to call the identical function to determine the 
> > conditional path.
> >
> >
> >
> > From: William Dunlap [mailto:wdun...@tibco.com]
> > Sent: Tuesday, March 13, 2018 12:14 PM
> > To: Doran, Harold 
> > Cc: Martin Morgan ; r-help@r-project.org
> > Subject: Re: [R] Possible Improvement to sapply
> >
> > Could your code use vapply instead of sapply?  vapply forces you to declare 
> > the type and dimensions
> > of FUN's output and stops if any call to FUN does not match the 
> > declaration.  It can use much less
> > memory and time than sapply because it fills in the output array as it goes 
> > instead of calling lapply()
> > and seeing how it could be simplified.
> >
> > Bill Dunlap
> > TIBCO Software
> > wdunlap tibco.com
> >
> > On Tue, Mar 13, 2018 at 7:06 AM, Doran, Harold 
> > > wrote:
> > Martin
> >
> > In terms of context of the actual problem, sapply is called millions of 
> > times because the work involves scoring individual students who took a 
> > test. A score for student A is generated and then student B and such and 
> > there are millions of students. The psychometric process of scoring 
> > students is complex and our code makes use of sapply many times for each 
> > student.
> >
> > The toy example 

Re: [R-es] Leer csvs de Carpeta

2018-03-14 Thread Pedro Herrero Petisco
Hola, por si te sirve yo hago la lectura de ficheros con este script:

ruta<-"Tu_Carpeta"
ficheros <- list.files(path=ruta)
ficheros<-paste(ruta,"/",ficheros,sep="")
datos <- do.call(rbind, lapply(ficheros, function(x) read.csv2(x)))

Saludos

El 14 de marzo de 2018, 6:00, Nacho García 
escribió:

> Buenos días a todos:
>
> Hace unos meses alguien preguntó cómo leer con R todos archivos csv de una
> carpeta. Ahora me encuentro yo en esta situación y no encuentro el corro.
> Alguien me lo puede mandar.
>
> Gracias!
>
> Enviado desde mi iPad
>
> [[alternative HTML version deleted]]
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R] Learning advanced R

2018-03-14 Thread Eric Berger
Bert's suggestion is good as a pointer to a variety of resources.
Sticking to the book format there are two of Hadley Wickham's books, which
have the advantage that they are freely available.
You can either read them online or download the source from github and
create your own copy (which you can then print, if desired.)
1. "R for Data Science"
 online: http://r4ds.had.co.nz/
 github: https://github.com/hadley/r4ds
2. "Advanced R"
 online: https://adv-r.hadley.nz/
 github: https://github.com/hadley/adv-r

Best,
Eric



On Wed, Mar 14, 2018 at 12:13 AM, Rich Shepard 
wrote:

> On Tue, 13 Mar 2018, Mark Leeds wrote:
>
> See Hadley's advanced R
>>
>
>   +1 A very well writte, highly useful book. Recommended.
>
> Rich
>
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posti
> ng-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.