Re: [R] qqplot for binomial distribution

2017-04-19 Thread Ashim Kapoor
Dear Boris,

Many thanks,
Ashim

On Tue, Apr 18, 2017 at 7:56 PM, Boris Steipe 
wrote:

> As per the help pages, the data samples are expected in the second
> argument, "y".
>
> So try
>   qqplot(rbinom(n=100, size=100, p=0.05), count1_vector)
>
> ... and then plot your qqline()
>
> Alternatively, try
>
> qqline(count1_vector,
>distribution = function(probs) { qbinom(probs, size=100, prob=0.05)
> },
>datax = TRUE, # <- logical. Should data values be on the x-axis?
>col = "red",
>lwd = 0.5)
> ... and use your original qqplot()
>
>
> B.
>
>
> > On Apr 18, 2017, at 12:47 AM, Ashim Kapoor 
> wrote:
> >
> > Dear Boris,
> >
> > Thank you for your reply.
> >
> > > dput(count1_vector)
> > c(5, 6, 4, 4, 6, 5, 4, 5, 3, 7, 5, 5, 3, 4, 8, 6, 10, 2, 4, 6,
> > 8, 4, 4, 6, 8, 5, 6, 3, 7, 9, 4, 7, 5, 7, 3, 4, 5, 2, 11, 7,
> > 8, 5, 5, 6, 3, 2, 3, 5, 9, 6, 5, 6, 7, 3, 10, 7, 6, 4, 9, 5,
> > 7, 3, 7, 3, 2, 3, 4, 5, 10, 4, 5, 5, 6, 7, 4, 8, 7, 5, 5, 4,
> > 8, 7, 9, 4, 4, 4, 7, 5, 4, 10, 4, 5, 6, 1, 3, 5, 4, 7, 4, 6)
> >
> > set.seed(123)
> > qqplot(count1_vector,rbinom(n=100,size=100,p=.05))
> > qqline(count1_vector,distribution = function(probs) { qbinom(probs,
> size=100, prob=0.05) },
> >col = "red",
> >lwd = 0.5)
> >
> > When I do this, the line does not pass through the center of my data.I
> do expect count1_vector to be 100 samples of binomial with n=100 and p=.05.
> >
> > Any comments or suggestions for me ?
> >
> > Note : I built a 95% Confidence interval for my data and I counted how
> often out of 100 times did the data fall outside the CI.This I expect to be
> binomial with n=100,p=.05. I repeated this a 100 times and obtained
> count1_vector.
> >
> > Best Regards,
> > Ashim.
> >
> >
> > On Mon, Apr 17, 2017 at 7:51 PM, Boris Steipe 
> wrote:
> > That's not how qqline() works. The line is drawn with respect to a
> _reference_distribution_ which is the normal distribution by default. For
> the binomial distribution, you need to specify the distribution argument.
> There is an example in the help page that shows you how this is done for
> qchisq(). for qbinom() it is:
> >
> >
> > set.seed(123)
> > qqplot(rbinom(n=100, size=100, p=0.05),
> >rbinom(n=100, size=100, p=0.05) )
> >
> > qqline(rbinom(n=100,size=100,p=.05),
> >distribution = function(probs) { qbinom(probs, size=100,
> prob=0.05) },
> >col = "red",
> >lwd = 0.5)
> >
> >
> >
> >
> > B.
> >
> >
> > > On Apr 17, 2017, at 9:15 AM, Ashim Kapoor 
> wrote:
> > >
> > > Dear Spencer,
> > >
> > > Okay. Many thanks. My next query is how do I use qqline?
> > >
> > > When I try
> > >
> > >> qqline(rbinom(n=100,size=100,p=.05))
> > >
> > > I don't get the line in the right place.
> > >
> > > Best Regards,
> > > Ashim
> > >
> > > On Mon, Apr 17, 2017 at 6:31 PM, Spencer Graves <
> > > spencer.gra...@effectivedefense.org> wrote:
> > >
> > >>
> > >>
> > >> On 2017-04-17 7:58 AM, Ashim Kapoor wrote:
> > >>
> > >>> Dear All,
> > >>>
> > >>> set.seed(123)
> > >>> qqplot(rbinom(n=100,size=100,p=.05), rbinom(n=100,size=100,p=.05) )
> > >>>
> > >>> I expect to see 1 clear line,but I don't. What am I misunderstanding?
> > >>>
> > >>
> > >>
> > >>  The distribution is discrete, and points are superimposed. Try
> the
> > >> following:
> > >>
> > >>
> > >> set.seed(123)
> > >> qqplot(jitter(rbinom(n=100,size=100,p=.05)),
> > >>   jitter(rbinom(n=100,size=100,p=.05) ))
> > >>
> > >>
> > >>  Spencer Graves
> > >>
> > >>>
> > >>> Best Regards,
> > >>> Ashim
> > >>>
> > >>>[[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/posti
> > >>> ng-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/posti
> > >> ng-guide.html
> > >> and provide commented, minimal, self-contained, reproducible code.
> > >>
> > >
> > >   [[alternative HTML version deleted]]
> > >
> > > __
> > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > > https://stat.ethz.ch/mailman/listinfo/r-help
> > > PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> > > and provide commented, minimal, self-contained, reproducible code.
> >
> >
>
>

[[alternative HTML version deleted]]

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

[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 Berend Hasselman

> On 19 Apr 2017, at 09:48, Rolf Turner  wrote:
> 
> 
> 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?
> 

I have also received several messages addressed to 
r-help-arch...@googlegroups.com.
I junked most of these.

I have not tried to reply to any of these messages.
I did send a message some time ago to a poster on  
r-help-arch...@googlegroups.com to stop doing this and to use the official help.
Apparently to no avail.

Seems like a good idea to give these mails the same treatment as stuff from 
nabble.


Berend Hasselman

> 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-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 peter dalgaard
I believe that the list maintainer is hunting this down. As I understood it, it 
was more due to incompetence than to actual malice.

-pd

> On 19 Apr 2017, at 09:48 , Rolf Turner  wrote:
> 
> 
> 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.

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

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


[R] Follow-up: RStudio: Place for Storing Options (as plain text)

2017-04-19 Thread G . Maubach
Hi All,

some time ago I asded a question about the places where RStudio stores it 
configuration information. I came across this posting

https://support.rstudio.com/hc/en-us/articles/206382178?version=1.0.136&mode=desktop

explaining RStudio keybindings (predefined and customized). At the end of 
the article is the information that RStudio stores keybindings in

~/.R/rstudio/keybindings/rstudio_commands.json
~/.R/rstudio/keybindings/editor_commands.json

I want to share this with you.

Kind regards

Georg


- Weitergeleitet von Georg Maubach/WWBO/WW/HAW am 19.04.2017 10:10 
-

Von:Georg Maubach/WWBO/WW/HAW
An: R-help mailing list , 
Kopie:  Martin Maechler , Jeff Newmiller 

Datum:  08.03.2017 08:59
Betreff:Follow-up: [R] RStudio: Place for Storing Options (as 
plain text)



Hi All,

I got a late reply from RStudio Support concerning the question where 
RStudio store options and configurations:

-- cut --

The post RStudio Config Files has a new comment. 
. . .
Unfortunately, it's unlikely that we'll be able to provide a programmatic 
R interface in the near future -- the way we lay out and store RStudio's 
client state does not make it as amenable to public consumption as we 
might hope.
That said, you can generally copy everything within that folder to a new 
machine (at the same relative path from the user home directory), and 
expect preferences to be respected + restored as you might expect.
. . .
--cut --

The result of the discussion is:

We can copy the complete RStudio directory for storing options and 
configurations under

%localappdata%\RStudio-Desktop or 
C:\Users\\AppData\Local\RStudio-Desktop

and copy it completely to a new installation of RStudio.

A programmatic approach to edit RStudio options and configurations is not 
possible due to design decisions.

The purpose of the initial question was to find a way to save RStudio 
options and configurations, e g. on git/github or similar. This is 
possible by initialising the above given directory with git or similar.

An open question is what happens if a new RStudio release makes changes to 
the options and configurations. If the stored directory can be completely 
used would need additional clearification, i.e. for each new version.

Kind regards

Georg




Von:Martin Maechler 
An: 
Kopie:   ,
Datum:  23.02.2017 08:37
Betreff:Re: [R] RStudio: Place for Storing Options



> Jeff Newmiller 
> on Sat, 11 Feb 2017 08:09:36 -0800 writes:

> For the record, then, Google listened to my incantation of
> "rstudio configuration file" and the second result was:

> 
https://support.rstudio.com/hc/en-us/articles/200534577-Resetting-RStudio-Desktop-s-State


> RStudio Desktop is also open source, so you can download
> the source code and look at the operating-system-specific
> bits (for "where") if the above link goes out of date or
> disappears.

Thanks a lot, Jeff!

And for the archives:  On reasonable OS's,  the hidden
directory/folder containing all the info is
  ~/.rstudio-desktop/
and if "things are broken" the recommendation is to rename that
   mv ~/.rstudio-desktop  ~/backup-rstudio-desktop
and (zip and) send along with your e-mail to the experts for diagnosis.


> On Thu, 9 Feb 2017, Martin Maechler wrote:

>> 
>>> Ulrik Stervbo  on Thu, 9
>>> Feb 2017 14:37:57 + writes:
>> 
>> > Hi Georg, > maybe someone here knows, but I think you
>> are more likely to get answers to > Rstudio related
>> questions with RStudio support: >
>> https://support.rstudio.com/hc/en-us
>> 
>> > Best, > Ulrik
>> 
>> Indeed, thank you, Ulrik.
>> 
>> In this special case, however, I'm quite sure many
>> readers of R-help would be interested in the answer; so
>> once you receive an answer, please post it (or a link to
>> a public URL with it) here on R-help, thank you in
>> advance.
>> 
>> We would like to be able to *save*, or sometimes *set* /
>> *reset* such options "in a scripted manner", e.g. for
>> controlled exam sessions.
>> 
>> Martin Maechler, ETH Zurich
>> 
>> > On Thu, 9 Feb 2017 at 12:35 
>> wrote:
>> 
>> >> Hi All, >> I would like to make a backup of my RStudio
>> IDE options I configure using >> "Tools/Global Options"
>> from the menu bar. Searching the >> web did not reveal
>> anything.
>> 
>> >> Can you tell me where RStudio IDE does store its
>> configuration?
>> 
>> >> Kind regards >> Georg
>> 
>> __
>> 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] R Course in Dublin (May 24th-May 26th, 2017) Introductory -> Modern

2017-04-19 Thread Antony Unwin
An R course from introductory to modern will be given by

Louis Aslett (Durham University, author of the packages PhaseType and 
ReliabilityTheory)
and
Antony Unwin (author of the book “Graphical Data Analysis with R” CRC Press 
2015  http://www.gradaanwr.net ).

The course will be held in Dublin at the IPA on Lansdowne Road (next to the 
Rugby ground) from May 24th to May 26th, 2017.

Details at  

http://insightsc.ie/training/r-statistical-software/ 


or send an email to train...@insightsc.ie  for 
further information

Antony Unwin
Insight Statistical Consulting, Dublin, Ireland
University of Augsburg, Germany
[[alternative HTML version deleted]]

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

Re: [R] Safeguarded Newton method for function minimization

2017-04-19 Thread Martin Maechler
> J C Nash 
> on Tue, 18 Apr 2017 13:32:52 -0400 writes:

> Recently Marie Boehnstedt reported a bug in the nlm()
> function for function minimization when both gradient and
> hessian are provided.
Indeed, on R's Bugzilla here :
https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17249

> She has provided a work-around for some cases and it seems
> this will get incorporated into the R function eventually.

indeed the first part -- fixing the wrong choldc() -- in the C code has
been in my version of R-devel for a while now.

See my follow up
https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17249#c4  and #c5

including my attachment which is an extended version of Marie's original :
https://bugs.r-project.org/bugzilla/attachment.cgi?id=2246

As that mentions _and_ shows: Fixing choldc() solves the problem
for the 2D Rosenbrook example, but _not_ the  4D Wood example.

> However, despite the great number of packages on CRAN,
> there does not appear to be a straightforward Newton
> approach to function minimization. This may be because
> providing the code for a hessian (the matrix of second
> derivatives) is a lot of work and error-prone.

> (R could also use some good tools for Automatic Differentiation).

The last part of what you say above is not at all true:
R -- and S (& S+ | S-PLUS) before it! -- always had deriv() and deriv3()
and my attachment above _shows_ you how to use  deriv3() to get
both the gradient and the hessian  via a version of automatic
differentiation completely effortlessly !!

For ease of readers, that part here, with an example:

##' Wood function (4 arguments 'x1' ... 'x4')
fwood <- function(x1,x2,x3,x4) {
  100*(x1^2-x2)^2 + (1-x1)^2 + 90*(x3^2-x4)^2 + (1-x3)^2 +
10.1*((1-x2)^2 + (1-x4)^2) + 19.8*(1-x2)*(1-x4)
}
## automatically construct correct gradient and hessian:
woodf.gh <- function(x) {
  stopifnot(is.numeric(x))
  woodGH <- deriv3(body(fwood)[[2]],
   c("x1","x2","x3","x4"), function.arg=TRUE)
  if(length(x) == 4)
woodGH(x[1],x[2],x[3],x[4])
  else if(is.matrix(x) && ncol(x) == 4)
woodGH(x[,1], x[,2], x[,3], x[,4])
  else stop("'x' must have length 4 or be a matrix with 4 columns")
}

and now get both the function f(x), gradient g(x) and Hessian H(x) 
for
 x = (0 0 0 0),
 x = (1 1 1 1), and
 x = (1 2 3 4)

with such a simple calle :
 
  > woodf.gh(rbind(0, 1, 1:4))
  [1]   42.00.0 2514.4
  attr(,"gradient")
 x1x2   x3 x4
  [1,]   -2 -40.0   -2  -40.0
  [2,]0   0.000.0
  [3,] -400 279.6 5404 -819.6
  attr(,"hessian")
  , , x1

x1   x2 x3 x4
  [1,]   20  0  0
  [2,] 802 -400  0  0
  [3,] 402 -400  0  0

  , , x2

 x1x2 x3   x4
  [1,]0 220.2  0 19.8
  [2,] -400 220.2  0 19.8
  [3,] -400 220.2  0 19.8

  , , x3

   x1 x2   x3x4
  [1,]  0  02 0
  [2,]  0  0  722  -360
  [3,]  0  0 8282 -1080

  , , x4

   x1   x2x3x4
  [1,]  0 19.8 0 200.2
  [2,]  0 19.8  -360 200.2
  [3,]  0 19.8 -1080 200.2

  > 

> I have also noted that a number of researchers try to
> implement textbook methods and run into trouble when maths
> and computing are not quite in sync. Therefore, I wrote a
> simple safeguarded Newton and put a small package on
> R-forge at

> https://r-forge.r-project.org/R/?group_id=395

> Note that Newton's method is used to solve nonlinear
> equations. In fact, for function minimization, we apply it
> to solve g(x) = 0 where g is the gradient and x is the
> vector of parameters. In part, safeguards ensure we reduce
> the function f(x) at each step to avoid some of the
> difficulties that may arise from a non-positive-definite
> hessian.

> In the package, I have a very simple quadratic test, the
> Rosenbrock test function and the Wood test function. The
> method fails on the last function -- the hessian is not
> positive definite where it stops.

> Before submitting this package to CRAN, I would like to
> see its behaviour on other test problems, but am lazy
> enough to wish to avoid creating the hessian code. If
> anyone has such code, it would be very welcome. Please
> contact me off-list. If I get some workable examples that
> are open for public view, I'll report back here.

> John Nash

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

[R] Multiple Histograms in R

2017-04-19 Thread prateek pande
Hi,

I have a data as mentioned below(at the bottom)

Now out of that data i have to create multiple histograms in a single view
in  R. On that histogram i need on x -axis binned data with Breaks 10 and
on y axis event rate . Here churn is dependent variable.


*for example, for mou_mean , on x -axis on histogram i need Bins(mou_mean)
and on y - axis in need Churn%age. *
*Bins(mou_mean)*

*Churn %age*
23-43  0.23%
33-53  0.5%
43-63   0.3%
53-73   0.4%
63-83   0.7%
83-1030.8%

Please help


*mou_mean*

*totalmrc_mean*

*rev_range*

*mou_range*

*Churn*

23

24

25

27

1

45

46

47

49

1

43

44

45

47

1

45

46

47

49

0

56

57

58

60

0

67

68

69

71

1

67

68

69

71

0

44

45

46

48

1

33

34

35

37

0

90

91

92

94

1

87

88

89

91

1

76

77

78

80

1

33

34

35

37

1

44

45

46

48

1

[[alternative HTML version deleted]]

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


Re: [R] Multiple Histograms in R

2017-04-19 Thread Rui Barradas

Hello,

Maybe package psych, function multi.hist is what you want.

https://cran.r-project.org/web/packages/psych/index.html

And don't post in HTML, your data is unreadable.

Hope this helps,

Rui Barradas

Em 19-04-2017 14:05, prateek pande escreveu:

Hi,

I have a data as mentioned below(at the bottom)

Now out of that data i have to create multiple histograms in a single view
in  R. On that histogram i need on x -axis binned data with Breaks 10 and
on y axis event rate . Here churn is dependent variable.


*for example, for mou_mean , on x -axis on histogram i need Bins(mou_mean)
and on y - axis in need Churn%age. *
*Bins(mou_mean)*

*Churn %age*
23-43  0.23%
33-53  0.5%
43-63   0.3%
53-73   0.4%
63-83   0.7%
83-1030.8%

Please help


*mou_mean*

*totalmrc_mean*

*rev_range*

*mou_range*

*Churn*

23

24

25

27

1

45

46

47

49

1

43

44

45

47

1

45

46

47

49

0

56

57

58

60

0

67

68

69

71

1

67

68

69

71

0

44

45

46

48

1

33

34

35

37

0

90

91

92

94

1

87

88

89

91

1

76

77

78

80

1

33

34

35

37

1

44

45

46

48

1

[[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] Safeguarded Newton method for function minimization

2017-04-19 Thread J C Nash

I should have given a more detailed explanation about Automatic Differentiation.
As Martin points out, there are some AD elements in deriv etc., but to my view
they are related more to symbolic differentiation, and not in the same space
as AD Model Builder or its successor whose name eludes me at the moment.
Nor like ADIFOR or ADOLC that can provide the derivative of a subprogram.

However, Martin's example of the Wood function shows what can be done, and this
is a valuable case. Indeed it shows a syntax of which I was previously unaware!
Because it is fairly complicated, I'm not sure I would say "effortlessly", but I
will certainly be copying it. Thanks. Previously, I've done the steps to get the
function partly manually to get to the functional form, as in Chapter 10 of my
Nonlinear Parameter Optimization book.

Note that there are functions all in R that are similar to the deriv() and 
deriv3()
in package nlsr by Duncan Murdoch and me. There is a facility to extend the 
derivatives
table to new functions. We can also generate the R gradient functions from 
expressions.

I'll take this chance to note that the Wood problem is NOT solved by nlm() with
analytic hessian, nor by a safeguarded or unsafeguarded Newton. And I ran a 
version
of the Fortran code UNCMIN that is the origin of nlm() and got a similar early 
termination.
But the hessian when these codes halt is not positive definite, so we are 
outside
the assumed conditions for these methods. Dealing with a non-pos-def hessian in
function minimization has created a small industry in Ph Ds for researchers in
optimization.

Thanks again for Martin's work.

JN




On 2017-04-19 08:56 AM, Martin Maechler wrote:

J C Nash 
on Tue, 18 Apr 2017 13:32:52 -0400 writes:


> Recently Marie Boehnstedt reported a bug in the nlm()
> function for function minimization when both gradient and
> hessian are provided.
Indeed, on R's Bugzilla here :
https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17249

> She has provided a work-around for some cases and it seems
> this will get incorporated into the R function eventually.

indeed the first part -- fixing the wrong choldc() -- in the C code has
been in my version of R-devel for a while now.

See my follow up
https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17249#c4  and #c5

including my attachment which is an extended version of Marie's original :
https://bugs.r-project.org/bugzilla/attachment.cgi?id=2246

As that mentions _and_ shows: Fixing choldc() solves the problem
for the 2D Rosenbrook example, but _not_ the  4D Wood example.

> However, despite the great number of packages on CRAN,
> there does not appear to be a straightforward Newton
> approach to function minimization. This may be because
> providing the code for a hessian (the matrix of second
> derivatives) is a lot of work and error-prone.

> (R could also use some good tools for Automatic Differentiation).

The last part of what you say above is not at all true:
R -- and S (& S+ | S-PLUS) before it! -- always had deriv() and deriv3()
and my attachment above _shows_ you how to use  deriv3() to get
both the gradient and the hessian  via a version of automatic
differentiation completely effortlessly !!

For ease of readers, that part here, with an example:

##' Wood function (4 arguments 'x1' ... 'x4')
fwood <- function(x1,x2,x3,x4) {
  100*(x1^2-x2)^2 + (1-x1)^2 + 90*(x3^2-x4)^2 + (1-x3)^2 +
10.1*((1-x2)^2 + (1-x4)^2) + 19.8*(1-x2)*(1-x4)
}
## automatically construct correct gradient and hessian:
woodf.gh <- function(x) {
  stopifnot(is.numeric(x))
  woodGH <- deriv3(body(fwood)[[2]],
   c("x1","x2","x3","x4"), function.arg=TRUE)
  if(length(x) == 4)
woodGH(x[1],x[2],x[3],x[4])
  else if(is.matrix(x) && ncol(x) == 4)
woodGH(x[,1], x[,2], x[,3], x[,4])
  else stop("'x' must have length 4 or be a matrix with 4 columns")
}

and now get both the function f(x), gradient g(x) and Hessian H(x)
for
 x = (0 0 0 0),
 x = (1 1 1 1), and
 x = (1 2 3 4)

with such a simple calle :

  > woodf.gh(rbind(0, 1, 1:4))
  [1]   42.00.0 2514.4
  attr(,"gradient")
 x1x2   x3 x4
  [1,]   -2 -40.0   -2  -40.0
  [2,]0   0.000.0
  [3,] -400 279.6 5404 -819.6
  attr(,"hessian")
  , , x1

x1   x2 x3 x4
  [1,]   20  0  0
  [2,] 802 -400  0  0
  [3,] 402 -400  0  0

  , , x2

 x1x2 x3   x4
  [1,]0 220.2  0 19.8
  [2,] -400 220.2  0 19.8
  [3,] -400 220.2  0 19.8

  , , x3

   x1 x2   x3x4
  [1,]  0  02 0
  [2,]  0  0  722  -360
  [3,]  0  0 8282 -1080

  , , x4

   x1   x2x3x4
  [1,]  0 19.8 0 200.2
  [2,]  0 19.8  -360 200.2
  [3,]  0 19.8 -1080 200.2

  >

> I have also noted that a number of researchers try to
> implement textbook methods and run into trouble when maths
> and computing are not quite in sync. Therefore, I wrote a
> simple safeguarded Newton and put 

Re: [R] Multiple Histograms in R

2017-04-19 Thread Bert Gunter
Also, *if* this is homework, don't post at all, as this list is not
for doing homework (though, for better or worse, sometimes such help
is provided).


-- 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, Apr 19, 2017 at 6:20 AM, Rui Barradas  wrote:
> Hello,
>
> Maybe package psych, function multi.hist is what you want.
>
> https://cran.r-project.org/web/packages/psych/index.html
>
> And don't post in HTML, your data is unreadable.
>
> Hope this helps,
>
> Rui Barradas
>
>
> Em 19-04-2017 14:05, prateek pande escreveu:
>>
>> Hi,
>>
>> I have a data as mentioned below(at the bottom)
>>
>> Now out of that data i have to create multiple histograms in a single view
>> in  R. On that histogram i need on x -axis binned data with Breaks 10 and
>> on y axis event rate . Here churn is dependent variable.
>>
>>
>> *for example, for mou_mean , on x -axis on histogram i need Bins(mou_mean)
>> and on y - axis in need Churn%age. *
>> *Bins(mou_mean)*
>>
>> *Churn %age*
>> 23-43  0.23%
>> 33-53  0.5%
>> 43-63   0.3%
>> 53-73   0.4%
>> 63-83   0.7%
>> 83-1030.8%
>>
>> Please help
>>
>>
>> *mou_mean*
>>
>> *totalmrc_mean*
>>
>> *rev_range*
>>
>> *mou_range*
>>
>> *Churn*
>>
>> 23
>>
>> 24
>>
>> 25
>>
>> 27
>>
>> 1
>>
>> 45
>>
>> 46
>>
>> 47
>>
>> 49
>>
>> 1
>>
>> 43
>>
>> 44
>>
>> 45
>>
>> 47
>>
>> 1
>>
>> 45
>>
>> 46
>>
>> 47
>>
>> 49
>>
>> 0
>>
>> 56
>>
>> 57
>>
>> 58
>>
>> 60
>>
>> 0
>>
>> 67
>>
>> 68
>>
>> 69
>>
>> 71
>>
>> 1
>>
>> 67
>>
>> 68
>>
>> 69
>>
>> 71
>>
>> 0
>>
>> 44
>>
>> 45
>>
>> 46
>>
>> 48
>>
>> 1
>>
>> 33
>>
>> 34
>>
>> 35
>>
>> 37
>>
>> 0
>>
>> 90
>>
>> 91
>>
>> 92
>>
>> 94
>>
>> 1
>>
>> 87
>>
>> 88
>>
>> 89
>>
>> 91
>>
>> 1
>>
>> 76
>>
>> 77
>>
>> 78
>>
>> 80
>>
>> 1
>>
>> 33
>>
>> 34
>>
>> 35
>>
>> 37
>>
>> 1
>>
>> 44
>>
>> 45
>>
>> 46
>>
>> 48
>>
>> 1
>>
>> [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] A new -up? / mailing list woes

2017-04-19 Thread J C Nash
A slightly different mailing list problem was preventing me from posting without going to moderation. Talking with Paul 
Gilbert, I realized that my email (handled by Thunderbird) was using an outgoing server that was not the one normally 
associated with my R-help subscription address. Changing that setting allowed unmoderated contributions -- like this 
one. I've suggested to Martin M that a note about this might be worth adding to the subscription page, since a lot of 
folk have multiple emails handled by clients like Thunderbird that may use a common outgoing SMTP server.


Sorry that this is not precisely about R, but it does concern R-help and other lists we use, and like the Windows/Mac 
"hide file extensions of common file types", the glitches keep us from doing real work.


JN


On 2017-04-19 04:32 AM, Rolf Turner wrote:


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



__
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] Is there a way to open R terminal running in the background

2017-04-19 Thread Brad P
Hello,

I am working on a GUI, which is working well so far.
I am working on a Windows 7 machine with 64 bit R (Microsoft R Open 3.3.2)

Essentially:
1) a VBS executable is used to open the GUI leaving the R terminal running
in the background but not showing using:

CreateObject("Wscript.Shell").Run R.exe CMD BATCH MyGUI.R , 0, TRUE

2) for the GUI I use code similar to that shown below

My question is, when the GUI is opened, an instance of R runs in the
background.
Is there a way to show ('open') that R terminal?  And similarly put it back
as invisible.
I am imagining that I can write an R function to either open this directly
or by using Windows OS commands

I have found  a way to open a terminal using the code at this link, but it
is not ideal (I want an actual R terminal):
http://freesourcecode.net/rprojects/104/sourcecode/ex-RGtk2-terminal.R



# MyGUI.R ##
library(RGtk2)

# initiate main window
main_window <<- gtkWindow(show = FALSE)
main_window["title"] <- "My GUI"
main_window$setDefaultSize(800, 600) # (width, height)

# problem: red [X] in top-right leaves underlying R instance open
main_window$deletable <- FALSE  # makes the top-right [X] delete option not
work ...
# Can this button be reprogrammed??

# function to read in data file
open_cb <- function(widget, window) {
  dialog <- gtkFileChooserDialog("Choose a CSV file", window, "open",
 "gtk-cancel", GtkResponseType["cancel"],
"gtk-open",
 GtkResponseType["accept"])
  if (dialog$run() == GtkResponseType["accept"]) {
fileName <<- dialog$getFilename()
dat <<- read.csv(fileName, header=TRUE, na.strings=c("","NA"))
  }
  dialog$destroy()
  statusbar$push(info, paste("Dataset", fileName, "is currently loaded."))
}

# variable to indicate whether it is time to stop R
StopNOW <<- 0

quit_cb <- function(widget, window){
  StopNOW <<- 1
  window$destroy()
  quit(save = "no")
}

# Lists actions in dropdown or toolbar menus
actions <- list(
  list("FileMenu", NULL, "Input File"),
  list("Open", "gtk-open", "_Import CSV File", "O",
   "Select a CSV file to load as a spreadsheet", open_cb),
  list("Quit", "gtk-quit", "_Quit", "Q",
   "Quit the application", quit_cb)
)
action_group <- gtkActionGroup("spreadsheetActions")
action_group$addActions(actions, main_window)

ui_manager <- gtkUIManager()
ui_manager$insertActionGroup(action_group, 0)
merge <- ui_manager$newMergeId()
ui_manager$addUi(merge.id = merge, path = "/", name = "menubar", action =
NULL, type = "menubar", top = FALSE)
ui_manager$addUi(merge, "/menubar", "file", "FileMenu", "menu", FALSE)
ui_manager$addUi(merge, "/menubar/file", "open", "Open", "menuitem", FALSE)
ui_manager$addUi(merge, "/", "toolbar", NULL, "toolbar", FALSE)
ui_manager$addUi(merge, "/toolbar", "quit", "Quit", "toolitem", FALSE)

menubar <- ui_manager$getWidget("/menubar")
toolbar <- ui_manager$getWidget("/toolbar")
main_window$addAccelGroup(ui_manager$getAccelGroup())

# Status bar shown at bottom left of GUI
statusbar <- gtkStatusbar()
info <- statusbar$getContextId("info")
statusbar$push(info, "Ready")

notebook <- gtkNotebook()
notebook$setTabPos("bottom")

vbox <- gtkVBox(homogeneous = FALSE, spacing = 0)
vbox$packStart(menubar, expand = FALSE, fill = FALSE, padding = 0)
vbox$packStart(toolbar, FALSE, FALSE, 0) # Uncomment if toolbar is used
vbox$packStart(notebook, TRUE, TRUE, 0)
vbox$packStart(statusbar, FALSE, FALSE, 0)
main_window$add(vbox)

# open GUI window
main_window$show()

gtkWidgetGrabFocus(main_window)

# This repeat loop & stopNOW variable keeps the GUI window open until closed
repeat {
Sys.sleep(0.001)
if (StopNOW == 1) break
  }
# End GUI Code

[[alternative HTML version deleted]]

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


Re: [R] Is there a way to open R terminal running in the background

2017-04-19 Thread Duncan Murdoch

On 19/04/2017 11:44 AM, Brad P wrote:

Hello,

I am working on a GUI, which is working well so far.
I am working on a Windows 7 machine with 64 bit R (Microsoft R Open 3.3.2)

Essentially:
1) a VBS executable is used to open the GUI leaving the R terminal running
in the background but not showing using:

