Re: [R] vegan CCA I am Completely new to ordination analyses

2011-03-13 Thread Jari Oksanen
kitty  gmail.com> writes:

> 
> Dear list,
> 
> I am trying to predict species volume from bioclimatic data, I have various
> sites and I have a data frame with species volume and
> the corresponding bioclimatic data for each site.
> 
> I read on a discussion forum that you can use ordination to predict species
> abundance (in my case volume) from 'new' climate data for sites where you do
> not know the abundance.
> 
> Unfortunately I cannot work out how to do this in the r package vegan, in
> fact I cannot even get a simple CCA to work; I have attached a sample of my
> data (volume and bioclimate data for around 100 of my sites) and the code I
> used is below.
> 
> Does the output look right? why am I getting a 0 output? Is
> there something wrong with my data, data format, r code etc?
> 
Ordination, including cca(), is multivariate analysis. If you only have one 
dependent variate, you should use univariate methods (regression etc.). 
Some multivariate methods fall back to univariate methods if you only 
have one dependent variable, but cca() does not do so in a meaningful way. 
In fact cca() does do this, but not meaningfully: your residual variation is 
zero and rank is zero. Switch to regression.

Cheers, Jari Oksanen

__
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 source a part of the file

2011-03-13 Thread Gabor Grothendieck
On Mon, Mar 14, 2011 at 12:07 AM, Paul Y. Peng  wrote:
> Yes, I do have Rtools installed on two Windows PCs I tested, and I used them
> to build R packages. I use sed all the time with no problems. Thanks for
> confirming me that it works on your Windows PC. I will test it again and
> will update you if I find out what's wrong in my pc.

Presumably you don't have it on your path at the point that you are using R.

There are some batch files at http://batchfiles.googlecode.com that
not only call R but also temporarily add Rtools to the path if they
find Rtools on your system.

-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at 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] recursive do.call

2011-03-13 Thread Jeroen Ooms
I would like to define a recursive equivalent to call or do.call, which takes
a vector of multiple function names and 'chains' them, by greedy matching of
arguments down the chain. For example, I would like to be able to do:

rec.do.call(c("glm","coef","print), list(formula=dist~speed, digits=3,
data=cars));

which would then be equivalent to:

print(coef(glm(formula=dist~speed, data=cars)), digits=3);

I've been playing around with a recursive function with ellipses, but I
can't wrap my head around it.

--
View this message in context: 
http://r.789695.n4.nabble.com/recursive-do-call-tp3353074p3353074.html
Sent from the R help mailing list archive at Nabble.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.


Re: [R] How to source a part of the file

2011-03-13 Thread Paul Y. Peng
Yes, I do have Rtools installed on two Windows PCs I tested, and I used them
to build R packages. I use sed all the time with no problems. Thanks for
confirming me that it works on your Windows PC. I will test it again and
will update you if I find out what's wrong in my pc.

On Sun, Mar 13, 2011 at 11:56 PM, Gabor Grothendieck <
ggrothendi...@gmail.com> wrote:

> On Sun, Mar 13, 2011 at 11:32 PM, Paul Y. Peng  wrote:
> > Many thanks to Jim Holtman and Gabor Grothendieck for your quick
> responses.
> > Jim's solution works beautifully for my tasks. Thanks. I also tried
> Gabor's
> > solution based on pipe(). Unfortunately it only works on a linux PC, not
> on
> > Windows 7/Vista. Submitting the command in Windows results in nothing. I
> > suspect that it is because pipe() function behaviors differently in the
> two
> > systems.
> >
> >
>
> You did specifically write in your post that you could use sed which
> suggests that you had it on your system.
>
> If that is not, in fact, the case you could get it from Duncan
> Murdoch's Rtools distribution:
> http://www.murdoch-sutherland.com/Rtools/
> which you would need in any case if you intend to develop R packages on
> Windows.
>
> I did run a test on my own Windows Vista system prior to posting so it
> certainly does work on Windows under the assumptions of the post.
>
> --
> Statistics & Software Consulting
> GKX Group, GKX Associates Inc.
> tel: 1-877-GKX-GROUP
> email: ggrothendieck at gmail.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.


Re: [R] Plotting symbols and colors based upon data values

2011-03-13 Thread Mark Linderman
David, thank you for your quick reply.  I spent a few minutes getting your
command to work with some sparse synthetic data, and then spent several
hours trying to figure out why my data didn't work (at least for symbols,
colors look okay).  I have massaged my data to where it is practically
indistinguishable from the synthetic data - yet it still doesn't work.
Attached are the two data files that can be plotted as follows:

broken = read.table("broken.table",header=TRUE)
works = read.table("works.table",header=TRUE)
xyplot(Y ~ X | A, data=works, pch=works$C , col=works$B)
xyplot(Y ~ X | A, data=broken, pch=broken$C , col=broken$B)

Only difference I see is that my data is largely sorted by $C whereas the
working data frame is not.   Not sure why that would make a difference.

Thanks again for your help!
Mark


> head(broken)
  X Y A B C
1 0.3476158 0.5334874 Cat A   red 1
2 0.5692598 0.3205288 Cat A   red 1
3 0.5879649 0.3593725 Cat A black 1
4 0.9642691 0.9242240 Cat A black 1
5 0.5303471 0.7964391 Cat A   red 1
6 0.9998770 0.1722618 Cat A black 1

> head(works)
   X  Y A  B C
1 0.55722499 31 cat D yellow 2
2 0.75100600 32 cat Bred 5
3 0.21665005 33 cat C  green 4
4 0.01201102 34 cat Bred 3
5 0.78503588 35 cat B  black 2
6 0.53589896 36 cat D   blue 5
-Original Message-
From: David Winsemius [mailto:dwinsem...@comcast.net] 
Sent: Saturday, March 12, 2011 10:39 PM
To: Mark Linderman
Cc: r-help@r-project.org
Subject: Re: [R] Plotting symbols and colors based upon data values


On Mar 12, 2011, at 7:57 PM, Mark Linderman wrote:

> I am new to R and am sure this is simple, but  I been unable to find a 
> solution.
>
> I have 5 columns of data labeled "X", "Y", "A","B","C".  I can easily 
> xyplot(Y ~ X | A) but I want the colors of the symbols to be based 
> upon the
> values of B and the shape of the symbols to be determined by C.   
> There are
> approximately four distinct values of B and C (say "b1","b2","b3","b4" 
> and "c1","c2","c3","c4", respectively)
>
No data to check it against (despite the request for such that accompanies
every posting) but see if this give the desired result:

xyplot(Y ~ X | A, data=dfrm2, pch=dfrm2$C , col=dfrm2$B)


> Either a solution or a pointer to a specific reference/example is 
> greatly appreciated.

There are many in the contributed documentation as well as in Sarkar's book
website and in the graphics galleries. As you suggested, it's pretty basic
stuff since you are benefiting from Sarkar's effort to carry over some of
the argument names from basic graphics. The one "trick" is to not rely on
the argument being assumed to come from the environment of the `data`
argument.

-- 

David Winsemius, MD
West Hartford, CT
__
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] Serial Date

2011-03-13 Thread Raoni Rosa Rodrigues
Hello R Help,

I'm working in a project with a software that register date and time data in 
serial time format. This format is used by excel, for exemple. In this format, 
40597.3911423958 is 2011/2/23 09:23:15. First part is number os days since 
1900/1/1, and second part is a fraction of a day.

I need to make this transformation in R, and use it to make some algebrian 
operations. I found that function 'serialNumber' of package 'cxxPack' transform 
a as.data class object in this format, but without time fraction. But I can't 
find nothing to do the inverse way, transform serial date format in a POSIX 
class, for exemple.

Since now, thanks for your time and atention.

All best,

Raoni
Associate Researcher
Fish Passage Center
UFMG, Brazil.


"Fica proibido o uso da palavra liberdade,

a qual será suprimida dos dicionários

e do pântano enganoso das bocas.

A partir deste instante

a liberdade será algo vivo e transparente

como um fogo ou um rio,

e a sua morada será sempre

o coração do homem."

(Thiago de Mello)


  
[[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] svg malformed on CentOS (epel R)

2011-03-13 Thread Jeroen Ooms
There is an issue with the default svg device on a centos workstation that I
am using. It does not result in an error, but it produces malformed svg
images. Exactly the same script works just fine on an ubuntu box. On Ubuntu
I am using R binary that comes with maverick, on centos I am using the
latest R binary from EPEL. Other than that both boxes are pretty clean, with
only the dependencies installed that are automatically installed when
installing R.

For example a testscript like this
svg("plot.svg");
plot(cars);
dev.off();

should produce this: http://www.stat.ucla.edu/~jeroen/files/plot_good.svg
(ubuntu), but on centos it produces this:
http://www.stat.ucla.edu/~jeroen/files/plot_bad.svg. 

It looks very much as if there is something wrong with the fronts; maybe I
am missing some library. However, as this is a production server, I don't
want to go install random packages to see if this fixes the problem.

Some questions:

- How could I fix it?
- Why is R not throwing an error instead of producing a malformed plot?
- Maybe we could notify the R binary maintainers from fedora to add a formal
dependency so that it works 'out of the box'?

Jeroen

--
View this message in context: 
http://r.789695.n4.nabble.com/svg-malformed-on-CentOS-epel-R-tp3352949p3352949.html
Sent from the R help mailing list archive at Nabble.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] nlysystemfit and loglikelihood values

2011-03-13 Thread Alex Olssen
Dear R-help,

The documentation for systemfit shows that logLik() can be used to
obtain loglikelihood values from linear systems estimated by
systemfit().
It seems to me that logLik() cannot be used for nlsystemfit().  Does
anyone know of any other packages that might let me obtain the
loglikelihood of a model estimated with nlsystemfit()?

Kind regards,

Alex Olssen

__
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] using initialize or using a constructor function

2011-03-13 Thread Laura Smith
Hi

I'm trying to learn about S4 methods, classes, etc.

Is it better to use initialize or use a construction function, please?

Thank you.

Laura Smith

