Re: [R] difference between max in summary table and max function

2015-02-13 Thread Allen Bingham
I thought I'd chime in ... submitting the following:

   ?summary

Provides the following documentation for the default for generalized
argument (other than class="data.frame", "factor", or "matrix"):

   ## Default S3 method:
   summary(object, ..., digits = max(3, getOption("digits")-3))

so passing along the object "testrow" w/o a corresponding argument for
digits ... defaults to digits=4 (assuming your system has the same default
option of digits = 7 that mine does).

... and since later in the documentation it indicates that digits is an:

   integer, used for number formatting with signif()

so noting that all of the values you reported from summary(testrow) all have
4 significant digits (including the Max. of 131500) (excepting the min value
of "1"), summary() is doing what it is documented to do.

... sorry for being pedantic --- but doing so to point out how helpful the
"?" command can be sometimes.

Hope this helps.

__
Allen Bingham
Bingham Statistical Consulting
aebingh...@gmail.com
LinkedIn Profile: www.linkedin.com/pub/allen-bingham/3b/556/325





-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Martyn Byng
Sent: Friday, February 13, 2015 3:15 AM
To: Franckx Laurent; r-help@r-project.org
Subject: Re: [R] difference between max in summary table and max function

Its a formatting thing, try

summary(testrow,digits=20)

-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Franckx
Laurent
Sent: 13 February 2015 11:00
To: r-help@r-project.org
Subject: [R] difference between max in summary table and max function

Dear all

I have found out that the max in the summary of an integer vector is not
always equal to the actual maximum of that vector. For example:


> testrow <- c(1:131509)
> summary(testrow)
   Min. 1st Qu.  MedianMean 3rd Qu.Max.
  1   32880   65760   65760   98630  131500
> max(testrow)
[1] 131509

This has occurred both in a Windows and in a Linux environment.

Does this mean that the max value in the summary is only an approximation?

Best regards

Laurent Franckx, PhD
Senior researcher sustainable mobility
VITO NV | Boeretang 200 | 2400 Mol
Tel. ++ 32 14 33 58 22| mob. +32 479 25 59 07 | Skype: laurent.franckx |
laurent.fran...@vito.be | Twitter @LaurentFranckx




VITO Disclaimer: http://www.vito.be/e-maildisclaimer

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


This e-mail has been scanned for all viruses by Star.\ _...{{dropped:8}}

__
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 portfolio return function?

2015-02-13 Thread Joshua Ulrich
Hi Ernie,

You seem confused.  sqrt(t(w) %*% V %*% w) calculates portfolio
volatility, not returns.  You can calculate portfolio volatility with
PerformanceAnalytics::StdDev.

require(PerformanceAnalytics)
data(edhec)

set.seed(21)
w <- runif(ncol(edhec))
w <- w/sum(w)
sqrt(t(w) %*% cov(edhec) %*% w)
StdDev(edhec, weights=w)

You can use PerformanceAnalytics to calculate the total portfolio
return a couple different ways.

w %*% t(Return.cumulative(edhec))
Return.cumulative(Return.portfolio(edhec, w))

Also, R-SIG-Finance is a better place to ask finance-specific
questions.  You'll likely get faster and more complete responses.

Best,
Josh


On Wed, Feb 11, 2015 at 10:25 AM, Ernest Stokely  wrote:
>
> For finance applications, I'm surprised that I am unable to find a function 
> to compute the portfolio return (sqrt(t(w) %*% V %*% w)) where w are 
> portfolio weights and V is the cov(returns). The Performance Analytics 
> portfolio return function seems to compute something else.
> Ernie
>
> __
> 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.




-- 
Joshua Ulrich  |  about.me/joshuaulrich
FOSS Trading  |  www.fosstrading.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] lme: Can not find groupData object in a function could this be a scoping problem?

2015-02-13 Thread John Sorkin
I resolved my program by restating RStudio . . .
Thanks you,
John


R 3.1.0, RStudio  0.98.95
Windows 7

I have written a function that uses lme:

doit<- function(TS,rho,premean,presd,RxEffect) {
.
.
.
  # Prepare data frames for regression analyses.
  data <- data.frame(group=c(rep("Cont",SS),rep("Exp",SS)),
   pre=pre,post=post)  
.
.
.
  
previous<-data.frame(time=c("pre","post"),cbind(subject=i,group=data[i,"group"],t(data[i,c("pre","post")])))
. 

.
.
  inter<-groupedData(value~as.integer(time)+as.integer(group)+
 as.integer(time)*as.integer(group)|subject,
 inner=~group,data=previous)

  print(inter)
  lmeinter<-lme(inter)
.
.
.
}

When I run the code, at the statement,lmeinter<-lme(inter)  I get a message:
Error in is.data.frame(data) : object 'inter' not found.
Please note that the print statement, print(inter) prints the groupedData 
object!
The code works fine when it is not in a function, i.e. 


  inter<-groupedData(value~as.integer(time)+as.integer(group)+
 as.integer(time)*as.integer(group)|subject,
 inner=~group,data=previous)

  lmeinter<-lme(inter)



runs and has no problem finding inter.


Can someone suggest what I might change to fix the problem? I think I may have 
a scoping problem but I am not knowledgeable enough to know (1) how to check 
this and (2) what to do to fix it.


Thanks,
John




John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 



John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 


Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
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] lme: Can not find groupData object in a function could this be a scoping problem?

2015-02-13 Thread John Sorkin
R 3.1.0, RStudio  0.98.95
Windows 7


I have written a function that uses lme:


doit<- function(TS,rho,premean,presd,RxEffect) {
.
.
.
  # Prepare data frames for regression analyses.
  data <- data.frame(group=c(rep("Cont",SS),rep("Exp",SS)),
   pre=pre,post=post)  
.
.
.
  
previous<-data.frame(time=c("pre","post"),cbind(subject=i,group=data[i,"group"],t(data[i,c("pre","post")])))
. 

.
.
  inter<-groupedData(value~as.integer(time)+as.integer(group)+
 as.integer(time)*as.integer(group)|subject,
 inner=~group,data=previous)

  print(inter)
  lmeinter<-lme(inter)
.
.
.
}


When I run the code, at the statement,lmeinter<-lme(inter)  I get a message:
Error in is.data.frame(data) : object 'inter' not found.
Please note that the print statement, print(inter) prints the groupedData 
object!
The code works fine when it is not in a function, i.e. 


  inter<-groupedData(value~as.integer(time)+as.integer(group)+
 as.integer(time)*as.integer(group)|subject,
 inner=~group,data=previous)

  lmeinter<-lme(inter)



runs and has no problem finding inter.


Can someone suggest what I might change to fix the problem? I think I may have 
a scoping problem but I am not knowledgeable enough to know (1) how to check 
this and (2) what to do to fix it.


Thanks,
John




