Re: [R] barp {plotrix} Start bars at 0 with a vector of positive values

2014-06-14 Thread Pascal Oettli
Hi Jim,

Yes, it seems to work. Thanks.

Regards,
Pascal

On Sat, Jun 14, 2014 at 2:03 PM, Jim Lemon j...@bitwrit.com.au wrote:
 On Sat, 14 Jun 2014 12:57:12 PM you wrote:
 Hi Jim,

 I tried your fix.

 This one works:
 barp(c(2,3,4,5,6,7,8), ylim=c(-10,10))

 This one fails:
 barp(c(2,3,4,5,6,7,8))

 Regards,
 Pascal

 Hi Pascal,
 Right again. This seems to work for both and I think handles the problem
 correctly:

  if(is.null(ylim)) {
   negy-any(height0,na.rm=TRUE)
   if(negy) miny-min(height,na.rm=TRUE)*1.05
   else miny-ifelse(ylog,min(height)/10,0)
   ylim-c(miny,max(height,na.rm=TRUE)*1.05)
  }
  else {
   miny-ylim[1]
   negy-miny0
  }

 Remove the line:

 negy-any(height0,na.rm=TRUE)

 and modify the succeeding conditional clause as above. This will appear
 in version 3.5-8.

 Jim




-- 
Pascal Oettli
Project Scientist
JAMSTEC
Yokohama, Japan

__
R-help@r-project.org mailing list
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] question about chi values GLM

2014-06-14 Thread Luis Fernando García
Dear all,

I am making an analysis using a GLM using three explanatory variables and a
response variable. I need to obtain a table similar to this one,
http://postimg.org/image/5sau79wlt/r

 nevertheless, I have not been able to do it. I am having a hard time
specially getting the chi square values. I would like to know how to obatin
them. I have used the function ANOVA, but it shows me the deviance but not
the Chi-Square values, can be used these values?

I also would like to know what function could help me to make ad hoc
comparisons for single variables and interactions.

If any of you knows how to do both estimations, I would really appreciate
it.

All the best!!!

This is my script
a=read.table(ricis3.txt,header=T)
attach(a)
model7=glm(Count~Sex+Time+Behaviour+Sex*Time+Sex*Behaviour+Time+Behaviour*Sex,family=poisson)
summary(model7)
anova(model7,test=Chi)
Sex TimeBehaviour   Count
MaleNight   Exploring   189
MaleNight   Interacting 11
MaleNight   Feeding 170
MaleNight   Mating  13
MaleNight   Resting 240
MaleDay Exploring   58
MaleDay Interacting 1
MaleDay Feeding 12
MaleDay Mating  3
MaleDay Resting 399
Female  Night   Exploring   187
Female  Night   Interacting 10
Female  Night   Feeding 95
Female  Night   Mating  8
Female  Night   Resting 175
Female  Day Exploring   45
Female  Day Interacting 6
Female  Day Feeding 10
Female  Day Mating  4
Female  Day Resting 406
ImmatureNight   Exploring   186
ImmatureNight   Interacting 15
ImmatureNight   Feeding 175
ImmatureNight   Resting 200
ImmatureDay Exploring   68
ImmatureDay Interacting 8
ImmatureDay Feeding 6
__
R-help@r-project.org mailing list
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] question about chi values GLM

2014-06-14 Thread peter dalgaard
The column labeled Deviance pretty much _is_ the chi-square, specifically the 
likelihood ratio test statistic, which has an asymptotic chi-square 
distribution. (Using test=Rao gives you the alternative Rao efficient score 
test, which in your case doesn't make much of a difference.) 

Notice though, that those displays are sequential and it is not clear that the 
one in the image you attach is made in the same way (or in a sensible way for 
that matter).  In particular, you have highly significant interaction terms, in 
which case the main effects tests are mostly irrelevant. You may need to 
consult a textbook on Poisson modelling or generalized linear modelling -- the 
discussion is a bit too long to be fitted into a mailing list.

-pd

On 14 Jun 2014, at 10:01 , Luis Fernando García luysgar...@gmail.com wrote:

 Dear all,
 
 I am making an analysis using a GLM using three explanatory variables and a
 response variable. I need to obtain a table similar to this one,
 http://postimg.org/image/5sau79wlt/r
 
 nevertheless, I have not been able to do it. I am having a hard time
 specially getting the chi square values. I would like to know how to obatin
 them. I have used the function ANOVA, but it shows me the deviance but not
 the Chi-Square values, can be used these values?
 
 I also would like to know what function could help me to make ad hoc
 comparisons for single variables and interactions.
 
 If any of you knows how to do both estimations, I would really appreciate
 it.
 
 All the best!!!
 
 This is my script
 a=read.table(ricis3.txt,header=T)
 attach(a)
 model7=glm(Count~Sex+Time+Behaviour+Sex*Time+Sex*Behaviour+Time+Behaviour*Sex,family=poisson)
 summary(model7)
 anova(model7,test=Chi)
 ricis3.txt__
 R-help@r-project.org mailing list
 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
Email: pd@cbs.dk  Priv: pda...@gmail.com

__
R-help@r-project.org mailing list
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] .Internal(filledcontour()) - ancient history or just plain wrong?