CreateObject("Wscript.Shell").Run R.exe CMD BATCH MyGUI.R , 0, TRUE


I think this is more of a Microsoft question than anything specific to 
R.  How do you ask VBS to show you a process that it is running?


No idea where to go with VBS questions.

Duncan Murdoch



2) for the GUI I use code similar to that shown below

My question is, when the GUI is opened, an instance of R runs in the
background.
Is there a way to show ('open') that R terminal?  And similarly put it back
as invisible.
I am imagining that I can write an R function to either open this directly
or by using Windows OS commands

I have found  a way to open a terminal using the code at this link, but it
is not ideal (I want an actual R terminal):
http://freesourcecode.net/rprojects/104/sourcecode/ex-RGtk2-terminal.R



# MyGUI.R ##
library(RGtk2)

# initiate main window
main_window <<- gtkWindow(show = FALSE)
main_window["title"] <- "My GUI"
main_window$setDefaultSize(800, 600) # (width, height)

# problem: red [X] in top-right leaves underlying R instance open
main_window$deletable <- FALSE  # makes the top-right [X] delete option not
work ...
# Can this button be reprogrammed??

# function to read in data file
open_cb <- function(widget, window) {
  dialog <- gtkFileChooserDialog("Choose a CSV file", window, "open",
 "gtk-cancel", GtkResponseType["cancel"],
"gtk-open",
 GtkResponseType["accept"])
  if (dialog$run() == GtkResponseType["accept"]) {
fileName <<- dialog$getFilename()
dat <<- read.csv(fileName, header=TRUE, na.strings=c("","NA"))
  }
  dialog$destroy()
  statusbar$push(info, paste("Dataset", fileName, "is currently loaded."))
}