John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 


Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] How to get the error and error variance after HB using bayesm

2015-02-13 Thread Bert Gunter
This is primarily about statistics, not R, and so is off topic here. I
believe you would do better posting on a stats site like
stats.stackexchange.com, where you could engage in a full (and likely
complicated) discussion of the pros and cons of Bayesian regression
vs. standard frequentist approaches.

Cheers,
Bert

Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374

"Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom."
Clifford Stoll




On Fri, Feb 13, 2015 at 11:46 AM, ARNAB KR MAITY  wrote:
> Hello Michael,
>
> I have a question here. Does Bayesian paradigm deal with MSE kind of stuff?
>
> Thanks & Regards,
> Arnab
>
>
>
> Arnab Kumar Maity
> Graduate Teaching Assistant
> Division of Statistics
> Northern Illinois University
> DeKalb, IL 60115
> Email: ma...@math.niu.edu
> Ph: 779-777-3428
>
> On Fri, Feb 13, 2015 at 4:45 AM, Michael Langmaack <
> michael.langma...@the-klu.org> wrote:
>
>> Hello all,
>>
>> I have a question concerning bayesian regression in R using the package
>> bayesm (version 2.2-5) by Peter Rossi. I have binary choice data and
>> estimated individual coefficients using the command
>> rhierBinLogit(Data=Data,Mcmc=Mcmc). That worked out properly, conversion
>> plots, histograms, parameter are fine. No a have to compute the errors and
>> the error variance or something like the MSE. But I do not know how to do.
>> I did not find a hint so far. I would be more than happy if anybody can
>> help me. Thanks in advance!
>>
>> Best regards,
>> Michael
>>
>> [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] qq-Plot function in version 3.1.2.

2015-02-13 Thread John Fox
Dear Xavier,

Perhaps you mean the qqPlot() function in the car package. If so, you should
install the car package. As well, if anc0 is a linear or generalized linear
model, qqPlot() has a method for plotting studentized residuals and you'd
probably prefer to use that rather than extracting the residuals from the
model.

I hope this helps,
 John

---
John Fox, Professor
McMaster University
Hamilton, Ontario, Canada
http://socserv.mcmaster.ca/jfox/



> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of
> CHIRIBOGA Xavier
> Sent: February-13-15 4:33 PM
> To: r-help@r-project.org
> Subject: [R] qq-Plot function in version 3.1.2.
> 
> Hello! SORRY PROBLEMS WITH FUNCTIONS AGAIN...
> 
> 
> 
> I NEED TO RUN A qqPlot ...I TRIED TO INSTALL IT , BUT A WARNING MESSAGE
> SAID
> 
> 
> 
> qqPlot is not available for version 3.1.2.
> 
> 
> 
> 
> 
> 
> 
> qqPlot(residuals(anc0),id.method="identify")
> Error: could not find function "qqPlot"
> > install.packages("qqPlot")
> Installing package into 'C:/Users/chiribogax/Documents/R/win-library/3.1'
> (as 'lib' is unspecified)
> Warning in install.packages :
>   package 'qqPlot' is not available (for R version 3.1.2)
> 
> 
> 
> WHAT CAN ID DO?
> 
> 
> 
> THANK YOU,
> 
> 
> 
> Xavier
> 
> __
> 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.


---
This email has been checked for viruses by Avast antivirus software.
http://www.avast.com

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