2014-06-14 Thread Raphael Päbst
Hello everyone!
In my ongoing odyssey through badly dokumented and sparingly commented
R-code, I've come across something that baffles me.
The following line of code

.Internal(filledcontour(as.double(x), as.double(y), z,
as.double(levels), col = col))
 not surprisingly results in an error, telling me that there is no
such function as filledcontour().
The code this comes from has been written for an older version of R,
probably 2.5.x so I was wondering, if the error results from me using
a current version (3.1.0) or if the author wanted to use
filled.contour() and forgot the '.'.

Would that in fact help or was there something called filledcontour()
that has changed into something else nowadays?

I've tried to contact the author, but he hasn't used R for at least
five years and hasn't replied so far, so I'm hoping soeone here can
give me a hint to the solution of this problem.

Many thanks in advance!

Raphael

__
R-help@r-project.org mailing list
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] .Internal(filledcontour()) - ancient history or just plain wrong?

2014-06-14 Thread Prof Brian Ripley

On 14/06/2014 10:04, Raphael Päbst wrote:

Hello everyone!
In my ongoing odyssey through badly dokumented and sparingly commented
R-code, I've come across something that baffles me.
The following line of code

.Internal(filledcontour(as.double(x), as.double(y), z,
as.double(levels), col = col))
  not surprisingly results in an error, telling me that there is no
such function as filledcontour().


But that passes a call to .Internal: it does not say what you say it 
does.  I suspect you saw


  there is no .Internal function 'filledcontour'

which is quite a different matter.


The code this comes from has been written for an older version of R,
probably 2.5.x so I was wondering, if the error results from me using
a current version (3.1.0) or if the author wanted to use
filled.contour() and forgot the '.'.

Would that in fact help or was there something called filledcontour()
that has changed into something else nowadays?


It has.  But it was never in the API, so should never have been used in 
user code and was never documented in R itself.


You should be able to rewrite this using .filled.contour in package 
graphics: it might be a drop-in replacement.




I've tried to contact the author, but he hasn't used R for at least
five years and hasn't replied so far, so I'm hoping soeone here can
give me a hint to the solution of this problem.

Many thanks in advance!

Raphael




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

__
R-help@r-project.org mailing list
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] .Internal(filledcontour()) - ancient history or just plain wrong?

2014-06-14 Thread Raphael Päbst
You are right, it was
  there is no .Internal function 'filledcontour'


and changing it to .filled.contour() removed the problem.

Just out of curiosity, would the old version with
.Internal(filledcontour()) have worked on older R-Versions?

Not that I fully understand how .Internal() works and should (or
should not) be used, but I'm always willing to understand more about
the code I'm working with.

Thanks again!

Raphael

On 6/14/14, Prof Brian Ripley rip...@stats.ox.ac.uk wrote:
 On 14/06/2014 10:04, Raphael Päbst wrote:
 Hello everyone!
 In my ongoing odyssey through badly dokumented and sparingly commented
 R-code, I've come across something that baffles me.
 The following line of code

 .Internal(filledcontour(as.double(x), as.double(y), z,
 as.double(levels), col = col))
   not surprisingly results in an error, telling me that there is no
 such function as filledcontour().

 But that passes a call to .Internal: it does not say what you say it
 does.  I suspect you saw