# variable to indicate whether it is time to stop R
StopNOW <<- 0

quit_cb <- function(widget, window){
  StopNOW <<- 1
  window$destroy()
  quit(save = "no")
}

# Lists actions in dropdown or toolbar menus
actions <- list(
  list("FileMenu", NULL, "Input File"),
  list("Open", "gtk-open", "_Import CSV File", "O",
   "Select a CSV file to load as a spreadsheet", open_cb),
  list("Quit", "gtk-quit", "_Quit", "Q",
   "Quit the application", quit_cb)
)
action_group <- gtkActionGroup("spreadsheetActions")
action_group$addActions(actions, main_window)

ui_manager <- gtkUIManager()
ui_manager$insertActionGroup(action_group, 0)
merge <- ui_manager$newMergeId()
ui_manager$addUi(merge.id = merge, path = "/", name = "menubar", action =
NULL, type = "menubar", top = FALSE)
ui_manager$addUi(merge, "/menubar", "file", "FileMenu", "menu", FALSE)
ui_manager$addUi(merge, "/menubar/file", "open", "Open", "menuitem", FALSE)
ui_manager$addUi(merge, "/", "toolbar", NULL, "toolbar", FALSE)
ui_manager$addUi(merge, "/toolbar", "quit", "Quit", "toolitem", FALSE)