Re: [R] Unable to use `eval(parse(text))' in nlme::lme

2015-02-13 Thread William Dunlap
> ff <- reformulate(termlabels=c("time","as.factor(gvhd)"), response=yname,
intercept=TRUE)

If the right hand side of the formula were more complicated than an
additive list of terms,
say '~ time * as.factor(gvhd)' or the left side were more than a name, say
'log(yname)' you
could use bquote() instead of reformulate.  E.g.,
  > formulaTemplate <- log(.(responseName)) ~ time * as.factor(gvhd)
  > lapply(c("y1","y2","y3"), function(yname)do.call(bquote,
list(formulaTemplate, list(responseName=as.name(yname)
  [[1]]
  log(y1) ~ time * as.factor(gvhd)

  [[2]]
  log(y2) ~ time * as.factor(gvhd)

  [[3]]
  log(y3) ~ time * as.factor(gvhd)

I used 'do.call' because bquote does not evaluate its first argument,
but we need to evaluate the name 'formulaTemplate'.  You could avoid that
by putting the template verbatim in the call to bquote, as in
  lapply(c("y1","y2","y3"), function(yname)bquote(log(.(responseName)) ~
time * as.factor(gvhd), list(responseName=as.name(yname

I like the do.call method because I can bury it in a function and forget
about it.

bquote() retains the environment of the formula template.


Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Mon, Feb 9, 2015 at 6:44 AM, Ravi Varadhan  wrote:

> Thanks to Rolf, Duncan, and Ben.
>
> Ben, your suggestion worked (with a minor correction of concatenating the
> termlabels into a vector).
>
> Here is the solution to those interested.
>
> ff <- reformulate(termlabels=c("time","as.factor(gvhd)"), response=yname,
> intercept=TRUE)
> dd <- subset(labdata2, Transplant_type!=0 & time >0)
> lme(ff, random=~1|Patient, data=dd, correlation=corAR1(),
> na.action=na.omit)
>
> Best,
> Ravi
>
> Ravi Varadhan, Ph.D. (Biostatistics), Ph.D. (Environmental Engg)
> Associate Professor
> Department of Oncology
> Division of Biostatistics & Bionformatics
> Johns Hopkins University
> 550 N. Broadway
> Baltimore, MD 21205
> 40-502-2619
>
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] qq-Plot function in version 3.1.2.

2015-02-13 Thread Spencer Graves

> On Feb 13, 2015, at 1:32 PM, CHIRIBOGA Xavier  
> wrote:
> 
> Hello! SORRY PROBLEMS WITH FUNCTIONS AGAIN...
> 
> 
> 
> I NEED TO RUN A qqPlot ...I TRIED TO INSTALL IT , BUT A WARNING MESSAGE SAID
> 
> 
> 
> qqPlot is not available for version 3.1.2.


  What do you want?  


  There is a "qqplot" function in the stats package.  Beyond that, 
consider the following:  


library(sos)
qqp <- ???qqPlot
# This downloaded 233 links in 96 packages for me just now.  
sum(qqp$Package=='qqPlot') 
# 0 ... i.e., there is no package by that name (and hasn't been one on CRAN, I 
don't think) 
qqp
# Opens a page in your default browser containing a table, the first entry of 
which is for a function "qqPlot" in the "EnvStats" package.  


  Hope this helps.  
  Spencer 
> 
> 
> qqPlot(residuals(anc0),id.method="identify")
> Error: could not find function "qqPlot"
>> install.packages("qqPlot")
> Installing package into ‘C:/Users/chiribogax/Documents/R/win-library/3.1’
> (as ‘lib’ is unspecified)
> Warning in install.packages :
>  package ‘qqPlot’ is not available (for R version 3.1.2)
> 
> 
> 
> WHAT CAN ID DO?
> 
> 
> 
> THANK YOU,
> 
> 
> 
> Xavier
> 
> __
> 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] qq-Plot function in version 3.1.2.

2015-02-13 Thread Sarah Goslee
Let's see...

You can spell it qqplot.
You can avoid trying to install nonexistent packages with made-up names.
You can learn to use www.rseek.org
You can learn how to undo your caps lock key. ;)

But do try the first one, in the form of
?qqplot

Sarah

On Fri, Feb 13, 2015 at 4:32 PM, CHIRIBOGA Xavier
 wrote:
> Hello! SORRY PROBLEMS WITH FUNCTIONS AGAIN...
>
>
>
> I NEED TO RUN A qqPlot ...I TRIED TO INSTALL IT , BUT A WARNING MESSAGE SAID
>
>
>
> qqPlot is not available for version 3.1.2.
>
>
>
>
>
>
>
> qqPlot(residuals(anc0),id.method="identify")
> Error: could not find function "qqPlot"
>> install.packages("qqPlot")
> Installing package into ‘C:/Users/chiribogax/Documents/R/win-library/3.1’
> (as ‘lib’ is unspecified)
> Warning in install.packages :
>   package ‘qqPlot’ is not available (for R version 3.1.2)
>
>
>
> WHAT CAN ID DO?
>
>
>
> THANK YOU,
>
>
>
> Xavier
>
> __
> 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.



-- 
Sarah Goslee
http://www.functionaldiversity.org

__
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] qq-Plot function in version 3.1.2.

2015-02-13 Thread CHIRIBOGA Xavier
Hello! SORRY PROBLEMS WITH FUNCTIONS AGAIN...



I NEED TO RUN A qqPlot ...I TRIED TO INSTALL IT , BUT A WARNING MESSAGE SAID



qqPlot is not available for version 3.1.2.







qqPlot(residuals(anc0),id.method="identify")
Error: could not find function "qqPlot"
> install.packages("qqPlot")
Installing package into ‘C:/Users/chiribogax/Documents/R/win-library/3.1’
(as ‘lib’ is unspecified)
Warning in install.packages :
  package ‘qqPlot’ is not available (for R version 3.1.2)



WHAT CAN ID DO?



THANK YOU,



Xavier

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


Re: [R] How to get the error and error variance after HB using bayesm

2015-02-13 Thread ARNAB KR MAITY
Hello Michael,

I have a question here. Does Bayesian paradigm deal with MSE kind of stuff?

Thanks & Regards,
Arnab



Arnab Kumar Maity
Graduate Teaching Assistant
Division of Statistics
Northern Illinois University
DeKalb, IL 60115
Email: ma...@math.niu.edu
Ph: 779-777-3428

On Fri, Feb 13, 2015 at 4:45 AM, Michael Langmaack <
michael.langma...@the-klu.org> wrote:

> Hello all,
>
> I have a question concerning bayesian regression in R using the package
> bayesm (version 2.2-5) by Peter Rossi. I have binary choice data and
> estimated individual coefficients using the command
> rhierBinLogit(Data=Data,Mcmc=Mcmc). That worked out properly, conversion
> plots, histograms, parameter are fine. No a have to compute the errors and
> the error variance or something like the MSE. But I do not know how to do.
> I did not find a hint so far. I would be more than happy if anybody can
> help me. Thanks in advance!
>
> Best regards,
> Michael
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] ggplot2 shifting bars to only overlap in groups

2015-02-13 Thread John Kane
Both files came through.  The R-help list is picky. For example it will accept 
cat.txt but not cat.csv.

Now I see what you are after. and I must admit I haven't a clue at the moment. 
I suspect others who know more about ggplot can help.  If not there is ggplot2 
Google Groups that has a lot of knowledge and you might want to post there.  It 
accepts all kinds of file types. :)

On the other hand, I don't like dynamite plots (what you have) and wondered if 
it was possible to do something with geom_point() instead.

It was, in a bit of a half-assed way so I'll pass on my raw code. It's ulgy but 
works. I don't know if I'd call it pub-quality but perhaps it can be tweaked 
(wrenched? , bludgened?) into something acceptable.

BTW, I changed your data.frame name to dat1.  df is an R function.  Type df and 
you will see what I mean. I've also converted the data to a dput() file. Not 
needed as you supplied a perfectly good data set but generally good practice.

Sorry I was not able to be of more help

John Kane
Kingston ON Canada

Begin code ##
library(ggplot2)
library(scales)
dat1  <-  structure(list(gender = structure(c(1L, 2L, 1L, 2L, 1L, 2L, 1L, 
2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 
2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L), .Label = c("male", "female"
), class = "factor"), direction = structure(c(1L, 1L, 2L, 2L, 
1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 
1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L), .Label = c("up", 
"down"), class = "factor"), condition = structure(c(1L, 1L, 1L, 
1L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 1L, 1L, 1L, 
1L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L), .Label = c("c1", 
"c2", "c3", "c4"), class = "factor"), location = structure(c(1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("east", 
"west"), class = "factor"), t = c(1.78664348823968, 1.045971213672, 
1.45271943418506, 1.52433880441405, 0.894240903766416, 1.04200421306615, 
0.992602172725307, 1.35686661120166, 1.15664717132331, 1.78519605814623, 
1.3131987417228, 1.23649081362245, 1.33657440193627, 1.39069933103098, 
1.16990353110185, 1.50384132346169, 0.240063246756554, 0.151918103772423, 
1.26918566082989, 1.44462610872269, 0.944676078996681, 0.945358342820427, 
0.68274449456263, 0.983609699924918, 1.06442538569853, 0.917922814494952, 
1.06681054493614, 0.899670881737641, 0.639091165646195, 1.81227533189609, 
1.02711921654525, 2.05244515236416), ci = c(0.199453475099606, 
0.0208699634619525, 0.0267762622040696, 0.0719683008799792, 0.0388022593655329, 
0.0873965412159785, 0.0828671112758008, 0.556676454332325, 0.109726976194332, 
0.237352334670391, 0.202173510668684, 0.104263016807603, 0.0174283081233597, 
0.027601059580507, 0.118300511535772, 0.272210060810133, 0.210343075045509, 
0.010793003362928, 0.241665829872765, 0.387877941848338, 0.230361471258575, 
0.233088662079594, 0.0956745517473407, 0.187969512005399, 0.0041769632082831, 
0.26242665290992, 0.297793257986101, 0.14520541873456, 0.123447338902161, 
0.10109002280374, 0.332925731545975, 0.434868806611465)), .Names = c("gender", 
"direction", "condition", "location", "t", "ci"), row.names = c(NA, 
-32L), class = "data.frame")


dat1$jit <- ifelse( dat1$gender == "male",  1,
ifelse( dat1$gender == 'female',  2,
  NA) )
dat1$jit  <-  as.numeric(dat1$jit)

dat1$jit  <-  jitter(dat1$jit)

x  <-  "male"
y  <-  "female"Begin code ##
ab <-  ggplot(dat1, aes (jit, t)) +
   geom_point(aes(colour = condition)) +
theme(axis.ticks = element_blank()) +
scale_x_continuous(breaks=c(1, 2), 
   labels=c("male", "female"),
   name="Gender")
ab


bb  <-  ab + facet_grid(location~.)
bb

bc  <-  bb + 
geom_errorbar(data = dat1, aes(ymin=t-ci, ymax=t+ci, 
colour = condition),
  width=.2 )
bc
  

cf  <-  bc + coord_flip()
cf

End code ###


John Kane
Kingston ON Canada

-Original Message-
From: hyil...@gmail.com
Sent: Fri, 13 Feb 2015 02:28:17 +0800
To: jrkrid...@inbox.com
Subject: Re: [R] ggplot2 shifting bars to only overlap in groups

I did not know the SVG file did not come through. I thought SVG should be able 
to pass through the filter. Here is a PDF file along with an PNG. Guess one of 
them should be able to pass.

祝好,

He who is worthy to receive his days and nights is worthy to receive* all 
else* from you (and me).
                                                 The Prophet, Gibran Kahlil 

On Fri, Feb 13, 2015 at 12:04 AM, John Kane  wrote:

 I'm a bit blind today. I read df as a dput() .

 John Kane
 Kingston ON Canada

 -Original Message-
 From: hyil...@gmail.com
 Sent: Thu, 12 Feb 2015 23:38:01 +0800
 To: jrkrid...@inbox.com
 Subject: Re: [R] ggplot2 shifting bars to only overlap 

Re: [R] Why I am getting error when writing a function for "optim"?

2015-02-13 Thread S Ellison
You don't appear to be supplying a valid parameter set to optim. 

The first argument in optim (par) must be a vector of parameters to optimise; 
you're passing a vector of NAs. Thise are not finite.

Also, temp is defined as a value and optim will not be able to optimise that. 
You need to define temp as a function.

S



***
This email and any attachments are confidential. Any use...{{dropped:8}}

__
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] sd, mean with a frequency distribution matrix

2015-02-13 Thread JS Huang
Hi,

  Try this.

> sd(unlist(sapply(1:dim(p)[1],function(i)rep(p[i,1],p[i,2] 



--
View this message in context: 
http://r.789695.n4.nabble.com/sd-mean-with-a-frequency-distribution-matrix-tp4703218p4703220.html
Sent from the R help mailing list archive at Nabble.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] 2d rotation: vegan?

2015-02-13 Thread Randall Morris-Ostrom
I've been working at interpreting the results of a non-metric multidimensional 
scaling analysis. I have been using metaMDS in the vegan package because one of 
the benefits is that it also rotates to solution to its principal components. 
(Eventually I realized that there is no reason why my results would be most 
interpretable when aligned along the PC, but it was a nice starting point.)

I have been trying to find ways to rotate the resulting plot so I can visualize 
it differently and look at actual plot positions (as opposed to just rotating 
the print outs I have been looking at.) I'm able to find lots of suggestions 
for how to rotate3d plots, but almost nothing for 2d. I have tried using the 
MDSrotate function in vegan, but really it comes down to the fact that I'm 
clueless when I try to make sense of the documentation. *somewhat embarrassed*  
My goal is basically to rotate the plot and exam the structure as a tool to 
generate theories about the meaning of the different dimensions (the 
interpretation of the clusters in my research are crystal clear.)

I generated a little fake data, just so there would be a plot. I've been trying 
to figure out how to do this as either just a simple scatterplot or using the 
vegan package.

Thank you for your time,
Randy

Randall Morris-Ostrom J.D., M.S.
Doctoral Candidate in Psychology,
University of St. Thomas
randall.morrisost...@icloud.com


Sample Code

library(vegan)
set.seed(12345)
x <- rnorm(1:10)
y <- rnorm(1:10)
df <- data.frame(x,y)
d <- dist(df, method = "euclidean")
nmds <- metaMDS(df, distance = "euclidean", k = 2)
plot(nmds)
# or
nmdp <- as.data.frame(nmds$points)
plot(nmdp$MDS1, nmdp$MDS2)
[[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] How to get the error and error variance after HB using bayesm

2015-02-13 Thread Michael Langmaack
Hello all,

I have a question concerning bayesian regression in R using the package bayesm 
(version 2.2-5) by Peter Rossi. I have binary choice data and estimated 
individual coefficients using the command rhierBinLogit(Data=Data,Mcmc=Mcmc). 
That worked out properly, conversion plots, histograms, parameter are fine. No 
a have to compute the errors and the error variance or something like the MSE. 
But I do not know how to do. I did not find a hint so far. I would be more than 
happy if anybody can help me. Thanks in advance!

Best regards,
Michael

[[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] Why I am getting error when writing a function for "optim"?

2015-02-13 Thread Jonsson
I have three directories where there is inside each of them 5 files.each file
is a matrix lines 500 and columns 300. I want to perform an optimization
using values from three corresponding pixels.Finally I get a matrix of lines
500 and columns 300 for each parameter in my equation:

   y=(ax1+bx2+c)^2+d
reproducible example:

  dat1 <- array(1:60, c(3,5,4));dat2 <- array(rnorm(60), c(3,5,4));
  dat3 <-array(rnorm(60), c(3,5,4))
reorder dimensions

   dat1 <- aperm(dat1, c(3,1,2));dat2 <- aperm(dat2, c(3,1,2));
   dat3 <- aperm(dat2, c(3,1,2))
make array a matrix

  dat1a <- dat1  ; dim(dat1a) <- c(dim(dat1)[1],prod(dim(dat1)[2:3]))
  dat2a <- dat2;  dim(dat2a) <- c(dim(dat2)[1],prod(dim(dat2)[2:3]))
  dat3a <- dat3 ; dim(dat3a) <- c(dim(dat3)[1],prod(dim(dat3)[2:3]))

> fun
function(x1,x2, y) {
  keep <- !(is.na(x) | is.na(x2)| is.na(y))
  if (sum(keep) > 2) { #less than 3 non-NA values?
temp <- sum((y[keep] - (p[1]*x1[keep]+p[2]*x2[keep]+p[3])^p[4]+p[5])^2)
res <- optim(rep(NA,5),temp)
  } else {
res <- c(NA, NA,NA,NA,NA)#five parameters
  }
 res
}
> res <- mapply(fun, x1=as.data.frame(dat1a), x2=as.data.frame(dat2a),
> y=as.data.frame(dat3a)) 
Error in optim(rep(NA, 5), temp) : non-finite value supplied by optim

Any idea please on how to correct my function?



--
View this message in context: 
http://r.789695.n4.nabble.com/Why-I-am-getting-error-when-writing-a-function-for-optim-tp4703205.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] problems with packages installation

2015-02-13 Thread Jeff Newmiller
I agree that the PG muddies the water a bit on this topic. However, the web 
page from which you downloaded the patched version warns:

"This is not an official release of R. Please check bugs in this version 
against the official release before reporting them."

When a new version is under  development, the number of bugs often increases 
temporarily by quite a bit. Any use you make of a patched or development 
version is at your own risk, and should be undertaken for two reasons only: to 
address a  specific problem you are having with the released version, or 
because you want to help test the unreleased version out of the goodness of 
your heart (bless you). In either case, chatter about bugs you encounter that 
are not in the released version belongs on R-devel.

If you can reproduce the problem in a released version, posting on R-help would 
be more appropriate, but if you are sure it is a bug then filling a report is 
the right thing to do.
---
Jeff NewmillerThe .   .  Go Live...
DCN:Basics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

On February 13, 2015 4:03:46 AM PST, PIKAL Petr  wrote:
>Hi Jeff
>
>Can you be more specific why question about "using" R-devel shall be
>directed to R-devel help list?
>
>Posting guide tells me:
>
>R-help is intended to be comprehensible to people who want to use R to
>solve problems but who are not necessarily interested in or
>knowledgeable about programming. R-devel is intended for questions and
>discussion about code development in R. Questions likely to prompt
>discussion unintelligible to non-programmers should go to to R-devel.
>For example, questions involving C, C++, etc. code should go to
>R-devel. More general questions involving pure R code and questions
>likely to be of interest to the large and diverse set of subscribers to
>R-help should go to R-help.
>
>and
>
>If you are using an old version of R and think it does not work
>properly, upgrade to the latest version and try that, before posting.
>If possible, try the current R-patched or R-devel version of R (see the
>FAQ for details), to see if the problem has already been addressed.
>
>So even Posting guide suggests to poor user not to use obsolete version
>of R and try R-patched or R-devel.
>
>To be honest - in R-patched (3.1.2)
>
>setInternet2(TRUE)
>utils:::menuInstallPkgs()
>
>works without problems and the same applies to R-devel version from
>June (3.2.0 - 66175) but it throws error in (3.2.0 - 67792).
>
>There is 15814 bug report about Package Installation which is replied
>by Brian Ripley:
>
>The 'package installer' is the program which installs the Apple
>package.  If you mean the 'Package Installer' menu item in R.app, there
>is a known issue (but that is only known to causes failures, not
>freezes).
>
>I tried Richard's suggestion (thanks Richard) and with small
>modification (I do not want to install from sources)
>
>install.packages("ggplot2", repos="http://cran.at.r-project.org";,
>dependencies=TRUE)
>
>works as expected, therefore the problem is in **menu driven
>installation procedure**. Shall I fill a bug report? Or it is already
>known to R developers?
>
>Best regards
>Petr
>
>
>> -Original Message-
>> From: Jeff Newmiller [mailto:jdnew...@dcn.davis.ca.us]
>> Sent: Thursday, February 12, 2015 6:15 PM
>> To: PIKAL Petr; r-help@r-project.org
>> Subject: Re: [R] problems with packages installation
>>
>> Time to (re)read the Posting Guide... questions about unreleased
>> versions of R are off topic here. Go to R-devel.
>>
>---
>> 
>> Jeff NewmillerThe .   .  Go
>> Live...
>> DCN:Basics: ##.#.   ##.#.  Live
>> Go...
>>   Live:   OO#.. Dead: OO#..
>> Playing
>> Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
>> /Software/Embedded Controllers)   .OO#.   .OO#.
>> rocks...1k
>>
>---
>> 
>> Sent from my phone. Please excuse my brevity.
>>
>> On February 12, 2015 11:40:48 AM EST, PIKAL Petr
>>  wrote:
>> >Dear all
>> >
>> >I just switched to new version
>> >
>> >> version
>> >   _
>> >platform   i386-w64-mingw32
>> >arch   i386
>> >os mingw32
>> >system i386, mingw32
>> >status Under development (unstable)
>> >major  3
>> >minor  2.0
>> >year   2015
>> >month  02
>> >day11
>> >svn rev 

Re: [R] [BUG] or [undocumented] boxplot - horizontal swaps ylim and xlim

2015-02-13 Thread Rainer M Krug
S Ellison  writes:

>> When using the function boxplot() together with the argument
>> | horizontal = TRUE
>> xlim and ylim become swapped, i.e. ylim refers to the x-axis instead of the 
>> y-
>> axis:
>
> It is neither a bug nor undocumented, though the documentation is a
> not in ?boxplot (because xlim and ylim aren't defined there) and is
> also tad unclear in the present version.
>
> For boxplot and its methods, xlim and ylim fall into '...', which is
> (as documented) passed to bxp (see boxplot.default).
> ?bxp, says:
>
> "pars,...: graphical parameters (etc) can be passed as arguments to this
>   function, either as a list ('pars') or normally('...'), see
>   the following.  (Those in '...' take precedence over those in
>   'pars'.)
>
>   Currently, 'yaxs' and 'ylim' are used 'along the boxplot',
>   i.e., vertically, when 'horizontal' is false, and 'xlim'
>   horizontally.  'xaxt', 'yaxt', 'las', 'cex.axis', and
>   'col.axis' are passed to 'axis', and 'main', 'cex.main',
>   'col.main', 'sub', 'cex.sub', 'col.sub', 'xlab', 'ylab',
>   'cex.lab', and 'col.lab' are passed to 'title'."
>
> The key phrase is "Currently, 'yaxs' and 'ylim' are used 'along the 
> boxplot'," 

Thanks for clarifying this.

I think this should be mentioned in boxplot as well.

Cheers,

Rainer

>
> S Ellison
>
>
>
> ***
> This email and any attachments are confidential. Any u...{{dropped:24}}
__
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] Sorting Surv objects

2015-02-13 Thread Therneau, Terry M., Ph.D.

Your work around is not as "easy" looking to me.

Survival times come in multiple flavors: left censored, right censored, interval censored, 
left-truncated and right censored, and multi-state.  Can you give me guidance on how each 
of these should sort?  If a sort method is added to the package it needs to deal with all 
of these.


 Professor Ripley has pointed out that the default action of sort() for right censored 
times, which I agree is reasonable.


Terry Therneau (author of the survival package)


On 02/13/2015 05:00 AM, r-help-requ...@r-project.org wrote:

It seems that Surv objects do not sort correctly.   This seems to be a bug.  
Anyone else found this?


>survival.data

[1] 4+ 3  1+ 2  5+

>class(survival.data)

[1] "Surv"

>sort(survival.data)

[1] 2  1+ 4+ 3  5+

An easy work-around is to define a function sort.Surv


__
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] SIMPLE question

2015-02-13 Thread S Ellison
> I want to do a boxcox transformation, but I got this:
> Error: could not find function "boxcox"
> 
> What can I do? 

Well, the recommended 'homework' in the posting guide would be a start.

i) ??boxcox, if you have any packages installed that include something with 
that functionality.
ii) RSiteSearch("Box-Cox")
iii) Use a search engine to find  'box-cox transform in R'

These would lead you to a number of packages, such as the car package, which 
include the transform. 

S


***
This email and any attachments are confidential. Any use...{{dropped:8}}

__
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] suggestion for optimal plotting to show significant differences

2015-02-13 Thread PIKAL Petr
Hi Rich

As usual in R one can come to same result by different means. Using lme from 
nlme

fit<- lme(value ~ day, data=test, random= ~1|item)
ranef(fit)
  (Intercept)
a  -4.8794330
b  -3.5063635
c  -1.7121614
d  -0.2002288
e   0.5118846
f   1.7805122
g   3.4489819
h   4.5568079
fixef(fit)
(Intercept) day
6.933644464 0.009715795

which is close to the way how "value" was constructed (day coefficient shall be 
1)

> mean(apply(ranef(fit), 2,diff))
[1] 1.348034

But AFAIK lme or nlme is applicable only if I can find some suitable model 
function.

I therefore like your suggestion to treat day as a factor which, if I 
understand it well, enables me to look at item differences each day and compare 
if they are or are not important.

Thanks for your insight
Best regards

Petr


> -Original Message-
> From: Richard M. Heiberger [mailto:r...@temple.edu]
> Sent: Thursday, February 12, 2015 9:27 PM
> To: PIKAL Petr
> Cc: r-help@r-project.org
> Subject: Re: [R] suggestion for optimal plotting to show significant
> differences
>
> ## The next step is to think of this in the analysis of covariance
> setting.
>
> ## this example is based on
>
> library(HH)
>
> demo("ancova", package="HH", ask=FALSE)
>
> item<-rep(letters[1:8], each=18)
> day<-rep((0:5)*100, 24)
> set<-rep(rep(1:3, each=6), 8)
> test<-data.frame(item, day, set)
> set.seed(111)
> test$value<-(test$day/100+1)+rnorm(144)
> test$value<-test$value+(as.numeric(test$item)*1.3)
> test$dayf <- factor(test$day)
>
>
> Fitalphabeta <- aov(value ~ day, data=test)
> AB <- xyplot(value ~ day | item, data=test, layout=c(8,1),
> scales=list(alternating=1),
>  main="regression, ignoring item\ncommon slope, common
> intercept") +
>layer(panel.abline(coef(Fitalphabeta)))
> AB
>
> Fitalphabeta0 <- aov(value ~ 0 + item, data=test)
> AB0 <- xyplot(value ~ day | item, data=test, layout=c(8,1),
> scales=list(alternating=1),
>   main="anova, ignoring day\nzero slope, variable
> intercept") +
>
> layer(panel.abline(a=coef(Fitalphabeta0)[panel.number()], b=0))
> AB0
>
> Fitalphaibeta <- aov(value ~ 0 + item + day, data=test)
> AiB <- xyplot(value ~ day | item, data=test, layout=c(8,1),
> scales=list(alternating=1),
>   main="ancova\ncommon slope, variable intercept") +
>
> layer(panel.abline(a=coef(Fitalphaibeta)[panel.number()],
> b=rev(coef(Fitalphaibeta))[1]))
> AiB
>
> Fitalphaibetaj <- aov(value ~ 0 + item / day, data=test)
> AiBj <- xyplot(value ~ day | item, data=test, layout=c(8,1),
> scales=list(alternating=1),
>main="ancova with interaction\nvariable slope, variable
> intercept") +
>
> layer(panel.abline(a=coef(Fitalphaibetaj)[panel.number()],
> b=coef(Fitalphaibetaj)[8 + panel.number()]))
> AiBj
>
> ## this is very tight on the standard 7x7 plotting surface.
> ## it will look ok with 10in wide and 7in high
> ## pdf("AB2x2.pdf", height=7, width=10)
> print(AB,   split=c(1, 1, 2, 2), more=TRUE)
> print(AB0,  split=c(1, 2, 2, 2), more=TRUE)
> print(AiB,  split=c(2, 1, 2, 2), more=TRUE)
> print(AiBj, split=c(2, 2, 2, 2), more=FALSE)
> ## dev.off()
>
> ## this arrangement matches the arrangement in demo("ancova")
> ## this too is very tight on the standard 7x7 plotting surface.
> ## it will look ok with 10in wide and 10in high
> ## pdf("AB2x3.pdf", height=10, width=10)
> print(AB,   split=c(1, 2, 2, 3), more=TRUE)
> print(AB0,  split=c(2, 3, 2, 3), more=TRUE)
> print(AiB,  split=c(2, 2, 2, 3), more=TRUE)
> print(AiBj, split=c(2, 1, 2, 3), more=FALSE)
> ## dev.off()
>
>
> On Thu, Feb 12, 2015 at 9:48 AM, PIKAL Petr 
> wrote:
> > Hi Rich
> >
> >> -Original Message-
> >> From: Richard M. Heiberger [mailto:r...@temple.edu]
> >> Sent: Wednesday, February 11, 2015 10:53 PM
> >> To: PIKAL Petr
> >> Cc: r-help@r-project.org
> >> Subject: Re: [R] suggestion for optimal plotting to show significant
> >> differences
> >>
> >> Petr,
> >>
> >> My first attempt is to use the simple=TRUE argument to
> interaction2wt.
> >>
> >> Then the bwplots in the item|item panel show the behavior of value
> over
> >> day for each item.  You get a plot similar to this panel with the
> >> growth curve plots from nlme, for example,
> >> bwplot(value ~ day | item, data=test, horizontal=FALSE) I am
> >> treating set as a replication and each box is cumulated over the
> three
> >> sets.
> >
> > Yes, that is the point - set is actually replication of result.
> >
> >>
> >> My analysis question is about day.  You have it as numeric.  My
> >> inclination would be to make day factor.  Then you could model the
> >> interaction of day and item.
> >
> > Hm. I hoped I can do
> >
> > fit<-lm(value~day*item, data=test)
> > summary(fit)
> >
> > in which case I can compare differences in intercepts and/or slopes
> for each item.
> >
> > However I am rather lost in aov
> >
> > test$dayf <- factor(test$day)
> >
> > fit1 <- aov(value~item+dayf, data=test)
> > summary(fit)
> > fit2 <- aov(value~item/dayf, data=test)
> > summary(f

Re: [R] [BUG] or [undocumented] boxplot - horizontal swaps ylim and xlim

2015-02-13 Thread S Ellison
> When using the function boxplot() together with the argument
> | horizontal = TRUE
> xlim and ylim become swapped, i.e. ylim refers to the x-axis instead of the y-
> axis:

It is neither a bug nor undocumented, though the documentation is a not in 
?boxplot (because xlim and ylim aren't defined there) and is also tad unclear 
in the present version.

For boxplot and its methods, xlim and ylim fall into '...', which is (as 
documented) passed to bxp (see boxplot.default).
?bxp, says:

"pars,...: graphical parameters (etc) can be passed as arguments to this
  function, either as a list ('pars') or normally('...'), see
  the following.  (Those in '...' take precedence over those in
  'pars'.)

  Currently, 'yaxs' and 'ylim' are used 'along the boxplot',
  i.e., vertically, when 'horizontal' is false, and 'xlim'
  horizontally.  'xaxt', 'yaxt', 'las', 'cex.axis', and
  'col.axis' are passed to 'axis', and 'main', 'cex.main',
  'col.main', 'sub', 'cex.sub', 'col.sub', 'xlab', 'ylab',
  'cex.lab', and 'col.lab' are passed to 'title'."

The key phrase is "Currently, 'yaxs' and 'ylim' are used 'along the boxplot',"  
   

S Ellison



***
This email and any attachments are confidential. Any use...{{dropped:8}}

__
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] problems with packages installation

2015-02-13 Thread PIKAL Petr
Hi Jeff

Can you be more specific why question about "using" R-devel shall be directed 
to R-devel help list?

Posting guide tells me:

R-help is intended to be comprehensible to people who want to use R to solve 
problems but who are not necessarily interested in or knowledgeable about 
programming. R-devel is intended for questions and discussion about code 
development in R. Questions likely to prompt discussion unintelligible to 
non-programmers should go to to R-devel. For example, questions involving C, 
C++, etc. code should go to R-devel. More general questions involving pure R 
code and questions likely to be of interest to the large and diverse set of 
subscribers to R-help should go to R-help.

and

If you are using an old version of R and think it does not work properly, 
upgrade to the latest version and try that, before posting. If possible, try 
the current R-patched or R-devel version of R (see the FAQ for details), to see 
if the problem has already been addressed.

So even Posting guide suggests to poor user not to use obsolete version of R 
and try R-patched or R-devel.

To be honest - in R-patched (3.1.2)

setInternet2(TRUE)
utils:::menuInstallPkgs()

works without problems and the same applies to R-devel version from June (3.2.0 
- 66175) but it throws error in (3.2.0 - 67792).

There is 15814 bug report about Package Installation which is replied by Brian 
Ripley:

The 'package installer' is the program which installs the Apple package.  If 
you mean the 'Package Installer' menu item in R.app, there is a known issue 
(but that is only known to causes failures, not freezes).

I tried Richard's suggestion (thanks Richard) and with small modification (I do 
not want to install from sources)

install.packages("ggplot2", repos="http://cran.at.r-project.org";, 
dependencies=TRUE)

works as expected, therefore the problem is in **menu driven installation 
procedure**. Shall I fill a bug report? Or it is already known to R developers?

Best regards
Petr


> -Original Message-
> From: Jeff Newmiller [mailto:jdnew...@dcn.davis.ca.us]
> Sent: Thursday, February 12, 2015 6:15 PM
> To: PIKAL Petr; r-help@r-project.org
> Subject: Re: [R] problems with packages installation
>
> Time to (re)read the Posting Guide... questions about unreleased
> versions of R are off topic here. Go to R-devel.
> ---
> 
> Jeff NewmillerThe .   .  Go
> Live...
> DCN:Basics: ##.#.   ##.#.  Live
> Go...
>   Live:   OO#.. Dead: OO#..
> Playing
> Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
> /Software/Embedded Controllers)   .OO#.   .OO#.
> rocks...1k
> ---
> 
> Sent from my phone. Please excuse my brevity.
>
> On February 12, 2015 11:40:48 AM EST, PIKAL Petr
>  wrote:
> >Dear all
> >
> >I just switched to new version
> >
> >> version
> >   _
> >platform   i386-w64-mingw32
> >arch   i386
> >os mingw32
> >system i386, mingw32
> >status Under development (unstable)
> >major  3
> >minor  2.0
> >year   2015
> >month  02
> >day11
> >svn rev67792
> >language   R
> >version.string R Under development (unstable) (2015-02-11 r67792)
> >nickname   Unsuffered Consequences
> >
> >and started to have problems with installing packages through utils
> >
> >> setInternet2(TRUE)
> >> utils:::menuInstallPkgs()
> >--- Please select a CRAN mirror for use in this session --- also
> >installing the dependencies ‘colorspace’, ‘Rcpp’, ‘stringr’,
> >‘RColorBrewer’, ‘dichromat’, ‘munsell’, ‘labeling’, ‘plyr’, ‘digest’,
> >‘gtable’, ‘reshape2’, ‘scales’, ‘proto’
> >
> >trying URL
> >'http://cran.at.r-project.org/src/contrib/colorspace_1.2-4.zip'
> >Error in download.file(url, destfile, method, mode = "wb", ...) :
> >cannot open URL
> >'http://cran.at.r-project.org/src/contrib/colorspace_1.2-4.zip'
> >In addition: Warning message:
> >In download.file(url, destfile, method, mode = "wb", ...) :
> >  cannot open: HTTP status was '404 Not Found'
> >Warning in download.packages(pkgs, destdir = tmpd, available =
> >available,  :
> >  download of package ‘colorspace’ failed 
> >
> >Before I start to disturb our IT I just want to know what could be the
> >issue. AFAIK I did not change anything on my PC. In previous R-devel
> >version I used this package installation worked (and still works)
> >
> >> utils:::menuInstallPkgs()
> >--- Please select a CRAN mirror for use in this session --- trying URL
> >'http://cran.at.r-project.org/bin/windows/contrib/3.2/mice_2.22.zip'
> >Content type 'application/zip' length 1148843 bytes (1.1 Mb) opened
> URL
> >downloaded 1.1 Mb
> >
> >package ‘mice’ successfully unpacked and MD5 sums checked
> >
> >The downloaded binary packages are

Re: [R] replace values in one df by values from key pairs in another df

2015-02-13 Thread arnaud gaboury
This is the wrong part of my code.

>
>> idName=users[users$id %in% ext]
>   idname
> 1: U03AEKWTL agreenmamba
> 2: U032FHV3S   poisonivy
> 3: U03AEKYL4  vairis
>

Best is to use:

idNames <- users[pmatch(ext, users$id, duplicates.ok = T)]. This leave
me with an ordered and duplicate entries :

> idNames <- users[pmatch(ext, users$id, duplicates.ok = T)]
  idname
1: U03AEKYL4  vairis
2: U03AEKYL4  vairis
3: U03AEKWTL agreenmamba
4: U032FHV3S   poisonivy

__
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] replace values in one df by values from key pairs in another df

2015-02-13 Thread arnaud gaboury
I have been searching for a while now, but can't put all pieces of the
puzzle together.

Goal : I want to replace all these kinds of patterns <@U032FHV3S> by
this <@agreenmamba>. In a more generic way, it is replacing 'id' by
user 'name'.

I have two df:
The first, 'history', is some message history where I want to do the
replacement. It is a chat history log,
The second one, idName, is a list of id:name. All are unique. This df
rows are exctracted from a bigger one called 'users' this way :
users[users$id %in% ext].


Please find below my two data.frames:
-
history <- structure(list(name = c("xaeth", "agreenmamba", "poisonivy",
"agreenmamba", "cruzecontrol", "poisonivy", "poisonivy", "vairis",
"vairis", "poisonivy"), text = c("and people told that agent their
geocities experience would never amount to anything (the convo
yesterday) ",
"<@U032FHV3S> ", "for me there is no such
question",
"<@U03AEKWTL|agreenmamba> uploaded a file:
",
"Lol.", "ha ha sorry", "some testing with my irc client", "anybody
knows how does \"Passcode circuitry too hot. Wait for cool down to
enter another passcode.\" works?",
"what is the cooldown time or how does it work...;", "<@U03AEKYL4>:
what app are you talking about ?"
)), .Names = c("name", "text"), class = c("data.table", "data.frame"
), row.names = c(NA, -10L)
--
idName <- structure(list(id = c("U03AEKWTL", "U032FHV3S", "U03AEKYL4"),
name = c("agreenmamba", "poisonivy", "vairis")), .Names = c("id",
"name"), sorted = "name", class = c("data.table", "data.frame"
), row.names = c(NA, -3L))



1- I can find the pattern to be replaced in history this way :

ext <- regmatches(history$text,regexpr('(?<=<@)[^|]{9}(?=>|)',history$text,
perl = T)
> ext
[1] "U032FHV3S" "U03AEKWTL" "U03AEKYL4"

2- I can select the pairs id:name in my 'users' df:

> idName=users[users$id %in% ext]
  idname
1: U03AEKWTL agreenmamba
2: U032FHV3S   poisonivy
3: U03AEKYL4  vairis

3-  i can write a loop to make the changes:

> hist.txt <- history$text
> for (i in 1:3){hist.txt <- gsub(ext[i],idName[[2]][i], hist.txt, perl = T)}

But this will not work because of two things:
- 'idName' is not ordered the same way as 'ext'
- if a users speak twice it will leave with with some NA

May you have some hints how to process ?
I was thinking of maybe using sapply(myFun) to my 'history' df where
myFun would be the replacement process.
OR something like with assigning in my env each 'id' to its corresponding 'name'


Thank you for help

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


Re: [R] difference between max in summary table and max function

2015-02-13 Thread Martyn Byng
Its a formatting thing, try

summary(testrow,digits=20)

-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Franckx Laurent
Sent: 13 February 2015 11:00
To: r-help@r-project.org
Subject: [R] difference between max in summary table and max function

Dear all

I have found out that the max in the summary of an integer vector is not always 
equal to the actual maximum of that vector. For example:


> testrow <- c(1:131509)
> summary(testrow)
   Min. 1st Qu.  MedianMean 3rd Qu.Max.
  1   32880   65760   65760   98630  131500
> max(testrow)
[1] 131509

This has occurred both in a Windows and in a Linux environment.

Does this mean that the max value in the summary is only an approximation?

Best regards

Laurent Franckx, PhD
Senior researcher sustainable mobility
VITO NV | Boeretang 200 | 2400 Mol
Tel. ++ 32 14 33 58 22| mob. +32 479 25 59 07 | Skype: laurent.franckx | 
laurent.fran...@vito.be | Twitter @LaurentFranckx




VITO Disclaimer: http://www.vito.be/e-maildisclaimer

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


This e-mail has been scanned for all viruses by Star.\ _...{{dropped:3}}

__
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] difference between max in summary table and max function

2015-02-13 Thread Franckx Laurent
Dear all

I have found out that the max in the summary of an integer vector is not always 
equal to the actual maximum of that vector. For example:


> testrow <- c(1:131509)
> summary(testrow)
   Min. 1st Qu.  MedianMean 3rd Qu.Max.
  1   32880   65760   65760   98630  131500
> max(testrow)
[1] 131509

This has occurred both in a Windows and in a Linux environment.

Does this mean that the max value in the summary is only an approximation?

Best regards

Laurent Franckx, PhD
Senior researcher sustainable mobility
VITO NV | Boeretang 200 | 2400 Mol
Tel. ++ 32 14 33 58 22| mob. +32 479 25 59 07 | Skype: laurent.franckx | 
laurent.fran...@vito.be | Twitter @LaurentFranckx




VITO Disclaimer: http://www.vito.be/e-maildisclaimer

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


[R] [BUG] or [undocumented] boxplot - horizontal swaps ylim and xlim

2015-02-13 Thread Rainer M Krug
When using the function boxplot() together with the argument

,
| horizontal = TRUE
`

