[R] tcltk problems

2017-11-17 Thread Rolf Turner


It recently came to my attention that my R installation no longer has 
tcltk capability.


I can't figure out why or what to do about it.

I built R from source.  I configured using the "--with-tcltk" flag.  The 
build and install *seemed* to go OK, but after realising I didn't have 
tcltk capability I looked into config.log.


There I found:


configure:39486: checking for tclConfig.sh
configure:39519: result: no
configure:39528: checking for tclConfig.sh in library (sub)directories
configure:39549: result: no
configure:39561: checking for tkConfig.sh
configure:39594: result: no
configure:39603: checking for tkConfig.sh in library (sub)directories
configure:39624: result: no
configure:39721: checking for tcl.h
conftest.c:249:17: fatal error: tcl.h: No such file or directory
compilation terminated.


I have tcl and tk (and the -dev versions) installed on my machine, and 
they are apparently up-to-date).


Moreover if I do "locate tclConfig.sh" I get:


/usr/lib/tcl8.6/tclConfig.sh
/usr/lib/x86_64-linux-gnu/tcl8.6/tclConfig.sh


And likewise "locate tcl.h" produces:


/usr/include/tcl8.6/tcl.h
/usr/include/tcl8.6/tcl-private/generic/tcl.h


So why can't "configure" find these files, and how can I tell it where 
to find them?


I'm running Ubuntu 16.04 and my last install of R was of version 3.4.2.

My installation procedure always worked in the past 

Thanks for any tips.

cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] tcltk problems

2017-11-17 Thread Rolf Turner

On 18/11/17 17:00, Erin Hodgess wrote:
When I have compiled from sourced on Ubuntu, I did NOT include the 
"with-tcltk" and it worked fine.  Did you try that, please?


In the past I have configured without using the "--with-tcltk" flag,
and R of course built just fine.  But it *did not* have tcltk 
capability.  When I wanted that capability I had to start using the

aforesaid flag.

It makes absolutely no sense that one would get tcltk capability when 
configuring without the flag but *not* get it when configuring *with* 
the flag.  If that is indeed the case then this definitely constitutes a 
bug in the "configure" system.


I cannot believe that it would work to leave out the flag, but I'll try 
it just for the sake of "completeness".


cheers,

Rolf

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] tcltk problems

2017-11-17 Thread Rolf Turner


On 18/11/17 17:00, Erin Hodgess wrote:

When I have compiled from sourced on Ubuntu, I did NOT include the 
"with-tcltk" and it worked fine.  Did you try that, please?


As I said, this idea makes absolutely no sense, but OK, I tried it.
And of course it didn't work.

Using the newly built R I ran capabilities() and got:

   jpeg pngtiff   tcltk X11aqua 
   TRUETRUETRUE   FALSETRUE   FALSE 
   http/ftp sockets  libxmlfifo  cledit   iconv 
   TRUETRUETRUETRUETRUETRUE 
NLS profmem   cairo ICU long.double libcurl 
   TRUE   FALSETRUETRUETRUETRUE 


cheers,

Rolf

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] Re: tcltk problems

2017-11-18 Thread Rolf Turner


On 19/11/17 05:36, Albrecht Kauffmann wrote:


Did you istall the tcl- and tk-devel packages?


(a) That should be "dev" not "devel".

(b) The answer to your question is, yes, as I made clear in my original 
post.


cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] tcltk problems

2017-11-18 Thread Rolf Turner

On 18/11/17 18:18, Peter Langfelder wrote:

Rolf,

looking at the configure script I believe you need to specify

--with-tcl-config=/usr/lib/tcl8.6/tclConfig.sh

and similarly

--with-tk-config=

HTH.


Yes it helped.  Thank you. I don't really understand why, but.

I had previously (following an off-list suggestion from Berwin Turlach) 
put in symbolic links in /usr/lib:


 tclConfig.sh -> tcl8.6/tclConfig.sh*
and
 tkConfig.sh -> tk8.6/tclConfig.sh

so if the configure was by default looking for these files in /usr/lib 
it should have found them.  But it seemed not to.


In respect of Dirk's suggestion that I try using pre-built ubuntu R, I 
decided to try that and did


sudo apt update
sudo apt-get install r-base

and that kind of worked --- but naturally it screwed something up.  I 
can no longer load a "personal" library of utilities --- when I try this

(either having the load command in my .Rprofile or by invoking
R --vanilla) R crashes and tries to dump core.

Now, after having successfully installed R from source (following Peter 
Langfelder's tip) I still cannot load my utilities library.  Something 
got changed by the "install r-base" procedure, and there would appear to 
be no way of tracking down just what got changed.


It's things like that which make me want to "do it myself" as much as 
possible.


W.r.t. Peter Dalgaard's suggestion/question about ${LIBnn}$:  I looked 
through R-3.4.2/configure and can see nowhere that LIBnn gets set. 
(Lots of references to LIBnn, but nowhere that its value gets set equal 
to something.)


BTW I (of course) am using the configure file that comes with R-3.4.2; I 
haven't changed anything.  So if anyone looks at the R-3.4.2 configure 
file they should see exactly what I see.


Then I scanned through BldDir/config.log and found:

LIBnn='lib64'

(on line 19901 !!!)

So it would appear that Peter D.'s conjecture is correct.

OTOH this is waaayyy after the "checking for tclConfig.sh" business, 
which happens at about line 15101 of config.log.  So how does it have an 
impact on that?


And how did LIBnn get to be set to 'lib64'?  I certainly didn't do it, 
and there's nothing about 'lib64' in the environment variables that I 
have set.


I remain mystified.

cheers,

Rolf

P.S.  On a whim, I scanned through config.log some more and found many, 
many errors logged and many, many "compilation terminated" notes.  In 
particular there seem to be problems with a file "confdef.h", which 
repeatedly seems to give rise to "fatal errors".  (Where is confdef.h?

It seems to be nowhere.)

But this was from a "*successful*" configure (using Peter L.'s 
suggestion.) So it would appear that these errors were harmless.  Mostly 
harmless???


R.

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] tcltk problems

2017-11-19 Thread Rolf Turner

On 20/11/17 03:15, Dirk Eddelbuettel wrote:


On 19 November 2017 at 12:17, peter dalgaard wrote:
| Dirk may want to dig in here:

I respectfully decline.

R builds fine on every Ubuntu system, and always has.  No bug in R, or
Ubuntu, or Debian (which would be cup of tea). There is the distro package
(which may be older if an older distro like 16.04 is used) and there always
is a current package at CRAN based on Michael's build of my packages. Always.

Of course a lot of people also locally build R, or maybe R-devel. There is no
general issue here as best as I can tell.

| [...] if one user has shot himself in the foot somehow.

My brief reading suggests that this is the case.


Point of order Mr. Chairman.  It is completely unfair to say that I shot 
myself in the foot.


I did:

sudo apt-get install tcl
sudo apt-get install tcl8.6.dev

and similarly for tk stuff.

I downloaded the source for R-3.4.2 and ran ../R-3.4.2/configure (from a 
"parallel" directory "BldDir".


It stuffed up, apparently being unable to find tclConfig.sh and tkConfig.sh.

*After* the stuff-up I put in symbolic links in /usr/lib to these file 
in the subdirectories (in which apt-get install apparently placed them.)
This was done according to a suggestion from Berwin Turlach, who found 
that there were similar symbolic links in his file system.  This did not

help however.

Peter Langfelder's suggestion, saying very explicitly what flags I 
should provide to "configure" in respect of the *Config.sh files, *DID* 
work.


I did *not* move any files around.  I did *not* make any alterations to
the configure script.  I did not modify anything, in a "non-standard" 
way --- or even in a standard way!  I just used the software provided, 
in the prescribed manner, and it did not work.



Nothing good comes off moving files around in /usr as was done.  It creates
local non-standard circumstances. You cannot expect standardized build to
anticipate each and every possible non-standard modification.

This discussion is still on the wrong list too.


Well, OK.  What list *should* it be on?  I was asking for help with an R 
problem.  It seems to me that R-help is appropriate.


cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] Re: installing "rgl" package

2017-11-23 Thread Rolf Turner

On 24/11/17 12:10, Duncan Murdoch wrote:

On 23/11/2017 6:05 PM, Santosh wrote:

Hi Rxperts,
I am trying to install 'rgl' package in Ubuntu.. Would highly appreciate
your assistance .. I tried several leads available on various discussion
fora and nothing helped so far.


Your message is really hard to follow, since you posted in HTML.  You 
need the OpenGL development packages.  On Ubuntu, that probably means 
MesaGL, but I don't know the names of the development packages. >

Duncan Murdoch



The installation of rgl runs without complaint on my system, so 
apparently I have whatever libraries are needed.


I did "apt-show-versions | grep mesa" on my laptop (a trick I just 
learned from Berwin Turlach; thanks Berwin!) and got a slew of bumff:



libegl1-mesa:amd64/xenial-updates 17.0.7-0ubuntu0.16.04.2 uptodate
libegl1-mesa-drivers:amd64/xenial-updates 12.0.6-0ubuntu0.16.04.1 uptodate
libgl1-mesa-dev:amd64/xenial-updates 17.0.7-0ubuntu0.16.04.2 uptodate
libgl1-mesa-dri:amd64/xenial-updates 17.0.7-0ubuntu0.16.04.2 uptodate
libgl1-mesa-glx:amd64/xenial-updates 17.0.7-0ubuntu0.16.04.2 uptodate
libglapi-mesa:amd64/xenial-updates 17.0.7-0ubuntu0.16.04.2 uptodate
libglu1-mesa:amd64/xenial 9.0.0-2.1 uptodate
libglu1-mesa-dev:amd64/xenial 9.0.0-2.1 uptodate
libwayland-egl1-mesa:amd64/xenial-updates 17.0.7-0ubuntu0.16.04.2 uptodate
mesa-common-dev:amd64/xenial-updates 17.0.7-0ubuntu0.16.04.2 uptodate
mesa-utils:amd64/xenial 8.3.0-1 uptodate
mesa-vdpau-drivers:amd64/xenial-updates 17.0.7-0ubuntu0.16.04.2 uptodate


(There were also a bunch of lines referring to i386 versions not being
installed; I deleted these to save space.)

So it would seem that you need to do at least:

sudo apt-get install libegl1-mesa
sudo apt-get install libegl1-mesa-dev

Doing this may result in the other bumff that is referred to getting 
installed automatically.  Try it and see if it works.  If not, keep 
doing the sudo apt-get install thing to the other bits and pieces until 
it does work.


Hope this helps; kind of a case of the blind leading the blind, but I 
*think* this should get you going with rgl.


cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276




* installing *source* package ‘rgl’ ...checking for gcc... gcc -std=gnu99
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc -std=gnu99 accepts -g... yes
checking for gcc -std=gnu99 option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -std=gnu99 -E
checking for gcc... (cached) gcc -std=gnu99
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc -std=gnu99 accepts -g... (cached) yes
checking for gcc -std=gnu99 option to accept ISO C89... (cached) none 
needed

checking for libpng-config... yes
configure: using libpng-config
configure: using libpng dynamic linkage
checking for X... libraries , headers
checking GL/gl.h usability... yes
checking GL/gl.h presence... yes
checking for GL/gl.h... yes
checking GL/glu.h usability... yes
checking GL/glu.h presence... yes
checking for GL/glu.h... yes
checking for glEnd in -lGL... noconfigure: error: missing required
library GLERROR: configuration failed for package ‘rgl’* removing
‘/data/R/lib/rgl’Warning in install.packages :
   installation of package ‘rgl’ had non-zero exit status

Checking the system dependencies based on README..

system('dpkg -l |grep  libgl1')ii  libgl1-mesa-dev
   10.1.3-0ubuntu0.6   amd64    free
implementation of the OpenGL API -- GLX development files

system('dpkg -l |grep  libglu1')ii  
libglu1-mesa:amd64
9.0.0-2 amd64    Mesa OpenGL 
utility library (GLU)

ii  libglu1-mesa-dev  9.0.0-2
    amd64    Mesa OpenGL utility library -- development
files

system('dpkg -l |grep  libpng')ii  
libpng12-0:amd64  
1.2.50-1ubuntu2.14.04.2 amd64    PNG library - 
runtime

ii  libpng12-dev  1.2.50-1ubuntu2.14.04.2
    amd64    PNG library - development

I also tried installing .. using the following command..
install.packages("rgl",dep=T,
INSTALL_opts="--no-multiarch",
configure.args=c(rgl="--with-gl-includes=/usr/include/GL"))


__
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] [FORGED] Re: R vs PYTHON vs SAS vs SPSS?

2017-12-01 Thread Rolf Turner


On 01/12/17 20:33, Hasan Diwan wrote:


Yes.


Very true.  But some *thinking* is required; that often proves to be a 
formidable stumbling block.


cheers,

Rolf Turner



On 30 November 2017 at 22:28,  wrote:


I am a mature learner; 3 masters
some doctoral work “ statistics for social sciences; psychological
statistics “
worked in spss and sas 2005 – 2006
now have forgotten ; relearning
my question is this can I do everything in R and Python and SAS studio
that I did in SPSS and the paid variation of SAS we used in doctoral
statistics class?
Can I do in Stat in R or Python or SAS studio
everything I need to do in multiple regression; ANOVA; ANCOVA etc
?
that I did/was starting to do in SPSS?


__
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] OT -- isotonic regression subject to bound constraints.

2017-12-11 Thread Rolf Turner


Well, I could argue that it's not *completely* OT since my question is 
motivated by an enquiry that I received in respect of a CRAN package 
"Iso" that I wrote and maintain.


The question is this:  Given observations y_1, ..., y_n, what is the 
solution to the problem:


  minimise \sum_{i=1}^n (y_i - y_i^*)^2

with respect to y_1^*, ..., y_n^* subject to the "isotonic" constraint
y_1^* <= y_2^* <= ... <= y_n^* and the *additional8 bound constraint
a <= y_1^* and y_n^* <= b, where a and b are given constants?

I have googled around a bit (unsuccessfully) and have asked this 
question on crossvalidated a couple of days ago, with no response whatever.


So I thought that I might try the super-knowledgeable R community, in 
the hope that someone out there might be able to tell me something useful.