menubar <- ui_manager$getWidget("/menubar")
toolbar <- ui_manager$getWidget("/toolbar")
main_window$addAccelGroup(ui_manager$getAccelGroup())

# Status bar shown at bottom left of GUI
statusbar <- gtkStatusbar()
info <- statusbar$getContextId("info")
statusbar$push(info, "Ready")

notebook <- gtkNotebook()
notebook$setTabPos("bottom")

vbox <- gtkVBox(homogeneous = FALSE, spacing = 0)
vbox$packStart(menubar, expand = FALSE, fill = FALSE, padding = 0)
vbox$packStart(toolbar, FALSE, FALSE, 0) # Uncomment if toolbar is used
vbox$packStart(notebook, TRUE, TRUE, 0)
vbox$packStart(statusbar, FALSE, FALSE, 0)
main_window$add(vbox)

# open GUI window
main_window$show()

gtkWidgetGrabFocus(main_window)

# This repeat loop & stopNOW variable keeps the GUI window open until closed
repeat {
Sys.sleep(0.001)
if (StopNOW == 1) break
  }
# End GUI 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] Prediction plots

2017-04-19 Thread Boris Steipe
Can you provide a small reproducible example and explain what exactly is going 
wrong?

Just a handful of data points will do.


B.



> On Apr 18, 2017, at 2:16 PM, Santiago Bueno  wrote:
> 
> Thanks Boris, the following is an extract of my data. I have developed
> biomass models using codes like:
> 
> start <- coef (lm(log(Btot)~I(log(dbh**2*haut)),data=dat[dat$Btot>0,]))
> 
> start[1] <- exp(start[1])
> 
> names(start) <- c("a","b")
> 
> M1 <- nls(Btot~a*(dbh**2*haut)**b,data=dat,start=start,weights=1/dat$dbh**4)
> 
> 
> start <- coef(lm(log(Btot)~I(log(dbh))+I(log(haut)),data=dat[dat$Btot>0,]))
> 
> start[1] <- exp(start[1])
> 
> names(start) <- c("a","b1","b2")
> 
> M2 <- nls(Btot~a*dbh**b1*haut**b2,data=dat,start=start,weights=1/dat$dbh**4)
> 
> 
> Tree No dbh haut Btot
> 1 35.00 18.90 0.535
> 2 25.00 16.60 0.248
> 3 23.00 19.50 0.228
> 4 13.50 15.60 0.080
> 5 20.00 18.80 0.172
> 6 23.00 17.40 0.190
> 7 29.00 19.90 0.559
> 8 17.60 18.20 0.117
> 9 31.00 25.30 0.645
> 10 26.00 23.50 0.394
> 11 13.00 13.00 0.038
> 12 32.00 20.70 0.443
> It is my interest to get prediction plots for the models. I have tried to
> use the following codes with no success: Let m be one of the fitted models
> with dbh as the only entry. To construct a plot of the predictions made by
> this model I have tried:
> with(dat,plot(dbh,Btot,xlab="Dbh(cm)",ylab="Biomass (t)"))
> D <- seq(par("usr")[1],par("usr")[2],length=200)
> lines(D,predict(m,newdata=data.frame(dbh=D)),col="red")
> For a model m that has dbh and height as entries, I have tried to get its
> predictions as follows:
> D <- seq(0,180,length=20)
> H <- seq(0,61,length=20)
> B <- matrix(predict(m,newdata=expand.grid(dbh=D,height=H)),length(D))
> 
> Can someone provide help please!!!
> 
> 
> Best regards,
> 
> Santiago Bueno
> 
>   [[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] Is there a way to open R terminal running in the background

2017-04-19 Thread Brad P
Duncan,

I was thinking to have an additional button in the GUI which would use an R
function to open the window/process running in the background.
I don't think this is a VBS question, as it is simply used to start the GUI
without opening R and calling it directly.
I suppose this may be considered a Windows question - I will look further
into opening a process running in the background using DOS commands.

Thank you for your time.


On Wed, Apr 19, 2017 at 12:14 PM, Duncan Murdoch 
wrote:

> On 19/04/2017 11:44 AM, Brad P wrote:
>
>> Hello,
>>
>> I am working on a GUI, which is working well so far.
>> I am working on a Windows 7 machine with 64 bit R (Microsoft R Open 3.3.2)
>>
>> Essentially:
>> 1) a VBS executable is used to open the GUI leaving the R terminal running
>> in the background but not showing using:
>>
>> CreateObject("Wscript.Shell").Run R.exe CMD BATCH MyGUI.R , 0, TRUE
>>
>
> I think this is more of a Microsoft question than anything specific to R.
> How do you ask VBS to show you a process that it is running?
>
> No idea where to go with VBS questions.
>
> Duncan Murdoch
>
>
>> 2) for the GUI I use code similar to that shown below
>>
>> My question is, when the GUI is opened, an instance of R runs in the
>> background.
>> Is there a way to show ('open') that R terminal?  And similarly put it
>> back
>> as invisible.
>> I am imagining that I can write an R function to either open this directly
>> or by using Windows OS commands
>>
>> I have found  a way to open a terminal using the code at this link, but it
>> is not ideal (I want an actual R terminal):
>> http://freesourcecode.net/rprojects/104/sourcecode/ex-RGtk2-terminal.R
>>
>>
>>
>> # MyGUI.R 
>> ##
>> library(RGtk2)
>>
>> # initiate main window
>> main_window <<- gtkWindow(show = FALSE)
>> main_window["title"] <- "My GUI"
>> main_window$setDefaultSize(800, 600) # (width, height)
>>
>> # problem: red [X] in top-right leaves underlying R instance open
>> main_window$deletable <- FALSE  # makes the top-right [X] delete option
>> not
>> work ...
>> # Can this button be reprogrammed??
>>
>> # function to read in data file
>> open_cb <- function(widget, window) {
>>   dialog <- gtkFileChooserDialog("Choose a CSV file", window, "open",
>>  "gtk-cancel", GtkResponseType["cancel"],
>> "gtk-open",
>>  GtkResponseType["accept"])
>>   if (dialog$run() == GtkResponseType["accept"]) {
>> fileName <<- dialog$getFilename()
>> dat <<- read.csv(fileName, header=TRUE, na.strings=c("","NA"))
>>   }
>>   dialog$destroy()
>>   statusbar$push(info, paste("Dataset", fileName, "is currently loaded."))
>> }
>>
>> # variable to indicate whether it is time to stop R
>> StopNOW <<- 0
>>
>> quit_cb <- function(widget, window){
>>   StopNOW <<- 1
>>   window$destroy()
>>   quit(save = "no")
>> }
>>
>> # Lists actions in dropdown or toolbar menus
>> actions <- list(
>>   list("FileMenu", NULL, "Input File"),
>>   list("Open", "gtk-open", "_Import CSV File", "O",
>>"Select a CSV file to load as a spreadsheet", open_cb),
>>   list("Quit", "gtk-quit", "_Quit", "Q",
>>"Quit the application", quit_cb)
>> )
>> action_group <- gtkActionGroup("spreadsheetActions")
>> action_group$addActions(actions, main_window)
>>
>> ui_manager <- gtkUIManager()
>> ui_manager$insertActionGroup(action_group, 0)
>> merge <- ui_manager$newMergeId()
>> ui_manager$addUi(merge.id = merge, path = "/", name = "menubar", action =
>> NULL, type = "menubar", top = FALSE)
>> ui_manager$addUi(merge, "/menubar", "file", "FileMenu", "menu", FALSE)
>> ui_manager$addUi(merge, "/menubar/file", "open", "Open", "menuitem",
>> FALSE)
>> ui_manager$addUi(merge, "/", "toolbar", NULL, "toolbar", FALSE)
>> ui_manager$addUi(merge, "/toolbar", "quit", "Quit", "toolitem", FALSE)
>>
>> menubar <- ui_manager$getWidget("/menubar")
>> toolbar <- ui_manager$getWidget("/toolbar")
>> main_window$addAccelGroup(ui_manager$getAccelGroup())
>>
>> # Status bar shown at bottom left of GUI
>> statusbar <- gtkStatusbar()
>> info <- statusbar$getContextId("info")
>> statusbar$push(info, "Ready")
>>
>> notebook <- gtkNotebook()
>> notebook$setTabPos("bottom")
>>
>> vbox <- gtkVBox(homogeneous = FALSE, spacing = 0)
>> vbox$packStart(menubar, expand = FALSE, fill = FALSE, padding = 0)
>> vbox$packStart(toolbar, FALSE, FALSE, 0) # Uncomment if toolbar is used
>> vbox$packStart(notebook, TRUE, TRUE, 0)
>> vbox$packStart(statusbar, FALSE, FALSE, 0)
>> main_window$add(vbox)
>>
>> # open GUI window
>> main_window$show()
>>
>> gtkWidgetGrabFocus(main_window)
>>
>> # This repeat loop & stopNOW variable keeps the GUI window open until
>> closed
>> repeat {
>> Sys.sleep(0.001)
>> if (StopNOW == 1) break
>>   }
>> # End GUI Code
>>
>> [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and m

Re: [R] Is there a way to open R terminal running in the background

2017-04-19 Thread Duncan Murdoch

On 19/04/2017 12:45 PM, Brad P wrote:

Duncan,

I was thinking to have an additional button in the GUI which would use
an R function to open the window/process running in the background.
I don't think this is a VBS question, as it is simply used to start the
GUI without opening R and calling it directly.
I suppose this may be considered a Windows question - I will look
further into opening a process running in the background using DOS commands.


If you run "R.exe CMD BATCH MyGUI.R", then R doesn't maintain a window 
at all.  It just reads input and writes output.  So I think it really is 
the higher level thing (VBS in your case, cmd.exe if you run that at a 
prompt) that might have the ability to do what you want.


Duncan Murdoch



Thank you for your time.


On Wed, Apr 19, 2017 at 12:14 PM, Duncan Murdoch
mailto:murdoch.dun...@gmail.com>> wrote:

On 19/04/2017 11:44 AM, Brad P wrote:

Hello,

I am working on a GUI, which is working well so far.
I am working on a Windows 7 machine with 64 bit R (Microsoft R
Open 3.3.2)

Essentially:
1) a VBS executable is used to open the GUI leaving the R
terminal running
in the background but not showing using:

CreateObject("Wscript.Shell").Run R.exe CMD BATCH MyGUI.R , 0, TRUE


I think this is more of a Microsoft question than anything specific
to R.  How do you ask VBS to show you a process that it is running?

No idea where to go with VBS questions.

Duncan Murdoch


2) for the GUI I use code similar to that shown below

My question is, when the GUI is opened, an instance of R runs in the
background.
Is there a way to show ('open') that R terminal?  And similarly
put it back
as invisible.
I am imagining that I can write an R function to either open
this directly
or by using Windows OS commands

I have found  a way to open a terminal using the code at this
link, but it
is not ideal (I want an actual R terminal):
http://freesourcecode.net/rprojects/104/sourcecode/ex-RGtk2-terminal.R




# MyGUI.R
##
library(RGtk2)

# initiate main window
main_window <<- gtkWindow(show = FALSE)
main_window["title"] <- "My GUI"
main_window$setDefaultSize(800, 600) # (width, height)

# problem: red [X] in top-right leaves underlying R instance open
main_window$deletable <- FALSE  # makes the top-right [X] delete
option not
work ...
# Can this button be reprogrammed??

# function to read in data file
open_cb <- function(widget, window) {
  dialog <- gtkFileChooserDialog("Choose a CSV file", window,
"open",
 "gtk-cancel",
GtkResponseType["cancel"],
"gtk-open",
 GtkResponseType["accept"])
  if (dialog$run() == GtkResponseType["accept"]) {
fileName <<- dialog$getFilename()
dat <<- read.csv(fileName, header=TRUE, na.strings=c("","NA"))
  }
  dialog$destroy()
  statusbar$push(info, paste("Dataset", fileName, "is currently
loaded."))
}

# variable to indicate whether it is time to stop R
StopNOW <<- 0

quit_cb <- function(widget, window){
  StopNOW <<- 1
  window$destroy()
  quit(save = "no")
}

# Lists actions in dropdown or toolbar menus
actions <- list(
  list("FileMenu", NULL, "Input File"),
  list("Open", "gtk-open", "_Import CSV File", "O",
   "Select a CSV file to load as a spreadsheet", open_cb),
  list("Quit", "gtk-quit", "_Quit", "Q",
   "Quit the application", quit_cb)
)
action_group <- gtkActionGroup("spreadsheetActions")
action_group$addActions(actions, main_window)

ui_manager <- gtkUIManager()
ui_manager$insertActionGroup(action_group, 0)
merge <- ui_manager$newMergeId()
ui_manager$addUi(merge.id  = merge, path = "/",
name = "menubar", action =
NULL, type = "menubar", top = FALSE)
ui_manager$addUi(merge, "/menubar", "file", "FileMenu", "menu",
FALSE)
ui_manager$addUi(merge, "/menubar/file", "open", "Open",
"menuitem", FALSE)
ui_manager$addUi(merge, "/", "toolbar", NULL, "toolbar", FALSE)
ui_manager$addUi(merge, "/toolbar", "quit", "Quit", "toolitem",
FALSE)

menubar <- ui_manager$getWidget("/menubar")
toolbar <- ui_manager$getWidget("/toolbar")
main_window$addAccelGroup(ui_manager$getAccelGroup())

# Status bar shown at bottom left of GUI
statusbar <- 

Re: [R] A new -up?

2017-04-19 Thread Santosh
otherwise explain it as unexplained "random variable"/ "residual error" :)

Santosh

On Wed, Apr 19, 2017 at 1:32 AM, Rolf Turner 
wrote:

>
> 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/posti
> ng-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] Setting .Rprofile for RStudio on a Windows 7 x64bit

