[R] quantmod's addTA plotting functions

2011-05-04 Thread Russ Abbott
Hi,

I'm having trouble with quantmod's addTA plotting functions.  They seem to
work fine when run from the command line. But when run inside a function,
only the last one run is visible.  Here's an example.


test.addTA <- function(from = "2010-06-01") {
getSymbols("^GSPC", from = from)
GSPC.close <- GSPC[,"GSPC.Close"]
GSPC.EMA.3   <- EMA(GSPC.close, n=3, ratio=NULL)
GSPC.EMA.10  <- EMA(GSPC.close, n=10, ratio=NULL)
chartSeries(GSPC.close, theme=chartTheme('white'), up.col="black",
dn.col="black")
addTA(GSPC.EMA.3,   on = 1, col = "#ff")
addTA(GSPC.EMA.10,  on = 1, col = "#ff")
# browser()
}


When I run this, GSPC.close always appears.  But only GSPC.EMA10 appears on
the plot along with it. If I switch the order of the addTA calls,
only GSPC.EMA3 appears. If I uncomment the call to browser() neither appears
when the browser() interrupt occurs. I can then draw both GSPC.EMA.3 and
GSPC.EMA10 manually, and let the function terminate. All intended plots are
visible after the function terminates. So it isn't as if one wipes out the
other. This shows that it's possible to get all three lines on the plot, but
I can't figure out how to do it without manual intervention. Any suggestions
are appreciated.

Thanks.

*-- Russ *

[[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] best subset regression in R

2011-05-04 Thread Bert Gunter
On Wed, May 4, 2011 at 9:47 AM, FMH  wrote:
> Dear All,
>
> Could someone please give some advice the way to do linear modelling via best 
> subset regression in R?...


Yes. Don't do it.

-- Bert

(Very Brief Explanation: Best subset regression was a questionable
approach to parsimonious modeling largely dictated by the
statistical/computing technology available in the 1960's and 70's. It
should by now be abandoned, buried, and forgotten. Use shrinkage
instead. LARS/LASSO (in the glmnet package) are among the
possibilities. Consult your local statistician for help (after making
sure he/she knows about such approaches, as not all do). Frank
Harrell's "Regresiion Modeling Strategies" is a useful starting point
to learn about this.



>
> Thanks,
> Kagba
>        [[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.
>
>



-- 
"Men by nature long to get on to the ultimate truths, and will often
be impatient with elementary studies or fight shy of them. If it were
possible to reach the ultimate truths without the elementary studies
usually prefixed to them, these would not be preparatory studies but
superfluous diversions."

-- Maimonides (1135-1204)

Bert Gunter
Genentech Nonclinical Biostatistics

__
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] bivariate linear interpolation

2011-05-04 Thread Andrew Robinson
The one that gives results that you trust and uses algorithms that you
understand!

Cheers

Andrew

On Wed, May 04, 2011 at 12:52:03PM +, Halldór Björnsson wrote:
> Hi,
> 
> I have three matrices (X,Y,P) with the same dimension. The X,Y grid is
> regular and I want to
> perform linear interpolation to pick out certain points. In matlab
> appropriate call is
> something like
> 
> Pout=interp2(X,Y,P,Xout,Yout, method="linear")
> 
> where Xout and Yout are the locations where I want the Pout data
> (typically a different grid).
> (Scipy has this routine in interpolate.interp2d, with similar arguments)
> 
> 
> In R there is (as often) the choice between many different
> interpolation routines. Akima has one for irregularly spaced
> data (and does not like co-linearity in the data). Fields has another
> one, with a more complicated arguments.
> 
> What is the best R function that accomplishes this?
> 
> Sincerely
> Halldór
> 
> __
> 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.

-- 
Andrew Robinson  
Program Manager, ACERA 
Department of Mathematics and StatisticsTel: +61-3-8344-6410
University of Melbourne, VIC 3010 Australia   (prefer email)
http://www.ms.unimelb.edu.au/~andrewpr  Fax: +61-3-8344-4599
http://www.acera.unimelb.edu.au/

Forest Analytics with R (Springer, 2011) 
http://www.ms.unimelb.edu.au/FAwR/
Introduction to Scientific Programming and Simulation using R (CRC, 2009): 
http://www.ms.unimelb.edu.au/spuRs/

__
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] SAPPLY function XXXX

2011-05-04 Thread Petr PIKAL
Hi

r-help-boun...@r-project.org napsal dne 04.05.2011 22:26:59:

> Erik Iverson  
> Odeslal: r-help-boun...@r-project.org
> 
> 04.05.2011 22:26
> 
> Komu
> 
> Dan Abner 
> 
> 
> > Ultimately, I would like for this to be 1 conponent in a larger 
function
> > that will produce PROC CONTENTS style output. Something like...
> > 
> > data1.contents<-data.frame(Variable=names(data1),
> >  Class=sapply(data1,class),
> >  n.valid=sapply(data1,sum(!is.na)),
> >  n.miss=sapply(data1,sum(is.na)))
> > data1.contents
> 
> Also meant to mention to see ?describe in the Hmisc package:
> 
> E.g.,
> 
>  > describe(c(NA, 1:10))
> 
> There is also a useful method for data.frame objects.

colSums(is.na(data1))
colSums(!is.na(data1))

may also show number of missing and nonmissing values in data frame.

Regards
Petr

> 
> --Erik
> 
> __
> 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] Uniform Gaussian Kernel

2011-05-04 Thread Andrew Robinson
I can't honestly say that I grasp what you're trying to do, but that
said, I wonder if the curve() function will help you?

Cheers

Andrew


On Wed, May 04, 2011 at 07:30:20AM -0700, blutack wrote:
> I have a vector with lots of different numbers. I need to make a graph
> showing the Uniform Distribution of the figures. I have created a graph
> showing all the different values, but now want individual Gaussian Kernel
> round each point. This is what I have but each time it comes up with an
> error as I have just based it on the Normal Distribution, but I'm not sure
> what I need to change to make it work. Where z is my vector.
> 
> plot(0, 0, xlim=range(0, 300), ylim=range(0, 1), pch=NA,)
> for(i in 1:length(z)) {
>   points(z[i], 0, pch="|")
> }
> 
> x = seq(-10, 10, 0.01)
> for(i in 1:length(z)){
>   std_dev = 1
>   lines(x, dunif(x, z[i], sd = std_dev))
> }
> 
> Any ideas? Thanks.
> 
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/Uniform-Gaussian-Kernel-tp3495742p3495742.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.

-- 
Andrew Robinson  
Program Manager, ACERA 
Department of Mathematics and StatisticsTel: +61-3-8344-6410
University of Melbourne, VIC 3010 Australia   (prefer email)
http://www.ms.unimelb.edu.au/~andrewpr  Fax: +61-3-8344-4599
http://www.acera.unimelb.edu.au/

Forest Analytics with R (Springer, 2011) 
http://www.ms.unimelb.edu.au/FAwR/
Introduction to Scientific Programming and Simulation using R (CRC, 2009): 
http://www.ms.unimelb.edu.au/spuRs/

__
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] split character vector by multiple keywords simultaneously

2011-05-04 Thread Andrew Robinson
A hack would be to use gsub() to prepend e.g. XXX to the keywords that
you want, perform a strsplit() to break the lines into component
strings, and then substr() to extract the pieces that you want from
those strings.

Cheers

Andrew

On Wed, May 04, 2011 at 04:08:40PM -0700, sunny wrote:
> Hi. I have a character vector that looks like this:
> 
> > temp <- c("Company name: The first company General Manager: John Doe I
> > Managers: John Doe II, John Doe III","Company name: The second company
> > General Manager: Jane Doe I","Company name: The third company Managers:
> > Jane Doe II, Jane Doe III")
> > temp
> [1] "Company name: The first company General Manager: John Doe I Managers:
> John Doe II, John Doe III"
> [2] "Company name: The second company General Manager: Jane Doe I"
>
> [3] "Company name: The third company Managers: Jane Doe II, Jane Doe III" 
> 
> I know all the keywords, i.e. "Company name:", "General Manager:",
> "Managers:" etc. I'm looking for a way to split this character vector into
> multiple character vectors, with one column for each keyword and the
> corresponding values for each, i.e.
> 
> Company name  General Manager  Managers
> 1  The first companyJohn Doe IJohn Doe II, John
> Doe III
> 2 The second companyJane Doe I  
> 3  The third company  Jane Doe II,
> Jane Doe III
> 
> I have tried a lot to find something suitable but haven't so far. Any help
> will be greatly appreciated. I am running R-2.12.1 on x86_64 linux.
> 
> Thanks.
> 
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/split-character-vector-by-multiple-keywords-simultaneously-tp3497033p3497033.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.

-- 
Andrew Robinson  
Program Manager, ACERA 
Department of Mathematics and StatisticsTel: +61-3-8344-6410
University of Melbourne, VIC 3010 Australia   (prefer email)
http://www.ms.unimelb.edu.au/~andrewpr  Fax: +61-3-8344-4599
http://www.acera.unimelb.edu.au/

Forest Analytics with R (Springer, 2011) 
http://www.ms.unimelb.edu.au/FAwR/
Introduction to Scientific Programming and Simulation using R (CRC, 2009): 
http://www.ms.unimelb.edu.au/spuRs/

__
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] two-way group mean prediction in survreg with three factors

2011-05-04 Thread Andrew Robinson
I hope not!

Facetiousness aside, the model that you have fit contains C, and,
indeed, an interaction between A and C.  So, the effect of A upon the
response variable depends on the level of C.  The summary you want
must marginalize C somehow, probably by a weighted or unweighted
average across its levels.  What does that summary really mean?  Can
you meaningfully average across the levels of a predictor that is
included in the model as a main and an interaction term?

Best wishes

Andrew