Note that the question can be expressed as finding the projection of the 
point (y_1, ..., y_n) onto the intersection of the isotonic cone and

the hypercube [a,b]^n.

At first I thought that protecting onto the isotonic cone and then 
projection that result onto the hypercube might work, but I am now 
pretty sure that is hopelessly naive.


Any hints?  Ta.

cheers,

Rolf Turner


--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] OT -- isotonic regression subject to bound constraints.

2017-12-11 Thread Rolf Turner

On 12/12/17 07:15, Rolf Turner wrote:


Well, I could argue that it's not *completely* OT since my question is 
motivated by an enquiry that I received in respect of a CRAN package 
"Iso" that I wrote and maintain.


The question is this:  Given observations y_1, ..., y_n, what is the 
solution to the problem:


   minimise \sum_{i=1}^n (y_i - y_i^*)^2

with respect to y_1^*, ..., y_n^* subject to the "isotonic" constraint
y_1^* <= y_2^* <= ... <= y_n^* and the *additional8 bound constraint
a <= y_1^* and y_n^* <= b, where a and b are given constants?




Scrub that question!  *Just* after I sent it (wouldn't you know!) I got 
an email from my original enquirer telling me that he'd found the 
solution in the package OrdMonReg on CRAN.


Sorry for the noise.

cheers,

Rolf Turner


--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] something weird has happened....!!!!!!!!!!

2017-12-15 Thread Rolf Turner

On 16/12/17 01:45, akshay kulkarni wrote:

dear Members,



Today something weird has happened on my R console. I have attached two 
screenshots of the same vector in my R console but they differ.


Also one of my function returns negative values, even after double checking the 
code, which should return only positive values..


Whats wrong..? 


How on earth could anyone possibly tell on the basis of the (opaque) 
pseudo-information that you have given us?



Reinstall R?


It is possible, but *highly unlikely* that this is what you should do.

As I said, it's impossible to suggest what you really should do unless 
you provide some genuine information.


Few members of this list are telepathic.  I certainly am not.

cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] Discrete valued time series data sets.

2018-01-01 Thread Rolf Turner


I am looking for (publicly available) examples of discrete valued time 
series data sets.  I have googled around a bit and have found lots of 
articles and books on discrete valued time series, but have had no 
success in locating sites at which data are available.


Can anyone make any useful suggestions?

Thanks.

cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] Discrete valued time series data sets.

2018-01-02 Thread Rolf Turner

On 03/01/18 06:04, Eric Berger wrote:

Hi Rolf,
I looked at 
https://docs.microsoft.com/en-us/azure/sql-database/sql-database-public-data-sets


One of the first sets in the list is the airline time series (I think it 
is also used in dplyr examples).


https://www.transtats.bts.gov/OT_Delay/OT_DelayCause1.asp

You might find other possibilities in that list.


Thanks Eric.  That site looks very useful.

cheers,

Rolf

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] Discrete valued time series data sets.

2018-01-02 Thread Rolf Turner

On 03/01/18 10:55, Achim Zeileis wrote:
The "tscount" package (see http://doi.org/10.18637/jss.v082.i05) comes 
with several count data time series. Maybe this is the kind of discrete 
data you were interested in?


Yes, that's very useful.  Thanks.

cheers,

Rolf

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] Error occurring in "emmeans" package for the two data sets I used. Please help.

2018-01-09 Thread Rolf Turner
eough.raimondi.ln, aov(serpulid.ln ~ biofilm))

summary(keough.raimondi.ln.aov,split=keough.contr.list)


Then, I tried to do post hoc analysis using "emmeans" package following
command:
---

emmeans(keough.raimondi.ln.aov, ~ biofilm)


This gives following error:
------
Error in recover_data.call(fcall, delete.response(terms(object)),
object$na.action,  :
   object 'possibly.random' not found
Error in ref_grid(object, ...) :
   Perhaps a 'data' or 'params' argument is needed


Help Needed:
--
On many other data sets and data frame I successfully used "emmeans"
package using the help available in R.

But, for the above two data-sets, I consistently got the same error as
described above.

I do not know what is amiss. Where I am missing or whatever is wrong, I
request the entire R-team to help me to solve above problem.


Well, you don't need the *entire* R-team!!! It probably (in some sense) 
includes millions of people. :-)



Thanking in advance.


Thanks for your thorough and well set out description of the problem.
Your reproducible examples were flawless.

I am not *completely* certain, but this looks to me like a bug in emmeans.

I have therefore taken the liberty of cc-ing this reply to Russell Lenth 
(the maintainer of emmeans) to get his take on the issue.


cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] Re: Revolutions blog: December 2017 roundup

2018-01-09 Thread Rolf Turner


On 10/01/18 07:47, Doran, Harold wrote:


The blog post that the vocal range directs to is *highly* offensive and
off color and in very poo taste to share with this group.


Huh?  And furthermore ???.

cheers,

Rolf

P. S.  Moreover:  "poo taste"!!! :-)

R.


--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] RE: [FORGED] Re: Revolutions blog: December 2017 roundup

2018-01-09 Thread Rolf Turner


On 10/01/18 09:31, Doran, Harold wrote:


It would be better for you to instead read the blog post that
uses extremely derogatory language instead of your silly post below.


I did read it, somewhat cursorily I admit, and saw no derogatory 
language whatever, which is why I was puzzled.


cheers,

Rolf

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] substr gives empty output

2018-01-21 Thread Rolf Turner


On 21/01/18 21:59, Luigi Marongiu wrote:

Dear all,
I have a string, let's say "testing", and I would like to extract in
sequence each letter (character) from it. But when I use substr() I only
properly get the first character, the rest is empty (""). What am I getting
wrong?


What you're getting wrong is failing the read the help for substr(). 
The third argument is "stop", not the length of the substring.



For example, I have this code:




x <- "testing"
k <- nchar(x)
for (i in 1:k) {
   y <- substr(x, i, 1)
   print(y)
}


You want y <- substr(x,i,i).

cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] Re: SE for all levels (including reference) of a factor atfer a GLM

2018-02-15 Thread Rolf Turner


On 16/02/18 15:28, Bert Gunter wrote:


This is really a statistical issue. What do you think the Intercept term
represents? See ?contrasts.

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 )


It's a *little* bit R-ish in that the results depend on the 
parametrisation of the model which by default in R is formed using the 
so-called "treatment" contrasts.


To wander from R into statistics (sorry Bert) the problem arises because
the "usual" parametrisation of the model is the "over-parametrised" form:

Y_ij = mu + beta_i + E_ij (i = 1, ..., I, j = 1, ..., J_i)

where Y_ij is the j-th observation corresponding to the i-th "treatment" 
or group.  (Things get a bit more complicated in "multi-way" models; 
let's not go there.)


The parameter "mu" is the "grand mean" and the "beta_i" are the 
"treatment" effects.


The trouble with this parametrisation is that the parameters are 
meaningless!  (The usual jargon is to say that they are "not estimable",

but "meaningless"  is a more accurate description.)

In order to ascribe unique values to the parameters, one must apply a 
"constraint".  With the "treatment contrasts" the constraint is that

beta_1 = 0.

As a result the mean for the first treatment is mu, that for the second
treatment is mu + beta_2, and so on.

Consequently the SE corresponding to "(Intercept)" is the SE of 
estimated mean for treatment 1.  The SE corresponding to beta_2 is the 
SE of the estimated *difference* between the mean for treatment 2 and 
that for treatment 1, and so on.


Frequently the constraint beta_1 + ...+ beta_I = 0 is used.  This
sort of treats all of the beta_i equally. At this point it gets R-ish 
again. You can impose the foregoing constraint by using either "sum" or 
"Helmert" contrasts.  You can get the "more natural", "fully" (rather 
than "over") parametrised model via the syntax:


g <- glm(a ~ 0 + b, data=df)

or

g <- glm(a ~ b - 1, data=df)

This syntax actually imposes the constraint that mu = 0.

(Here "contrasts" don't get involved --- a bit counterintuitive, that.)

The foregoing expressions will give you estimates labelled "b0", "b1", 
"b2" (nothing labelled "(Intercept)") and these estimate are of the 
treatment means and the SEs are straightforward to interpret.


There *is* a rationale for the use of the over-parametrised model, but I 
won't try to explain it here.  I've raved on long enough.


Marc:  I hope this helps.

cheers,

Rolf

P.S. It is bad form to call a data frame "df" since this is the name of 
the density function for the family of F-distributions.  There are 
circumstances in which such usage can lead to error messages which are 
impossible to interpret, e.g. "object of type 'closure' is not 
subsettable". (!!!)


R.



On Thu, Feb 15, 2018 at 5:27 PM, Marc Girondot via R-help <
r-help@r-project.org> wrote:


Dear R-er,

I try to get the standard error of fitted parameters for factors with a
glm, even the reference one:

a <- runif(100)
b <- sample(x=c("0", "1", "2"), size=100, replace = TRUE)
df <- data.frame(A=a, B=b, stringsAsFactors = FALSE)

g <- glm(a ~ b, data=df)
summary(g)$coefficients

# I don't get SE for the reference factor, here 0:

   Estimate Std. Errort value Pr(>|t|)
(Intercept)  0.50384827 0.05616631  8.9706490 2.236684e-14
b1  -0.03598386 0.07496151 -0.4800311 6.322860e-01
b2   0.03208039 0.07063113  0.4541962 6.507023e-01

# Then I try to change the order of factors, for example:

df$B[df$B=="0"] <- "3"
g <- glm(a ~ b, data=df)
summary(g)$coefficients

By I get the same...

Any idea ?

Thanks

Marc


__
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] deparseDots to get names of all arguments?

2018-02-20 Thread Rolf Turner

On 21/02/18 11:36, Spencer Graves wrote:

Hi, All:


   How can I get the names of all the arguments in dots(...)?


   I'm able to get the name of the first argument but not the second:



deparseDots <- function(...){
   deparse(substitute(...))
}
a <- 1
b <- 2
deparseDots(a, b)
[1] "a"

 >    I'd like to get c('a', 'b').


Does

names(list(...))

do what you want?

cheers,

Rolf

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] Repeated use of dyn.load().

2018-03-01 Thread Rolf Turner


I am working with a function "foo" that explicitly dynamically loads a 
shared object library or "DLL", doing something like dyn.load("bar.so"). 
 This is a debugging exercise so I make changes to the underlying 
Fortran code (yes, I acknowledge that I am a dinosaur) remake the DLL 
"bar.so" and then run foo again.  This is all *without* quitting and 
restarting R.  (I'm going to have to do this a few brazillion times, and

I want the iterations to be as quick as possible.)

This seems to work --- i.e. foo seems to obtain the latest version of 
bar.so.  But have I just been lucky so far?  (I have not experimented 
heavily).


Am I running risks of leading myself down the garden path?  Are there 
Traps for Young (or even Old) Players lurking about?


I would appreciate Wise Counsel.

cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

P. S.:

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

Matrix products: default
BLAS: /usr/local/lib64/R/lib/libRblas.so
LAPACK: /usr/local/lib64/R/lib/libRlapack.so

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

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

other attached packages:
[1] misc_0.0-16

loaded via a namespace (and not attached):
 [1] compiler_3.4.3   deldir_0.1-15Matrix_1.2-10
 [4] spatstat.utils_1.8-0 mgcv_1.8-22  abind_1.4-5
 [7] spatstat.data_1.2-0  spatstat_1.55-0  rpart_4.1-11
[10] nlme_3.1-131 grid_3.4.3   polyclip_1.6-1
[13] lattice_0.20-35  goftest_1.1-1tensor_1.5

__
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] Extracting specified pages from a lattice ("trellis") object.

2018-04-13 Thread Rolf Turner


Suppose that (e.g.) xyplot() returns an object "xxx" with (say) 3 pages.
I would like to extract/plot (print) just one of these pages, e.g.
page 2.

Here's a toy example:

x   <- rep(seq(0,1,length=11),12)
set.seed(42)
y   <- rnorm(3*44)
a   <- rep(letters[1:12],each=11)
dta <- data.frame(x=x,y=y,a=a)
xxx <- xyplot(y~x|a,data=dta,layout=c(2,2))

I would to extract from xxx and print page 2 (the page corresponding to
levels e, f, g and h).

Is there any (simple) way that I can do this?

I've mucked around with update.trellis() and [.trellis, but I cannot 
make head nor tail of the documentation.  The [.trellis method seems to 
work in some situations, but not in others, and since I cannot 
understand what it actually does, I cannot figure out why.


E.g. in my toy example "xxx[5:8]" seems to give me what I want, but in 
the context of my real application a similar construction does not work.


Thanks for any insight.

cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] Extracting specified pages from a lattice ("trellis") object.

2018-04-23 Thread Rolf Turner


On 24/04/18 15:17, Paul Murrell wrote:


Hi

I think the subsetting works by giving you the panels for the 
corresponding levels of the conditioning variable(s).  Note that, if 
there is more than one conditioning variable, you will need more than 
one subsetting index.


For example, taking this plot with two conditioning variables and 12 
panels in total ...


dotplot(variety ~ yield | year * site, data=barley)

... this produces three pages ...

dotplot(variety ~ yield | year * site, data=barley,
     layout=c(2,2))

... and this produces the second page (both panels for the first 
conditioning variable and the third and fourth panels for the second 
conditioning variable) ...


dotplot(variety ~ yield | year * site, data=barley,
     layout=c(2,2))[1:2, 3:4]

Hope that helps.


Hmm.  Thanks Paul.  I may be able to work with that.  But what I really 
wanted was to take


bar <- dotplot(variety ~ yield | year * site, data=barley)

and then do (something like)

foo <- bar[]

so that foo contains only the second page of bar, and then do print(foo)
to get a plot of (just) the second page.  Without re-issuing a 
(modified) plot command.


Is that not at all possible?

cheers,

Rolf.

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] Re: Specifying priors in a multi-response MCMCglmm

2018-05-01 Thread Rolf Turner


On 02/05/18 09:53, Michelle Kline wrote:


Hi Bert,

That was distinctly unhelpful


Not if you actually follow Bert's advice.


and your outward hostility to a field you
obviously don't understand reveals a regrettable level of ignorance.