2017-04-19 Thread Henrik Bengtsson
I'd be really surprised if basically not all text editors could be
used here; it more that some have quirks making it less obvious.  For
instance, with plain old Notepad that comes with all Windows distros
you can put (double) quotes around the file name in the Save As...
dialog to prevent Notepad from adding it's own default *.txt extension
(when the extension is missing).  BTW, since you're using RStudio, you
can also use that to create your .Rprofile file; RStudio's Save As...
does not mess with the filename - it saves the file as you specify.

Bruce, what I think would have helped helping you here early on is if
you had given a bit more details on what you did / tried.  There was a
lot of "does not work" early on, which gives little clues.  It wasn't
clear where you saved the files.  Maybe you weren't sure yourself, but
even knowing so would have helped help you.  It was also not clear how
much experience you had with R, which caused confusion - knowing "new
to R, with non professional programming skills" would probably have
cut some corners.  As a helper, here and on other forums, it's often
hard to guess this and to provide a proper reply is then hard - like
trying to give a scientific presentation when you don't know who's in
the audience.  This happens all the time and most people quickly picks
up what the expectations are and then get a smoother ride going
forward.

/Henrik

PS. With the risk of adding confusion, unless you already do so, you
should focus on only using/editing your
C:/Users/BruceRatner/Documents/.Rprofile (also referred to as
~/.Rprofile) file.  That one does not require any Administrative
rights to edit and has the advantage of working also when you update R
later.   The C:/PROGRA~1/R/R-33~1.3/etc/.Rprofile.site file requires
Admin to edit and will have to be recreated/reedited whenever you
update R (e.g. R 3.4.0 will install in a different directory).  A
regular R user should never have to edit the latter.  It's mostly used
for system admins who wish to set common startup settings for multiple
users in a location file.  The *.site part of .Rprofile.site suggests
site-wide settings.  So, use ~/.Rprofile to control your R startup
settings.


On Tue, Apr 18, 2017 at 8:26 AM, Bruce Ratner PhD  wrote:
> Dear John:
> My pleasure to respond to your request.
> Problem: Cannot get the .Rprofile file to take affect in either R (or 
> RStudio).
> As to "what" can be in put into a  .Rprofile file is abound, many examples in 
> the manuals, blogs, links, and books.
>
> The "how to" write the file was the real issue, not clearly covered in any 
> material I could find or purchase.
>
> I read that any notepad-type app can be used to create the .Rprofile file:
> 1. with or without a txt/R extension, and/or
> 2. with or without Administrator permission.
>
> Not being a professional programmer/developer, I did not know about text 
> editors that can create files with no extension, which was the problem at 
> hand.
>
> After many back and forth drilling down by R-helpers with trouble shooting 
> queries, it became clear that I was not using a developer's text editor.
>
> Solution: I found an editor online, EditPad Pro 7 (for Windows), with which I 
> created my .Rprofile file.
>
> The result was complete success, and gratitude to all R-helpers who stuck by 
> me,
> understanding I am new to R, with non professional programming skills. As a 
> statistician (or if you prefer data scientist) for twenty plus years, clearly 
> I must know how to program, but not at the pro level or pro understanding.
>
> John, I hope this write up is satisfactory, if not please let let me know, as 
> I will rewrite until you are happy with it.
>
> It is a nice surprise to hear your wanting to archive the problem-solution, 
> which almost did me in, and which created ill feelings among several 
> R-helpers towards me.
>
> Regards,
> Bruce
>
> __
> Bruce Ratner PhD
> The Significant Statistician™
> (516) 791-3544
> Statistical Predictive Analytics -- www.DMSTAT1.com
> Machine-Learning Data Mining -- www.GenIQ.net
>
>
>
>> On Apr 18, 2017, at 9:52 AM, Sparks, John James  wrote:
>>
>> Bruce,
>>
>> Do you think that you could post the final solution to the problem?  That
>> way it would be stored with this thread and the next person who has the
>> same problem would be able to locate the FINAL solution.
>>
>> --JJS
>>
>>
>>> On Mon, April 17, 2017 12:47 pm, BR_email wrote:
>>> TO _ALL_:
>>> THANK YOU. THANK YOU. THANK YOU.
>>> After hours, and hours, and hours, and ... , and hours: Success.
>>> To all who helped, thanks.
>>> My quest was minor, but major for me, as I learn from the path of one,
>>> whether big or small begets another.
>>>
>>> I never look down at anyone, except to help him/her up.
>>>
>>> With gratitude,
>>> Bruce
>>>
>>> Bruce Ratner, Ph.D.
>>> The Significant Statistician™
>>> (516) 791-3544
>>> Statistical Predictive Analtyics -- www.DMSTAT1.com
>>> Machine-Learning Data Mining and Modeling -

[R] Asking for help

2017-04-19 Thread Santiago Bueno
I have tried to ask for help ragarding R software but it seems that I do
not know how to send my questions. Can someone "PLEASE" tutor me on how to
structure my messages?

Best regards,

Santiago

[[alternative HTML version deleted]]

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


Re: [R] Setting .Rprofile for RStudio on a Windows 7 x64bit

2017-04-19 Thread BR_email

Henrik:
Your points are well taken.
My biggest mistake was that I thought my question was an easy one.
But as you rightly stated, I did not explicitly provide my background.
I assumed my question implied how much I did not know, beyond being new 
to R.
It's like Einstein teaching arithmetic, he would know his audience and 
teach accordingly.


It was tough on me (mentally draining) because I want to learn R
and just couldn't break through until I believe either you or Peter 
picked up on my using notepad.


Well, I am glad you guys really want to help and must as I needed it.

Regards,
Bruce

 


Henrik Bengtsson wrote:

I'd be really surprised if basically not all text editors could be
used here; it more that some have quirks making it less obvious.  For
instance, with plain old Notepad that comes with all Windows distros
you can put (double) quotes around the file name in the Save As...
dialog to prevent Notepad from adding it's own default *.txt extension
(when the extension is missing).  BTW, since you're using RStudio, you
can also use that to create your .Rprofile file; RStudio's Save As...
does not mess with the filename - it saves the file as you specify.

Bruce, what I think would have helped helping you here early on is if
you had given a bit more details on what you did / tried.  There was a
lot of "does not work" early on, which gives little clues.  It wasn't
clear where you saved the files.  Maybe you weren't sure yourself, but
even knowing so would have helped help you.  It was also not clear how
much experience you had with R, which caused confusion - knowing "new
to R, with non professional programming skills" would probably have
cut some corners.  As a helper, here and on other forums, it's often
hard to guess this and to provide a proper reply is then hard - like
trying to give a scientific presentation when you don't know who's in
the audience.  This happens all the time and most people quickly picks
up what the expectations are and then get a smoother ride going
forward.

/Henrik

PS. With the risk of adding confusion, unless you already do so, you
should focus on only using/editing your
C:/Users/BruceRatner/Documents/.Rprofile (also referred to as
~/.Rprofile) file.  That one does not require any Administrative
rights to edit and has the advantage of working also when you update R
later.   The C:/PROGRA~1/R/R-33~1.3/etc/.Rprofile.site file requires
Admin to edit and will have to be recreated/reedited whenever you
update R (e.g. R 3.4.0 will install in a different directory).  A
regular R user should never have to edit the latter.  It's mostly used
for system admins who wish to set common startup settings for multiple
users in a location file.  The *.site part of .Rprofile.site suggests
site-wide settings.  So, use ~/.Rprofile to control your R startup
settings.