On Wed, May 04, 2011 at 12:24:50PM -0400, Pang Du wrote:
> I'm fitting a regression model for censored data with three categorical
> predictors, say A, B, C.  My final model based on the survreg function is 
> 
> Surv(..) ~ A*(B+C).
> 
> I know the three-way group mean estimates can be computed using the predict
> function. But is there any way to obtain two-way group mean estimates, say
> estimated group mean for (A1, B1)-group?  The sample group means don't
> incorporate censoring and thus may not be appropriate here.
> 
>  
> 
> Pang Du
> 
> Virginia Tech
> 
> 
>   [[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.

-- 
Andrew Robinson  
Program Manager, ACERA 
Department of Mathematics and StatisticsTel: +61-3-8344-6410
University of Melbourne, VIC 3010 Australia   (prefer email)
http://www.ms.unimelb.edu.au/~andrewpr  Fax: +61-3-8344-4599
http://www.acera.unimelb.edu.au/

Forest Analytics with R (Springer, 2011) 
http://www.ms.unimelb.edu.au/FAwR/
Introduction to Scientific Programming and Simulation using R (CRC, 2009): 
http://www.ms.unimelb.edu.au/spuRs/

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

2011-05-04 Thread Andrew Robinson
Hi Paul,

I suggest that you should send us commented, minimal, self-contained,
reproducible code.

That means, in essence, developing the simplest possible
representation of your problem.  In the process of developing the
simplest possible representation, you may learn more about the
problem.  Maybe even solve it.  

Even if you don't, then you enable us to make a much better
contribution, because we can actually try out our suggestions before
sending them.

With what you sent here, all we can do is speculate.

Cheers,

Andrew

On Wed, May 04, 2011 at 04:33:12PM -0400, Paul Ossenbruggen wrote:
> Hi,
> 
>   I am attempting to fit a ARMA/GARCH regression model without success.
> 
>   ### ARIMA-GARCH model with regressor ###
> 
> ### Time series data: A multivariate data set.
> cov.ts.dq = cov.ts[1:4,"dq1"][!is.na(cov.ts[,"dq1"])]
> cov.ts.day = ts.intersect(dq = diff(q.ts), day = lag(q.ts, -1))
> 
> ### The following R scripts work:
> (summary(no.day.fitr <- garchFit(dq ~ arma(0,3) + garch(1,1), data = 
> cov.ts.day)))
> (summary(no.day.fitr2 <- garchFit(dq ~ arma(0,3) + garch(1,1), data = 
> cov.ts.day,
>   include.mean=FALSE)))
> 
> ### ERROR: I add in the regressor "day".
> (summary(no.day.fitr3 <- garchFit(dq ~ day + arma(0,3) + garch(1,1), data = 
> cov.ts.day,
>   include.mean=FALSE)))
> ### Error in .garchArgsParser(formula = formula, data = data, trace = FALSE) 
> : 
> ###  object 'formula.mean' not found
> 
> ### ERROR: 
> day.fitr4 <- garchFit(formula.mean = dq ~ day + arma(0,3),formula.var = 
> ~garch(1,0), data = cov.ts.day,include.mean = FALSE)
> ### Error in garchFit(formula.mean = dq ~ day + arma(0, 3), formula.var = 
> ~garch(1,  : 
> ### Multivariate data inputs require lhs for the formula.
> ### Note: If I remove "day" I obtain the same error message.
>   
>   I would greatly appreciate knowing how to overcome this problem.
> 
>   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.

-- 
Andrew Robinson  
Program Manager, ACERA 
Department of Mathematics and StatisticsTel: +61-3-8344-6410
University of Melbourne, VIC 3010 Australia   (prefer email)
http://www.ms.unimelb.edu.au/~andrewpr  Fax: +61-3-8344-4599
http://www.acera.unimelb.edu.au/

Forest Analytics with R (Springer, 2011) 
http://www.ms.unimelb.edu.au/FAwR/
Introduction to Scientific Programming and Simulation using R (CRC, 2009): 
http://www.ms.unimelb.edu.au/spuRs/

__
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] Obtaining the name of an object XXXX

2011-05-04 Thread Rolf Turner

On 05/05/11 11:16, Dan Abner wrote:

Hello everyone,

How does one write a function to return the name of an input object (that is
assumed to be a data frame) as a character string? I tired using the get(),
but this does not work as I had hoped. For example:

myfn<-function(x){

output<-data.frame(Attribute="Data Set Name",Value=as.character(get(x)))

print(output)

}


foo <- function(x) {
deparse(substitute(x))
}

cheers,

Rolf Turner

__
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] print elements' placings from vector

2011-05-04 Thread derek
Yes, thank you.

--
View this message in context: 
http://r.789695.n4.nabble.com/print-elements-placings-from-vector-tp3496645p3497080.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] split character vector by multiple keywords simultaneously

2011-05-04 Thread sunny
Hi. I have a character vector that looks like this:

> temp <- c("Company name: The first company General Manager: John Doe I
> Managers: John Doe II, John Doe III","Company name: The second company
> General Manager: Jane Doe I","Company name: The third company Managers:
> Jane Doe II, Jane Doe III")
> temp
[1] "Company name: The first company General Manager: John Doe I Managers:
John Doe II, John Doe III"
[2] "Company name: The second company General Manager: Jane Doe I"  
 
[3] "Company name: The third company Managers: Jane Doe II, Jane Doe III" 

I know all the keywords, i.e. "Company name:", "General Manager:",
"Managers:" etc. I'm looking for a way to split this character vector into
multiple character vectors, with one column for each keyword and the
corresponding values for each, i.e.

Company name  General Manager  Managers
1  The first companyJohn Doe IJohn Doe II, John
Doe III
2 The second companyJane Doe I  
3  The third company  Jane Doe II,
Jane Doe III

I have tried a lot to find something suitable but haven't so far. Any help
will be greatly appreciated. I am running R-2.12.1 on x86_64 linux.

Thanks.

--
View this message in context: 
http://r.789695.n4.nabble.com/split-character-vector-by-multiple-keywords-simultaneously-tp3497033p3497033.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] Obtaining the name of an object XXXX

2011-05-04 Thread Dan Abner
Hello everyone,

How does one write a function to return the name of an input object (that is
assumed to be a data frame) as a character string? I tired using the get(),
but this does not work as I had hoped. For example:

myfn<-function(x){

output<-data.frame(Attribute="Data Set Name",Value=as.character(get(x)))

print(output)

}

Thank you!

Dan

[[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] Panels order in lattice graphs

2011-05-04 Thread Andrew Robinson
Hi Cristina,

you can probably hack your own solution using the index.cond argument.

Cheers

Andrew

On Wed, May 04, 2011 at 04:50:53PM +0100, Cristina Silva wrote:
> Hi all,
> 
> In lattice graphs, panels are drawn from left to right and bottom to 
> top. The flag "as.table=TRUE" changes to left to right and top to 
> bottom. Is there any way to change to first top to bottom and then left 
> to right? didn´t find anything neither in Help pages nor Lattice book.
> 
> Cristina
> 
> -- 
> --
> Cristina Silva
> INRB/L-IPIMAR
> Unidade de Recursos Marinhos e Sustentabilidade
> Av. de Brasília, 1449-006 Lisboa
> Portugal
> Tel.: 351 21 3027096
> Fax: 351 21 3015948
> csi...@ipimar.pt
> 
> __
> 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.

-- 
Andrew Robinson  
Program Manager, ACERA 
Department of Mathematics and StatisticsTel: +61-3-8344-6410
University of Melbourne, VIC 3010 Australia   (prefer email)
http://www.ms.unimelb.edu.au/~andrewpr  Fax: +61-3-8344-4599
http://www.acera.unimelb.edu.au/

Forest Analytics with R (Springer, 2011) 
http://www.ms.unimelb.edu.au/FAwR/
Introduction to Scientific Programming and Simulation using R (CRC, 2009): 
http://www.ms.unimelb.edu.au/spuRs/

__
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] Problems saving ff objects

2011-05-04 Thread Andrew Robinson
I wonder if this question should be directed to the package
maintainer?

Best wishes,

Andrew

On Wed, May 04, 2011 at 02:31:51PM +0100, Jannis wrote:
> Just did some more testing.May the problem be due to the fact that I am 
> using a windows machine? I just ran the same code on a Linux machine and 
> everything worked fine.
> 
> If windows (or the file system of the disk) caused the problem, is there any 
> way to resolve it? I know that using Linux would be a better choice ;-) but 
> unfortunatley this in no option at the moment
> 
> 
> Best
> Jannis
> 
> --- Jannis  schrieb am Mi, 4.5.2011:
> 
> > Von: Jannis 
> > Betreff: [R] Problems saving ff objects
> > An: r-help@r-project.org
> > Datum: Mittwoch, 4. Mai, 2011 13:17 Uhr
> > Dear list,
> > 
> > 
> > I am trying to understand and use the ff package. As I had
> > some problems saving some ff objects, and as I did not fully
> > manage to understand the whole concept of *.ff, *.ffData and
> > *.RData with the help of the documentation, I tried to
> > reproduce the examples from the help of ffsave.
> > 
> > When I ran, however : (copied from the help)
> > 
> >  message("let's create some ff objects")
> >   n <- 8e3
> >   a <- ff(sample(n, n, TRUE), vmode="integer",
> > length=n, filename="d:/tmp/a.ff")
> >   b <- ff(sample(255, n, TRUE), vmode="ubyte",
> > length=n, filename="d:/tmp/b.ff")
> >   x <- ff(sample(255, n, TRUE), vmode="ubyte",
> > length=n, filename="d:/tmp/x.ff")
> >   y <- ff(sample(255, n, TRUE), vmode="ubyte",
> > length=n, filename="d:/tmp/y.ff")
> >   z <- ff(sample(255, n, TRUE), vmode="ubyte",
> > length=n, filename="d:/tmp/z.ff")
> >   df <- ffdf(x=x, y=y, z=z)
> >   rm(x,y,z)
> > 
> >   message("save all of them")
> >   ffsave.image("d:/tmp/x")
> > 
> > I get:
> > 
> > Error in ffsave(list = ls(envir = .GlobalEnv, all.names =
> > TRUE), file = outfile,  : 
> >   the previous files do not match the rootpath (case
> > sensitive)
> > 
> > 
> > Whats wrong here? Should this not be working as I did not
> > change anything in the code?
> > 
> > 
> > 
> > Cheers
> > Jannis
> > 
> > 
> > > sessionInfo()
> > R version 2.12.0 (2010-10-15)
> > Platform: i386-pc-mingw32/i386 (32-bit)
> > 
> > locale:
> > [1] LC_COLLATE=English_United States.1252 
> > [2] LC_CTYPE=English_United States.1252   
> > [3] LC_MONETARY=English_United States.1252
> > [4] LC_NUMERIC=C           
> >               
> > [5] LC_TIME=English_United States.1252    
> > 
> > attached base packages:
> > [1] tools     stats 
> >    graphics  grDevices utils 
> >    datasets  methods  
> > [8] base     
> > 
> > other attached packages:
> > [1] ff_2.2-2   bit_1.1-7  rj_0.5.2-1
> > 
> > loaded via a namespace (and not attached):
> > [1] rJava_0.8-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.
> >
> 
> __
> 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.

-- 
Andrew Robinson  
Program Manager, ACERA 
Department of Mathematics and StatisticsTel: +61-3-8344-6410
University of Melbourne, VIC 3010 Australia   (prefer email)
http://www.ms.unimelb.edu.au/~andrewpr  Fax: +61-3-8344-4599
http://www.acera.unimelb.edu.au/

Forest Analytics with R (Springer, 2011) 
http://www.ms.unimelb.edu.au/FAwR/
Introduction to Scientific Programming and Simulation using R (CRC, 2009): 
http://www.ms.unimelb.edu.au/spuRs/

__
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] help with the maxBHHH routine

2011-05-04 Thread Andrew Robinson
Hi Rohit,

actually, the request for simple reproducible code means that you have
to find the simplest possible representation of the problem.  

What happens if you simplify the observation level gradient and the
likelihood function?  Eg to trivial examples?  If you still get the
error, then simplify it futher.  If you get the error with the
simplest possible problem, then share it.  If you don't , then try to
figure out what the changes were that resolved the problem, and scale
those back up to your original problem.

Does that make sense?

Cheers

Andrew


On Thu, May 05, 2011 at 03:22:55AM +0530, Rohit Pandey wrote:
>Hi Andrew, Ravi and Arne,
> 
>Thank you so much for your prompt replies. I see that all of you mention
>the need for simple, reproducible code. I had thought of doing this, but
>the functions I was using for the observation level gradient and
>likelihood function were very long. I will paste them below here.
> 
>Also, sorry for the ambiguity with the "1000's of observations and 821
>parameters" on the one hand and the 10 * 2 matrix on the other. The latter
>is a toy data set and the former is the real data set I ultimately hope to
>apply this routine to once it works. Also, sorry for not mentioning the
>fact that the maxBHHH function I am using is from the maxLik package
>(thanks, Ravi for pointing out).
>So, the code that is giving me the errors is:
>
> maxBHHH(logLikALS4,grad=nuGradientC4,finalHessian="BHHH",start=prm,iterlim=2)
>and
>
> maxBHHH(logLikALS4,grad=nuGradientC4,finalHessian="BHHH",start=prm,iterlim=2)
>Where nuGradientC4 returns a 2*10 matrix and nuGradientC5 a 10*2 matrix
>(there are 10 parameters and 2 observations).
>I have attached the required functions in the .R file.
>These make for some pretty long code, but all you have to do is either
>load the file or paste the contents into your R console (and maybe see
>that they're returning what they're supposed to). I'm sorry I couldn't
>think of a way to come up with a shorter version of this code (I tried my
>best).
> 
>Once you load the file, you should see the following:
> 
>#The observation level likelihood function
>> logLikALS4(prm)
>1 2
>-0.6931472 -0.6931472
> 
>#The observation level gradients
>> nuGradientC4(prm)
>1 2 3 4 5 6 7 8 9 10
>2 -0.3518519 0.3518519 0.000 0 -0.1481481 -0.167 0.1481481
>0.167 0.000 0.000
>4 0.000 -0.3518519 0.3518519 0 0.000 0.000 -0.167
>-0.1481481 0.167 0.1481481
>Warning messages:
>1: In [1]is.na(x) : [2]is.na() applied to non-(list or vector) of type
>'NULL'
>2: In [3]is.na(x) : [4]is.na() applied to non-(list or vector) of type
>'NULL'
> 
>> nuGradientC5(prm)
>2 4
>1 -0.3518519 0.000
>2 0.3518519 -0.3518519
>3 0.000 0.3518519
>4 0.000 0.000
>5 -0.1481481 0.000
>6 -0.167 0.000
>7 0.1481481 -0.167
>8 0.167 -0.1481481
>9 0.000 0.167
>10 0.000 0.1481481
>Warning messages:
>1: In [5]is.na(x) : [6]is.na() applied to non-(list or vector) of type
>'NULL'
>2: In [7]is.na(x) : [8]is.na() applied to non-(list or vector) of type
>'NULL'
> 
>Ignore the warning messages.
> 
>The errors are:
> 
>>
>
> maxBHHH(logLikALS4,grad=nuGradientC4,finalHessian="BHHH",start=prm,iterlim=2)
>Error in checkBhhhGrad(g = gr, theta = theta, analytic = (!is.null(attr(f,
>:
>the matrix returned by the gradient function (argument 'grad') must have
>at least as many rows as the number of parameters (10), where each row
>must correspond to the gradients of the log-likelihood function of an
>individual (independent) observation:
>currently, there are (is) 10 parameter(s) but the gradient matrix has only
>2 row(s)
>In addition: Warning messages:
>1: In [9]is.na(x) : [10]is.na() applied to non-(list or vector) of type
>'NULL'
>2: In [11]is.na(x) : [12]is.na() applied to non-(list or vector) of type
>'NULL'
> 
>and:
> 
>>
>
> maxBHHH(logLikALS4,grad=nuGradientC5,finalHessian="BHHH",start=prm,iterlim=2)
>Error in gr[, fixed] <- NA : (subscript) logical subscript too long
>In addition: Warning messages:
>1: In [13]is.na(x) : [14]is.na() applied to non-(list or vector) of type
>'NULL'
>2: In [15]is.na(x) : [16]is.na() applied to non-(list or vector) of type
>'NULL'
> 
>Again, thanks for your patience and help.
> 
>Rohit
>On Wed, May 4, 2011 at 4:44 AM, Andrew Robinson
><[17]a.robin...@ms.unimelb.edu.au> wrote:
> 
>  I suggest that you provide some commented, minimal, self-contained,
>  reproducible code.
> 
>  Cheers
> 
>  Andrew
>  On Wed, May 04, 2011 at 02:23:29AM +0530, Rohit Pandey wrote:
>  > Hello R community,
>  >
>  > I have been using R's inbuilt maximum likel

Re: [R] combine lattice plot and standard R plot

2011-05-04 Thread Dennis Murphy
Hi:

If it's doable, you'll probably need the gridBase package.
Fortunately, it has a nice vignette to get you started, which tells
you at the end that there are limitations in compatibility between
base and grid graphics (lattice is built on the latter).

HTH,
Dennis

2011/5/4 Lucia Cañas :
> Dear R users,
>
> I would like to combine lattice plot (xyplot) and standard R plot (plot and 
> plotCI) in an unique figure.
>
> I use the function "par()" to combine plot and plotCI and I use the function 
> "print()" to combine xyplot. I tried to use these functions to combine xyplot 
> and plotCI and plots but they do not work. Does anybody know how I can do 
> this?
>
> Thank you very much in advance.
>
>
>
>
> Lucía Cañás Ferreiro
>
> Instituto Español de Oceanografía
> Centro Oceanográfico de A coruña
> Paseo Marítimo Alcalde Francisco Vázquez, 10
> 15001 - A Coruña, Spain
>
> Tel: +34 981 218151  Fax: +34 981 229077
> lucia.ca...@co.ieo.es
> http://www.ieo.es
>
>
>
>        [[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] how to replace all variable values?

2011-05-04 Thread Dennis Murphy
Hi:

> x1 <- 1:5
> x2 <- 6:10
> x3 <- c(1, 2, 5)
> x4 <- 3
> x5 <- 4
> x2[x1 %in% x3]
[1]  6  7 10
> x2[x1 %in% x4]
[1] 8
> x2[x1 %in% x5]
[1] 9


HTH,
Dennis

On Wed, May 4, 2011 at 2:20 PM, blue100  wrote:
> dear all,
>
> Im a complete R newby with the following question.
>
> I have a dataset where my variable values are incorrectly numbered. it has
> to be something like this
>
> Where x is variable name, y=actual value which must become corresponding
> z-value
>
> x3      x4      x5                                      x3      x4      x5
> y1      y3      y4                                      z1      z3      z4
> y2                              must become             z2
> y5                                                      z5
>
> The y and z variables are matched by:
>
> x1      x2
> y1      z1
> y2      z2
> y3      z3
> y4      z4
> y5      z5
>
> Anybody any suggestion? All help is very much appreciated..
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/how-to-replace-all-variable-values-tp3496838p3496838.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] print elements' placings from vector

2011-05-04 Thread Dennis Murphy
Hi:

Is this what you're after?

> z=c(1,3,0.5,6,8,10,2,2,3,4,7,3)
> which(z > 2)
[1]  2  4  5  6  9 10 11 12

HTH,
Dennis

On Wed, May 4, 2011 at 1:02 PM, derek  wrote:
> Dear R,
>
> Here is a code:
> z=c(1,3,0.5,6,8,10,2,2,3,4,7,3)
> z[z>2]
>
> I dont want print the elements, but theirs placings in vector.
>
>
>
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/print-elements-placings-from-vector-tp3496645p3496645.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] best subset regression in R

2011-05-04 Thread Frank Harrell
Beware - this approach is a statistical train wreck.  Been there, done that. 
If all you want is "an" answer it will save you a lot of time thinking,
however.
Frank


FMH-4 wrote:
> 
> Dear All,
>  
> Could someone please give some advice the way to do linear modelling via
> best subset regression in R? I'd really appreciate for your kindness.
>  
> Thanks,
> Kagba
>   [[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.
> 


-
Frank Harrell
Department of Biostatistics, Vanderbilt University
--
View this message in context: 
http://r.789695.n4.nabble.com/best-subset-regression-in-R-tp3496671p3496981.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] Box-Cox transformation in R

2011-05-04 Thread Dennis Murphy
Hi:

Start here:

library(sos)# Install first if necessary
findFn('Box-Cox')

This search finds 131 matches; the basic Box-Cox transformations for
regression are found in the MASS and car packages. For other
situations, consult the packages and functions identified from the sos
search.

HTH,
Dennis

On Wed, May 4, 2011 at 9:53 AM, FMH  wrote:
> Hi,
>
> Could any one please help how I can transform data based on Box-Cox 
> Transformations in R.
>
> Any helps will be much appreciated.
>
> thanks,
> Kagba
>        [[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] combine lattice plot and standard R plot

2011-05-04 Thread Abhijit Dasgupta
Hi,

All of the components in the grid.arrange statement are from ggplot2 and 
lattice, which are both in turn based on the grid package. What 
grid.arrange is able to do is use the grid framework to arrange the 
individual plots on a page. The base graphics are not based on grid, and 
so won't work (afaik) with grid.arrange

Abhijit
On 5/4/2011 2:47 PM, Scott Chamberlain wrote:
> What about the example in gridExtra package:
>
> require(ggplot2); require(lattice); require(gridExtra)
> grid.arrange(qplot(1:10), xyplot(1:10~1:10), tableGrob(head(iris)), nrow=2, 
> as.table=TRUE, main="test main", sub=textGrob("test sub", gp=gpar(font=2)))
> On Wednesday, May 4, 2011 at 1:44 PM, Jonathan Daily wrote:
> If you read the help documentation, lattice is not really compatible
>> with standard graphics.
>>
>> library("lattice")
>> ?lattice
>>
>> 2011/5/4 Lucia Cañas:
>>> Dear R users,
>>>
>>> I would like to combine lattice plot (xyplot) and standard R plot (plot and 
>>> plotCI) in an unique figure.
>>>
>>> I use the function "par()" to combine plot and plotCI and I use the 
>>> function "print()" to combine xyplot. I tried to use these functions to 
>>> combine xyplot and plotCI and plots but they do not work. Does anybody know 
>>> how I can do this?
>>>
>>> Thank you very much in advance.
>>>
>>>
>>>
>>>
>>> Lucía Cañás Ferreiro
>>>
>>> Instituto Español de Oceanografía
>>> Centro Oceanográfico de A coruña
>>> Paseo Marítimo Alcalde Francisco Vázquez, 10
>>> 15001 - A Coruña, Spain
>>>
>>> Tel: +34 981 218151 Fax: +34 981 229077
>>> lucia.ca...@co.ieo.es
>>> http://www.ieo.es
>>>
>>>
>>>
>>> [[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.
>>
>>
>> -- 
>> ===
>> Jon Daily
>> Technician
>> ===
>> #!/usr/bin/env outside
>> # It's great, trust me.
>>
>> __
>> 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.

[[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] how to replace all variable values?

2011-05-04 Thread blue100
dear all,

Im a complete R newby with the following question.

I have a dataset where my variable values are incorrectly numbered. it has
to be something like this

Where x is variable name, y=actual value which must become corresponding
z-value

x3  x4  x5  x3  x4  x5
y1  y3  y4  z1  z3  z4
y2  must become z2
y5  z5

The y and z variables are matched by:

x1  x2  
y1  z1  
y2  z2  
y3  z3  
y4  z4
y5  z5

Anybody any suggestion? All help is very much appreciated..

--
View this message in context: 
http://r.789695.n4.nabble.com/how-to-replace-all-variable-values-tp3496838p3496838.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] fGarch

2011-05-04 Thread Paul Ossenbruggen
Hi,

I am attempting to fit a ARMA/GARCH regression model without success.

### ARIMA-GARCH model with regressor ###

### Time series data: A multivariate data set.
cov.ts.dq = cov.ts[1:4,"dq1"][!is.na(cov.ts[,"dq1"])]
cov.ts.day = ts.intersect(dq = diff(q.ts), day = lag(q.ts, -1))

### The following R scripts work:
(summary(no.day.fitr <- garchFit(dq ~ arma(0,3) + garch(1,1), data = 
cov.ts.day)))
(summary(no.day.fitr2 <- garchFit(dq ~ arma(0,3) + garch(1,1), data = 
cov.ts.day,
include.mean=FALSE)))

### ERROR: I add in the regressor "day".
(summary(no.day.fitr3 <- garchFit(dq ~ day + arma(0,3) + garch(1,1), data = 
cov.ts.day,
include.mean=FALSE)))
### Error in .garchArgsParser(formula = formula, data = data, trace = FALSE) : 
###  object 'formula.mean' not found

### ERROR: 
day.fitr4 <- garchFit(formula.mean = dq ~ day + arma(0,3),formula.var = 
~garch(1,0), data = cov.ts.day,include.mean = FALSE)
### Error in garchFit(formula.mean = dq ~ day + arma(0, 3), formula.var = 
~garch(1,  : 
### Multivariate data inputs require lhs for the formula.
### Note: If I remove "day" I obtain the same error message.

I would greatly appreciate knowing how to overcome this problem.

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.


[R] print elements' placings from vector

2011-05-04 Thread derek
Dear R,

Here is a code:
z=c(1,3,0.5,6,8,10,2,2,3,4,7,3)
z[z>2]

I dont want print the elements, but theirs placings in vector.




--
View this message in context: 
http://r.789695.n4.nabble.com/print-elements-placings-from-vector-tp3496645p3496645.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] ANOVA 1 too few degrees of freedom

2011-05-04 Thread Rovinpiper
And I responded as follows:

Hi,

Thanks for your advice. I tried using table() to check for missing
data. Here are the results:

> table(Combined.Plot)

Combined.Plot

 60m   A1   B1   B3   B4   C5   C9   D2   D9 F60m   F8   Q7
 34 34   3434   343434   3434   34  34   34

> table(Combined.Day)

Combined.Day

  1 2.5  7.5   8.5  10.5 12.5 14.5 17.5 18.5 19.5 21.5 24.5 29.5
32.5 37.5 50.5 79.5
  24   2424   24242424   242424   24   24
24 24 24 24 24

So this seems to indicate that I have what I want. I have two
respiration data points at each plot on each day.

I set this data up so that I could make comparisons of all of the
samples on the same day. That's why I have numbers like 2.5.

I also made a table for comparison of Combined.Day and Combined.Plot.

> cbind(Combined.Day, Combined.Plot)
Combined.Day Combined.Plot
1"1"  "60m"
2.5  "2.5""60m"
7.5  "7.5""60m"
8.5  "8.5""60m"
10.5 "10.5"   "60m"
12.5 "12.5"   "60m"
14.5 "14.5"   "60m"
17.5 "17.5"   "60m"
18.5 "18.5"   "60m"
19.5 "19.5"   "60m"
21.5 "21.5"   "60m"
24.5 "24.5"   "60m"
29.5 "29.5"   "60m"
32.5 "32.5"   "60m"
37.5 "37.5"   "60m"
50.5 "50.5"   "60m"
79.5 "79.5"   "60m"
1"1"  "A1"
2.5  "2.5""A1"
7.5  "7.5""A1"
8.5  "8.5""A1"
10.5 "10.5"   "A1"
12.5 "12.5"   "A1"
14.5 "14.5"   "A1"
17.5 "17.5"   "A1"
18.5 "18.5"   "A1"
19.5 "19.5"   "A1"
21.5 "21.5"   "A1"
24.5 "24.5"   "A1"
29.5 "29.5"   "A1"
32.5 "32.5"   "A1"
37.5 "37.5"   "A1"
50.5 "50.5"   "A1"
79.5 "79.5"   "A1"
1"1"  "B1"
2.5  "2.5""B1"
7.5  "7.5""B1"
8.5  "8.5""B1"
10.5 "10.5"   "B1"
12.5 "12.5"   "B1"
14.5 "14.5"   "B1"
17.5 "17.5"   "B1"
18.5 "18.5"   "B1"
19.5 "19.5"   "B1"
21.5 "21.5"   "B1"
24.5 "24.5"   "B1"
29.5 "29.5"   "B1"
32.5 "32.5"   "B1"
37.5 "37.5"   "B1"
50.5 "50.5"   "B1"
79.5 "79.5"   "B1"
1"1"  "B3"
2.5  "2.5""B3"
7.5  "7.5""B3"
8.5  "8.5""B3"
10.5 "10.5"   "B3"
12.5 "12.5"   "B3"
14.5 "14.5"   "B3"
17.5 "17.5"   "B3"
18.5 "18.5"   "B3"
19.5 "19.5"   "B3"
21.5 "21.5"   "B3"
24.5 "24.5"   "B3"
29.5 "29.5"   "B3"
32.5 "32.5"   "B3"
37.5 "37.5"   "B3"
50.5 "50.5"   "B3"
79.5 "79.5"   "B3"
1"1"  "B4"
2.5  "2.5""B4"
7.5  "7.5""B4"
8.5  "8.5""B4"
10.5 "10.5"   "B4"
12.5 "12.5"   "B4"
14.5 "14.5"   "B4"
17.5 "17.5"   "B4"
18.5 "18.5"   "B4"
19.5 "19.5"   "B4"
21.5 "21.5"   "B4"
24.5 "24.5"   "B4"
29.5 "29.5"   "B4"
32.5 "32.5"   "B4"
37.5 "37.5"   "B4"
50.5 "50.5"   "B4"
79.5 "79.5"   "B4"
1"1"  "C5"
2.5  "2.5""C5"
7.5  "7.5""C5"
8.5  "8.5""C5"
10.5 "10.5"   "C5"
12.5 "12.5"   "C5"
14.5 "14.5"   "C5"
17.5 "17.5"   "C5"
18.5 "18.5"   "C5"
19.5 "19.5"   "C5"
21.5 "21.5"   "C5"
24.5 "24.5"   "C5"
29.5 "29.5"   "C5"
32.5 "32.5"   "C5"
37.5 "37.5"   "C5"
50.5 "50.5"   "C5"
79.5 "79.5"   "C5"
1"1"  "C9"
2.5  "2.5""C9"
7.5  "7.5""C9"
8.5  "8.5""C9"
10.5 "10.5"   "C9"
12.5 "12.5"   "C9"
14.5 "14.5"   "C9"
17.5 "17.5"   "C9"
18.5 "18.5"   "C9"
19.5 "19.5"   "C9"
21.5 "21.5"   "C9"
24.5 "24.5"   "C9"
29.5 "29.5"   "C9"
32.5 "32.5"   "C9"
37.5 "37.5"   "C9"
50.5 "50.5"   "C9"
79.5 "79.5"   "C9"
1"1"  "D2"
2.5  "2.5""D2"
7.5  "7.5""D2"
8.5  "8.5""D2"
10.5 "10.5"   "D2"
12.5 "12.5"   "D2"
14.5 "14.5"   "D2"
17.5 "17.5"   "D2"
18.5 "18.5"   "D2"
19.5 "19.5"   "D2"
21.5 "21.5"   "D2"
24.5 "24.5"   "D2"
29.5 "29.5"   "D2"
32.5 "32.5"   "D2"
37.5 "37.5"   "D2"
50.5 "50.5"   "D2"
79.5 "79.5"   "D2"
1"1"  "D9"
2.5  "2.5""D9"
7.5  "7.5""D9"
8.5  "8.5""D9"
10.5 "10.5"   "D9"
12.5 "12.5"   "D9"
14.5 "14.5"   "D9"
17.5 "17.5"   "D9"
18.5 "18.5"   "D9"
19.5 "19.5"   "D9"
21.5 "21.5"   "D9"
24.5 "24.5"   "D9"
29.5 "29.5"   "D9"
32.5 "32.5"   "D9"
37.5 "37.5"   "D9"
50.5 "50.5"   "D9"
79.5 "79.5"   "D9"
1"1"  "F60m"
2.5  "2.5""F60m"
7.5  "7.5""F60m"
8.5  "8.5""F60m"
10.5 "10.5"   "F60m"
12.5 "12.5"   "F60m"
14.5 "14.5"   "F60m"
17.5 "17.5"   "F60m"
18.5 "18.5"   "F60m"
19.5 "19.5"   "F60m"
21.5 "21.5"   "F60m"
24.5 "24.5"   "F60m"
29.5 "29.5"   "F60m"
32.5 "32.5"   "F60m"
37.5 "37.5"   "F60m"
50.5 "50.5"   "F60m"
79.5 "79.5"   "F60m"
1"1"  "F8"
2.5  "2.5""F8"
7.5  "7.5""F8"
8.5  "8.5""F8"
10.5 "10.5"   "F8"
12.5 "12.5"   "F8"
14.5 "14.5"   

Re: [R] merging multiple columns from two dataframes

2011-05-04 Thread Scott Chamberlain
 merge(dat, pheno, by.x = "sid", by.y = "sen")


Scott
On Wednesday, May 4, 2011 at 12:53 PM, 1Rnwb wrote: 
> Hello,
> 
> I have data in a dataframe with 139104 rows which is multiple of 96x1449. i
> have a phenotype file which contains the phenotype information for the 96
> samples. the snp name is repeated 1449X96 samples. I haveto merge the two
> dataframes based on sid and sen. this is how my two dataframes look like
>  dat<-data.frame(snpname=rep(letters[1:12],12),sid=rep(1:12,each=12), 
>  genotype=rep(c('aa','ab','bb'), 12))
>  pheno<-data.frame(sen=1:12,disease=rep(c('N','Y'),6), wellid=1:12)
> 
> I have to merge or add the disease column and 3 other columns to the data
> file. I am unable to use merge in R. I have searched google, i guess i am
> not hitting the correct terms to get the answer. I would appreciate any
> input on this issue. thanks
> sharad
> 
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/merging-multiple-columns-from-two-dataframes-tp3496341p3496341.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.
> 

[[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] ANOVA 1 too few degrees of freedom

2011-05-04 Thread Rovinpiper
This response went to my email:

Without your data it's hard to say, but one possibility is that your
plots are nested within treatments instead of crossed, or that you have
something rather more cunning going on involving the Days. For example
if you had 8 days for six of your plots and another 8 days for the
remaining 6 plots, you may find that the total degrees of freedom aren't
quite what you expected, as those subgroups need an intercept each. (I
had this for a replicated latin square design - but I have to say that
my problem then was that lm() gavbe me too many df and an apparently
unbalanced design - I had to add the superset factor manually to get it
right)

Another possibility is that one of your plots has no data; try
table(Combined.Plot) to check.



--
View this message in context: 
http://r.789695.n4.nabble.com/ANOVA-1-too-few-degrees-of-freedom-tp3493349p3496870.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] Bigining with a Program of SVR

2011-05-04 Thread ypriverol
How can I apply feature selection with caret and support vector regression. 
 

--
View this message in context: 
http://r.789695.n4.nabble.com/Bigining-with-a-Program-of-SVR-tp3484476p3496685.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] SAPPLY function XXXX

2011-05-04 Thread Dan Abner
Perfect Erik! Thank you!



On Wed, May 4, 2011 at 4:22 PM, Erik Iverson  wrote:

> Dan,
>
>
>
> I am attempting to write a function to count the number of non-missing
>> values of each column in a data frame using the sapply function. I have
>> the
>> following code which is receiving the error message below.
>>
>>
>> n.valid<-sapply(data1,sum(!is.na))
>>>
>> Error in !is.na : invalid argument type
>>
>
> That's the FUN argument to sapply, which expects a function.  is.na is
> indeed a function, but !is.na is not a function:
>
>
> > !is.na
> Error in !is.na : invalid argument type
>
> You need to write your own function to do what you want. Luckily this is
> easy. Let's write one to count the number of missing values in a vector.
>
> countNAs <- function(x) {
>   sum(!is.na(x))
> }
>
> Now you have a function that does what you want, so you can use sapply with
> it.
>
> sapply(data1, countNAs)
>
> You could also do an anonymous (unnamed) function within sapply to the same
> effect.
>
> sapply(data1, function(x) sum(!is.na(x)))
>
> NB: none of this is tested!
>
> --Erik
>
>
>
>> Ultimately, I would like for this to be 1 conponent in a larger function
>> that will produce PROC CONTENTS style output. Something like...
>>
>> data1.contents<-data.frame(Variable=names(data1),
>>  Class=sapply(data1,class),
>>  n.valid=sapply(data1,sum(!is.na)),
>>  n.miss=sapply(data1,sum(is.na)))
>> data1.contents
>>
>> Any suggestions/assistance are appreciated.
>>
>> Thank you,
>>
>> Daniel
>>
>>[[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>

[[alternative HTML version 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] help with the maxBHHH routine

2011-05-04 Thread Rohit Pandey
Hi Andrew, Ravi and Arne,

Thank you so much for your prompt replies. I see that all of you mention the
need for simple, reproducible code. I had thought of doing this, but the
functions I was using for the observation level gradient and likelihood
function were very long. I will paste them below here.

Also, sorry for the ambiguity with the "1000's of observations and 821
parameters" on the one hand and the 10 * 2 matrix on the other. The latter
is a toy data set and the former is the real data set I ultimately hope to
apply this routine to once it works. Also, sorry for not mentioning the fact
that the maxBHHH function I am using is from the maxLik package (thanks,
Ravi for pointing out).

So, the code that is giving me the errors is:

maxBHHH(logLikALS4,grad=nuGradientC4,finalHessian="BHHH",start=prm,iterlim=2)

and

maxBHHH(logLikALS4,grad=nuGradientC4,finalHessian="BHHH",start=prm,iterlim=2)
Where nuGradientC4 returns a 2*10 matrix and nuGradientC5 a 10*2 matrix
(there are 10 parameters and 2 observations).

I have attached the required functions in the .R file.

These make for some pretty long code, but all you have to do is either load
the file or paste the contents into your R console (and maybe see that
they're returning what they're supposed to). I'm sorry I couldn't think of a
way to come up with a shorter version of this code (I tried my best).

Once you load the file, you should see the following:


#The observation level likelihood function
> logLikALS4(prm)
 1  2
-0.6931472 -0.6931472

#The observation level gradients
> nuGradientC4(prm)
   1  2 3 4  5  6
7  8 910
2 -0.3518519  0.3518519 0.000 0 -0.1481481 -0.167  0.1481481
0.167 0.000 0.000
4  0.000 -0.3518519 0.3518519 0  0.000  0.000 -0.167
-0.1481481 0.167 0.1481481
Warning messages:
1: In is.na(x) : is.na() applied to non-(list or vector) of type 'NULL'
2: In is.na(x) : is.na() applied to non-(list or vector) of type 'NULL'


> nuGradientC5(prm)
2  4
1  -0.3518519  0.000
2   0.3518519 -0.3518519
3   0.000  0.3518519
4   0.000  0.000
5  -0.1481481  0.000
6  -0.167  0.000
7   0.1481481 -0.167
8   0.167 -0.1481481
9   0.000  0.167
10  0.000  0.1481481
Warning messages:
1: In is.na(x) : is.na() applied to non-(list or vector) of type 'NULL'
2: In is.na(x) : is.na() applied to non-(list or vector) of type 'NULL'

Ignore the warning messages.

The errors are:

>
maxBHHH(logLikALS4,grad=nuGradientC4,finalHessian="BHHH",start=prm,iterlim=2)
Error in checkBhhhGrad(g = gr, theta = theta, analytic = (!is.null(attr(f,
:
  the matrix returned by the gradient function (argument 'grad') must have
at least as many rows as the number of parameters (10), where each row must
correspond to the gradients of the log-likelihood function of an individual
(independent) observation:
 currently, there are (is) 10 parameter(s) but the gradient matrix has only
2 row(s)
In addition: Warning messages:
1: In is.na(x) : is.na() applied to non-(list or vector) of type 'NULL'
2: In is.na(x) : is.na() applied to non-(list or vector) of type 'NULL'

 and:

>
maxBHHH(logLikALS4,grad=nuGradientC5,finalHessian="BHHH",start=prm,iterlim=2)
Error in gr[, fixed] <- NA : (subscript) logical subscript too long
In addition: Warning messages:
1: In is.na(x) : is.na() applied to non-(list or vector) of type 'NULL'
2: In is.na(x) : is.na() applied to non-(list or vector) of type 'NULL'

Again, thanks for your patience and help.

Rohit


On Wed, May 4, 2011 at 4:44 AM, Andrew Robinson <
a.robin...@ms.unimelb.edu.au> wrote:

> I suggest that you provide some commented, minimal, self-contained,
> reproducible code.
>
> Cheers
>
> Andrew
>
> On Wed, May 04, 2011 at 02:23:29AM +0530, Rohit Pandey wrote:
> > Hello R community,
> >
> > I have been using R's inbuilt maximum likelihood functions, for the
> > different methods (NR, BFGS, etc).
> >
> > I have figured out how to use all of them except the maxBHHH function.
> This
> > one is different from the others as it requires an observation level
> > gradient.
> >
> > I am using the following syntax:
> >
> > maxBHHH(logLik,grad=nuGradient,finalHessian="BHHH",start=prm,iterlim=2)
> >
> > where logLik is the likelihood function and returns a vector of
> observation
> > level likelihoods and nuGradient is a function that returns a matrix with
> > each row corresponding to a single observation and the columns
> corresponding
> > to the gradient values for each parameter (as is mentioned in the online
> > help).
> >
> > however, this gives me the following error:
> >
> > *Error in checkBhhhGrad(g = gr, theta = theta, analytic =
> (!is.null(attr(f,
> > :
> >   the matrix returned by the gradient function (argument 'grad') must
> have
> > at least as many rows as the number of parameters (10), where each row
> must
> > correspond to the gradients of the log-likelih

Re: [R] what happens when I store linear models in an array?

2011-05-04 Thread Andrew D. Steen
Thanks all, this is very helpful.
--Andrew Steen

> -Original Message-
> From: David Winsemius [mailto:dwinsem...@comcast.net]
> Sent: Wednesday, May 04, 2011 4:35 PM
> To: Andrew D. Steen
> Cc: r-help@r-project.org
> Subject: Re: [R] what happens when I store linear models in an array?
> 
> 
> On May 4, 2011, at 4:49 AM, Andrew D. Steen wrote:
> 
> > I've got a bunch of similar datasets, all of which I've fit to linear
> > models.  I'd like to easily create arrays of a specific parameter
> > from each
> > linear model (e.g., all of the intercepts in one array).  I figured
> > I'd put
> > the model objects into an array, and then (somehow) I could easily
> > create
> > corresponding arrays of intercepts or residuals or whatever, but I
> > can't the
> > parameters back out.
> >
> > Right now I've stored the model objects in a 2-D array:
> >> lms.ASP <- array(list(), c(3,4))
> >
> > Then I fill the array element-by-element:
> >> surf105.lm. ASP <- lm(ASP ~ time)
> >> lms.ASP[1,1] <- list(surf105.lm.ASP)
> >
> > Something is successfully being stored in the array:
> >> test <- lms.tx.ASP[1,1]
> >> test
> > [[1]]
> > Call:
> > lm(formula = ASP ~ time)
> > Coefficients:
> > (Intercept)  elapsed.time..hr
> > 0.430732  0.004073
> >
> > But I can't seem to call extraction functions on the linear models:
> >> fitted(lms.ASP[1,1])
> > NUL
> >
> > It seems like something less than the actual linear model object is
> > being
> > stored in the array, but I don't understand what's happening, or how
> > to
> > easily batch-extract parameters of linear models.  Any advice?
> >
> 
> The problem is that the "[" function is returning a sublist from that
> array of lists, which is still a list. You wanted the contents of the
> first (and only) element of that list and  Andrew Robinson offered you
> the solution.
> 
> --
> 
> David Winsemius, MD
> Heritage Laboratories
> 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] Regexp question

2011-05-04 Thread johannes rara
Thank you all!

2011/5/4 David Wolfskill :
> On Wed, May 04, 2011 at 10:41:36PM +0300, johannes rara wrote:
>> I have a string like this
>>
>> st <- "SELECT COUNT(empid), COUNT(mgrid), COUNT(empname),
>> COUNT(salary), FROM Employees"
>>
>> How can I remove the last comma before the FROM statement?
>
> This doesn't use a regex, per se, but:
>
>> st <- "SELECT COUNT(empid), COUNT(mgrid), COUNT(empname), COUNT(salary), 
>> FROM Employees"
>> st
> [1] "SELECT COUNT(empid), COUNT(mgrid), COUNT(empname), COUNT(salary), FROM 
> Employees"
>> sub(", FROM", " FROM", st)
> [1] "SELECT COUNT(empid), COUNT(mgrid), COUNT(empname), COUNT(salary) FROM 
> Employees"
>>
>
> I'm not sure that's what you had in mind, though.
>
> Peace,
> david
> --
> David H. Wolfskill                              r...@catwhisker.org
> Depriving a girl or boy of an opportunity for education is evil.
>
> See http://www.catwhisker.org/~david/publickey.gpg for my public key.
>

__
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] Box-Cox transformation in R

2011-05-04 Thread Patrick Breheny

On 05/04/2011 12:53 PM, FMH wrote:

Hi,

Could any one please help how I can transform data based on Box-Cox 
Transformations in R.

Any helps will be much appreciated.

thanks,
Kagba
[[alternative HTML version deleted]]



See the boxcox function in the MASS package.

___
Patrick Breheny
Assistant Professor
Department of Biostatistics
Department of Statistics
University of Kentucky

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

2011-05-04 Thread David Wolfskill
On Wed, May 04, 2011 at 10:41:36PM +0300, johannes rara wrote:
> I have a string like this
> 
> st <- "SELECT COUNT(empid), COUNT(mgrid), COUNT(empname),
> COUNT(salary), FROM Employees"
> 
> How can I remove the last comma before the FROM statement?

This doesn't use a regex, per se, but:

> st <- "SELECT COUNT(empid), COUNT(mgrid), COUNT(empname), COUNT(salary), FROM 
> Employees"
> st
[1] "SELECT COUNT(empid), COUNT(mgrid), COUNT(empname), COUNT(salary), FROM 
Employees"
> sub(", FROM", " FROM", st)
[1] "SELECT COUNT(empid), COUNT(mgrid), COUNT(empname), COUNT(salary) FROM 
Employees"
> 

I'm not sure that's what you had in mind, though.

Peace,
david
-- 
David H. Wolfskill  r...@catwhisker.org
Depriving a girl or boy of an opportunity for education is evil.

See http://www.catwhisker.org/~david/publickey.gpg for my public key.


pgpZ5pcpDh3l8.pgp
Description: PGP signature
__
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] Str info. Thanks for helping

2011-05-04 Thread Ivan Calandra
It looks from str(SA) that Response IPS1 is a data.frame of class "anova", 
which probably cannot be coerced to vector.

Maybe you can use unlist() instead of as.vector()
Or something like 
SA[["Response IPS1"]]["as.factor(WSD)",]  ## to select the first row only, even 
maybe with unlist()

Without a better REPRODUCIBLE example, I cannot tell more (maybe some others 
can, that's why I reply to the list)

HTH,
Ivan


Le 4 mai 2011 à 20:17, reith_will...@bah.com a écrit :

> I am still waiting for this to get posted so I thought I would email it to 
> you.
> 
> SA gives the output: 
> 
> Response IPS1 : 
>Df Sum Sq Mean Sq F value   Pr(>F) 
> as.factor(WSD)   3 3.3136 1.10455  23.047 5.19e-12 *** 
> Residuals  129 6.1823 0.04793 
> --- 
> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 
> . 
> . 
> . 
> There are 11 more just like this output. Just increment IPS1 to IPS2, etc. 
> 
> 
> Goal: save "3 3.3136 1.10455  23.047 5.19e-12" as a vector. 
> 
> 
> Str(SA) gives the output: 
> 
> str(SA) 
>> str(SA) 
> List of 12 
> " $  Response IPS1 :Classes 'anova' and 'data.frame': 2 obs. of  5 
> variables:" 
>  ..$ Df : num [1:2] 3 129 
>  ..$ Sum Sq : num [1:2] 3.31 6.18 
>  ..$ Mean Sq: num [1:2] 1.1045 0.0479 
>  ..$ F value: num [1:2] 23 NA 
>  ..$ Pr(>F) : num [1:2] 5.19e-12 NA 
> 
> 
> There are several more but they are just repeats of this one only with IPS2, 
> IPS3,...  
> 
> The command: 
> 
>> SA1<-as.vector(SA$"Reponse IPS1") 
> 
> Returns 
> 
>> NULL 
> 
> As do several variations I have tried. Any ideas.



--
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Institut und Museum
Abt. Säugetiere
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231
ivan.calan...@uni-hamburg.de

**
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/1525_8_1.php

__
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] best subset regression in R

2011-05-04 Thread Jeremy Miles
On 4 May 2011 09:47, FMH  wrote:
> Dear All,
>
> Could someone please give some advice the way to do linear modelling via best 
> subset regression in R? I'd really appreciate for your kindness.
>


Google is your friend here:
http://www.google.com/search?q=best+subsets+regression+R , and sends
me to this page:
http://www.statmethods.net/stats/regression.html

Jeremy

-- 
Jeremy Miles
Support Dan and Alex's school: Vote for Goethe Charter School to
receive a grant from Pepsi to help build a library:
http://www.refresheverything.com/gicslibrary

__
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] SAPPLY function XXXX

2011-05-04 Thread Erik Iverson



Ultimately, I would like for this to be 1 conponent in a larger function
that will produce PROC CONTENTS style output. Something like...

data1.contents<-data.frame(Variable=names(data1),
 Class=sapply(data1,class),
 n.valid=sapply(data1,sum(!is.na)),
 n.miss=sapply(data1,sum(is.na)))
data1.contents


Also meant to mention to see ?describe in the Hmisc package:

E.g.,

> describe(c(NA, 1:10))

There is also a useful method for data.frame objects.

--Erik

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

2011-05-04 Thread Jerome Asselin
On Wed, 2011-05-04 at 22:41 +0300, johannes rara wrote:
> I have a string like this
> 
> st <- "SELECT COUNT(empid), COUNT(mgrid), COUNT(empname),
> COUNT(salary), FROM Employees"
> 
> How can I remove the last comma before the FROM statement?

gsub(",[^,]*FROM ", " FROM ", st)

HTH,
Jerome

__
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] SAPPLY function XXXX

2011-05-04 Thread Erik Iverson

Dan,



I am attempting to write a function to count the number of non-missing
values of each column in a data frame using the sapply function. I have the
following code which is receiving the error message below.



n.valid<-sapply(data1,sum(!is.na))

Error in !is.na : invalid argument type


That's the FUN argument to sapply, which expects a function.  is.na is 
indeed a function, but !is.na is not a function:


> !is.na
Error in !is.na : invalid argument type

You need to write your own function to do what you want. Luckily this is 
easy. Let's write one to count the number of missing values in a vector.


countNAs <- function(x) {
   sum(!is.na(x))
}

Now you have a function that does what you want, so you can use sapply 
with it.


sapply(data1, countNAs)

You could also do an anonymous (unnamed) function within sapply to the 
same effect.


sapply(data1, function(x) sum(!is.na(x)))

NB: none of this is tested!

--Erik




Ultimately, I would like for this to be 1 conponent in a larger function
that will produce PROC CONTENTS style output. Something like...

data1.contents<-data.frame(Variable=names(data1),
 Class=sapply(data1,class),
 n.valid=sapply(data1,sum(!is.na)),
 n.miss=sapply(data1,sum(is.na)))
data1.contents

Any suggestions/assistance are appreciated.

Thank you,

Daniel

[[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] join tables in R

2011-05-04 Thread Steve Lianoglou
Hi,

On Wed, May 4, 2011 at 10:32 AM, Roccato Alfredo (UniCredit)
 wrote:
> I'd to match-merge 2 tables in such a manner that I keep all the rows in 
> table 1, but not the rows that are in both table 1 and 2.
> Thank you for your help,
> Alfredo
>
>> master <- data.frame(ID=2001:2011)
>> train   <- data.frame(ID=2004:2006)
>> valid <- ???
>
> in this example table valid should have the following
>
>> str(valid)
>  Year: int  2001 2002 2003 2007 2008 2009 2010 2011

Are you working with only one column at a time? If so:

R> keep <- !(master$ID %in% train$ID)
R> valid <- master[keep,]

If you are working with combinations of columns as the keys for each
row, there are other ways ...

> in SAS I'd do the following:
> data master; do id=2001 to 2011; output; end; run;
> data train; do id=2004 to 2006; output; end; run;
> data valid; merge master(in=a) train(in=b); by id; if a and not b; run;
>
> and in SQL:
> create table valid as
>  select a.* from master where ID not in (select ID from train)

My solution does pretty much what this select statement would do.

-steve

-- 
Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

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

2011-05-04 Thread Henrique Dallazuanna
Try this:

gsub(",\\s+FROM", " FROM", st)

On Wed, May 4, 2011 at 4:41 PM, johannes rara  wrote:
> I have a string like this
>
> st <- "SELECT COUNT(empid), COUNT(mgrid), COUNT(empname),
> COUNT(salary), FROM Employees"
>
> How can I remove the last comma before the FROM statement?
>
> -J
>
> __
> 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.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

__
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] join tables in R

2011-05-04 Thread Petr Savicky
On Wed, May 04, 2011 at 04:32:14PM +0200, Roccato Alfredo (UniCredit) wrote:
> I'd to match-merge 2 tables in such a manner that I keep all the rows in 
> table 1, but not the rows that are in both table 1 and 2.
> Thank you for your help,
> Alfredo
> 
> > master <- data.frame(ID=2001:2011)
> > train   <- data.frame(ID=2004:2006)
> > valid <- ???
> 
> in this example table valid should have the following
> 
> > str(valid)
>  Year: int  2001 2002 2003 2007 2008 2009 2010 2011

Hi.

Try the following, which assumes that "train" is a subset of "master".

  master <- data.frame(ID=2001:2011)
  train  <- data.frame(ID=2004:2006)
  valid <- master[! (master[, 1] %in% train[ ,1]), , drop=FALSE]

Hope this helps.

Petr Savicky.

__
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] Saving Values in a Vector from a For Loop

2011-05-04 Thread Steve Lianoglou
Hi,

On Wed, May 4, 2011 at 10:19 AM, blutack  wrote:
> Hi,
> I have a created a function, but now I need to call it about a hundred times
> and store the results as a vector.
> I think doing a for loop would work, but I cant work out how to save the
> values generated from the function as a vector. Any ideas?

R> n.times <- 100
R> result <- numeric(n.times) ## assuming your function returns numeric
R> for (i in 1:n.times) {
  result[i] <- myfunction(...)
}

or

R> result <- replicate(n.times, myfunction(...))

or if you need the index

R> result <- sapply(seq(n.times), function(i) myfunction(i, ...))

I guess you get the idea ...

-- 
Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

__
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] join tables in R

2011-05-04 Thread Steve_Friedman
Look at the merge command

?merge


Steve Friedman Ph. D.
Ecologist  / Spatial Statistical Analyst
Everglades and Dry Tortugas National Park
950 N Krome Ave (3rd Floor)
Homestead, Florida 33034

steve_fried...@nps.gov
Office (305) 224 - 4282
Fax (305) 224 - 4147


   
 "Roccato Alfredo  
 (UniCredit)"  
  "r-help@r-project.org"  
 Sent by:
 r-help-bounces@r-  cc 
 project.org   
   Subject 
   [R] join tables in R
 05/04/2011 10:32  
 AM
   
   
   
   




I'd to match-merge 2 tables in such a manner that I keep all the rows in
table 1, but not the rows that are in both table 1 and 2.
Thank you for your help,
Alfredo

> master <- data.frame(ID=2001:2011)
> train   <- data.frame(ID=2004:2006)
> valid <- ???

in this example table valid should have the following

> str(valid)
 Year: int  2001 2002 2003 2007 2008 2009 2010 2011

in SAS I'd do the following:
data master; do id=2001 to 2011; output; end; run;
data train; do id=2004 to 2006; output; end; run;
data valid; merge master(in=a) train(in=b); by id; if a and not b; run;

and in SQL:
create table valid as
  select a.* from master where ID not in (select ID from train)



 [[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] SAPPLY function XXXX

2011-05-04 Thread Dan Abner
Hello everyone,

I am attempting to write a function to count the number of non-missing
values of each column in a data frame using the sapply function. I have the
following code which is receiving the error message below.


> n.valid<-sapply(data1,sum(!is.na))
Error in !is.na : invalid argument type

Ultimately, I would like for this to be 1 conponent in a larger function
that will produce PROC CONTENTS style output. Something like...

data1.contents<-data.frame(Variable=names(data1),
 Class=sapply(data1,class),
 n.valid=sapply(data1,sum(!is.na)),
 n.miss=sapply(data1,sum(is.na)))
data1.contents

Any suggestions/assistance are appreciated.

Thank you,

Daniel

[[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] Box-Cox transformation in R

2011-05-04 Thread FMH
Hi,
 
Could any one please help how I can transform data based on Box-Cox 
Transformations in R. 
 
Any helps will be much appreciated. 
 
thanks,
Kagba
[[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] best subset regression in R

2011-05-04 Thread FMH
Dear All,
 
Could someone please give some advice the way to do linear modelling via best 
subset regression in R? I'd really appreciate for your kindness.
 
Thanks,
Kagba
[[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] Outlier removal by Principal Component Analysis : error message

2011-05-04 Thread boule
Hi,

I am currently analysis Raman spectroscopic data with the hyperSpec package.
I consulted the documentation on this package and I found an example
work-flow dedicated to Raman spectroscopy (see the address :
http://hyperspec.r-forge.r-project.org/chondro.pdf)

I am currently trying to remove outliers thanks to PCA just as they did in
the documentation, but I get a message error I can't explain. Here is my
code :

"#import the data :
T=read.table('bladder bis concatenation colonne.txt',header=TRUE)
spec=new("hyperSpec",wavelength=T[,1],spc=t(T[,-1]),data=data.frame(sample=colnames(T[,-1])),label=list(.wavelength="Raman
shift (cm-1)",spc="Intensity (a.u.)"))

#baseline correction of the spectra
spec=spec[,,500~1800]
bl=spc.fit.poly.below(spec)
spec=spec-bl

#normalization of the spectra
spec=sweep(spec,1,apply(spec,1,mean),'/')

#PCA
pca=prcomp(~ spc,data=spec$.,center=TRUE)
scores=decomposition(spec,pca$x,label.wavelength="PC",label.spc="score/a.u.")
loadings=decomposition(spec,t(pca$rotation),scores=FALSE,label.spc="laoding
I/a.u.")

#plot the scores of the first 20 PC against all other to have an idea where
to find the outliers
pairs(scores[[,,1:20]],pch=19,cex=0.5)

#identify the outliers thanks to "map.identify"
out=map.identify(scores[,,5])
Erreur dans `[.data.frame`(x@data, , j, drop = FALSE) : 
  undefined columns selected

Does anybody understand where the problem comes from ?
And does anybody know another mean to find spectra outliers ?

Thank you in advance.

Boule

--
View this message in context: 
http://r.789695.n4.nabble.com/Outlier-removal-by-Principal-Component-Analysis-error-message-tp3496023p3496023.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] two-way group mean prediction in survreg with three factors

2011-05-04 Thread Pang Du
I'm fitting a regression model for censored data with three categorical
predictors, say A, B, C.  My final model based on the survreg function is 

Surv(..) ~ A*(B+C).

I know the three-way group mean estimates can be computed using the predict
function. But is there any way to obtain two-way group mean estimates, say
estimated group mean for (A1, B1)-group?  The sample group means don't
incorporate censoring and thus may not be appropriate here.

 

Pang Du

Virginia Tech


[[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] Fwd: simple question

2011-05-04 Thread Nilaya Sharma
Sorry I had typo in previous email,

this typo corrected version:

 Dear R experts

I have simple question, please execuse me:

#example data, the real data consists of 2 pairs of variables
K1 <- c(1,2,1, 1, 1,1); K2 <- c(1, 1,2,2, 1,2); K3 <- c(3, 1, 3, 3, 1, 3)
M1a <- rep( K1, 100); M1b <- rep(K2, 100)
M2a <- rep(K1, 100); M2b <- rep(K1, 100)
M3a <- rep(K1, 100); M3b <- rep(K3, 100)
mydf <- data.frame(M1a, M1b, M2a, M2b, M3a, M3b)

# matrix operation
nmat <- matrix(c(paste('M', 1:3, 'a', sep = ''), paste('M', 1:3, 'b', sep =
'')), 3)

 coffin <- function(x)  {
x <- as.vector(x)
d1cf <- ifelse(mydf[x[1]] == mydf[x[2]],0,1)   # idea is if first comulm is
equal to second column then the value of d1cf is 0 else is 1
a1cf <- ifelse(mydf[x[1]] > median(mydf[x[1]]), 1, -1) # ??? this my
question

# while   mydf[x[1]] = mydf[x[2]]  and value of
mydf[x[1]] >  median(mydf[x[1]]), the value of a1cf is 1 else
 # mydf[x[1]] = mydf[x[2]]  and value of
mydf[x[1]] <  median(mydf[x[1]]), the value of a1cf is -1

Cf <- d1cf + a1cf
return(Cf)
 }

Cim <- apply(nmat, 1, coffin)

I tried hard could get a appropriate way to do the job.

Can you help me?

NIL



-- Forwarded message --
From: Nilaya Sharma 
Date: Wed, May 4, 2011 at 11:32 AM
Subject: simple question
To: r-help@r-project.org


Dear R experts

I have simple question, please execuse me:

#example data, the real data consists of 2 pairs of variables
K1 <- c(1,2,1, 1, 1,1); K2 <- c(1, 1,2,2, 1,2); K3 <- c(3, 1, 3, 3, 1, 3)
M1a <- rep( K1, 100); M1b <- rep(K2, 100)
M2a <- rep(K1, 100); M2b <- rep(K1, 100)
M3a <- rep(K1, 100); M3b <- rep(K3, 100)
mydf <- data.frame(M1a, M1b, M2a, M2b, M3a, M3b)

# matrix operation
nmat <- matrix(c(paste('M', 1:3, 'a', sep = ''), paste('M', 1:3, 'b', sep =
'')), 3)

 coffin <- function(x)  {
x <- as.vector(x)
d1cf <- ifelse(mydf[x[1]] == mydf[x[2]],0,1)   # idea is if first comulm is
equal to second column then the value of d1cf is 0 else is 1
a1cf <- ifelse(mydf[x[1]] > median(df3[x[1]]), 1, -1) # ??? this my
question

# while   mydf[x[1]] = mydf[x[2]]  and value of
mydf[x[1]] >  median(df3[x[1]]), the value of a1cf is 1 else
 # mydf[x[1]] = mydf[x[2]]  and value of
mydf[x[1]] <  median(df3[x[1]]), the value of a1cf is -1

Cf <- d1cf + a1cf
return(Cf)
 }

Cim <- apply(nmat, 1, coffin)

I tried hard could get a appropriate way to do the job.

Can you help me?

NIL

[[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] Storing data from a test as a vector or matrix

2011-05-04 Thread wwreith
I figured out that attributes is the command that I was trying to find. It
allowed me to find out that I was needing to use "stats" not "Df" or
"Pillai" etc. Following command worked.

> S1<-as.vector(S$stats[1,])

However when I try the same thing with summary.aov it is not working.

>SA<-summary.aov(M)
>SA1<-as.vector(SA$Reponse IPS1)

or 

>SA1<-as.vector(SA$Reponse IPS1[1,])


Using attributes command I get " Response IPS1". I have tried several
variations like including the first space in the quotes, deleting the space
between the two words, adding in [1,], etc. The error is stating unexpected
text. I have even tried using " " which works for the stats line above but
does not work here.


Again thanks for any suggestions on what I am not understanding here. 


--
View this message in context: 
http://r.789695.n4.nabble.com/Storing-data-from-a-test-as-a-vector-or-matrix-tp3495626p3495901.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] Storing data from a test as a vector or matrix

2011-05-04 Thread wwreith
SA gives the output:

Response IPS1 :
Df Sum Sq Mean Sq F value   Pr(>F)
as.factor(WSD)   3 3.3136 1.10455  23.047 5.19e-12 ***
Residuals  129 6.1823 0.04793 
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 
.
.
.
There are 11 more just like this output. Just increment IPS1 to IPS2, etc.


Goal: save "3 3.3136 1.10455  23.047 5.19e-12" as a vector.


Str(SA) gives the output:

str(SA) 
> str(SA)   
List of 12  
" $  Response IPS1 :Classes 'anova' and 'data.frame':   2 obs. of  5
variables:" 
  ..$ Df : num [1:2] 3 129  
  ..$ Sum Sq : num [1:2] 3.31 6.18  
  ..$ Mean Sq: num [1:2] 1.1045 0.0479  
  ..$ F value: num [1:2] 23 NA  
  ..$ Pr(>F) : num [1:2] 5.19e-12 NA


There are several more but they are just repeats of this one only with IPS2,
IPS3,...

The command:

> SA1<-as.vector(SA$"Reponse IPS1")

Returns 

>NULL

As do several variations I have tried. Any ideas. 

--
View this message in context: 
http://r.789695.n4.nabble.com/Storing-data-from-a-test-as-a-vector-or-matrix-tp3495626p3495950.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] Superscript number before letter

2011-05-04 Thread Janhal
Yes thats it :-)
Thank you very much!
Janine

--
View this message in context: 
http://r.789695.n4.nabble.com/Superscript-number-before-letter-tp3495577p3495812.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] Uniform Gaussian Kernel

2011-05-04 Thread blutack
I have a vector with lots of different numbers. I need to make a graph
showing the Uniform Distribution of the figures. I have created a graph
showing all the different values, but now want individual Gaussian Kernel
round each point. This is what I have but each time it comes up with an
error as I have just based it on the Normal Distribution, but I'm not sure
what I need to change to make it work. Where z is my vector.

plot(0, 0, xlim=range(0, 300), ylim=range(0, 1), pch=NA,)
for(i in 1:length(z)) {
points(z[i], 0, pch="|")
}

x = seq(-10, 10, 0.01)
for(i in 1:length(z)){
std_dev = 1
lines(x, dunif(x, z[i], sd = std_dev))
}

Any ideas? Thanks.

--
View this message in context: 
http://r.789695.n4.nabble.com/Uniform-Gaussian-Kernel-tp3495742p3495742.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] Distance measure in heatmaps

2011-05-04 Thread Muhidini
Hi, 
First- I am relatively new to R and would therefore greatly appreciate any
kind of help from you ! 

I am currently trying to use R to make a heatmap using the Pheatmap package. 

My question: I want to include a different distance measure than the ones
given by the implemented hclust function in the pheatmap package (such as
euclidean etc.). I have calculated a distance matrix somewhere else (unifrac
for those who are interested) and want to cluster my columns according to
this matrix. Is there a way to do this ? 

Thanks for any kind of input 
Muhidini 


--
View this message in context: 
http://r.789695.n4.nabble.com/Distance-measure-in-heatmaps-tp3495734p3495734.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] Instrumental variable quantile estimation of spatial autoregressive models

2011-05-04 Thread Marie-Line Glaesener
Dear all,

I would like to implement a spatial quantile regression using instrumental 
variable estimation (according to Su and Yang (2007), Instrumental variable 
quantile estimation of spatial autoregressive models, SMU economics & statistis 
working paper series, 2007, 05-2007, p.35 ).

I am applying the hedonic pricing method on land transactions in Luxembourg.  
My original data set contains 4335 observations.
I'm quite new to R and would like to ask if someone has implemented the method 
proposed by Su and Yang in R or if anyone could give me a hint on the different 
codes and steps?
Please find attached a small sample of my data and matrix.
R codes:

library(foreign)
library(lmtest)
library(spdep)
library(quantreg)

data<-read.table("DataSample.txt",header=TRUE, sep="")
attach(data)

matrix<-read.gwt2nb("matrixsample.gwt" ,region.id=no_Trans)
matrix.listw<-nb2listw(matrix)

OLS model
OLS<-lm(lnprice~surface+d2007+LUX+tsect_ci, data=data)
summary(OLS)

SAR model
SAR<-lagsarlm(lnprice~surface+d2007+LUX+tsect_ci, data=data, listw = 
matrix.listw)
summary(SAR)

I hope that this information is sufficient and will help you to help me :)

Many thanks in advance,

Marie-Line Glaesener

PhD student
Unité de Recherche IPSE (Identités. Politiques, Sociétés, Espaces)
Laboratoire de Géographie et Aménagement du Territoire

UNIVERSITÉ DU LUXEMBOURG
CAMPUS WALFERDANGE
Route de Diekirch / BP 2
L-7201 Walferdange
Luxembourg
www.geo.ipse.uni.lu

no_transidsect  lnprice surface surfsq  dVFAd2006   d2007   LUX
73474   1312040212.408  594 352836  0   1   0   0
73710   1205050311.878  576 331776  0   0   1   0
73713   1205050512.429  383 146689  1   1   0   1
73722   1311020212.782  10781162084 0   0   1   0
73764   1207050311.849  495 245025  0   1   0   0
__
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] Saving Values in a Vector from a For Loop

2011-05-04 Thread blutack
Hi, 
I have a created a function, but now I need to call it about a hundred times
and store the results as a vector.
I think doing a for loop would work, but I cant work out how to save the
values generated from the function as a vector. Any ideas?
Thanks. 

--
View this message in context: 
http://r.789695.n4.nabble.com/Saving-Values-in-a-Vector-from-a-For-Loop-tp3495714p3495714.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] nls problem with R

2011-05-04 Thread Mike Marchywka



> Date: Wed, 4 May 2011 07:07:44 -0700
> From: sterles...@hotmail.com
> To: r-help@r-project.org
> Subject: Re: [R] nls problem with R
>
> Thanks Andrew.
> I am sorry for some typos that I omit some numbers of T2.
> Based on your suggestion,I think the problem is in the initial values.
> And I will read more theory about the non-linear regression.

there is unlikely to be any magic involved, unlike getting hotmail to work.
As a tool for understanding your data, you should have some idea
of the qualitiative properties of model and data and the error
function you use to reconcile the two. 

If you can post your full data set I may post an R example of somethings
to try. I was looking for an excuse to play with nls, I'm not expert here,
and curious to see what I can do with your example for critique by others.
If you want to fully automate this for N contnuous parameters, you
can take a shotgun approach but not sure it helps other htna to
find gross problems in model or data.
I actually wrote a loop to keep picking random parameter values
and calculate and SSE between predicted and real data. What you soon
find is that this is like trying to decode a good crypto algorithm
by guessing- you can do the math to see the problem LOL.







>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/nls-problem-with-R-tp3494454p3495672.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.


[R] join tables in R

2011-05-04 Thread Roccato Alfredo (UniCredit)
I'd to match-merge 2 tables in such a manner that I keep all the rows in table 
1, but not the rows that are in both table 1 and 2.
Thank you for your help,
Alfredo

> master <- data.frame(ID=2001:2011)
> train   <- data.frame(ID=2004:2006)
> valid <- ???

in this example table valid should have the following

> str(valid)
 Year: int  2001 2002 2003 2007 2008 2009 2010 2011

in SAS I'd do the following:
data master; do id=2001 to 2011; output; end; run;
data train; do id=2004 to 2006; output; end; run;
data valid; merge master(in=a) train(in=b); by id; if a and not b; run;

and in SQL:
create table valid as
  select a.* from master where ID not in (select ID from train)



[[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] merging multiple columns from two dataframes

2011-05-04 Thread 1Rnwb
Hello,

I have data  in a dataframe with 139104 rows which is multiple of 96x1449. i
have a phenotype file which contains the phenotype information for the 96
samples. the snp name is repeated 1449X96 samples. I haveto merge the two
dataframes based on sid and sen. this is how my two dataframes look like
   dat<-data.frame(snpname=rep(letters[1:12],12),sid=rep(1:12,each=12), 
 genotype=rep(c('aa','ab','bb'), 12))
   pheno<-data.frame(sen=1:12,disease=rep(c('N','Y'),6), wellid=1:12)

I have to merge or add the disease column and 3 other columns to the data
file. I am unable to use merge in R. I have searched google, i guess i am
not hitting the correct terms to get the answer. I would appreciate any
input on this issue. thanks
sharad

--
View this message in context: 
http://r.789695.n4.nabble.com/merging-multiple-columns-from-two-dataframes-tp3496341p3496341.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] Regexp question

2011-05-04 Thread johannes rara
I have a string like this

st <- "SELECT COUNT(empid), COUNT(mgrid), COUNT(empname),
COUNT(salary), FROM Employees"

How can I remove the last comma before the FROM statement?

-J

__
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] combine lattice plot and standard R plot

2011-05-04 Thread Scott Chamberlain
What about the example in gridExtra package:

require(ggplot2); require(lattice); require(gridExtra)
grid.arrange(qplot(1:10), xyplot(1:10~1:10), tableGrob(head(iris)), nrow=2, 
as.table=TRUE, main="test main", sub=textGrob("test sub", gp=gpar(font=2)))
On Wednesday, May 4, 2011 at 1:44 PM, Jonathan Daily wrote:
If you read the help documentation, lattice is not really compatible
> with standard graphics.
> 
> library("lattice")
> ?lattice
> 
> 2011/5/4 Lucia Cañas :
> > Dear R users,
> > 
> > I would like to combine lattice plot (xyplot) and standard R plot (plot and 
> > plotCI) in an unique figure.
> > 
> > I use the function "par()" to combine plot and plotCI and I use the 
> > function "print()" to combine xyplot. I tried to use these functions to 
> > combine xyplot and plotCI and plots but they do not work. Does anybody know 
> > how I can do this?
> > 
> > Thank you very much in advance.
> > 
> > 
> > 
> > 
> > Lucía Cañás Ferreiro
> > 
> > Instituto Español de Oceanografía
> > Centro Oceanográfico de A coruña
> > Paseo Marítimo Alcalde Francisco Vázquez, 10
> > 15001 - A Coruña, Spain
> > 
> > Tel: +34 981 218151 Fax: +34 981 229077
> > lucia.ca...@co.ieo.es
> > http://www.ieo.es
> > 
> > 
> > 
> > [[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.
> 
> 
> 
> -- 
> ===
> Jon Daily
> Technician
> ===
> #!/usr/bin/env outside
> # It's great, trust me.
> 
> __
> 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] combine lattice plot and standard R plot

2011-05-04 Thread Jonathan Daily
If you read the help documentation, lattice is not really compatible
with standard graphics.

library("lattice")
?lattice

2011/5/4 Lucia Cañas :
> Dear R users,
>
> I would like to combine lattice plot (xyplot) and standard R plot (plot and 
> plotCI) in an unique figure.
>
> I use the function "par()" to combine plot and plotCI and I use the function 
> "print()" to combine xyplot. I tried to use these functions to combine xyplot 
> and plotCI and plots but they do not work. Does anybody know how I can do 
> this?
>
> Thank you very much in advance.
>
>
>
>
> Lucía Cañás Ferreiro
>
> Instituto Español de Oceanografía
> Centro Oceanográfico de A coruña
> Paseo Marítimo Alcalde Francisco Vázquez, 10
> 15001 - A Coruña, Spain
>
> Tel: +34 981 218151  Fax: +34 981 229077
> lucia.ca...@co.ieo.es
> http://www.ieo.es
>
>
>
>        [[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.
>
>



-- 
===
Jon Daily
Technician
===
#!/usr/bin/env outside
# It's great, trust me.

__
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] combine lattice plot and standard R plot

2011-05-04 Thread Lucia Cañas
Dear R users,

I would like to combine lattice plot (xyplot) and standard R plot (plot and 
plotCI) in an unique figure.

I use the function "par()" to combine plot and plotCI and I use the function 
"print()" to combine xyplot. I tried to use these functions to combine xyplot 
and plotCI and plots but they do not work. Does anybody know how I can do this?

Thank you very much in advance.




Lucía Cañás Ferreiro

Instituto Español de Oceanografía
Centro Oceanográfico de A coruña
Paseo Marítimo Alcalde Francisco Vázquez, 10
15001 - A Coruña, Spain

Tel: +34 981 218151  Fax: +34 981 229077
lucia.ca...@co.ieo.es
http://www.ieo.es



[[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] tryCatch?

2011-05-04 Thread Mikkel Grum
Beautiful Prof.

This worked:

for (i in seq(along = tbl$key)) {
if (inherits(try(sqlSave(pg, tbl[i, ], "tbl", append = TRUE,
rownames = FALSE), silent = TRUE), "try-error", TRUE))
sqlUpdate(pg, tbl[i, ], index = "key1")
)
}

--- On Wed, 5/4/11, Prof Brian Ripley  wrote:

> From: Prof Brian Ripley 
> Subject: Re: [R] tryCatch?
> To: "Mikkel Grum" 
> Cc: "R Help" 
> Date: Wednesday, May 4, 2011, 12:21 PM
> Start with try(): you may find it
> easier to understand.
> 
> if(inherits(try(), "try-error"))
> 
> 
> so in your case
> 
> if(inherits(try(sqlSave(pg, tbl[i, ], "tbl", append =
> TRUE,
>                
>          rownames = FALSE
>      sqlUpdate(pg, tbl[i, ], index =
> "key")
> 
> or some such.
> 
> On Wed, 4 May 2011, Mikkel Grum wrote:
> 
> > I would like to do inserts into a database table, but
> do updates in the fairly rare cases in which the inserts
> fail. I thought tryCatch might be the way to do it, but I
> honestly do not understand the help file for tryCatch at
> all.
> >
> > I thought something like this might work:
> > for (i in seq(along = tbl$key)) {
> >    tryCatch(sqlSave(pg, tbl[i, ], "tbl",
> append = TRUE, rownames = FALSE),
> >        if (fails) do
> {sqlUpdate(pg, tbl[i, ], index = "key")})
> > }
> >
> > This obviously isn't the correct syntax, but could
> tryCatch do this if I got the syntax right? And any tips on
> what the right syntax would be?
> >
> > Mikkel
> >
> > __
> > R-help@r-project.org
> mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained,
> reproducible code.
> >
> 
> -- 
> Brian D. Ripley,           
>       rip...@stats.ox.ac.uk
> Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
> University of Oxford,         
>    Tel:  +44 1865 272861 (self)
> 1 South Parks Road,         
>            +44 1865
> 272866 (PA)
> Oxford OX1 3TG, UK           
>     Fax:  +44 1865 272595
>

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


Re: [R] natural cubic splines

2011-05-04 Thread David Winsemius


On May 4, 2011, at 8:34 AM, Joshua Wiley wrote:


Hi Ondrej,

What documentation have you looked at?  Does this help at all?

require(splines)
?ns
## one example
summary(lm(y ~ ns(x, df = 3),
 data = data.frame(y = runif(100), x = rbinom(100, 9, .25)^2)))

## built in examples
example(ns)

Also, I am very fond of the book, Modern Applied Statistics with S by
Venables & Ripley.  It has a section on splines that might help you.



Agree on that last point entirely. I understand that restricted cubic  
splines are another name for natural splines (but would welcome  
correction if that understanding is in error). They are used  
extensively in the rms/Hmisc package combination with the supporting  
text "Regression Modeling Strategies".


--
David

Cheers,

Josh


2011/5/4 Ondřej Mikula :

Dear R-helpers,
I need to fit natural cubic spline with specified number of knots. I
expected 'splines' package will be helpful, but I am confused by its
help. Is more detailed documentation available for it or could you
recommend another R function?
Best regards
Ondrej Mikuladucible code.





David Winsemius, MD
Heritage Laboratories
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] Superscript number before letter

2011-05-04 Thread David Winsemius

On May 4, 2011, at 8:43 AM, Richard M. Heiberger wrote:

> David,
>
> That is not clear from the original request.  The request was for  
> {}^18*O

I see your point. The use of the phantom would also allow a pre- 
superscript with no preceding "delta". Thanks for bearing with my  
obtuseness.

-- 
David.

>
> It wasn't for delta^18
> Therefore I put the space there to be sure that the 18 was seen as  
> pre-superscript of O,
> not as a post-superscript of delta.  I probably should also have  
> used ~ as
>
> plot(1:10, xlab=expression(delta~{}^18*"O" * " VSMOW [‰]"))
>
> The original was unclear on [], since it was inside half a set of  
> quotation marks.
>
> Rich
>
>
>
> On Wed, May 4, 2011 at 11:01 AM, David Winsemius  > wrote:
>
> On May 4, 2011, at 7:28 AM, Richard M. Heiberger wrote:
>
> Dos this do what you want?
>
> plot(1:10, xlab=expression(delta*{}^18*"O" * " VSMOW [‰]"))
>
> The specific is to put an empty item there to hold the superscript.
>
> I do not think that is necessary:
>
>
> plot(1:10, xlab=expression(delta^18*O~VSMOW["‰"]))
>
> (I wasn't sure if the [.] operation was supposed to be a subscript.)
>
> I generally avoid spaces in plotmath expressions and use tildes "~"  
> to accomplish any needed spaces. The asterisk "*" is the non-spacing  
> separator between elements.
>
>
>
>
> On Wed, May 4, 2011 at 9:37 AM, Janhal  wrote:
>
> Salut,
> I have been struggling to superscript the 18 before the O without ^  
> visible
> and found only help to superscript numbers after the letter. Thanks to
> anyone who can help.
> xlab=expression(delta*18O VSMOW [‰]")
> Cheers,
> Janine
>
> --
>
> David Winsemius, MD
> Heritage Laboratories
> West Hartford, CT
>
>

David Winsemius, MD
Heritage Laboratories
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] problem with package "adapt" for R in Mac

2011-05-04 Thread Uwe Ligges

On 04.05.2011 19:22, Matías Ramírez Salgado wrote:

The package is called: "adapt" (adapt_1.0-4.tgz is the version of
package for mac, search it in google)
is not in all CRAN servers, because is an old package.


Yes, there is a reason why the package was archived (which I said 
already!): It does not pass the checks for new versions of R.


Either get a source version from the archives of CRAN and try to install 
it from sources (which may require fixes) or use another package that 
provides similar features such as


 - R2Cuba
 - cubature


Uwe Ligges




I tried to install it from package manager as CRAN (binaries), Other
repositorys, and as a local source packages, and allways returns this
messaje:

[Workspace restored from /Users/matiashernanramirezsalgado/.RData]
Durante la inicializaci'on - Mensajes de aviso perdidos
1: Setting LC_CTYPE failed, using "C"
2: Setting LC_TIME failed, using "C"
3: Setting LC_MESSAGES failed, using "C"
* installing *binary* package 'adapt' ...

* DONE (adapt)
 >
 > library(adapt)
Error: package 'adapt' was built before R 2.10.0: please re-install it




2011/5/4 Uwe Ligges mailto:lig...@statistik.tu-dortmund.de>>



On 04.05.2011 09:19, Andrew Robinson wrote:

Hi,

Is there such a package?


There was such a package that is archived now.


I can't find it on CRAN.  Can you let us
know exactly how you tried to install it, and what the error message
was (if any)?


The OP is probably looking for packages such as
- R2Cuba
- cubature

Uwe Ligges





Cheers

Andrew


On Wed, May 04, 2011 at 01:29:37AM -0300, Mat?as Ram?rez Salgado
wrote:

Hi,

How i can install the package "adapt" in some version of R
for mac?

i try in 2.13, 2.9,2.7 and other previous versions... and
nothing happens.

and another question: There are some packages that do the
same but that it
is implemented for mac? (calculate integrals in 2 or more
dimmensions).

help me please, it's for an important work.

greetings.


--
Mat?as Hern?n Ram?rez Salgado.
Estudiante de Estad?stica.
Pontificia Universidad Cat?lica de Chile.

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






--
Matías Hernán Ramírez Salgado.
Estudiante de Estadística.
Pontificia Universidad Católica de Chile.



__
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 package "adapt" for R in Mac

2011-05-04 Thread Matías Ramírez Salgado
The package is called: "adapt" (adapt_1.0-4.tgz is the version of package
for mac, search it in google)
is not in all CRAN servers, because is an old package.

I tried to install it from package manager as CRAN (binaries), Other
repositorys, and as a local source packages, and allways returns this
messaje:

[Workspace restored from /Users/matiashernanramirezsalgado/.RData]
Durante la inicializaci'on - Mensajes de aviso perdidos
1: Setting LC_CTYPE failed, using "C"
2: Setting LC_TIME failed, using "C"
3: Setting LC_MESSAGES failed, using "C"
* installing *binary* package 'adapt' ...

* DONE (adapt)
>
> library(adapt)
Error: package 'adapt' was built before R 2.10.0: please re-install it




2011/5/4 Uwe Ligges 

>
>
> On 04.05.2011 09:19, Andrew Robinson wrote:
>
>> Hi,
>>
>> Is there such a package?
>>
>
> There was such a package that is archived now.
>
>
>  I can't find it on CRAN.  Can you let us
>> know exactly how you tried to install it, and what the error message
>> was (if any)?
>>
>
> The OP is probably looking for packages such as
> - R2Cuba
> - cubature
>
> Uwe Ligges
>
>
>
>
>
>> Cheers
>>
>> Andrew
>>
>>
>> On Wed, May 04, 2011 at 01:29:37AM -0300, Mat?as Ram?rez Salgado wrote:
>>
>>> Hi,
>>>
>>> How i can install the package "adapt" in some version of R for mac?
>>>
>>> i try in 2.13, 2.9,2.7 and other previous versions... and nothing
>>> happens.
>>>
>>> and another question: There are some packages that do the same but that
>>> it
>>> is implemented for mac? (calculate integrals in 2 or more dimmensions).
>>>
>>> help me please, it's for an important work.
>>>
>>> greetings.
>>>
>>>
>>> --
>>> Mat?as Hern?n Ram?rez Salgado.
>>> Estudiante de Estad?stica.
>>> Pontificia Universidad Cat?lica de Chile.
>>>
>>>[[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.
>>>
>>
>>
>>


-- 
Matías Hernán Ramírez Salgado.
Estudiante de Estadística.
Pontificia Universidad Católica de Chile.

[[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] tryCatch?

2011-05-04 Thread Prof Brian Ripley

Start with try(): you may find it easier to understand.

if(inherits(try(), "try-error")) 

so in your case

if(inherits(try(sqlSave(pg, tbl[i, ], "tbl", append = TRUE,
rownames = FALSE
sqlUpdate(pg, tbl[i, ], index = "key")

or some such.

On Wed, 4 May 2011, Mikkel Grum wrote:


I would like to do inserts into a database table, but do updates in the fairly 
rare cases in which the inserts fail. I thought tryCatch might be the way to do 
it, but I honestly do not understand the help file for tryCatch at all.

I thought something like this might work:
for (i in seq(along = tbl$key)) {
   tryCatch(sqlSave(pg, tbl[i, ], "tbl", append = TRUE, rownames = FALSE),
   if (fails) do {sqlUpdate(pg, tbl[i, ], index = "key")})
}

This obviously isn't the correct syntax, but could tryCatch do this if I got 
the syntax right? And any tips on what the right syntax would be?

Mikkel

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



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

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


Re: [R] Simple loop

2011-05-04 Thread Petr Savicky
On Wed, May 04, 2011 at 08:52:07AM -0700, William Dunlap wrote:
> > -Original Message-
> > From: r-help-boun...@r-project.org 
> > [mailto:r-help-boun...@r-project.org] On Behalf Of Petr Savicky
> > Sent: Wednesday, May 04, 2011 12:51 AM
> > To: r-help@r-project.org
> > Subject: Re: [R] Simple loop
> > 
> > On Tue, May 03, 2011 at 12:04:47PM -0700, William Dunlap wrote:
> > [...]
> > > ave() can deal that problem:
> > >   > cbind(x, newCol2 = with(x, ave(H, Site, Prof,
> > > FUN=function(y)y-min(y
> > > Site Prof  H newCol2
> > >   111 24   8
> > >   211 16   0
> > >   311 67  51
> > >   412 23   0
> > >   512 56  33
> > >   612 45  22
> > >   721 67  21
> > >   821 46   0
> > >   Warning message:
> > >   In min(y) : no non-missing arguments to min; returning Inf
> > > The warning is unfortunate: ave() calls FUN even for when
> > > there is no data for a particular group (Site=2, Prof=2 in this
> > > case).
> > 
> > The warning may be avoided using min(y, Inf) instead of min().
> 
> Yes, but the fact remains that ave() wastes time and causes
> unnecessary warnings and errors by calling FUN when it knows
> it will do nothing with the result (because there are no entries
> in x with a given combination of the factor levels in the ...
> arguments).

I agree. For the original question, avoiding the warning is
preferrable. The general question belongs more to R-devel.

> Using paste(Site,Prof) when calling ave() is ugly, in that it
> forces you to consider implementation details that you expect
> ave() to take care of (how does paste convert various types
> to strings?).  It also courts errors  since paste("A B", "C")
> and paste("A", "B C") give the same result but represent different
> Site/Prof combinations.

Thank you for this remark. I used the formulation "combine
... in any way suitable for the application" with this effect in
mind, but let us be more specific. For numbers, in particular
integers, paste() seems to be good enough. For character vectors,
a possible approach is

  paste(X, Y, sep="\r")

since the character "\r" is unlikely to be used in character
vectors. A similar approach is used, for example in unique.matrix().
I did not like it much, but it also has advantages.

Petr Savicky.

__
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] tryCatch?

2011-05-04 Thread Mikkel Grum
I would like to do inserts into a database table, but do updates in the fairly 
rare cases in which the inserts fail. I thought tryCatch might be the way to do 
it, but I honestly do not understand the help file for tryCatch at all.

I thought something like this might work:
for (i in seq(along = tbl$key)) {
tryCatch(sqlSave(pg, tbl[i, ], "tbl", append = TRUE, rownames = FALSE),
if (fails) do {sqlUpdate(pg, tbl[i, ], index = "key")})
}

This obviously isn't the correct syntax, but could tryCatch do this if I got 
the syntax right? And any tips on what the right syntax would be?

Mikkel

__
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] Error Rscript: No such file or directory

2011-05-04 Thread xavier abulker
Thanks a lot Duncan, 
I have removed the system variable incorrectly setup and it works now.
Have a nice day
Xavier




From: Duncan Murdoch 

Cc: r-help@r-project.org
Sent: Wed, 4 May, 2011 17:37:55
Subject: Re: [R] Error Rscript: No such file or directory

On 04/05/2011 11:49 AM, xavier abulker wrote:
> Hello,
> I'm trying to build a simple cpp file using the R CMD SHLIB command and I
>always
> receive the same error message:
>
> cygwin warning:
>MS-DOS style path detected: C:/PROGRA~1/R/R-212~1.1/etc/i386/Makeconf
>Preferred POSIX equivalent is:
> /cygdrive/c/PROGRA~1/R/R-212~1.1/etc/i386/Makeconf
>CYGWIN environment variable option "nodosfilewarning" turns off this 
>warning.
>Consult the user's guide for more details about POSIX paths:
>  http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
> gcc -shared -s -static-libgcc -o hello.dll tmp.def hello.o Rscript -e
> Rcpp:::LdFlags() -LC:/PROGRA~1

It looks as though you have somehow got some strange environment 
variables or contents of a Makevars file set, possibly because you have 
install Rcpp.  The "Rscript -e Rcpp:::LdFlags()" should not be there.

Duncan Murdoch

> /R/R-212~1.1/bin/i386 -lR
> gcc.exe: Rscript: No such file or directory

It looks as though the file
> Here is what I do:
>
> * From the cpp file below:
>
> //file hello.cpp
> #include
> void sayhello() {
>   printf("Hello world\n");
> }
>
> * I build the file with the DOS command:
>
> R CMD SHLIB hello.c
>
>
> My confirguration is
> R 2.12.2
> Windows XP 2002 SP3
> I have installed the Rtools components and have included the following links
> into my path:
>
> C:\Rtools\bin;
> C:\Rtools\perl\bin;
> C:\Rtools\MinGW\bin;
> C:\Program Files\R\R-2.12.1\bin
>
> Thanks a lot for you help
> Xavier
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
[[alternative HTML version 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] Error Rscript: No such file or directory

2011-05-04 Thread Duncan Murdoch

On 04/05/2011 11:49 AM, xavier abulker wrote:

Hello,
I'm trying to build a simple cpp file using the R CMD SHLIB command and I always
receive the same error message:

cygwin warning:
   MS-DOS style path detected: C:/PROGRA~1/R/R-212~1.1/etc/i386/Makeconf
   Preferred POSIX equivalent is:
/cygdrive/c/PROGRA~1/R/R-212~1.1/etc/i386/Makeconf
   CYGWIN environment variable option "nodosfilewarning" turns off this warning.
   Consult the user's guide for more details about POSIX paths:
 http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
gcc -shared -s -static-libgcc -o hello.dll tmp.def hello.o Rscript -e
Rcpp:::LdFlags() -LC:/PROGRA~1


It looks as though you have somehow got some strange environment 
variables or contents of a Makevars file set, possibly because you have 
install Rcpp.  The "Rscript -e Rcpp:::LdFlags()" should not be there.


Duncan Murdoch


/R/R-212~1.1/bin/i386 -lR
gcc.exe: Rscript: No such file or directory


It looks as though the file

Here is what I do:

* From the cpp file below:

//file hello.cpp
#include
void sayhello() {
  printf("Hello world\n");
}

* I build the file with the DOS command:

R CMD SHLIB hello.c


My confirguration is
R 2.12.2
Windows XP 2002 SP3
I have installed the Rtools components and have included the following links
into my path:

C:\Rtools\bin;
C:\Rtools\perl\bin;
C:\Rtools\MinGW\bin;
C:\Program Files\R\R-2.12.1\bin

Thanks a lot for you help
Xavier

[[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] xtable without a loop alongside a ggplot

2011-05-04 Thread Justin Haynes
I would like to create a table of my points and identify which
'quadrant' of a plot they are in with the 'origin' at the means.  the
kicker is i would like to display it right next to or below a ggplot
of the data.  Maybe xtable isnt the right thing to use, but its the
only thing i can think of.  Any help is appreciated!

set.seed(144)
x=rnorm(100,mean=5,sd=1)
test<-data.frame(x=x,y=x^2)
test$right<-sapply(test$x,function(x) {mean.x<-mean(test$x);any(x>mean.x)})
test$up<-sapply(test$y,function(y) {mean.y<-mean(test$y);any(y>mean.y)})

for(i in 1:length(test$x)){
  if(test$right[i]==TRUE & test$up[i]==TRUE)
print(paste(rownames(test[i,]),'is in the upper right quadrant'))
  if(test$right[i]==FALSE & test$up[i]==TRUE)
print(paste(rownames(test[i,]),'is in the upper left quadrant'))
  if(test$right[i]==TRUE & test$up[i]==FALSE)
print(paste(rownames(test[i,]),'is in the lower right quadrant'))
  if(test$right[i]==FALSE & test$up[i]==FALSE)
print(paste(rownames(test[i,]),'is in the lower left quadrant'))
}

I know theres a better way then using a for loop!  and I haven't the
foggiest how to use xtable.  as i said, the ultimate goal is to create
a plot with a table along side it showing outliers and where they
appear using the inout function from the splancs package and a
confidence ellipse from the ellipse package.

Thank you for your help as usual!

Justin

__
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] Panels order in lattice graphs

2011-05-04 Thread Cristina Silva

Hi all,

In lattice graphs, panels are drawn from left to right and bottom to 
top. The flag "as.table=TRUE" changes to left to right and top to 
bottom. Is there any way to change to first top to bottom and then left 
to right? didn´t find anything neither in Help pages nor Lattice book.


Cristina

--
--
Cristina Silva
INRB/L-IPIMAR
Unidade de Recursos Marinhos e Sustentabilidade
Av. de Brasília, 1449-006 Lisboa
Portugal
Tel.: 351 21 3027096
Fax: 351 21 3015948
csi...@ipimar.pt

__
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] Simple loop

2011-05-04 Thread William Dunlap
> -Original Message-
> From: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] On Behalf Of Petr Savicky
> Sent: Wednesday, May 04, 2011 12:51 AM
> To: r-help@r-project.org
> Subject: Re: [R] Simple loop
> 
> On Tue, May 03, 2011 at 12:04:47PM -0700, William Dunlap wrote:
> [...]
> > ave() can deal that problem:
> >   > cbind(x, newCol2 = with(x, ave(H, Site, Prof,
> > FUN=function(y)y-min(y
> > Site Prof  H newCol2
> >   111 24   8
> >   211 16   0
> >   311 67  51
> >   412 23   0
> >   512 56  33
> >   612 45  22
> >   721 67  21
> >   821 46   0
> >   Warning message:
> >   In min(y) : no non-missing arguments to min; returning Inf
> > The warning is unfortunate: ave() calls FUN even for when
> > there is no data for a particular group (Site=2, Prof=2 in this
> > case).
> 
> The warning may be avoided using min(y, Inf) instead of min().

Yes, but the fact remains that ave() wastes time and causes
unnecessary warnings and errors by calling FUN when it knows
it will do nothing with the result (because there are no entries
in x with a given combination of the factor levels in the ...
arguments).

Using paste(Site,Prof) when calling ave() is ugly, in that it
forces you to consider implementation details that you expect
ave() to take care of (how does paste convert various types
to strings?).  It also courts errors  since paste("A B", "C")
and paste("A", "B C") give the same result but represent different
Site/Prof combinations.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 

> 
>   cbind(x, newCol2 = with(x, ave(H, Site, Prof, 
> FUN=function(y)y-min(y,Inf
> 
> Site Prof  H newCol2
>   111 24   8
>   211 16   0
>   311 67  51
>   412 23   0
>   512 56  33
>   612 45  22
>   721 67  21
>   821 46   0
> 
> Another approach is to combine Site, Prof to a single column
> in any way suitable for the application. For example
> 
>   cbind(x, newCol2 = with(x, ave(H, paste(Site, Prof), 
> FUN=function(y)y-min(y
> 
> Petr Savicky.
> 
> __
> 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] Superscript number before letter

2011-05-04 Thread Richard M. Heiberger
David,

That is not clear from the original request.  The request was for {}^18*O

It wasn't for delta^18
Therefore I put the space there to be sure that the 18 was seen as
pre-superscript of O,
not as a post-superscript of delta.  I probably should also have used ~ as

plot(1:10, xlab=expression(delta~{}^18*"O" * " VSMOW [‰]"))

The original was unclear on [], since it was inside half a set of quotation
marks.

Rich



On Wed, May 4, 2011 at 11:01 AM, David Winsemius wrote:

>
> On May 4, 2011, at 7:28 AM, Richard M. Heiberger wrote:
>
> Dos this do what you want?
>>
>> plot(1:10, xlab=expression(delta*{}^18*"O" * " VSMOW [‰]"))
>>
>> The specific is to put an empty item there to hold the superscript.
>>
>
> I do not think that is necessary:
>
>
> plot(1:10, xlab=expression(delta^18*O~VSMOW["‰"]))
>
> (I wasn't sure if the [.] operation was supposed to be a subscript.)
>
> I generally avoid spaces in plotmath expressions and use tildes "~" to
> accomplish any needed spaces. The asterisk "*" is the non-spacing separator
> between elements.
>
>
>
>
>> On Wed, May 4, 2011 at 9:37 AM, Janhal  wrote:
>>
>> Salut,
>>> I have been struggling to superscript the 18 before the O without ^
>>> visible
>>> and found only help to superscript numbers after the letter. Thanks to
>>> anyone who can help.
>>> xlab=expression(delta*18O VSMOW [‰]")
>>> Cheers,
>>> Janine
>>>
>>> --
>>>
>>
> David Winsemius, MD
> Heritage Laboratories
> 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.


[R] Error Rscript: No such file or directory

2011-05-04 Thread xavier abulker

Hello,
I'm trying to build a simple cpp file using the R CMD SHLIB command and I 
always 
receive the same error message:

cygwin warning:
  MS-DOS style path detected: C:/PROGRA~1/R/R-212~1.1/etc/i386/Makeconf
  Preferred POSIX equivalent is: 
/cygdrive/c/PROGRA~1/R/R-212~1.1/etc/i386/Makeconf
  CYGWIN environment variable option "nodosfilewarning" turns off this warning.
  Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
gcc -shared -s -static-libgcc -o hello.dll tmp.def hello.o Rscript -e 
Rcpp:::LdFlags() -LC:/PROGRA~1
/R/R-212~1.1/bin/i386 -lR
gcc.exe: Rscript: No such file or directory

Here is what I do:

* From the cpp file below: 

//file hello.cpp
#include 
void sayhello() {
 printf("Hello world\n");
}

* I build the file with the DOS command:

R CMD SHLIB hello.c


My confirguration is 
R 2.12.2
Windows XP 2002 SP3
I have installed the Rtools components and have included the following links 
into my path: 

C:\Rtools\bin;
C:\Rtools\perl\bin;
C:\Rtools\MinGW\bin;
C:\Program Files\R\R-2.12.1\bin

Thanks a lot for you help
Xavier

[[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] natural cubic splines

2011-05-04 Thread Joshua Wiley
Hi Ondrej,

What documentation have you looked at?  Does this help at all?

require(splines)
?ns
## one example
summary(lm(y ~ ns(x, df = 3),
  data = data.frame(y = runif(100), x = rbinom(100, 9, .25)^2)))

## built in examples
example(ns)

Also, I am very fond of the book, Modern Applied Statistics with S by
Venables & Ripley.  It has a section on splines that might help you.

Cheers,

Josh


2011/5/4 Ondřej Mikula :
> Dear R-helpers,
> I need to fit natural cubic spline with specified number of knots. I
> expected 'splines' package will be helpful, but I am confused by its
> help. Is more detailed documentation available for it or could you
> recommend another R function?
> Best regards
> Ondrej Mikula
>
> __
> 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] natural cubic splines

2011-05-04 Thread Ondřej Mikula
Dear R-helpers,
I need to fit natural cubic spline with specified number of knots. I
expected 'splines' package will be helpful, but I am confused by its
help. Is more detailed documentation available for it or could you
recommend another R function?
Best regards
Ondrej Mikula

__
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] hurdle, simulated power

2011-05-04 Thread David Atkins


Hi all--

We are planning an intervention study for adolescent alcohol use, and I 
am planning to use simulations based on a hurdle model (using the 
hurdle() function in package pscl) for sample size estimation.


The simulation code and power code are below -- note that at the moment 
the "power" code is just returning the coefficients, as something isn't 
working quite right.


The average estimates from code below are:

count_(Intercept) count_trt  zero_(Intercept)
  2.498327128  -0.000321315   0.910293501
 zero_trt
 -0.200134813

Three of the four look right (ie, converging to population values), but 
the count_trt is stuck at zero, regardless of sample size (when it 
should be ~ -0.20).


Does anyone see what's wrong?

Thanks for any input.

cheers, Dave



mysim <- function(n, beta0, beta1, alpha0, alpha1, theta){
trt <- c(rep(0,n), rep(1,n))
### mean function logit model
p0 <- exp(alpha0 + alpha1*trt)/(1 + exp(alpha0 + alpha1*trt))
### 0 / 1 based on p0
y1 <- as.numeric(runif(n)>p0)
### mean function count portion
mu <- exp(beta0 + beta1*trt)
### estimate counts using NB dist
require(MASS, quietly = TRUE)
y2 <- rnegbin(n, mu = mu, theta = theta)
### if y2 = 0, draw new value
while(sum(y2==0)>0){
		y2[which(y2==0)] <- rnegbin(length(which(y2==0)), mu=mu[which(y2==0)], 
theta = theta)

}
y<-y1*y2
data.frame(trt=trt,y=y)
}
#alpha0, alpha1 is the parameter for zero part
#beta0,beta1 is the parameter for negative binomial
#theta is dispersion parameter for negative binomial, infinity 
correspond to poisson

#

#example power analysis
#return three power, power1 for zero part, power2 for negative binomial part
#power3 for joint test,significance level can be set, default is 0.05
#M is simulation time
#require pscl package
#library(pscl)

mypower <- function(n, beta0, beta1, alpha0, alpha1, theta, 
siglevel=0.05, M=1000){

myfun <- function(n,beta0,beta1,alpha0,alpha1,theta,siglevel){
data <- mysim(n,beta0,beta1,alpha0,alpha1,theta)
require(pscl, quietly = TRUE)
res <- hurdle(y ~ trt, data = data, dist = "negbin", trace = 
FALSE)
est <- coef(res)#[c(2,4)]
#v<-res$vcov[c(2,4),c(2,4)]
#power1<-as.numeric(2*pnorm(-abs(est)[2]/sqrt(v[2,2]))	r <- replicate(M, myfun(n,beta0,beta1,alpha0,alpha1,theta,siglevel), 
simplify=TRUE)

apply(r, 1, mean)
}

out <- mypower(n = 1000, beta0 = 2.5, beta1 = -0.20,
 alpha0 = -0.90, alpha1 = 0.20,
 theta = 2.2, M = 100)
out


--
Dave Atkins, PhD
Research Associate Professor
Department of Psychiatry and Behavioral Science
University of Washington
datk...@u.washington.edu

Center for the Study of Health and Risk Behaviors (CSHRB)   
1100 NE 45th Street, Suite 300  
Seattle, WA  98105  
206-616-3879
http://depts.washington.edu/cshrb/
(Mon-Wed)   

Center for Healthcare Improvement, for Addictions, Mental Illness,
  Medically Vulnerable Populations (CHAMMP)
325 9th Avenue, 2HH-15
Box 359911
Seattle, WA 98104
http://www.chammp.org
(Thurs)

__
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] create a folder with mode '0777'

2011-05-04 Thread Prof Brian Ripley
Please read the comments in the help about umask (and in the posting 
guide about the 'at a minimum' information required in postings, for 
the details do depend on the version of R and it seems yours is not 
current).


In R 2.13.0:

 ‘dir.create’ creates the last element of the path, unless
 ‘recursive = TRUE’.  Trailing path separators are discarded.  The
 mode will be modified by the ‘umask’ setting in the same way as
 for the system function ‘mkdir’.

so try

um <- Sys.umask(0)
dir.create('test/sub', recursive=TRUE)
Sys.umask(um)

(Whether mkdir -p respects umask depends on your OS ... and the 
command-line command and the system call of that name may differ.)


On Wed, 4 May 2011, Xian Zhang wrote:


Dear list,

I am trying to create a folder structure, say 'test/sub', and set the
folder and sub folder to be writable to everyone.

By default

dir.create('test/sub', recursive=TRUE, mode='0777')

creates folders with mode: drwxr-xr-x

After

Sys.chmod('test/sub',mode='0777')

The folder 'test' is: drwxr-xr-x
and the sub folder 'sub' is: drwxrwxrwx

The question is how to generate a folder and sub folders, with every
folder being drwxrwxrwx ?

I am using a linux/redhat system.

Thank you for your help.
Xian

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



--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Is this confict of different versions of R or something else?

2011-05-04 Thread David Winsemius


On May 4, 2011, at 3:44 AM, TheSavageSam wrote:


Hello!

I have had some problems lately with use of R at home and school. At  
my home
laptop (Ubuntu linux 64bit & R-2.12.0) R works just fine. But when I  
take my
codes to school(Windows XP 32bit & R-2.10.1 I think) and run those  
there

those codes probably won't work. Functions as combinations()


> ?combinations
No documentation for 'combinations' in specified packages and libraries:
you could try '??combinations'

So I (like you) don't have the package with combinations loaded.


didn't work and
expand.grid() worked a bit differently. About expand.grid I just  
couldn't
pass a dataframe of parametres but I had to pass all the colums  
separately.


That is most probably a version difference. The Core group works very  
diligently to keep the versions returning the same results (when  
possible) on all platforms. Graphics and operating system-specific  
tasks (including clipboard access) are obvious exceptions.


Is this because my university has so old version of R? Or is it  
because I am

using Linux at home? Or is it because some libraries aren't installed?
I like R very much, but if there is difference between R in different
operating systems, then I dislike that.

Can you give me some tips how to avoid these problems? Install  
latest R to

my university PC? I don't want to fall back at Windows users -category
anymore.

--
TheSavageSam

--


David Winsemius, MD
Heritage Laboratories
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] Superscript number before letter

2011-05-04 Thread David Winsemius


On May 4, 2011, at 7:28 AM, Richard M. Heiberger wrote:


Dos this do what you want?

plot(1:10, xlab=expression(delta*{}^18*"O" * " VSMOW [‰]"))

The specific is to put an empty item there to hold the superscript.


I do not think that is necessary:

plot(1:10, xlab=expression(delta^18*O~VSMOW["‰"]))

(I wasn't sure if the [.] operation was supposed to be a subscript.)

I generally avoid spaces in plotmath expressions and use tildes "~" to  
accomplish any needed spaces. The asterisk "*" is the non-spacing  
separator between elements.





On Wed, May 4, 2011 at 9:37 AM, Janhal  wrote:


Salut,
I have been struggling to superscript the 18 before the O without ^  
visible
and found only help to superscript numbers after the letter. Thanks  
to

anyone who can help.
xlab=expression(delta*18O VSMOW [‰]")
Cheers,
Janine

--


David Winsemius, MD
Heritage Laboratories
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] Storing data from a test as a vector or matrix

2011-05-04 Thread Ivan Calandra

Hi,

I would suggest you to check the structure of your summary object with 
str(), like this:

S <- summary(M, test="Pillai")
str(S)

You will then see how to access each element of it.
If you cannot manage to do it yourself, then provide an example, or at 
least the output from str(s).
By the way, when you get an error, then copy it so that we have a better 
idea of what happens.


HTH,
Ivan




Le 5/4/2011 15:55, wwreith a écrit :

I just finished a MANOVA test and got the following output:


summary(M, test="Pillai")

 Df Pillai approx F num Df den DfPr(>F)
as.factor(X)   3 1.1922   6.5948 36360<  2.2e-16 ***
Residuals  129
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1


I would like to store the values Df=3, Pillai=1.1922, P-value, etc. as a
vector.

I have tried the following code that did not work:


S=summary(M, test="Pillai")
S1<-as.vector(S$Df, S$Pillai)

but I am getting an error every time. I have also tried just S$Df. Is there
a way to find out if "Df" and "Pillai" are correct headers to reference. For
example maybe it is "df" or "degreesfreedom" etc.

I know the concept works because I have used it for logistic regression.

  >v1<- as.vector(exp(L1$coefficients))

The difference is that I know "coefficients" is the correct header to refer
to.

--
View this message in context: 
http://r.789695.n4.nabble.com/Storing-data-from-a-test-as-a-vector-or-matrix-tp3495626p3495626.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.



--
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Museum
Abt. Säugetiere
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231
ivan.calan...@uni-hamburg.de

**
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/1525_8_1.php

__
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] Format ddmmYYYY in date

2011-05-04 Thread David Winsemius


On May 4, 2011, at 5:57 AM, Ben Bolker wrote:


smoff  boku.ac.at> writes:

My problem is that I have a table containing dates in the first  
column of 10
years. These dates have the format ddmm at least in the csv- 
file. After
importing the file using read.table() R deletes the first character  
if it is

a zero.


[snip]

How do I solve this problem? Is there a way to tell R not to delete  
the
first character even if it is a zero or to directly read the first  
column as

date?


See the "colClasses" argument of ?read.table ...

(added a little bit of text to make gmane happy)


I've had similar problems and this was my first strategy:

> test <- c('1241949', '5182001','12252009')
> ifelse(nchar(test)==7, paste("0", test, sep=""), test)
[1] "01241949" "05182001" "12252009"

I then used colClasses, and later simply asked to have all dates in  
the output format from the database changed to "-mm-dd".




__
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
Heritage Laboratories
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] what happens when I store linear models in an array?

2011-05-04 Thread David Winsemius


On May 4, 2011, at 4:49 AM, Andrew D. Steen wrote:


I've got a bunch of similar datasets, all of which I've fit to linear
models.  I'd like to easily create arrays of a specific parameter  
from each
linear model (e.g., all of the intercepts in one array).  I figured  
I'd put
the model objects into an array, and then (somehow) I could easily  
create
corresponding arrays of intercepts or residuals or whatever, but I  
can't the

parameters back out.

Right now I've stored the model objects in a 2-D array:

lms.ASP <- array(list(), c(3,4))


Then I fill the array element-by-element:

surf105.lm. ASP <- lm(ASP ~ time)
lms.ASP[1,1] <- list(surf105.lm.ASP)


Something is successfully being stored in the array:

test <- lms.tx.ASP[1,1]
test

[[1]]
Call:
lm(formula = ASP ~ time)
Coefficients:
(Intercept)  elapsed.time..hr
0.430732  0.004073

But I can't seem to call extraction functions on the linear models:

fitted(lms.ASP[1,1])

NUL

It seems like something less than the actual linear model object is  
being
stored in the array, but I don't understand what's happening, or how  
to

easily batch-extract parameters of linear models.  Any advice?



The problem is that the "[" function is returning a sublist from that  
array of lists, which is still a list. You wanted the contents of the  
first (and only) element of that list and  Andrew Robinson offered you  
the solution.


--

David Winsemius, MD
Heritage Laboratories
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] Format ddmmYYYY in date

2011-05-04 Thread David Winsemius


On May 4, 2011, at 5:57 AM, Ben Bolker wrote:


smoff  boku.ac.at> writes:

My problem is that I have a table containing dates in the first  
column of 10
years. These dates have the format ddmm at least in the csv- 
file. After
importing the file using read.table() R deletes the first character  
if it is

a zero.


[snip]

How do I solve this problem? Is there a way to tell R not to delete  
the
first character even if it is a zero or to directly read the first  
column as

date?


See the "colClasses" argument of ?read.table ...

(added a little bit of text to make gmane happy)


I've had similar problems and this was my first strategy:

> test <- c('1241949', '5182001','12252009')
> ifelse(nchar(test)==7, paste("0", test, sep=""), test)
[1] "01241949" "05182001" "12252009"

I then used colClasses, and later simply asked to have all dates in  
the output format from the database changed to "-mm-dd".




__
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
Heritage Laboratories
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] create a folder with mode '0777'

2011-05-04 Thread Patrick Breheny
Linux systems have a user mask that limits the file mode creation 
possibilities of any processes launched from that shell.  If you check 
your /etc/profile file, you will see the line


umask 022

This prevents you by default from creating files with write access for 
everyone except the user.  In other words, this is a linux issue, not an 
R issue -- the same thing happens when you use mkdir.  This can be 
overridden, however.  For example,


system("chmod -R 0777 test")

which recursively changes the mode of test and all its subdirectories 
from within R.


___
Patrick Breheny
Assistant Professor
Department of Biostatistics
Department of Statistics
University of Kentucky

On 05/04/2011 09:55 AM, Xian Zhang wrote:

Dear list,

I am trying to create a folder structure, say 'test/sub', and set the
folder and sub folder to be writable to everyone.

By default

dir.create('test/sub', recursive=TRUE, mode='0777')

creates folders with mode: drwxr-xr-x

After

Sys.chmod('test/sub',mode='0777')

The folder 'test' is: drwxr-xr-x
and the sub folder 'sub' is: drwxrwxrwx

The question is how to generate a folder and sub folders, with every
folder being drwxrwxrwx ?

I am using a linux/redhat system.

Thank you for your help.
Xian

__
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] Simple General Statistics and R question (with 3 line example) - get z value from pairwise.wilcox.test

2011-05-04 Thread peter dalgaard

On May 4, 2011, at 15:11 , JP wrote:

> Peter thanks for the fantastically simple and understandable explanation...
> 
> To sum it up... to find the z values of a number of pairwise wilcox
> tests do the following:
> 
> # pairwise tests with bonferroni correction
> x <- pairwise.wilcox.test(a, b, alternative="two.sided",
> p.adj="bonferroni", exact=F, paired=T)


You probably don't want the bonferroni correction there. Rather p.adj="none". 
You generally correct the p values for multiple testing, not the test 
statistics.

(My sentiment would be to pick apart the stats:::wilcox.test.default function 
and clone the computation of Z from it, but presumably backtracking from the p 
value is a useful expedient.)

> # what is the data structure we got back
> is.matrix(x$p.value)
> # p vals
> x$p.value
> # z.scores for each
> z.score <- qnorm(x$p.value / 2)
> 

Hmm, you're not actually getting a signed z out of this, you might want to try 
alternative="greater" and drop the division by 2 inside qnorm(). (If the signs 
come out inverted, I meant "less" not "greater"...)


> 
> 
> On 4 May 2011 13:25, peter dalgaard  wrote:
>> 
>> On May 4, 2011, at 11:03 , JP wrote:
>> 
>>> On 3 May 2011 20:50, peter dalgaard  wrote:
 
 On Apr 28, 2011, at 15:18 , JP wrote:
 
> 
> 
> I have found that when doing a wilcoxon signed ranked test you should 
> report:
> 
> - The median value (and not the mean or sd, presumably because of the
> underlying potential non normal distribution)
> - The Z score (or value)
> - r
> - p value
> 
 
 ...printed on 40g/m^2 acid free paper with a pencil of 3B softness?
 
 Seriously, with nonparametrics, the p value is the only thing of real 
 interest, the other stuff is just attempting to check on authors doing 
 their calculations properly. The median difference is of some interest, 
 but it is not actually what is being tested, and in heavily tied data, it 
 could even be zero with a highly significant p-value. The Z score can in 
 principle be extracted from the p value (qnorm(p/2), basically) but it's 
 obviously unstable in the extreme cases. What is r? The correlation? 
 Pearson, not Spearman?
 
>>> 
>>> Thanks for this Peter - a couple of more questions:
>>> 
>>> a <- rnorm(500)
>>> b <- runif(500, min=0, max=1)
>>> x <- wilcox.test(a, b, alternative="two.sided", exact=T, paired=T)
>>> x$statistic
>>> 
>>>V
>>> 31835
>>> 
>>> What is V? (is that the value Z of the test statistic)?
>> 
>> No. It's the sum of the positive ranks:
>> 
>>r <- rank(abs(x))
>>STATISTIC <- sum(r[x > 0])
>>names(STATISTIC) <- "V"
>> 
>> (where x is actually x-y in the paired case)
>> 
>> Subtract the expected value of V (sum(1:500)/2 == 62625) in your case, and 
>> divide by the standard deviation (sqrt(500*501*1001/24)=3232.327) and you 
>> get Z=-9.54. The slight discrepancy is likely due to your use of exact=T (so 
>> your p value is not actually computed from Z).
>> 
>> 
>>> 
>>> z.score <- qnorm(x$p.value/2)
>>> [1] -9.805352
>>> 
>>> But what does this zscore show in practice?
>> 
>> 
>> That your test statistic is approx. 10 standard deviations away from its 
>> mean, if the null hypothesis were to be true.
>> 
>> 
>>> 
>>> The d.f. are suggested to be reported here:
>>> http://staff.bath.ac.uk/pssiw/stats2/page2/page3/page3.html
>>> 
>> 
>> Some software replaces the asymptotic normal distribution of the rank sums 
>> with the t-distribution with the same df as would be used in an ordinary t 
>> test. However, since there is no such thing as an independent variance 
>> estimate in the Wilcoxon test, it is hard to see how that should be an 
>> improvement. I have it down to "coding by non-statistician".
>> 
>> 
>>> And r is mentioned here
>>> http://huberb.people.cofc.edu/Guide/Reporting_Statistics%20in%20Psychology.pdfs
>>> 
>>> 
>> 
>> Aha, so it's supposed to be the effect size. On the referenced site they 
>> suggest to use r=Z/sqrt(N). (They even do so for the independent samples 
>> version, which looks wrong to me).
>> 
>>> 
> My questions are:
> 
> - Are the above enough/correct values to report (some places even
> quote W and df) ?
 
 df is silly, and/or blatantly wrong...
 
>  What else would you suggest?
> - How do I calculate the Z score and r for the above example?
> - How do I get each statistic from the pairwise.wilcox.test call?
> 
> Many Thanks
> JP
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
 
 --
 Peter Dalgaard
 Center for Statistics, Copenhagen Business School
 Solbjerg Plads 3, 2000 Frederiksberg, Denmark
 Phone: (+45

[R] Odp: Is this confict of different versions of R or something else?

2011-05-04 Thread Petr PIKAL
Hi

r-help-boun...@r-project.org napsal dne 04.05.2011 12:44:04:

> TheSavageSam  
> Odeslal: r-help-boun...@r-project.org
> 
> 
> Hello!
> 
> I have had some problems lately with use of R at home and school. At my 
home
> laptop (Ubuntu linux 64bit & R-2.12.0) R works just fine. But when I 
take my
> codes to school(Windows XP 32bit & R-2.10.1 I think) and run those there
> those codes probably won't work. Functions as combinations() didn't work 
and
> expand.grid() worked a bit differently. About expand.grid I just 
couldn't
> pass a dataframe of parametres but I had to pass all the colums 
separately.
> 
> Is this because my university has so old version of R? Or is it because 
I am
> using Linux at home? Or is it because some libraries aren't installed?
> I like R very much, but if there is difference between R in different
> operating systems, then I dislike that.

Hm. Untill now I thought that different versions are for introducing new 
features, properties or enhanced computing. You can not expect that 
everything what works in new version will work in any older version.

There can be slight issues with different operation systems, however I 
believe the biggest problem is old R version in your school PC.

Regards
Petr


> 
> Can you give me some tips how to avoid these problems? Install latest R 
to
> my university PC? I don't want to fall back at Windows users -category
> anymore.
> 
> --
> TheSavageSam
> 
> --
> View this message in context: http://r.789695.n4.nabble.com/Is-this-
> 
confict-of-different-versions-of-R-or-something-else-tp3495104p3495104.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] Superscript number before letter

2011-05-04 Thread Richard M. Heiberger
Dos this do what you want?

plot(1:10, xlab=expression(delta*{}^18*"O" * " VSMOW [‰]"))

The specific is to put an empty item there to hold the superscript.

On Wed, May 4, 2011 at 9:37 AM, Janhal  wrote:

> Salut,
> I have been struggling to superscript the 18 before the O without ^ visible
> and found only help to superscript numbers after the letter. Thanks to
> anyone who can help.
> xlab=expression(delta*18O VSMOW [‰]")
> Cheers,
> Janine
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Superscript-number-before-letter-tp3495577p3495577.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.
>

[[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] nls problem with R

2011-05-04 Thread Ravi Varadhan
In addition to the suggestion about finding a good initial value, you should 
also scale your response V2 (and, of course, V0).  Divide V2 by 10^4, for 
example.  Now your V0 should also be scaled by this factor.  This would likely 
help with convergence.

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: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of sterlesser
Sent: Wednesday, May 04, 2011 10:08 AM
To: r-help@r-project.org
Subject: Re: [R] nls problem with R

Thanks Andrew.
I am sorry for some typos that I omit some numbers of T2.
Based on your suggestion,I think the problem is in the initial values.
And I will read more theory about the non-linear regression.

--
View this message in context: 
http://r.789695.n4.nabble.com/nls-problem-with-R-tp3494454p3495672.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] Watts Strogatz game

2011-05-04 Thread Gábor Csárdi
On Wed, May 4, 2011 at 9:28 AM, Robert Baer  wrote:
>>> I have a erdos-renyi game with 6000 nodes and probability 0.003.
>>>
>>> g1 = erdos.renyi.game(6000, 0.003)
>>>
>>> How to create a Watts Strogatz game with the same probability.
>>>
>>> g1 = watts.strogatz.game(1, 6000, ?, ?)
>>> What should be the third and fourth parameter to this argument.

You can work out the number of edges in a Watts-Strogatz game easily,
by calculating the degree of the nodes in the non-randomized network.
This will be different for different dimensions, of course.
Randomization does not change the average degree.

Obviously, you cannot exactly match all Erdos-Renyi graphs, because
the W-S density cannot change continuously.

Gabor

> According to ?watts.strogatz.game help file (in the igraph package?), the
> four arguments to this function are:
> dim     Integer constant, the dimension of the starting lattice.
> size     Integer constant, the size of the lattice along each dimension.
> nei     Integer constant, the neighborhood within which the vertices of the
> lattice will be connected.
> p         Real constant between zero and one, the rewiring probability.
>
> So it looks like the last two should be neighborhood and rewiring
> probability respectively.
>
> __
> 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.
>



-- 
Gabor Csardi      MTA KFKI RMKI

__
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] nls problem with R

2011-05-04 Thread sterlesser
Thanks Andrew.
I am sorry for some typos that I omit some numbers of T2.
Based on your suggestion,I think the problem is in the initial values.
And I will read more theory about the non-linear regression.

--
View this message in context: 
http://r.789695.n4.nabble.com/nls-problem-with-R-tp3494454p3495672.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] ID parameter in model

2011-05-04 Thread Göran Broström
On Wed, May 4, 2011 at 2:18 PM, Mike Harwood  wrote:
> Thank you, Goran.  Please see the package details below:

Thanks, I have uploaded a corrected version of eha to CRAN. Should be
available soon.

Göran

[...]

__
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] nls problem with R

2011-05-04 Thread sterlesser
Thanks Ruben.
Your suggestion about more deeper analysis about the model itself is really
helpful.
I am trying out some new initial values based on the analysis of the special
T2 in the model.

--
View this message in context: 
http://r.789695.n4.nabble.com/nls-problem-with-R-tp3494454p3495663.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] create a folder with mode '0777'

2011-05-04 Thread Xian Zhang
Dear list,

I am trying to create a folder structure, say 'test/sub', and set the
folder and sub folder to be writable to everyone.

By default

dir.create('test/sub', recursive=TRUE, mode='0777')

creates folders with mode: drwxr-xr-x

After

Sys.chmod('test/sub',mode='0777')

The folder 'test' is: drwxr-xr-x
and the sub folder 'sub' is: drwxrwxrwx

The question is how to generate a folder and sub folders, with every
folder being drwxrwxrwx ?

I am using a linux/redhat system.

Thank you for your help.
Xian

__
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] Unexp. behavior from boot with multiple statistics

2011-05-04 Thread algorimancer
Thanks, that clears things up quite a bit.  Now I'm left wondering why there
is so much bias, but that's a separate issue.

--
View this message in context: 
http://r.789695.n4.nabble.com/Unexp-behavior-from-boot-with-multiple-statistics-tp3493300p3495590.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.


  1   2   >