I didn't see any hostility to any field.  Bert, like many of us, objects 
to people blithely and arrogantly applying possibly deep statistical 
techniques of which they apparently have little understanding, with an 
attitude of "Oh, it's just statistics.  How hard can it be?"


I don't think anyone who knows anything about anything would classify 
Bert as ignorant.



By the way, my research is Anthropology despite my job title.


OK.  Your job title is misleading.  Let's say "in order to avoid 
producing yet more irreproducible anthropological research" then.


cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] Re: NAs produced by integer overflow, but only some time ...

2018-05-09 Thread Rolf Turner


On 10/05/18 02:58, Stefan Th. Gries wrote:


Before responding to Jeff's posting, let me reiterate my question: Why
does a function using m1*m1 produce an integer overflow, but m1^2 does
not?


This was made clear in Jeff's initial response.


As for Jeff's 'response':




Your intemperate reaction to Jeff's response is completely uncalled for. 
 I find Jeff's patience in giving a such a detailed answer to you your 
rather muddled question to be remarkable.


cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] [R-sig-Geo] Help

2018-05-14 Thread Rolf Turner



Please keep your posts "on-list".  You are much more likely to get a 
useful answer that way.  There are many others on the list whose 
knowledge and insight are far greater than mine.


I have therefore cc-ed the list in this reply.

On 14/05/18 21:48, Soufianou Abou wrote:


Thank you for advice, Rolf Turner

My question is as follows:

I'd use maxent to model the potential distribution of cowpea on the 
basis of the only presence data. Indeed, I have acquired a number of 
environmental variables and bioclimatic regarding my area of study. But 
to choose the most contributive variables in the model; I would like to 
make a correlation analysis of these. On this, could you explain to me 
the step by step procedures to follow in R? I would like to say scripts 
for:- compile and call all environmental variables;- run the correlation 
test to select the least correlated ones.


As I said before, I don't think this is the right approach, but I can't 
be sure without knowing more about your data.  I find your description 
to be vague.


How are your data stored?  What information do you have about the 
"distribution of cowpea".  Do you have *points* where cowpea is present 
or more extensive *regions* where it is present?  (And could these 
regions be "considered to be points" on the scale of interest?) How are 
your predictors stored?  Are the values of these predictors known at 
every point of your study area?  Can you show us a bit of your data (use 
the function dput() to include *a small sample* of your data in the body 
of your email).


If you insist on mucking about with correlation and testing, perhaps the 
function cor.test() will give you what you want.  I reiterate however 
that this seems to me to be a wrong approach.


cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] help on the R package Softmaxreg

2018-05-28 Thread Rolf Turner


On 28/05/18 18:13, Vy Ong wrote:


Hello,
Are there anyone knowing about the Softmaxreg R package?


I suspect that the maintainer of softmaxreg (please note the
*lower case* "s") "knows about" this package!



cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] OT --- grammar.

2018-06-24 Thread Rolf Turner



Does/should one say "the degrees of freedom is defined to be" or "the 
degrees of freedom are defined to be"?


Although value of "degrees of freedom" is a single number, the first 
formulation sounds very odd to my ear.


I would like to call upon the collective wisdom of the R community to 
help me decide.


Thanks, and my apologies for the off-topic post.

cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] OT --- grammar.

2018-06-24 Thread Rolf Turner

On 25/06/18 12:03, Bert Gunter wrote:

Ted, et. al.:

Re: "Data is" vs "data are" ... Heh heh!

"This is the kind of arrant pedantry up with which I will not put."
(Attributed to Churchill in one form or another, likely wrongly.)

See here for some semi-authoritative dicussion:

http://www.onlinegrammar.com.au/top-10-grammar-myths-data-is-plural-so-must-take-a-plural-verb/


I beg to differ.  "The data was out of date" sounds just plain stupid to 
my sensitive ears.


It's rather like using the phrase "begs the question" to mean "raises 
the question" or "invites the question" rather than to carry its 
*correct* meaning of "assumes what is to be proved".  The fact that the 
phrase is almost always used in its *incorrect* sense these days, and 
almost never in its *correct* sense, does not diminish the fact that 
those who use it incorrectly are ignorant scumbags!  The language is 
weakened and diminished by the encroachment of incorrect usage.


cheers,

Rolf


--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] Plot multiple time series on a seasonal plot

2018-06-29 Thread Rolf Turner

On 30/06/18 01:41, Jérôme François via R-help wrote:

Dear members,

I would like to plot a second time series (a forecast) to a seasonal plot made 
with function seasonplot() from the package forecast.


Here is a reproducible example:
ts1 <- structure(c(112035, 82, 111015, 109331, 107525, 107749, 111435,
111629, 112462, 112256, 109496, 107917, 108221, 107463, 105960,
103883, 101038, 100056, 101628, 102973, 103371, 102463, 100774,
100718, 100471, 99828, 99365, 98521, 95695, 96443, 96287, 97525,
98293, 98014, 96658, 96736, 96089, 95337, 95382, 92748, 91448,
91560, 92996, 94046, 94128, 93888, 93888, 91091, 91877, 91681,
91045, 89367, 87912), .Tsp = c(2014, 2018.333, 12), class = "ts")

ts2 <- structure(c(87867.2152330971, 89713.0862474283, 89600.565347383,
91066.3196835822, 90523.1926861474, 89322.8025396445, 88771.5545520503,
89247.0913151542, 88803.5578121458, 88060.0948570082, 87015.6578227365,
85785.4121532206), .Tsp = c(2018.417, 2019.333,
12), class = "ts")


library(forecast)seasonplot(ts1, year.labels = TRUE, year.labels.left = TRUE)


How can I add ts2 to the seasonal plot? I would like it to be distinguishable 
from ts1 (e.g. different color).

lines(ts2) doesn't work.
Thank you.



I don't know anything about forecast/seasonplot.  However my experience 
is that par(new=TRUE) usually rescues one in situations like this.


It's a bit shaganappi, but ...

seasonplot(ts1, year.labels = TRUE, year.labels.left = TRUE,
   main="Whatever")
OP <- par(new=TRUE,xaxt="n",yaxt="n")
seasonplot(ts2, col="red",main="")
par(OP)

seems to work.

It would be nice to have an "add=" argument (defaulting to FALSE, of 
course) to seasonplot().


cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] prod(NaN, NA) vs. prod(NA, NaN)

2018-07-03 Thread Rolf Turner



On 04/07/18 00:24, Martin Møller Skarbiniks Pedersen wrote:


Hi,
   I am currently using R v3.4.4 and I just discovered this:


prod(NA, NaN) ; prod(NaN, NA)

[1] NA
[1] NaN

?prod says:
 If ‘na.rm’ is ‘FALSE’ an ‘NA’ value in any of the arguments will
  cause a value of ‘NA’ to be returned, otherwise ‘NA’ values are
  ignored.

So according to the manual-page for prod() NA should be returned in both
cases?


However for sum() is opposite is true:

sum(NA, NaN) ; sum(NaN, NA)

[1] NA
[1] NA

?sum says:
 If ‘na.rm’ is ‘FALSE’ an ‘NA’ or ‘NaN’ value in any of the
  arguments will cause a value of ‘NA’ or ‘NaN’ to be returned,
  otherwise ‘NA’ and ‘NaN’ values are ignored.


Maybe the manual for prod() should say the same as sum() that
both NA and NaN can be returned?


But:

> sum(NA,NaN)
[1] NA
> sum(NaN,NA)
[1] NA

so sum gives NA "both ways around".  Perhaps a slight inconsistency 
here?  I doubt that it's worth losing any sleep over, however.


Interestingly (???):

> NaN*NA
[1] NaN
> NA*NaN
[1] NA
> NaN+NA
[1] NaN
> NA+NaN
[1] NA

So we have an instance of non-commutative arithmetic operations.  And 
sum() is a wee bit inconsistent with "+".


Again I doubt that the implications are all that serious.

cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] Generate N random numbers with a given probability and condition

2018-07-04 Thread Rolf Turner



On 05/07/18 10:21, Nelly Reduan wrote:


Dear all,

I would like to generate N random numbers with a given probability and 
condition but I'm not sure how to do this.
For example, I have N = 20 and the vector from which to choose is seq(0, 10, 
1). I have tested:

x <- sample(seq(0, 10, 1), 20, replace=TRUE, prob=rep(0.28, times=length(seq(0, 
10, 1

But I don�t know how to put the condition sum(x) <= max(seq(0, 10, 1)).
Many thanks for your time.


Your thinking requires considerable clarification.

(1) Note that seq(0,10,1) is just 0, 1, 2, ..., 10.

(2) Hence length(seq(0,10,1)) is 11.

(3) Likewise max(seq(0,10,1)) is 10.

(4) Your prob vector is *constant* --- so specifying "prob" makes
no difference --- the result is the same as if you omitted "prob".

(5) You need to think carefully about what you really mean by "random".
In what way do you want the final result to be "random"?

I expect that the lecturer who assigned this problem to you  needs to 
clarify his/her thinking as well.


cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] Re: Generate N random numbers with a given probability and condition

2018-07-11 Thread Rolf Turner

On 11/07/18 12:46, Jim Lemon wrote:

Hi Nell,
I may not have the right idea about this, but I think you need to do
this in two steps if it can be done. Let's say you want a sequence of
20 (N) numbers between 0 and 10 that sums to 10 (M). You can enumerate
the monotonically increasing sequences like this:

c(0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1)
c(0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,2)
...
c(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10)




Jim:  You should *not* do people's homework for them!

cheers,

Rolf

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] [bug] spdep package?

2018-07-23 Thread Rolf Turner

On 23/07/18 22:30, Jeremie Juste wrote:



Hello,


I found a dangerous issue in the library spdep. I get variables x and y
that cannot be removed by rm() and I don't don't how they show up. Can
anyone reproduce this?


I cannot.

This is *very* unlikely to be a bug.  People should always exercise a 
great deal of caution about conjecturing bugs when they encounter a

phenomenon that they don't understand.

What do you see if you simply do "ls()"?  (After loading spdep.)
I.e. do you see an "x" listed as an object in your workspace/global 
environment?


What does find("x") return?

It puzzles me that your sessionInfo() doesn't show something like:


other attached packages:
[1] spdep_0.6-13  Matrix_1.2-10 sp_1.2-5


There are probably other issues that you have not told us about.

cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276



~$ R --vanilla

rm(list=ls())
library(spdep)
x

[1]   0  30  60  90 120 150 180 210 240 270 300 330 360 390 420 450

rm(list=ls())
x

[1]   0  30  60  90 120 150 180 210 240 270 300 330 360 390 420 450




Sys.info()


sysname"Linux"
release"4.9.0-6-amd64"
version"#1 SMP Debian 4.9.88-1+deb9u1 (2018-05-07)"
nodename   "freegnu"
machine"x86_64"



Session




sessionInfo()


R version 3.4.1 (2017-06-30)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Debian GNU/Linux 9 (stretch)

Matrix products: default
BLAS: /usr/local/lib/R/lib/libRblas.so
LAPACK: /usr/local/lib/R/lib/libRlapack.so

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

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

loaded via a namespace (and not attached):
[1] compiler_3.4.1


__
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] Finding Infimum in R

2017-04-10 Thread Rolf Turner


On 10/04/17 20:57, Boris Steipe wrote:


Are you sure this is trivial? I have the impression the combination
of an ill-posed problem and digital representation of numbers might
just create the illusion that is so.



Fortune nomination.

cheers,

Rolf

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] hier.part limitation

2017-04-10 Thread Rolf Turner

On 10/04/17 21:33, Abdel-Rahman, Elfatih wrote:

Dear all,

Does the package "hier.part" limited to only 12 predictor variables.
I  was trying to use it to partition (select) the most relevant predictor
variables our of 30 ones, and I always get an error message says:
"Error: Number of variables must be < 13 for current implementation"


Uh, why do you suppose that the function puts out that error message?

If you want a function that handles 13 or more variables you'll have to 
write it yourself.


cheers,

Rolf Turner

P. S. I have no knowledge whatever of hier.part(), so I have no insight 
as to why that restriction is there, but I imagine there's a good 
reason, for some value of "good".


R. T.

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] Setting .Rprofile for RStudio on a Windows 7 x64bit

2017-04-15 Thread Rolf Turner

On 16/04/17 07:57, BR_email wrote:

Boris:
As before, you assume that I, Bruce Ratner, just asks questions without
first trying it myself.
FYI: I purchased and read four RStudio books, as well as all the links I
found in the web.
I will not take your maligning me.
Please try to assist me, but do not bully me.
Bruce Ratner, Ph.D.


Bruce, you are being preciously hypersensitive.  Boris's comment was 
completely appropriate and betrayed not the slightest trace of 
"bullying".  If you had indeed done your homework in the manner that 
Boris recommended you would had no need to clutter this mailing list 
with your (off-topic) question.


cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] Setting .Rprofile for RStudio on a Windows 7 x64bit

2017-04-16 Thread Rolf Turner


On 17/04/17 08:46, John C Frain wrote:


Bruce

The official documentation for these startup files can be obtained with
the command

Help(Startup)



Minor point of order, Mr. Chairman.  That should be:

help(Startup)

There is (as far as I know) no such function as "Help()".  It is 
important to remember that R is case sensitive.


Another point that is worthy of thought is "How in God's name would any 
beginner know or find out about the usage help(Startup)?"  Unless they 
were explicitly told about it, in the manner which you just 
demonstrated.  The usage gets a mention in "An Introduction to R" --- 
but I had to search for it.


To me the word "startup" is not terribly intuitive.  I would tend to 
search for "starting" rather than "startup", I think, but I'm not sure 
what the average beginner would search for.  A search of "An 
Introduction to R" for "starting" gets seven or eight hits, one of which 
is relevant.  So it all takes patience and persistence.


Also note that "An Introduction to R" mostly uses the word "startup" 
(lower case "s") and only uses "Startup" twice.  Note also that


help(startup)

fails.  You have to get that initial "S" right.

This isn't a criticism of the documentation.  I'm just pointing out that 
there are problems, mostly insoluble.  Until some clever Johnny gets on 
with developing that mind_read() function referred to in fortune(182).


cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] Unknown anomaly