there is no .Internal function 'filledcontour'

 which is quite a different matter.

 The code this comes from has been written for an older version of R,
 probably 2.5.x so I was wondering, if the error results from me using
 a current version (3.1.0) or if the author wanted to use
 filled.contour() and forgot the '.'.

 Would that in fact help or was there something called filledcontour()
 that has changed into something else nowadays?

 It has.  But it was never in the API, so should never have been used in
 user code and was never documented in R itself.

 You should be able to rewrite this using .filled.contour in package
 graphics: it might be a drop-in replacement.


 I've tried to contact the author, but he hasn't used R for at least
 five years and hasn't replied so far, so I'm hoping soeone here can
 give me a hint to the solution of this problem.

 Many thanks in advance!

 Raphael



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

 __
 R-help@r-project.org mailing list
 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
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] .Internal(filledcontour()) - ancient history or just plain wrong?

2014-06-14 Thread Prof Brian Ripley

On 14/06/2014 10:30, Raphael Päbst wrote:

You are right, it was
   there is no .Internal function 'filledcontour'


and changing it to .filled.contour() removed the problem.

Just out of curiosity, would the old version with
.Internal(filledcontour()) have worked on older R-Versions?


Possibly.  Note that the internals of that undocumented .Internal did 
change over the years.




Not that I fully understand how .Internal() works and should (or
should not) be used, but I'm always willing to understand more about
the code I'm working with.

Thanks again!

Raphael

On 6/14/14, Prof Brian Ripley rip...@stats.ox.ac.uk wrote:

On 14/06/2014 10:04, Raphael Päbst wrote:

Hello everyone!
In my ongoing odyssey through badly dokumented and sparingly commented
R-code, I've come across something that baffles me.
The following line of code

.Internal(filledcontour(as.double(x), as.double(y), z,
as.double(levels), col = col))
   not surprisingly results in an error, telling me that there is no
such function as filledcontour().


But that passes a call to .Internal: it does not say what you say it
does.  I suspect you saw

there is no .Internal function 'filledcontour'

which is quite a different matter.


The code this comes from has been written for an older version of R,
probably 2.5.x so I was wondering, if the error results from me using
a current version (3.1.0) or if the author wanted to use
filled.contour() and forgot the '.'.

Would that in fact help or was there something called filledcontour()
that has changed into something else nowadays?


It has.  But it was never in the API, so should never have been used in
user code and was never documented in R itself.

You should be able to rewrite this using .filled.contour in package
graphics: it might be a drop-in replacement.



I've tried to contact the author, but he hasn't used R for at least
five years and hasn't replied so far, so I'm hoping soeone here can
give me a hint to the solution of this problem.

Many thanks in advance!

Raphael




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

__
R-help@r-project.org mailing list
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.




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

__
R-help@r-project.org mailing list
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] Numerical integration with R

2014-06-14 Thread Christofer Bogaso
Hi again,