On Tue, Apr 18, 2017 at 8:26 AM, Bruce Ratner PhD  wrote:

Dear John:
My pleasure to respond to your request.
Problem: Cannot get the .Rprofile file to take affect in either R (or RStudio).
As to "what" can be in put into a  .Rprofile file is abound, many examples in 
the manuals, blogs, links, and books.

The "how to" write the file was the real issue, not clearly covered in any 
material I could find or purchase.

I read that any notepad-type app can be used to create the .Rprofile file:
1. with or without a txt/R extension, and/or
2. with or without Administrator permission.

Not being a professional programmer/developer, I did not know about text 
editors that can create files with no extension, which was the problem at hand.

After many back and forth drilling down by R-helpers with trouble shooting 
queries, it became clear that I was not using a developer's text editor.

Solution: I found an editor online, EditPad Pro 7 (for Windows), with which I 
created my .Rprofile file.

The result was complete success, and gratitude to all R-helpers who stuck by me,
understanding I am new to R, with non professional programming skills. As a 
statistician (or if you prefer data scientist) for twenty plus years, clearly I 
must know how to program, but not at the pro level or pro understanding.

John, I hope this write up is satisfactory, if not please let let me know, as I 
will rewrite until you are happy with it.

It is a nice surprise to hear your wanting to archive the problem-solution, 
which almost did me in, and which created ill feelings among several R-helpers 
towards me.

Regards,
Bruce

__
Bruce Ratner PhD
The Significant Statistician™
(516) 791-3544
Statistical Predictive Analytics -- www.DMSTAT1.com
Machine-Learning Data Mining -- www.GenIQ.net




On Apr 18, 2017, at 9:52 AM, Sparks, John James  wrote:

Bruce,

Do you think that you could post the final solution to the problem?  That
way it would be stored with this thread and the next person who has the
same problem would be able to locate the FINAL solution.

--JJS



On Mon, April 17, 2017 12:47 pm, BR_email wrote:
TO _ALL_:
THANK YOU. THANK YOU. THAN

Re: [R] Asking for help

2017-04-19 Thread Ista Zahn
For help in formulating your question in a way that makes it easy to
help you see 
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

When asking for help on the R-help mailing list in particular, make
sure to send plain-text email.

Best,
Ista