2017-04-18 Thread Rolf Turner

On 19/04/17 13:55, Benjamin Robira wrote:

Dear Sir,

I writting to you as I am facing an irregularity in R that I do not know
the origin. When doing a sequence from 0 to 1 by 0.02 and assigning it to
a vector (i.e. code: a <- seq(from=0, to=1, by=0.02)) then, when I try to
use the 36th element (and two others behave the same way) it is not
recognized correctly. For instance a[36]==0.7, what should give TRUE,
gives instead FALSE. However, this works fine for element 35 and 37 and
all other elements but two.
I do not know the reason. I restarted my R session and tried on another
computer. This has been the same. None of my colleagues had an answer. I
hope that you would be able to help me fix that as it must be a pretty
straightforward error that I do not realise.

I would be thankful for any help.



See FAQ 7.31.

cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] A new -up?

2017-04-19 Thread Rolf Turner


Now that this mailing list seems to have managed to eliminate the malign 
influence of nabble, some clever Johnny seems to have come up with a new 
way to cloud the lines of communication.  I have started receiving 
r-help emails from r-help-arch...@googlegroups.com.  It seems
that one cannot reply to this address --- at least I can't.  I tried a 
couple of times and got bounces.


However I just received from r-help@r-project.org a reply by Jeff 
Newmiller to one of the posts that I received  via "r-help-archive".  So 
it seems that *Jeff* can reply to these things.


So am I doing something wrong, or is "r-help-archive" messing things up 
for other people as well?  And if the latter, can something be done to 
remove its malign influence?


cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] A new -up?

2017-04-19 Thread Rolf Turner


On 19/04/17 20:01, peter dalgaard wrote:


I believe that the list maintainer is hunting this down. As I
understood it, it was more due to incompetence than to actual malice.


Years ago I ran across an aphorism that very much appealed to me: 
"Never attribute to malice that which may be adequately explained by 
stupidity."


More recently I saw the same sentiment, expressed only slightly 
differently, in someone's signature file --- can't remember whose.


cheers,

Rolf

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] Bug in the triMat( ) function in the deldir package.

2017-04-22 Thread Rolf Turner


Yesterday Jay Call drew to my attention the fact that the triMat() 
function was giving wrong answers in some instances.  Wrong answers 
occur if the union of three contiguous Delaunay triangles happens to 
constitute another triangle.  This latter triangle appeared in the list 
of triangles produced by triMat() but is *not* itself a Delaunay 
triangle (and hence should not appear in the list).


I have swatted this bug (at least I think/hope that I have!) and have 
uploaded a revised version of deldir (version 0.1-14) to CRAN.  The 
revision contains other amendments and innovations in addition to this 
bug fix.


If you have in the past used triMat(), you should check your results 
from that usage against those produced by the triMat() function from the 
revised version.


Sorry 'bout that.

cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] missing and replace

2017-04-26 Thread Rolf Turner

On 27/04/17 12:45, Val wrote:

HI all,

I have a data frame with three variables. Some of the variables do
have missing values and I want to replace those missing values
(1represented by NA) with the mean value of that variable. In this
sample data,  variable z and y do have missing values. The mean value
of y  and z are152. 25  and 359.5, respectively . I want replace those
missing values  by the respective mean value ( rounded to the nearest
whole number).

DF1 <- read.table(header=TRUE, text='ID1 x y z
1  25  122352
2  30  135376
3  40   NA350
4  26  157NA
5  60  195360')
mean x= 36.2
mean y=152.25
mean z= 359.5

output
ID1  x  y  z
1   25 122   352
2   30 135   376
3   40 152   350
4   26 157   360
5   60 195   360


This is pretty basic.  You really ought to learn a bit more about R if 
you are going to use R.  That being said, try:


newDF1 <- as.data.frame(lapply(DF1,function(x){
x[is.na(x)] <- mean(x,na.rm=TRUE)
x}))

There may be sexier ways of accomplishing your goal, but this should work.

cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] Re: How create columns for squared values from previous columns?

2017-04-28 Thread Rolf Turner

On 29/04/17 13:21, C W wrote:

I came up with this solution,


cbind(dat, dat[, 1:3]^2)

   X1 X2 X3 X4  X5  X1
X2X3
1  0.72776481 -1.1332612 -1.9857503 0.46189400 -0.09016379 0.529641625
1.28428102 3.9432044
2  0.05126592  0.2858707  0.9075806 1.27582713 -0.49438507 0.002628194
0.08172203 0.8237026
3 -0.40430146  0.5457195 -1.1924042 0.15025594  1.99710475 0.163459669
0.29780978 1.4218277
4  1.40746971 -1.2279416  0.3296075 0.84411774 -0.52371619 1.980970990
1.50784058 0.1086411
5 -0.53841150  0.4750082 -0.4705148 0.05591914 -0.31503500 0.289886944
0.22563275 0.2213842
6  0.90691210  0.7247171  0.8244184 0.73328097 -1.05284737 0.822489552
0.52521494 0.6796657

But, you would NOT ONLY get undesired variable names, BUT ALSO duplicated
names. I suppose I can use paste() to solve that?

Any better ideas?


Well, if the names bizzo is your only worry, you could hit the result 
with data.frame() *after* cbinding on the squared terms:


dat <- matrix(rnorm(30),ncol=5)
dat <- cbind(dat,dat[,1:3]^2)
dat <- data.frame(dat)
names(dat)

And as you indicate, the names of a data frame are easily adjusted.

I wouldn't lose sleep over it.

cheers,

Rolf Turner

P.S. You could also do

names(dat) <- make.unique(names(dat))

to your original idea, to get rid of the lack of uniqueness.  The result 
is probably "undesirable" but.


R. T.

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] Re: display double dot over character in plotmath?

2017-05-13 Thread Rolf Turner

On 14/05/17 06:10, David Winsemius wrote:



On May 13, 2017, at 5:47 AM, Ranjan Maitra  wrote:

On Fri, 12 May 2017 23:39:14 -0700 Daniel Nordlund  wrote:


On 5/12/17 4:55 PM, Ranjan Maitra wrote:

Hi,

Is it possible to display double dot (umlaut) over a character such as would be 
possible using \ddot x in LaTeX? I can do this using tikzDevice but I wanted 
something simpler to point to.

Here is an example of what I would like to do, but it is not quite there:

require(ggplot2)
data<-as.data.frame(c("a","b","c","a","b","c"))
colnames(data)<-"Y"
data$X<-c(1:6)
data$Z<-c(1,2,3,1,2,3)

ggplot(data, aes(x=X)) + geom_line(aes(y = Z), size=0.43) + 
xlab(expression(atop(top,bold(Age~"à"

I would like to put in a double dot over the "a" in the x-axis instead of "`".

Many thanks for any suggestions and best wishes,
Ranjan



You haven't told what OS you are using, but with Windows OS, you can get
the 'ä' by making sure the NUMLOCK key is on, hold down the alt key and
press 0228 on the numeric keypad.




I am sorry, I use a linux operating system. I use Fedora 25 but the student I 
wanted to show this uses Ubuntu, though I don't know if the distribution 
matters.


On a Mac it is cmd-u followed by the vowel of your choice. Perhaps you should 
do a google search on the topic of getting umlauted characters for the distro 
of your choice?



Well, Linux is not Mac.  For which I am everlastingly thankful.

I believe the following works on both Fedora and Ubuntu:

(1) First add/set a "compose" key:

In my current system (Ubuntu 16.04.2; Mate Desktop 1.12.1) the sequence 
of clicks is:


System -> Control Center -> Keyboard -> Layouts -> Options
   -> Position of Compose key -> [e.g.] Left Win

Clicking on "Left Win" inserts a tick mark in the little white box.  On 
my keyboard the "Left Win" key is to the left of the "Alt" key, which is 
to the left of the space bar.  It displays the (yeuchh!!!) Windoze 
symbol, a distorted window in black and white.  This key is totally 
useless for anything else, so one might as well use it for the compose key.


(2) Then do:   .  E.g

'  a " ' gives  ' ä '.

Note: Do *not* hold the compose key down while pressing the other
keys.  Press the compose key and release it; then press "a" (nothing
appears) then press ' " ' --- and bingo, ä appears.

HTH

cheers,

Rolf Turner

P. S.  Of course you just need to do the "set a compose key" bizzo 
*once* and then it is set and works forever more.  Until you change or 
bugger up your OS. :-)


R. T.

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] p-value=0 running log-rank test

2017-05-18 Thread Rolf Turner


This is not an R question.

Your question indicates that you really need to learn some statistics.

To answer the very last part:

> pchisq(430,3,lower=FALSE)
[1] 7.020486e-93

And if that is not 0 to all intents and purposes, then God help us all.

cheers,

Rolf Turner

On 19/05/17 12:48, Anne Karin da Mota Borges wrote:

Dear all,

I have a question concerning the p-value. When running log-rank test I get
a p-value = 0.
What is it mean? Can this be true? Why aren´t there decimal points? Is
there a way to find out the exact p-value?

Here is the output:


survdiff(Surv(tempo2,status)~tphist, data=base,rho=0)

Call:
survdiff(formula = Surv(tempo2, status) ~ tphist, data = base,
rho = 0)

   N Observed Expected (O-E)^2/E (O-E)^2/V
tphist=1 513   19   40.87911.710  9.00e+01
tphist=2  4943.892 0.003  3.27e-03
tphist=3  2391.68631.717  3.29e+01
tphist=4  18   150.543   385.172  3.91e+02

 Chisq= 430  on 3 degrees of freedom, p= 0

Thank you in advance.


__
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] [FORGED] Logical Operators' inconsistent Behavior

2017-05-19 Thread Rolf Turner


On 19/05/17 21:48, Ramnik Bansal wrote:


Hi,

I need to understand the inconsistent behaviour of & and I operators when
used with NA.

The code below explains this inconsistency


TRUE & NA

[1] NA


FALSE & NA

[1] FALSE


TRUE & NA

[1] NA


FALSE | NA

[1] NA


TRUE | NA

[1] TRUE


TRUE == NA

[1] NA


FALSE == NA

[1] NA


What inconsistency?  It all makes complete sense.  Think about it.

TRUE & FALSE is FALSE but TRUE & TRUE is TRUE, so TRUE & NA could be
either TRUE or FALSE and consequently is NA.

OTOH FALSE & (anything) is FALSE so FALSE & NA is FALSE.

Und so weiter.

As I said *think* about it; don't just go with your immediate knee-jerk 
(simplistic) reaction.


cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] Logical Operators' inconsistent Behavior

2017-05-19 Thread Rolf Turner

On 19/05/17 23:38, S Ellison wrote:

TRUE & FALSE is FALSE but TRUE & TRUE is TRUE, so TRUE & NA could be
either TRUE or FALSE and consequently is NA.

OTOH FALSE & (anything) is FALSE so FALSE & NA is FALSE.

As I said *think* about it; don't just go with your immediate knee-jerk
(simplistic) reaction.


Hmm... not sure that was quite fair to the OP.


The OP complained that the logical operators in R are inconsistent. 
This is an arrogant and presumptuous assertion that deserves a 
reprimand.  One should be very, very circumspect about presuming to know 
better than R.



Yes, FALSE &
== FALSE. But 'NA' does not mean 'anything'; it means 'missing' (see
?'NA').


Well, duh.  Yes, I know what NA means.  If it's missing, you don't know 
what it's value is.  But it doesn't *matter* what its value is; FALSE &

 is FALSE.  So FALSE & NA is FALSE, irrespective of what NA
"really" is.


It is much less obvious that FALSE &  should generate a
non-missing value. SQL, for example, generally takes the view that any
expression involving 'missing' is 'missing'.


Well, then SQL gets it wrong.


And R's behaviour can look odd if the vagaries of real data intervene:
b1 <- c(A=TRUE, C=FALSE)
b2 <- c(A=FALSE, B=FALSE, C=TRUE)
b1['B'] & b2['B']
#Which returns
# 
# FALSE

which - particularly since it appears without warning 


Everything appears without warning.  Nobody expected the Spanish 
Inquisition.



 - is not an obviously sensible outcome.


Why not?  It's obviously sensible to me, and to anyone else who is 
thinking.  Since b1['B'] is NA (b1 doesn't have an entry named 'B') and 
b2['B'] is FALSE we get NA & FALSE which is FALSE.  Where's the problem?


The "" in the output that you show is the *name* of the 'B' entry of 
b1, and since there isn't one, it doesn't have a name.  So the name is 
missing whence it is rendered as "" (missing character).



I am not suggesting a change to R's logical operations, which have
clearly been thought through (that is evident from NA&FALSE ==
FALSE&NA == FALSE). But R's behaviour looks to me like a choice among
difficult alternatives, rather than the only possible choice. I'd
give the OP some credit for that.


You seem to be arguing for the sake of arguing.  It's really quite 
straightforward *if* you *think* about it.


cheers,

Rolf

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] Logical Operators' inconsistent Behavior

2017-05-19 Thread Rolf Turner

On 20/05/17 00:01, Jérémie Juste wrote:

Hello,

Rolf said,

TRUE & FALSE is FALSE but TRUE & TRUE is TRUE, so TRUE & NA could be
either TRUE or FALSE and consequently is NA.

OTOH FALSE & (anything) is FALSE so FALSE & NA is FALSE.


According to this logic why is

FALSE & NA

[1] FALSE


Huh????

cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] Re: [FORGED] Logical Operators' inconsistent Behavior

2017-05-20 Thread Rolf Turner

On 20/05/17 22:18, Duncan Murdoch wrote:

On 20/05/2017 5:53 AM, Martin Maechler wrote:

Ramnik Bansal 
on Sat, 20 May 2017 08:52:55 +0530 writes:


> Taking this question further.
> If I use a complex number or a numeric as an operand in logical
> operations, to me it APPEARS that these two types are first
coerced to
> LOGICAL internally and then THIS logical output is further used
as the
> operand.

> For eg.
>> x <- 4+5i; c(x & F, x & T, x | F, x | T)
> [1] FALSE  TRUE  TRUE  TRUE

> This output is consistent with
>> x <- 4+5i; c(as.logical(x) & F, as.logical(x) & T,
as.logical(x) | F, as.logical(x) | T)
> [1] FALSE  TRUE  TRUE  TRUE