[[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] How to source a part of the file

2011-03-13 Thread Gabor Grothendieck
On Sun, Mar 13, 2011 at 11:32 PM, Paul Y. Peng  wrote:
> Many thanks to Jim Holtman and Gabor Grothendieck for your quick responses.
> Jim's solution works beautifully for my tasks. Thanks. I also tried Gabor's
> solution based on pipe(). Unfortunately it only works on a linux PC, not on
> Windows 7/Vista. Submitting the command in Windows results in nothing. I
> suspect that it is because pipe() function behaviors differently in the two
> systems.
>
>

You did specifically write in your post that you could use sed which
suggests that you had it on your system.

If that is not, in fact, the case you could get it from Duncan
Murdoch's Rtools distribution:
http://www.murdoch-sutherland.com/Rtools/
which you would need in any case if you intend to develop R packages on Windows.

I did run a test on my own Windows Vista system prior to posting so it
certainly does work on Windows under the assumptions of the post.

-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at 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.


Re: [R] use "caret" to rank predictors by random forest model

2011-03-13 Thread Xiaoqi Cui
Thanks for your prompt reply!

You're right, I didn't add the parameter "importance=TRUE" when I used function 
"train" to fit the random forest model. Once I used the above parameter, 
everything went well. Also the functions "varImp" and "plot" work well too.  

I noticed "caret" is really good at selecting important predictors. Here I just 
have another question about using the package "caret" to select the best subset 
of predictors. As I know, the function "rfe" can be used to select the optimal 
set of important predictors given a series of sizes of the subsets. I'm 
wondering if "caret" can automatically give the best size of the selected 
subset without user providing the candidate sizes. Thanks,

Best,

Xiaoqi
- Original Message -
From: "Max Kuhn" 
To: "Xiaoqi Cui" 
Cc: r-help@r-project.org
Sent: Monday, March 7, 2011 2:33:06 PM GMT -06:00 US/Canada Central
Subject: Re: [R] use "caret" to rank predictors by random forest model

It would help if you provided the code that you used for the caret functions.

The most likely issues is not using importance = TRUE in the call to train()

I believe that I've only implemented code for plotting the varImp
objects resulting from train() (eg. there is plot.varImp.train but not
plot.varImp).

Max

On Mon, Mar 7, 2011 at 3:27 PM, Xiaoqi Cui  wrote:
> Hi,
>
> I'm using package "caret" to rank predictors using random forest model and 
> draw predictors importance plot. I used below commands:
>
> rf.fit<-randomForest(x,y,ntree=500,importance=TRUE)
> ## "x" is matrix whose columns are predictors, "y" is a binary resonse vector
> ## Then I got the ranked predictors by ranking 
> "rf1$importance[,"MeanDecreaseAccuracy"]"
> ## Then draw the importance plot
> varImpPlot(rf.fit)
>
> As you can see, all the functions I used are directly from the package 
> "randomForest", instead of from "caret". so I'm wondering if the package 
> "caret" has some functions who can do the above ranking and ploting.
>
> In fact, I tried functions "train", "varImp" and "plot" from package "caret", 
> the random forest model that built by "train" can not be input correctly to 
> "varImp", which gave error message like "subscripts out of bounds". Also 
> function "plot" doesn't work neither.
>
> So I'm wondering if anybody has encountered the same problem before, and 
> could shed some light on this. I would really appreciate your help.
>
> Thanks,
> Xiaoqi
>
> __
> 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.
>



-- 

Max

__
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 source a part of the file

2011-03-13 Thread Paul Y. Peng
Many thanks to Jim Holtman and Gabor Grothendieck for your quick responses.
Jim's solution works beautifully for my tasks. Thanks. I also tried Gabor's
solution based on pipe(). Unfortunately it only works on a linux PC, not on
Windows 7/Vista. Submitting the command in Windows results in nothing. I
suspect that it is because pipe() function behaviors differently in the two
systems.


On Fri, Mar 11, 2011 at 4:56 PM, jim holtman  wrote:

> I meant to say, but my fingers got ahead of my brain:
>
> source(textConnection(readLines(yourFile)[10:20]))
>
> On Fri, Mar 11, 2011 at 4:53 PM, jim holtman  wrote:
> > You can do:
> >
> > source(readLines(yourFile)[10:20])   # lines 10-20 of the file
> >
> > On Fri, Mar 11, 2011 at 4:41 PM, Paul Y. Peng  wrote:
> >> I have a text file of R commands. Some times I only want to run a few
> lines
> >> of the R commands in an existing R session and wonder whether there is a
> >> simple way to do this.
> >>
> >> To run a few lines in a new session of R, I could use sed to pick up the
> >> lines from the file and pipe them into R.
> >>
> >> source() does not allow me to specify which lines to be
> included/excluded.
> >> Is there any function that is similar to source() but allows me to
> specify
> >> lines included/excluded?
> >>
> >> Paul.
> >>
> >>[[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.
> >>
> >
> >
> >
> > --
> > Jim Holtman
> > Data Munger Guru
> >
> > What is the problem that you are trying to solve?
> >
>
>
>
> --
> Jim Holtman
> Data Munger Guru
>
> What is the problem that you are trying to solve?
>

[[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] pairwise p-values in KM plots?

2011-03-13 Thread David Winsemius


On Mar 13, 2011, at 8:33 PM, Angel Russo wrote:

How can I compute pairwise p-values in Kaplan-meier plots for three  
or more

groups?

bin.1<-cut(score,c(-1000,-1,1,1000),c("low","intermediate","high"))

I use "km.coxph.plot" currently which reports one p-value.


help(summary.glht, package=multcomp)

--

David Winsemius, MD
West Hartford, CT

__
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] Non-constancy of variances in mixed model.

2011-03-13 Thread Ben Ward
Hi, I've been doing an experiment, measuring the dead-zone-diameters of 
bacteria, when they've been grown with paper diffusion disks of 
antimicrobial. There are two groups, or treatments - one is bacteria 
that have been cultured in said antimicrobial for the past year, the 
other group is of the same species, but lab stock and has not gone had 
any prior contact with the antimicrobial. Because I take four readings 
from each disk, and there are three disks in a petri dish, and three 
petri dishes for each lineage (or replicate), and there are 5 lineages 
for each group/treatment, I want to use lme() so I can add lineage, 
dish, and disk as random effects, and have group as the fixed effect, so 
I'm analysing differences between two groups, a bit like a t.test or 
anova, but without riddiculous degrees of freedom. I've done qqPlots() 
and normality tests on my data, according to shapiro.test() on both my 
subsets (I split the data into the two groups):


> shapiro.test(DiamEVDettol)

Shapiro-Wilk normality test

data:  DiamEVDettol
W = 0.9823, p-value = 0.0221


> shapiro.test(DiamNEDettol)

Shapiro-Wilk normality test

data:  DiamNEDettol
W = 0.9788, p-value = 0.007677

> qqPlot(DiamEVDettol, dist="norm")
> qqPlot(DiamNEDettol, dist="norm")

Which from the R-Book shows non-normality. qqPlot() I did show a slight 
S shape, and then slightly more profound s-shape respectively 
suggesting, lepikurtosis. Skewness and Kurtosis are:


> skewness(DiamEVDettol)
[1] -0.1917142

> kurtosis(DiamEVDettol)
[1] -0.7594319

> skewness(DiamNEDettol)
[1] 0.1314403

> kurtosis(DiamNEDettol)
[1] -0.8365288

(I'm not sure how to get p-values to see if they're significant or not) .

But I'm unsure on how to proceed, I had done:

allrandom <- lme(Diameter~1,random=~1|Group/Lineage/Dish/Disk,data=Dataset)
So as I could do a Variance components analysis:

> VarCorr(allrandom)
Variance StdDev
Group = pdLogChol(1)
(Intercept) 1.87737501.3701734
Lineage =   pdLogChol(1)
(Intercept) 0.26484750.5146333
Dish =  pdLogChol(1)
(Intercept) 0.06010470.2451626
Disk =  pdLogChol(1)
(Intercept) 0.14564510.3816348
Residual1.34563461.1600149

> vars<-c(1.8773750,0.2648475,0.0601047,1.3456346)

> 100*vars/sum(vars)
[1] 52.914183  7.464779  1.694063 37.926975

Before moving on to:

groupfixed <-lme(Diameter~Group,random=~1|Lineage/Dish/Disk,data=Dataset)

Because Group is what I'm interested in, and is the only one with 
informative factor levels, other than maybe Lineage. I was going to gon 
on and construct similar models with different interactions or terms, 
but this issue of skewness and non normality stopped me, at first 
boxplots show what, in my only 3 years undergraduate experience looked 
like normal data - indeed neater data than I'm used to in biological 
science experiments. However this furthur probing o skewness and 
kurtosis and qqplots and shapiro.tests reveals otherwise. The variance 
is also not the same between the two groups (this was anticipated, 
because of natural selection of the bacteria in one of the groups, that 
variance could be less).


I'm concerned as to what I should do about the data I have, in terms of 
transformations, or whether there's a way for mixed models to take into 
account different distributions of data like a glm so my data does not 
have to be strictly normal or have equal variance.


Another concern of mine is whether I should be using lme as above, or as 
a book I read states, re-coding factor levels, and using lmer, for example:


Treatment<-factor(Treatment)
Liver<-factor(Liver)
Rat<-factor(Rat)
rat<-Treatment:Rat
liver<-Treatment:Rat:Liver
model<-lmer(Glycogen~Treatment+(1|rat)+(1|liver)

so with me it might be:

Group<-factor(Group)
Lineage<-factor(Lineage)
Dish<-factor(Dish)
Disk<-factor(Disk)
lineage<-Group:Lineage
dish<-Group:Lineage:Dish
disk<-Group:Lineage:Dish:Disk
model<-lmer(Diameter~Group+(1|lineage)+(1|dish)+(1|disk)

I'm not clear on what the difference would be here.


Thanks,

Ben W.

__
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] troubles with logistic regression

2011-03-13 Thread Bill.Venables
It means you have selected a response variable from one data frame 
(unmarried.male) and a predictor from another data frame (fieder.male) and they 
have different lengths.  

You might be better off if you used the names in the data frame rather than 
selecting columns in a form such as 'some.data.frame[, 3]',  This just confuses 
the issue and makes it very easy to make mistakes - as indeed you have done.

Also, to fit models on subsets of the data, you do not have to create separate 
data frames.  See the 'subset' argument of glm, which is standard for most 
fitting functions.  This is also a way to avoid problems and would have helped 
you here as well.

Bill Venables.
 

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of gked
Sent: Monday, 14 March 2011 4:33 AM
To: r-help@r-project.org
Subject: [R] troubles with logistic regression

hello everyone,
I working on the dataset for my project in class and got stuck on trying to
run logistic regression. here is my code:
data <- read.csv(file="C:/Users/fieder.data.2000.csv")

# creating subset of men 
fieder.male<-subset(data,data[,8]==1)
unmarried.male<-subset(data,data[,8]==1&data[,6]==1)

# glm fit
agesq.male<-(unmarried.male[,5])^2
male.sqrtincome<-sqrt(unmarried.male[,9])

fieder.male.mar.glm<-glm(as.factor(unmarried.male[,6])~
 factor(fieder.male[,7])+fieder.male[,5]+agesq.male+
  male.sqrtincome,binomial(link="logit") )
par(mfrow=c(1,1))
plot(c(0,300),c(0,1),pch=" ",
   xlab="sqrt income, truncated at 9",
   ylab="modeled probability of being never-married")
junk<- lowess(male.sqrtincome,
  log(fieder.male.mar.glm$fitted.values/
  (1-fieder.male.mar.glm$fitted.values)))
  lines(junk$x,exp(junk$y)/(1+exp(junk$y)))
title(main="probability of never marrying\n males, by sqrt(income)")
points(male.sqrtincome[unmarried.male==0],
  fieder.male.mar.glm$fitted.values[unmarried.male==0],pch=16)
points(male.sqrtincome[unmarried.male==1],
  fieder.male.mar.glm$fitted.values[unmarried.male==1],pch=1)

The error says: 
Error in model.frame.default(formula = as.factor(unmarried.male[, 6]) ~  : 
  variable lengths differ (found for 'factor(fieder.male[, 7])')
 
What does it mean? Where am i making a mistake?
Thank you
P.S. i  am also attaching data file in .csv format
http://r.789695.n4.nabble.com/file/n3352356/fieder.data.2000.csv
fieder.data.2000.csv 

--
View this message in context: 
http://r.789695.n4.nabble.com/troubles-with-logistic-regression-tp3352356p3352356.html
Sent from the R help mailing list archive at Nabble.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-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] Plotting symbols and colors based upon data values

2011-03-13 Thread David Winsemius


On Mar 13, 2011, at 8:51 PM, Mark Linderman wrote:

David, thank you for your quick reply.  I spent a few minutes  
getting your
command to work with some sparse synthetic data, and then spent  
several
hours trying to figure out why my data didn't work (at least for  
symbols,

colors look okay).  I have massaged my data to where it is practically
indistinguishable from the synthetic data - yet it still doesn't work.
Attached are the two data files that can be plotted as follows:

broken = read.table("broken.table",header=TRUE)
works = read.table("works.table",header=TRUE)
xyplot(Y ~ X | A, data=works, pch=works$C , col=works$B)
xyplot(Y ~ X | A, data=broken, pch=broken$C , col=broken$B)


I get the same problem and after experimenting for a while I think I  
can solve it by randomizing the order of the entries:


> broken <- broken[sample(417), ]

> xyplot(Y ~ X | A, data=broken, pch=broken$C, col=broken$B)

Why xyplot should fail to properly assign pch values just because all  
"1"'s are at the beginning seems to me to be a bug.


--
David.

After confirming the the problem recurs when re-order()-ed by broken 
$C, I am appending dput( ordered-broken) for others to experiment


> dput(broken[order(broken$C), ])
structure(list(rown = c(91L, 193L, 128L, 8L, 143L, 46L, 60L,
99L, 112L, 67L, 25L, 15L, 188L, 93L, 115L, 4L, 190L, 64L, 147L,
119L, 82L, 120L, 23L, 139L, 28L, 42L, 180L, 24L, 145L, 71L, 13L,
95L, 94L, 104L, 149L, 74L, 32L, 184L, 11L, 114L, 90L, 70L, 63L,
141L, 192L, 126L, 153L, 172L, 26L, 151L, 109L, 133L, 79L, 35L,
61L, 43L, 52L, 29L, 30L, 80L, 154L, 7L, 121L, 122L, 106L, 182L,
16L, 2L, 175L, 34L, 102L, 174L, 117L, 178L, 100L, 68L, 48L, 31L,
53L, 168L, 59L, 165L, 123L, 69L, 55L, 62L, 163L, 39L, 108L, 96L,
97L, 113L, 87L, 164L, 169L, 33L, 118L, 45L, 148L, 129L, 22L,
116L, 101L, 157L, 191L, 89L, 75L, 156L, 137L, 183L, 98L, 150L,
124L, 144L, 127L, 155L, 57L, 36L, 14L, 161L, 187L, 138L, 111L,
146L, 20L, 107L, 140L, 110L, 125L, 41L, 105L, 159L, 103L, 132L,
44L, 166L, 56L, 171L, 195L, 40L, 135L, 5L, 58L, 37L, 54L, 83L,
17L, 142L, 77L, 162L, 170L, 160L, 78L, 38L, 194L, 21L, 167L,
27L, 81L, 185L, 47L, 66L, 73L, 3L, 134L, 158L, 51L, 173L, 50L,
18L, 12L, 6L, 189L, 72L, 85L, 65L, 92L, 179L, 86L, 49L, 130L,
177L, 152L, 176L, 9L, 10L, 76L, 88L, 131L, 181L, 19L, 186L, 136L,
1L, 84L, 366L, 235L, 196L, 224L, 206L, 288L, 204L, 274L, 199L,
239L, 271L, 295L, 266L, 305L, 284L, 340L, 268L, 296L, 293L, 262L,
300L, 212L, 336L, 208L, 358L, 242L, 221L, 237L, 369L, 292L, 201L,
338L, 233L, 217L, 227L, 225L, 270L, 267L, 345L, 205L, 219L, 278L,
337L, 230L, 380L, 291L, 229L, 367L, 339L, 241L, 228L, 263L, 349L,
348L, 371L, 202L, 207L, 351L, 282L, 222L, 200L, 213L, 285L, 375L,
302L, 231L, 223L, 386L, 352L, 363L, 353L, 357L, 359L, 350L, 283L,
362L, 218L, 198L, 374L, 301L, 286L, 364L, 368L, 220L, 298L, 280L,
214L, 273L, 303L, 382L, 354L, 238L, 373L, 234L, 356L, 216L, 289L,
370L, 381L, 343L, 361L, 306L, 281L, 203L, 341L, 355L, 346L, 272L,
264L, 360L, 334L, 210L, 197L, 342L, 299L, 378L, 236L, 333L, 294L,
347L, 275L, 385L, 365L, 209L, 297L, 240L, 265L, 379L, 304L, 269L,
372L, 384L, 344L, 287L, 332L, 376L, 261L, 377L, 383L, 215L, 232L,
277L, 276L, 211L, 290L, 335L, 226L, 279L, 399L, 307L, 395L, 400L,
411L, 388L, 319L, 403L, 320L, 309L, 318L, 407L, 402L, 308L, 326L,
251L, 260L, 246L, 408L, 331L, 312L, 387L, 414L, 253L, 315L, 413L,
416L, 327L, 393L, 322L, 390L, 317L, 389L, 249L, 325L, 329L, 398L,
397L, 323L, 396L, 255L, 415L, 245L, 391L, 412L, 259L, 417L, 311L,
392L, 409L, 328L, 254L, 248L, 310L, 258L, 405L, 324L, 250L, 406L,
316L, 394L, 257L, 404L, 243L, 252L, 410L, 313L, 256L, 330L, 321L,
244L, 401L, 247L, 314L), X = c(0.701250601327047, 0.164821685524657,
0.606994603062049, 0.863256110809743, 0.956295087235048,  
0.94587846682407,
0.838799783028662, 0.523805776145309, 0.562612239504233,  
0.0359199855010957,
0.142975208582357, 0.459868715610355, 0.579013091977686,  
0.384347806917503,
0.161508617224172, 0.96426909067668, 0.504280025139451,  
0.438289026031271,
0.373645842541009, 0.439572562696412, 0.25889431219548,  
0.0467256724368781,
0.365111395483837, 0.40517632686533, 0.847934616263956,  
0.0139284294564277,
0.228810637025163, 0.976755930809304, 0.537870434345677,  
0.831849699141458,
0.735547028947622, 0.107985522132367, 0.200033176457509,  
0.250281900400296,
0.578671747585759, 0.289995870785788, 0.440369168063626,  
0.364585015457124,
0.905479809269309, 0.446940524037927, 0.658691298449412,  
0.0173427225090563,
0.24269335786812, 0.430798843270168, 0.164247164269909,  
0.357896727975458,
0.381168011575937, 0.466935358708724, 0.598047381266952,  
0.236625553574413,
0.075431430246681, 0.729021292412654, 0.332617457257584,  
0.800470217363909,
0.658606661716476, 0.857558676274493, 0.95546124689281,  
0.319315308239311,
0.26408554892987, 0.736351884901524, 0.998718089656904,  
0.0957230781204998,
0.689594832016155, 0.422279811929911, 0.9711551531218,  
0.564745565643534,
0.493862147675827, 0.569259794196114, 0.042532019615,

Re: [R] Stepwise Discriminant... in R

2011-03-13 Thread Bill.Venables
If you want to do a stepwise selection there is a function in the klaR package 
to do it.  This is not what you are asking for, though.  You want a way of 
finding the successive error rates as additional variables are added in the 
forward selection process.  As far as I can see you have to do this yourself 
and it is a mildly interesting little exercise in R programming.  Here is one 
possible way to do it.

First you need a couple of functions:

##
errorRate <- function(object, ...) {
  if(!require(MASS)) stop("you need the MASS package installed")
  UseMethod("errorRate")
}

errorRate.lda <- function(object, data = eval.parent(object$call$data),
  type = "plug-in") {
  pred <- predict(object, data, type = type)$class
  actu <- eval(formula(object)[[2]], data)
  conf <- table(pred, actu)
  1 - sum(diag(conf))/sum(conf)
}

eRates <- function(object, data = eval.parent(object$call$data),
   type = "plug-in") {
  f <- formula(object)
  r <- data.frame(formula = deparse(f[[3]]),
  Error = errorRate(object, data,
  type = type))
  while(length(f[[3]]) > 1) {
f[[3]] <- f[[3]][[2]]
object$call$formula <- f
object <- update(object, data = data)
r <- rbind(data.frame(formula = deparse(f[[3]]),
  Error = errorRate(object, data,
  type = type)),
   r)
  }
  r
}
##

(I have made errorRate generic as it is potentially a generic sort of 
operation.)
Now look at your trivial example (extended a bit):

##
require(klaR)
QRBdfa <-
data.frame(LANDUSE = sample(c("A", "B", "C"), 270, rep = TRUE),
   Al = runif(270, 0, 125),
   Sb = runif(270, 0, 1),
   Ba = runif(270, 0, 235),
   Bi = runif(270, 0, 0.11),
   Cr = runif(270, 0, 65))

gw_obj <- greedy.wilks(LANDUSE ~ ., data = QRBdfa, niveau = 1) ## NB large 
'niveau'
##

To use the functions you need an lda fit with the same formula as for the gw 
object and the same data argument as in the original call.  (If you try to do 
this the way suggested in the help file for greedy.wilks the functions to be 
used here will not work. No dollars in formulae is always a good rule to 
follow.)

The way greedy.wilks is written makes this a bit tricky, but unless you want to 
just type it in, here is a partly automated way of doing it:

##
require(MASS)
fit <- do.call(lda, list(formula = formula(gw_obj),
 data = quote(QRBdfa)))
##

To use the functions:

> errorRate(fit)  ## for one error rate
[1] 0.5962963
> eRates(fit) ## for a sequence of error rates.
 formula Error
1 Ba 0.6148148
2Ba + Bi 0.6296296
3   Ba + Bi + Al 0.6074074
4  Ba + Bi + Al + Cr 0.5740741
5 Ba + Bi + Al + Cr + Sb 0.5962963
> 

Since this example uses very artificial random data, the output will be 
different every time you re-create the data.  Note also that the error rates 
are not necessarily monotonically decreasing.

Bill Venables.



-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Ty Smith
Sent: Monday, 14 March 2011 3:51 AM
To: r-help@r-project.org
Subject: [R] Stepwise Discriminant... in R

Hello R list,

I'm looking to do some stepwise discriminant function analysis (DFA) based
on the minimization of Wilks' lambda in R to end up with a composite
signature (of metals "Al","Sb","Bi","Cr","Ba") capable of discriminating
100% of the source factors (LANDUSE: "A","B","C").

The Wilks' lambda portion seems straightforward. I am using the following:

gw_obj <- greedy.wilks(LANDUSE ~ ., data = QRBdfa, niveau = 0.1)
gw_obj

Thus determining the stepwise order of metals.But I can't seem to figure out
how to coerce the DFA to give me an output with the % of factors which each
successive metal (variable) correctly classifies (discriminates). e.g.

StepMetal%correctly classified
1Al25
2Sb   75
3Bi89
4Cr   100

I've worked up a trivial example below. Can anyone offer any suggestions on
how I might go about doing this in R?

I am working in a MAC OS environment with a current version of R.

Many thanks in advance!

Tyler

#Example
library(scatterplot3d)
library(klaR)

Al <-runif(27, 0, 125)
QRBdfa <- as.data.frame(Al)
QRBdfa$LANDUSE <- factor(c("A","A","A","B","B","B","C","C","C"))
QRBdfa$Sb <- runif(27, 0, 1)
QRBdfa$Ba <- runif(27, 0, 235)
QRBdfa$Bi <- runif(27, 0, 0.11)
QRBdfa$Cr <- runif(27, 0, 65)


gw_obj <- greedy.wilks(LANDUSE ~ ., data = QRBdfa, niveau = 0.1)
gw_obj


fit <- lda(LANDUSE ~ Al + Sb + Bi + Cr + Ba, data = QRBdfa)

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.

Re: [R] Problems getting html files out of R CMD check

2011-03-13 Thread Duncan Murdoch

On 11-03-13 7:14 PM, Amos Folarin wrote:

Hi,

I'm trying to R CMD check a package, however I have hit a snag. There seems
to be a problem with the creation of the /html files (the only file that's
constructed here is the 00Index.html). I've tested each of the .Rd files
independently with R CMD Rdconv, they all happily create html files without
complaint.


R doesn't build .html files any more unless you ask it to explicitly, 
e.g. using R CMD Rdconv.


Duncan Murdoch




R CMD check  gives the no warnings. I'm therefore curious why this
hasn't created the html files for the package, I think I must be missing
something.

* using log directory ‘/home/me/scratch/CellProfileR.Rcheck’
* using R version 2.12.2 (2011-02-25)
* using platform: i686-pc-linux-gnu (32-bit)
* using session charset: UTF-8
* checking for file ‘CellProfileR/DESCRIPTION’ ... OK
* checking extension type ... Package
* this is package ‘CellProfileR’ version ‘1.0’
* checking package dependencies ... OK
* checking if this is a source package ... OK
* checking for executable files ... OK
* checking whether package ‘CellProfileR’ can be installed ... OK
* checking package directory ... OK
* checking for portable file names ... OK
* checking for sufficient/correct file permissions ... OK
* checking DESCRIPTION meta-information ... OK
* checking top-level files ... OK
* checking index information ... OK
* checking package subdirectories ... OK
* checking R files for non-ASCII characters ... OK
* checking R files for syntax errors ... OK
* checking whether the package can be loaded ... OK
* checking whether the package can be loaded with stated dependencies ... OK
* checking whether the package can be unloaded cleanly ... OK
* checking for unstated dependencies in R code ... OK
* checking S3 generic/method consistency ... OK
* checking replacement functions ... OK
* checking foreign function calls ... OK
* checking R code for possible problems ... OK
* checking Rd files ... NOTE
prepare_Rd: CellProfile-R-internal.Rd:10: Dropping empty section \usage
prepare_Rd: CellProfile-R-internal.Rd:12: Dropping empty section \arguments
prepare_Rd: CellProfile-R-internal.Rd:22: Dropping empty section \value
prepare_Rd: CellProfile-R-internal.Rd:25: Dropping empty section \note
prepare_Rd: CellProfile-R-internal.Rd:23: Dropping empty section \references
prepare_Rd: CellProfile-R-internal.Rd:29: Dropping empty section \seealso
prepare_Rd: CellProfile-R-internal.Rd:30: Dropping empty section \examples
prepare_Rd: CellProfile-R-package.Rd:43: Dropping empty section \seealso
prepare_Rd: CellProfile-R-package.Rd:44: Dropping empty section \examples
prepare_Rd: createUnifiedTable.Rd:59-61: Dropping empty section \note
prepare_Rd: createUnifiedTable.Rd:53-55: Dropping empty section \references
prepare_Rd: fileConnect.Rd:47-49: Dropping empty section \note
prepare_Rd: fileConnect.Rd:41-43: Dropping empty section \references
prepare_Rd: fileConnect.Rd:53-55: Dropping empty section \seealso
prepare_Rd: loadTable.Rd:29-31: Dropping empty section \details
prepare_Rd: loadTable.Rd:41-43: Dropping empty section \note
prepare_Rd: loadTable.Rd:35-37: Dropping empty section \references
prepare_Rd: mapMetadataToTable.Rd:53-55: Dropping empty section \note
prepare_Rd: mapMetadataToTable.Rd:47-49: Dropping empty section \references
prepare_Rd: mapMetadataToTable.Rd:59-61: Dropping empty section \seealso
prepare_Rd: mySqlConnect.Rd:27-29: Dropping empty section \details
prepare_Rd: mySqlConnect.Rd:39-41: Dropping empty section \note
prepare_Rd: mySqlConnect.Rd:33-35: Dropping empty section \references
prepare_Rd: mySqlConnect.Rd:43-45: Dropping empty section \seealso
prepare_Rd: mySqlConnect.Rd:46: Dropping empty section \examples
prepare_Rd: recastDatabaseTable.Rd:39-41: Dropping empty section \note
prepare_Rd: recastDatabaseTable.Rd:36-38: Dropping empty section \author
prepare_Rd: recastDatabaseTable.Rd:33-35: Dropping empty section \references
prepare_Rd: recastDatabaseTable.Rd:45-47: Dropping empty section \seealso
prepare_Rd: saveTable.Rd:20-22: Dropping empty section \details
prepare_Rd: saveTable.Rd:30-32: Dropping empty section \note
prepare_Rd: saveTable.Rd:24-26: Dropping empty section \references
prepare_Rd: saveTable.Rd:36-38: Dropping empty section \seealso
prepare_Rd: saveTable.Rd:39: Dropping empty section \examples
prepare_Rd: splitTableOnVariable.Rd:18: Dropping empty section \details
prepare_Rd: splitTableOnVariable.Rd:24-26: Dropping empty section \note
prepare_Rd: splitTableOnVariable.Rd:20-22: Dropping empty section
\references
prepare_Rd: splitTableOnVariable.Rd:30-32: Dropping empty section \seealso
prepare_Rd: sqLiteConnect.Rd:34-36: Dropping empty section \note
prepare_Rd: sqLiteConnect.Rd:28-30: Dropping empty section \references
prepare_Rd: sqLiteConnect.Rd:40-42: Dropping empty section \seealso
* checking Rd metadata ... OK
* checking Rd cross-references ... OK
* checking for missing documentation entries ... OK
* checking for code/documentation mismat

Re: [R] readMat - how to retrieve the variables

2011-03-13 Thread Eduardo M. A. M.Mendes
So sorry but the data is confidential.

Cheers

Ed


-Original Message-
From: David Winsemius [mailto:dwinsem...@comcast.net] 
Sent: Sunday, March 13, 2011 9:16 PM
To: Eduardo M. A. M.Mendes
Cc: 'Joshua Wiley'; R-help@r-project.org
Subject: Re: [R] readMat - how to retrieve the variables


On Mar 13, 2011, at 7:48 PM, Eduardo M. A. M.Mendes wrote:

> Hi there
>
> ...   means that I have not copied all the data that R showed on the  
> screen.

I fail to see the point in posting mangled dput output.

--
David.
>
> Cheers
>
> Ed
>
>
> -Original Message-
> From: David Winsemius [mailto:dwinsem...@comcast.net]
> Sent: Sunday, March 13, 2011 8:37 PM
> To: Eduardo M. A. M.Mendes
> Cc: 'Joshua Wiley'; R-help@r-project.org
> Subject: Re: [R] readMat - how to retrieve the variables
>
>
> On Mar 13, 2011, at 7:27 PM, Eduardo M. A. M.Mendes wrote:
>
>> Hello there
>>
>> Here is the output of the command
>>
>> structure(list(a =
>> structure(list(structure(list(structure(c(16.259746877453,
>> 17.7125316239611, 17.7801266531401, 18.7370886410339, 
>> 18.5622784910323, 19. 
>
> That seems pretty unlikely. All of those "" are not in the output 
> from dput are they? The dimension of 3683 implies otherwise.
>
>> 
>> ), .Dim = c(3683L, 1L)), structure(c(0, 0, 6.7, 46.1, 2, 0, 29.5, 
>> 93.7, 4.5, 39.6, 1.4, 5.5, 9, 12.2, 5.7, 0, 0, 0, 0, 8, 0, 19.5,
>> 30 
>> 
>> ), .Dim = c(3683L, 1L))), .Dim = c(2L, 1L, 1L), .Dimnames = list(
>>   c("flow", "precip"), NULL, NULL)), structure(list(structure(c(42, 
>> 42, 44, 60, 84, 97, 113, 357, 613, 495, 401, 295, 250, 228, 202,
>> 174 
>> 
>> 12, 36, 0, 2, 0, 6, 13, 0, 1, 0, 12, 0, 0, 32, 0, 0, 1, 36, 7, 36, 
>> 48, 27, 7), .Dim = c(3683L, 1L))), .Dim = c(2L, 1L, 1L), .Dimnames = 
>> list(
>>   c("flow", "precip"), NULL, NULL))), .Dim = c(2L, 1L, 1L), .Dimnames 
>> = list(
>>   c("river1", "river2"), NULL, NULL))), .Names = "a", header = 
>> structure(list(
>>   description = "MATLAB 5.0 MAT-file, Platform: PCWIN, Created on:
>> Sun Mar
>> 13 18:51:54 2011  ",
>>   version = "5", endian = "little"), .Names = c("description", 
>> "version", "endian")))
>>
>> Cheers
>>
>> Ed
>>
>>
>> -Original Message-
>> From: David Winsemius [mailto:dwinsem...@comcast.net]
>> Sent: Sunday, March 13, 2011 8:01 PM
>> To: Eduardo M. A. M.Mendes
>> Cc: 'Joshua Wiley'; R-help@r-project.org
>> Subject: Re: [R] readMat - how to retrieve the variables
>>
>>
>> On Mar 13, 2011, at 6:42 PM, Eduardo M. A. M.Mendes wrote:
>>
>>>
>>> Hi Joshua
>>>
>>> Many thanks.
>>>
>>> The values of flow can be accessed in a weird way and we can used 
>>> them for some calculations.  Since I am a newbie as far as using R 
>>> is concerned I wonder whether you could tell me how to create a 
>>> structure in R that looks like the one I have in matlab (that is, a 
>>> variable a that contains river1 and river2 that contains flow and 
>>> precipitation).
>>
>> If you posted the results of dput(a) ,  we might be able to test our 
>> pet theories, but here is my hapless first guess:
>>
>> mat.R.struc <- with(b$a[,,1],   #looks like it was a matrix that had
>> lists as elements
>> cbind(as.data.frame(river1), as.data.frame(river2) )
>>)
>>
>> It's not so much that it will "look like" your Matlab structure, but 
>> it could be something that you can work with. This will create a
>> long-
>> format structure which is a typical one for plotting ans regression.
>> Another option would be an R array which, unlike matrices, can have 
>> more than 2 dimensions.
>>
>>
>>>
>>> Cheers
>>>
>>> Ed
>>>
>>>
>>> -Original Message-
>>> From: Joshua Wiley [mailto:jwiley.ps...@gmail.com]
>>> Sent: Sunday, March 13, 2011 7:20 PM
>>> To: Eduardo M. A. M.Mendes
>>> Cc: R-help@r-project.org
>>> Subject: Re: [R] readMat - how to retrieve the variables
>>>
>>> On Sun, Mar 13, 2011 at 2:56 PM, Eduardo M. A. M.Mendes 
>>> >>> wrote:
 Hi Joshua

 Many thanks for the prompt reply.

 I have saved a short version of the matlab file and the output on R 
 is

> b=readMat("testr.mat")
> b
 $a
 , , 1

[,1]
 river1 List,2
 river2 List,2
>>>
>>> It looks like you are dealing with a special series of lists nested 
>>> within three dimensional arrays within lists.  My suggestion would 
>>> be to double check that the matlab file has reasonable data 
>>> (whatever that means) and try to double check your use of readmat 
>>> (do you meet all the requirements for versions, etc.).  That is not 
>>> a common R structure so the extraction is similarly uncommon.
>>> Perhaps Henrik will be along with more helpful answers.
>>>
>>> Good luck,
>>>
>>> Josh


 attr(,"header")
 attr(,"header")$description
 [1] "MATLAB 5.0 MAT-file, Platform: PCWIN, Created on: Sun Mar 13
 18:51:54 2011  "

 attr(,"header")$vers

[R] pairwise p-values in KM plots?

2011-03-13 Thread Angel Russo
How can I compute pairwise p-values in Kaplan-meier plots for three or more
groups?

 bin.1<-cut(score,c(-1000,-1,1,1000),c("low","intermediate","high"))

I use "km.coxph.plot" currently which reports one p-value.

Thanks very much.

[[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] readMat - how to retrieve the variables

2011-03-13 Thread David Winsemius


On Mar 13, 2011, at 7:48 PM, Eduardo M. A. M.Mendes wrote:


Hi there

...   means that I have not copied all the data that R showed on the  
screen.


I fail to see the point in posting mangled dput output.

--
David.


Cheers

Ed


-Original Message-
From: David Winsemius [mailto:dwinsem...@comcast.net]
Sent: Sunday, March 13, 2011 8:37 PM
To: Eduardo M. A. M.Mendes
Cc: 'Joshua Wiley'; R-help@r-project.org
Subject: Re: [R] readMat - how to retrieve the variables


On Mar 13, 2011, at 7:27 PM, Eduardo M. A. M.Mendes wrote:


Hello there

Here is the output of the command

structure(list(a =
structure(list(structure(list(structure(c(16.259746877453,
17.7125316239611, 17.7801266531401, 18.7370886410339,
18.5622784910323, 19. 


That seems pretty unlikely. All of those "" are not in the  
output from

dput are they? The dimension of 3683 implies otherwise.



), .Dim = c(3683L, 1L)), structure(c(0, 0, 6.7, 46.1, 2, 0, 29.5,
93.7, 4.5, 39.6, 1.4, 5.5, 9, 12.2, 5.7, 0, 0, 0, 0, 8, 0, 19.5,
30 

), .Dim = c(3683L, 1L))), .Dim = c(2L, 1L, 1L), .Dimnames = list(
  c("flow", "precip"), NULL, NULL)), structure(list(structure(c(42,
42, 44, 60, 84, 97, 113, 357, 613, 495, 401, 295, 250, 228, 202,
174 

12, 36, 0, 2, 0, 6, 13, 0, 1, 0, 12, 0, 0, 32, 0, 0, 1, 36, 7, 36,  
48,
27, 7), .Dim = c(3683L, 1L))), .Dim = c(2L, 1L, 1L), .Dimnames =  
list(

  c("flow", "precip"), NULL, NULL))), .Dim = c(2L, 1L, 1L), .Dimnames
= list(
  c("river1", "river2"), NULL, NULL))), .Names = "a", header =
structure(list(
  description = "MATLAB 5.0 MAT-file, Platform: PCWIN, Created on:
Sun Mar
13 18:51:54 2011  ",
  version = "5", endian = "little"), .Names = c("description",
"version", "endian")))

Cheers

Ed


-Original Message-
From: David Winsemius [mailto:dwinsem...@comcast.net]
Sent: Sunday, March 13, 2011 8:01 PM
To: Eduardo M. A. M.Mendes
Cc: 'Joshua Wiley'; R-help@r-project.org
Subject: Re: [R] readMat - how to retrieve the variables


On Mar 13, 2011, at 6:42 PM, Eduardo M. A. M.Mendes wrote:



Hi Joshua

Many thanks.

The values of flow can be accessed in a weird way and we can used
them for some calculations.  Since I am a newbie as far as using R  
is

concerned I wonder whether you could tell me how to create a
structure in R that looks like the one I have in matlab (that is, a
variable a that contains river1 and river2 that contains flow and
precipitation).


If you posted the results of dput(a) ,  we might be able to test our
pet theories, but here is my hapless first guess:

mat.R.struc <- with(b$a[,,1],   #looks like it was a matrix that had
lists as elements
cbind(as.data.frame(river1), as.data.frame(river2) )
   )

It's not so much that it will "look like" your Matlab structure, but
it could be something that you can work with. This will create a  
long-

format structure which is a typical one for plotting ans regression.
Another option would be an R array which, unlike matrices, can have
more than 2 dimensions.




Cheers

Ed


-Original Message-
From: Joshua Wiley [mailto:jwiley.ps...@gmail.com]
Sent: Sunday, March 13, 2011 7:20 PM
To: Eduardo M. A. M.Mendes
Cc: R-help@r-project.org
Subject: Re: [R] readMat - how to retrieve the variables

On Sun, Mar 13, 2011 at 2:56 PM, Eduardo M. A. M.Mendes

wrote:
Hi Joshua

Many thanks for the prompt reply.

I have saved a short version of the matlab file and the output on R
is


b=readMat("testr.mat")
b

$a
, , 1

   [,1]
river1 List,2
river2 List,2


It looks like you are dealing with a special series of lists nested
within three dimensional arrays within lists.  My suggestion would  
be

to double check that the matlab file has reasonable data (whatever
that means) and try to double check your use of readmat (do you meet
all the requirements for versions, etc.).  That is not a common R
structure so the extraction is similarly uncommon.
Perhaps Henrik will be along with more helpful answers.

Good luck,

Josh



attr(,"header")
attr(,"header")$description
[1] "MATLAB 5.0 MAT-file, Platform: PCWIN, Created on: Sun Mar 13
18:51:54 2011  "

attr(,"header")$version
[1] "5"

attr(,"header")$endian
[1] "little"

When I issue the command b$a[,,1]$river1[,,1]$flow  I see the flow
values.

Unfortunately the data is confidential.

Many thanks

Ed


-Original Message-
From: Joshua Wiley [mailto:jwiley.ps...@gmail.com]
Sent: Sunday, March 13, 2011 6:30 PM
To: Eduardo M. A. M.Mendes
Cc: R-help@r-project.org
Subject: Re: [R] readMat - how to retrieve the variables

Hi Ed,

Can you please provide *at least* the R output from running:

str(data)

where "data" is the variable name you stored the results of
readMat() in.  If it is reasonably small and can be sent as
plaintext (I do not know Matlabs file format off hand), you could
send us the actual data so we can try to read it in, but at the
least str() will 

Re: [R] readMat - how to retrieve the variables

2011-03-13 Thread Eduardo M. A. M.Mendes
Hi there

...   means that I have not copied all the data that R showed on the screen.

Cheers

Ed


-Original Message-
From: David Winsemius [mailto:dwinsem...@comcast.net] 
Sent: Sunday, March 13, 2011 8:37 PM
To: Eduardo M. A. M.Mendes
Cc: 'Joshua Wiley'; R-help@r-project.org
Subject: Re: [R] readMat - how to retrieve the variables


On Mar 13, 2011, at 7:27 PM, Eduardo M. A. M.Mendes wrote:

> Hello there
>
> Here is the output of the command
>
> structure(list(a =
> structure(list(structure(list(structure(c(16.259746877453,
> 17.7125316239611, 17.7801266531401, 18.7370886410339, 
> 18.5622784910323, 19. 

That seems pretty unlikely. All of those "" are not in the output from
dput are they? The dimension of 3683 implies otherwise.

> 
> ), .Dim = c(3683L, 1L)), structure(c(0, 0, 6.7, 46.1, 2, 0, 29.5, 
> 93.7, 4.5, 39.6, 1.4, 5.5, 9, 12.2, 5.7, 0, 0, 0, 0, 8, 0, 19.5,
> 30 
> 
> ), .Dim = c(3683L, 1L))), .Dim = c(2L, 1L, 1L), .Dimnames = list(
>c("flow", "precip"), NULL, NULL)), structure(list(structure(c(42, 
> 42, 44, 60, 84, 97, 113, 357, 613, 495, 401, 295, 250, 228, 202,
> 174 
> 
> 12, 36, 0, 2, 0, 6, 13, 0, 1, 0, 12, 0, 0, 32, 0, 0, 1, 36, 7, 36, 48, 
> 27, 7), .Dim = c(3683L, 1L))), .Dim = c(2L, 1L, 1L), .Dimnames = list(
>c("flow", "precip"), NULL, NULL))), .Dim = c(2L, 1L, 1L), .Dimnames 
> = list(
>c("river1", "river2"), NULL, NULL))), .Names = "a", header = 
> structure(list(
>description = "MATLAB 5.0 MAT-file, Platform: PCWIN, Created on:  
> Sun Mar
> 13 18:51:54 2011  ",
>version = "5", endian = "little"), .Names = c("description", 
> "version", "endian")))
>
> Cheers
>
> Ed
>
>
> -Original Message-
> From: David Winsemius [mailto:dwinsem...@comcast.net]
> Sent: Sunday, March 13, 2011 8:01 PM
> To: Eduardo M. A. M.Mendes
> Cc: 'Joshua Wiley'; R-help@r-project.org
> Subject: Re: [R] readMat - how to retrieve the variables
>
>
> On Mar 13, 2011, at 6:42 PM, Eduardo M. A. M.Mendes wrote:
>
>>
>> Hi Joshua
>>
>> Many thanks.
>>
>> The values of flow can be accessed in a weird way and we can used 
>> them for some calculations.  Since I am a newbie as far as using R is 
>> concerned I wonder whether you could tell me how to create a 
>> structure in R that looks like the one I have in matlab (that is, a 
>> variable a that contains river1 and river2 that contains flow and 
>> precipitation).
>
> If you posted the results of dput(a) ,  we might be able to test our 
> pet theories, but here is my hapless first guess:
>
> mat.R.struc <- with(b$a[,,1],   #looks like it was a matrix that had
> lists as elements
>  cbind(as.data.frame(river1), as.data.frame(river2) )
> )
>
> It's not so much that it will "look like" your Matlab structure, but 
> it could be something that you can work with. This will create a long- 
> format structure which is a typical one for plotting ans regression.
> Another option would be an R array which, unlike matrices, can have 
> more than 2 dimensions.
>
>
>>
>> Cheers
>>
>> Ed
>>
>>
>> -Original Message-
>> From: Joshua Wiley [mailto:jwiley.ps...@gmail.com]
>> Sent: Sunday, March 13, 2011 7:20 PM
>> To: Eduardo M. A. M.Mendes
>> Cc: R-help@r-project.org
>> Subject: Re: [R] readMat - how to retrieve the variables
>>
>> On Sun, Mar 13, 2011 at 2:56 PM, Eduardo M. A. M.Mendes 
>> >> wrote:
>>> Hi Joshua
>>>
>>> Many thanks for the prompt reply.
>>>
>>> I have saved a short version of the matlab file and the output on R 
>>> is
>>>
 b=readMat("testr.mat")
 b
>>> $a
>>> , , 1
>>>
>>> [,1]
>>> river1 List,2
>>> river2 List,2
>>
>> It looks like you are dealing with a special series of lists nested 
>> within three dimensional arrays within lists.  My suggestion would be 
>> to double check that the matlab file has reasonable data (whatever 
>> that means) and try to double check your use of readmat (do you meet 
>> all the requirements for versions, etc.).  That is not a common R 
>> structure so the extraction is similarly uncommon.
>> Perhaps Henrik will be along with more helpful answers.
>>
>> Good luck,
>>
>> Josh
>>>
>>>
>>> attr(,"header")
>>> attr(,"header")$description
>>> [1] "MATLAB 5.0 MAT-file, Platform: PCWIN, Created on: Sun Mar 13
>>> 18:51:54 2011  "
>>>
>>> attr(,"header")$version
>>> [1] "5"
>>>
>>> attr(,"header")$endian
>>> [1] "little"
>>>
>>> When I issue the command b$a[,,1]$river1[,,1]$flow  I see the flow 
>>> values.
>>>
>>> Unfortunately the data is confidential.
>>>
>>> Many thanks
>>>
>>> Ed
>>>
>>>
>>> -Original Message-
>>> From: Joshua Wiley [mailto:jwiley.ps...@gmail.com]
>>> Sent: Sunday, March 13, 2011 6:30 PM
>>> To: Eduardo M. A. M.Mendes
>>> Cc: R-help@r-project.org
>>> Subject: Re: [R] readMat - how to retrieve the variables
>>>
>>> Hi Ed,
>>>
>>> Can you please provide *at least* the R output from running:
>>>
>>> str(dat

Re: [R] readMat - how to retrieve the variables

2011-03-13 Thread David Winsemius


On Mar 13, 2011, at 7:27 PM, Eduardo M. A. M.Mendes wrote:


Hello there

Here is the output of the command

structure(list(a =
structure(list(structure(list(structure(c(16.259746877453,
17.7125316239611, 17.7801266531401, 18.7370886410339,  
18.5622784910323,

19. 


That seems pretty unlikely. All of those "" are not in the output  
from dput are they? The dimension of 3683 implies otherwise.




), .Dim = c(3683L, 1L)), structure(c(0, 0, 6.7, 46.1, 2, 0, 29.5,
93.7, 4.5, 39.6, 1.4, 5.5, 9, 12.2, 5.7, 0, 0, 0, 0, 8, 0, 19.5,
30 

), .Dim = c(3683L, 1L))), .Dim = c(2L, 1L, 1L), .Dimnames = list(
   c("flow", "precip"), NULL, NULL)), structure(list(structure(c(42,
42, 44, 60, 84, 97, 113, 357, 613, 495, 401, 295, 250, 228, 202,
174 

12, 36, 0, 2, 0, 6, 13, 0, 1, 0, 12, 0, 0, 32, 0, 0, 1, 36, 7,
36, 48, 27, 7), .Dim = c(3683L, 1L))), .Dim = c(2L, 1L,  
1L), .Dimnames =

list(
   c("flow", "precip"), NULL, NULL))), .Dim = c(2L, 1L,  
1L), .Dimnames =

list(
   c("river1", "river2"), NULL, NULL))), .Names = "a", header =
structure(list(
   description = "MATLAB 5.0 MAT-file, Platform: PCWIN, Created on:  
Sun Mar

13 18:51:54 2011  ",
   version = "5", endian = "little"), .Names = c("description",
"version", "endian")))

Cheers

Ed


-Original Message-
From: David Winsemius [mailto:dwinsem...@comcast.net]
Sent: Sunday, March 13, 2011 8:01 PM
To: Eduardo M. A. M.Mendes
Cc: 'Joshua Wiley'; R-help@r-project.org
Subject: Re: [R] readMat - how to retrieve the variables


On Mar 13, 2011, at 6:42 PM, Eduardo M. A. M.Mendes wrote:



Hi Joshua

Many thanks.

The values of flow can be accessed in a weird way and we can used  
them

for some calculations.  Since I am a newbie as far as using R is
concerned I wonder whether you could tell me how to create a  
structure

in R that looks like the one I have in matlab (that is, a variable a
that contains river1 and river2 that contains flow and  
precipitation).


If you posted the results of dput(a) ,  we might be able to test our  
pet

theories, but here is my hapless first guess:

mat.R.struc <- with(b$a[,,1],   #looks like it was a matrix that had
lists as elements
 cbind(as.data.frame(river1), as.data.frame(river2) )
)

It's not so much that it will "look like" your Matlab structure, but  
it
could be something that you can work with. This will create a long-  
format

structure which is a typical one for plotting ans regression.
Another option would be an R array which, unlike matrices, can have  
more

than 2 dimensions.




Cheers

Ed


-Original Message-
From: Joshua Wiley [mailto:jwiley.ps...@gmail.com]
Sent: Sunday, March 13, 2011 7:20 PM
To: Eduardo M. A. M.Mendes
Cc: R-help@r-project.org
Subject: Re: [R] readMat - how to retrieve the variables

On Sun, Mar 13, 2011 at 2:56 PM, Eduardo M. A. M.Mendes

wrote:
Hi Joshua

Many thanks for the prompt reply.

I have saved a short version of the matlab file and the output on R
is


b=readMat("testr.mat")
b

$a
, , 1

[,1]
river1 List,2
river2 List,2


It looks like you are dealing with a special series of lists nested
within three dimensional arrays within lists.  My suggestion would be
to double check that the matlab file has reasonable data (whatever
that means) and try to double check your use of readmat (do you meet
all the requirements for versions, etc.).  That is not
a common R structure so the extraction is similarly uncommon.
Perhaps Henrik will be along with more helpful answers.

Good luck,

Josh



attr(,"header")
attr(,"header")$description
[1] "MATLAB 5.0 MAT-file, Platform: PCWIN, Created on: Sun Mar 13
18:51:54 2011  "

attr(,"header")$version
[1] "5"

attr(,"header")$endian
[1] "little"

When I issue the command b$a[,,1]$river1[,,1]$flow  I see the flow
values.

Unfortunately the data is confidential.

Many thanks

Ed


-Original Message-
From: Joshua Wiley [mailto:jwiley.ps...@gmail.com]
Sent: Sunday, March 13, 2011 6:30 PM
To: Eduardo M. A. M.Mendes
Cc: R-help@r-project.org
Subject: Re: [R] readMat - how to retrieve the variables

Hi Ed,

Can you please provide *at least* the R output from running:

str(data)

where "data" is the variable name you stored the results of
readMat() in.  If it is reasonably small and can be sent as  
plaintext

(I do not know Matlabs file format off hand), you could send us the
actual data so we can try to read it in, but at the least str() will
let us see how R is storing your data and give you some explanation.

Side note, as data() is a function, it might be worthwhile to call
your actual data something else (say, mydata, dat, etc.).  For  
anyone

else interested, readMat() is in package "R.matlab".

Cheers,

Josh

On Sun, Mar 13, 2011 at 2:07 PM, Eduardo M. A. M.Mendes

wrote:
Hello

I have a matlab MAT file that contains one single variable: a.  The
structure of a is as follows:

a.

Re: [R] readMat - how to retrieve the variables

2011-03-13 Thread Eduardo M. A. M.Mendes
Hello there

Here is the output of the command

structure(list(a =
structure(list(structure(list(structure(c(16.259746877453, 
17.7125316239611, 17.7801266531401, 18.7370886410339, 18.5622784910323, 
19. 

), .Dim = c(3683L, 1L)), structure(c(0, 0, 6.7, 46.1, 2, 0, 29.5, 
93.7, 4.5, 39.6, 1.4, 5.5, 9, 12.2, 5.7, 0, 0, 0, 0, 8, 0, 19.5, 
30 

), .Dim = c(3683L, 1L))), .Dim = c(2L, 1L, 1L), .Dimnames = list(
c("flow", "precip"), NULL, NULL)), structure(list(structure(c(42, 
42, 44, 60, 84, 97, 113, 357, 613, 495, 401, 295, 250, 228, 202, 
174 

12, 36, 0, 2, 0, 6, 13, 0, 1, 0, 12, 0, 0, 32, 0, 0, 1, 36, 7, 
36, 48, 27, 7), .Dim = c(3683L, 1L))), .Dim = c(2L, 1L, 1L), .Dimnames =
list(
c("flow", "precip"), NULL, NULL))), .Dim = c(2L, 1L, 1L), .Dimnames =
list(
c("river1", "river2"), NULL, NULL))), .Names = "a", header =
structure(list(
description = "MATLAB 5.0 MAT-file, Platform: PCWIN, Created on: Sun Mar
13 18:51:54 2011  ", 
version = "5", endian = "little"), .Names = c("description", 
"version", "endian")))

Cheers

Ed


-Original Message-
From: David Winsemius [mailto:dwinsem...@comcast.net] 
Sent: Sunday, March 13, 2011 8:01 PM
To: Eduardo M. A. M.Mendes
Cc: 'Joshua Wiley'; R-help@r-project.org
Subject: Re: [R] readMat - how to retrieve the variables


On Mar 13, 2011, at 6:42 PM, Eduardo M. A. M.Mendes wrote:

>
> Hi Joshua
>
> Many thanks.
>
> The values of flow can be accessed in a weird way and we can used them 
> for some calculations.  Since I am a newbie as far as using R is 
> concerned I wonder whether you could tell me how to create a structure 
> in R that looks like the one I have in matlab (that is, a variable a 
> that contains river1 and river2 that contains flow and precipitation).

If you posted the results of dput(a) ,  we might be able to test our pet
theories, but here is my hapless first guess:

mat.R.struc <- with(b$a[,,1],   #looks like it was a matrix that had  
lists as elements
  cbind(as.data.frame(river1), as.data.frame(river2) )
 )

It's not so much that it will "look like" your Matlab structure, but it
could be something that you can work with. This will create a long- format
structure which is a typical one for plotting ans regression.  
Another option would be an R array which, unlike matrices, can have more
than 2 dimensions.


>
> Cheers
>
> Ed
>
>
> -Original Message-
> From: Joshua Wiley [mailto:jwiley.ps...@gmail.com]
> Sent: Sunday, March 13, 2011 7:20 PM
> To: Eduardo M. A. M.Mendes
> Cc: R-help@r-project.org
> Subject: Re: [R] readMat - how to retrieve the variables
>
> On Sun, Mar 13, 2011 at 2:56 PM, Eduardo M. A. M.Mendes 
>  > wrote:
>> Hi Joshua
>>
>> Many thanks for the prompt reply.
>>
>> I have saved a short version of the matlab file and the output on R 
>> is
>>
>>> b=readMat("testr.mat")
>>> b
>> $a
>> , , 1
>>
>>  [,1]
>> river1 List,2
>> river2 List,2
>
> It looks like you are dealing with a special series of lists nested 
> within three dimensional arrays within lists.  My suggestion would be 
> to double check that the matlab file has reasonable data (whatever 
> that means) and try to double check your use of readmat (do you meet 
> all the requirements for versions, etc.).  That is not
> a common R structure so the extraction is similarly uncommon.   
> Perhaps Henrik will be along with more helpful answers.
>
> Good luck,
>
> Josh
>>
>>
>> attr(,"header")
>> attr(,"header")$description
>> [1] "MATLAB 5.0 MAT-file, Platform: PCWIN, Created on: Sun Mar 13  
>> 18:51:54 2011  "
>>
>> attr(,"header")$version
>> [1] "5"
>>
>> attr(,"header")$endian
>> [1] "little"
>>
>> When I issue the command b$a[,,1]$river1[,,1]$flow  I see the flow 
>> values.
>>
>> Unfortunately the data is confidential.
>>
>> Many thanks
>>
>> Ed
>>
>>
>> -Original Message-
>> From: Joshua Wiley [mailto:jwiley.ps...@gmail.com]
>> Sent: Sunday, March 13, 2011 6:30 PM
>> To: Eduardo M. A. M.Mendes
>> Cc: R-help@r-project.org
>> Subject: Re: [R] readMat - how to retrieve the variables
>>
>> Hi Ed,
>>
>> Can you please provide *at least* the R output from running:
>>
>> str(data)
>>
>> where "data" is the variable name you stored the results of
>> readMat() in.  If it is reasonably small and can be sent as plaintext 
>> (I do not know Matlabs file format off hand), you could send us the 
>> actual data so we can try to read it in, but at the least str() will 
>> let us see how R is storing your data and give you some explanation.
>>
>> Side note, as data() is a function, it might be worthwhile to call 
>> your actual data something else (say, mydata, dat, etc.).  For anyone 
>> else interested, readMat() is in package "R.matlab".
>>
>> Cheers,
>>
>> Josh
>>
>> On Sun, Mar 13, 2011 at 2:07 PM, Eduardo M. A. M.Mendes 
>> > > wrote:
>>> Hello
>>>
>>> I have a matlab MAT file that contains one

Re: [R] readMat - how to retrieve the variables

2011-03-13 Thread Eduardo M. A. M.Mendes
Hi Joshua

Many many thanks.

Cheers

Ed


-Original Message-
From: Joshua Wiley [mailto:jwiley.ps...@gmail.com] 
Sent: Sunday, March 13, 2011 8:00 PM
To: Eduardo M. A. M.Mendes
Cc: R-help@r-project.org
Subject: Re: [R] readMat - how to retrieve the variables

Hi Ed,

Here are some different ways of structuring and storing data in R as well as 
how to access them.

Hope this helps,

Josh

#

set.seed(10)
## Option 1a (closest to what you want?) a1a <- list(river1 = data.frame(flow = 
1:10, precipitation = runif(10)),
  river2 = data.frame(flow = 11:20, precipitation = runif(10)))

set.seed(10)
## Option 1b (a slight variant), lists + named vectors a1b <- list(river1 = 
list(flow = 1:10, precipitation = runif(10)),
  river2 = list(flow = 11:20, precipitation = runif(10)))

set.seed(10)
## Option 2 (a.k.a. 'long' format)
a2 <- data.frame(flow = 1:20, precipitation = runif(20),
  river = factor(rep(1:2, each = 10)))

set.seed(10)
## Option 3 (a.k.a. 'wide' format)
a3 <- data.frame(r1.flow = 1:10, r2.flow = 11:20,
  r1.precipitation = runif(10), r2.precipitation = runif(10))

## compare the str()uctures of all four objects

str(a1a)
str(a1b)
str(a2)
str(a3)

## Access "flow" from "river1" in option 1a ## four equivalent options 
a1a$river1$flow a1a[["river1"]][,"flow"] a1a[[1]][, 1] a1a[[c(1, 1)]]

## Option 1b
a1b$river1$flow ## works
a1b[[1]][, 1] ## does not work, used vectors not a dataframe a1b[[c(1, 1)]] ## 
works

## Option 2
a2$flow ## both rivers' flow, useful for plotting a2[, 1] a2[, "flow"] ## for 
example:
require(lattice)
xyplot(flow ~ precipitation | river, data = a2)

## Option 3
a3$r1.flow
a3[, 1]
a3[, "r1.flow"]

##

On Sun, Mar 13, 2011 at 3:42 PM, Eduardo M. A. M.Mendes  
wrote:
>
> Hi Joshua
>
> Many thanks.
>
> The values of flow can be accessed in a weird way and we can used them for 
> some calculations.  Since I am a newbie as far as using R is concerned I 
> wonder whether you could tell me how to create a structure in R that looks 
> like the one I have in matlab (that is, a variable a that contains river1 and 
> river2 that contains flow and precipitation).
>
> Cheers
>
> Ed
>
>
> -Original Message-
> From: Joshua Wiley [mailto:jwiley.ps...@gmail.com]
> Sent: Sunday, March 13, 2011 7:20 PM
> To: Eduardo M. A. M.Mendes
> Cc: R-help@r-project.org
> Subject: Re: [R] readMat - how to retrieve the variables
>
> On Sun, Mar 13, 2011 at 2:56 PM, Eduardo M. A. M.Mendes 
>  wrote:
>> Hi Joshua
>>
>> Many thanks for the prompt reply.
>>
>> I have saved a short version of the matlab file and the output on R 
>> is
>>
>>> b=readMat("testr.mat")
>>> b
>> $a
>> , , 1
>>
>>   [,1]
>> river1 List,2
>> river2 List,2
>
> It looks like you are dealing with a special series of lists nested within 
> three dimensional arrays within lists.  My suggestion would be to double 
> check that the matlab file has reasonable data (whatever that means) and try 
> to double check your use of readmat (do you meet all the requirements for 
> versions, etc.).  That is not a common R structure so the extraction is 
> similarly uncommon.  Perhaps Henrik will be along with more helpful answers.
>
> Good luck,
>
> Josh
>>
>>
>> attr(,"header")
>> attr(,"header")$description
>> [1] "MATLAB 5.0 MAT-file, Platform: PCWIN, Created on: Sun Mar 13 18:51:54 
>> 2011  "
>>
>> attr(,"header")$version
>> [1] "5"
>>
>> attr(,"header")$endian
>> [1] "little"
>>
>> When I issue the command b$a[,,1]$river1[,,1]$flow  I see the flow values.
>>
>> Unfortunately the data is confidential.
>>
>> Many thanks
>>
>> Ed
>>
>>
>> -Original Message-
>> From: Joshua Wiley [mailto:jwiley.ps...@gmail.com]
>> Sent: Sunday, March 13, 2011 6:30 PM
>> To: Eduardo M. A. M.Mendes
>> Cc: R-help@r-project.org
>> Subject: Re: [R] readMat - how to retrieve the variables
>>
>> Hi Ed,
>>
>> Can you please provide *at least* the R output from running:
>>
>> str(data)
>>
>> where "data" is the variable name you stored the results of readMat() in.  
>> If it is reasonably small and can be sent as plaintext (I do not know 
>> Matlabs file format off hand), you could send us the actual data so we can 
>> try to read it in, but at the least str() will let us see how R is storing 
>> your data and give you some explanation.
>>
>> Side note, as data() is a function, it might be worthwhile to call your 
>> actual data something else (say, mydata, dat, etc.).  For anyone else 
>> interested, readMat() is in package "R.matlab".
>>
>> Cheers,
>>
>> Josh
>>
>> On Sun, Mar 13, 2011 at 2:07 PM, Eduardo M. A. M.Mendes 
>>  wrote:
>>> Hello
>>>
>>> I have a matlab MAT file that contains one single variable: a.  The 
>>> structure of a is as follows:
>>>
>>> a.river1.flow (flow values)
>>> a.river1.date_flow (date)
>>> a.river1.precip (precipitation values) a.river1.dat

[R] Problems getting html files out of R CMD check

2011-03-13 Thread Amos Folarin
Hi,

I'm trying to R CMD check a package, however I have hit a snag. There seems
to be a problem with the creation of the /html files (the only file that's
constructed here is the 00Index.html). I've tested each of the .Rd files
independently with R CMD Rdconv, they all happily create html files without
complaint.


R CMD check  gives the no warnings. I'm therefore curious why this
hasn't created the html files for the package, I think I must be missing
something.

* using log directory ‘/home/me/scratch/CellProfileR.Rcheck’
* using R version 2.12.2 (2011-02-25)
* using platform: i686-pc-linux-gnu (32-bit)
* using session charset: UTF-8
* checking for file ‘CellProfileR/DESCRIPTION’ ... OK
* checking extension type ... Package
* this is package ‘CellProfileR’ version ‘1.0’
* checking package dependencies ... OK
* checking if this is a source package ... OK
* checking for executable files ... OK
* checking whether package ‘CellProfileR’ can be installed ... OK
* checking package directory ... OK
* checking for portable file names ... OK
* checking for sufficient/correct file permissions ... OK
* checking DESCRIPTION meta-information ... OK
* checking top-level files ... OK
* checking index information ... OK
* checking package subdirectories ... OK
* checking R files for non-ASCII characters ... OK
* checking R files for syntax errors ... OK
* checking whether the package can be loaded ... OK
* checking whether the package can be loaded with stated dependencies ... OK
* checking whether the package can be unloaded cleanly ... OK
* checking for unstated dependencies in R code ... OK
* checking S3 generic/method consistency ... OK
* checking replacement functions ... OK
* checking foreign function calls ... OK
* checking R code for possible problems ... OK
* checking Rd files ... NOTE
prepare_Rd: CellProfile-R-internal.Rd:10: Dropping empty section \usage
prepare_Rd: CellProfile-R-internal.Rd:12: Dropping empty section \arguments
prepare_Rd: CellProfile-R-internal.Rd:22: Dropping empty section \value
prepare_Rd: CellProfile-R-internal.Rd:25: Dropping empty section \note
prepare_Rd: CellProfile-R-internal.Rd:23: Dropping empty section \references
prepare_Rd: CellProfile-R-internal.Rd:29: Dropping empty section \seealso
prepare_Rd: CellProfile-R-internal.Rd:30: Dropping empty section \examples
prepare_Rd: CellProfile-R-package.Rd:43: Dropping empty section \seealso
prepare_Rd: CellProfile-R-package.Rd:44: Dropping empty section \examples
prepare_Rd: createUnifiedTable.Rd:59-61: Dropping empty section \note
prepare_Rd: createUnifiedTable.Rd:53-55: Dropping empty section \references
prepare_Rd: fileConnect.Rd:47-49: Dropping empty section \note
prepare_Rd: fileConnect.Rd:41-43: Dropping empty section \references
prepare_Rd: fileConnect.Rd:53-55: Dropping empty section \seealso
prepare_Rd: loadTable.Rd:29-31: Dropping empty section \details
prepare_Rd: loadTable.Rd:41-43: Dropping empty section \note
prepare_Rd: loadTable.Rd:35-37: Dropping empty section \references
prepare_Rd: mapMetadataToTable.Rd:53-55: Dropping empty section \note
prepare_Rd: mapMetadataToTable.Rd:47-49: Dropping empty section \references
prepare_Rd: mapMetadataToTable.Rd:59-61: Dropping empty section \seealso
prepare_Rd: mySqlConnect.Rd:27-29: Dropping empty section \details
prepare_Rd: mySqlConnect.Rd:39-41: Dropping empty section \note
prepare_Rd: mySqlConnect.Rd:33-35: Dropping empty section \references
prepare_Rd: mySqlConnect.Rd:43-45: Dropping empty section \seealso
prepare_Rd: mySqlConnect.Rd:46: Dropping empty section \examples
prepare_Rd: recastDatabaseTable.Rd:39-41: Dropping empty section \note
prepare_Rd: recastDatabaseTable.Rd:36-38: Dropping empty section \author
prepare_Rd: recastDatabaseTable.Rd:33-35: Dropping empty section \references
prepare_Rd: recastDatabaseTable.Rd:45-47: Dropping empty section \seealso
prepare_Rd: saveTable.Rd:20-22: Dropping empty section \details
prepare_Rd: saveTable.Rd:30-32: Dropping empty section \note
prepare_Rd: saveTable.Rd:24-26: Dropping empty section \references
prepare_Rd: saveTable.Rd:36-38: Dropping empty section \seealso
prepare_Rd: saveTable.Rd:39: Dropping empty section \examples
prepare_Rd: splitTableOnVariable.Rd:18: Dropping empty section \details
prepare_Rd: splitTableOnVariable.Rd:24-26: Dropping empty section \note
prepare_Rd: splitTableOnVariable.Rd:20-22: Dropping empty section
\references
prepare_Rd: splitTableOnVariable.Rd:30-32: Dropping empty section \seealso
prepare_Rd: sqLiteConnect.Rd:34-36: Dropping empty section \note
prepare_Rd: sqLiteConnect.Rd:28-30: Dropping empty section \references
prepare_Rd: sqLiteConnect.Rd:40-42: Dropping empty section \seealso
* checking Rd metadata ... OK
* checking Rd cross-references ... OK
* checking for missing documentation entries ... OK
* checking for code/documentation mismatches ... OK
* checking Rd \usage sections ... OK
* checking Rd contents ... OK
* checking for unstated dependencies in examples ... OK
* checking data for non-A

Re: [R] install.packages & reshape failure

2011-03-13 Thread Joshua Wiley
Hi Geoff,

What is your platform and R version?  I cannot replicate on either:

R version 2.12.1 (2010-12-16)
Platform: i386-pc-mingw32/i386 (32-bit)
attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base
other attached packages:
[1] reshape_0.8.4 plyr_1.4
loaded via a namespace (and not attached):
[1] tools_2.12.1

R version 2.13.0 Under development (unstable) (2011-03-08 r54703)
Platform: x86_64-pc-mingw32/x64 (64-bit)
attached base packages:
[1] tcltk stats graphics  grDevices utils datasets  methods   base
other attached packages:
[1] reshape_0.8.4 plyr_1.4

Are you doing anything else in your .Rprofile (i.e., maybe there is a
more complex interaction going on)?  What happens if you start a
vanilla R session, then:

require(reshape)
require(tcltk)
install.packages("quantreg")

?

Cheers,

Josh

On Sun, Mar 13, 2011 at 3:50 PM, Geoff Russell
 wrote:
> I'm not sure where I should send this, I don't have a bugzilla account,
> but ... it concerns an interaction between library(reshape) and
> install.packages() ...
>
> My current .Rprofile includes: library(reshape)
>
> After which install.packages fails ... e.g.,
>
>> install.packages("quantreg")
> Warning in install.packages("quantreg") :
>  argument 'lib' is missing: using '/usr/local/lib/R/site-library'
> --- Please select a CRAN mirror for use in this session ---
> Loading Tcl/Tk interface ... done
> Error in try(function ()  : unused argument(s) (function ()
>
> Removing the "library(reshape)" from the .Rprofile fixes the problem.
>
> Cheers,
> Geoff
>
>        [[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.
>



-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.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.


Re: [R] readMat - how to retrieve the variables

2011-03-13 Thread David Winsemius


On Mar 13, 2011, at 6:42 PM, Eduardo M. A. M.Mendes wrote:



Hi Joshua

Many thanks.

The values of flow can be accessed in a weird way and we can used  
them for some calculations.  Since I am a newbie as far as using R  
is concerned I wonder whether you could tell me how to create a  
structure in R that looks like the one I have in matlab (that is, a  
variable a that contains river1 and river2 that contains flow and  
precipitation).


If you posted the results of dput(a) ,  we might be able to test our  
pet theories, but here is my hapless first guess:


mat.R.struc <- with(b$a[,,1],   #looks like it was a matrix that had  
lists as elements

 cbind(as.data.frame(river1), as.data.frame(river2) )
)

It's not so much that it will "look like" your Matlab structure, but  
it could be something that you can work with. This will create a long- 
format structure which is a typical one for plotting ans regression.  
Another option would be an R array which, unlike matrices, can have  
more than 2 dimensions.





Cheers

Ed


-Original Message-
From: Joshua Wiley [mailto:jwiley.ps...@gmail.com]
Sent: Sunday, March 13, 2011 7:20 PM
To: Eduardo M. A. M.Mendes
Cc: R-help@r-project.org
Subject: Re: [R] readMat - how to retrieve the variables

On Sun, Mar 13, 2011 at 2:56 PM, Eduardo M. A. M.Mendes > wrote:

Hi Joshua

Many thanks for the prompt reply.

I have saved a short version of the matlab file and the output on R  
is



b=readMat("testr.mat")
b

$a
, , 1

 [,1]
river1 List,2
river2 List,2


It looks like you are dealing with a special series of lists nested  
within three dimensional arrays within lists.  My suggestion would  
be to double check that the matlab file has reasonable data  
(whatever that means) and try to double check your use of readmat  
(do you meet all the requirements for versions, etc.).  That is not  
a common R structure so the extraction is similarly uncommon.   
Perhaps Henrik will be along with more helpful answers.


Good luck,

Josh



attr(,"header")
attr(,"header")$description
[1] "MATLAB 5.0 MAT-file, Platform: PCWIN, Created on: Sun Mar 13  
18:51:54 2011  "


attr(,"header")$version
[1] "5"

attr(,"header")$endian
[1] "little"

When I issue the command b$a[,,1]$river1[,,1]$flow  I see the flow  
values.


Unfortunately the data is confidential.

Many thanks

Ed


-Original Message-
From: Joshua Wiley [mailto:jwiley.ps...@gmail.com]
Sent: Sunday, March 13, 2011 6:30 PM
To: Eduardo M. A. M.Mendes
Cc: R-help@r-project.org
Subject: Re: [R] readMat - how to retrieve the variables

Hi Ed,

Can you please provide *at least* the R output from running:

str(data)

where "data" is the variable name you stored the results of  
readMat() in.  If it is reasonably small and can be sent as  
plaintext (I do not know Matlabs file format off hand), you could  
send us the actual data so we can try to read it in, but at the  
least str() will let us see how R is storing your data and give you  
some explanation.


Side note, as data() is a function, it might be worthwhile to call  
your actual data something else (say, mydata, dat, etc.).  For  
anyone else interested, readMat() is in package "R.matlab".


Cheers,

Josh

On Sun, Mar 13, 2011 at 2:07 PM, Eduardo M. A. M.Mendes > wrote:

Hello

I have a matlab MAT file that contains one single variable: a.  The
structure of a is as follows:

a.river1.flow (flow values)
a.river1.date_flow (date)
a.river1.precip (precipitation values) a.river1.date_precip
a.river2.flow a.river2.date_flow a.river2.precip  
a.river2.date_precip


I have used readMat to load the variable a in R, however I have no
idea how readMat translates a.  I managed to get some values out of
data=readMat("matfile.mat")

data$a[,,1]$river1[,,1]$flow  -> Why do I need [,,1]?  Why not
data$a$river1$flow?

Many thanks

Ed

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


--
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.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.


David Winsemius, MD
West Hartford, CT

__
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] readMat - how to retrieve the variables

2011-03-13 Thread Joshua Wiley
Hi Ed,

Here are some different ways of structuring and storing data in R as
well as how to access them.

Hope this helps,

Josh

#

set.seed(10)
## Option 1a (closest to what you want?)
a1a <- list(river1 = data.frame(flow = 1:10, precipitation = runif(10)),
  river2 = data.frame(flow = 11:20, precipitation = runif(10)))

set.seed(10)
## Option 1b (a slight variant), lists + named vectors
a1b <- list(river1 = list(flow = 1:10, precipitation = runif(10)),
  river2 = list(flow = 11:20, precipitation = runif(10)))

set.seed(10)
## Option 2 (a.k.a. 'long' format)
a2 <- data.frame(flow = 1:20, precipitation = runif(20),
  river = factor(rep(1:2, each = 10)))

set.seed(10)
## Option 3 (a.k.a. 'wide' format)
a3 <- data.frame(r1.flow = 1:10, r2.flow = 11:20,
  r1.precipitation = runif(10), r2.precipitation = runif(10))

## compare the str()uctures of all four objects

str(a1a)
str(a1b)
str(a2)
str(a3)

## Access "flow" from "river1" in option 1a
## four equivalent options
a1a$river1$flow
a1a[["river1"]][,"flow"]
a1a[[1]][, 1]
a1a[[c(1, 1)]]

## Option 1b
a1b$river1$flow ## works
a1b[[1]][, 1] ## does not work, used vectors not a dataframe
a1b[[c(1, 1)]] ## works

## Option 2
a2$flow ## both rivers' flow, useful for plotting
a2[, 1]
a2[, "flow"]
## for example:
require(lattice)
xyplot(flow ~ precipitation | river, data = a2)

## Option 3
a3$r1.flow
a3[, 1]
a3[, "r1.flow"]

##

On Sun, Mar 13, 2011 at 3:42 PM, Eduardo M. A. M.Mendes
 wrote:
>
> Hi Joshua
>
> Many thanks.
>
> The values of flow can be accessed in a weird way and we can used them for 
> some calculations.  Since I am a newbie as far as using R is concerned I 
> wonder whether you could tell me how to create a structure in R that looks 
> like the one I have in matlab (that is, a variable a that contains river1 and 
> river2 that contains flow and precipitation).
>
> Cheers
>
> Ed
>
>
> -Original Message-
> From: Joshua Wiley [mailto:jwiley.ps...@gmail.com]
> Sent: Sunday, March 13, 2011 7:20 PM
> To: Eduardo M. A. M.Mendes
> Cc: R-help@r-project.org
> Subject: Re: [R] readMat - how to retrieve the variables
>
> On Sun, Mar 13, 2011 at 2:56 PM, Eduardo M. A. M.Mendes 
>  wrote:
>> Hi Joshua
>>
>> Many thanks for the prompt reply.
>>
>> I have saved a short version of the matlab file and the output on R is
>>
>>> b=readMat("testr.mat")
>>> b
>> $a
>> , , 1
>>
>>       [,1]
>> river1 List,2
>> river2 List,2
>
> It looks like you are dealing with a special series of lists nested within 
> three dimensional arrays within lists.  My suggestion would be to double 
> check that the matlab file has reasonable data (whatever that means) and try 
> to double check your use of readmat (do you meet all the requirements for 
> versions, etc.).  That is not a common R structure so the extraction is 
> similarly uncommon.  Perhaps Henrik will be along with more helpful answers.
>
> Good luck,
>
> Josh
>>
>>
>> attr(,"header")
>> attr(,"header")$description
>> [1] "MATLAB 5.0 MAT-file, Platform: PCWIN, Created on: Sun Mar 13 18:51:54 
>> 2011                                                  "
>>
>> attr(,"header")$version
>> [1] "5"
>>
>> attr(,"header")$endian
>> [1] "little"
>>
>> When I issue the command b$a[,,1]$river1[,,1]$flow  I see the flow values.
>>
>> Unfortunately the data is confidential.
>>
>> Many thanks
>>
>> Ed
>>
>>
>> -Original Message-
>> From: Joshua Wiley [mailto:jwiley.ps...@gmail.com]
>> Sent: Sunday, March 13, 2011 6:30 PM
>> To: Eduardo M. A. M.Mendes
>> Cc: R-help@r-project.org
>> Subject: Re: [R] readMat - how to retrieve the variables
>>
>> Hi Ed,
>>
>> Can you please provide *at least* the R output from running:
>>
>> str(data)
>>
>> where "data" is the variable name you stored the results of readMat() in.  
>> If it is reasonably small and can be sent as plaintext (I do not know 
>> Matlabs file format off hand), you could send us the actual data so we can 
>> try to read it in, but at the least str() will let us see how R is storing 
>> your data and give you some explanation.
>>
>> Side note, as data() is a function, it might be worthwhile to call your 
>> actual data something else (say, mydata, dat, etc.).  For anyone else 
>> interested, readMat() is in package "R.matlab".
>>
>> Cheers,
>>
>> Josh
>>
>> On Sun, Mar 13, 2011 at 2:07 PM, Eduardo M. A. M.Mendes 
>>  wrote:
>>> Hello
>>>
>>> I have a matlab MAT file that contains one single variable: a.  The
>>> structure of a is as follows:
>>>
>>> a.river1.flow (flow values)
>>> a.river1.date_flow (date)
>>> a.river1.precip (precipitation values) a.river1.date_precip
>>> a.river2.flow a.river2.date_flow a.river2.precip a.river2.date_precip
>>>
>>> I have used readMat to load the variable a in R, however I have no
>>> idea how readMat translates a.  I managed to get some values out of
>>> data=readMat("matfile.mat")
>>>
>>> data$a[,,1]

[R] install.packages & reshape failure

2011-03-13 Thread Geoff Russell
I'm not sure where I should send this, I don't have a bugzilla account,
but ... it concerns an interaction between library(reshape) and
install.packages() ...

My current .Rprofile includes: library(reshape)

After which install.packages fails ... e.g.,

> install.packages("quantreg")
Warning in install.packages("quantreg") :
  argument 'lib' is missing: using '/usr/local/lib/R/site-library'
--- Please select a CRAN mirror for use in this session ---
Loading Tcl/Tk interface ... done
Error in try(function ()  : unused argument(s) (function ()

Removing the "library(reshape)" from the .Rprofile fixes the problem.

Cheers,
Geoff

[[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] readMat - how to retrieve the variables

2011-03-13 Thread Eduardo M. A. M.Mendes

Hi Joshua

Many thanks.  

The values of flow can be accessed in a weird way and we can used them for some 
calculations.  Since I am a newbie as far as using R is concerned I wonder 
whether you could tell me how to create a structure in R that looks like the 
one I have in matlab (that is, a variable a that contains river1 and river2 
that contains flow and precipitation).

Cheers

Ed


-Original Message-
From: Joshua Wiley [mailto:jwiley.ps...@gmail.com] 
Sent: Sunday, March 13, 2011 7:20 PM
To: Eduardo M. A. M.Mendes
Cc: R-help@r-project.org
Subject: Re: [R] readMat - how to retrieve the variables

On Sun, Mar 13, 2011 at 2:56 PM, Eduardo M. A. M.Mendes  
wrote:
> Hi Joshua
>
> Many thanks for the prompt reply.
>
> I have saved a short version of the matlab file and the output on R is
>
>> b=readMat("testr.mat")
>> b
> $a
> , , 1
>
>   [,1]
> river1 List,2
> river2 List,2

It looks like you are dealing with a special series of lists nested within 
three dimensional arrays within lists.  My suggestion would be to double check 
that the matlab file has reasonable data (whatever that means) and try to 
double check your use of readmat (do you meet all the requirements for 
versions, etc.).  That is not a common R structure so the extraction is 
similarly uncommon.  Perhaps Henrik will be along with more helpful answers.

Good luck,

Josh
>
>
> attr(,"header")
> attr(,"header")$description
> [1] "MATLAB 5.0 MAT-file, Platform: PCWIN, Created on: Sun Mar 13 18:51:54 
> 2011  "
>
> attr(,"header")$version
> [1] "5"
>
> attr(,"header")$endian
> [1] "little"
>
> When I issue the command b$a[,,1]$river1[,,1]$flow  I see the flow values.
>
> Unfortunately the data is confidential.
>
> Many thanks
>
> Ed
>
>
> -Original Message-
> From: Joshua Wiley [mailto:jwiley.ps...@gmail.com]
> Sent: Sunday, March 13, 2011 6:30 PM
> To: Eduardo M. A. M.Mendes
> Cc: R-help@r-project.org
> Subject: Re: [R] readMat - how to retrieve the variables
>
> Hi Ed,
>
> Can you please provide *at least* the R output from running:
>
> str(data)
>
> where "data" is the variable name you stored the results of readMat() in.  If 
> it is reasonably small and can be sent as plaintext (I do not know Matlabs 
> file format off hand), you could send us the actual data so we can try to 
> read it in, but at the least str() will let us see how R is storing your data 
> and give you some explanation.
>
> Side note, as data() is a function, it might be worthwhile to call your 
> actual data something else (say, mydata, dat, etc.).  For anyone else 
> interested, readMat() is in package "R.matlab".
>
> Cheers,
>
> Josh
>
> On Sun, Mar 13, 2011 at 2:07 PM, Eduardo M. A. M.Mendes 
>  wrote:
>> Hello
>>
>> I have a matlab MAT file that contains one single variable: a.  The 
>> structure of a is as follows:
>>
>> a.river1.flow (flow values)
>> a.river1.date_flow (date)
>> a.river1.precip (precipitation values) a.river1.date_precip 
>> a.river2.flow a.river2.date_flow a.river2.precip a.river2.date_precip
>>
>> I have used readMat to load the variable a in R, however I have no 
>> idea how readMat translates a.  I managed to get some values out of
>> data=readMat("matfile.mat")
>>
>> data$a[,,1]$river1[,,1]$flow  -> Why do I need [,,1]?  Why not 
>> data$a$river1$flow?
>>
>> Many thanks
>>
>> Ed
>>
>> __
>> 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.

--
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.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] confidence intervals for noncentrality parameters

2011-03-13 Thread David Bickel
Is there any quick way to compute confidence intervals for the
noncentrality parameter of the noncentral chi-square family? I get an
error when installing the Deducer package.

I would appreciate any help.

David

__
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] readMat - how to retrieve the variables

2011-03-13 Thread Joshua Wiley
On Sun, Mar 13, 2011 at 2:56 PM, Eduardo M. A. M.Mendes
 wrote:
> Hi Joshua
>
> Many thanks for the prompt reply.
>
> I have saved a short version of the matlab file and the output on R is
>
>> b=readMat("testr.mat")
>> b
> $a
> , , 1
>
>       [,1]
> river1 List,2
> river2 List,2

It looks like you are dealing with a special series of lists nested
within three dimensional arrays within lists.  My suggestion would be
to double check that the matlab file has reasonable data (whatever
that means) and try to double check your use of readmat (do you meet
all the requirements for versions, etc.).  That is not a common R
structure so the extraction is similarly uncommon.  Perhaps Henrik
will be along with more helpful answers.

Good luck,

Josh
>
>
> attr(,"header")
> attr(,"header")$description
> [1] "MATLAB 5.0 MAT-file, Platform: PCWIN, Created on: Sun Mar 13 18:51:54 
> 2011                                                  "
>
> attr(,"header")$version
> [1] "5"
>
> attr(,"header")$endian
> [1] "little"
>
> When I issue the command b$a[,,1]$river1[,,1]$flow  I see the flow values.
>
> Unfortunately the data is confidential.
>
> Many thanks
>
> Ed
>
>
> -Original Message-
> From: Joshua Wiley [mailto:jwiley.ps...@gmail.com]
> Sent: Sunday, March 13, 2011 6:30 PM
> To: Eduardo M. A. M.Mendes
> Cc: R-help@r-project.org
> Subject: Re: [R] readMat - how to retrieve the variables
>
> Hi Ed,
>
> Can you please provide *at least* the R output from running:
>
> str(data)
>
> where "data" is the variable name you stored the results of readMat() in.  If 
> it is reasonably small and can be sent as plaintext (I do not know Matlabs 
> file format off hand), you could send us the actual data so we can try to 
> read it in, but at the least str() will let us see how R is storing your data 
> and give you some explanation.
>
> Side note, as data() is a function, it might be worthwhile to call your 
> actual data something else (say, mydata, dat, etc.).  For anyone else 
> interested, readMat() is in package "R.matlab".
>
> Cheers,
>
> Josh
>
> On Sun, Mar 13, 2011 at 2:07 PM, Eduardo M. A. M.Mendes 
>  wrote:
>> Hello
>>
>> I have a matlab MAT file that contains one single variable: a.  The
>> structure of a is as follows:
>>
>> a.river1.flow (flow values)
>> a.river1.date_flow (date)
>> a.river1.precip (precipitation values) a.river1.date_precip
>> a.river2.flow a.river2.date_flow a.river2.precip a.river2.date_precip
>>
>> I have used readMat to load the variable a in R, however I have no
>> idea how readMat translates a.  I managed to get some values out of
>> data=readMat("matfile.mat")
>>
>> data$a[,,1]$river1[,,1]$flow  -> Why do I need [,,1]?  Why not
>> data$a$river1$flow?
>>
>> Many thanks
>>
>> Ed
>>
>> __
>> 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.

-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.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.


Re: [R] R hangs when connected via VPN [incl. minimal example]

2011-03-13 Thread Marius Hofert
Dear Duncan,

thanks for your suggestion. I contacted "REvolution Computing" on this behalf. 
Rmpi and rlecuyer are loaded automatically, so they are not explicitly needed 
in the minimal example. 
I'll post the answer (if I receive one). 
It's quite an annoying problem if you frequently work on a server.

Cheers,

Marius

On 2011-03-13, at 13:26 , Duncan Murdoch wrote:

> On 11-03-13 4:34 AM, Marius Hofert wrote:
>> Dear expeRts,
>> 
>> This is a similar post as on R-SIG-MAC [I didn't receive an answer there; 
>> not sure if it was the right place to post either].
>> 
>> I'm running R version 2.12.1 (Platform: x86_64-apple-darwin9.8.0/x86_64 
>> (64-bit))
>> on a MacBook Pro under Mac OS X 10.6.6. The following minimal example runs 
>> fine
>> under this setup. However, if I am connected to a server via a VPN client
>> [Cisco AnyConnect; same with Apple's internal VPN connection], then the 
>> minimal
>> example hangs and just does not do anything. The "red button" in the R 
>> Console
>> is dark red [normal behavior if R is running], so R tries to do something, 
>> but
>> cannot succeed. CPU goes up to 100%... Same happens if I start the job from 
>> the
>> command line via R CMD BATCH. What's going on? Is this a known issue?
>> 
>> Cheers,
>> 
>> Marius
>> 
>> library(doSNOW)
>> library(Rmpi)
>> library(rlecuyer)
>> library(foreach)
> 
> You're using 4 different contributed packages here. Do you really need all of 
> those?  If so, it's going to be hard to debug.
> 
> I'd suggest trying to determine the last successful call, and the first 
> unsuccessful one, then take this up with the maintainer of the package that 
> fails.
> 
> Duncan Murdoch
> 
>> 
>> cl<- makeCluster(mpi.universe.size(), type ="MPI")
>> tmp<- clusterSetupRNG(cl, seed=rep(1,6))
>> registerDoSNOW(cl)
>> 
>> counter<- 0
>> res<- foreach(k = 1:1000) %do% {
>> counter<- counter + 1
>> }
>> tmp<- stopCluster(cl)
>> 
>> unlist(res)
>> __
>> 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] readMat - how to retrieve the variables

2011-03-13 Thread Eduardo M. A. M.Mendes
Hi Joshua

Many thanks for the prompt reply.

I have saved a short version of the matlab file and the output on R is

> b=readMat("testr.mat")
> b
$a
, , 1

   [,1]  
river1 List,2
river2 List,2


attr(,"header")
attr(,"header")$description
[1] "MATLAB 5.0 MAT-file, Platform: PCWIN, Created on: Sun Mar 13 18:51:54 2011 
 "

attr(,"header")$version
[1] "5"

attr(,"header")$endian
[1] "little"

When I issue the command b$a[,,1]$river1[,,1]$flow  I see the flow values.

Unfortunately the data is confidential.

Many thanks

Ed


-Original Message-
From: Joshua Wiley [mailto:jwiley.ps...@gmail.com] 
Sent: Sunday, March 13, 2011 6:30 PM
To: Eduardo M. A. M.Mendes
Cc: R-help@r-project.org
Subject: Re: [R] readMat - how to retrieve the variables

Hi Ed,

Can you please provide *at least* the R output from running:

str(data)

where "data" is the variable name you stored the results of readMat() in.  If 
it is reasonably small and can be sent as plaintext (I do not know Matlabs file 
format off hand), you could send us the actual data so we can try to read it 
in, but at the least str() will let us see how R is storing your data and give 
you some explanation.

Side note, as data() is a function, it might be worthwhile to call your actual 
data something else (say, mydata, dat, etc.).  For anyone else interested, 
readMat() is in package "R.matlab".

Cheers,

Josh

On Sun, Mar 13, 2011 at 2:07 PM, Eduardo M. A. M.Mendes  
wrote:
> Hello
>
> I have a matlab MAT file that contains one single variable: a.  The 
> structure of a is as follows:
>
> a.river1.flow (flow values)
> a.river1.date_flow (date)
> a.river1.precip (precipitation values) a.river1.date_precip 
> a.river2.flow a.river2.date_flow a.river2.precip a.river2.date_precip
>
> I have used readMat to load the variable a in R, however I have no 
> idea how readMat translates a.  I managed to get some values out of
> data=readMat("matfile.mat")
>
> data$a[,,1]$river1[,,1]$flow  -> Why do I need [,,1]?  Why not 
> data$a$river1$flow?
>
> Many thanks
>
> Ed
>
> __
> 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.
>



--
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.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] devSVG error

2011-03-13 Thread Kyle Covington
I was using devSVG to save plots of trees using the RSVGDevice package for
devSVG and tree package for the trees.  When I put text into the plot,
obviously there are < and > symbols.  These seem to be corrupting the svg
file which is XML and makes use of <> for syntax.

Is there any way around this, some setting in devSVG that I can turn on that
will capture these things and make them syntactically correct for SVG or is
this a bug in devSVG (in that case I'd like to report the bug).  Or is this
actually valid .svg in which case GIMP and Qt both have bugs.

Thanks
Kyle

[[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] readMat - how to retrieve the variables

2011-03-13 Thread Joshua Wiley
Hi Ed,

Can you please provide *at least* the R output from running:

str(data)

where "data" is the variable name you stored the results of readMat()
in.  If it is reasonably small and can be sent as plaintext (I do not
know Matlabs file format off hand), you could send us the actual data
so we can try to read it in, but at the least str() will let us see
how R is storing your data and give you some explanation.

Side note, as data() is a function, it might be worthwhile to call
your actual data something else (say, mydata, dat, etc.).  For anyone
else interested, readMat() is in package "R.matlab".

Cheers,

Josh

On Sun, Mar 13, 2011 at 2:07 PM, Eduardo M. A. M.Mendes
 wrote:
> Hello
>
> I have a matlab MAT file that contains one single variable: a.  The
> structure of a is as follows:
>
> a.river1.flow (flow values)
> a.river1.date_flow (date)
> a.river1.precip (precipitation values)
> a.river1.date_precip
> a.river2.flow
> a.river2.date_flow
> a.river2.precip
> a.river2.date_precip
>
> I have used readMat to load the variable a in R, however I have no idea how
> readMat translates a.  I managed to get some values out of
> data=readMat("matfile.mat")
>
> data$a[,,1]$river1[,,1]$flow  -> Why do I need [,,1]?  Why not
> data$a$river1$flow?
>
> Many thanks
>
> Ed
>
> __
> 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.
>



-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.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.


Re: [R] Having a problem with choose.files

2011-03-13 Thread Duncan Murdoch

On 11-03-13 7:11 AM, carl.finkbei...@tnsglobal.com wrote:

I am relatively new to R, and am having a problem with the following
snippet of code, and I do not at all understand why it is behaving this
way.  I am running Windows XP, with R 2.12.1.

I copy and paste these 4 lines into the R Console:
   t<-c("a","b","c")
   ans<-select.list(t)
   txtNBS<-winDialogString("NBS","300")
   choose.files()

I click on OK in the Select One dialog, and on OK in the Question
dialog, and then Cancel in the file dialog.  Everything behaves as I
expect it to.  (All 3 of those dialog functions are in the utils
package.)

I then copy and paste these 6 lines defining the function fn, into the R
Console.  Note that the body of the function is exactly the same as the
4 lines above that worked well.
   fn<-function() {
 t<-c("a","b","c")
 ans<-select.list(t)
 txtNBS<-winDialogString("NBS","300")
 choose.files()
   }


I think I know the details of the problem now.  The problem is that 
select.list()'s internal implementation didn't give R a chance to 
process messages after it was done, so its cleanup wasn't acted on at 
the right time.  (Event driven programming is lots of fun.)  When you 
run select.list() at the command line, R processes the cleanup after it 
is done, and things are fine.


This is easy to fix, and I'll do that in R-devel and R-patched.

I don't know an easy workaround in the meantime, other than not using 
the "graphics=TRUE" version of select.list ahead of other 
dialog-generating functions.


Duncan Murdoch



When I then invoke this function by typing fn() into the R Console, I
again click OK in the Select One dialog, and on OK in the Question
dialog.  BUT, the file dialog never appears.  Furthermore, if I then
type choose.files() into the R Console, about half the time the file
dialog appears and about half the time it doesn't.

Any help anyone can give me is much appreciated.  I cannot see what I am
doing wrong here.

Thanks,

Carl Finkbeiner

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


[R] readMat - how to retrieve the variables

2011-03-13 Thread Eduardo M. A. M.Mendes
Hello

I have a matlab MAT file that contains one single variable: a.  The
structure of a is as follows:

a.river1.flow (flow values)
a.river1.date_flow (date)
a.river1.precip (precipitation values)
a.river1.date_precip
a.river2.flow
a.river2.date_flow
a.river2.precip
a.river2.date_precip

I have used readMat to load the variable a in R, however I have no idea how
readMat translates a.  I managed to get some values out of
data=readMat("matfile.mat")

data$a[,,1]$river1[,,1]$flow  -> Why do I need [,,1]?  Why not
data$a$river1$flow?

Many thanks

Ed

__
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] use of ROCR package (ROC curve / AUC value) in a specific case versus integral calculation

2011-03-13 Thread Jose-Marcio Martins da Cruz

Christine SINOQUET wrote:

Hello,

I would like to use the ROCR package to draw ROC curves and compute AUC
values.

However, in the specific context of my application, the true positive
rates and false positive rates are already provided by some upstream
method.

Of course, I can draw a ROC plot with the following command :

plot(x=FPrate, y=TPrate, "o", xlab="false positive rate", ylab="true
positive rate", xlim=c(0, 1), ylim=c(0, 1)

but this will bot compute the AUC value.

There are two possibilities :
Either it is possible to use the above parameters - FPrate and TPrate
vectors- to run the performance function and I would like to know how,


or it is not possible and I have to compute the area under the curve but
I cannot find on the Web how to perform this, through an R package,
using the two vectors above, if possible (I would rather not implement
an integration algorithm).

I thank you in advance for your answer.


My answer doesn't use R...

For some applications, when the classifier performance is quite good, integrating the ROC curve 
isn't a good idea, as the curve is very abrupt.


Another approach is to use the fact that the (1-AUC) represents the probability of taking at random 
one positive and one negative event and don't geting  them in the correct order (by their score). 
This is related to the Wilcoxon distribution.


So, if you have a set of negative and positive events and the "scores" assigned to them, you can 
sort them by their scores and enumerate the number of couples out of order you can get.


Hope this help.

José-Marcio


--
 ---
 Jose Marcio MARTINS DA CRUZ   http://j-chkmail.ensmp.fr
 Ecole des Mines de Paris
 60, bd Saint Michel  75272 - PARIS CEDEX 06
 mailto:jose-marcio.mart...@mines-paristech.fr

__
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] An example on how to use neuralnet to predict values

2011-03-13 Thread Eduardo M. A. M. Mendes
Hello

I am new to R and wonder whether someone out there could send me an example
on how to use the package neuralnet to fit a model to data, following the
usual procedure, that is, fitting the model using the training set and then
using the validation set to check the model.   Moreover, the neural net
model is recursive (uses its own output values)-> infinite steps ahead
prediction. 

Many thanks

Ed

__
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] An example of using neuralnet to predict infinite steps ahead

2011-03-13 Thread Eduardo M. A. M.Mendes
Hello

I am new to R and wonder whether someone out there could send me an example
on how to use the package neuralnet to fit a model to data, following the
usual procedure, that is, fitting the model using the training set and then
using the validation set to check the model.   Moreover, the neural net
model is recursive (uses its own output values)-> infinite steps ahead
prediction. 

Many thanks

Ed

__
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] pass character vector in instrument field of get.hist.quote function

2011-03-13 Thread Joshua Ulrich
Sorry for the late reply.  Here's another approach using
quantmod::getSymbols.  It implicitly loops over a vector of tickers.

require(quantmod)
getSymbols(tickers[,1], from="2011-01-01", to="2011-01-31")
# If you want to merge all the close prices into one object:
ClosePrices <- do.call(merge, lapply(tickers[,1], function(x) Cl(get(x
head(ClosePrices)
#BCSI.Close WBSN.Close NTAP.Close FFIV.Close SU.Close
# 2011-01-03  30.50  20.36  57.41 134.3338.82
# 2011-01-04  30.24  19.82  57.38 132.0738.03
# 2011-01-05  31.36  19.90  57.87 137.2938.40
# 2011-01-06  32.04  19.79  57.49 138.0737.23
# 2011-01-07  31.95  19.77  57.20 138.3537.30
# 2011-01-10  31.55  19.76  58.22 142.6937.04

Hope that helps,
--
Joshua Ulrich  |  FOSS Trading: www.fosstrading.com



On Sun, Mar 13, 2011 at 1:29 PM, algotr8der  wrote:
> Thank you all. Your solutions work. I suppose it doesnt matter whether I use
> coredata or not (at least for my current purposes). I have created a
> user-defined function and have saved it in a ".R" file in my current working
> directory. But now I'm not sure how to invoke this function. R complains
> that it cannot find the function.
>
> If I copy and paste the function code into the R console and call it after
> that everything works fine. Is there a way to bring that function into
> memory by giving a path to its location? I imagine that I will have many
> user-defined functions written in their own '.R' files over time.
>
> Thank you all.
>
>
>
>
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/pass-character-vector-in-instrument-field-of-get-hist-quote-function-tp3350779p3352344.html
> Sent from the R help mailing list archive at Nabble.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-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] using pre-calculated coefficients and LP in coxph()?

2011-03-13 Thread David Winsemius


On Mar 13, 2011, at 2:43 PM, Ravi Varadhan wrote:

Like David, I too thought that `offset' is the way to do this.  I  
was actually in the midst of testing the differences between using  
`offset' and `init' when David's email came.


Here is what I could figure out so far:

1.  If you want to fix only a subset of regressors, but let others  
be estimated, then you must use `offset'.  The `init' approach will  
not work.


2. Even when all the regressors are fixed (I have to admit that I do  
not see the point of this, like David said), there seems to be a  
difference in using `init' and `offset'.


   I want to thank you, Ravi, for taking the next steps beyond my  
speculations. However, I did not mean to imply that I could see no  
point in using an offset with coxph(). I only meant to say that the OP  
had not yet provided a basis for doing so.


   If one were trying to test  a pre-determined classification rule  
against a new or augmented candidate rule, then entering an offset  
term could be very desirable. An example in my domain of interest  
might be to use a set of life-table estimates for the effect of sex  
and age , then  including other covariates, and even including a  
subject_age term to test whether there was a departure from the  
population expectations. I admit that I have not seen worked examples  
using coxph(), but Therneau has offered examples using Poisson models  
with glm() in his publications regarding "expected survival" both in  
Mayo Clinic Technical Reports and in his book with Grambsch, "Modeling  
Survival Data".


First of all, we cannot interpret or use the standard errors, CIs,  
abd p-values when iter.max=0.  Secondly, there is major disagreement  
in the predictions between `offset' and `init' with no iterations.  
You can run the following code to verify this:


ans1 <- coxph(Surv(time, status) ~ age + ph.karno, data = lung, init  
= c(0.05, -0.05), iter.max = 0)
ans2 <- coxph(Surv(time, status) ~ offset(0.05*age) +  
offset(-0.05*ph.karno), data = lung)


lp1 <- predict(ans1, type="lp")
lp2 <- predict(ans2, type="lp")

all.equal(lp1, lp2)

all.equal(lp1, lp2)

[1] "Mean relative difference: 1.463598"

The results from `offset' are correct, i.e. lp2 can be readily  
verified to be equal to 0.05 * (age - ph.karno).  I don't know how  
lp1 is computed.


Ravi.


Ravi Varadhan, Ph.D.
Assistant Professor,
Division of Geriatric Medicine and Gerontology
School of Medicine
Johns Hopkins University

Ph. (410) 502-2619
email: rvarad...@jhmi.edu


- Original Message -
From: David Winsemius 
Date: Sunday, March 13, 2011 2:29 pm
Subject: Re: [R] using pre-calculated coefficients and LP in coxph()?
To: Dimitris Rizopoulos 
Cc: r-help@r-project.org, Angel Russo 



On Mar 13, 2011, at 1:32 PM, Dimitris Rizopoulos wrote:


probably you want to use the 'init' argument and 'iter.max'
control-argument of coxph(). For example, for the Lung dataset, we  
fix

the coefficients of age and ph.karno at 0.05 and -0.05, respectively:


library(survival)

coxph(Surv(time, status) ~ age + ph.karno, data = lung,
 init = c(0.05, -0.05), iter.max = 0)





I hope it helps.

Best,
Dimitris


On 3/13/2011 6:08 PM, Angel Russo wrote:

I need to force a coxph() function in R to use a pre-calculated set

of beta
coefficients of a gene signature consisting of xx genes and the  
gene

expression is also provided of those xx genes.


I would have guessed (and that is all one can do without an example
and better description of what the setting and goal might be) that  
the

use of the offset capablity in coxph might be needed.

--
David.


If I try to use "coxph()" function in R using just the gene

expression data

alone, the beta coefficients and coxph$linear.predictors will

change and I

need to use the pre-calcuated linear predictor not re-computed

using coxph()

function. The reason is I need to compute a quantity that uses as

it's input

the coxph() output but I need this output to be pre-calculated
beta-coefficients and linear.predictor.

Any one can show me how to do this in R?

Thanks a lot.


David Winsemius, MD
West Hartford, CT

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

PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.


David Winsemius, MD
West Hartford, CT

__
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] using pre-calculated coefficients and LP in coxph()?

2011-03-13 Thread Dimitris Rizopoulos

On 3/13/2011 7:43 PM, Ravi Varadhan wrote:

Like David, I too thought that `offset' is the way to do this.  I was actually 
in the midst of testing the differences between using `offset' and `init' when 
David's email came.

Here is what I could figure out so far:

1.  If you want to fix only a subset of regressors, but let others be 
estimated, then you must use `offset'.  The `init' approach will not work.



Yes, indeed, this is right.


2. Even when all the regressors are fixed (I have to admit that I do not see 
the point of this, like David said), there seems to be a difference in using 
`init' and `offset'.  First of all, we cannot interpret or use the standard 
errors, CIs, abd p-values when iter.max=0.  Secondly, there is major 
disagreement in the predictions between `offset' and `init' with no iterations. 
You can run the following code to verify this:



Of course, indeed, I don't know what Angel has in mind, but there are 
some cases where you might want to compute the hessian matrix at 
specific values using vcov() (local approximation of the likelihood for 
sensitivity analysis), and in this case the `offset' approach will not work.



ans1<- coxph(Surv(time, status) ~ age + ph.karno, data = lung, init = c(0.05, 
-0.05), iter.max = 0)
ans2<- coxph(Surv(time, status) ~ offset(0.05*age) + offset(-0.05*ph.karno), 
data = lung)

lp1<- predict(ans1, type="lp")
lp2<- predict(ans2, type="lp")

all.equal(lp1, lp2)

all.equal(lp1, lp2)

[1] "Mean relative difference: 1.463598"



in fact both are the same, only in the first one they are centered, e.g.,

ans1$linear.predictors
ans2$linear.predictors - mean(ans2$linear.predictors)


The results from `offset' are correct, i.e. lp2 can be readily verified to be 
equal to 0.05 * (age - ph.karno).  I don't know how lp1 is computed.

Ravi.


Ravi Varadhan, Ph.D.
Assistant Professor,
Division of Geriatric Medicine and Gerontology
School of Medicine
Johns Hopkins University

Ph. (410) 502-2619
email: rvarad...@jhmi.edu


- Original Message -
From: David Winsemius
Date: Sunday, March 13, 2011 2:29 pm
Subject: Re: [R] using pre-calculated coefficients and LP in coxph()?
To: Dimitris Rizopoulos
Cc: r-help@r-project.org, Angel Russo



  On Mar 13, 2011, at 1:32 PM, Dimitris Rizopoulos wrote:

  >probably you want to use the 'init' argument and 'iter.max'
control-argument of coxph(). For example, for the Lung dataset, we fix
the coefficients of age and ph.karno at 0.05 and -0.05, respectively:
  >
  >library(survival)
  >
  >coxph(Surv(time, status) ~ age + ph.karno, data = lung,
  >init = c(0.05, -0.05), iter.max = 0)

  >
  >
  >I hope it helps.
  >
  >Best,
  >Dimitris
  >
  >
  >On 3/13/2011 6:08 PM, Angel Russo wrote:
  >>I need to force a coxph() function in R to use a pre-calculated set
of beta
  >>coefficients of a gene signature consisting of xx genes and the gene
  >>expression is also provided of those xx genes.

  I would have guessed (and that is all one can do without an example
and better description of what the setting and goal might be) that the
use of the offset capablity in coxph might be needed.

  --
  David.
  >>
  >>If I try to use "coxph()" function in R using just the gene
expression data
  >>alone, the beta coefficients and coxph$linear.predictors will
change and I
  >>need to use the pre-calcuated linear predictor not re-computed
using coxph()
  >>function. The reason is I need to compute a quantity that uses as
it's input
  >>the coxph() output but I need this output to be pre-calculated
  >>beta-coefficients and linear.predictor.
  >>
  >>Any one can show me how to do this in R?
  >>
  >>Thanks a lot.

  David Winsemius, MD
  West Hartford, CT

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

  PLEASE do read the posting guide
  and provide commented, minimal, self-contained, reproducible code.




--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus University Medical Center

Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014
Web: http://www.erasmusmc.nl/biostatistiek/

__
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] FW: how to change the margins of a plot area

2011-03-13 Thread Lathouri, Maria
Dear all

I am sorry about that; I thought that since in R csv formats are acceptable, it 
will be here as well. I have attached it in a text format.

I hope now it is better.

Thank you
Maria


From: David Winsemius [dwinsem...@comcast.net]
Sent: 13 March 2011 18:24
To: Lathouri, Maria
Subject: Re: [R] how to change the margins of a plot area

Please read the Posting Guide and note that ".csv" files are NOT
mentioned as one of the acceptable formats for attachments to postings!


On Mar 13, 2011, at 1:00 PM, Lathouri, Maria wrote:

> Dear all
>
> I have attached a file in a csv format, with two variables; the code
> that I am using to plot the boxplots is
>> boxplot(ALKY, CL, ylab="Concentration", lwd=0.7, boxwex=0.4)
>
> I hope this will help.
>
> Thanks
> Maria
>
> 
> From: John Kane [jrkrid...@yahoo.ca]
> Sent: 13 March 2011 13:19
> To: r-help@r-project.org; Lathouri, Maria
> Subject: Re: [R] how to change the margins of a plot area
>
> Hi Maria,
> I think we need some sample data and code to really be ablo to help.
>
> in the meantime have have a look at ?par for general plotting info.
>
> --- On Sun, 3/13/11, Lathouri, Maria 
> wrote:
>
>> From: Lathouri, Maria 
>> Subject: [R] how to change the margins of a plot area
>> To: "r-help@r-project.org" 
>> Received: Sunday, March 13, 2011, 8:15 AM
>> Dear all,
>>
>> I am ploting two boxplot of two chemical variables using
>> the format
>> boxplot(Alkalinity, logAlkalinity, log="y",
>> col=c("lightblue"), lwd=0.6, boxwex=0.3)
>>
>> However when I plot like this, the distance between the two
>> boxplots is very big and as well the distance of each
>> boxplot from the plot area, left and right. How can I
>> minimise that distance between the boxplots and as well the
>> distance of each boxplot from the left and right margin of
>> the plot area?
>>
>> Another question is that when I write in the above
>> ylab="Concentration", I get in the y axis as well in each
>> tick and a number. How can I not have this but only the
>> text?
>>
>> Thank you.
>>
>> Kind regards
>> Maria
>>
>>[[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.

David Winsemius, MD
West Hartford, CTALKYCL
24  17
42  16.8
20  15.2
33  15.8
34  14.7
38  14.8
32  13.2
27  13.3
37  15.7
31  12.7
31  14
35  14.8
30  14.6
31  14.7
34  15.6
39  16
44  15.2
40  14.3
51  17.2
41  16.3
30  12
48  15.1
40  14
46  15.8
33  13.9
44  15.2
33  14.1
33.42520849 14.6906392
31  14.6
31  10.6
49.65524516 15.8163576
49  15
47  14.3
33  13
39  12.5
38  12.8
30  12
30  12.2
29.82656017 14.29424761
34  14.2
34  12.8
56  16
60  17.4
61  18.4
59  15.7
44  15.3
41  16.2
33  13.8
38  13
41  13.5
37  17.1
21  12.8
39  16.1
36.412.5
50.717.1
37.312.1
41.711.9
62.117.5
43.413.8
42  13.5
40  14.1
40.16876216 15.9
36.48094861 16.4
41.4029284  15.5
55.16932486 17
56.74926517 17.2
40.75086976 14.9
57.92527479 15.5
61.0741 16.4
47.58835403 15.8
26.78666719 19.8
29.11069914 18.5
43.89296089 15.7
29.80014395 15.3
45.43326189 17.9
21.52111069 14.8
34.28668871 16.3
51.33203813 15.4
61.16524423 19.1
33.08808335 16
28.45357602 13.1
46.95762322 15
41.2184536  14.6
41.67606216 14
34.53359965 17.6
34.88690373 17.4
34.61562996 15.5
44.29030259 17
39.68692169 16.3
39.43498713 19.5
37.04679913 16.6
58.97385637 16.1
44.08944815 14.9
42.07100781 13.8
40.29932265 15.4
43.10896392 16.6
34.27550906 13.6
28.53052378 11.9
46.85048052 15.9
__
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] using pre-calculated coefficients and LP in coxph()?

2011-03-13 Thread Ravi Varadhan
Like David, I too thought that `offset' is the way to do this.  I was actually 
in the midst of testing the differences between using `offset' and `init' when 
David's email came.  

Here is what I could figure out so far:

1.  If you want to fix only a subset of regressors, but let others be 
estimated, then you must use `offset'.  The `init' approach will not work.

2. Even when all the regressors are fixed (I have to admit that I do not see 
the point of this, like David said), there seems to be a difference in using 
`init' and `offset'.  First of all, we cannot interpret or use the standard 
errors, CIs, abd p-values when iter.max=0.  Secondly, there is major 
disagreement in the predictions between `offset' and `init' with no iterations. 
You can run the following code to verify this:

ans1 <- coxph(Surv(time, status) ~ age + ph.karno, data = lung, init = c(0.05, 
-0.05), iter.max = 0)
ans2 <- coxph(Surv(time, status) ~ offset(0.05*age) + offset(-0.05*ph.karno), 
data = lung)

lp1 <- predict(ans1, type="lp")
lp2 <- predict(ans2, type="lp")

all.equal(lp1, lp2)
> all.equal(lp1, lp2)
[1] "Mean relative difference: 1.463598"

The results from `offset' are correct, i.e. lp2 can be readily verified to be 
equal to 0.05 * (age - ph.karno).  I don't know how lp1 is computed.

Ravi.


Ravi Varadhan, Ph.D.
Assistant Professor,
Division of Geriatric Medicine and Gerontology
School of Medicine
Johns Hopkins University

Ph. (410) 502-2619
email: rvarad...@jhmi.edu


- Original Message -
From: David Winsemius 
Date: Sunday, March 13, 2011 2:29 pm
Subject: Re: [R] using pre-calculated coefficients and LP in coxph()?
To: Dimitris Rizopoulos 
Cc: r-help@r-project.org, Angel Russo 


>  On Mar 13, 2011, at 1:32 PM, Dimitris Rizopoulos wrote:
>  
>  >probably you want to use the 'init' argument and 'iter.max' 
> control-argument of coxph(). For example, for the Lung dataset, we fix 
> the coefficients of age and ph.karno at 0.05 and -0.05, respectively:
>  >
>  >library(survival)
>  >
>  >coxph(Surv(time, status) ~ age + ph.karno, data = lung,
>  >   init = c(0.05, -0.05), iter.max = 0)
>  
>  >
>  >
>  >I hope it helps.
>  >
>  >Best,
>  >Dimitris
>  >
>  >
>  >On 3/13/2011 6:08 PM, Angel Russo wrote:
>  >>I need to force a coxph() function in R to use a pre-calculated set 
> of beta
>  >>coefficients of a gene signature consisting of xx genes and the gene
>  >>expression is also provided of those xx genes.
>  
>  I would have guessed (and that is all one can do without an example 
> and better description of what the setting and goal might be) that the 
> use of the offset capablity in coxph might be needed.
>  
>  -- 
>  David.
>  >>
>  >>If I try to use "coxph()" function in R using just the gene 
> expression data
>  >>alone, the beta coefficients and coxph$linear.predictors will 
> change and I
>  >>need to use the pre-calcuated linear predictor not re-computed 
> using coxph()
>  >>function. The reason is I need to compute a quantity that uses as 
> it's input
>  >>the coxph() output but I need this output to be pre-calculated
>  >>beta-coefficients and linear.predictor.
>  >>
>  >>Any one can show me how to do this in R?
>  >>
>  >>Thanks a lot.
>  
>  David Winsemius, MD
>  West Hartford, CT
>  
>  __
>  R-help@r-project.org mailing list
>  
>  PLEASE do read the posting guide 
>  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] using pre-calculated coefficients and LP in coxph()?

2011-03-13 Thread Angel Russo
Thanks very much Dimitrius and David.

I want to compute CPE using pre-calculated beta-model and linear.predictor
using the following code. I hope it the code is OK. Let me know. I am also
doing some sanity checks.

testc$x <- scores
testc$y <- Surv(testdata$time,testdata$status)
testfit <- coxph(y ~ x, testc, iter.max=0, init=1)
cpe=phcpe(testfit)

Thanks very much again.

-

On Sun, Mar 13, 2011 at 2:28 PM, David Winsemius wrote:

>
> On Mar 13, 2011, at 1:32 PM, Dimitris Rizopoulos wrote:
>
>  probably you want to use the 'init' argument and 'iter.max'
>> control-argument of coxph(). For example, for the Lung dataset, we fix the
>> coefficients of age and ph.karno at 0.05 and -0.05, respectively:
>>
>> library(survival)
>>
>> coxph(Surv(time, status) ~ age + ph.karno, data = lung,
>>   init = c(0.05, -0.05), iter.max = 0)
>>
>
>
>>
>> I hope it helps.
>>
>> Best,
>> Dimitris
>>
>>
>> On 3/13/2011 6:08 PM, Angel Russo wrote:
>>
>>> I need to force a coxph() function in R to use a pre-calculated set of
>>> beta
>>> coefficients of a gene signature consisting of xx genes and the gene
>>> expression is also provided of those xx genes.
>>>
>>
> I would have guessed (and that is all one can do without an example and
> better description of what the setting and goal might be) that the use of
> the offset capablity in coxph might be needed.
>
> --
> David.
>
>
>>> If I try to use "coxph()" function in R using just the gene expression
>>> data
>>> alone, the beta coefficients and coxph$linear.predictors will change and
>>> I
>>> need to use the pre-calcuated linear predictor not re-computed using
>>> coxph()
>>> function. The reason is I need to compute a quantity that uses as it's
>>> input
>>> the coxph() output but I need this output to be pre-calculated
>>> beta-coefficients and linear.predictor.
>>>
>>> Any one can show me how to do this in R?
>>>
>>> Thanks a lot.
>>>
>>
> David Winsemius, MD
> West Hartford, CT
>
>

[[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] pass character vector in instrument field of get.hist.quote function

2011-03-13 Thread David Winsemius


On Mar 13, 2011, at 2:29 PM, algotr8der wrote:

Thank you all. Your solutions work. I suppose it doesnt matter  
whether I use

coredata or not (at least for my current purposes). I have created a
user-defined function and have saved it in a ".R" file in my current  
working
directory. But now I'm not sure how to invoke this function. R  
complains

that it cannot find the function.

If I copy and paste the function code into the R console and call it  
after

that everything works fine. Is there a way to bring that function into
memory by giving a path to its location?


?source


I imagine that I will have many
user-defined functions written in their own '.R' files over time.

Thank you all.



David Winsemius, MD
West Hartford, CT

__
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] chisq.test and cbind

2011-03-13 Thread Simone Santoro

Hi,


This is a mixed conceptual/methodological issue.

I have 3 years and 2 localities, I want to compare the Sex Ratio series between 
the two localities.


I can do it year by year, for instance:


> SR2010<-data.frame(FAO=c(96,52),JUNC=c(60,42))

> SR2010

  FAO JUNC

1  96   60

2  52   42

> chisq.test(SR2010)


Pearson's Chi-squared test with Yates' continuity correction


data:  SR2010 

X-squared = 0.6995, df = 1, p-value = 0.4030


Or perhaps I could be interested 
in testing if there is any difference in SR along my time series (just 
three years), is that correct?:


> data1<-data.frame(Mfao=c(173,96,96),Ffao=c(136,62,52),Mjunc=c(7,26,60),Fjunc=c(5,23,42))

> data1

  Mfao Ffao Mjunc Fjunc

1  173  136 7 5

2   96   622623

3   96   526042

> attach(data1)

> chisq.test(cbind(Mfao,Ffao),cbind(Mjunc,Fjunc))


Pearson's Chi-squared test


data:  cbind(Mfao, Ffao) 

X-squared = 3.4443, df = 2, p-value = 0.1787


Thanks in advance for any response
  
[[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] troubles with logistic regression

2011-03-13 Thread gked
hello everyone,
I working on the dataset for my project in class and got stuck on trying to
run logistic regression. here is my code:
data <- read.csv(file="C:/Users/fieder.data.2000.csv")

# creating subset of men 
fieder.male<-subset(data,data[,8]==1)
unmarried.male<-subset(data,data[,8]==1&data[,6]==1)

# glm fit
agesq.male<-(unmarried.male[,5])^2
male.sqrtincome<-sqrt(unmarried.male[,9])

fieder.male.mar.glm<-glm(as.factor(unmarried.male[,6])~
 factor(fieder.male[,7])+fieder.male[,5]+agesq.male+
  male.sqrtincome,binomial(link="logit") )
par(mfrow=c(1,1))
plot(c(0,300),c(0,1),pch=" ",
   xlab="sqrt income, truncated at 9",
   ylab="modeled probability of being never-married")
junk<- lowess(male.sqrtincome,
  log(fieder.male.mar.glm$fitted.values/
  (1-fieder.male.mar.glm$fitted.values)))
  lines(junk$x,exp(junk$y)/(1+exp(junk$y)))
title(main="probability of never marrying\n males, by sqrt(income)")
points(male.sqrtincome[unmarried.male==0],
  fieder.male.mar.glm$fitted.values[unmarried.male==0],pch=16)
points(male.sqrtincome[unmarried.male==1],
  fieder.male.mar.glm$fitted.values[unmarried.male==1],pch=1)

The error says: 
Error in model.frame.default(formula = as.factor(unmarried.male[, 6]) ~  : 
  variable lengths differ (found for 'factor(fieder.male[, 7])')
 
What does it mean? Where am i making a mistake?
Thank you
P.S. i  am also attaching data file in .csv format
http://r.789695.n4.nabble.com/file/n3352356/fieder.data.2000.csv
fieder.data.2000.csv 

--
View this message in context: 
http://r.789695.n4.nabble.com/troubles-with-logistic-regression-tp3352356p3352356.html
Sent from the R help mailing list archive at Nabble.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.


Re: [R] pass character vector in instrument field of get.hist.quote function

2011-03-13 Thread algotr8der
Thank you all. Your solutions work. I suppose it doesnt matter whether I use
coredata or not (at least for my current purposes). I have created a
user-defined function and have saved it in a ".R" file in my current working
directory. But now I'm not sure how to invoke this function. R complains
that it cannot find the function. 

If I copy and paste the function code into the R console and call it after
that everything works fine. Is there a way to bring that function into
memory by giving a path to its location? I imagine that I will have many
user-defined functions written in their own '.R' files over time. 

Thank you all.





--
View this message in context: 
http://r.789695.n4.nabble.com/pass-character-vector-in-instrument-field-of-get-hist-quote-function-tp3350779p3352344.html
Sent from the R help mailing list archive at Nabble.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.


Re: [R] betareg help

2011-03-13 Thread Achim Zeileis

Ben,

thanks for your analysis...I also just sent a message with some similar 
(and some different) ideas.


On Sun, 13 Mar 2011, Ben Bolker wrote:


  The problem seems to be that the algorithm for coming up with a
starting guess for the phi (dispersion) parameter is getting a negative
number.


Yes, as I had written earlier today for the regression on an intercept 
only.



It's not all that easy to figure this out ...


Indeed. I've already added a better warning and an ad hoc workaround to 
the devel version of betareg.


thx,
Z


The data set is a
little bit nasty (lots of points stacked on the equivalent of (0,0)),
but not pathological.
  I'm cc'ing the maintainer of the package --

adding the lines

 if (sum(phi_y)<0) {
  stop("bad estimated start value for phi: consider setting start
values manually\n",
   "(see ?betareg.control)\n",
   "Estimated starting values for
mean:\n",paste(beta,collapse=","))
   }

at line 162 of betareg.R in the current CRAN version provides
a more informative error message in this case.

 See below for solutions.
=


results <- read.csv2("betareg_tmp.csv")
results$drugcat <- cut(results$drug,c(0,0.005,0.06,0.17))
table(results$drug)
table(results$alcoh)
table(results$cond)
## shows that fairly large fractions of the data are
##  in the lowest category:
## 165/209=0.001 'drug'
## 54/209=0.001 'alcoh'
## 38/209=0.001 'cond'
## so this will be a fairly challenging problem in any case

library(ggplot2)

ggplot(results,aes(x=alcoh,y=cond))+stat_sum(aes(size=..n..),alpha=0.7)+
 facet_wrap(~drugcat)+theme_bw()


library(betareg)
## set phi link to logarithmic
## basic problem (digging through betareg.fit etc.) is
##   that initial estimate of phi, based on
##   linear model of logit(cond) ~ alcoh + cond, is NEGATIVE ...
## doesn't seem to be any way to override this starting value
## brute force

try(gyl<-betareg(cond ~ alcoh + drug, data=results,
link.phi="log"))

## pick through, debugging ... find starting values used

svec <- c(-1.6299469,0.8048446,1.7071124,0)
gyl<-betareg(cond ~ alcoh + drug, data=results,
link.phi="log",
control=betareg.control(start=svec))

## would work fine with more generic starting values

svec2 <- c(qlogis(mean(results$cond)),0,0,0)
gyl2<-betareg(cond ~ alcoh + drug, data=results,
link.phi="log",
control=betareg.control(start=svec2))

## before I got that to work, I also tried this (which
##  will be slower and less efficient but is a useful
## alternative

library(bbmle)

## define a variant parameterization of the beta distribution with
##  m=a/(a+b), phi=(a+b)
dbeta2 <- function(x,m,phi,log=FALSE) {

 a <- m*phi
 b <- phi*(1-m)
 dbeta(x,shape1=a,shape2=b,log=log)
}

m1 <- mle2(cond~dbeta2(m=plogis(mu),phi=exp(logphi)),
parameters=list(mu~alcoh+drug),
data=results,
start=list(mu=qlogis(mean(results$cond)),logphi=0))
summary(m1)
p1 <- profile(m1)
plot(p1,show.points=TRUE)
confint(p1)
confint(m1,method="quad") ## not much difference

coef(m1)
coef(gyl)

On 11-03-13 12:59 PM, Vlatka Matkovic Puljic wrote:

Sorry, here is my data (attached).

2011/3/12 Ben Bolker mailto:bbol...@gmail.com>>

Vlatka Matkovic Puljic  gmail.com
> writes:

   >
   > That was also my first  thought.
   > But I guess  it has something to do with W and phihat
   > (which I'm struggling to check

 Again, it would help to post a reproducible example ...
hard to debug/diagnose by remote control.  If you can't
possibly post the data to the list, or put them on a web
site somewhere, or randomize them a bit so you're not
giving anything away, or find a simulated example that
shows the same problem, you could as a last resort send them
to me.

 Ben Bolker

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




--
**
Vlatka Matkovic Puljic
+32/ 485/ 453340






__
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] using pre-calculated coefficients and LP in coxph()?

2011-03-13 Thread David Winsemius


On Mar 13, 2011, at 1:32 PM, Dimitris Rizopoulos wrote:

probably you want to use the 'init' argument and 'iter.max' control- 
argument of coxph(). For example, for the Lung dataset, we fix the  
coefficients of age and ph.karno at 0.05 and -0.05, respectively:


library(survival)

coxph(Surv(time, status) ~ age + ph.karno, data = lung,
   init = c(0.05, -0.05), iter.max = 0)





I hope it helps.

Best,
Dimitris


On 3/13/2011 6:08 PM, Angel Russo wrote:
I need to force a coxph() function in R to use a pre-calculated set  
of beta

coefficients of a gene signature consisting of xx genes and the gene
expression is also provided of those xx genes.


I would have guessed (and that is all one can do without an example  
and better description of what the setting and goal might be) that the  
use of the offset capablity in coxph might be needed.


--
David.


If I try to use "coxph()" function in R using just the gene  
expression data
alone, the beta coefficients and coxph$linear.predictors will  
change and I
need to use the pre-calcuated linear predictor not re-computed  
using coxph()
function. The reason is I need to compute a quantity that uses as  
it's input

the coxph() output but I need this output to be pre-calculated
beta-coefficients and linear.predictor.

Any one can show me how to do this in R?

Thanks a lot.


David Winsemius, MD
West Hartford, CT

__
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] betareg help

2011-03-13 Thread Achim Zeileis

On Sun, 13 Mar 2011, Vlatka Matkovic Puljic wrote:


http://dl.dropbox.com/u/21595123/Book1.csv


Thanks. As I suspected. Due to the many 0.001 values, the starting value 
selection does not work well. In the development version of betareg() I've 
added a more useful warning message and an ad hoc workaround. Until it's 
available, you need to select your own starting values (as suggested in my 
previous e-mail).


For example:

## data
d <- read.csv2("Book1.csv")

## starting values
cf <- coef(lm(qlogis(cond) ~ alcoh + drug, data = d))

## basic regression model
m <- betareg(cond ~ alcoh + drug, data = d,
  start = list(mean = cf, precision = 1))

## with precision regression
m2 <- betareg(cond ~ alcoh + drug | alcoh + drug, data = d,
  start = list(mean = cf, precision = c(1, 0, 0)))

## estimate only a threshold model
m3 <- glm(factor(cond > 0.001) ~ alcoh + drug, data = d, family = binomial)

All three models show some positive but non-significant association 
between the response and the regressors.


hth,
Z


2011/3/13 David Winsemius 


Nothing came through. You need to read the posting guide.


On Mar 13, 2011, at 12:59 PM, Vlatka Matkovic Puljic wrote:

 Sorry, here is my data (attached).


2011/3/12 Ben Bolker 

 Vlatka Matkovic Puljic  gmail.com> writes:




That was also my first  thought.
But I guess  it has something to do with W and phihat
(which I'm struggling to check



 Again, it would help to post a reproducible example ...
hard to debug/diagnose by remote control.  If you can't
possibly post the data to the list, or put them on a web
site somewhere, or randomize them a bit so you're not
giving anything away, or find a simulated example that
shows the same problem, you could as a last resort send them
to me.

Ben Bolker






David Winsemius, MD
West Hartford, CT





--
**
Vlatka Matkovic Puljic
+32/ 485/ 453340

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


[R] Stepwise Discriminant... in R

2011-03-13 Thread Ty Smith
Hello R list,

I'm looking to do some stepwise discriminant function analysis (DFA) based
on the minimization of Wilks' lambda in R to end up with a composite
signature (of metals "Al","Sb","Bi","Cr","Ba") capable of discriminating
100% of the source factors (LANDUSE: "A","B","C").

The Wilks' lambda portion seems straightforward. I am using the following:

gw_obj <- greedy.wilks(LANDUSE ~ ., data = QRBdfa, niveau = 0.1)
gw_obj

Thus determining the stepwise order of metals.But I can't seem to figure out
how to coerce the DFA to give me an output with the % of factors which each
successive metal (variable) correctly classifies (discriminates). e.g.

StepMetal%correctly classified
1Al25
2Sb   75
3Bi89
4Cr   100

I've worked up a trivial example below. Can anyone offer any suggestions on
how I might go about doing this in R?

I am working in a MAC OS environment with a current version of R.

Many thanks in advance!

Tyler

#Example
library(scatterplot3d)
library(klaR)

Al <-runif(27, 0, 125)
QRBdfa <- as.data.frame(Al)
QRBdfa$LANDUSE <- factor(c("A","A","A","B","B","B","C","C","C"))
QRBdfa$Sb <- runif(27, 0, 1)
QRBdfa$Ba <- runif(27, 0, 235)
QRBdfa$Bi <- runif(27, 0, 0.11)
QRBdfa$Cr <- runif(27, 0, 65)


gw_obj <- greedy.wilks(LANDUSE ~ ., data = QRBdfa, niveau = 0.1)
gw_obj


fit <- lda(LANDUSE ~ Al + Sb + Bi + Cr + Ba, data = QRBdfa)

[[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] betareg help

2011-03-13 Thread Ben Bolker
   The problem seems to be that the algorithm for coming up with a
starting guess for the phi (dispersion) parameter is getting a negative
number.  It's not all that easy to figure this out ... The data set is a
little bit nasty (lots of points stacked on the equivalent of (0,0)),
but not pathological.
   I'm cc'ing the maintainer of the package --

adding the lines

  if (sum(phi_y)<0) {
   stop("bad estimated start value for phi: consider setting start
values manually\n",
"(see ?betareg.control)\n",
"Estimated starting values for
mean:\n",paste(beta,collapse=","))
}

at line 162 of betareg.R in the current CRAN version provides
a more informative error message in this case.

  See below for solutions.
=


results <- read.csv2("betareg_tmp.csv")
results$drugcat <- cut(results$drug,c(0,0.005,0.06,0.17))
table(results$drug)
table(results$alcoh)
table(results$cond)
## shows that fairly large fractions of the data are
##  in the lowest category:
## 165/209=0.001 'drug'
## 54/209=0.001 'alcoh'
## 38/209=0.001 'cond'
## so this will be a fairly challenging problem in any case

library(ggplot2)

ggplot(results,aes(x=alcoh,y=cond))+stat_sum(aes(size=..n..),alpha=0.7)+
  facet_wrap(~drugcat)+theme_bw()


library(betareg)
## set phi link to logarithmic
## basic problem (digging through betareg.fit etc.) is
##   that initial estimate of phi, based on
##   linear model of logit(cond) ~ alcoh + cond, is NEGATIVE ...
## doesn't seem to be any way to override this starting value
## brute force

try(gyl<-betareg(cond ~ alcoh + drug, data=results,
 link.phi="log"))

## pick through, debugging ... find starting values used

svec <- c(-1.6299469,0.8048446,1.7071124,0)
gyl<-betareg(cond ~ alcoh + drug, data=results,
 link.phi="log",
 control=betareg.control(start=svec))

## would work fine with more generic starting values

svec2 <- c(qlogis(mean(results$cond)),0,0,0)
gyl2<-betareg(cond ~ alcoh + drug, data=results,
 link.phi="log",
 control=betareg.control(start=svec2))

## before I got that to work, I also tried this (which
##  will be slower and less efficient but is a useful
## alternative

library(bbmle)

## define a variant parameterization of the beta distribution with
##  m=a/(a+b), phi=(a+b)
dbeta2 <- function(x,m,phi,log=FALSE) {

  a <- m*phi
  b <- phi*(1-m)
  dbeta(x,shape1=a,shape2=b,log=log)
}

m1 <- mle2(cond~dbeta2(m=plogis(mu),phi=exp(logphi)),
 parameters=list(mu~alcoh+drug),
 data=results,
 start=list(mu=qlogis(mean(results$cond)),logphi=0))
summary(m1)
p1 <- profile(m1)
plot(p1,show.points=TRUE)
confint(p1)
confint(m1,method="quad") ## not much difference

coef(m1)
coef(gyl)

On 11-03-13 12:59 PM, Vlatka Matkovic Puljic wrote:
> Sorry, here is my data (attached).
> 
> 2011/3/12 Ben Bolker mailto:bbol...@gmail.com>>
> 
> Vlatka Matkovic Puljic  gmail.com
> > writes:
> 
> >
> > That was also my first  thought.
> > But I guess  it has something to do with W and phihat
> > (which I'm struggling to check
> 
>  Again, it would help to post a reproducible example ...
> hard to debug/diagnose by remote control.  If you can't
> possibly post the data to the list, or put them on a web
> site somewhere, or randomize them a bit so you're not
> giving anything away, or find a simulated example that
> shows the same problem, you could as a last resort send them
> to me.
> 
>  Ben Bolker
> 
> __
> 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.
> 
> 
> 
> 
> -- 
> **
> Vlatka Matkovic Puljic
> +32/ 485/ 453340
>

__
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] using pre-calculated coefficients and LP in coxph()?

2011-03-13 Thread Dimitris Rizopoulos
probably you want to use the 'init' argument and 'iter.max' 
control-argument of coxph(). For example, for the Lung dataset, we fix 
the coefficients of age and ph.karno at 0.05 and -0.05, respectively:


library(survival)

coxph(Surv(time, status) ~ age + ph.karno, data = lung,
init = c(0.05, -0.05), iter.max = 0)


I hope it helps.

Best,
Dimitris


On 3/13/2011 6:08 PM, Angel Russo wrote:

I need to force a coxph() function in R to use a pre-calculated set of beta
coefficients of a gene signature consisting of xx genes and the gene
expression is also provided of those xx genes.

If I try to use "coxph()" function in R using just the gene expression data
alone, the beta coefficients and coxph$linear.predictors will change and I
need to use the pre-calcuated linear predictor not re-computed using coxph()
function. The reason is I need to compute a quantity that uses as it's input
the coxph() output but I need this output to be pre-calculated
beta-coefficients and linear.predictor.

Any one can show me how to do this in R?

Thanks a lot.

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



--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus University Medical Center

Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014
Web: http://www.erasmusmc.nl/biostatistiek/

__
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] betareg help

2011-03-13 Thread Vlatka Matkovic Puljic
http://dl.dropbox.com/u/21595123/Book1.csv

2011/3/13 David Winsemius 

> Nothing came through. You need to read the posting guide.
>
>
> On Mar 13, 2011, at 12:59 PM, Vlatka Matkovic Puljic wrote:
>
>  Sorry, here is my data (attached).
>>
>> 2011/3/12 Ben Bolker 
>>
>>  Vlatka Matkovic Puljic  gmail.com> writes:
>>>
>>>
 That was also my first  thought.
 But I guess  it has something to do with W and phihat
 (which I'm struggling to check

>>>
>>>  Again, it would help to post a reproducible example ...
>>> hard to debug/diagnose by remote control.  If you can't
>>> possibly post the data to the list, or put them on a web
>>> site somewhere, or randomize them a bit so you're not
>>> giving anything away, or find a simulated example that
>>> shows the same problem, you could as a last resort send them
>>> to me.
>>>
>>> Ben Bolker
>>>
>>
>>
>
> David Winsemius, MD
> West Hartford, CT
>
>


-- 
**
Vlatka Matkovic Puljic
+32/ 485/ 453340

[[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] Need Assistance in Stacked Area plot

2011-03-13 Thread Hadley Wickham
You might try sending a reproducible example
(https://github.com/hadley/devtools/wiki/Reproducibility) to the
ggplot2 mailing list.

Hadley

On Wed, Feb 16, 2011 at 8:41 AM, Kishorenalluri
 wrote:
>
> Dear All,
>
> I need the assistance to plot the staked area plot using ggplot2
>
> What i am expecting is to plot in X-axis the time(Shown in column1) from
> range of 0 to 100 seconds, and in the y axis the stable increment in area in
> both directions (less than and greater than zero) for columns 3, 4, 5 (
> Column1, Column2, column3). The example as follows
>        TIME              concentration           Column1
> Column2               Column3
>        0.     0.E+00    0.E+00    0.E+00
> 0.E+00
>        0.     0.E+00    1.06339151E-16 -1.45858050E-21
> -5.91725566E-19
>        0.     5.38792107E-16 1.02157781E-17 -1.64419026E-20
> -7.66233765E-19
>        1.     2.59545931E-15 3.42126227E-18 -1.98776066E-20
> -3.72669548E-19
>        1.     2.91310885E-15    2.81003039E-18   -1.91286265E-20
> -2.38608440E-19
>        2.     3.07852570E-15    2.50631096E-18   -1.81194864E-20
> -1.86739453E-19
>        3.     3.23261641E-15   -5.56403736E-16 -1.77552840E-20
> -1.70484122E-19
>        3.     3.35382008E-15 1.54158070E-17   -2.34217089E-20
> -2.07658923E-19
>        4.     3.82413183E-15   -9.70815457E-13    0.E+00
> -6.79571364E-19
>        4.     5.95542983E-15    6.80013097E-16   -4.50874919E-19
> -2.66777428E-19
>        5.     4.39175250E-14 2.47867332E-15   -1.01608288E-18
> -9.76030255E-19
>        6.     1.38894685E-13    5.61681417E-15   -3.93770327E-18
> -3.49248490E-18
>        6.     3.68692195E-13    1.16035253E-14   -1.41445363E-17
> -1.22159013E-17
>        7.     8.73269040E-13 1.79082686E-14   -3.66076039E-17
> -2.95735768E-17
>        7.     1.76597984E-12    2.12332352E-14   -6.62184833E-17
> -4.70513477E-17
>        8.     2.95030081E-12    2.25656057E-14   -9.60506242E-17
> -5.97356578E-17
>        9.     4.26108735E-12 1.34254419E-14 -1.25090653E-16
> -6.95633425E-17
>        9.     5.63056757E-12    2.32612717E-14 -1.53348074E-16
> -8.54969359E-17
>       10.     7.01928856E-12    2.31851800E-14 -1.82546609E-16
> -1.02043519E-16
>       10.     8.39638583E-12    2.31701226E-14   -2.11755800E-16
> -1.18810066E-16
>       11.     9.76834605E-12 -5.45647674E-13   -2.40796726E-16
> -1.35796249E-16
>       12.     1.11376775E-11   -9.78639513E-13   -2.69731656E-16
> -1.53027433E-16
>       12.     1.25059438E-11    2.32773795E-14   -2.98461854E-16
> -1.70614303E-16
>       13.     1.38742114E-11    2.33364991E-14 -3.27081730E-16
> -1.88394094E-16
>       13.     1.52430947E-11    2.33958407E-14 -3.55573728E-16
> -2.06350128E-16
>       14.     1.66127832E-11    2.34487161E-14 -3.83935678E-16
> -2.24396442E-16
>       15.     1.79830524E-11    2.34906687E-14   -4.12155560E-16
> -2.42441983E-16
>       15.     1.93533963E-11    2.26377072E-14 -4.39950727E-16
> -2.90534988E-16
>       16.     2.06980593E-11    2.17171727E-14   -4.70446135E-16
> -3.56228328E-16
>       16.     2.19820310E-11    1.87207801E-14   -4.98853596E-16
> -4.46861939E-16
>       17.     2.32023004E-11    1.94966974E-14   -5.22695187E-16
> -5.78943073E-16
>       18.     2.43484124E-11    1.78879137E-14   -5.38143362E-16
> -7.87629728E-16
>       18.     2.54003017E-11    3.09723082E-11   -5.36126990E-16
> -1.16329436E-15
>       19.     2.63149519E-11    9.87861573E-15   -4.79610661E-16
> -2.06287085E-15
>       19.     2.69770178E-11   -8.01983206E-14   -6.65787469E-17
> -3.62969106E-15
>       20.     2.50814500E-11    1.40265746E-09   -4.91364111E-17
> -3.37932814E-15
>       21.     2.23899790E-11   -1.55489960E-14   -4.45522315E-17
> -3.35597818E-15
>       21.     2.09705026E-11   -1.20672358E-14   -5.22849137E-17
> -3.35854728E-15
>       22.     1.99397498E-11   -1.67958460E-14   -6.01502858E-17
> -3.24838081E-15
>       22.     1.91117367E-11   -1.08397245E-14   -6.67337987E-17
> -3.01352774E-15
>       23.     1.84409696E-11   -3.92677717E-15   -7.10576594E-17
> -2.67668939E-15
>       24.     1.78951028E-11   -2.97739441E-15   -7.26367637E-17
> -2.28204667E-15
>       24.     1.74505303E-11   -2.59241020E-15   -7.15967013E-17
> -1.88057466E-15
>       25.     1.70886909E-11   -2.22676101E-11   -6.90344927E-17
> -1.51430500E-15
>       25.     1.67938004E-11   -2.43300435E-15   -6.45959094E-17
> -1.20480757E-15
>       26.     1.65527898E-11   -2.00735751E-15   -6.04828745E-17
> -9.62120866E-16
>       27.     1.63547265E-11   -1.67859253E-15   -5.68950146E-17
> -7.80733120E-16
>       27.     1.61904094E-11   -1.41262089E-15   -5.41786960E-17
> -6.51168814E-16
>       28.     1.60527139E-11   -2.49439678E-12   -5.23952425E-17
> -5.62375603E-16
>       28.     1.59360

[R] using pre-calculated coefficients and LP in coxph()?

2011-03-13 Thread Angel Russo
I need to force a coxph() function in R to use a pre-calculated set of beta
coefficients of a gene signature consisting of xx genes and the gene
expression is also provided of those xx genes.

If I try to use "coxph()" function in R using just the gene expression data
alone, the beta coefficients and coxph$linear.predictors will change and I
need to use the pre-calcuated linear predictor not re-computed using coxph()
function. The reason is I need to compute a quantity that uses as it's input
the coxph() output but I need this output to be pre-calculated
beta-coefficients and linear.predictor.

Any one can show me how to do this in R?

Thanks a lot.

[[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] how to change the margins of a plot area

2011-03-13 Thread Lathouri, Maria
Dear all

I have attached a file in a csv format, with two variables; the code that I am 
using to plot the boxplots is 
>boxplot(ALKY, CL, ylab="Concentration", lwd=0.7, boxwex=0.4)

I hope this will help.

Thanks
Maria


From: John Kane [jrkrid...@yahoo.ca]
Sent: 13 March 2011 13:19
To: r-help@r-project.org; Lathouri, Maria
Subject: Re: [R] how to change the margins of a plot area

Hi Maria,
I think we need some sample data and code to really be ablo to help.

in the meantime have have a look at ?par for general plotting info.

--- On Sun, 3/13/11, Lathouri, Maria  wrote:

> From: Lathouri, Maria 
> Subject: [R] how to change the margins of a plot area
> To: "r-help@r-project.org" 
> Received: Sunday, March 13, 2011, 8:15 AM
> Dear all,
>
> I am ploting two boxplot of two chemical variables using
> the format
> boxplot(Alkalinity, logAlkalinity, log="y",
> col=c("lightblue"), lwd=0.6, boxwex=0.3)
>
> However when I plot like this, the distance between the two
> boxplots is very big and as well the distance of each
> boxplot from the plot area, left and right. How can I
> minimise that distance between the boxplots and as well the
> distance of each boxplot from the left and right margin of
> the plot area?
>
> Another question is that when I write in the above
> ylab="Concentration", I get in the y axis as well in each
> tick and a number. How can I not have this but only the
> text?
>
> Thank you.
>
> Kind regards
> Maria
>
> [[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] 'Date' elements within a matrix

2011-03-13 Thread Gabor Grothendieck
On Sun, Mar 13, 2011 at 11:46 AM, Bogaso Christofer
 wrote:
> Thanks everyone for clarifying my query. However I was wondering why that
> Date character is not preserved within a matrix? Why R forcefully changes
> that to numeric? I am especially concerned because as per the definition of
> the matrix, each element needs to be of same class. Is there any other
> example other than Date class which R forcefully changes to some simpler
> class if it placed within a matrix?
>

Actually it is possible although there will be some limitations in how
certain methods treat it:

> dd <- seq(as.Date("2011-01-01"), as.Date("2011-01-09"), by = "day")
> dim(dd) <- c(3, 3)
> dd
[1] "2011-01-01" "2011-01-02" "2011-01-03" "2011-01-04" "2011-01-05"
[6] "2011-01-06" "2011-01-07" "2011-01-08" "2011-01-09"
> dd[1,1]
[1] "2011-01-01"
> dd[1,]
[1] "2011-01-01" "2011-01-04" "2011-01-07"





-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at 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.


Re: [R] betareg help

2011-03-13 Thread Vlatka Matkovic Puljic
Sorry, here is my data (attached).

2011/3/12 Ben Bolker 

> Vlatka Matkovic Puljic  gmail.com> writes:
>
> >
> > That was also my first  thought.
> > But I guess  it has something to do with W and phihat
> > (which I'm struggling to check
>
>   Again, it would help to post a reproducible example ...
> hard to debug/diagnose by remote control.  If you can't
> possibly post the data to the list, or put them on a web
> site somewhere, or randomize them a bit so you're not
> giving anything away, or find a simulated example that
> shows the same problem, you could as a last resort send them
> to me.
>
>  Ben Bolker
>
> __
> 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.
>



-- 
**
Vlatka Matkovic Puljic
+32/ 485/ 453340
__
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] replace with quantile value for a large data frame...

2011-03-13 Thread Dimitris Rizopoulos

one way is the following:

X1 <- c(1:10)
X2 <- c(11:20)
X3 <- c(21:30)
X4 <- c(31:40)
X5 <- c(41:50)
DF <- data.frame(X1, X2, X3, X4, X5)

as.data.frame(sapply(DF, function (x) {
qx <- quantile(x)
cut(x, qx, include.lowest = TRUE,
labels = 1:4)
}))


You may also have a look at function cut2() from package Hmisc.


I hope it helps.

Best,
Dimitris


On 3/13/2011 4:49 PM, Ram H. Sharma wrote:

Dear R-Experts

I am sure this might look simple question for experts, at least is problem
for me. I have a large data frame with over 1000 variables and each have
different distribution( i.e. have different quantile). I want to create a
new grouped data frame, where the new variables where the value falling in
first (<25%), second (25% to<50%), third (50% to<75%) and fourth quantiles
(>75%) are replaced with 1,2,3, 4 respectively. The following example is
just to workout.
# my example:
X1<- c(1:10)


X2<- c(11:20)
X3<- c(21:30)
X4<- c(31:40)
X5<- c(41:50)
dataf<- data.frame(X1, X2, X3, X4, X5)






# my efforts of the last week led me to this point


for (i along(length(dataf[1,]))) {


qntfun<- function (x) {
   XQ<- as.numeric(as.matrix(quantile(x)))
   Q1<- XQ[1]
   Q2<- XQ[2]
   Q3<- XQ[3]
   Q4<- XQ[4]
   for (i in 1:length(x)){
   if (x[i]<  Q2) {
   x[i]<- 1
   } else {
   if ( x[i]>  Q2&  x[i]<  Q3){
   x[i]<- 2
   }   else {
   if ( x[i]>Q3&  x[i]  Q4) {
   x[i]<- 4
   } else{
x[i]<- 0
   }
   }
   }
   }
   }
   }
apply(dataf, 1:length(dataf), qntfun)
  }


# I got error, I can not fix it. I would be glad to see a more slim
solution, but I could not think any.

Thanks in advance for your help.

Ram Sharma

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



--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus University Medical Center

Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014
Web: http://www.erasmusmc.nl/biostatistiek/

__
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] Setting the language of Rs error messages

2011-03-13 Thread Richard M. Heiberger
Yes.

Add that line to your .Rprofile file.  See
?Startup
for full details on initialization of an R session.


On Sun, Mar 13, 2011 at 10:32 AM, Alexx Hardt  wrote:

> Am 13.03.2011 15:13, schrieb Richard M. Heiberger:
>
>  > Sys.setenv(LANG="EN")
>>
>
> Thanks, this is exactly what I was looking for.
>
> Can I somehow configure R to set this variable to EN whenever I start it?
>
>
> __
> 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 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] 'Date' elements within a matrix

2011-03-13 Thread David Winsemius


On Mar 13, 2011, at 11:46 AM, Bogaso Christofer wrote:

Thanks everyone for clarifying my query. However I was wondering why  
that
Date character is not preserved within a matrix? Why R forcefully  
changes
that to numeric? I am especially concerned because as per the  
definition of

the matrix, each element needs to be of same class.


THe help page for `matrix` says that there is coercion with  
`as.vector` and the help page for `as.vector` describes further  
specific defaults for that operation, so I think your mental model of  
what matrix requires may need refinement from a simplistic notion of  
"matrix needs same class".


My reading could be wrong but it appears any vector of a non-atomic  
class is going to be coerced to an atomic class (as well as having any  
names stripped off).


--
David.


Is there any other
example other than Date class which R forcefully changes to some  
simpler

class if it placed within a matrix?

Thanks and regards,


-Original Message-
From: Gabor Grothendieck [mailto:ggrothendi...@gmail.com]
Sent: 12 March 2011 02:46
To: Bogaso Christofer
Cc: r-help@r-project.org
Subject: Re: [R] 'Date' elements within a matrix

On Fri, Mar 11, 2011 at 4:15 PM, Bogaso Christofer
 wrote:

Dear all, when I put date objects (class of 'Date') in a matrix it
becomes
numeric:

dat <- matrix(seq(as.Date("2011-01-01"), as.Date("2011-01-09"),  
by="1

day"), 3)


dat


 [,1]  [,2]  [,3]

[1,] 14975 14978 14981

[2,] 14976 14979 14982

[3,] 14977 14980 14983


class(dat[1,1])


[1] "numeric"



As it could not preserve the 'Date' characteristics after putting my
Date observations, I find it difficult to carry forward further
calculation with Dates. Can somebody help me on how to preserve the
Data properties while storing them within some matrix?


If its important to you to store them in a matrix (as opposed to a  
data

frame) then try storing them in a matrix of lists:


dd <- seq(as.Date("2011-01-01"), as.Date("2011-01-09"), by = "day") m
<- matrix(as.list(dd), 3) m[[1,1]]

[1] "2011-01-01"


--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at 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.


David Winsemius, MD
West Hartford, CT

__
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] Problem implementing 'waldtest' when using 'mlogit' package

2011-03-13 Thread Mark Difford
On Mar 13, 2011; 03:44pm Gaurav Ghosh wrote:

>> I have been working through the examples in one of the vignettes
>> associated with the 'mlogit' 
>> package, 'Kenneth Train's exercises using the mlogit package for R.'  In
>> spite of using the code 
>> unchanged, as well as the data used in the examples, I have been unable
>> to run a Wald test to 
>> test two models.

It strikes me that you may not have given the full facts. I have no problem
with this (using a development version of R). Note that you need to make H
first.

> data("Heating", package = "mlogit")
> H <- mlogit.data(Heating, shape = "wide", choice = "depvar",
+ varying = c(3:12))
> m <- mlogit(depvar ~ ic + oc | 0, H)
> summary(m)

> mc <- mlogit(depvar ~ ic + oc, H, reflevel="hp") 
> mi2 <- mlogit(depvar ~ oc + ic | income, H, reflevel="hp")
> waldtest(mc,mi2)
Wald test

Model 1: depvar ~ ic + oc
Model 2: depvar ~ oc + ic | income
  Res.Df Df  Chisq Pr(>Chisq)
1894 
2890  4 4.6456 0.3256

What does print(mc) and print(mi2) report?

Mark.

> sessionInfo()
R version 2.13.0 Under development (unstable) (2010-10-14 r53299)
Platform: i386-pc-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United
States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C 
 
[5] LC_TIME=English_United States.1252

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

other attached packages:
 [1] mlogit_0.2-1  maxLik_1.0-0  miscTools_0.6-10  lmtest_0.9-27
zoo_1.6-4
 [6] statmod_1.4.9 Formula_1.0-0 rms_3.3-0 Hmisc_3.8-3  
modeltools_0.2-17
[11] mvtnorm_0.9-96survival_2.36-5  

loaded via a namespace (and not attached):
 [1] cluster_1.13.3 coin_1.0-18colorspace_1.0-1   grid_2.13.0   
lattice_0.19-17   
 [6] Matrix_0.999375-47 mboost_2.0-10  party_0.9-1sandwich_2.2-6
tools_2.13.0

--
View this message in context: 
http://r.789695.n4.nabble.com/Problem-implementing-waldtest-when-using-mlogit-package-tp3351904p3351984.html
Sent from the R help mailing list archive at Nabble.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.


Re: [R] Setting the language of Rs error messages

2011-03-13 Thread Alexx Hardt

Am 13.03.2011 15:13, schrieb Richard M. Heiberger:


 > Sys.setenv(LANG="EN")


Thanks, this is exactly what I was looking for.

Can I somehow configure R to set this variable to EN whenever I start it?

__
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] replace with quantile value for a large data frame...

2011-03-13 Thread Ram H. Sharma
Dear R-Experts

I am sure this might look simple question for experts, at least is problem
for me. I have a large data frame with over 1000 variables and each have
different distribution( i.e. have different quantile). I want to create a
new grouped data frame, where the new variables where the value falling in
first (<25%), second (25% to <50%), third (50% to <75%) and fourth quantiles
(>75%) are replaced with 1,2,3, 4 respectively. The following example is
just to workout.
# my example:
   X1 <- c(1:10)

> X2 <- c(11:20)
> X3 <- c(21:30)
> X4 <- c(31:40)
> X5 <- c(41:50)
> dataf <- data.frame(X1, X2, X3, X4, X5)
>



> # my efforts of the last week led me to this point
>
for (i along(length(dataf[1,]))) {

> qntfun <- function (x) {
>   XQ <- as.numeric(as.matrix(quantile(x)))
>   Q1 <- XQ[1]
>   Q2 <- XQ[2]
>   Q3 <- XQ[3]
>   Q4 <- XQ[4]
>   for (i in 1:length(x)){
>   if (x[i] < Q2) {
>   x[i] <- 1
>   } else {
>   if ( x[i] > Q2 & x[i] < Q3){
>   x[i] <- 2
>   }   else {
>   if ( x[i] >Q3 & x[i]x[i] <- 3
>   } else {
>   if (x[i] > Q4) {
>   x[i] <- 4
>   } else{
>x[i] <- 0
>   }
>   }
>   }
>   }
>   }
>   }
> apply(dataf, 1:length(dataf), qntfun)
>  }
>
# I got error, I can not fix it. I would be glad to see a more slim
solution, but I could not think any.

Thanks in advance for your help.

Ram Sharma

[[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] Full floor of offices in JLT for sale

2011-03-13 Thread Konstantin
Full floor of offices in JLT for sale
Building: JBC 2 (opposite DAMAS)
Total size: 10908 sq.ft.
7 offices:
01 – 1502 sq.ft. ;
02 – 1123 sq.ft. ;
03 – 2457 sq.ft. ; 
04 – 2232 sq.ft. ; 
05 - 1123 sq.ft. ; 
06 – 1502 sq.ft. ;
07 – 1093 sq.ft. ; 
9 parking spaces 
Price 550 dhs per sq.ft.
Total price: AED 5.999.400 Net to the owner
For more information please call: 0508928199 Konstantin 
Broker No: 8314
Office No: 244
NOTE: If you do not wish to receive any more emails from us, please reply to 
this email with the subject REMOVE FROM LIST or UNSUBSCRIBE . I am sincerely 
apologize for any possible inconvenience.
[[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] use of ROCR package (ROC curve / AUC value) in a specific case versus integral calculation

2011-03-13 Thread Christine SINOQUET

Hello,

I would like to use the ROCR package to draw ROC curves and compute AUC 
values.


However, in the specific context of my application, the true positive 
rates and false positive rates are already provided by some upstream method.


Of course, I can draw a ROC plot with the following command :

plot(x=FPrate, y=TPrate, "o", xlab="false positive rate", ylab="true 
positive rate", xlim=c(0, 1), ylim=c(0, 1)


but this will bot compute the AUC value.

There are two possibilities :
Either it is possible to use the above parameters - FPrate and TPrate 
vectors- to run the performance function and I would like to know how,



or it is not possible and I have to compute the area under the curve but 
I cannot find on the Web how to perform this, through an R package, 
using the two vectors above, if possible (I would rather not implement 
an integration algorithm).


I thank you in advance for your answer.

Best regards,

Christine Sinoquet

__
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] betareg help

2011-03-13 Thread Achim Zeileis

On Sat, 12 Mar 2011, Vlatka Matkovic Puljic wrote:


Maybe I should include data:


As Ben said previously: The full data would have been more useful.

However, I've had a look at the response and even a regression with an 
intercept only had the same problem.


R> betareg(cond ~ 1, data = results)
Error in optim(par = start, fn = loglikfun, gr = gradfun, method = method, 
: initial value in 'vmmin' is not finite


The reason is that the estimate of the starting value of the precision 
parameter is negative. I'll have a look at whether I can fix that in 
betareg(). For the moment, please simply provide different starting 
values, e.g., you could use the results from an OLS regression for the 
mean and some constant for the precision parameter:


R> cf <- coef(lm(qlogis(cond) ~ 1, data = results))
R> betareg(cond ~ 1, data = results, start = list(mean = cf, precision = 1))

Call:
betareg(formula = cond ~ 1, data = results, start = list(mean = cf, 
precision = 1))


Coefficients (mean model with logit link):
(Intercept)
-0.5829

Phi coefficients (precision model with identity link):
(phi)
1.145

The source of the negative precision estimate seems to stem from the large 
amount of observations with the minimal value 0.001. I suspect that these 
were zeros in the original coding. It may be worth to try a hurdle-type 
model, i.e., adopt a two-part model: (1) model zeros-vs-non-zeros via a 
glm(..., family = binomial). (2) model non-zeros only via betareg().


hth,
Z


results$cond
[1] 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001
[13] 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001
[25] 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001
[37] 0.001 0.001 0.020 0.020 0.020 0.030 0.030 0.050 0.050 0.050 0.050 0.050
[49] 0.050 0.050 0.050 0.050 0.060 0.060 0.060 0.070 0.070 0.070 0.070 0.080
[61] 0.090 0.100 0.100 0.100 0.100 0.100 0.100 0.120 0.120 0.130 0.130 0.140
[73] 0.160 0.160 0.170 0.170 0.180 0.180 0.200 0.200 0.210 0.210 0.210 0.220
[85] 0.230 0.250 0.250 0.250 0.250 0.270 0.280 0.300 0.300 0.300 0.300 0.300
[97] 0.310 0.320 0.330 0.340 0.350 0.350 0.350 0.360 0.400 0.430 0.430 0.450
[109] 0.450 0.450 0.450 0.450 0.450 0.450 0.450 0.450 0.450 0.460 0.470
0.470
[121] 0.470 0.470 0.480 0.490 0.490 0.500 0.500 0.500 0.500 0.500 0.500
0.500
[133] 0.500 0.500 0.500 0.520 0.530 0.550 0.550 0.550 0.560 0.600 0.600
0.600
[145] 0.600 0.600 0.620 0.640 0.650 0.650 0.650 0.650 0.660 0.680 0.680
0.680
[157] 0.680 0.700 0.700 0.700 0.700 0.700 0.700 0.710 0.740 0.750 0.750
0.750
[169] 0.750 0.760 0.760 0.770 0.780 0.800 0.800 0.800 0.800 0.800 0.810
0.820
[181] 0.820 0.830 0.830 0.840 0.850 0.850 0.850 0.850 0.860 0.870 0.870
0.870
[193] 0.900 0.900 0.900 0.900 0.900 0.910 0.920 0.920 0.930 0.930 0.950
0.950
[205] 0.950 0.960 0.980 0.980 0.999

2011/3/12 Vlatka Matkovic Puljic 


Dear R users,

I'm trying to do betareg on my dataset.
Dependent variable is not normally distributed and is proportion (of condom
use (0,1)).
But I'm having problems:

 gyl<-betareg(cond ~ alcoh + drug, data=results)
Error in optim(par = start, fn = loglikfun, gr = gradfun, method = method,
:
initial value in 'vmmin' is not finite

Why is R returning me error in optim()?
What should I do?

In advance, thank you for advice!




--
**
Vlatka Matkovic Puljic
+32/ 485/ 453340





--
**
Vlatka Matkovic Puljic
+32/ 485/ 453340

[[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] 'Date' elements within a matrix

2011-03-13 Thread Bogaso Christofer
Thanks everyone for clarifying my query. However I was wondering why that
Date character is not preserved within a matrix? Why R forcefully changes
that to numeric? I am especially concerned because as per the definition of
the matrix, each element needs to be of same class. Is there any other
example other than Date class which R forcefully changes to some simpler
class if it placed within a matrix?

Thanks and regards,


-Original Message-
From: Gabor Grothendieck [mailto:ggrothendi...@gmail.com] 
Sent: 12 March 2011 02:46
To: Bogaso Christofer
Cc: r-help@r-project.org
Subject: Re: [R] 'Date' elements within a matrix

On Fri, Mar 11, 2011 at 4:15 PM, Bogaso Christofer
 wrote:
> Dear all, when I put date objects (class of 'Date') in a matrix it 
> becomes
> numeric:
>
>> dat <- matrix(seq(as.Date("2011-01-01"), as.Date("2011-01-09"), by="1
> day"), 3)
>
>> dat
>
>      [,1]  [,2]  [,3]
>
> [1,] 14975 14978 14981
>
> [2,] 14976 14979 14982
>
> [3,] 14977 14980 14983
>
>> class(dat[1,1])
>
> [1] "numeric"
>
>
>
> As it could not preserve the 'Date' characteristics after putting my 
> Date observations, I find it difficult to carry forward further 
> calculation with Dates. Can somebody help me on how to preserve the 
> Data properties while storing them within some matrix?

If its important to you to store them in a matrix (as opposed to a data
frame) then try storing them in a matrix of lists:

> dd <- seq(as.Date("2011-01-01"), as.Date("2011-01-09"), by = "day") m 
> <- matrix(as.list(dd), 3) m[[1,1]]
[1] "2011-01-01"


-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at 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.


Re: [R] Problem implementing 'waldtest' when using 'mlogit' package

2011-03-13 Thread Achim Zeileis

On Sun, 13 Mar 2011, Ghosh, Gaurav wrote:


Hi all,

I have been working through the examples in one of the vignettes 
associated with the 'mlogit' package, 'Kenneth Train's exercises using 
the mlogit package for R.' In spite of using the code unchanged, as well 
as the data used in the examples, I have been unable to run a Wald test 
to test two models.


Specifically, I have run the following command, where mc and mi2 are 
fitted models: waldtest(mc,mi2)


The two fitted models are:
mc <- mlogit(depvar ~ ic + oc, H, reflevel="hp")
mi2 <- mlogit(depvar ~ oc + ic | income, H, reflevel="hp")


That's still not the complete code for replicating the problem...please do 
provide reproducible examples as the posting guide asks you!


Using R 2.12.2 and mlogit 0.2-1, I can replicate the results from the 
vignette using


library("mlogit")
data("Heating", package = "mlogit")
H <- mlogit.data(Heating, shape = "wide", choice = "depvar", varying = 3:12)
mc <- mlogit(depvar ~ ic + oc, H, reflevel = "hp")
mi2 <- mlogit(depvar ~ oc + ic | income, H, reflevel = "hp")
waldtest(mc, mi2)


I think that the test is taken from the 'lmtest' package.


The generic is from "lmtest" but the method is provided by "mlogit".


I get the following error message:
Error in terms.default(x) : no terms component


The default method should not be called, there is a terms() method for 
"mlogit" objects. Maybe you're using an old version of mlogit?

Z




I would be grateful for tips on how to proceed.  Thanks in advance.

Best regards,
Gaurav S. Ghosh, Ph.D.,
E.ON Energy Research Centre, Room 01.32,
RWTH Aachen,
Mathieustra?e 6,
D-52074 Aachen, Germany



[[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] Setting the language of Rs error messages

2011-03-13 Thread Richard M. Heiberger
> Sys.setenv(LANG="DE")
> 2+"a"
Fehler in 2 + "a" : nicht-numerisches Argument für binären Operator
> Sys.setenv(LANG="EN")
> 2+"a"
Error in 2 + "a" : non-numeric argument to binary operator
>

On Sun, Mar 13, 2011 at 8:39 AM, Alexx Hardt  wrote:

> Hi,
> My R has been installed on a Ubuntu linux computer in Germany. The error
> messages I get are in German, for example:
>
> In min(magnitudes) : kein nicht-fehlendes Argument für min; gebe Inf zurück
>
> I would like those to be displayed in English, for pasting them into
> google.
> I tried searching for "R language", which brings me a ton of results for..
> well, the R language :)
> "R german english" just resulted in a bunch of dictionaries.
>
> I mostly run R within emacs; I don't know if that is relevant to my
> question.
>
> Can someone tell me how to configure R to speak english to me?
>
> Thanks in advance,
>  Alex
>
> --
> alexx@alexx-fett:~$ vi .emacs
>
> __
> 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 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] Setting the language of Rs error messages

2011-03-13 Thread Alexx Hardt

Hi,
My R has been installed on a Ubuntu linux computer in Germany. The error 
messages I get are in German, for example:


In min(magnitudes) : kein nicht-fehlendes Argument für min; gebe Inf zurück

I would like those to be displayed in English, for pasting them into google.
I tried searching for "R language", which brings me a ton of results 
for.. well, the R language :)

"R german english" just resulted in a bunch of dictionaries.

I mostly run R within emacs; I don't know if that is relevant to my 
question.


Can someone tell me how to configure R to speak english to me?

Thanks in advance,
 Alex

--
alexx@alexx-fett:~$ vi .emacs

__
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] pdf device - different page orientation and different plot sizes

2011-03-13 Thread derek
Hello R,

I would like make single pdf file in which the the pages are are of mixed
format. 
Manual states this code (down). The problem is the second "{}" overwrites
the first "{}", but I want to append them.

require(graphics)
require(stats)
HBA=read.table("file.txt",header =FALSE,sep = "", dec = ",",fileEncoding =
"", encoding = "unknown", skip=19,nrows=400)
attach(HBA)

{
pdf(file ="file.pdf",width=3.2,height=2.5,paper="A4")
par(mfrow=c(4,2))
plot(V1,V2,type = "l")
lines(V29,V30)
plot(V3,V4,type = "l")
lines(V5,V6)   dev.off()
dev.off()
}

{
pdf(file ="file.pdf",width=11,height=7,paper="A4r")
par(mfrow=c(1,1))
plot(V1,V2,type = "l")
lines(V29,V30)
plot(V3,V4,type = "l")
lines(V5,V6)   dev.off()
dev.off()
}



--
View this message in context: 
http://r.789695.n4.nabble.com/pdf-device-different-page-orientation-and-different-plot-sizes-tp3351881p3351881.html
Sent from the R help mailing list archive at Nabble.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.


Re: [R] Gnuplot fit function in R

2011-03-13 Thread Stefan
OK, this helps. Seems to be exactly what I need. Thanks.

Stefan

Am 12.03.2011 um 17:57 schrieb Ben Bolker:

> Stefan  me.com> writes:
> 
> [snip]
> 
>> I'm just wondering if there is a equivalent to the fit function of
>> gnuplot in R?
>> If not, s there any good resource on fitting gaussians into a curve?
> 
> 
>  Try
> 
> ?nls
> ?predict.nls
> 
> __
> 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] A basic question about reshape2

2011-03-13 Thread John Kane
I am not sure about this but I don't see how a melt command helps.

See what 
z = dcast(x, I ~ V, mean)
gives you.


--- On Sun, 3/13/11, Jim & Carolyn Watkins  wrote:

> From: Jim & Carolyn Watkins 
> Subject: [R] A basic question about reshape2
> To: r-help@r-project.org
> Received: Sunday, March 13, 2011, 9:18 AM
> Dear R Community:
> 
>  
> 
> This is a newbie reshare2 question; it starts with read a
> set of data and to
> melt it:
> 
> x = data.frame(I=c("a","b","a","b","b"), V=c(2,4,2,5,7)) 
> 
> y = melt(x, id = 1:1) 
> 
> What is wrong with the final dcast step:
> 
> z = dcast(y, formula = I ~ "variable",  c(length,
> mean, median))

> Will one of you please help me with this problem?




__
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] Problem implementing 'waldtest' when using 'mlogit' package

2011-03-13 Thread Ghosh, Gaurav
Hi all,

I have been working through the examples in one of the vignettes associated 
with the 'mlogit' package, 'Kenneth Train's exercises using the mlogit package 
for R.'  In spite of using the code unchanged, as well as the data used in the 
examples, I have been unable to run a Wald test to test two models.

Specifically, I have run the following command, where mc and mi2 are fitted 
models:
waldtest(mc,mi2)

I think that the test is taken from the 'lmtest' package.  I get the following 
error message:
Error in terms.default(x) : no terms component

The two fitted models are:
mc <- mlogit(depvar ~ ic + oc, H, reflevel="hp")
mi2 <- mlogit(depvar ~ oc + ic | income, H, reflevel="hp")

I would be grateful for tips on how to proceed.  Thanks in advance.

Best regards,
Gaurav S. Ghosh, Ph.D.,
E.ON Energy Research Centre, Room 01.32,
RWTH Aachen,
Mathieustraße 6,
D-52074 Aachen, Germany



[[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] how to change the margins of a plot area

2011-03-13 Thread John Kane
Hi Maria,
I think we need some sample data and code to really be ablo to help.

in the meantime have have a look at ?par for general plotting info.

--- On Sun, 3/13/11, Lathouri, Maria  wrote:

> From: Lathouri, Maria 
> Subject: [R] how to change the margins of a plot area
> To: "r-help@r-project.org" 
> Received: Sunday, March 13, 2011, 8:15 AM
> Dear all,
> 
> I am ploting two boxplot of two chemical variables using
> the format
> boxplot(Alkalinity, logAlkalinity, log="y",
> col=c("lightblue"), lwd=0.6, boxwex=0.3)
> 
> However when I plot like this, the distance between the two
> boxplots is very big and as well the distance of each
> boxplot from the plot area, left and right. How can I
> minimise that distance between the boxplots and as well the
> distance of each boxplot from the left and right margin of
> the plot area?
> 
> Another question is that when I write in the above
> ylab="Concentration", I get in the y axis as well in each
> tick and a number. How can I not have this but only the
> text?
> 
> Thank you.
> 
> Kind regards
> Maria
> 
>     [[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.


[R] A basic question about reshape2

2011-03-13 Thread Jim & Carolyn Watkins
Dear R Community:

 

This is a newbie reshare2 question; it starts with read a set of data and to
melt it:

x = data.frame(I=c("a","b","a","b","b"), V=c(2,4,2,5,7)) 

y = melt(x, id = 1:1) 

 

What is wrong with the final dcast step:

z = dcast(y, formula = I ~ "variable",  c(length, mean, median))

 

Will one of you please help me with this problem?

 

 


[[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] problem with looping formula through table

2011-03-13 Thread herr dittmann
Dear useRs,

I am stuck with a piece of code and hope you could give me some pointers.

My aim is to calculate the lm-regression coefficients of individual stocks 
against an index. I am interested in both the coefficient and the pval. While I 
could do this manually for a select hand full, I hope to scale this up say for 
30+ stocks (DAX-30, FTSE-100 etc.) to eventually have a matrix of coefficients 
and p-values for each individual stock.

First, let's get share prices:

library(tseries)

sie <- get.hist.quote(instrument="SIE.DE", start="2010-01-01", quote="AdjClose")
vow <- get.hist.quote(instrument="VOW.DE", start="2010-01-01", quote="AdjClose")
lin <- get.hist.quote(instrument="LIN.DE", start="2010-01-01", quote="AdjClose")
dax <- get.hist.quote(instrument="^GDAXI", start="2010-01-01", quote="AdjClose")

returns.table <- diff(log(na.omit(merge(dax, lin, sie, vow

My function to get the betas pval is:

B <- function(share,bench){
beta <- summary(lm(share~bench))$coef[2]
pval <- summary(lm(share~bench))$coef[8]
coefs <- t(as.matrix(c(beta, pval), ncol=2, byrow=TRUE))
coefs
}

The function B works fine:

B(returns[,2],returns[,1])

> B(returns[,2],returns[,1])
  [,1] [,2]
[1,] 0.7568787 9.740043e-47


Now, at the following step I am stuck. I am trying to loop through my 
returns.table:

Attempt 1:

for(i in 2:4){result[i] <- B(returns[,i],returns[,1]); result}
Error in result[i] <- B(returns[, i], returns[, 1]) : 
  object 'result' not found


Attempt 2:

for(i in 2:4){print(B(returns[,i],returns[,1]))}
  [,1] [,2]
[1,] 0.7568787 9.740043e-47
 [,1] [,2]
[1,] 1.311835 2.924594e-86
 [,1] [,2]
[1,] 1.023310 1.078007e-30

Attempt 2 gets me a little closer to the desired matrix of coefficient and pval 
by each share.


What am I doing wrong here?

Any pointers most welcome.

Many thanks in advance!

Regards,

Bernd





__
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] Having a problem with choose.files

2011-03-13 Thread Duncan Murdoch

On 11-03-13 7:11 AM, carl.finkbei...@tnsglobal.com wrote:

I am relatively new to R, and am having a problem with the following
snippet of code, and I do not at all understand why it is behaving this
way.  I am running Windows XP, with R 2.12.1.

I copy and paste these 4 lines into the R Console:
   t<-c("a","b","c")
   ans<-select.list(t)
   txtNBS<-winDialogString("NBS","300")
   choose.files()

I click on OK in the Select One dialog, and on OK in the Question
dialog, and then Cancel in the file dialog.  Everything behaves as I
expect it to.  (All 3 of those dialog functions are in the utils
package.)

I then copy and paste these 6 lines defining the function fn, into the R
Console.  Note that the body of the function is exactly the same as the
4 lines above that worked well.
   fn<-function() {
 t<-c("a","b","c")
 ans<-select.list(t)
 txtNBS<-winDialogString("NBS","300")
 choose.files()
   }

When I then invoke this function by typing fn() into the R Console, I
again click OK in the Select One dialog, and on OK in the Question
dialog.  BUT, the file dialog never appears.  Furthermore, if I then
type choose.files() into the R Console, about half the time the file
dialog appears and about half the time it doesn't.

Any help anyone can give me is much appreciated.  I cannot see what I am
doing wrong here.


Looks like a bug in one of those functions.  I'll look into it.

Duncan Murdoch

__
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] R hangs when connected via VPN [incl. minimal example]

2011-03-13 Thread Duncan Murdoch

On 11-03-13 4:34 AM, Marius Hofert wrote:

Dear expeRts,

This is a similar post as on R-SIG-MAC [I didn't receive an answer there; not 
sure if it was the right place to post either].

I'm running R version 2.12.1 (Platform: x86_64-apple-darwin9.8.0/x86_64 
(64-bit))
on a MacBook Pro under Mac OS X 10.6.6. The following minimal example runs fine
under this setup. However, if I am connected to a server via a VPN client
[Cisco AnyConnect; same with Apple's internal VPN connection], then the minimal
example hangs and just does not do anything. The "red button" in the R Console
is dark red [normal behavior if R is running], so R tries to do something, but
cannot succeed. CPU goes up to 100%... Same happens if I start the job from the
command line via R CMD BATCH. What's going on? Is this a known issue?

Cheers,

Marius

library(doSNOW)
library(Rmpi)
library(rlecuyer)
library(foreach)


You're using 4 different contributed packages here. Do you really need 
all of those?  If so, it's going to be hard to debug.


I'd suggest trying to determine the last successful call, and the first 
unsuccessful one, then take this up with the maintainer of the package 
that fails.


Duncan Murdoch



cl<- makeCluster(mpi.universe.size(), type ="MPI")
tmp<- clusterSetupRNG(cl, seed=rep(1,6))
registerDoSNOW(cl)

counter<- 0
res<- foreach(k = 1:1000) %do% {
 counter<- counter + 1
}
tmp<- stopCluster(cl)

unlist(res)
__
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.


[R] how to change the margins of a plot area

2011-03-13 Thread Lathouri, Maria
Dear all,

I am ploting two boxplot of two chemical variables using the format
boxplot(Alkalinity, logAlkalinity, log="y", col=c("lightblue"), lwd=0.6, 
boxwex=0.3)

However when I plot like this, the distance between the two boxplots is very 
big and as well the distance of each boxplot from the plot area, left and 
right. How can I minimise that distance between the boxplots and as well the 
distance of each boxplot from the left and right margin of the plot area?

Another question is that when I write in the above ylab="Concentration", I get 
in the y axis as well in each tick and a number. How can I not have this but 
only the text?

Thank you.

Kind regards
Maria

[[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] Having a problem with choose.files

2011-03-13 Thread Carl.Finkbeiner
I am relatively new to R, and am having a problem with the following
snippet of code, and I do not at all understand why it is behaving this
way.  I am running Windows XP, with R 2.12.1.

I copy and paste these 4 lines into the R Console:
  t<-c("a","b","c")
  ans<-select.list(t)
  txtNBS<-winDialogString("NBS","300")
  choose.files()

I click on OK in the Select One dialog, and on OK in the Question
dialog, and then Cancel in the file dialog.  Everything behaves as I
expect it to.  (All 3 of those dialog functions are in the utils
package.)

I then copy and paste these 6 lines defining the function fn, into the R
Console.  Note that the body of the function is exactly the same as the
4 lines above that worked well.
  fn<-function() {
t<-c("a","b","c")
ans<-select.list(t)
txtNBS<-winDialogString("NBS","300")
choose.files()
  }

When I then invoke this function by typing fn() into the R Console, I
again click OK in the Select One dialog, and on OK in the Question
dialog.  BUT, the file dialog never appears.  Furthermore, if I then
type choose.files() into the R Console, about half the time the file
dialog appears and about half the time it doesn't.  

Any help anyone can give me is much appreciated.  I cannot see what I am
doing wrong here.

Thanks,

Carl Finkbeiner

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

2011-03-13 Thread derek
Nice, thank you.

--
View this message in context: 
http://r.789695.n4.nabble.com/how-to-label-lines-tp3350452p3351605.html
Sent from the R help mailing list archive at Nabble.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.


Re: [R] Merge data under conditions

2011-03-13 Thread flymer
Thanks to both of you for your help! 

Jim, my problem is to match some observations of a time serie (vector 'a' in
my example) with theoretical predictions of this process (vector 'b' in my
example), with a small time lag between them.



--
View this message in context: 
http://r.789695.n4.nabble.com/Merge-data-under-conditions-tp3350864p3351472.html
Sent from the R help mailing list archive at Nabble.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.


Re: [R] Reg : Using R in Web

2011-03-13 Thread Erich Neuwirth
Assuming you are using a Windows based server have a look at
statconnWS at rcom.univie.ac.at
Warning: statconnWS is NOT open source.
It is under development, and it also will work under Linux in the future.
The statconnDCOM server also might be an option for you.
It is available from the same web site.


On 3/13/2011 6:12 AM, Vikram wrote:
> Hi everyone .
> 
> I would like to integrate R with Microsoft Silverlight . I would like to
> know whether we can connect R through any other software . If possible how ?
> Could anyone help me with this
> 
> Thanks
>

__
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] R 2.13.0 scheduled for April 13

2011-03-13 Thread Peter Dalgaard
This is to announce that we plan to release R version 2.13.0 on Wednesday,
April 13, 2011.

Those directly involved should review the generic schedule at
http://developer.r-project.org/release-checklist.html

The source tarballs will be made available daily (barring build
troubles) via

http://cran.r-project.org/src/base-prerelease/

For the R Core Team
Peter Dalgaard

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

___
r-annou...@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-announce

__
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] Lattice: Feature Request

2011-03-13 Thread Deepayan Sarkar
On Sat, Mar 12, 2011 at 1:30 AM, Jim Price  wrote:
> Thanks Peter.
>
> This is true, but consider this continuation of my example (which is
> probably what I should have written originally):
>
>
> my.opts <- list(default.args = list(
>                       as.table = TRUE,
>                                    between = list(x = 0.2, y = 0.2),
>                       scales = list(alternating = 1, tck = c(1, 0), col =
> 'black') # Illustrative, doesn't do anything
>                ))
>
>
> oldopts <- lattice.options(my.opts)
>
> useOuterStrips(xyplot(
>                      resp ~ time | subject * var,
>                      data = temp
>                      ))
>
> lattice.options(oldopts)
>
>
> If the scales option worked like as.table, aspect, etc, then I wouldn't need
> to use a default.scales call per xyplot. Just trying to remove some typing
> from each call that I make.

Your wish is reasonable, but note that there are two kinds of default
arguments handled by lattice.options(): those that are common for all
functions (like "as.table" and "between") and those that are
function-specific, like "panel.xyplot", "panel.bwplot", etc. Adding a
new default of the second kind involves a lot more work (both
implementation and maintenance), and I would be reluctant to do so
unless there is a really good reason. I'm more open to additions of
the first kind.

In this particular case, "default.scales" is really function-specific.
On the other hand, only a few functions (e.g., bwplot, cloud, splom)
have a default value other than list(), so having a global default
(overridden in those few cases) shouldn't be too bad. Of course then
it will not be possible to have, say, an xyplot-specific change,
because the change will also affect densityplot(), histogram(), etc.
If that seems reasonable, please go ahead and send me a patch.

-Deepayan


> Jim.
>
>
>
> Peter Ehlers wrote:
>>
>> On 2011-03-10 15:07, Jim Price wrote:
>> New feature not needed. You'll notice that the 'Details'
>> section of ?xyplot says, regarding lattice.options:
>>
>>    Default values can be set in this manner for the following
>>    arguments: as.table, aspect, between, page, main, sub,
>>    par.strip.text, layout, skip and strip.
>>
>> No mention of 'scales'. But xyplot has an argument
>> 'default.scales' which you can set globally:
>>
>>   def.scal <- list(alternating = 1, tck = c(1, 0))
>>
>> and then add this
>>
>>   default.scales = def.scal
>>
>> to the arguments in your xyplot call.
>>
>>
>> Peter Ehlers

__
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] R hangs when connected via VPN [incl. minimal example]

2011-03-13 Thread Marius Hofert
Dear expeRts,

This is a similar post as on R-SIG-MAC [I didn't receive an answer there; not 
sure if it was the right place to post either]. 

I'm running R version 2.12.1 (Platform: x86_64-apple-darwin9.8.0/x86_64 
(64-bit))
on a MacBook Pro under Mac OS X 10.6.6. The following minimal example runs fine
under this setup. However, if I am connected to a server via a VPN client 
[Cisco AnyConnect; same with Apple's internal VPN connection], then the minimal 
example hangs and just does not do anything. The "red button" in the R Console 
is dark red [normal behavior if R is running], so R tries to do something, but 
cannot succeed. CPU goes up to 100%... Same happens if I start the job from the 
command line via R CMD BATCH. What's going on? Is this a known issue? 

Cheers,

Marius

library(doSNOW) 
library(Rmpi) 
library(rlecuyer) 
library(foreach)

cl <- makeCluster(mpi.universe.size(), type ="MPI") 
tmp <- clusterSetupRNG(cl, seed=rep(1,6)) 
registerDoSNOW(cl)

counter <- 0
res <- foreach(k = 1:1000) %do% {
counter <- counter + 1
}
tmp <- stopCluster(cl)

unlist(res)
__
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 different series for different groups in xyplot

2011-03-13 Thread Dennis Murphy
Hi:

Try this:

xyplot(y ~ x1 | x2 * x3, groups = x4, data = example,
   type= c("l", "p"), pch=c(16, 4), col=c("blue", "red"),
   col.line = c('blue', 'transparent'),
   xlim = c(1.04, 1.26), ylim = c(0, 1.1), xlab = "X2", ylab = "Y",
   key = list(space = "top", text = list("A"),
   points = list(pch=16, col="blue", cex=0.8),
   text = list("B"),
   points = list(pch=4, col="red", cex=0.8)))

I think you had your A and B labels reversed in the legend, but check to be
sure.

HTH,
Dennis

On Sat, Mar 12, 2011 at 10:47 PM, Jie Liu  wrote:

> Hi guys,
>
> I got a problem when I was trying to use lattice to do some plot. Below is
> one working example which can generate one curve for A and one curve for B
> in each subplot. However, I would like to just show the points for B, not
> connecting the dots. As for A, I still want a curve (dots are connected).
> Is
> there any people having any suggestions. Data are attached. Thanks a lot,
>
> --Jerry
>
> library(lattice)
> example <- read.csv("example.txt",header=T)
> xyplot(y~x1|as.factor(x2)*as.factor(x3), groups = as.factor(x4),
> data=example, type="b", pch=c(16,4), col=c("blue","red"),
> xlim=c(1.04,1.26),
> ylim = c(0,1.1), xlab = "X2", ylab = "Y",key = list(space = "top", text =
> list("B"),  points = list(pch=16, col="blue", cex=0.8), text = list("A"),
> points = list(pch=4, col="red", cex=0.8)) )
>
> __
> 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 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.