I was tying to solve following 2-fold integration with package cubature.
However spending approximately 2 hours it failed to generate any number. I
am using latest R with win-7 machine having 4gb ram.

 library(cubature)
 f - function(x) {
+ z1 - x[1]
+ z2 - x[2]
+
+ Rho = 1
+
+ L - log(1 - pnorm(z1)) * log(1 - pnorm(Rho * z1 + sqrt(1 - Rho^2) * z2))
* dnorm(z1) * dnorm(z2)
+
+ return(L)
+ }; adaptIntegrate(f, lowerLimit = c(-Inf, -Inf), upperLimit = c(Inf, Inf))
Error in adaptIntegrate(f, lowerLimit = c(-Inf, -Inf), upperLimit = c(Inf,
 :
  'Realloc' could not re-allocate memory (1006632880 bytes)
In addition: Warning messages:
1: In adaptIntegrate(f, lowerLimit = c(-Inf, -Inf), upperLimit = c(Inf,  :
  Reached total allocation of 1535Mb: see help(memory.size)
2: In adaptIntegrate(f, lowerLimit = c(-Inf, -Inf), upperLimit = c(Inf,  :
  Reached total allocation of 1535Mb: see help(memory.size)


Would really appreciate if someone helps me to sort out this problem.

Thanks and regards,

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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] question about chi values GLM

2014-06-14 Thread Prof Brian Ripley

On 14/06/2014 09:45, peter dalgaard wrote:

The column labeled Deviance pretty much _is_ the chi-square, specifically the 
likelihood ratio test statistic, which has an asymptotic chi-square distribution. (Using 
test=Rao gives you the alternative Rao efficient score test, which in your case doesn't 
make much of a difference.)

Notice though, that those displays are sequential and it is not clear that the 
one in the image you attach is made in the same way (or in a sensible way for 
that matter).  In particular, you have highly significant interaction terms, in 
which case the main effects tests are mostly irrelevant. You may need to 
consult a textbook on Poisson modelling or generalized linear modelling -- the 
discussion is a bit too long to be fitted into a mailing list.


We do not know what is meant by the entries in those tables.  Many years 
ago (before even the term 'deviance' was coined) H.O. Lancaster and 
others partitioned chi-squared tests, with a similar table to an 
analysis of deviance but different numerical quantities.  Although 
Peter's guess is the most likely one, it is not the only possible one.


As an overall test of fit in a Poisson log-linear model there is a 
likelihood-ratio aka deviance test (sometimes called a G^2 test or 
G-test) and a Chi-squared test (which is different).


The 'df' in the table make no sense.  For three binary variables, Season 
x sex has more df than Season or Sex, and Time x Sex has fewer  
Even if we had the reference (and the OP really should have given us 
that to allow him to reproduce it under 'fair use' copyright law) I 
guess we would be little the wiser.



-pd

On 14 Jun 2014, at 10:01 , Luis Fernando García luysgar...@gmail.com wrote:


Dear all,

I am making an analysis using a GLM using three explanatory variables and a
response variable. I need to obtain a table similar to this one,
http://postimg.org/image/5sau79wlt/r

nevertheless, I have not been able to do it. I am having a hard time
specially getting the chi square values. I would like to know how to obatin
them. I have used the function ANOVA, but it shows me the deviance but not
the Chi-Square values, can be used these values?

I also would like to know what function could help me to make ad hoc
comparisons for single variables and interactions.

If any of you knows how to do both estimations, I would really appreciate
it.

All the best!!!

This is my script
a=read.table(ricis3.txt,header=T)
attach(a)
model7=glm(Count~Sex+Time+Behaviour+Sex*Time+Sex*Behaviour+Time+Behaviour*Sex,family=poisson)
summary(model7)
anova(model7,test=Chi)
ricis3.txt__
R-help@r-project.org mailing list
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.





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

__
R-help@r-project.org mailing list
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] Numerical integration with R

2014-06-14 Thread David Winsemius

On Jun 14, 2014, at 7:40 AM, Christofer Bogaso wrote:

 Hi again,
 
 I was tying to solve following 2-fold integration with package cubature.
 However spending approximately 2 hours it failed to generate any number. I
 am using latest R with win-7 machine having 4gb ram.
 
 library(cubature)
 f - function(x) {
 + z1 - x[1]
 + z2 - x[2]
 +
 + Rho = 1
 +
 + L - log(1 - pnorm(z1)) * log(1 - pnorm(Rho * z1 + sqrt(1 - Rho^2) * z2))
 * dnorm(z1) * dnorm(z2)
 +
 + return(L)
 + }; adaptIntegrate(f, lowerLimit = c(-Inf, -Inf), upperLimit = c(Inf, Inf))
 Error in adaptIntegrate(f, lowerLimit = c(-Inf, -Inf), upperLimit = c(Inf,
 :
  'Realloc' could not re-allocate memory (1006632880 bytes)
 In addition: Warning messages:
 1: In adaptIntegrate(f, lowerLimit = c(-Inf, -Inf), upperLimit = c(Inf,  :
  Reached total allocation of 1535Mb: see help(memory.size)
 2: In adaptIntegrate(f, lowerLimit = c(-Inf, -Inf), upperLimit = c(Inf,  :
  Reached total allocation of 1535Mb: see help(memory.size)
 
 
 Would really appreciate if someone helps me to sort out this problem.

You are posting a problem with no data. You are also not explaining what you 
are trying to do. In particular, what was your intent when you wrote:

upperLimit = c(Inf, Inf)   # 

When I run this with finite limits that are increasing in range  and several 
values for a length 2 x-vector

x - c(0.1,0.1)
x -c(.1, 0 )
x - c(10,10)
x - c(10, -10)

I consistently get:

#
 adaptIntegrate(f, lowerLimit = c(-1000, 1000), upperLimit = c(-1000, 1000))
$integral
[1] 0

$error
[1] 0

$functionEvaluations
[1] 17

$returnCode
[1] 0
#---

Which makes me think there is something mathematically degenerate about your 
L expression.

 
 Thanks and regards,
 
   [[alternative HTML version deleted]]


Arrrgh. Pray tell, exactly how many years have you been posting to R-help? I've 
checked... and it's really not that difficult to get gmail to send plain text.

-- 
David Winsemius
Alameda, CA, USA

__
R-help@r-project.org mailing list
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] Logistic Regression

2014-06-14 Thread javad bayat
Dear all, I have to use Zelig package for doing logistic regression.
How can I use Zelig package for logistic regression?

I did this code by glm function:

glm1 = glm(kod~Curv+Elev+Out.c+Slope+Aspect,data=data,
   family=binomial)
summary(glm1)

But the results were not appropriate for my data.

Many thanks for your helps.







-- 
Best Regards
Javad Bayat
M.Sc. Environment Engineering
Shahid Beheshti (National) University (SBU)
Alternative Mail: bayat...@yahoo.com

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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] Output for Boot function in Car package

2014-06-14 Thread Dan Hughes
Dear users,

Can anyone help with a rather simplistic question about the interpretation
of output using the Boot ( ) function in the Car package?

I am trying to bootstrap a simple univariate linear regression in order to
look at the bootstrap regression coefficients e.g.

mod1 - lm (y~x)
mod1.b - Boot(mod1, R=999)
summary (mod1.b)

This returns output like this:

  R  original   bootBias  bootSE   bootMed
  (Intercept) 999   5.365528   -8.0960e-05   0.0501306   5.365241
  x  999   0.0322117.3683e-05   0.0029743   0.032158

I'm having trouble finding out what bootMed means. If 'original' is the
non-bootstrapped regression coefficient, is bootMed the bootstrapped
regression coefficient?

I presume this is a frighteningly simple question for regular car package
users, but I can't seem to find an explanation what this means.

Best wishes

Dan Hughes

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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] data format setting

2014-06-14 Thread eliza botto
Thanks Frede,it helped alot.

eliza

From: fr...@vestas.com
To: eliza_bo...@hotmail.com; r-help@r-project.org
Date: Sat, 14 Jun 2014 06:09:08 +0200
Subject: RE: [R] data format setting







Hi Eliza
To me it seems like that you're not thinking before you messing about with the 
data before an analysis. 
The years with data for 366 days is leap years. It happens every fourth year 
and the extra day falls on the 29th of februar. I guess it is the results from 
the dcast function that screws things up to make you believe that it's day 
number 366.
The best thing to do is to do your analysis on the complete data with some 
missing values for February 29th between leap years. 
Or you can discard the leap year day for leap years and do the analysis for all 
years of 365 days.
What is the rationale by imputing missing data using the approx function? I 
mean the no leap year has only 365 days. 
If you for some unknown reasons you want to fill in value for the NAs one 
natural way is to substitute the NAs on February 29th by the mean of the 
values on February 28th and Marts 1st. I think there is a na.approx function 
for that in some package (perhaps zoo). Other metods are available in R: google 
for R + impute.
Best Regards
Frede
Sendt fra Samsung mobil

 Oprindelig meddelelse 
Fra: eliza botto 
Dato:13/06/2014 20.48 (GMT+01:00) 
Til: r-help@r-project.org 
Emne: Re: [R] data format setting 


Thanks dennis,

It worked but I had to do some simple modifications to get to the ultimate 
format.

Now I have a list in the following format

$A

2004200520062007200820092010

..

...

...

..

...



$AY



196719682000...



some columns had 365 rows and some 366. those with 365 rows had their 366 row 
as NA. 

Now I want to apply approx. command to interpolate 366 values to 365, but when 
I apply approx command I gives out something 

which is with $x and $y, and frankly speaking it messed up everything.

Is their a way that i do it neatly without getting the format deteriorated?





In any way, thank-you very much indeed.



Eliza



 Date: Fri, 13 Jun 2014 11:11:37 -0700

 Subject: Re: [R] data format setting

 From: djmu...@gmail.com

 To: eliza_bo...@hotmail.com

 

 Hi:

 

 Maybe something like this:

 

 library(reshape2)

 L - split(DF, DF$year)

 L2 - llply(L, function(d) dcast(d, month + day ~ year, value.var =

 discharge))

 

 Obviously untested, so caveat emptor. The idea is to use the dcast

 function to reshape the data from long to wide format within year.

 

 Dennis

 

 On Fri, Jun 13, 2014 at 8:55 AM, eliza botto eliza_bo...@hotmail.com wrote:

 

  Dear R family,

  I hope you all be doing great. I have a dataset of following format. The 
  data file is of the following format.

 

st year month day discharge

  1  A 2004 1   1  6.752828

  2  A 2004 1   2  7.602053

  3  A 2004 1   3  5.583619

  4  A 2004 1   4  5.019562

  5  A 2004 1   5  4.804489

  6  A 2004 1   6  4.363541

  7  A 2004 1   7  3.801333

  8  A 2004 1   8  3.455991

  9  A 2004 1   9  3.402634

  10 A 2004 1  10  3.250693

  ..

  ..

  continue

  ..

  ..

   st year month day discharge

  2AY 196710   3  0.56

  20001AY 196710   4  0.56

  20002AY 196710   5  0.48

  20003AY 196710   6  0.56

  20004AY 196710   7  0.48

  20005AY 196710   8  0.40

  20006AY 196710   9  0.40

  20007AY 196710  10  0.56

  20008AY 196710  11  0.56

  20009AY 196710  12  0.65

  20010AY 196710  13  0.85

 

  you can see that there are five columns.

  The first column has the name of the station. I want to split the data 
  w.r.t the names of the stations. Each station has data for certain years. 
  for example A has data for years from 2004 to 2010 and for AY its from 
  1967 to 2000.similarly for other years there is data for different number 
  of years.

  I want to make a list of matrices each containing the data for that station 
  in the following format

  $A

  2004200520062007200820092010

  ..

  ...

  ...

  ..

  ...

 

  $AY

 

  196719682000

 

  each column should have 365 to 366 values depending on whether there is a 
  leap year or not. obviously for non-leap years 366th row should be an NA.

  kindly help me on it.

  Thankyou very much in advance.

  Eliza

 

 

  [[alternative HTML version deleted]]

 

  __

  R-help@r-project.org mailing list

  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 

[R] How to draw Bubble chart with mini pie charts as bubbles in R

2014-06-14 Thread Agony
Dear all,
Good day!

Could anybody help me how to draw a bubble chart with mini pie charts as 
bubbles in R ?
Introducing any experiences, books, booklet or source code will appreciated.

Bunch of thanks.

Best,
Amir

__
R-help@r-project.org mailing list
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] Output for Boot function in Car package

2014-06-14 Thread David Winsemius

On Jun 14, 2014, at 1:15 AM, Dan Hughes wrote:

 Dear users,
 
 Can anyone help with a rather simplistic question about the interpretation
 of output using the Boot ( ) function in the Car package?
 
 I am trying to bootstrap a simple univariate linear regression in order to
 look at the bootstrap regression coefficients e.g.
 
 mod1 - lm (y~x)
 mod1.b - Boot(mod1, R=999)
 summary (mod1.b)
 
 This returns output like this:
 
  R  original   bootBias  bootSE   bootMed
  (Intercept) 999   5.365528   -8.0960e-05   0.0501306   5.365241
  x  999   0.0322117.3683e-05   0.0029743   0.032158
 
 I'm having trouble finding out what bootMed means. If 'original' is the
 non-bootstrapped regression coefficient, is bootMed the bootstrapped
 regression coefficient?
 
 I presume this is a frighteningly simple question for regular car package
 users, but I can't seem to find an explanation what this means.

I'm not a regular or even an intermittent user of `car` but offhand I would 
suspect it is the median. 

Do read the Posting Guide, 
and the help page for Boot and the tutorial that is linked from that help page, 
 
and please learn to post in plain text.

 
 Best wishes
 
 Dan Hughes
 
   [[alternative HTML version deleted]]

-- 

David Winsemius
Alameda, CA, USA

__
R-help@r-project.org mailing list
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] Logistic Regression

2014-06-14 Thread Suzen, Mehmet
You might want to read this vignette:
http://cran.r-project.org/web/packages/HSAUR/vignettes/Ch_logistic_regression_glm.pdf

On 14 June 2014 19:53, javad bayat j.bayat...@gmail.com wrote:
 Dear all, I have to use Zelig package for doing logistic regression.
 How can I use Zelig package for logistic regression?

 I did this code by glm function:

 glm1 = glm(kod~Curv+Elev+Out.c+Slope+Aspect,data=data,
family=binomial)
 summary(glm1)

 But the results were not appropriate for my data.

 Many thanks for your helps.







 --
 Best Regards
 Javad Bayat
 M.Sc. Environment Engineering
 Shahid Beheshti (National) University (SBU)
 Alternative Mail: bayat...@yahoo.com

 [[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list
 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
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] Defining default method for S3, S4 and R5 classes

2014-06-14 Thread Suzen, Mehmet
There is a nice tutorial on this:
http://adv-r.had.co.nz/OO-essentials.html

For an in depth guide, have a look at the book from John Chambers,
Software for data analysis programming with R.

On 13 June 2014 12:20, Luca Cerone luca.cer...@gmail.com wrote:
 Dear all,

 I am writing a script implementing a pipeline to analyze some of the
 data we receive.

 One of the steps in this pipeline involves clustering the data, and I
 am interested
 in studying the effects of different clustering algorithms on the final 
 results.

 I am having issues making my code general enough because the
 clustering algorithms we are interested all return different types of
 objects (S3, S4 and R5 classes, as well as simple named lists).

 From the output of these algorithms I need to extract a list with as many
 elements as the number of clusters and such that each element contains the ids
 of the elements in each cluster.

 I have easily done this for each of the cluster algorithms,
 the problem is: how can I make so that rather than having to check for
 classes and
 types this is done automatically?

 For example, for the algorithms that return S3 classes I have defined
 a method get_cluster_list.default and then created the methods for
 the individual classes, which is used in the main body of the
 pipeline.

 I have no idea how I can do this for S4 and R5 classes and,  more
 importantly, I would
 like an approach that works when using all S3, S4 and R5 classes.

 Do you know how I could do this?

 Thanks for the help,
 Luca

 __
 R-help@r-project.org mailing list
 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
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 to draw Bubble chart with mini pie charts as bubbles in R

2014-06-14 Thread Jim Lemon
On Sat, 14 Jun 2014 01:03:21 PM Agony wrote:
 Dear all,
 Good day!
 
 Could anybody help me how to draw a bubble chart with mini pie 
charts as
 bubbles in R ? Introducing any experiences, books, booklet or source 
code
 will appreciated.
 
Hi Amir,
The floating.pie function (plotrix) might do what you want. For 
example:

# first create a simple function to do the chart
pie_bubbles-function(xpos,ypos,radii,sectors,
 sector_col=NULL,main=,xlab=,ylab=) {

 xlim-c(min(xpos-radii),max(xpos+radii))
 ylim-c(min(ypos-radii),max(ypos+radii))
 nbubbles-length(xpos)
 if(is.null(sector_col)) {
  sector_col-list()
  for(scol in 1:nbubbles)
   sector_col[[scol]]-rainbow(length(sectors[[scol]]))
 }
 plot(0,xlim=xlim,ylim=ylim,type=n,
  main=main,xlab=xlab,ylab=ylab)
 for(bubble in 1:nbubbles)
  floating.pie(xpos=xpos[bubble],ypos=ypos[bubble],
   x=sectors[[bubble]],radius=radii[bubble],
   col=sector_col[[bubble]])
}
# set the x positions
xpos-c(2,4,6,8,10)
# and the y positions
ypos-c(4,8,6,10,2)
# the radii are the bubble radii
radii-c(1,0.5,1.2,0.7,1.3)
# these are the sector extents of the pies
sectors-list(1:4,c(5,3,8,6,2),c(3,2,1),c(3,7,5,8),c(2.5,3.7))
# get the plotrix package
library(plotrix)
pie_bubbles(xpos,ypos,radii,sectors,main=Pie bubbles)

The above is pretty basic, but it should get you started.

Jim

__
R-help@r-project.org mailing list
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] sort() depends on locale

2014-06-14 Thread Marius Hofert
Hi,

If I use invisible(Sys.setlocale(LC_COLLATE, C)) in ~/.Rprofile, then

 sort(c(L.Y, Lu, L.Q))
[1] L.Q L.Y Lu

whereas using invisible(Sys.setlocale(LC_COLLATE, en_US.UTF-8)) results in

 sort(c(L.Y, Lu, L.Q))
[1] L.Q Lu  L.Y

I know this issue has appeared already
(https://stat.ethz.ch/pipermail/r-help//2012-February/304089.html), I
just don't see a reason for the second output: either '.' comes before
letters, then the result should be
L.Q L.Y Lu or it comes afterwards, then it should be Lu L.Q
L.Y -- the above result thus seems inconsistent to any useful notion
of 'sort' (?)

Cheers,

Marius

__
R-help@r-project.org mailing list
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.