> This consistency makes me draw an on-the-surface conclusion that in
> the case of logical operations if the operand is not of type
'logical'
> it is first coerced into 'logical'.

That conclusion is wrong as you show below.
Rather, as the error message says,
logical
"operations are possible only for numeric, logical or complex types"

Again:

1) Logical/Arithmetic  operations "work" with "numeric-like" types,
namely
  numeric, logical or complex, (and numeric = {integer, double})

  ==> all other types give an error (the one you've cited twice)

2) For "numeric-like" types and *logical* operations (&, |, !; plus &&
and ||)
   the equivalent of as.logical() is applied before performing the Op.

Seems pretty consistent ...
and also according to the principle of "least surprise" (for me at
least).



The surprise is that as.logical("TRUE") returns TRUE, whereas automatic
coercion doesn't apply to character strings.  I don't think we should
change this, but it is an inconsistency.  (We could perhaps mention it
in the ?logical help page.)



Actually it *is* mentioned.  From ?logical:


Character strings c("T", "TRUE", "True", "true") are regarded as
true,  c("F", "FALSE", "False", "false") as false, and all others as NA.


cheers,

Rolf

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] Re: [FORGED] Logical Operators' inconsistent Behavior

2017-05-20 Thread Rolf Turner

On 20/05/17 22:42, Duncan Murdoch wrote:

On 20/05/2017 6:39 AM, Rolf Turner wrote:

On 20/05/17 22:18, Duncan Murdoch wrote:

On 20/05/2017 5:53 AM, Martin Maechler wrote:

Ramnik Bansal 
on Sat, 20 May 2017 08:52:55 +0530 writes:


> Taking this question further.
> If I use a complex number or a numeric as an operand in logical
> operations, to me it APPEARS that these two types are first
coerced to
> LOGICAL internally and then THIS logical output is further used
as the
> operand.

> For eg.
>> x <- 4+5i; c(x & F, x & T, x | F, x | T)
> [1] FALSE  TRUE  TRUE  TRUE

> This output is consistent with
>> x <- 4+5i; c(as.logical(x) & F, as.logical(x) & T,
as.logical(x) | F, as.logical(x) | T)
> [1] FALSE  TRUE  TRUE  TRUE

> This consistency makes me draw an on-the-surface conclusion
that in
> the case of logical operations if the operand is not of type
'logical'
> it is first coerced into 'logical'.

That conclusion is wrong as you show below.
Rather, as the error message says,
logical
"operations are possible only for numeric, logical or complex
types"

Again:

1) Logical/Arithmetic  operations "work" with "numeric-like" types,
namely
  numeric, logical or complex, (and numeric = {integer, double})

  ==> all other types give an error (the one you've cited twice)

2) For "numeric-like" types and *logical* operations (&, |, !; plus &&
and ||)
   the equivalent of as.logical() is applied before performing the Op.

Seems pretty consistent ...
and also according to the principle of "least surprise" (for me at
least).



The surprise is that as.logical("TRUE") returns TRUE, whereas automatic
coercion doesn't apply to character strings.  I don't think we should
change this, but it is an inconsistency.  (We could perhaps mention it
in the ?logical help page.)



Actually it *is* mentioned.  From ?logical:


Character strings c("T", "TRUE", "True", "true") are regarded as
true,  c("F", "FALSE", "False", "false") as false, and all others as NA.




I meant that the negative part should be mentioned:  this only works
with an explicit as.logical(), not with implicit coercion.


Ah, I see.  I missed the point.

cheers,

Rolf

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] Re: Fwd: Rpart help

2017-05-23 Thread Rolf Turner


On 24/05/17 14:38, Bert Gunter wrote:


Forget Excel. Erase it from your memory. banish its paradigms from
your practices. Faiing to do so will only bring misery as you explore
R. R is a rational programming language primarily for data analysis,
statistics, and graphics. Excel is, ummm, not.


Gotta be a fortune!!!

cheers,

Rolf

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] Re: Rpart help

2017-05-24 Thread Rolf Turner

On 24/05/17 20:30, peter dalgaard wrote:




And, never mind Bert's rant, a simple table(single_order, churn)
would give info similar to what you claim to have from Excel, minus
the risk of finding that the data are not the same, or that Excel was
doing something bizarre.




Bert?  Rant?  Perish the thought!!! :-)

cheers,

Rolf

P. S.  My thunderbird spell-checker suggests "laggard" as an alternative 
for the unrecognised "dalgaard".  :-)


R.


--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] Need Help - R Programming - Using iteration value to change field names for processing for every iteraion

2017-05-30 Thread Rolf Turner

On 30/05/17 19:02, Vijaya Kumar Regati wrote:

Hi,

I am new to R programming, I am trying to work on below requirement. But could 
not achieve desired result.
Appreciate if someone can help me on this :

test dataframe :
   Day1.balc Day2.balc Day3.balc Day4.balc
x   100203040
y   100101010

class(test)

[1] "data.frame"

My Goal is to accomplish :
Day2.balc <- Day2.balc + Day1.balc
Day3.balc <- Day3.balc + Day2.balc
.
.
.
Day30.balc <- Day30.balc + Day29.balc

 # Testing for first 4 days
 for (i in 1:4 ) {
 test$Day[i].balc <- test$Day[i].balc + test$Day[i-1].balc
 }

I identified the line I have written inside the loop is not the correct one, 
can someone help me how I can use iteration value(i), for every iteration, as a 
basis for changing field names since field consists of 1,2,3... for each 
different day( Day1.balc Day2.balc Day3.balc Day4.balc etc.,).


(1) Learn some R (read "An Introduction to R" from the R web page; 
manuals).  Don't use iteration when you don't need to; i.e. use 
vectorised operations whenever possible.  (Much faster and clearer.)


(2) Distinguish between data frames and matrices; they are *NOT* the 
same thing!  What you need here are matrices.


(3) I think this will work for you:

M <- as.matrix(test)
    Mnew <- cbind(0,M[,-ncol(M)]) + M

cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] deviance in GLM vs. summary.glm

2017-05-31 Thread Rolf Turner

On 31/05/17 16:53, array chip via R-help wrote:

Hi, I am running a logistic regression on a simple dataset (attached) using glm:

dat<-read.table("dat.txt",sep='\t',header=T)

If I use summary() on a logistic model:

summary(glm(y~x1*x2,dat,family='binomial'))

Coefficients:Estimate Std. Error z value Pr(>|z|)(Intercept)
19.575377.01   0.0040.997x1-18.595377.01  -0.003
0.997x2B   -19.575377.01  -0.0040.997x1:x2B 38.15
7604.24   0.0050.996
As you can see, the interaction term is very insignificant (p = 0.996)!
But if I use a anova() to compare a full vs reduced model to evaluate the 
interaction term:

anova(glm(y~x1+x2,dat,family='binomial'), 
glm(y~x1*x2,dat,family='binomial'))Analysis of Deviance Table

Model 1: y ~ x1 + x2Model 2: y ~ x1 * x2  Resid. Df Resid. Dev Df Deviance1 
   22 27.067221 21.209  1   5.8579
This follows a chi-square distribution with 1 df, so the corresponding p value 
is:

1-pchisq(5.8679,1)[1] 0.01541944

So I get very different p value on the interaction term, can someone share 
what's going wrong here?


(1) To re-emphasize Berwin Turlach's exhortation, ***PLEASE*** do not 
post in html; your results are nearly impossible to read.


(2) To add a tiny bit to Berwin's comments:

There is something a bit weird about your data; note that if you look at 
the fitted values from your fit, you get only *three* distinct values 
--- whereas there should be four, since there are four distinct
treatment combinations, (0,A), (0,B), (1,A) and (1,B).  And all possible 
treatment combinations do indeed occur.


The deficiency occurs because the last three of your coefficients (the 
non-intercept terms) sum to (effectively) 0.  Thus you get the same 
fitted value from the (1,B) combination as from the (0,A) combination.


It is not clear to me what the implications of all this are --- 
particularly since it's getting on for my bed time :-) --- but it seems 
clear that this sort of "degeneracy" is going to mess things up.
And perhaps contribute to the Hauck-Donner effect that Berwin told you 
about.


I would also advise you to try experimenting with simulated data.  (When 
in doubt, simulate.  Even when not in doubt, simulate.  That is my 
guiding principle.)  I.e. try to simulate y-values from a coefficient 
vector that does not suffer from the "degeneracy", fit a model to the 
simulated y-values, and compare the two tests.  They still won't agree, 
but they will (surely?) be less wildly discrepant.


cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] Re: Question on function "scatterplot3d"

2017-05-31 Thread Rolf Turner

On 01/06/17 13:17, Ismail SEZEN wrote:



On 1 Jun 2017, at 03:41, li li  wrote:

Hi all,
  I have a question with regard to making plots using function
"scatterplot3d".
Please see the example below. It looks like, for y axis, the tickmark text
was cutoff.
The number "10" does not show up completely. I tried to work with par(mpg).
It does not
seem to work. Hope to get some advice here. Thanks much!
   Hanna

C <- runif(30)
B <- rep(1:3, each=10)
A <- rep(1:10,3)
scatterplot3d(B,A,C, type = "h", lwd = 1, pch = 16, color="red",  main =
"",
  grid=TRUE,  col.grid="lightgreen",
  xlab="x", ylab="y", zlab="z”)


Everything seems ok to me. Try to reset/clear all plots in your plotting window 
and try only to run the code above. Perhaps You changed par settings before in 
some point?



I tried the code given above, and after I replaced the deleted> incorrect double quote mark (after the final "z"), it ran and 
looked OK *except* for the positioning of the "y" axis label, which is 
at the "far end" of the y-axis rather than being at the "centre" of the 
y-axis.  (See attached.)


Is this a bug?

cheers,

Rolf Turner

P.S. I have also attached the code in the file "scatScript.txt", for 
convenience.


P^2. S.:

> sessionInfo()
R Under development (unstable) (2017-04-21 r72585)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.2 LTS

Matrix products: default
BLAS: /usr/local/lib/R/lib/libRblas.so
LAPACK: /usr/local/lib/R/lib/libRlapack.so

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

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

other attached packages:
[1] scatterplot3d_0.3-40 misc_0.0-16

loaded via a namespace (and not attached):
 [1] compiler_3.5.0   deldir_0.1-15Matrix_1.2-8
 [4] spatstat.utils_1.4-1 tools_3.5.0  mgcv_1.8-17
 [7] abind_1.4-5  spatstat_1.50-0  rpart_4.1-11
[10] nlme_3.1-131 grid_3.5.0   polyclip_1.6-1
[13] lattice_0.20-35  goftest_1.1-1tensor_1.5

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276


scat.pdf
Description: Adobe PDF document
library(scatterplot3d)
set.seed(42)
C <- runif(30)
B <- rep(1:3, each=10)
A <- rep(1:10,3)
scatterplot3d(B,A,C, type = "h", lwd = 1, pch = 16, color="red",
  main = "", grid=TRUE,  col.grid="lightgreen",
  xlab="x", ylab="y", zlab="z")

__
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] [FORGED] Re: Question on function "scatterplot3d"

2017-06-01 Thread Rolf Turner

On 01/06/17 19:54, Uwe Ligges wrote:
A design flaw, whether the labels are cut depends somewhat on the sizce 
of the device, hence there is the argument


y.margin.add

add additional space between tick mark labels and axis label of the y axis

for working around that limittation that can be set to some positive 
value



This seems to be addressing Hannah's (li li's) original enquiry, not my 
follow-up in which I worried about the position, along the y-axis, of 
the y-axis label.


Or am I misunderstanding/missing something?

cheers,

Rolf

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] Re: Question on function "scatterplot3d"

2017-06-01 Thread Rolf Turner

On 02/06/17 03:02, Uwe Ligges wrote:



On 01.06.2017 10:03, Rolf Turner wrote:

On 01/06/17 19:54, Uwe Ligges wrote:
A design flaw, whether the labels are cut depends somewhat on the 
sizce of the device, hence there is the argument


y.margin.add

add additional space between tick mark labels and axis label of the y 
axis


for working around that limittation that can be set to some positive 
value



This seems to be addressing Hannah's (li li's) original enquiry, not 
my follow-up in which I worried about the position, along the y-axis, 
of the y-axis label.


Ah, that is intended as a smart way of rotating it along the axis is not 
easy (if not impossible) with the bas egraohics system.


OK.  Fair enuff.  Thanks.

cheers,

Rolf

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [spatstat] Convert shapefile to pixel image

2017-06-01 Thread Rolf Turner


On 02/06/17 01:17, lluis.hurt...@uv.es wrote:


Dear all,

I am currently working with the spatstat package, using windows and pixel 
images.

First:

My aim is to transform a shapefile (see attached) into a pixel image.

My idea is to start transforming the shapefile into a Spatial Polygon file:

x <- readShapeSpatial("21441.shp")
y <- as(x, "SpatialPolygons")
z <- as.owin(y)

Given z, I want to identify each polygon with a single constant value. This is 
like adding marks to the SpatialPolygons file. Then I want to convert these 
polygons into an image, such that the value of each pixel corresponds to the 
value associated to the polygon where the pixel lies.

I have been able to do this individually, polygon by polygon, but then I cannot 
merge the resulting images into a single one. Any idea?

Second:

I would also need a single window containing all the smallest polygons (the 
boundary). I have tried:

w <- union.owin(z)

But the resulting window w still shows internal polygons. As read in spatstas 
FAQ page:

"First, convert each of the regions into a separate owin object. Then apply 
union.owin to combine them."

So I try,

regions <- slot(y, "polygons")
regions <- lapply(regions, function(x) { SpatialPolygons(list(x)) })
windows <- lapply(regions, as.owin)

But windows is a list of 4307 polygons. How can introduce all of them as a 
single argument?


M <- union.owin(windows)

Warning messages:
1: In union.owin(windows) : Some arguments were not windows
2: In union.owin(windows) : No windows were given


Thank you very much for you help.


As Don has said, this question would be better asked on R-sig-geo.

A *reproducible* example would be nice, e.g. perhaps you could tell us 
how to get the shapefile in question.