On Wed, Apr 19, 2017 at 3:56 PM, Santiago Bueno  wrote:
> I have tried to ask for help ragarding R software but it seems that I do
> not know how to send my questions. Can someone "PLEASE" tutor me on how to
> structure my messages?
>
> Best regards,
>
> Santiago
>
> [[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] Asking for help

2017-04-19 Thread Boris Steipe
What about the advice I sent you this morning?


B.


> On Apr 19, 2017, at 1:49 PM, Boris Steipe  wrote:
> 
> No attachments please. Use the dput() function. And keep the correspondence 
> on the list, there are many colleagues who are far more knowledgeable than I 
> am.
> 
> Cheers,
> Boris
> 
> 
> 
> 
>> On Apr 19, 2017, at 1:47 PM, Santiago Bueno  wrote:
>> 
>> Thanks a lot Mr. Steipe. I have attached to this email an Excel file with 48 
>> observations.  The problem is that when I try to get the prediction plot for 
>> the following model:
>> start <- coef (lm(log(Btot)~I(log(dbh**2*haut)),data=dat[dat$Btot>0,]))
>> start[1] <- exp(start[1])
>> names(start) <- c("a","b")
>> model18 <- 
>> nls(Btot~a*(dbh**2*haut)**b,data=dat,start=start,weights=1/dat$dbh**4)
>> summary(model18)
>> 
>> using this code:
>> 
>> with(dat,plot(dbh**2*haut,Btot,xlab="dbh^2*H(cm^2.m)",ylab="Biomass (t)", 
>> pch=19))
>> D <- seq(0,180,length=20)
>> H <- seq(0,61,length=20)
>> 
>> abline(model18, lwd=3)
>> 
>> I get the data points but not the prediction line (see below)
>> 
>> 
>> If you can help me in getting this line, I will be eternaly grateful..
>> 
>> Best regards,
>> 
>> Santiago Bueno
>> 
>> On Wed, Apr 19, 2017 at 12:20 PM, Boris Steipe  
>> wrote:
>> Can you provide a small reproducible example and explain what exactly is 
>> going wrong?
>> 
>> Just a handful of data points will do.
>> 
>> 
>> B.
>> 
>> 
>> 
>>> On Apr 18, 2017, at 2:16 PM, Santiago Bueno  wrote:
>>> 
>>> Thanks Boris, the following is an extract of my data. I have developed
>>> biomass models using codes like:
>>> 
>>> start <- coef (lm(log(Btot)~I(log(dbh**2*haut)),data=dat[dat$Btot>0,]))
>>> 
>>> start[1] <- exp(start[1])
>>> 
>>> names(start) <- c("a","b")
>>> 
>>> M1 <- nls(Btot~a*(dbh**2*haut)**b,data=dat,start=start,weights=1/dat$dbh**4)
>>> 
>>> 
>>> start <- coef(lm(log(Btot)~I(log(dbh))+I(log(haut)),data=dat[dat$Btot>0,]))
>>> 
>>> start[1] <- exp(start[1])
>>> 
>>> names(start) <- c("a","b1","b2")
>>> 
>>> M2 <- nls(Btot~a*dbh**b1*haut**b2,data=dat,start=start,weights=1/dat$dbh**4)
>>> 
>>> 
>>> Tree No dbh haut Btot
>>> 1 35.00 18.90 0.535
>>> 2 25.00 16.60 0.248
>>> 3 23.00 19.50 0.228
>>> 4 13.50 15.60 0.080
>>> 5 20.00 18.80 0.172
>>> 6 23.00 17.40 0.190
>>> 7 29.00 19.90 0.559
>>> 8 17.60 18.20 0.117
>>> 9 31.00 25.30 0.645
>>> 10 26.00 23.50 0.394
>>> 11 13.00 13.00 0.038
>>> 12 32.00 20.70 0.443
>>> It is my interest to get prediction plots for the models. I have tried to
>>> use the following codes with no success: Let m be one of the fitted models
>>> with dbh as the only entry. To construct a plot of the predictions made by
>>> this model I have tried:
>>> with(dat,plot(dbh,Btot,xlab="Dbh(cm)",ylab="Biomass (t)"))
>>> D <- seq(par("usr")[1],par("usr")[2],length=200)
>>> lines(D,predict(m,newdata=data.frame(dbh=D)),col="red")
>>> For a model m that has dbh and height as entries, I have tried to get its
>>> predictions as follows:
>>> D <- seq(0,180,length=20)
>>> H <- seq(0,61,length=20)
>>> B <- matrix(predict(m,newdata=expand.grid(dbh=D,height=H)),length(D))
>>> 
>>> Can someone provide help please!!!
>>> 
>>> 
>>> Best regards,
>>> 
>>> Santiago Bueno
>>> 
>>>  [[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.
>> 
>> 
>> 
> 

> On Apr 19, 2017, at 4:13 PM, Ista Zahn  wrote:
> 
> For help in formulating your question in a way that makes it easy to
> help you see 
> http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
> 
> When asking for help on the R-help mailing list in particular, make
> sure to send plain-text email.
> 
> Best,
> Ista
> 
> On Wed, Apr 19, 2017 at 3:56 PM, Santiago Bueno  wrote:
>> I have tried to ask for help ragarding R software but it seems that I do
>> not know how to send my questions. Can someone "PLEASE" tutor me on how to
>> structure my messages?
>> 
>> Best regards,
>> 
>> Santiago
>> 
>>[[alternative HTML version deleted]]
>> 
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRI

Re: [R] Setting .Rprofile for RStudio on a Windows 7 x64bit

2017-04-19 Thread John
On Wed, 19 Apr 2017 15:57:42 -0400
BR_email  wrote:

> Henrik:
> Your points are well taken.
> My biggest mistake was that I thought my question was an easy one.
> But as you rightly stated, I did not explicitly provide my background.
> I assumed my question implied how much I did not know, beyond being
> new to R.
> It's like Einstein teaching arithmetic, he would know his audience
> and teach accordingly.
> 
> It was tough on me (mentally draining) because I want to learn R
> and just couldn't break through until I believe either you or Peter 
> picked up on my using notepad.
> 
> Well, I am glad you guys really want to help and must as I needed it.
> 
> Regards,
> Bruce
> 
Henrik's point about editors is very important since it has implications
well beyond editing something like .Rprofile.  Depending on the scale
and kinds of data you work with, you may conclude that one of
the easiest means of getting data into R is through delimited, plain
text files.  I tend to prefer tab-delimited files because the data I use
often contains descriptive fields that are useful to have, but often
contain commas, ruling out standard csv files.  Many "text" editors in
both Windows and Linux routinely and quietly convert tabs to some
standard number of spaces.  You want an editor that will produce
precisely what you tell it to.  While you can pull delimited files into
Excel, a good text editor, not Notepad or Wordpad, such as Notepad++ in
Windows or Kwrite in Linux (both of which will save a tab as a tab
(though Kwrite needs to set to do so) and speed data formatting and
editing immensely.  Also, if you are using RStudio you should consider
using the "project" capability.  You will then never have to worry
about .Rproject again.

JWDougherty

__
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] rdb and rds files include abolute file paths / help understanding how lazy-load dbs are created

2017-04-19 Thread Jeff Newmiller
I think we are (I certainly am) going to need a more concrete example. As in, 
point us at a specific package and filename in this package that illustrates 
your concern. Such precision would also be expected on R-devel, so the lack of 
response may have been self-inflicted. 

Are you aware of the system.file and file.path functions?  File names that YOU 
enter into your package code should be referenced using these functions. I have 
been assuming so far that you were referring to filenames picked up by R as it 
builds the package, which appear to be handled just fine however they are 
stored though I don't know the details. 
-- 
Sent from my phone. Please excuse my brevity.

On April 19, 2017 2:40:05 PM PDT, Philip Rinn  wrote:
>Hi,
>
>On 12.04.2017 at 08:09, Jeff Newmiller wrote:
>
>> Someone might respond here anyway, but I think this is more of an
>R-devel
>> question.
>
>I tired R-devel before[1] with no response :(.
>
>> Anyway, as long as the package file after installation has
>appropriate file
>> names for where it is installed, what does it matter what is in the
>files
>> before installation?
>
>That's actually the point. In the installed .rd[bs] files the absolute
>file paths
>are still present but often[2] the referenced files don't even exist on
>the
>computer the packaged is installed. My approach therefore is to replace
>those
>absolute paths by relative[3] paths. But to do so I need to understand
>where
>exactly those absolute paths are injected in the files - that's why I
>asked for
>help in my fist mail - sorry for not being clear enough.
>
>Best,
>Philip
>
>
>[1] https://stat.ethz.ch/pipermail/r-devel/2017-April/074016.html
>[2] At least on Linux for packages installed via the distribution
>packages system.
>And I think this also holds for prebuild windows/mac builds from cran.
>[3] Relative to teh root directory of the package source

__
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] Multiple Histograms in R

2017-04-19 Thread Jim Lemon
Hi Prateek,
There is some difficulty with including the empty categories in the
factors generated. I couldn't get these even with drop=FALSE, so I had
to go through the "xtab" function. You can do it with the "table"
function in the base package, but it is a little more trouble. See if
this is what you want>

ppdat<-read.table(text="mou_mean,totalmrc_mean,rev_range,mou_range,Churn
23,24,25,27,1
45,46,47,49,1
43,44,45,47,1
45,46,47,49,0
56,57,58,60,0
67,68,69,71,1
67,68,69,71,0
44,45,46,48,1
33,34,35,37,0
90,91,92,94,1
87,88,89,91,1
76,77,78,80,1
33,34,35,37,1
44,45,46,48,1",
sep=",",header=TRUE)
ppdat$mou_mean_cut<-cut(ppdat$mou_mean,breaks=seq(23,103,10),include.lowest=TRUE)
ppdat$totalmrc_mean_cut<-cut(ppdat$totalmrc_mean,breaks=seq(23,103,10))
ppdat$rev_range_cut<-cut(ppdat$rev_range,breaks=seq(23,103,10))
ppdat$mou_range_cut<-cut(ppdat$mou_range,breaks=seq(23,103,10))
library(prettyR)
ppx<-xtab(Churn~mou_mean_cut,ppdat)
mou_mean_agg<-100*ppx$counts[2,]/colSums(ppx$counts)
mou_mean_agg[is.nan(mou_mean_agg)]<-0
ppx<-xtab(Churn~totalmrc_mean_cut,ppdat)
totalmrc_mean_agg<-100*ppx$counts[2,]/colSums(ppx$counts)
totalmrc_mean_agg[is.nan(totalmrc_mean_agg)]<-0
ppx<-xtab(Churn~rev_range_cut,ppdat)
rev_range_agg<-100*ppx$counts[2,]/colSums(ppx$counts)
rev_range_agg[is.nan(rev_range_agg)]<-0
ppx<-xtab(Churn~mou_range_cut,ppdat)
mou_range_agg<-100*ppx$counts[2,]/colSums(ppx$counts)
mou_range_agg[is.nan(mou_range_agg)]<-0
ppmat<-matrix(c(mou_mean_agg,totalmrc_mean_agg,rev_range_agg,
 mou_range_agg),nrow=4,byrow=TRUE)
library(plotrix)
barp(ppmat,col=rainbow(4),main="Multiple histogram",ylim=c(0,105),
 names.arg=levels(ppdat$mou_mean_cut),ylab="Percent churn")
legend(2.5,107,c("mou_mean","totalmrc_mean","rev_range","mou_range"),
 fill=rainbow(4))

Jim


On Wed, Apr 19, 2017 at 11:05 PM, prateek pande  wrote:
> Hi,
>
> I have a data as mentioned below(at the bottom)
>
> Now out of that data i have to create multiple histograms in a single view
> in  R. On that histogram i need on x -axis binned data with Breaks 10 and
> on y axis event rate . Here churn is dependent variable.
>
>
> *for example, for mou_mean , on x -axis on histogram i need Bins(mou_mean)
> and on y - axis in need Churn%age. *
> *Bins(mou_mean)*
>
> *Churn %age*
> 23-43  0.23%
> 33-53  0.5%
> 43-63   0.3%
> 53-73   0.4%
> 63-83   0.7%
> 83-1030.8%
>
> Please help
>
>
> *mou_mean*
>
> *totalmrc_mean*
>
> *rev_range*
>
> *mou_range*
>
> *Churn*
>
> 23
>
> 24
>
> 25
>
> 27
>
> 1
>
> 45
>
> 46
>
> 47
>
> 49
>
> 1
>
> 43
>
> 44
>
> 45
>
> 47
>
> 1
>
> 45
>
> 46
>
> 47
>
> 49
>
> 0
>
> 56
>
> 57
>
> 58
>
> 60
>
> 0
>
> 67
>
> 68
>
> 69
>
> 71
>
> 1
>
> 67
>
> 68
>
> 69
>
> 71
>
> 0
>
> 44
>
> 45
>
> 46
>
> 48
>
> 1
>
> 33
>
> 34
>
> 35
>
> 37
>
> 0
>
> 90
>
> 91
>
> 92
>
> 94
>
> 1
>
> 87
>
> 88
>
> 89
>
> 91
>
> 1
>
> 76
>
> 77
>
> 78
>
> 80
>
> 1
>
> 33
>
> 34
>
> 35
>
> 37
>
> 1
>
> 44
>
> 45
>
> 46
>
> 48
>
> 1
>
> [[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] Multiple Histograms in R

2017-04-19 Thread Hasan Diwan
Prateek,
I'm shocked this isn't answered previously, but you can try the par command
(mfrow and mfcol parameters) and par(mfrow=n, mfcol=m) will generate n
plots per row and m rows per column. For subsequent questions, please do a
search through the archives before asking. -- H

On 19 April 2017 at 06:05, prateek pande  wrote:

> Hi,
>
> I have a data as mentioned below(at the bottom)
>
> Now out of that data i have to create multiple histograms in a single view
> in  R. On that histogram i need on x -axis binned data with Breaks 10 and
> on y axis event rate . Here churn is dependent variable.
>
>
> *for example, for mou_mean , on x -axis on histogram i need Bins(mou_mean)
> and on y - axis in need Churn%age. *
> *Bins(mou_mean)*
>
> *Churn %age*
> 23-43  0.23%
> 33-53  0.5%
> 43-63   0.3%
> 53-73   0.4%
> 63-83   0.7%
> 83-1030.8%
>
> Please help
>
>
> *mou_mean*
>
> *totalmrc_mean*
>
> *rev_range*
>
> *mou_range*
>
> *Churn*
>
> 23
>
> 24
>
> 25
>
> 27
>
> 1
>
> 45
>
> 46
>
> 47
>
> 49
>
> 1
>
> 43
>
> 44
>
> 45
>
> 47
>
> 1
>
> 45
>
> 46
>
> 47
>
> 49
>
> 0
>
> 56
>
> 57
>
> 58
>
> 60
>
> 0
>
> 67
>
> 68
>
> 69
>
> 71
>
> 1
>
> 67
>
> 68
>
> 69
>
> 71
>
> 0
>
> 44
>
> 45
>
> 46
>
> 48
>
> 1
>
> 33
>
> 34
>
> 35
>
> 37
>
> 0
>
> 90
>
> 91
>
> 92
>
> 94
>
> 1
>
> 87
>
> 88
>
> 89
>
> 91
>
> 1
>
> 76
>
> 77
>
> 78
>
> 80
>
> 1
>
> 33
>
> 34
>
> 35
>
> 37
>
> 1
>
> 44
>
> 45
>
> 46
>
> 48
>
> 1
>
> [[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.
>



-- 
OpenPGP:
https://sks-keyservers.net/pks/lookup?op=get&search=0xFEBAD7FFD041BBA1
If you wish to request my time, please do so using
http://bit.ly/hd1ScheduleRequest.
Si vous voudrais faire connnaisance, allez a
http://bit.ly/hd1ScheduleRequest.

Sent
from my mobile device
Envoye de mon portable

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