xlim and ylim become swapped, i.e. ylim refers to the x-axis instead of
the y-axis:

--8<---cut here---start->8---
x <- runif(1000)
boxplot(x)
boxplot(
   x,
   ylim = c(0.2, 0.8)
   )
boxplot(
   x,
   ylim = c(0.2, 0.8),
   horizontal=TRUE
   )
--8<---cut here---end--->8---

This is either a bug or undocumented.

Cheers,

Rainer

-- 
Rainer M. Krug
email: Rainerkrugsde
PGP: 0x0F52F982


signature.asc
Description: PGP signature
__
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 with Flexmix- multivariate time series data

2015-02-13 Thread atesh koul
Hi all,

I am trying to use R package flexmix for data clustering which I find
extremely useful. I would like to know how many clusters could be there in
the data and the assignment of trials to these clusters.

The data are hand kinematics data- 16 variables at 10 discrete time points
for 17 subjects. I am trying to use the FLXMCmvnorm driver for as the data
features are correlated multinomial features (formula - data~time|subject).

However, using the driver, I found out that only the left hand side in the
formula is used. This would remove the time dependence that I am trying to
model. Currently, I am stuck at this point. I would really appreciate if
any one could provide me any help on how in the formula I can include the
time dependence as well.

I would really appreciate help regarding this and would go a long way in
solving my problem. Please let me know if more information about the data
is needed.

Thanks,

Best regards,
Atesh

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