In respect of your last point:  Rather than "M <- union.owin(windows)" 
you should use:


M <- do.call(union.owin, windows)

But that's rather off the track.  What I think you should do (it's hard 
to be certain without a reproducible example) is something like:


tw <- tess(tiles=windows)
iw <- as.im(funxy(as.function(tw,values=vvv),W=Window(tw)),dimyx=128)

where "vvv" is a vector of the values that you wish to associate with 
the individual polygons.  There may be less cryptic ways of 
accomplishing the same thing, but this is the sexiest way, I think.


The value chosen for "dimyx", i.e. 128, is just by way of example.  You 
can use whatever value suits you.  The larger it is, the smoother the 
individual polygons will look, in pixellated form, but the longer things 
will take.  With 4307 polygons, that might be a rather long time!


HTH

cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] glm and stepAIC selects too many effects

2017-06-05 Thread Rolf Turner

On 06/06/17 18:08, Marc Girondot via R-help wrote:

This is a question at the border between stats and r.

When I do a glm with many potential effects, and select a model using 
stepAIC, many independent variables are selected even if there are no 
relationship between dependent variable and the effects (all are random 
numbers).


Do someone has a solution to prevent this effect ? Is it related to 
Bonferoni correction ?


Is there is a ratio of independent vs number of observations that is 
safe for stepAIC ?


Thanks

Marc

Example of code. When 2 independent variables are included, no effect is 
selected, when 11 are included, 7 to 8 are selected.


x <- rnorm(15, 15, 2)
A <- rnorm(15, 20, 5)
B <- rnorm(15, 20, 5)
C <- rnorm(15, 20, 5)
D <- rnorm(15, 20, 5)
E <- rnorm(15, 20, 5)
F <- rnorm(15, 20, 5)
G <- rnorm(15, 20, 5)
H <- rnorm(15, 20, 5)
I <- rnorm(15, 20, 5)
J <- rnorm(15, 20, 5)
K <- rnorm(15, 20, 5)

df <- data.frame(x=x, A=A, B=B, C=C, D=D,
  E=E, F=F, G=G, H=H, I=I, J=J,
  K=K)

G1 <- glm(formula = x ~ A + B,
  data=df, family = gaussian(link = "identity"))

g1 <- stepAIC(G1)

summary(g1)

G2 <- glm(formula = x ~ A + B + C + D + E + F + G + H + I + J + K,
  data=df, family = gaussian(link = "identity"))

g2 <- stepAIC(G2)

summary(g2)


IMHO there's nothing much that you can do about this.  Trying to get the 
data to select a model is always fraught with peril.


The phenomenon that you have observed has been remarked on before; see
Alan Miller's book "Subset Selection in Regression" (Chapman and Hall, 
1990), page 12 (first paragraph of section 1.4).


However you might find some of Miller's recommendations to be at least a 
*bit* useful.


cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] Problem related to rowSums

2017-06-07 Thread Rolf Turner


On 07/06/17 21:08, Yogesh Gupta wrote:


Hi...

I have a dataframe with n columns and n rows. I need to find how many rows
contains zero raw read count across all column.


(1) You should probably have a *matrix*, not a data frame.

(2) Have you ever heard of the idea of providing a *reproducible* example?

(3) I *think* the following may be what you want/need:

M <- as.matrix(M) # Where the initial M is your "data frame".
sum(apply(M,1,function(x){isTRUE(all.equal(x,rep(0,length(x}))

Untested, since you did not supply a reproducible example.

cheers,

Rolf

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] How Can I Execute a String Expression?

2017-06-12 Thread Rolf Turner


On 13/06/17 13:55, Donald Macnaughton wrote:


I have the string ggstr that I've built with string manipulation:

ggstr =  "ggplot(df1, aes(x,y)) + geom_smooth(se=FALSE, span=0.01)"

Assuming df1 is properly defined, this string will execute properly if I
submit it manually without the quotes. How can execute the command as a
string, so that I can run it repeatedly (with minor modifications) in a
loop?  Presumably, it would be something like:

execute(ggstr)

Thanks for your help.


eval(parse(text = ggstr))

cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] IF LOOOP

2017-06-13 Thread Rolf Turner

On 14/06/17 08:46, matthias worni wrote:

Hey

This should be a rather simple quesiton for some of you. I want to make
some progress in looping...
I have the vector r, which contains single values --> see below:

r
   [1] 1.1717118 1.1605215 1.1522907 1.1422830 1.1065277 1.1165451 1.1163768
1.1048872 1.0848836 1.0627211
  [11] 1.0300964 1.0296879 1.0308194 1.0518188 1.0657229 1.0685514 1.0914881
1.1042577 1.1039351 1.0880163


I would like to take out simply the value "0.990956" from the vector,
printing out the rest of it.  The code is from the internet but does not
seem to work for my vector. Can't figure out why... Thanks for the help

r <- as.vector(lw)
count=0
for (i in r)  {
   if(i == 0.990956) {
 break
   }
 print(i)
   }


FAQ 7.31

cheers,

Rolf Turner


--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] Re: draw stripes in a circle in R

2017-06-14 Thread Rolf Turner

On 15/06/17 05:29, David Winsemius wrote:



On Jun 14, 2017, at 10:18 AM, David Winsemius  wrote:



On Jun 14, 2017, at 9:46 AM, Jeff Newmiller  wrote:

I don't see a question. If your question is whether R supports pattern fills, 
AFAIK it does not. If that is not your question, ask one.
--
Sent from my phone. Please excuse my brevity.

On June 14, 2017 7:57:41 AM PDT, jean-philippe 
 wrote:

dear R users,

I would like to fill a circle with yellow stripes instead of a uniform
yellow color. To draw the circle I used the following command after
having loaded the (very nice !) plotrix library :


I finally understood the question and it needs a hack to the draw.circle 
function in plotrix since the angle and density arguments don't get passed in:

First get code for draw.circle:

--

draw.circle   # then copy to console and edit

draw.circle2  <- function (x, y, radius, nv = 100, border = NULL, col = NA, lty 
= 1,
density=NA, angle=45,  lwd = 1 )
{
 xylim <- par("usr")
 plotdim <- par("pin")
 ymult <- getYmult()
 angle.inc <- 2 * pi/nv
 angles <- seq(0, 2 * pi - angle.inc, by = angle.inc)
 if (length(col) < length(radius))
 col <- rep(col, length.out = length(radius))
 for (circle in 1:length(radius)) {
 xv <- cos(angles) * radius[circle] + x
 yv <- sin(angles) * radius[circle] * ymult + y
 polygon(xv, yv, border = border, col = col, lty = lty, 
density=density, angle=angle,
 lwd = lwd)
 }
 invisible(list(x = xv, y = yv))
}

Now run your call to pdf with draw.circle2 instead of draw.circle.


This is just idle curiosity, since I'm not really able to contribute 
anything useful, but I can't resist asking:  When I try to run the OP's 
code I get an error:



Error in alpha("red", 0.4) : could not find function "alpha".


Why does this (apparently) not happen to anyone else?  Why does the 
universe pick on *me*?  What is the function "alpha()"?  Where is it to 
be found?


Searching on "alpha" is of course completely unproductive; there are far 
too many (totally irrelevant) instances.


cheers,

Rolf

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] about fitting a regression line

2017-06-14 Thread Rolf Turner

On 15/06/17 10:40, lily li wrote:

Hi R users,

I have some data points (Xi, Yi), and they may follow such a pattern Yi =
cCOS(Xi) + d, how to find the c and d in R? which function to use? Also,
how to get the R2 and p value for this correlation? Thanks for any kind of
help.


If I understand you correctly (always a dubious conditional):

fit <- lm(y ~ cos(x))

where y and x are vectors of the y and x values of your data points, 
should answer all of your questions.


I am bewildered that you need to ask.  You have been posting to this 
list for quite a while.  Have you learned nothing about R?  It's time 
that you did.  Read and study carefully "An Introduction to R" from the 
R web site -> Manuals.


cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] Re: about fitting a regression line

2017-06-14 Thread Rolf Turner

On 15/06/17 11:28, lily li wrote:

Thanks. I thought lm() function is for linear model, such as the
correlation below:
Y= aX + b

On Wed, Jun 14, 2017 at 5:25 PM, MacQueen, Don  wrote:


Start with the lm() function; i.e., see

   ?lm



And you don't think that Y = a*cos(X) + b is a linear model?

The mind boggles.

Well, I guess there is a "subtlety" here.  Linear models are *linear in 
the PARAMETERS of the model*, not in the predictors.


First-year knuckle-draggers get confused about this.  People who are 
using R to do research should be a bit beyond such confusion.


cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] Re: draw stripes in a circle in R

2017-06-14 Thread Rolf Turner

On 15/06/17 10:27, David Winsemius wrote:



On Jun 14, 2017, at 1:53 PM, Rolf Turner  wrote:





Why does this (apparently) not happen to anyone else?  Why does the
universe pick on *me*?  What is the function "alpha()"?  Where is
it to be found?


I discovered some time ago that I no longer needed to load the
ggplot2 package. I wasn't entirely happy to make this discovery since
I stilll cling to the old lattice style. Eventually I figgured out
that it was because one of packages that I load in my .Rprofile-file
had changed its imports. The `alpha` function I see is from ggplot2.
Resistance is futile. I've now been partially assimilated.



N'ya-hah!  The light dawns!  Thank you.

cheers,

Rolf

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] Re: draw stripes in a circle in R

2017-06-14 Thread Rolf Turner

On 15/06/17 13:51, David Winsemius wrote:



On Jun 14, 2017, at 5:52 PM, Jeff Newmiller  wrote:

Sigh. I never load packages in .Rprofile to avoid the irreproducibility trap. 
Might seem drastic to some, but I don't feel much pain because I almost always 
edit my code in a file rather than on the fly at the console, and re-run it 
frequently from a fresh R process to check my progress.


Yes, . But I am a long-time user of the rms/Hmisc combo, as well as the 
survival package, so near the top of my .Rprofile is:

require(lattice)
require(sos)
require(rms)

Should I be ashamed of that?

I suppose I should, and I _am_ ashamed of some of the other stuff in
there  ,  ... and I've been meaning to address my
manifold deficiencies w.r.t. irreproducibility by moving to RStudio,
but I keep putting it off.



This is getting *way* off topic ... but why does using RStudio help with 
the irreproducibility problem?  I thought that RStudio just made it 
easier to point-and-click.  For those who like doing that sort of thing.
(I tend to believe the dictum that a GUI makes it easy to do easy things 
and impossible to do hard things.)


cheers,

Rolf

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] Generate correlated expontial distribution -- lamda please guide

2017-06-16 Thread Rolf Turner

On 16/06/17 15:53, Sunny Singha wrote:

Hi,
I need to generate correlated (positive as well as negative) bivariate 
exponential
distribution with rate of 1/5 or any rate.
I need some guidance here. Please help.


I believe this question is ill-posed.

(1) My understanding is that there is no "bivariate exponential" 
distribution, or rather that there are many possible definitions. 
(Others, younger and wiser, may correct me or elaborate on this.)


(2) If your requirement is simply to obtain a bivariate distribution 
with exponential marginals and a given correlation between the 
variables, I believe there are a variety of ways.  One way might be to 
use copulas.  Another might be to use "coupling" (see Muirhead, "Aspects 
of Multivariate Statistical Theory", Wiley, p. 43, Ex. 1.7).


Some googling (why didn't you do that?) led me to


http://r.789695.n4.nabble.com/How-to-generate-bivariate-exponential-distribution-td3596944.html


in which Petr Savicky gives a simple construction.

cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] About error bars on barplots

2017-06-17 Thread Rolf Turner

On 18/06/17 12:10, lily li wrote:

Hi R users,

I have a question about adding uncertainty bars to stacked bar plots.

DF:
   year   A   B   C   Amin  Amax  Bmin  Bmax  Cmin  Cmax
  2009  40  45  15   30  61   23   56  14   17
  2010  36  41  23   26  54   22   51  22   24

I use the code below:

DF.refm = melt(subset(DF[,c(1:4)]),id.vars='year',variable_name='Legend')

fig1 = ggplot(data=DF.refm, aes(x=year,y=value,fill=Legend))+
   geom_bar(stat='identity',size=.5)+ theme_bw()+ xlab('Year')+
ylab('Percent (%)')
print(fig1)

But I don't know how to change it a little bit. For example, how to add the
error bars on the plot, as is shown in the figure below? The error bar for
variable A ranges from Amin to Amax, the same applies to variables B and C.
Thanks for your help.



Your figure did not come through, at least not to me.  You are probably 
doing something fancy, and the mailing list software stripped out the 
figure.  *Do* learn to keep things simple.  _Attach_ figures as *.pdf 
files, for instance.


That being said, to answer your question, my advice (and that of many 
others) is: DON'T.  Error bars on boxplots (such plots are sometimes 
known as "dynamite plots" or "detonator plots") are considered by the 
cognoscenti to be abominations.


cheers,

Rolf

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] How to write an estimated seasonal ARIMA model from R output?

2017-06-20 Thread Rolf Turner

On 20/06/17 17:21, Y S wrote:

I'm trying to use the following command.
arima (x, order = c(p,d,q), seasonal =list(order=c(P,D,Q), period=s)

How can I write an estimated seasonal ARIMA model from the outputs. To be 
specifically, which sign to use? I know R uses a different signs from S plus.

Is it correct that the model is:
(1-ar1*B-ar2*B^2-...)(1-sar1*B^s-sar2*B^2s-)(1-B)^d(1-B^s)^D 
X_t=(1+ma1*B+ma2*B^2+...)(1+sma1*B^s+sma2*B^2s+) a_t

For example:

m1=arima(koeps,order=c(0,1,1),seasonal=list(order=c(0,1,1),period=4))
m1

Call:
arima(x = koeps, order = c(0, 1, 1), seasonal = list(order = c(0, 1, 1), period 
= 4))
Coefficients:
   ma1 sma1
   -0.4096  -0.8203
s.e.   0.0866   0.0743

Should the estimated model be written as:
(1-B)(1-B^4) X_t=(1-0.4096B)(1-0.8203B^4) a_t
or (1-B)(1-B^4) X_t=(1+0.4096B)(1+0.8203B^4) a_t

Thanks!


Please do not post in html, although this doesn't seem to have messed 
things up too badly in this instance.


The help for arima() says:


The definition used here has

X[t] = a[1]X[t-1] + … + a[p]X[t-p] + e[t] + b[1]e[t-1] + … + b[q]e[t-q]


so your first possibility, i.e.

(1-B)(1-B^4) X_t=(1-0.4096B)(1-0.8203B^4) a_t

is the correct one.

This stuff *does* get confusing; parity errors keep creeping in!

cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] Re: Question about correlation

2017-07-05 Thread Rolf Turner


On 06/07/17 10:23, Jim Lemon wrote:


I think that Goran is right, I didn't take "cor(data)" literally.


See fortune(15).

cheers,

Rolf


--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] How does findAssocs() calculate the correlation value ??

2017-07-06 Thread Rolf Turner

On 07/07/17 13:55, θ ” wrote:

hi:

I want to know the math behind the "tm" package findAssocs().

I have found that someone had asked the question before, and have a good 
explanation by Rick.

�]http://r.789695.n4.nabble.com/findAssocs-td3845751.html�^


But I still don't understand how to calculate the correlation value between the 
two vectors.


For example:

# Correlation word2 with word3

cor(c(0,1,1,1,1),c(0,0,1,1,1))
[1] 0.6123724


How does it caculate  cor(c(0,1,1,1,1),c(0,0,1,1,1)) to get 0.6123724 ?


Look in any first year statistics text for the definition of correlation.

cheers,

Rolf Turner


--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] Making 2 dimensional vector from the 3 dimensional one

2017-07-14 Thread Rolf Turner


On 14/07/17 21:43, Csima, Gabriella wrote:


Hi All,
I want to make a 1 dimension vector from the first two dimensions of a 3 dimension array, 
so make a 2 dimension vector from a 3-dimension one, with "fusing" (making 
as.vector) the first two dimensions.
It seems to be very easy, but I cannot find the solution, I mean it would very 
strange, that I would do taking the single 1 dimensional vectors from the 3 
dimensional one, make one vector from the first two vectors and make two 
dimension from the original 3rd one and this new one, but  I think there would 
be an easier way that I do not find.
Could you help me, please?
Thanks very much,


(1) Please avoid posting in HTML (although no great harm was done in 
this instance).  This is a plain text mailing list, and HTML often makes 
a mess.


(2) Spend some time learning R (e.g. read "An Introduction to R" from 
the R web site).  In particular learn about array indexing.


(3) It is not *at all* clear to me what you actually want to do.  A 
simple example of what you've got and what you want to get would help.


(4) What on earth do you mean by "a 1 dimension vector"?  A
1 dimensional vector is a scalar.  I can't believe that this is actually 
what you are talking about.  Please clarify.


cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] A problem with order() function in R

2017-07-17 Thread Rolf Turner

On 18/07/17 14:58, Jesadaporn Pupantragul wrote:

Hello r-help
I am learning R and use R-studio.
I create vector x <- c(19,17,23,11) and use function order(x).
The result show [1]  4 2 1 3. Why it doesn't show [1] 3 2 4 1.
Follow picture that i attach.
Thank you for you answer.


Perhaps this will give you some insight:

o <- order(x)
x[o]

cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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 in shiny writing a .txt file

2017-07-19 Thread Rolf Turner


On 19/07/17 19:19, Ana Belén Marín wrote:


Hi all!

I'm developing a shiny app and I have problems when I wanna write a .txt
file.




" ... when I *want to* write ..."

The language of this mailing list is *English*, not Valspeak.

cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] How export data set (available in the package) from R?

2017-07-30 Thread Rolf Turner

On 30/07/17 15:47, Ted via R-help wrote:

"Data set flchain available in the survival  package".  How can I get it (from 
R)  as Excel file? Thanks!


The best advice is *DON'T*!!!

I.e. Don't use Excel.  Ever.  Unless you really *want* to create chaos 
and havoc, and let slip the dogs of war.


cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] Flummoxed by gsub().

2017-08-22 Thread Rolf Turner


I have a vector (say "x") of the form

[1] "mung5"  "mung10" "mung20" "gorp5"  "gorp10" "gorp20"

I want to extract just the numbers (strings of digits) that appear at 
the end of the strings in "x".


My reading of ?regex led me to believe that

gsub("[:alpha:]","",x)

should give the result that I want.  However it returns

[1] "mung5"  "mung10" "mung20" "gor5"   "gor10"  "gor20"

i.e. it chops the last letter out of the "gorp" string, but nothing else.

I am completely bewildered by this behaviour and can see no rationale 
for it nor any way to adjust my syntax to get what I want.


A bit of Googling led me to the information that

gsub("\\D","",x)

should work, and indeed it does, giving:

[1] "5"  "10" "20" "5"  "10" "20"

OM!  (Apparently "\D" means *not* a digit.)

So I have *a* solution to my problem.  However I would really like to 
know why the  the first idea I tried did not work and

what it is actually *doing*!

Anybody?

cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] Flummoxed by gsub().

2017-08-23 Thread Rolf Turner


On 23/08/17 18:33, Stefan Evert wrote:




On 23 Aug 2017, at 07:45, Rolf Turner  wrote:

My reading of ?regex led me to believe that

gsub("[:alpha:]","",x)

should give the result that I want.


That's looking for any of the characters a, l, p, h, : .


OK.  I see that now.  I don't think that it's really stated anywhere 
that to search for (and possibly change) any one of a string of 
characters you enclose that string of characters in brackets [  ].


The first example from ?grep makes this "clear" (for some value of the 
word "clear") once you understand what this example is on about.


So it's "obvious" once you've been shown, and totally opaque until then.


What you meant to say was

gsub("[[:alpha:]]","",x)

i.e. the character class [:alpha:] within a character set.


Yup.  Got it.  Thanks very much.

cheers,

Rolf

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] Flummoxed by gsub().

2017-08-23 Thread Rolf Turner

On 23/08/17 18:41, PIKAL Petr wrote:

Hi Rolf

I am not at all an expert in regex but

gsub("[[:alpha:]]","",x)

Works as you expected. Do not ask me why.


Thanks Petr.  Stefan Evert's explanation clarified the issue.  Which I 
must say *needed* some clarification!


cheers,

Rolf

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] Flummoxed by gsub().

2017-08-23 Thread Rolf Turner

On 24/08/17 02:46, Bert Gunter wrote:

Inline.

-- 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, Aug 23, 2017 at 2:29 AM, Rolf Turner  wrote:


On 23/08/17 18:33, Stefan Evert wrote:




On 23 Aug 2017, at 07:45, Rolf Turner  wrote:

My reading of ?regex led me to believe that

 gsub("[:alpha:]","",x)

should give the result that I want.



That's looking for any of the characters a, l, p, h, : .



OK.  I see that now.  I don't think that it's really stated anywhere that to
search for (and possibly change) any one of a string of characters you
enclose that string of characters in brackets [  ].

The first example from ?grep makes this "clear" (for some value of the word
"clear") once you understand what this example is on about.

So it's "obvious" once you've been shown, and totally opaque until then.


Well, "obviousness" is in the mind of the beholder, but, from ?regexp:

"A character class is a list of characters enclosed between [ and ]
which matches any single character in that list; "... (at the end of
the above section)

"For example, [[:alnum:]] means [0-9A-Za-z] "...

Note the doubled brackets. So seems pretty explicit to me.


Well, yes.  Once it's pointed out it's "obvious".  But it's buried 
pretty deeply in a large mass of text, and I didn't see it until you 
pointed it out.


If *I* had written the help file, it would be much more perspicuous.

cheers,

Rolf

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] Re: Block comment?

2017-09-02 Thread Rolf Turner

On 03/09/17 03:56, William Dunlap via R-help wrote:

Is the reason you want a block comment containing code (as opposed to
arbitrary text) that you want to be able to easily run the commented out
code?  If so the 'if()' construct has the advantage that you only need to
change code at the start of the comment, not at both ends.

The if(FALSE) could be if(isTRUE(getOption("DEBUG_ISSUE_XYZ"))) so you
would not even have to change code to re-enable the debugging code, just
call options(DEBUG_ISSUE_XYX=TRUE)).



(a) The foregoing is getting too subtle for my feeble brain.

(b) A fundamental problem with the

   if(FALSE) {
  ...
   }

paradigm is that the enclosed code must be syntactically valid, and 
there are certainly situations in which one might wish to comment out 
sections of code that are *not* syntactically valid.  E.g. one might 
wish to comment out *part* of a piece of syntactically valid code for 
the purpose of experimenting with an alternative approach.


cheers,

Rolf

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276


On Sat, Sep 2, 2017 at 7:54 AM, Suzen, Mehmet  wrote:


AFAIK block comment is not possible
it needs to be implemented in R interpreter and defined in the
parser.'If' solution is not elegant.

On 2 September 2017 at 14:09, Uwe Ligges
 wrote:



On 02.09.2017 11:40, Christian wrote:


I consider it quite worth while to introduce into R syntax a nestable
block comment like

#{

}#



if(FALSE){

}

Best,
Uwe Ligges



It would make documentation more easily manageable and lucid.
Is there considerable need for this.

Please, comment on this.
How about R core?

Christian



__
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.



[[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.


Re: [R] [FORGED] Re: Block comment?

2017-09-02 Thread Rolf Turner


On 03/09/17 12:29, Duncan Murdoch wrote:


On 02/09/2017 6:57 PM, Rolf Turner wrote:

On 03/09/17 03:56, William Dunlap via R-help wrote:

Is the reason you want a block comment containing code (as opposed to
arbitrary text) that you want to be able to easily run the commented out
code?  If so the 'if()' construct has the advantage that you only 
need to

change code at the start of the comment, not at both ends.

The if(FALSE) could be if(isTRUE(getOption("DEBUG_ISSUE_XYZ"))) so you
would not even have to change code to re-enable the debugging code, just
call options(DEBUG_ISSUE_XYX=TRUE)).



(a) The foregoing is getting too subtle for my feeble brain.

(b) A fundamental problem with the

 if(FALSE) {
...
 }

paradigm is that the enclosed code must be syntactically valid, and
there are certainly situations in which one might wish to comment out
sections of code that are *not* syntactically valid.  E.g. one might
wish to comment out *part* of a piece of syntactically valid code for
the purpose of experimenting with an alternative approach.


If the code is not syntactically valid, why would you expect the block 
comment to be syntactically valid?


I thought I had made that clear.  One might wish to comment out a 
*piece* of syntactically valid code (with a view to replacing it).
The piece commented out might not be syntactically valid simply because 
it is *just a piece* and might thereby be incomplete.


The proposal at the start of this 
thread was that #{ would open the block and would be matched by }# to 
close the block.  What if the closing sequence occurred within the block 
unintentionally?  Then the poor feeble programmer would be even more 
confused.


Do not the same considerations essentially apply to the well established
/*  */ convention used in C?  Well maybe you simply *can't* get the 
"*/" string within a block of C code, but still 


If "#{}#" runs this risk, then some other construction which doesn't 
run the risk could be used.


I like the current rule: 


De gustibus non disputandum.

any line starting with # is a comment. 
(Actually the rule is a bit more subtle than that, but it's close.)
If I want to comment out a block, I can spend a long time typing # at 
the start of every line, or I can ask my editor to do it.  I don't need 
to worry if something in the block unintentionally closes it, because 
that's impossible.  If the first line is a comment, all the rest are too.


I don't follow the foregoing, but no matter.  I'm slow.

This issue is quite obviously No Big Deal.  Block comments are a 
convenience that it would be nice to have, but obviously one can live 
without them and not suffer unduly.


cheers,

Rolf

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] [R-sig-Geo] circular spatial polygon

2017-09-13 Thread Rolf Turner

On 13/09/17 13:24, Kátia Emidio wrote:

Dear Rolf,

Thanks for your help!

What I need is a spatial window with shape equal to the figure attached. 
This figure I made using ArcGis, but it is important to me make it in R. 
After having this figure I will make some analysis using spatstat among 
others. The points within figure are trees...


(1) I believe that this discussion should be kept on-list.  It is not my 
role to provide private consulting for you.  I  am therefore cc-ing the 
list in this email.


(2) It is still not completely clear what you really want; the figure 
that you attached appears to be a disc with 4 diameters superimposed. 
So you might be after a single (circular) owin object and a line segment 
pattern consisting of the 4 diameters.  Or you might be after *eight* 
owin objects, each being one the eight disc-segments into which the 
diameters divide the disc.


I shall assume the latter.  To start with define a function, say "wedge":

wedge <- function(theta1,theta2,radius,npoly=100,centre=c(0,0)){
library(spatstat)
# Should do some checking on the values of theta1 and theta2 here,
# but I shan't bother.
theta <- seq(theta1,theta2,length=npoly+1)
x <- c(0,radius*cos(theta),0)
y <- c(0,radius*sin(theta),0)
W <- owin(poly=list(x=x,y=y))
return(affine(W,vec=centre))
}

Then do something like:

wedgies <- vector("list",length=8)
cntr <- c(673593.21,673593.21)
for(i in 1:8) wedgies[[i]] <- wedge((i-1)*pi/4,i*pi/4,15,centre=cntr)
ttt <- tess(tiles=wedgies)
plot(ttt) # Looks OK to me.

And maybe also do:

W <- do.call(union.owin,wedgies)
plot(W)
for(i in 1:8) {
plot(wedgies[[i]],add=TRUE,border="red")
readline("Go? ")
}

Also looks OK to me.

Is *this* what you want?

cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] Help in R

2017-09-13 Thread Rolf Turner


On 14/09/17 07:50, Jessie Todd wrote:


I don’t know if my question is answerable, but it is worth a try. I
have a data set that I am trying to analyze in R for a course and the
instructions were to get a standard deviation which I already
computed in R and use that number and change it to a biased standard
deviation….(I have the two equations and I understand the difference
between the two and how the unbiased has the degree of freedom…..I
just do not know how use my standard deviation and transform it in R
to a biased one.


This list has a no-homework policy, and I would say "ask your lecturer" 
but it seems your lecturer could be a bit out to lunch, so that might be 
bad advice.


Standard deviations estimates are *always* biased!  (That might be a 
slight overstatement but it is essentially correct.)


What may be biased or unbiased are *variance* estimates.  In the 
simplest setting:


   V1 = (1/n) sum_{i=1)^n (x_i - xbar)^2 is biased.

I.e. E(V1) is not equal to sigma^2, the population variance.

   V2 = (1/(n-1)) sum_{i=1)^n (x_i - xbar)^2 is unbiased.

I.e. E(V2) *is* equal to sigma^2.

The var() function in R gives you the unbiased estimate of variance.

It's a piece of cake to obtain the biased estimate of variance from the
unbiased one --- just multiply by appropriate constant.  (Hint:  this 
constant involves n and n-1. :-) )


What your lecturer *probably* wants you to do is form the biased 
estimate of variance and then estimate the standard deviation by taking

the square root of the biased estimate.

To verify whether the foregoing conjecture is true, you'll have to ask 
your lecturer.  Good luck


Note *both* sqrt(V1) and sqrt(V2) are *biased* estimates of sigma (the 
population standard deviation).


HTH

cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] Converting SAS Code

2017-09-29 Thread Rolf Turner

On 30/09/17 07:45, jlu...@ria.buffalo.edu wrote:





The conceptual paradigm for R is only marginally commensurate with that of
standard statistical software.
You must immerse yourself in R to become proficient.


Fortune nomination.

cheers,

Rolf

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] Converting SAS Code

2017-09-30 Thread Rolf Turner

On 01/10/17 01:22, Robert Baer wrote:



On 9/29/2017 3:37 PM, Rolf Turner wrote:

On 30/09/17 07:45, jlu...@ria.buffalo.edu wrote:





The conceptual paradigm for R is only marginally commensurate with 
that of

standard statistical software.
You must immerse yourself in R to become proficient.


Fortune nomination.

For newer list members wondering what Rolf is talking about try:

library(fortunes) fortune() to get a flavor! There are many pearls of 
wisdom.


For the *really* new members, note that you may have to *install* the 
fortunes package first:


> install.packages("fortunes",lib=)

Note that the package is "fortunes" (with an "s") but the function is
fortune() (no "s").

cheers,

Rolf

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] RFM Analysis Help

2017-10-04 Thread Rolf Turner


On 04/10/17 21:11, Hemant Sain wrote:


I'm trying to perform a RFM analysis on attached dataset,




Is "RFM" the Russian [1] version of "RTFM"?

(Sorry, just couldn't resist!)

cheers,

Rolf Turner

[1] The Russian language had no definite articles.  Or indefinite
ones either, for that matter.


--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] bootstrapping results in table format

2017-10-07 Thread Rolf Turner

On 07/10/17 12:16, Peter Wagey wrote:

Hi R users,
I was struggling to put the results into table format. Would you mind to
show using following data and code how we can put the results into table? I
further would like to have a  confidence interval for each group.


set.seed(1000)
data <- as.data.table(list(x1 = runif(200), x2 = runif(200), group =
runif(200)>0.5))
data.frame(data)
head(data)
stat <- function(x, i) {x[i, c(m1 = mean(x1))]}
A<-data[, list(list(boot(.SD, stat, R = 10))), by = group]$V1


(1) Don't post in html.

(2) Don't send code that makes use of packages that you don't mention
(in this case "data.table").

(3) Don't use "data" as the name of a data object.  There is a base 
function called "data" whence you run the risk of getting toadally 
incomprehensible error messages as the result of certain syntax errors.

Also see fortune("dog").

cheers,

Rolf Turner


--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] lib default location

2016-05-21 Thread Rolf Turner

On 22/05/16 01:54, Uwe Ligges wrote:



On 21.05.2016 14:49, Alba Pompeo wrote:

Everytime I install a package from CRAN I receive this message:

Installing package into ‘/home/albap/R/x86_64-pc-linux-gnu-library/3.3’
(as ‘lib’ is unspecified)

Should I set my lib? If so, what's the recommended path?


It is fine to keep this per user default.


Note that you can suppress the somewhat redundant message by specifying 
quiet=TRUE in the call to install.packages().


cheers,

Rolf Turner

Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] couldn't install pcalg package in R 3.1.3

2016-05-27 Thread Rolf Turner

On 28/05/16 06:08, Lida Zeighami wrote:

Hi Dears!

Would you please let me know how I can install package pcalg for R version
3.1.3 ?
I've tried different ways but got error!

Thanks inadvance!



An answer the helpfulness of which is commensurate with the clarity of 
your question:  Do it correctly.


cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] Creating R file

2016-05-28 Thread Rolf Turner

On 28/05/16 19:37, Hong Yu wrote:





When you need numerical data input in R programs, you can use EXCEL
to create .csv file.  When you need output calculation results, you
can write out .csv file in R programs.

Yes, the most common .cvs file format is comma seperated numerical
values.  You can use EXCEL to create .csv file, and view the content
with text editor.


There are myriad ways to create *.csv files, including text editors and 
R itself, and other sound statistical packages.  There is no need to use 
the abomination that is known as Excel.


cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] Re: email threads chronology

2016-05-30 Thread Rolf Turner

On 31/05/16 03:58, Bert Gunter wrote:




On Mon, May 30, 2016 at 5:51 AM, Fowler, Mark  wrote:
...
"The preceding replies suggest this is something going on at my end,
perhaps related to network security. I'm curious what might be causing
it, and if there is something I can do about it - short of contacting
IT staff, which is more irritating than the corrupted threads."

Semi-Fortune!? This is probably not quite suitable for the fortunes
package, but I still think it's clever.


I think this would be an excellent fortune!

cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] Re: Extract from a text file

2016-05-31 Thread Rolf Turner

On 01/06/16 15:27, Bert Gunter wrote:

On Tue, May 31, 2016 at 7:05 PM, Jeff Newmiller
 wrote:

You need to go back and study how I made my solution reproducible and make your 
problem reproducible.

You probably also ought to spend some time comparing the regex pattern to your 
actual data... the point of this list is to learn how to construct these 
solutions yourself.



Ah, if only that were the case.

(or is that just the grumbling of an old curmudgeon?)



Both! :-)

cheers,

Rolf

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] Re: help with r package "trip"

2016-06-15 Thread Rolf Turner

On 15/06/16 20:18, Jim Lemon wrote:

Hi Alice,
Have you tried creating a vector of the start position (xpos[1],ypos[1]):

xstart<-rep(xpos[1],n)
ystart<-rep(ypos[1],n)
# where "n" is the number of subsequent positions in the trip
max(trackDistance(xstart,ystart,xpos[2:n],ypos[2:n],...))

may then give you the value of the longest distance from the start. I
don't have the trip package or I could see if you really need to
replicate the start positions.


Jim:  This seems to me to be somewhat off the point.  The OP was faced 
with the problem of not being able to access the function homedist(). 
This function seems *not* to be exported from the trip package, and yet 
it is a *documented* function which I would assume to imply that users 
should be able to invoke it directly.


It is possible that in the past the OP was dealing with a version of the 
trip package that was created before namespaces came into the picture, 
whence "exporting" was not relevant.  I would suggest that the OP 
contact the package maintainer (maintainer("trip") will give you the 
email address) and enquire as to what is going on.


In the interim, a workaround *might* be to invoke homedist() as

trip:::homedist()

Note the *triple* colon in the foregoing.  I am not at all familiar with 
the trip package so my advice should probably be taken with several 
grains of salt.


cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276


On Wed, Jun 15, 2016 at 1:43 PM, Alice Domalik  wrote:

Hi List,

I'm relatively new to R, so apologies if my question is rather elementary.
I'm working with some bird tracking data and I would like to calculate the 
maximum distance traveled from the colony.
For the maximum distance traveled, I was going to use the function homedist(). 
However, when I try to use this function I get the following error:
Error: could not find function "homedist"
Anyone know why I would get this error? I have been using other functions in 
"trip" without an issue. Is there an alternative way I can calculate this?

Thanks in advance for any help!


__
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] [FORGED] Ask function missing in package car

2016-06-21 Thread Rolf Turner

On 22/06/16 13:06, Ashim Kapoor wrote:

Dear All,

my details:-

sessionInfo()

R version 3.3.0 (2016-05-03)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 15.10

locale:
 [1] LC_CTYPE=en_IN   LC_NUMERIC=C LC_TIME=en_IN
 [4] LC_COLLATE=en_IN LC_MONETARY=en_INLC_MESSAGES=en_IN
 [7] LC_PAPER=en_IN   LC_NAME=CLC_ADDRESS=C
[10] LC_TELEPHONE=C   LC_MEASUREMENT=en_IN LC_IDENTIFICATION=C

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

other attached packages:
[1] car_2.1-2

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.5lattice_0.20-33MASS_7.3-43
grid_3.3.0
 [5] nlme_3.1-128   MatrixModels_0.4-1 SparseM_1.7
minqa_1.2.4
 [9] nloptr_1.0.4   Matrix_1.2-6   splines_3.3.0
lme4_1.1-12
[13] pbkrtest_0.4-6 parallel_3.3.0 mgcv_1.8-7
nnet_7.3-10
[17] quantreg_5.24





## Not run:
attach(UN)

# enter the power-transformation parameter
# start with 1
Ask(p, function(p) qq.plot(box.cox(gdp, p),

+ ylab=paste("transformed gdp, power =",p)))
Error: could not find function "Ask"




What can I do to correct this?


What led you to believe that such a function exists (in the "car" 
package or anywhere else for that matter)?  And what exactly do you want 
it to do for you?


cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] Re: Generate list if sequence form two vector element

2016-06-22 Thread Rolf Turner

On 22/06/16 20:00, Jim Lemon wrote:

Hi Tanvir,
Not at all elegant, but:

make.seq<-function(x) return(seq(x[1],x[2]))
apply(matrix(c(a,b),ncol=2),1,make.seq)


Not sure that this is more "elegant" but it's a one-liner:

 lapply(1:length(a),function(i,a,b){a[i]:b[i]},a=a,b=b)

cheers,

Rolf


On Wed, Jun 22, 2016 at 5:32 PM, Mohammad Tanvir Ahamed via R-help
 wrote:

Hi,
I want to do the follow thing

Input :
a <- c(1,3,6,9)


b<-c(10,7,20,2)


Expected outcome :

d<-list(1:10,3:7,6:20,2:9)


__
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] [FORGED] Re: Rattle

2016-06-24 Thread Rolf Turner

On 25/06/16 09:13, Jeff Newmiller wrote:

This is like asking, "My car doesn't work. Can anyone tell me what is wrong?"




Fortune nomination!

cheers,

Rolf


--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] Help with the Cut Function

2016-06-25 Thread Rolf Turner

On 26/06/16 07:05, Shivi Bhatia wrote:

Dear Team,

Please see the code below:

Age1<- cut(desc$Age, breaks = c(20,30,40,Inf),labels = c("Low","Mid","Top"))
here i am creating three categories as mentioned from the age var from desc
data set.
All the values are set correctly however the values which are below 20 are
set to NA.
Is there anything i am doing incorrect.


No.  What is the problem?  This seems to me to be exactly what one would 
expect.


If you don't want NAs, set your lower break to be less than the minimum 
of desc$Age, e.g. -Inf.


cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] Error using function seas()

2016-06-25 Thread Rolf Turner


This is identical to the question that you previously asked and you 
still have not addressed the problem of making your example *reproducible*.


cheers,

Rolf Turner

On 26/06/16 01:52, T.Riedle wrote:

Dear all,

I am trying to run the seas() function. If I run the seas() function as shown 
below I get following errors. What is wrong with my code?



data<-Shiller_data[,2]



ts<-ts(data,start=c(1871, 01), end=c(2015, 12), frequency=12)



ts


 Jan Feb Mar Apr May Jun Jul Aug Sep
 Oct

18714.444.504.614.744.864.824.734.794.84
4.59

18724.864.885.045.185.185.135.105.044.95
4.97

18735.115.155.115.045.054.984.974.974.59
4.19

18744.664.804.734.604.484.464.464.474.54
4.53

18754.544.534.594.654.474.384.394.414.37
4.30

18764.464.524.514.344.184.154.103.933.69
3.67

18773.553.343.172.942.942.732.853.053.24
3.31

18783.253.183.243.333.343.413.483.453.52
3.48

18793.583.713.653.773.943.964.044.074.22
4.68

18805.115.205.305.184.774.795.015.195.18
5.33

18816.196.176.246.226.506.586.356.206.25
6.15

18825.925.795.785.785.715.686.006.186.24
6.07

18835.815.685.755.875.775.825.735.475.53
5.38

18845.185.325.305.064.654.464.464.744.59
4.44

18854.244.374.384.374.324.304.464.714.65
4.92

18865.205.305.195.125.025.255.335.375.51
5.65

18875.585.545.675.805.905.735.595.455.38
5.20

18885.315.285.085.105.175.015.145.255.38
5.35

18895.245.305.195.185.325.415.305.375.50
5.40

18905.385.325.285.395.625.585.545.415.32
5.08

18914.844.904.814.974.954.854.774.935.33
5.33

18925.515.525.585.575.575.545.545.625.48
5.59

18935.615.515.315.314.844.614.184.084.37
4.50

18944.324.384.514.574.404.344.254.414.48
4.34

18954.254.194.194.374.614.704.724.794.82
4.75

18964.274.454.384.424.404.324.043.814.01
4.10

18974.224.184.194.064.084.274.464.754.98
4.82

18984.884.874.654.574.875.065.085.275.26
5.15

18996.086.316.406.486.216.076.286.446.37
6.34

19006.106.216.266.346.045.865.865.945.80
6.01




SP <- seas(ts)


Error: X-13 run failed



Errors:

- Problem reading 
C:\Users\tr206\AppData\Local\Temp\Rtmp4Qtc08\x1312202a115399/data.dta. Too

  many observations in file.

- Problem reading 
C:\Users\tr206\AppData\Local\Temp\Rtmp4Qtc08\x1312202a115399/data.dta. Check

  your input file and format.

- Time series could not be read due to previously found errors

- Specify series before user-defined adjustments

- Need to specify a series to identify outliers


__
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.


  1   2   3   4   5   6   7   8   9   10   >