Re: [R] Reading a file created with Fortran

2008-02-26 Thread Dieter Menne
Ben Bolker  ufl.edu> writes:


>   Perhaps read.fwf is what you want?  (fwf stands for
> "fixed width format").  You would have to work out the
> field widths, but it would seem to be pretty straightforward).

> [A little bit of extra verbiage will make gmane happier ...]
> 
>   Ben Bolker

True, gmane is a bit too strict, but overall it would help improve the 
clarity if everyone in R-help would use gmane. 

(To the non-gmanians): the gmane interface to R-help

http://news.gmane.org/gmane.comp.lang.r.general

simply refuses to post messages with high quoted/reply ratio.

Dieter

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Loading user defined functions autometically each time I start R

2008-02-26 Thread Arun Kumar Saha
I am using R 2.6.2. under windows

On Wed, Feb 27, 2008 at 12:43 PM, <[EMAIL PROTECTED]> wrote:

> >From: Arun Kumar Saha <[EMAIL PROTECTED]>
> >Date: 2008/02/27 Wed AM 01:03:26 CST
> >To: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> >Subject: [R] Loading user defined functions autometically each time I
> start R
>
> i'm on linux so if you are not it's
> probably slightly different on windows
> but not much. I just put my .Rprofile
> file ( you need the . in front but I had to take it
> off when I sent you ) in my /opt/mark ( hiome
> dorectory on linux ) directory.
>
> generally speaking, when you ask questions
> like that, be sure to specify your OS or
> people ( not me ) will get annoyed.
>
> i you start up R, the .Rprofile should
> get called and the functions in your
> arun.R file should be available to you.
> good luck.
>
>
> I';m no expert so hopefully someone else
> will reply also ( that's why i emailed
> privately ).
>
>
>
> >Hi all,
> >
> >I wrote some user defined function for my own. Now I want to get a
> mechanism
> >so that every time I start R, those function will automatically be loaded
> in
> >R without manually copying pasting. Can gurus here pls tell me how to do
> >that? Or I have to build my own packages bundled with those functions.
> >However I am not familiar in writing R package yet.
> >
> >Regards,
> >
> >   [[alternative HTML version deleted]]
> >
> >__
> >R-help@r-project.org mailing list
> >https://stat.ethz.ch/mailman/listinfo/r-help
> >PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> >and provide commented, minimal, self-contained, reproducible code.
>



-- 
--
Arun Kumar Saha, M.Sc.
Statistical Arbitrage Quant
RISK  MANAGEMENT  DIVISION
Transgraph Consulting [www.transgraph.com]
Hyderabad, INDIA
Contact #  Home: (91-033) 25558038 [CALCUTTA]
   Home: (91-040) 40033010 [HYDERABAD]
   Office: (91-040) 30685012 Ext. 17 [email preferred]
 FAX: (91-040) 55755003 [if absolutely necessary]
  Mobile: 919989122010
E-Mail: [EMAIL PROTECTED]
   [EMAIL PROTECTED]
--

[[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 specify ggplot2 facet plot order

2008-02-26 Thread Chris Friedl

Hi, new to R and ggplot2. I've been trying to get a facet plot in which the
order of the facets is as I require, rather than ordered numerically,
alphabetically, by Roman numerals, mean (answers to these were posted here
after much searching). Here's some test code to demonstrate what I get.

series = c('C2','C4','C8','C10','C15','C20')
ids = c('ID1','ID2','ID3')
mydata <- data.frame(SERIES=rep(cases,30),ID=rep(ids,60),VALUE=rnorm(180))
qplot(VALUE, data = mydata, geom="density", facets=SERIES ~ ID)

the facet rows are plotted in alpha order, namely, C10, C15, C2, C20, C4,
C8. I want them plotted in the order specified by series.

I've looked at reorder to reorder the factor called SERIES but that requires
a vector of the same length upon which the ordering is defined through some
function. I guess my noobness with all things R has brought me to a grinding
halt.

I can conceive an algorithm but don't know how to implement.
1. create myordervector of length(SERIES) comprising integers in a mapping
C2: 1, C4: 2, C8: 3 ...
2. reorder using this vector as follows:
mydata <- with(mydata, reorder(SERIES, myordervector , as.numeric))
3. Then plot as above

Is this remotely sensible? Perhaps the order is determined at plot time
rather than from the data.frame. In this case I guess the reordering before
plotting is moot. I'm stuck. Can anyone help out please.

thanks.




-- 
View this message in context: 
http://www.nabble.com/how-to-specify-ggplot2-facet-plot-order-tp15705404p15705404.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] "Raw" histogram plots

2008-02-26 Thread Prof Brian Ripley
On Tue, 26 Feb 2008, Andre Nathan wrote:

> I know about stem, but the data set has 1 million points, so it's not
> very useful here. I want to avoid binning just to have an idea about the
> shape of the distribution, before deciding how I'll bin it.

Ideas:

1) use a much smaller sample of the data (1000 should suffice)
2) use a density plot (see ?density), perhaps on a sub-sample
(although as that will bin the data on a fine grid, this does not matter 
much).


>
> Andre
>
> On Tue, 2008-02-26 at 16:20 -0600, roger koenker wrote:
>> take a look at
>>
>>  ?stem
>>
>> There is still a place for handtools in the age of integrated
>> circuits.  Of course, avoiding binning isn't really desirable.
>>
>> url:www.econ.uiuc.edu/~rogerRoger Koenker
>> email[EMAIL PROTECTED]Department of Economics
>> vox: 217-333-4558University of Illinois
>> fax:   217-244-6678Champaign, IL 61820
>>
>>
>> On Feb 26, 2008, at 4:10 PM, Andre Nathan wrote:
>>
>>> Hello
>>>
>>> I need to plot a histogram, but insted of using bars, I'd like to plot
>>> the data points. I've been doing it like this so far:
>>>
>>>  h <- hist(x, plot = F)
>>>  plot(y = x$counts / sum(x$counts),
>>>   x = x$breaks[2:length(x$breaks)],
>>>   type = "p", log = "xy")
>>>
>>> Sometimes I want to have a look at the "raw" data (avoiding any kind
>>> of
>>> binning). When x only contains integers, it's easy to just use bins of
>>> size 1 when generating h with "breaks = seq(0, max(x))".
>>>
>>> Is there any way to do something similar when x consists of fractional
>>> data? What I'm doing is setting a small bin length (for example,
>>> "breaks
>>> = seq(0, 1, by = 1e-6)", but there's still a chance that points will
>>> be
>>> grouped in a single bin.
>>>
>>> Is there a better way to do this kind of "raw histogram" plotting?
>>>
>>> Thanks,
>>> Andre
>>>
>>> __
>>> R-help@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/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.
>

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

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


[R] Loading user defined functions autometically each time I start R

2008-02-26 Thread Arun Kumar Saha
Hi all,

I wrote some user defined function for my own. Now I want to get a mechanism
so that every time I start R, those function will automatically be loaded in
R without manually copying pasting. Can gurus here pls tell me how to do
that? Or I have to build my own packages bundled with those functions.
However I am not familiar in writing R package yet.

Regards,

[[alternative HTML version deleted]]

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


Re: [R] Add a rectangle behind a plot

2008-02-26 Thread Prof Brian Ripley
On Tue, 26 Feb 2008, Judith Flores wrote:

> Hi there,
>
>   I found one reference to add a reactangle behind a
> plot using plot(...,add=T), I tried this but didn't
> obtain the desired result.
>
> If a I have the following code:
>
> plot(x,y)
> rect(xleft, ybottom, xright,ytop,col='green)
>
>   The rectangle appear on top of the plot.

That's what you asked for by plotting it second.  Try something like

plot(x, y, type="n")
rect(xleft, ybottom, xright,ytop,col='green')
points(x, y)

> Any help will be greatly appreciated,
>
> Judith

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
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] numeric format

2008-02-26 Thread Don MacQueen
While we're at it, and since you're new...

Your example will be much easier for r-help folks to read if you do 
it like this:

j <- 0.4
for(i in 1:20) {
   j=j+0.1
   cp[i] <- pnorm(-j*3)*10^6
   ratio[i] <- j
}

  table <- data.frame(ratio,cp)
  table

But the loop is unnecessary. Try

j <- seq(0.5, by=0.1, length=20)
tbl <- data.frame(ratio=j, cp= pnorm(-3*j)*10^6)


Also, the formatting you are getting is not, I don't think, the default. I get:

>  j <- seq(0.5, by=0.1, length=20)
>  tbl <- data.frame(ratio=j, cp= pnorm(-3*j)*10^6)
>  head(tbl)
   ratiocp
1   0.5 66807.201
2   0.6 35930.319
3   0.7 17864.421
4   0.8  8197.536
5   0.9  3466.974
6   1.0  1349.898

Note that they are aligned to all have 3 places after the decimal point.

Do you want the actual cp values to be adjusted to have some other 
number of decimal places, or do you just want the format changed?

For the former, use, for example, round(cp,1).

For the latter, it kind of depends on your ultimate goal. If you want 
to control the number of decimal places, because you're going to move 
it into a report, for example, you might try looking into the 
formatC() and use something like

formatC(tbl$cp,digits=1,format='f')

As in,

>  tbl$cp <- formatC(tbl$cp,digits=1,format='f')
>  head(tbl)
   ratio  cp
1   0.5 66807.2
2   0.6 35930.3
3   0.7 17864.4
4   0.8  8197.5
5   0.9  3467.0
6   1.0  1349.9

To get rid of the row labels, you will have to use Rolf's suggestion, 
or perhaps delve into the write.table function.

-Don


At 3:41 PM -0800 2/26/08, cvandy wrote:
>Thanks, Erik,
>This is a partial copy of my code.  I want to get rid of the left column of
>integers and I want to control the number of decimal places after the
>decimal point.
>
>  > j<-0.4
>>   for(i in 1:20){
>+ j=j+0.1;cp[i]<-pnorm(-j*3)*10^6;ratio[i]<-j}
>  >  table<-data.frame(ratio,cp)
>>  table
>ratio   cp
>10.5  66807.201268858
>20.6 35930.3191129258
>30.7 17864.4205628166
>40.8 8197.53592459613
>50.9 3466.97380304067
>6
>
>>  CHV
>
>__
>R-help@r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.
>
>
>
>--
>View this message in context: 
>http://www.nabble.com/numeric-format-tp15700452p15702792.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.


-- 
-
Don MacQueen
Lawrence Livermore National Laboratory
Livermore, CA, USA
925-423-1062
[EMAIL PROTECTED]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] ggplot2 boxplot confusion

2008-02-26 Thread Chris Friedl

Ultimately my aim is to get a plot of density faceted by 2 factors with a
horizontal boxplot overlaid on each density plot in the grid to indicate
summary stats. So I've been experimenting with creating boxplots and density
plots. Here's some representative data.

series = c('C2','C4','C8','C10','C15','C20')
ids = c('ID1','ID2','ID3')
mydata <- data.frame(SERIES=rep(cases,30),ID=rep(ids,60),VALUE=rnorm(180))

1. Using R default graphics I can create a boxplot of data independent of
factors as follows:
boxplot(mydata$VALUE)

But I can't see how to do this with ggplot2. All the examples in the help
show x and y aesthetics. How to boxplot a single vector? (I saw a reference
to a "group" parameter in R-help somewhere but can't find it in the ggplot2
help pages. Is this a case of group = identity ?)

2. I've read the density plot help and noticed the reference to ..density..
as a means to pass density data instead of original data. But I can't seem
to get a boxplot to overlay a density plot. This is what I've got so far
with consequent error message:

m <- ggplot(mydata, aes(x=VALUE))
m + geom_density()+ geom_boxplot(aes(x=..density..))

Error in data.frame(..., check.names = FALSE) : 
  arguments imply differing number of rows: 0, 180

I've tried y=..density.., both x= and y =  ..density.. and neither and all
fail somehow. Problem is I don't really understand what I'm doing at this
point.

So can anyone help me out with this? thanks







-- 
View this message in context: 
http://www.nabble.com/ggplot2-boxplot-confusion-tp15706116p15706116.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] multdrc error

2008-02-26 Thread Xin Gong

Dear Sir/Madam:

I am newbie of R. I a currently using multdrc object to generate fitting curve 
and IC50. My 384 well format raw data contains multi dose response curves. My 
script goes through sets of data then produce curve and ic50.

Here is my sudo code:

For (plateid in platelist)
{
Input data (plateid) as matrix
Curve fitting
model4logistic <- multdrc(rdata ~ ld, logDose=10)  
}


The first 3 plates are ok, 4th plate has following error

Error in mdrcOpt(opfct, startVec, optMethod, derFlag, constrained, warnVal,  : 
  Convergence failed

I know the expected fitting is ugly, is it the reason to produce the error?
Any clue about this error message? 

Thanks you in advance for your help,

 
Xin Gong

 



[[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] "Raw" histogram plots

2008-02-26 Thread Marc Schwartz
If the goal is to get a sense of the 'shape' of the overall distribution 
of 'x', then why not use:

   plot(density(x))

?

HTH,

Marc Schwartz


Peter Alspach wrote:
> Andre
>
> If I understand you correctly, you could try a barplot() on the result
> of table().
>
> HTH ..
>
> Peter Alspach
>
>
>> -Original Message-
>> From: [EMAIL PROTECTED]
>> [mailto:[EMAIL PROTECTED] On Behalf Of Andre Nathan
>> Sent: Wednesday, 27 February 2008 1:34 p.m.
>> To: roger koenker
>> Cc: r-help
>> Subject: Re: [R] "Raw" histogram plots
>>
>> I know about stem, but the data set has 1 million points, so
>> it's not very useful here. I want to avoid binning just to
>> have an idea about the shape of the distribution, before
>> deciding how I'll bin it.
>>
>> Andre
>>
>> On Tue, 2008-02-26 at 16:20 -0600, roger koenker wrote:
>>> take a look at
>>>
>>> ?stem
>>>
>>> There is still a place for handtools in the age of integrated
>>> circuits.  Of course, avoiding binning isn't really desirable.
>>>
>>>
>>> On Feb 26, 2008, at 4:10 PM, Andre Nathan wrote:
>>>
 Hello

 I need to plot a histogram, but insted of using bars, I'd like to
 plot the data points. I've been doing it like this so far:

   h<- hist(x, plot = F)
   plot(y = x$counts / sum(x$counts),
x = x$breaks[2:length(x$breaks)],
type = "p", log = "xy")

 Sometimes I want to have a look at the "raw" data
>> (avoiding any kind
 of binning). When x only contains integers, it's easy to just use
 bins of size 1 when generating h with "breaks = seq(0, max(x))".

 Is there any way to do something similar when x consists of
 fractional data? What I'm doing is setting a small bin
>> length (for
 example, "breaks = seq(0, 1, by = 1e-6)", but there's
>> still a chance
 that points will be grouped in a single bin.

 Is there a better way to do this kind of "raw histogram" plotting?

 Thanks,
 Andre


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Backwards Lasso

2008-02-26 Thread Alethea Rea
Has anyone computed a Backwards lasso with positive coefficients? I 
would like the R commands or guidance on fitting such a model.

The backwards lasso and positively constrained lasso are both described 
in Least Angle Regression, Efron etal 2002.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Adding LaTeX cross-references into Sweave plots

2008-02-26 Thread Duncan Murdoch
Peter Dunn wrote:
> Hi all
>
> I'm using Sweave and LaTeX, and love how they interact.
>
> But here's a different interaction I'm not sure how to achieve; I 
> hope someone can help.  I use a simple example, of course, to 
> demonstrate.
>
> Suppose in my LaTeX document I have this:
>
>   Here is a linear equation:
>   \begin{equation}
>   y = -1 + 3 x
>   \label{EQ:example}
>   \end{equation}
>
> This appears in the final product with an Equation number, say (1).
>
> Now suppose I wish to produce a graphic in R:
>
>   <>=
>   plot( c(-1,1), c(-1,1), type="n", 
>   main="Graph of Eq (1)")
>   abline(-1, 3)
>   @
>
> All easy.
>
> But... how to I ensure the correct LaTeX label appears in the plot?  
> You see, if I run LaTeX again, and my equation is no longer 
> labelled (1) and changes to (say) label (3), I have to manually fix 
> the Sweave code to read
>
>   <>=
>   plot( c(-1,1), c(-1,1), type="n", 
>   main="Graph of Eq (3)")
>   abline(-1, 3)
>   @
>
> Any ideas of how that can be automated?  I guess something like this 
> (though this obviously will fail):
>
>
>   <>=
>   plot( c(-1,1), c(-1,1), type="n", 
>   main="Graph of Eq (\label{EQ:equation})")
>   abline(-1, 3)
>   @
>
> Thanks as always.
>   
I don't think there's a reasonable way to do this.  If you want to be 
unreasonable, you could execute R code to read the .aux file produced 
from a previous LaTeX run (which is how LaTeX handles references).  I'd 
say a better approach is just not to use a main title, use the figure 
caption to include the equation number.

Duncan Murdoch

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


Re: [R] Kalman Filter

2008-02-26 Thread Spencer Graves
  Have you looked at the 'dlm' package?  It has a vignette to help 
you learn to use it.  Also, I've heard that a book about that package is 
scheduled to appear in the next few months. 

  I have looked at the Kalman functions in the 'stats' package but 
have not found documentation that seemed sufficient to get me started 
using it. 

  RSiteSearch('Kalman', 'fun') produced 48 hits for me just now.  If 
you don't find what you want with 'dlm' (and maybe even if you do), you 
may wish to examine that list, if you haven't already. 

  Hope this helps. 
  Spencer

Vladimír Šamaj wrote:
> Hi
>
> My name is Vladimir Samaj. I am a student of Univerzity of Zilina. I am
> trying to implement Kalman Filter into my school work. I have some problems
> with understanding of R version of Kalman Filter in package stats( functions
> KalmanLike, KalmanRun, KalmanSmooth,KalmanForecast).
>
> 1) Can you tell me how are you seting the initial values of state vector in
> Kalman Filter? Are you using some method?
>
> 2) I have fond function StructTS in stats package. I dont understand, how
> exactly, are you computing(what method are you using) fitted values which
> are the output of this function( $fitted ) . In description od this function
> is that it fit a structural model for a time series by maximum likehood.
> Does it means, that the fitted values are fit by maximum likehood? If so how
> does look the likehood function?
>
> 3)Finaly, I dont understand smooting problem.  What I know is that, if I
> have t observations of some time serie, I can use  function KalmanRun to get
> estimates of state vector. And if I gain aditional observations of time
> serie( T > t ), I shoud use KalmanSmooth function to smooth estimates of
> state vector. I dont understand, that how shoud I "tell" to KalmanSmooth
> funtion that I allready did filtering and it shoud use the values from
> filtering to smoothing.
>
> I will be glad if you help me. I hope that my folmulations were correct.
>
> Thank you very much.
>
>   [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Add a rectangle behind a plot

2008-02-26 Thread Gabor Grothendieck
Just replot the points over it again:

points(x, y)

Also there is an example using lattice graphics in the Example
section of:

library(zoo)
?xyplot.zoo

On Tue, Feb 26, 2008 at 7:16 PM, Judith Flores <[EMAIL PROTECTED]> wrote:
> Hi there,
>
>   I found one reference to add a reactangle behind a
> plot using plot(...,add=T), I tried this but didn't
> obtain the desired result.
>
> If a I have the following code:
>
> plot(x,y)
> rect(xleft, ybottom, xright,ytop,col='green)
>
>   The rectangle appear on top of the plot.
>
> Any help will be greatly appreciated,
>
> Judith
>
>
>
>
>  
> 
> Never miss a thing.  Make Yahoo your home page.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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 include the documentation of a function in a Sweave document?

2008-02-26 Thread Duncan Murdoch
Thibaut Jombart wrote:
> Duncan Murdoch wrote:
>   
   
 
>>> Maybe a clue: we can use
>>> cat(readLines(as.character(?plot)),sep="\n")
>>>
>>> to display the help (here, of plot) directly to the screen. So we could
>>> use something like:
>>>
>>> <>=
>>> ?plot
>>> @
>>>
>>>
>>> <>=
>>> cat(readLines(as.character(?plot)),sep="\n")
>>> @
>>>
>>> But this doesn't work (latex compilation error) as weird characters 
>>> appear in the produced tex, at some places (tabulations?), like:
>>>
>>> _T_h_e _D_e_f_a_
>>>
>>> (not sure what it will look like in this email, but emacs reads things
>>> like _^HT_^HH_^He...).
>>>
>>> Maybe an encoding problem? I tried specifying different encoding to 
>>> readLines, with no luck (latin1, UTF-8). Otherwise, the help appears 
>>> in the .tex.
>>>   
>> Those are backspaces:  it's trying to underline the title.  You'd get 
>> a better display if you read the latex version instead.  I think you 
>> need to construct the path to it yourself (using system.file() etc.)
>>
>> Duncan Murdoch
>>
>>
>>
>> 
> Thanks for the hint !
> So, the code below roughly works:
>
> ###
> \documentclass{article}
> \usepackage{verbatim}
> \begin{document}
> <>=
> ?plot
> @
>
>
> <>=
> path <- sub("help","latex",as.character(?plot))
> path <- paste(path,'tex',sep=".")
> cat(readLines(path),sep="\n")
> @
>
> \end{document}
> ###
>
> The document compiles with pdflatex but still complains about a bunch of 
> unknown latex instructions (like \HeaderA, used at the begining of the 
> included (plot.tex) tex file. The resulting pdf indeed looks a bit nasty.
>
> What command shall we include in the header to have it work?
>   

The refman.tex file starts like this:

\documentclass[a4paper]{book}
\usepackage[times,hyper]{Rd}
\usepackage[latin1]{inputenc}
\usepackage{makeidx}

Those packages should do it.  (Rd.sty is in R_HOME/share/texmf).

Duncan Murdoch

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


[R] Adding LaTeX cross-references into Sweave plots

2008-02-26 Thread Peter Dunn
Hi all

I'm using Sweave and LaTeX, and love how they interact.

But here's a different interaction I'm not sure how to achieve; I 
hope someone can help.  I use a simple example, of course, to 
demonstrate.

Suppose in my LaTeX document I have this:

Here is a linear equation:
\begin{equation}
y = -1 + 3 x
\label{EQ:example}
\end{equation}

This appears in the final product with an Equation number, say (1).

Now suppose I wish to produce a graphic in R:

<>=
plot( c(-1,1), c(-1,1), type="n", 
main="Graph of Eq (1)")
abline(-1, 3)
@

All easy.

But... how to I ensure the correct LaTeX label appears in the plot?  
You see, if I run LaTeX again, and my equation is no longer 
labelled (1) and changes to (say) label (3), I have to manually fix 
the Sweave code to read

<>=
plot( c(-1,1), c(-1,1), type="n", 
main="Graph of Eq (3)")
abline(-1, 3)
@

Any ideas of how that can be automated?  I guess something like this 
(though this obviously will fail):


<>=
plot( c(-1,1), c(-1,1), type="n", 
main="Graph of Eq (\label{EQ:equation})")
abline(-1, 3)
@

Thanks as always.

P.

-- 
Dr Peter Dunn  |  dunn  usq.edu.au
Faculty of Sciences, USQ; http://www.sci.usq.edu.au/staff/dunn
Aust. Centre for Sustainable Catchments: www.usq.edu.au/acsc

This email (including any attached files) is confidentia...{{dropped:15}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] "Raw" histogram plots

2008-02-26 Thread Peter Alspach
Andre

If I understand you correctly, you could try a barplot() on the result
of table().

HTH ..

Peter Alspach
 

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Andre Nathan
> Sent: Wednesday, 27 February 2008 1:34 p.m.
> To: roger koenker
> Cc: r-help
> Subject: Re: [R] "Raw" histogram plots
> 
> I know about stem, but the data set has 1 million points, so 
> it's not very useful here. I want to avoid binning just to 
> have an idea about the shape of the distribution, before 
> deciding how I'll bin it.
> 
> Andre
> 
> On Tue, 2008-02-26 at 16:20 -0600, roger koenker wrote:
> > take a look at
> > 
> > ?stem
> > 
> > There is still a place for handtools in the age of integrated 
> > circuits.  Of course, avoiding binning isn't really desirable.
> > 
> > url:www.econ.uiuc.edu/~rogerRoger Koenker
> > email[EMAIL PROTECTED]Department of Economics
> > vox: 217-333-4558University of Illinois
> > fax:   217-244-6678Champaign, IL 61820
> > 
> > 
> > On Feb 26, 2008, at 4:10 PM, Andre Nathan wrote:
> > 
> > > Hello
> > >
> > > I need to plot a histogram, but insted of using bars, I'd like to 
> > > plot the data points. I've been doing it like this so far:
> > >
> > >  h <- hist(x, plot = F)
> > >  plot(y = x$counts / sum(x$counts),
> > >   x = x$breaks[2:length(x$breaks)],
> > >   type = "p", log = "xy")
> > >
> > > Sometimes I want to have a look at the "raw" data 
> (avoiding any kind 
> > > of binning). When x only contains integers, it's easy to just use 
> > > bins of size 1 when generating h with "breaks = seq(0, max(x))".
> > >
> > > Is there any way to do something similar when x consists of 
> > > fractional data? What I'm doing is setting a small bin 
> length (for 
> > > example, "breaks = seq(0, 1, by = 1e-6)", but there's 
> still a chance 
> > > that points will be grouped in a single bin.
> > >
> > > Is there a better way to do this kind of "raw histogram" plotting?
> > >
> > > Thanks,
> > > Andre
> > >
> > > __
> > > R-help@r-project.org mailing list
> > > https://stat.ethz.ch/mailman/listinfo/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.
> 

The contents of this e-mail are privileged and/or confidential to the named
 recipient and are not to be used by any other person and/or organisation.
 If you have received this e-mail in error, please notify the sender and delete
 all material pertaining to this e-mail.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Hmisc xYplot won't do conditioning on factors?

2008-02-26 Thread Ivan Adzhubey
Hi,

I am trying to replace (lattice) standard xyplot with xYplot variant from 
Hmisc package to be able to add error bars to my plots. However, this does 
not work, e.g:

library(lattice)
d <- data.frame(
SKU=gl(3, 1, 21, labels=c("a", "b", "c")), 
Weekday=gl(7, 3, 21), 
QCRate=runif(21))

xyplot(QCRate ~ Weekday | SKU, data=d)

(this plots nice 3 panels as per a,b,c conditionals)

library(Hmisc)
> xYplot(QCRate ~ Weekday | SKU, data=d)
Error in Summary.factor(1:7, na.rm = TRUE) :
  range not meaningful for factors

Is there a workaround?

Thanks,
Ivan

The information transmitted in this electronic communica...{{dropped:10}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] missing packages from install

2008-02-26 Thread array chip
Hi,

When I install new packages from CRAN, I frequently
find that some packages were missing from the download
queue. For example, on one of my computer with R2.6.2,
I can not find package glmpath from the download
queue. On my other computer with R2.5.1, I could still
find that particular package. What could be the reason
for this? Is this computer related or R version
related?

I downloaded the gz file for package glmpath into my
local drive (Windows XP), how can I install it? I
tried:

install.packages('H:\\R\\glmpath_0.94.tar.gz')

but got error message:
Warning message:
package 'H:\rw1070\glmpath_0.94.tar.gz' is not
available 

Thanks

John Zhang


  

Looking for last minute shopping deals?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] "Raw" histogram plots

2008-02-26 Thread Andre Nathan
I know about stem, but the data set has 1 million points, so it's not
very useful here. I want to avoid binning just to have an idea about the
shape of the distribution, before deciding how I'll bin it.

Andre

On Tue, 2008-02-26 at 16:20 -0600, roger koenker wrote:
> take a look at
> 
>   ?stem
> 
> There is still a place for handtools in the age of integrated
> circuits.  Of course, avoiding binning isn't really desirable.
> 
> url:www.econ.uiuc.edu/~rogerRoger Koenker
> email[EMAIL PROTECTED]Department of Economics
> vox: 217-333-4558University of Illinois
> fax:   217-244-6678Champaign, IL 61820
> 
> 
> On Feb 26, 2008, at 4:10 PM, Andre Nathan wrote:
> 
> > Hello
> >
> > I need to plot a histogram, but insted of using bars, I'd like to plot
> > the data points. I've been doing it like this so far:
> >
> >  h <- hist(x, plot = F)
> >  plot(y = x$counts / sum(x$counts),
> >   x = x$breaks[2:length(x$breaks)],
> >   type = "p", log = "xy")
> >
> > Sometimes I want to have a look at the "raw" data (avoiding any kind  
> > of
> > binning). When x only contains integers, it's easy to just use bins of
> > size 1 when generating h with "breaks = seq(0, max(x))".
> >
> > Is there any way to do something similar when x consists of fractional
> > data? What I'm doing is setting a small bin length (for example,  
> > "breaks
> > = seq(0, 1, by = 1e-6)", but there's still a chance that points will  
> > be
> > grouped in a single bin.
> >
> > Is there a better way to do this kind of "raw histogram" plotting?
> >
> > Thanks,
> > Andre
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/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] Highlighting different series with colors

2008-02-26 Thread Michael A. Miller
> "Valentin" == Valentin Bellassen <[EMAIL PROTECTED]> writes:

> Hello, I have a data frame with 3 vectors $x, $y, and
> $type. I would like to plot $x~$y and having different
> colors for the corresponding points, one for each level of
> $type. Would someone know how to do that? Is it possible to
> then generate a legend automatically?

If type is a factor, you can use it as.numeric:
plot(x ~ y, data, col=as.numeric(type))
legend(..., col=as.numeric(data$type))

Mike

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Add a rectangle behind a plot

2008-02-26 Thread Judith Flores
Hi there,

   I found one reference to add a reactangle behind a
plot using plot(...,add=T), I tried this but didn't
obtain the desired result.

If a I have the following code:

plot(x,y)
rect(xleft, ybottom, xright,ytop,col='green)

   The rectangle appear on top of the plot.

Any help will be greatly appreciated,

Judith

 


  

Never miss a thing.  Make Yahoo your home page.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] score test statistic in logistic regression

2008-02-26 Thread bkelcey

Hi,

looking for a function or syntax to estimate the score test in logistic 
regression for the null hypothesis b1=0 in the model logit(p)=b0+ b1*x 
+b2*z. Data comes from the binomial distribution (n,p).
Thanks,
ben

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] NLS -- multiplicative errors and group comparison

2008-02-26 Thread Derek Ogle
Hello,

 

I am attempting to fit a non-linear model (Von Bertalanffy growth model)
to fish length-at-age data with the purpose of determining if any of the
three parameters differ between male and female fish.  I believe that I
can successfully accomplish this goal assuming an additive error
structure (illustrated in section 1 below).  My trouble begins when I
attempt this analysis using a model with a multiplicative error
structure.  I believe that I can fit the multiplicative error model to
data without attempting to test between males and females (section 2
below), but I am not sure how to declare the model formula if I want to
test between males and females (section 3 below).  In addition, I
assumed what I did in section 2 was correct, separated the data into a
dataframe of males and a dataframe of females, and then attempted to fit
separate models to each group (Section 4).  This was "successful" for
males but not for females.  The problem with the female group appears to
be that my "logging" creates NaN cells.  When I put a trace on the nls
function it appears to do one iteration and then fails.  My assumption
is that the nls function must be attempting different parameter
estimates that return a NaN but I cannot test this as I'm not sure how
to see the new parameters that it is trying.  [I tried different
starting values but did not find any that corrected this problem.]

 

So (1) how do I declare the model formula for using multiplicative
errors (i.e., is what I did in Section 2 correct), (2) how do I declare
the model formula for comparing two groups and using multiplicative
errors, and (3) any suggestions for how to find the "issue" leading to
the error for just the female model in section 4.

 

Sys.info information is in Section 4 and I am using R 2.6.1.  I have not
included the data as it is a rather large file.

 

Thank you very much for reading this long message and for any help that
you can offer.

 

 

 

### Section 1 ###

> library(xlsReadWrite)

> fwd <- read.xls("FWDrum_SDF.xls",sheet=1)

> fwd$Gm <- fwd$Gf <- rep(0,length(fwd$age))

> fwd$Gf[fwd$sex=="female"] <- 1

> fwd$Gm[fwd$sex=="male"] <- 1

> str(fwd)

'data.frame':   719 obs. of  5 variables:

 $ age: num  1.27 2.25 2.25 2.25 2.25 ...

 $ tl : num  226 208 226 226 234 ...

 $ sex: Factor w/ 2 levels "female","male": 1 1 1 1 1 1 1 1 1 1 ...

 $ Gf : num  1 1 1 1 1 1 1 1 1 1 ...

 $ Gm : num  0 0 0 0 0 0 0 0 0 0 ...

 

# starting values

> sLinf <- 405

> sK <- 0.11

> sto <- -5.2

> svb <- list(Linf=sLinf,K=sK,to=sto)

 

# Fit the additive error structure model to both groups combined

> vbla <- nls(tl~Linf*(1-exp(-K*(age-to))),start=svb,data=fwd)

> summary(vbl1)

 

Formula: tl ~ Linf * (1 - exp(-K * (age - to)))

 

Parameters:

   Estimate Std. Error t value Pr(>|t|)

Linf 520.751048  19.560552  26.623  < 2e-16 ***

K  0.061097   0.008506   7.183 1.72e-12 ***

to-6.950346   1.112839  -6.246 7.24e-10 ***

---

Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 

 

Residual standard error: 83.75 on 716 degrees of freedom

 

Number of iterations to convergence: 9 

Achieved convergence tolerance: 7.525e-06 

 

# Fit the additive error structure model to the separate groups

#  compare this to vbla to see if any parameters differ (fit other
models to see which parameter)

> vbla.gen<- nls(tl~Gf*Linff*(1-exp(-Kf*(age-tof))) +
Gm*Linfm*(1-exp(-Km*(age-tom))),

+
start=list(Linff=sLinf,Kf=sK,tof=sto,Linfm=sLinf,Km=sK,tom=sto),data=fwd
)

> summary(vbla.gen)

 

Formula: tl ~ Gf * Linff * (1 - exp(-Kf * (age - tof))) + Gm * Linfm * 

(1 - exp(-Km * (age - tom)))

 

Parameters:

Estimate Std. Error t value Pr(>|t|)

Linff 692.719734  47.191732  14.679  < 2e-16 ***

Kf  0.038532   0.006469   5.957 4.04e-09 ***

tof-7.589941   1.235644  -6.142 1.35e-09 ***

Linfm 372.224132  13.268491  28.053  < 2e-16 ***

Km  0.095814   0.024983   3.835 0.000137 ***

tom-8.058334   2.445654  -3.295 0.001033 ** 

---

Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 

 

Residual standard error: 68.15 on 713 degrees of freedom

 

Number of iterations to convergence: 8 

Achieved convergence tolerance: 6.589e-06

 

 

 

### Section 2 ###

> vblm <- nls(log(tl)~log(Linf*(1-exp(-K*(age-to,start=svb,data=fwd)

> summary(vblm)

 

Formula: log(tl) ~ log(Linf * (1 - exp(-K * (age - to

 

Parameters:

   Estimate Std. Error t value Pr(>|t|)

Linf 515.414166  21.239627  24.267  < 2e-16 ***

K  0.055431   0.007486   7.404 3.71e-13 ***

to-8.289902   1.002402  -8.270 6.51e-16 ***

---

Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 

 

Residual standard error: 0.1907 on 716 degrees of freedom

 

Number of iterations to convergence: 8 

Achieved convergence tolerance: 2.236e-06

 

 

### Section 3 ###

# FIRST TRY -- Fit the multiplicative error structure model to the
separate groups

> vblm.gen1<- nls(log(tl)~log(Gf*Linff*(1-exp(-Kf

[R] Multiple linear regression with for loop

2008-02-26 Thread M�hlbacher
Hi everyone!

 I have an array containing the following fields for over hundred compounds:
cpd, activity, fixterm, energy1, energy2, energy3, ...

I want to run a multiple linear regression on all entries of an array. 
Therefore I tried to do this with a for loop. (Maybe there is a direct way of 
calculating it using apply, but I don't know that either.)
 
 Actually i tried the following code:
 
 ...
 > attach(data)
 > for(i in 1:length(cpd)) {
 > fitted.model <- lm(activity ~ fixterm + i)
 > coef(fitted.model)
 > }
 ...
 
 Unfortunatly this loop doesn't give the intended correlation coefficients of 
each regression. If I insert a line "print(i)" into the loop the desired values 
for i are printed correctly. Only the coefficient outputs are missing.
 Probably the solution is very near, but I just can't see it.
 
 Many thanks in advance,
 Markus
 
   
-

[[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] multdrc error---Error in mdrcOpt(opfct, startVec, optMethod, derFlag, constrained, warnVal

2008-02-26 Thread Xin Gong
Hi,

 

I am newbie of R. I a currently using multdrc object to generate fitting
curve and IC50. My 384 well format raw data contains multi dose response
curves. My script goes through set of data then produce curve and ic50.

 

Here is my sudo code:

 

For (plateid in platelist)

{

Input data (plateid) as matrix

 

Curve fitting

model4logistic <- multdrc(rdata ~ ld, logDose=10)  

}

 

The first 3 plates are ok, 4th plate has following error

Error in mdrcOpt(opfct, startVec, optMethod, derFlag, constrained,
warnVal,  : 

  Convergence failed

 

I know the expected fitting is ugly, is it the reason to produce the
error?

 

Thanks you in advance for your help,

 

Xin Gong

 


[[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] numeric format

2008-02-26 Thread cvandy

Thanks, Erik,
This is a partial copy of my code.  I want to get rid of the left column of
integers and I want to control the number of decimal places after the
decimal point. 

> j<-0.4
>  for(i in 1:20){
+ j=j+0.1;cp[i]<-pnorm(-j*3)*10^6;ratio[i]<-j}
>  table<-data.frame(ratio,cp)
> table
   ratio   cp
10.5  66807.201268858
20.6 35930.3191129258
30.7 17864.4205628166
40.8 8197.53592459613
50.9 3466.97380304067
6

> CHV

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



-- 
View this message in context: 
http://www.nabble.com/numeric-format-tp15700452p15702792.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] GLM

2008-02-26 Thread Bill.Venables
Just a couple of notes.

* What you are attempting to fit here is a linear model, or, more precisely 
13112 simple linear regressions.  Why not just use 'lm'?  'glm' is for fitting 
generalized linear models and using it for this special case is going to be 
computationally costly. [NB the concept of a 'general' linear model is foreign 
to R.]

* If ever you do manage to fit you 13112 simple linear regressions, what then?  

* Since thery really are separate models, why not try doing it in smaller 
batches, the first 1000, the next 1000, and so on?


Bill Venables
CSIRO Laboratories
PO Box 120, Cleveland, 4163
AUSTRALIA
Office Phone (email preferred): +61 7 3826 7251
Fax (if absolutely necessary):  +61 7 3826 7304
Mobile: +61 4 8819 4402
Home Phone: +61 7 3286 7700
mailto:[EMAIL PROTECTED]
http://www.cmis.csiro.au/bill.venables/ 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Dani Valverde
Sent: Wednesday, 27 February 2008 3:11 AM
To: R Help
Subject: [R] GLM

Hello,
I am trying to perform a glm analysis on a 68x13113 matrix (named 
data.spect). The first column corresponds to the predictor 
(data.spect[,1]) and the rest to the response variables 
(data.spect[,2:13113]). When I try this code

glmObject <- glm(data.spect[,2:13113]~data.spect[,1])

I get the following error:

Error: (subscript) logical subscript too long

Could anyone help me on solving this problem?
Best,

Dani

-- 
Daniel Valverde Saubí

Grup de Biologia Molecular de Llevats
Facultat de Veterinària de la Universitat Autònoma de Barcelona
Edifici V, Campus UAB
08193 Cerdanyola del Vallès- SPAIN

Centro de Investigación Biomédica en Red
en Bioingeniería, Biomateriales y
Nanomedicina (CIBER-BBN)

Grup d'Aplicacions Biomèdiques de la RMN
Facultat de Biociències
Universitat Autònoma de Barcelona
Edifici Cs, Campus UAB
08193 Cerdanyola del Vallès- SPAIN
+34 93 5814126

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Rcmdr importing excel files

2008-02-26 Thread Prof Brian Ripley
On Tue, 26 Feb 2008, John Fox wrote:

> Dear John and Stephen,
>
> As I recall, importing from Excel, Access, or dBase files works properly
> only under Windows, and consequently the menu item appears only in Windows
> systems. I frankly don't recall why this is the case, since the RODBC
> package is used. The code for reading these kinds of files was contributed
> by Matthieu Lesnoff, to whom I'm copying this response. Maybe he'll have a
> more complete answer.

You don't just need the RODBC package, but also the MS ODBC drivers.
I'd be surprised if such drivers existed anywhere else, as they rely 
on Windows internals.

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
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] Multiple lines with a different color assigned to each line (corrected code)

2008-02-26 Thread hadley wickham
It's hard to provide a useful answer without know what your data looks
like, but maybe something like:

library(ggplot2)
qplot(timep, mn, data=summ, geom="line", colour = tx)

Hadley

On Tue, Feb 26, 2008 at 4:24 PM, Judith Flores <[EMAIL PROTECTED]> wrote:
> Sorry, I just realized I didn't type in the correct
>  names of the variables I am working with, this is how
>  it should be:
>
>  plot(1,1,type="n")
>  for (i in summ$tx) {
>
>points(summ$timep[summ$tx==i],summ$mn[summ$tx==i])
>lines(summ$timep[summ$tx==i],summ$mn[summ$tx==i])
>  }
>
>
>  Thank you,
>
>  Judith
>
>
>
>   
> 
>  Be a better friend, newshound, and
>
>  __
>  R-help@r-project.org mailing list
>  https://stat.ethz.ch/mailman/listinfo/r-help
>  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>  and provide commented, minimal, self-contained, reproducible code.
>



-- 
http://had.co.nz/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] "Raw" histogram plots

2008-02-26 Thread hadley wickham
On Tue, Feb 26, 2008 at 4:10 PM, Andre Nathan <[EMAIL PROTECTED]> wrote:
> Hello
>
>  I need to plot a histogram, but insted of using bars, I'd like to plot
>  the data points. I've been doing it like this so far:
>
>   h <- hist(x, plot = F)
>   plot(y = x$counts / sum(x$counts),
>x = x$breaks[2:length(x$breaks)],
>type = "p", log = "xy")

Another approach would be to use ggplot2, where all statistical
transformations can be performed separately from their traditional
appearance:

install.packages("ggplot2")
qplot(x, stat="bin", geom="bar")
qplot(x, stat="bin")

Hadley

-- 
http://had.co.nz/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] lasso with Cox regression

2008-02-26 Thread array chip
Rob Tibshirani propose to use lasso with Cox
regression for variable selection in his 1997 paper
"The lasso method for variable selection in the Cox
model" published in Statistics In Medicine 16:385. I
understand the lars() function in lars package
implemented lasso, but it does not do lasso with Cox
model, does anyone know of any R package/function that
does lasso with a Cox model?

Thanks

John Zhang


  

Looking for last minute shopping deals?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Rcmdr importing excel files

2008-02-26 Thread John Kane
Thanks very much. 
--- John Fox <[EMAIL PROTECTED]> wrote:

> Dear John and Stephen,
> 
> As I recall, importing from Excel, Access, or dBase
> files works properly
> only under Windows, and consequently the menu item
> appears only in Windows
> systems. I frankly don't recall why this is the
> case, since the RODBC
> package is used. The code for reading these kinds of
> files was contributed
> by Matthieu Lesnoff, to whom I'm copying this
> response. Maybe he'll have a
> more complete answer.
> 
> Regards,
>  John
> 
> 
> John Fox, Professor
> Department of Sociology
> McMaster University
> Hamilton, Ontario, Canada L8S 4M4
> 905-525-9140x23604
> http://socserv.mcmaster.ca/jfox
> 
> > -Original Message-
> > From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]
> > project.org] On Behalf Of John Kane
> > Sent: February-26-08 5:27 PM
> > To: stephen sefick; r-help@r-project.org
> > Subject: Re: [R] Rcmdr importing excel files
> > 
> > I'm on Windows XP R 2.6.2
> > The command
> > Data > Import > From Excel, Access etc
> > Supply data.frame name
> > Select xls file and then select the sheet seem to
> work
> > for me
> > 
> > What is not showing?
> > --- stephen sefick <[EMAIL PROTECTED]> wrote:
> > 
> > > I am using R 2.6.2 on Mac OS X 10.4.9-  I would
> like
> > > to import excel
> > > files into R with Rcmdr, but This option does
> not
> > > present itself in
> > > the file menu.  Any help would be greatly
> > > appreciated.
> > >
> > > Stephen
> > >
> > > --
> > > Let's not spend our time and resources thinking
> > > about things that are
> > > so little or so large that all they really do
> for us
> > > is puff us up and
> > > make us feel like gods.  We are mammals, and
> have
> > > not exhausted the
> > > annoying little problems of being mammals.
> > >
> > >   -K. Mullis
> > >
> > > __
> > > R-help@r-project.org mailing list
> > > https://stat.ethz.ch/mailman/listinfo/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-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Rcmdr importing excel files

2008-02-26 Thread John Fox
Dear John and Stephen,

As I recall, importing from Excel, Access, or dBase files works properly
only under Windows, and consequently the menu item appears only in Windows
systems. I frankly don't recall why this is the case, since the RODBC
package is used. The code for reading these kinds of files was contributed
by Matthieu Lesnoff, to whom I'm copying this response. Maybe he'll have a
more complete answer.

Regards,
 John


John Fox, Professor
Department of Sociology
McMaster University
Hamilton, Ontario, Canada L8S 4M4
905-525-9140x23604
http://socserv.mcmaster.ca/jfox

> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> project.org] On Behalf Of John Kane
> Sent: February-26-08 5:27 PM
> To: stephen sefick; r-help@r-project.org
> Subject: Re: [R] Rcmdr importing excel files
> 
> I'm on Windows XP R 2.6.2
> The command
> Data > Import > From Excel, Access etc
> Supply data.frame name
> Select xls file and then select the sheet seem to work
> for me
> 
> What is not showing?
> --- stephen sefick <[EMAIL PROTECTED]> wrote:
> 
> > I am using R 2.6.2 on Mac OS X 10.4.9-  I would like
> > to import excel
> > files into R with Rcmdr, but This option does not
> > present itself in
> > the file menu.  Any help would be greatly
> > appreciated.
> >
> > Stephen
> >
> > --
> > Let's not spend our time and resources thinking
> > about things that are
> > so little or so large that all they really do for us
> > is puff us up and
> > make us feel like gods.  We are mammals, and have
> > not exhausted the
> > annoying little problems of being mammals.
> >
> > -K. Mullis
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/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-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] RSPerl on OS X Server 10.4.11

2008-02-26 Thread Gregory Downs

Hello,

I tried the R-Sig-Mac list with this query, but had no takers.  I hope 
that the following isn't too far off the mark for this list.  Many 
thanks in advance if someone can help me out!


Quick summary:  I can't get RSPerl working on a PPC G5 with the 
pre-compiled binary for Mac OS X, but it does work if I compile R from 
source with the "--enable-R-shlib" flag.  If I need to compile from 
source...what other options are recommended?


More details...

I'm having some trouble getting RSPerl working on an XServe cluster.  Using:

perl v5.8.6
R v2.6.2 (installed from binaries from CRAN)
RSPerl v0.92-1
OS X Server 10.4.11, PowerPC G5

I'm installing RSPerl with:

R CMD INSTALL -c -l '/home/gdowns/R' --configure-args='--with-in-perl' 
RSPerl_0.92-1.tar.gz


but when I try to load the library I get:

> library("RSPerl")
Error in dyn.load(file, ...) :
  unable to load shared library '/home/gdowns/R/RSPerl/libs/ppc/RSPerl.so':
  dlopen(/home/gdowns/R/RSPerl/libs/ppc/RSPerl.so, 6): Symbol not 
found: _boot_R

  Referenced from: /home/gdowns/R/RSPerl/libs/ppc/RSPerl.so
  Expected in: dynamic lookup

Error: package/namespace load failed for 'RSPerl'

So, I tried building R from scratch, using:

./configure --prefix=/tmp/R/ --enable-R-shlib

I then repeated the install of RSPerl with this special version of R:

/tmp/R/R.framework/Resources/bin/R  CMD INSTALL -c -l '/home/gdowns/R' 
--configure-args='--with-in-perl' RSPerl_0.92-1.tar.gz


RSPerl *does* work with this version of R.  I'm confused because 
question 1.3 of the RMacOSX-FAQ says:


"Note that the CRAN binary includes R shared library, so there is no 
need to re-compile R with --enable-R-shlib. "


I also note that when installing RSPerl with the binary distribution of 
R, the R CMD INSTALL process does not generate the perl modules (in the 
RSPerl/perl directory).  They do get created with the 
compiled-from-source version of R (which is, I suspect, why it works!).


I'm not sure where I'm going wrong with this.  I'd highly prefer to 
stick with the pre-compiled binary to make upgrading easier.  Plus I'm 
sure that the version I built today is not as well optimized as the 
binary distribution!


If I really do need to compile R from scratch, can anyone recommend the 
appropriate configure flags?


many thanks and best regards,
Greg.
--
Gregory Downs
CRSC Room 219/414
Department of Plant Agriculture
University of Guelph
Guelph, Ontario, Canada, N1G 2W1
519-824-4120 x58164
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Rcmdr importing excel files

2008-02-26 Thread John Kane
I'm on Windows XP R 2.6.2 
The command 
Data > Import > From Excel, Access etc 
Supply data.frame name 
Select xls file and then select the sheet seem to work
for me

What is not showing?
--- stephen sefick <[EMAIL PROTECTED]> wrote:

> I am using R 2.6.2 on Mac OS X 10.4.9-  I would like
> to import excel
> files into R with Rcmdr, but This option does not
> present itself in
> the file menu.  Any help would be greatly
> appreciated.
> 
> Stephen
> 
> -- 
> Let's not spend our time and resources thinking
> about things that are
> so little or so large that all they really do for us
> is puff us up and
> make us feel like gods.  We are mammals, and have
> not exhausted the
> annoying little problems of being mammals.
> 
>   -K. Mullis
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Multiple lines with a different color assigned to each line (corrected code)

2008-02-26 Thread Judith Flores
Sorry, I just realized I didn't type in the correct
names of the variables I am working with, this is how
it should be:

plot(1,1,type="n")
for (i in summ$tx) {

   points(summ$timep[summ$tx==i],summ$mn[summ$tx==i])
   lines(summ$timep[summ$tx==i],summ$mn[summ$tx==i])
}


Thank you,

Judith



  

Be a better friend, newshound, and

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] numeric format

2008-02-26 Thread Rolf Turner

On 27/02/2008, at 11:01 AM, John Kane wrote:

> Can you give a working example of what is happening
> and explain what is x?
>
> With a simple x vector of x <- rnorm(20, 5, 2)
> I don't get anything like what you seem to be getting.
>
> My code
> ===
> x <- rnorm(20, 5, 2)
> table<-data.frame(x, scientific=F, digits=4)
> table
> ===
>
> The numbers on the left are simply line numbers that
> are automatically printed when you are printing a
> dataframe to the screen.  I don't see any way to
> supress them for a simple command such as your
> table
>
> You might want to have a look at print and
> print.default to address the digits problem



I have often wanted to suppress these row numbers and for that purpose
wrote the following version of print.data.frame() which I keep in a
local package (that I have set up to be loaded automatically on startup)
which masks the system version of print.data.frame():

print.data.frame <- function (x, ..., digits = NULL, quote = FALSE,
 right = TRUE, srn = FALSE)
{
 if (length(x) == 0) {
 cat("NULL data frame with", length(row.names(x)), "rows\n")
 }
 else if (length(row.names(x)) == 0) {
 print.default(names(x), quote = FALSE)
 cat("<0 rows> (or 0-length row.names)\n")
 }
 else {
 if (!is.null(digits)) {
 op <- options(digits = digits)
 on.exit(options(op))
 }
 rowlab <- if (srn)
 rep("", nrow(x))
 else row.names(x)
 prmatrix(format(x), rowlab = rowlab, ..., quote = quote,
 right = right)
 }
 invisible(x)
}

The ``srn'' argument means ``suppress row numbers''; it defaults to  
FALSE so by default
the behaviour of my print.data.frame() is the same as that of the  
system print.data.frame().
To suppress the row numbers you can say, e.g.

print(junk,srn=TRUE)

Note to Young Players --- you need only type ``print'' in the above,  
r.t. ``print.data.frame'',
since print.data.frame() is a ``method'' for print().

I once suggested to an R Core person that my version of  
print.data.frame() be adopted as the
system version, but was politely declined.

cheers,

Rolf Turner


##
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}

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


Re: [R] "Raw" histogram plots

2008-02-26 Thread roger koenker
take a look at

?stem

There is still a place for handtools in the age of integrated
circuits.  Of course, avoiding binning isn't really desirable.

url:www.econ.uiuc.edu/~rogerRoger Koenker
email[EMAIL PROTECTED]Department of Economics
vox: 217-333-4558University of Illinois
fax:   217-244-6678Champaign, IL 61820


On Feb 26, 2008, at 4:10 PM, Andre Nathan wrote:

> Hello
>
> I need to plot a histogram, but insted of using bars, I'd like to plot
> the data points. I've been doing it like this so far:
>
>  h <- hist(x, plot = F)
>  plot(y = x$counts / sum(x$counts),
>   x = x$breaks[2:length(x$breaks)],
>   type = "p", log = "xy")
>
> Sometimes I want to have a look at the "raw" data (avoiding any kind  
> of
> binning). When x only contains integers, it's easy to just use bins of
> size 1 when generating h with "breaks = seq(0, max(x))".
>
> Is there any way to do something similar when x consists of fractional
> data? What I'm doing is setting a small bin length (for example,  
> "breaks
> = seq(0, 1, by = 1e-6)", but there's still a chance that points will  
> be
> grouped in a single bin.
>
> Is there a better way to do this kind of "raw histogram" plotting?
>
> Thanks,
> Andre
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] "Raw" histogram plots

2008-02-26 Thread Andre Nathan
Hello

I need to plot a histogram, but insted of using bars, I'd like to plot
the data points. I've been doing it like this so far:

  h <- hist(x, plot = F)
  plot(y = x$counts / sum(x$counts),
   x = x$breaks[2:length(x$breaks)],
   type = "p", log = "xy")

Sometimes I want to have a look at the "raw" data (avoiding any kind of
binning). When x only contains integers, it's easy to just use bins of
size 1 when generating h with "breaks = seq(0, max(x))".

Is there any way to do something similar when x consists of fractional
data? What I'm doing is setting a small bin length (for example, "breaks
= seq(0, 1, by = 1e-6)", but there's still a chance that points will be
grouped in a single bin.

Is there a better way to do this kind of "raw histogram" plotting?

Thanks,
Andre

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] numeric format

2008-02-26 Thread John Kane
Can you give a working example of what is happening
and explain what is x?

With a simple x vector of x <- rnorm(20, 5, 2)
I don't get anything like what you seem to be getting.

My code
===
x <- rnorm(20, 5, 2)
table<-data.frame(x, scientific=F, digits=4)
table  
===

The numbers on the left are simply line numbers that
are automatically printed when you are printing a
dataframe to the screen.  I don't see any way to
supress them for a simple command such as your 
table

You might want to have a look at print and
print.default to address the digits problem

By the way, table is a reserved word in R and probably
should not be used as a name for a data.frame.

--- cvandy <[EMAIL PROTECTED]> wrote:

> 
> Hi!
> I'm an R newbie and this should be a trivial
> problem, but I can't make it
> work and cannot find what I'm doing wrong in the
> literature.
> I entered the the command:
> table<-data.frame(x, scientific=F, digits=4)
> table
> This prints a column of x with 16 useless decimal
> places after the decimal
> point.  Also, it prints an unwanted index number
> (1-20) in the left column.
> How do I get rid of the index column and how do I
> control the number of
> decimal places?
> Thanks in advance.
> CHV  
> -- 
> View this message in context:
>
http://www.nabble.com/numeric-format-tp15700452p15700452.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] Plot Principal component analysis

2008-02-26 Thread Christos Hatzis
Sorry, it should have been:

col = c("red", "blue")[c(rep(1, 100), rep(2, 15))]

-Christos 

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Christos Hatzis
> Sent: Tuesday, February 26, 2008 4:46 PM
> To: 'SNN'; r-help@r-project.org
> Subject: Re: [R] Plot Principal component analysis
> 
> If your samples are in the specified order (i.e. first 100 
> from group A and remaining from group B) you can try the 
> following in your plot call:
> 
> plot(..., col=c("red", "blue")[c(rep(100, 1), rep(15, 2))])
> 
> -Christos 
> 
> > -Original Message-
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED] On Behalf Of SNN
> > Sent: Tuesday, February 26, 2008 4:11 PM
> > To: r-help@r-project.org
> > Subject: [R] Plot Principal component analysis
> > 
> > 
> > Hi,
> > 
> > I have matrix of 300,000*115 (snps*individual). I ran the 
> PCA on the 
> > covariance matrix which has a dimention oof 115*115. I have 
> the first 
> > 100 individuals from group A and the rest of
> > 15 individuals from group B. I need to plot the data in two and 3 
> > dimentions with respect to PC1 and PC2 and (in 3D with 
> respect to PC1, 
> > PC2 and PC3). I do not know how to have the plot ploting 
> the first 100 
> > points corresponding to group A in red (for example) and 
> the rest of 
> > the 15 points in Blue? i.e I want the each group in a 
> diffrent color 
> > in the same plot. I appreciate if someone can help.
> > 
> > Thanks,
> > --
> > View this message in context: 
> > http://www.nabble.com/Plot-Principal-component-analysis-tp1570
> > 0123p15700123.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-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Multiple lines with a different color assigned to each line

2008-02-26 Thread John Kane
I am not sure if I completely understand but would
something like this work? (not tested)

points( col=i)
lines ( col=i=1)

--- Judith Flores <[EMAIL PROTECTED]> wrote:

> Dear R-experts,
> 
>I want to assign different colors to groups of
> points, lines and segments in a plot.
> 
>   I have a vector(dat$tx) that is going to have a
> different number of levels every time the user wants
> to plot a set of data. The number of lines is going
> to
> be equal to the number of levels of the vector
> mentioned. 
> 
> What I have so far is this:
> 
> plot(1,1,type="n")
> for (i in dat$tx) {
> 
>   
> points(summ$timep[summ$tx==i],summ$mn[summ$tx==i])
>lines(summ$timep[summ$tx==i],summ$mn[summ$tx==i])
> }
> 
> How can I assign different colors to the points and
> lines?
> 
> Thank you in advance for any help,
> 
> Judith
> 
> 
>  
>

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



[[elided Yahoo spam]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] numeric format

2008-02-26 Thread jim holtman
Those are parameter to 'print';  what you want is something like:

> x <- data.frame(a=runif(10))
> print(x)
 a
1  0.713705394
2  0.715496609
3  0.629578524
4  0.184360667
5  0.456639418
6  0.008667156
7  0.260985437
8  0.270915631
9  0.689128652
10 0.302484280
> print(x,scientific=F, digits=4)
  a
1  0.713705
2  0.715497
3  0.629579
4  0.184361
5  0.456639
6  0.008667
7  0.260985
8  0.270916
9  0.689129
10 0.302484
>


On 2/26/08, cvandy <[EMAIL PROTECTED]> wrote:
>
> Hi!
> I'm an R newbie and this should be a trivial problem, but I can't make it
> work and cannot find what I'm doing wrong in the literature.
> I entered the the command:
> table<-data.frame(x, scientific=F, digits=4)
> table
> This prints a column of x with 16 useless decimal places after the decimal
> point.  Also, it prints an unwanted index number (1-20) in the left column.
> How do I get rid of the index column and how do I control the number of
> decimal places?
> Thanks in advance.
> CHV
> --
> View this message in context: 
> http://www.nabble.com/numeric-format-tp15700452p15700452.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.
>


-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?  Tell me what you want to
do, not how you want to do it.

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


Re: [R] Plot Principal component analysis

2008-02-26 Thread Christos Hatzis
If your samples are in the specified order (i.e. first 100 from group A and
remaining from group B) you can try the following in your plot call:

plot(..., col=c("red", "blue")[c(rep(100, 1), rep(15, 2))])

-Christos 

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of SNN
> Sent: Tuesday, February 26, 2008 4:11 PM
> To: r-help@r-project.org
> Subject: [R] Plot Principal component analysis
> 
> 
> Hi,
> 
> I have matrix of 300,000*115 (snps*individual). I ran the PCA 
> on the covariance matrix which has a dimention oof 115*115. I 
> have the first 100 individuals from group A and the rest of 
> 15 individuals from group B. I need to plot the data in two 
> and 3 dimentions with respect to PC1 and PC2 and (in 3D with 
> respect to PC1, PC2 and PC3). I do not know how to have the 
> plot ploting the first 100 points corresponding to group A in 
> red (for example) and the rest of the 15 points in Blue? i.e 
> I want the each group in a diffrent color in the same plot. I 
> appreciate if someone can help.
> 
> Thanks,
> --
> View this message in context: 
> http://www.nabble.com/Plot-Principal-component-analysis-tp1570
> 0123p15700123.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] numeric format

2008-02-26 Thread Erik Iverson
Without knowing what your 'x' is, it's hard to see what is happening 
that you don't like.

Your data.frame function creates a data.frame containing columns 
scientific and digits, equal to FALSE and 4 for all rows, respectively. 
  Is that what you want?


cvandy wrote:
> Hi!
> I'm an R newbie and this should be a trivial problem, but I can't make it
> work and cannot find what I'm doing wrong in the literature.
> I entered the the command:
> table<-data.frame(x, scientific=F, digits=4)
> table
> This prints a column of x with 16 useless decimal places after the decimal
> point.  Also, it prints an unwanted index number (1-20) in the left column.
> How do I get rid of the index column and how do I control the number of
> decimal places?
> Thanks in advance.
> CHV

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Set without argument

2008-02-26 Thread Christophe Genolini
Hi Martin

What do you think of the following code ?

A <- 1

imputeMyObj <- function(x){
  xImp <- 3 #Calcul for Imputation of x
  nam<-deparse(substitute(x))
  assign(nam,xImp,envir=parent.frame())
}
imputeMyObj(A)
A

I guess it is not usual, but do you think it is 'bad' programming or 
will have side effect that I do not see ?

Christophe

> Christophe Genolini <[EMAIL PROTECTED]> writes:
>
>   
>> Hi the list,
>>
>> I am defining S4 objet. Is it possbile to define a method that change 
>> the slot of an object without using <- ?
>> My object contain a numeric and a matrix. At some point, I would like to 
>> impute the missing value in the matrix. So I would like to use something 
>> like :
>>
>> -
>> setClass("MyObj",representation(time="numeric",traj="matrix"))
>> a <- new("MyObj",time=3,traj=matrix(c(1:6,NA,8:12),ncol=3))
>> imputeMyObj(a)
>> -
>> 
>
> Hi Christophe --
>
> The 'usual' way to write the above code is
>
>   
>> a <- imputeMyObj(a)
>> 
>
> with imputeMyObj designed to take a 'MyObj' as it's argument, and
> return a modified 'MyObj' (that the user can assign to 'a', if they
> like). Inside imputeMyObj, the developer would, in the end, write
> something like
>
> impuateMyObj <- function(obj) {
># calculate imputed values 'imp'
>slot(obj, "traj") <- imp
>obj
> }
>
> A better design would have a 'setter' method, minimally
>
>   
>> setGeneric("traj<-",
>> 
> +function(object, ..., value) standardGeneric("traj<-"))
> [1] "traj<-"
>   
>> setReplaceMethod("traj",
>> 
> +  signature=signature(
> +object="MyObj",
> +value="matrix"),
> +  function(object, ..., value) {
> +  slot(object, "traj") <- value
> +  object
> +  })
> [1] "traj<-"
>
> and then the impute code would have
>
> impuateMyObj <- function(obj) {
># calculate imputed values 'imp'
>traj(obj) <- imp
>obj
> }
>
> It's possible to design 'MyObj' so that it can be modified in-place
> (e.g., storing data in a slot of class 'environment', which has
> reference-like behavior) but this will probably surprise both you and
> the user.
>
> Martin
>
>   
>> I find 'setTime<-' to change le slot time, but it can not work in the 
>> case of imputeMyObs since this mehod does not need a value...
>>
>> Any solution ?
>>
>> Thanks
>>
>> Christophe
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/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] combining 40,000 with 40,000 data frame (different tact)

2008-02-26 Thread jim holtman
?rbind

On 2/26/08, stephen sefick <[EMAIL PROTECTED]> wrote:
> I have not been able to find anything to do what I want, so I am going
> to tact to the left.  I have twp continuous time series for two years
> with the same fourteen variables.  I would like to simply append the
> second year to the first.  They both have the same column headings
> etc.  Just like tapping two pieces of paper together for a long number
> series.
> Thanks
>
> Stephen
>
> --
> Let's not spend our time and resources thinking about things that are
> so little or so large that all they really do for us is puff us up and
> make us feel like gods.  We are mammals, and have not exhausted the
> annoying little problems of being mammals.
>
>-K. Mullis
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>


-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?  Tell me what you want to
do, not how you want to do it.

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


Re: [R] combining 40,000 with 40,000 data frame (different tact)

2008-02-26 Thread Paul Hiemstra
stephen sefick schreef:
> I have not been able to find anything to do what I want, so I am going
> to tact to the left.  I have twp continuous time series for two years
> with the same fourteen variables.  I would like to simply append the
> second year to the first.  They both have the same column headings
> etc.  Just like tapping two pieces of paper together for a long number
> series.
> Thanks
>
> Stephen
>
>   
?rbind

cheers,
Paul

-- 
Drs. Paul Hiemstra
Department of Physical Geography
Faculty of Geosciences
University of Utrecht
Heidelberglaan 2
P.O. Box 80.115
3508 TC Utrecht
Phone: +31302535773
Fax:+31302531145
http://intamap.geo.uu.nl/~paul

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] lrm error message

2008-02-26 Thread Angelo Passalacqua
I'm trying to learn how to use the lrm() function by simulating data using
an old dataset but it's giving me an error I don't understand:

(nst$regular already exists)

nst$regular<-as.ordered(nst$regular)

nst$age<-rnorm(n=942,mean=43.20488,sd=17.03)

nst$age<-round(age,digits=0)
regform<-regular~age

reglrm<-lrm(regform,nst)
summary(reglrm)
Error in summary.Design(reglrm) :
  adjustment values not defined here or with datadist for age

ive looked at the help file for lrm and thought it was simple enough but
apparently not.  any help would be greatly appreciated.

[[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] numeric format

2008-02-26 Thread cvandy

Hi!
I'm an R newbie and this should be a trivial problem, but I can't make it
work and cannot find what I'm doing wrong in the literature.
I entered the the command:
table<-data.frame(x, scientific=F, digits=4)
table
This prints a column of x with 16 useless decimal places after the decimal
point.  Also, it prints an unwanted index number (1-20) in the left column.
How do I get rid of the index column and how do I control the number of
decimal places?
Thanks in advance.
CHV  
-- 
View this message in context: 
http://www.nabble.com/numeric-format-tp15700452p15700452.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] Plot Principal component analysis

2008-02-26 Thread SNN

Hi,

I have matrix of 300,000*115 (snps*individual). I ran the PCA on the
covariance matrix which has a dimention oof 115*115. I have the first 100
individuals from group A and the rest of 15 individuals from group B. I need
to plot the data in two and 3 dimentions with respect to PC1 and PC2 and (in
3D with respect to PC1, PC2 and PC3). I do not know how to have the plot
ploting the first 100 points corresponding to group A in red (for example)
and the rest of the 15 points in Blue? i.e I want the each group in a
diffrent color in the same plot. I appreciate if someone can help.

Thanks,
-- 
View this message in context: 
http://www.nabble.com/Plot-Principal-component-analysis-tp15700123p15700123.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] Multiple lines with a different color assigned to each line

2008-02-26 Thread Judith Flores
Dear R-experts,

   I want to assign different colors to groups of
points, lines and segments in a plot.

  I have a vector(dat$tx) that is going to have a
different number of levels every time the user wants
to plot a set of data. The number of lines is going to
be equal to the number of levels of the vector
mentioned. 

What I have so far is this:

plot(1,1,type="n")
for (i in dat$tx) {

   points(summ$timep[summ$tx==i],summ$mn[summ$tx==i])
   lines(summ$timep[summ$tx==i],summ$mn[summ$tx==i])
}

How can I assign different colors to the points and
lines?

Thank you in advance for any help,

Judith


  

Be a better friend, newshound, and

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Summing up diagonals w/o for-loop

2008-02-26 Thread Marc Schwartz
Camarda, Carlo Giovanni wrote:
> Dear R-users,
>
> is there any way to sum up the elements of the "diagonals" of a matrix
> without using a for-loop? While there is a simple way over rows and
> columns, I don't see a straightforward multiplication for the diagonals,
> am I too demanding? Or, more likely, I'm lack some algebra trick? Is
> there any R-function that can deal with this problem w/o loop?
>
> Actually I would need to sum up just the upper diagonals.
>
> Here a simple, but general, example for presenting the problem.
>
> Thanks in advance for any help,
> Carlo Giovanni Camarda
>
> m<- 7
> n<- 5
> mat<- matrix(1:35, n, m)
> ones.r<- rep(1,n)
> ones.c<- rep(1,m)
> # sum over the rows
> sum.r<- mat%*%ones.c
> # sum over the cols
> sum.c<- t(mat)%*%ones.r
> # sum over the diags
> sum.d<- numeric(m+n-1)
> sum.d[1]<- mat[n,1]
> sum.d[m+n-1]<- mat[1,m]
> for(i in 2:n){
>  sum.d[i]<- sum(diag(mat[(n+1-i):n,1:i]))
> }
> for(i in 2:(m-1)){
>  sum.d[i+n-1]<- sum(diag(mat[,i:m]))
> }
>


If we have 'mat':

 > mat
  [,1] [,2] [,3] [,4] [,5] [,6] [,7]
[1,]16   11   16   21   26   31
[2,]27   12   17   22   27   32
[3,]38   13   18   23   28   33
[4,]49   14   19   24   29   34
[5,]5   10   15   20   25   30   35


You can use:

 > rowSums(mat)
[1] 112 119 126 133 140

and:

 > colSums(mat)
[1]  15  40  65  90 115 140 165


for your initial steps, rather than the matrix multiplication. See 
?colSums for more information.

There may be a better way than this, but one approach for the diagonals 
in the order you want is to split() the matrix into it's constituent 
diagonals based upon subsetting using the row() and col() values. This 
yields a list:

 > split(mat, col(mat) - row(mat))
$`-4`
[1] 5

$`-3`
[1]  4 10

$`-2`
[1]  3  9 15

$`-1`
[1]  2  8 14 20

$`0`
[1]  1  7 13 19 25

$`1`
[1]  6 12 18 24 30

$`2`
[1] 11 17 23 29 35

$`3`
[1] 16 22 28 34

$`4`
[1] 21 27 33

$`5`
[1] 26 32

$`6`
[1] 31



Then we can use sapply() to sum() over the list elements:

 > sum.d
  [1]   5  14  27  44  65  90 115 100  81  58  31

 > sapply(split(mat, col(mat) - row(mat)), sum)
  -4  -3  -2  -1   0   1   2   3   4   5   6
   5  14  27  44  65  90 115 100  81  58  31

If you want to sum the diagonals "the other way" replace the '-' in the 
second argument in split() with a '+'.


See ?split, ?sapply, ?row and ?col for more information.

HTH,

Marc Schwartz

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 values from adfstat objects

2008-02-26 Thread Matt33

Thanks for the tip, Erik. I did check, but didn't see any $... elements to
choose from. For comparison, I checked another object class (lm) with the
str function, and it clearly showed $coefficients, $residuals, etc..

So it would seem that the usual approach doesn't work with adfstat
objects...
-- 
View this message in context: 
http://www.nabble.com/Obtaining-values-from-adfstat-objects-tp15699940p15700174.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] Obtaining values from adfstat objects

2008-02-26 Thread Erik Iverson
Try str(yourobject) to see the structure of the object.  If there were a 
value called, say, p.value, you could then do:

myvar <- yourobject$p.value

This is just general advice, I don't know the specifics of the package 
you mention, but try this first.

Best,
Erik Iverson

Matt33 wrote:
> Hi,
> 
> I'm using the ADF.test function in the uroot package to obtain an
> adfstat-class object. I'm wondering how I can extract the values (test
> statistic, p value, etc.) from this class, since it doesn't seem to have
> usual values. I get the following summary, but I'm not sure how to do
> anything with these values -- how can I put the number into another
> variable?
> 
>   - -- - -- 
>   Augmented Dickey & Fuller test
>   - -- - -- 
> 
>   Null hypothesis: Unit root.
>   Alternative hypothesis: Stationarity.
> 
> 
>   ADF statistic:
> 
> Estimate Std. Error t value Pr(>|t|)
> adf.reg   -0.997  0.123  -8.074 0.01
> 
>   Lag orders: 
>   Number of available observations: 67 
> Warning message:
> In interpolpval(code = code, stat = adfreg[, 3], N = N) :
>   p-value is smaller than printed p-value
> 
> Thanks.

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


[R] Obtaining values from adfstat objects

2008-02-26 Thread Matt33

Hi,

I'm using the ADF.test function in the uroot package to obtain an
adfstat-class object. I'm wondering how I can extract the values (test
statistic, p value, etc.) from this class, since it doesn't seem to have
usual values. I get the following summary, but I'm not sure how to do
anything with these values -- how can I put the number into another
variable?

  - -- - -- 
  Augmented Dickey & Fuller test
  - -- - -- 

  Null hypothesis: Unit root.
  Alternative hypothesis: Stationarity.


  ADF statistic:

Estimate Std. Error t value Pr(>|t|)
adf.reg   -0.997  0.123  -8.074 0.01

  Lag orders: 
  Number of available observations: 67 
Warning message:
In interpolpval(code = code, stat = adfreg[, 3], N = N) :
  p-value is smaller than printed p-value

Thanks.
-- 
View this message in context: 
http://www.nabble.com/Obtaining-values-from-adfstat-objects-tp15699940p15699940.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] How to include the documentation of a function in a Sweave document?

2008-02-26 Thread Jean lobry
Dear all,

thanks for your suggestions. I like the idea of including directly
the LaTeX file corresponding to the targeted topic, however, my
understanding from the reading of ?help is that these LaTeX files
are not always available, depending on the build of R.

I found a solution that works well enough for me by removing
the backslashes from the help file this way:

 tmp.rnw 
\documentclass{article}
\begin{document}

<>=
mypager <- function(..., header = rep("", nfiles),
   title = "R Information", delete.file = FALSE){
   args <- list(...)
   sanitize <- function(strings){
 f <- function(x){
   x.raw <- charToRaw(x)
   backspaces <- which(x.raw == charToRaw('\b'))
   if(length(backspaces) > 0){
 x.raw <- x.raw[-c(backspaces, backspaces - 1)] # remove "_\b"
   }
   rawToChar(x.raw[x.raw >= as.raw(20)]) # remove non-printable ASCII
 }
 res <- sapply(strings, f)
 names(res) <- NULL
 return(res)
   }
   help.out <- lapply(args[[1]], readLines)
   help.out <- lapply(help.out, sanitize)
   lapply(help.out, cat, sep = "\n")
}
@

<>=
?plot
@
<>=
help("plot", chmhelp = FALSE, htmlhelp = FALSE, pager = mypager)
@

\end{document}
 tmp.rnw 

This works well for me when I'm Sweaving the file from an R
session in the CLI interface in a terminal, but not when I'm
Sweaving the file from the R GUI for the Mac (the function
mypager is not called despite pager = mypager when calling
the help function, don't understand why).

The PDF looks like this:
http://pbil.univ-lyon1.fr/members/lobry/tmp/tmp.pdf

Thanks again for your help,

Best,

Jean

-- 
Jean R. Lobry([EMAIL PROTECTED])
Laboratoire BBE-CNRS-UMR-5558, Univ. C. Bernard - LYON I,
43 Bd 11/11/1918, F-69622 VILLEURBANNE CEDEX, FRANCE
allo  : +33 472 43 27 56 fax: +33 472 43 13 88
http://pbil.univ-lyon1.fr/members/lobry/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Summing up diagonals w/o for-loop

2008-02-26 Thread Greg Snow
Does this do what you want?

> d <- col(mat) - row(mat)
> tapply( mat, d, sum )

Hope this helps,

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
(801) 408-8111
 
 

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Camarda, 
> Carlo Giovanni
> Sent: Tuesday, February 26, 2008 1:32 PM
> To: [EMAIL PROTECTED]
> Subject: [R] Summing up diagonals w/o for-loop
> 
> Dear R-users,
> 
> is there any way to sum up the elements of the "diagonals" of 
> a matrix without using a for-loop? While there is a simple 
> way over rows and columns, I don't see a straightforward 
> multiplication for the diagonals, am I too demanding? Or, 
> more likely, I'm lack some algebra trick? Is there any 
> R-function that can deal with this problem w/o loop?
> 
> Actually I would need to sum up just the upper diagonals.
> 
> Here a simple, but general, example for presenting the problem. 
> 
> Thanks in advance for any help,
> Carlo Giovanni Camarda
> 
> m <- 7
> n <- 5
> mat <- matrix(1:35, n, m)
> ones.r <- rep(1,n)
> ones.c <- rep(1,m)
> # sum over the rows
> sum.r <- mat%*%ones.c
> # sum over the cols
> sum.c <- t(mat)%*%ones.r
> # sum over the diags
> sum.d <- numeric(m+n-1)
> sum.d[1] <- mat[n,1]
> sum.d[m+n-1] <- mat[1,m]
> for(i in 2:n){
> sum.d[i] <- sum(diag(mat[(n+1-i):n,1:i])) } for(i in 2:(m-1)){
> sum.d[i+n-1] <- sum(diag(mat[,i:m])) }
> 
> 
> 
> --
> This mail has been sent through the MPI for Demographic 
> ...{{dropped:10}}
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Cryptic error message using RuleFit

2008-02-26 Thread Christopher Schwalm
Hello LIST,

In using Rulefit I;ve bee nabel to fit a model using rulefit without 
incident. However, when trying to use intnull and interact things go 
astray.

> rf=rulefit(x,"N", cat.vars="H", 
> not.used=c("G","T"),huber=0.9,path.speed=1);
[snip]
RuleFit model 2/26/2008 2:17p
ave(abs(error)) terms path steps
84.16 110 8301

> null.mod <- intnull()
[snip building trees and fitting rules]
Warning messages:
1: In system("mv -f rulefit.mod mod.sv") : mv not found
2: In system("mv -f rulefit.sum sum.sv") : mv not found
3: In system("mv -f rfout out.sv") : mv not found
4: In system("mv -f train.y train.sv") : mv not found
5: In system("mv -f mod.sv rulefit.mod") : mv not found
6: In system("mv -f sum.sv rulefit.sum") : mv not found
7: In system("mv -f train.sv train.y") : mv not found
8: In system("mv -f out.sv rfout") : mv not found

> int = interact(c("A", "M", "H", "P"), null.mod)
Error in interact(c("A", "M", "H", "P"), null.mod) : 
  input null.mods inconsistent with RuleFit home directory model.

Something is amiss with the directory but it looks fine (the files from rf 
are present and where they should be based on the installation notes) and I 
can not figure out what the missing piece here is. Any insight appreciated.

Thanks,
Christopher

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Summing up diagonals w/o for-loop

2008-02-26 Thread Camarda, Carlo Giovanni
Dear R-users,

is there any way to sum up the elements of the "diagonals" of a matrix
without using a for-loop? While there is a simple way over rows and
columns, I don't see a straightforward multiplication for the diagonals,
am I too demanding? Or, more likely, I'm lack some algebra trick? Is
there any R-function that can deal with this problem w/o loop?

Actually I would need to sum up just the upper diagonals.

Here a simple, but general, example for presenting the problem. 

Thanks in advance for any help,
Carlo Giovanni Camarda

m <- 7
n <- 5
mat <- matrix(1:35, n, m)
ones.r <- rep(1,n)
ones.c <- rep(1,m)
# sum over the rows
sum.r <- mat%*%ones.c
# sum over the cols
sum.c <- t(mat)%*%ones.r
# sum over the diags
sum.d <- numeric(m+n-1)
sum.d[1] <- mat[n,1]
sum.d[m+n-1] <- mat[1,m]
for(i in 2:n){
sum.d[i] <- sum(diag(mat[(n+1-i):n,1:i]))
}
for(i in 2:(m-1)){
sum.d[i+n-1] <- sum(diag(mat[,i:m]))
}



--
This mail has been sent through the MPI for Demographic ...{{dropped:10}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Subsetting within xyplot()

2008-02-26 Thread Erik Iverson
See the description of the subset argument in ?xyplot

   subset: logical or integer indexing vector (can be specified in terms
   of variables in 'data').  Only these rows of 'data' will be
   used for the plot.  If 'subscripts' is 'TRUE', the subscripts
   will provide indices to the rows of data before the
   subsetting is done.  Whether levels of factors in the data
   frame that are unused after the subsetting will be dropped
   depends on the 'drop.unused.levels' argument.

That is not what you are passing.

David Afshartous wrote:
> All,
> 
> I'm having problems w/ a simple attempt to subset an xyplot.
> 
> The first plot below is a plot of y versus x for certain values of a third
> categorical variable z.  Now I'd like to further restrict this to certain
> values of variable y.  Neither of the two attempts below work.  Any
> suggestions much appreciated.  (note: I don't want to merely use ylim since
> I have a loess plot and I want this to be calculated w/ the restricted
> values).
> 
> Thanks,
> David 
> 
> 
> 
> 
> y = c( 0.4,  0.6, -0.1,  0.3,  0.3, -0.2,  0.7,  0.7,  0.2,  0.0,  0.9,
> -0.1,  0.6, -1.1,  0.8, -1.0,  0.4,  0.1,  0.7, -0.2, -0.1, -0.1,  2.2,
> 0.7,  1.1,  0.2, -0.2, -0.9,  0.4,  0.1, -0.3, -0.4)
> x = c(4.1000,  4.9600,  1.2000,  3.9000,  3.1875,  1.9000,  1.8625,
> 0.7650,  1.5750,  2.4700,  1.6250,  1.5500,  2.3125,  1.3125,  1.0600,
> -0.5500,  1.1000,  0.0200, -0.0375,  3.4600,  2.5250,  2.0950,  0.8000,
> 1.6050, -0.4150, -0.7300,  1.1550,  1.4850,  2.2000,  2.2500,  0.6000,
> 2.1000)
> junk.frm = data.frame(x, y, z = rep(c("D", "P"), 16))
> 
> xyplot(y ~ x , data = junk.frm[junk.frm$z =="D",], type = c("g", "p",
> "smooth"), pch = 20)
> 
> xyplot(y ~ x , data = junk.frm[junk.frm$z =="D",], type = c("g", "p",
> "smooth"), pch = 20,
> , subset = junk.frm[junk.frm$y < 2, ])
> Error in tmp[subset] : invalid subscript type 'list'
> 
> xyplot(y ~ x , data = junk.frm[junk.frm$z =="D",], type = c("g", "p",
> "smooth"), pch = 20,
> data = junk.frm[junk.frm$y < 2 & junk.frm$z =="D", ])
> Error in xyplot(y ~ x, data = junk.frm[junk.frm$z == "D", ], type = c("g",
> : 
>   formal argument "data" matched by multiple actual arguments
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] combining 40,000 with 40,000 data frame (different tact)

2008-02-26 Thread stephen sefick
I have not been able to find anything to do what I want, so I am going
to tact to the left.  I have twp continuous time series for two years
with the same fourteen variables.  I would like to simply append the
second year to the first.  They both have the same column headings
etc.  Just like tapping two pieces of paper together for a long number
series.
Thanks

Stephen

-- 
Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods.  We are mammals, and have not exhausted the
annoying little problems of being mammals.

-K. Mullis

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Subsetting within xyplot()

2008-02-26 Thread Henrique Dallazuanna
Try this:

 xyplot(y ~ x , data = junk.frm, type = c("g", "p","smooth"), pch=20,
subset=z=="D" & y < 2)

On 26/02/2008, David Afshartous <[EMAIL PROTECTED]> wrote:
>
>  All,
>
>  I'm having problems w/ a simple attempt to subset an xyplot.
>
>  The first plot below is a plot of y versus x for certain values of a third
>  categorical variable z.  Now I'd like to further restrict this to certain
>  values of variable y.  Neither of the two attempts below work.  Any
>  suggestions much appreciated.  (note: I don't want to merely use ylim since
>  I have a loess plot and I want this to be calculated w/ the restricted
>  values).
>
>  Thanks,
>  David
>
>
>
>
>  y = c( 0.4,  0.6, -0.1,  0.3,  0.3, -0.2,  0.7,  0.7,  0.2,  0.0,  0.9,
>  -0.1,  0.6, -1.1,  0.8, -1.0,  0.4,  0.1,  0.7, -0.2, -0.1, -0.1,  2.2,
>  0.7,  1.1,  0.2, -0.2, -0.9,  0.4,  0.1, -0.3, -0.4)
>  x = c(4.1000,  4.9600,  1.2000,  3.9000,  3.1875,  1.9000,  1.8625,
>  0.7650,  1.5750,  2.4700,  1.6250,  1.5500,  2.3125,  1.3125,  1.0600,
>  -0.5500,  1.1000,  0.0200, -0.0375,  3.4600,  2.5250,  2.0950,  0.8000,
>  1.6050, -0.4150, -0.7300,  1.1550,  1.4850,  2.2000,  2.2500,  0.6000,
>  2.1000)
>  junk.frm = data.frame(x, y, z = rep(c("D", "P"), 16))
>
>  xyplot(y ~ x , data = junk.frm[junk.frm$z =="D",], type = c("g", "p",
>  "smooth"), pch = 20)
>
>  xyplot(y ~ x , data = junk.frm[junk.frm$z =="D",], type = c("g", "p",
>  "smooth"), pch = 20,
>  , subset = junk.frm[junk.frm$y < 2, ])
>  Error in tmp[subset] : invalid subscript type 'list'
>
>  xyplot(y ~ x , data = junk.frm[junk.frm$z =="D",], type = c("g", "p",
>  "smooth"), pch = 20,
>  data = junk.frm[junk.frm$y < 2 & junk.frm$z =="D", ])
>  Error in xyplot(y ~ x, data = junk.frm[junk.frm$z == "D", ], type = c("g",
>  :
>   formal argument "data" matched by multiple actual arguments
>
>  __
>  R-help@r-project.org mailing list
>  https://stat.ethz.ch/mailman/listinfo/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.


[R] Subsetting within xyplot()

2008-02-26 Thread David Afshartous

All,

I'm having problems w/ a simple attempt to subset an xyplot.

The first plot below is a plot of y versus x for certain values of a third
categorical variable z.  Now I'd like to further restrict this to certain
values of variable y.  Neither of the two attempts below work.  Any
suggestions much appreciated.  (note: I don't want to merely use ylim since
I have a loess plot and I want this to be calculated w/ the restricted
values).

Thanks,
David 




y = c( 0.4,  0.6, -0.1,  0.3,  0.3, -0.2,  0.7,  0.7,  0.2,  0.0,  0.9,
-0.1,  0.6, -1.1,  0.8, -1.0,  0.4,  0.1,  0.7, -0.2, -0.1, -0.1,  2.2,
0.7,  1.1,  0.2, -0.2, -0.9,  0.4,  0.1, -0.3, -0.4)
x = c(4.1000,  4.9600,  1.2000,  3.9000,  3.1875,  1.9000,  1.8625,
0.7650,  1.5750,  2.4700,  1.6250,  1.5500,  2.3125,  1.3125,  1.0600,
-0.5500,  1.1000,  0.0200, -0.0375,  3.4600,  2.5250,  2.0950,  0.8000,
1.6050, -0.4150, -0.7300,  1.1550,  1.4850,  2.2000,  2.2500,  0.6000,
2.1000)
junk.frm = data.frame(x, y, z = rep(c("D", "P"), 16))

xyplot(y ~ x , data = junk.frm[junk.frm$z =="D",], type = c("g", "p",
"smooth"), pch = 20)

xyplot(y ~ x , data = junk.frm[junk.frm$z =="D",], type = c("g", "p",
"smooth"), pch = 20,
, subset = junk.frm[junk.frm$y < 2, ])
Error in tmp[subset] : invalid subscript type 'list'

xyplot(y ~ x , data = junk.frm[junk.frm$z =="D",], type = c("g", "p",
"smooth"), pch = 20,
data = junk.frm[junk.frm$y < 2 & junk.frm$z =="D", ])
Error in xyplot(y ~ x, data = junk.frm[junk.frm$z == "D", ], type = c("g",
: 
  formal argument "data" matched by multiple actual arguments

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Kenward-Roger correction in lme

2008-02-26 Thread Douglas Bates
On Mon, Feb 25, 2008 at 1:46 PM, Peter Dalgaard
<[EMAIL PROTECTED]> wrote:
> Ben Bolker wrote:
>  > stian  mail.rockefeller.edu  mail.rockefeller.edu> writes:
>  >
>  >> Hi,I am wondering how to conduct Kenward-Roger correction in
>  >> the linear mixed model using R. Any idea?
>  >>
>  >> Thanks a lot,
>  >>
>  >> Suyan
>  >>
>  >
>  >   Not really possible, I'm afraid.  Having already invested a huge
>  > amount of time in making lme4 available (and this is the cutting-edge
>  > version of linear mixed models for R), Doug Bates has declined to
>  > spend effort implementing K-R because (1) he's not convinced of the
>  > appropriateness of adjusting F-distribution degrees of freedom in
>  > this way, (2) he doesn't think that the K-R algorithm will be
>  > feasible for the sorts of large-data problems he's interested in,
>  > (3) [can't find the reference] he finds the correspondence between
>  > K-R's notation and his difficult.

Regarding (2), it is more an issue of the structure of the model than
of the size of the data set.  One of the big differences between the
lme4 package and the nlme package, or other software for fitting
linear mixed models, is that lme4 is designed to handle models with
non-nested random effects.  The random effects can be completely
crossed, such as in an experiment where a sample of subjects are each
exposed to the same selection of items and the model incorporates
random effects for both subject and item, or partially crossed where
annual test scores may be associated with both the student taking the
test and the teacher for the student that year.

It has been a while since I looked at the Kenward-Roger formulation
but my recollection is that it would be difficult to extend the
calculations to models with non-nested random effects.  I am not
opposed to the method in principle - it's just that I am not about to
have the time to work on it myself in the foreseeable future.  If
someone else wants to work it out then I say go for it.

>  The last one could be due to me rather than Doug, and certainly, it is
>  just an obstacle rather than anything prohibitive in itself. I tend to
>  think that (2) is "nontrivial" rather than "infeasible", but it is true
>  that the K-R formulas depend on items like the covariance matrix (say,
>  Sigma) for the entire data set, which is at best implicitly available in
>  large-data problems. Whether or not it would be possible to work with
>  implicit representations of Sigma is what is difficult to see because of
>  the notational differences (it's been a while, but my recollection is
>  that Doug uses Sigma for a different purpose, and there are a couple of
>  similarly confusing notational switches).

Beyond notation there is a question of emphasis in the formulation of
the model.  Most of the theory of linear mixed models focuses on the
marginal distribution of the response random variable.  I have found
it more useful to consider the distribution of the random effects,
conditional on the observed values of the response.  My latest
attempts to explain the computational methods (slides at
http://www.stat.wisc.edu/~bates/2008-02-22-Emory.pdf)  examine the
conditional distribution of the random effects - in particular, the
unnormalized conditional density of the random effects.  In the case
of a linear mixed model the logarithm of this density is a quadratic
form.  For a generalized linear mixed model or a nonlinear mixed model
or a generalized nonlinear mixed model the conditional density can be
optimized via a penalized IRLS or penalized NLS algorithm to obtain
the conditional means and the conditional variance-covariance matrix.

I consider a linear transformation, U, of the random effects, B, for
which Var(U) = sigma^2 I.  By transforming to U I can incorporate the
effect of the variance component parameters into a (sparse) model
matrix A rather than into the variance-covariance matrix.  The linear
predictor that was expressed as eta = X beta + Z b is now X beta + A'
u  where A is the transpose of a sparse model matrix that is derived
from Z.  Evaluation of the deviance and related quantities hinges on
calculating the sparse Cholesky factor L that satisfies LL' = AA' + I.
(There is also a fixed permutation matrix. P, involved in that
expression but it doesn't have any effect on the theory - although it
can have a tremendous effect on the speed of the calculation.)

One reason for expressing the model in this way is because it is
exactly the way that the calculations are carried out.  There are
slots named X, Zt (for Z-transpose), A and L in the object returned by
lmer and they have exactly the meanings shown above.

It is possible to get an expression for the marginal
variance-covariance of the response vector but it will be an n by n
matrix and will only have nice sparsity patterns for models with
nested random effects.  For models with non-nested random effects this
is potentially a dense n by n matrix and you really don't want to try
work

Re: [R] Reading a file created with Fortran

2008-02-26 Thread Ben Bolker
Dennis Fisher  plessthan.com> writes:

> 
> Colleagues,
> 
> I am trying to read a file written by Fortran.  Several lines of the  
> file are pasted below:

  Perhaps read.fwf is what you want?  (fwf stands for
"fixed width format").  You would have to work out the
field widths, but it would seem to be pretty straightforward).
[A little bit of extra verbiage will make gmane happier ...]

  Ben Bolker

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


[R] Reading a file created with Fortran

2008-02-26 Thread Dennis Fisher
Colleagues,

I am trying to read a file written by Fortran.  Several lines of the  
file are pasted below:

101   06e+050280.9777.484208.18147.20.246350.4020.7308717.882600 1 1
101 0.500280.9777.484208.18147.20.246350.4020.7308717.882600 0 0
101   100280.9777.484208.18147.20.246350.4020.7308717.882600 0 0
101 1.500280.9777.484208.18147.20.246350.4020.7308717.882600 0 0
101   200280.9777.484208.18147.20.246350.4020.7308717.882600 0 0
101 2.500280.9777.484208.18147.20.246350.4020.7308717.882600 0 0
101   300280.9777.484208.18147.20.246350.4020.7308717.882600 0 0
101   400280.9777.484208.18147.20.246350.4020.7308717.882600 0 0
101   600280.9777.484208.18147.20.246350.4020.7308717.882600 0 0

The fortran format statement is:
(E3.0,E4.0,E5.0,E1.0,3E6.0,E5.0,E7.0,E5.0,E7.0,E6.0,E3.0,2F2.0)

The read.table command cannot parse the table correctly because there  
are no spaces between columns.  Although readLines reads the file, it  
does not separate the elements into columns.  I suspect that the  
"what" option of "scan" accomplishes my intent although its  
implementation is poorly document in help (or perhaps I am too dense  
to understand it).

Can anyone advise as to an efficient means to read these data and  
separate into columns?

Thanks.

Dennis


Dennis Fisher MD
P < (The "P Less Than" Company)
Phone: 1-866-PLessThan (1-866-753-7784)
Fax: 1-415-564-2220
www.PLessThan.com


[[alternative HTML version deleted]]

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


Re: [R] Custom LaTeX tables

2008-02-26 Thread Gabor Grothendieck
On Tue, Feb 26, 2008 at 10:58 AM, Werner Wernersen
<[EMAIL PROTECTED]> wrote:
> Hello,
>
> I am very happy that I have Sweave and R to write my
> papers. But I still have to do some tables by hand
> since I have not found out how I can customize the
> latex tables produced by R further (I mainly use
> xtable()). Like for instance, I have a table which
> needs an extra row every few rows as a group header
> and sometimes I want some extra horizontal lines in
> the table and also a multicolumn heading.
>
> How do you guys cope with such cases, do you set the
> table by hand in the end or have you found a neat way
> to deal with this?
>
> Many thanks and regards,
>  Werner

A few options are:

- Hmisc latex() supports multicolumn headings and group headings
although the large number of arguments may be daunting

- xtable (and Hmisc's latex too) supports a style of combining
latex fragments with the xtable.  The add.to.row= argument on
print.xtable is the
one to notice. e.g. using the builtin BOD data frame this adds a 2nd row
of headings and a group heading:

print(xtable(BOD, align = "r|r|r|"), include.rownames = FALSE,
add.to.row = list(pos = list(0, 3),
command = c("\\multicolumn{1}{|c|}{(days)} &
\\multicolumn{1}{|c|}{(mg/l)}  ",
"\\hline \\multicolumn{2}{|l|}{Special Values}  \\hline ")))

- given the freedom from restrictions I find its often just best to
do it manually in latex or if you have many tables with the same format
in a report to generate a report-specific table layout wrapper that emits
the latex you need.

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


Re: [R] using eval-parse-paste in a loop

2008-02-26 Thread Tony Plate
Using eval-parse for this looks like overkill.  You should just be able to 
do something straightforward like:

for (i in 1:120)
   assign(paste("book", i, sep=""), read.xls(paste("Book", i, ".xls", 
sep=""), sheet=1, from=4, colClasses="numeric"))

which would put your spreadsheets in variables book1, book2, etc.

Or, if you want to put everything in a list:

books <- lapply(1:120, function(i) read.xls(paste("Book", i, ".xls", 
sep=""), sheet=1, from=4, colClasses="numeric"))

BTW, the reason your attempts with parse() were failing is that default 
argument of parse() is a filename (do args(parse) to see this quickly). 
You wanted parse(text=...).

-- Tony Plate

Michael Anyadike-Danes wrote:
> R-helpers
> 
>  
> 
> I have 120 small Excel sheets to read and I am using
> library(xlsReadWrite): one example below.
> 
>  
> 
> I had hoped to read sheets by looping over a list of numbers in their
> name (eg Book1.xls, Book2.xls, etc).
> 
>  
> 
> I thought I had seen examples which used eval-parse-paste in this way. 
> 
>  
> 
> However, I have not been able to get it to work..
> 
>  
> 
> 1. is this a feasible approach?
> 
>  
> 
> 2. if not advice would be welcome.
> 
>  
> 
> 3. Equally, advice about a better approach would also be v. welcome.
> 
>  
> 
> I haven't included the data because my failed attempt is
> data-independent (and probably more basic).  
> 
>  
> 
>  
> 
> Michael Anyadike-Danes
> 
>  
> 
> # show that read.xls works
> 
>  
> 
>> test <- read.xls("Book1.xls",sheet=1,from=4,colClasses="numeric")
> 
>> str(test)
> 
> 'data.frame':   23 obs. of  13 variables:
> 
>  $ Off.Flows..Thousands.: num  117.19NaN NA   1.43   2.26 ...
> 
>  $ Off.Flows..Thousands.: num  8.42 NaN NA 0.08 0.11 0.01 0.11 1.59 0.16
> 0.04 ...
> 
>  $ Off.Flows..Thousands.: num  20 NaN NA 0.2 0.3 0.02 0.32 4.39 0.41
> 0.11 ...
> 
>  $ Off.Flows..Thousands.: num  12.36   NaNNA  0.14  0.27 ...
> 
>  $ Off.Flows..Thousands.: num  7.59 NaN NA 0.11 0.18 0.01 0.14 1.46 0.23
> 0.06 ...
> 
>  $ Off.Flows..Thousands.: num  10.31   NaNNA  0.12  0.23 ...
> 
>  $ Off.Flows..Thousands.: num  7.55 NaN NA 0.08 0.2 0.01 0.11 1.6 0.23
> 0.05 ...
> 
>  $ Off.Flows..Thousands.: num  10.57   NaNNA  0.19  0.21 ...
> 
>  $ Off.Flows..Thousands.: num  9.36 NaN NA 0.13 0.26 0.02 0.13 2.12 0.27
> 0.07 ...
> 
>  $ Off.Flows..Thousands.: num  8.21 NaN NA 0.1 0.19 0.01 0.1 1.9 0.23
> 0.06 ...
> 
>  $ Off.Flows..Thousands.: num  9.04 NaN NA 0.13 0.11 0.01 0.17 1.54 0.17
> 0.05 ...
> 
>  $ Off.Flows..Thousands.: num  13.42   NaNNA  0.14  0.19 ...
> 
>  $ Off.Flows..Thousands.: num  0.37 NaN NA NaN 0.01 NaN 0.01 0.05 0.02
> NaN ...
> 
>  
> 
> ### simple minded attempt substituting eval-parse-paste
> 
>  
> 
>> nam <- 1
> 
>  
> 
>> test <-
> eval(parse(paste('read.xls("Book',nam,'.xls",sheet=1,from=4,colClasses="
> numeric")',sep='')))
> 
> Error in file(file, "r") : unable to open connection
> 
> In addition: Warning message:
> 
> In file(file, "r") :
> 
>   cannot open file
> 'read.xls("Book1.xls",sheet=1,from=4,colClasses="numeric")', reason
> 'Invalid argument'
> 
>  
> 
> ### stripping off eval, looking for clues
> 
>  
> 
> parse(paste('read.xls("Book',nam,'.xls",sheet=1,from=4,colClasses="numer
> ic")',sep=''))
> 
> Error in file(file, "r") : unable to open connection
> 
> In addition: Warning message:
> 
> In file(file, "r") :
> 
>   cannot open file
> 'read.xls("Book1.xls",sheet=1,from=4,colClasses="numeric")', reason
> 'Invalid argument'
> 
>  
> 
> ### stripping off parse, still looking for clues
> 
>  
> 
> paste('read.xls("Book',nam,'.xls",sheet=1,from=4,colClasses="numeric")',
> sep='')
> 
> [1] "read.xls(\"Book1.xls\",sheet=1,from=4,colClasses=\"numeric\")"
> 
>  
> 
> 
> 
> 
> 
> Economic Research Institute of Northern Ireland
> 
> Floral Buildings
> 
> 2-14 East Bridge Street
> 
> Belfast BT1 3NQ
> 
> Tel:  (028) 90727362
> 
> Fax: (028) 90319003
> 
> 
> 
> 
>   [[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] Kalman Filter

2008-02-26 Thread Vladimír Šamaj
Hi

My name is Vladimir Samaj. I am a student of Univerzity of Zilina. I am
trying to implement Kalman Filter into my school work. I have some problems
with understanding of R version of Kalman Filter in package stats( functions
KalmanLike, KalmanRun, KalmanSmooth,KalmanForecast).

1) Can you tell me how are you seting the initial values of state vector in
Kalman Filter? Are you using some method?

2) I have fond function StructTS in stats package. I dont understand, how
exactly, are you computing(what method are you using) fitted values which
are the output of this function( $fitted ) . In description od this function
is that it fit a structural model for a time series by maximum likehood.
Does it means, that the fitted values are fit by maximum likehood? If so how
does look the likehood function?

3)Finaly, I dont understand smooting problem.  What I know is that, if I
have t observations of some time serie, I can use  function KalmanRun to get
estimates of state vector. And if I gain aditional observations of time
serie( T > t ), I shoud use KalmanSmooth function to smooth estimates of
state vector. I dont understand, that how shoud I "tell" to KalmanSmooth
funtion that I allready did filtering and it shoud use the values from
filtering to smoothing.

I will be glad if you help me. I hope that my folmulations were correct.

Thank you very much.

[[alternative HTML version deleted]]

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


Re: [R] using eval-parse-paste in a loop

2008-02-26 Thread Bert Gunter
As Thomas Lumley has frequently noted, eval(parse...)) should generally be
avoided.

You probably want do.call(), as in

## warning: UNTESTED

lapply(numbs,
function(n)do.call(read.xls,list(file=paste("Book",n,".xls",sep=""),sheet=1,
...)))   ## ... contains the other explicitly names arguments


Note that this would automatically create your list for you.

Cheers,

Bert Gunter
Genentech Nonclinical Statistics

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Erik Iverson
Sent: Tuesday, February 26, 2008 9:29 AM
To: Michael Anyadike-Danes
Cc: r-help@r-project.org
Subject: Re: [R] using eval-parse-paste in a loop


> ### stripping off eval, looking for clues
> 
>  
> 
> parse(paste('read.xls("Book',nam,'.xls",sheet=1,from=4,colClasses="numer
> ic")',sep=''))
> 
> Error in file(file, "r") : unable to open connection
> 
> In addition: Warning message:
> 
> In file(file, "r") :
> 
>   cannot open file
> 'read.xls("Book1.xls",sheet=1,from=4,colClasses="numeric")', reason
> 'Invalid argument'
> 

Your clue is that it looks like parseis unsuccessfully trying to open a 
file.  Look at ?parse and note the first argument, which you are using 
because of positional matching.

You want eval(parse(text = paste(...)))

Best,
Erik Iverson

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

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


Re: [R] using eval-parse-paste in a loop

2008-02-26 Thread Erik Iverson
Michael -


> 
> 3. Equally, advice about a better approach would also be v. welcome.
> 


As an alternative approach, you may want to save the sheet names in a 
list and then use the lapply function to read your data into a list. 
This would greatly reduce the 'clutter' of objects in your global 
environment, and then let you apply analysis functions to each sheet 
with subsequent usage of the *apply functions.

Best,
Erik Iverson

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


Re: [R] using eval-parse-paste in a loop

2008-02-26 Thread Erik Iverson

> ### stripping off eval, looking for clues
> 
>  
> 
> parse(paste('read.xls("Book',nam,'.xls",sheet=1,from=4,colClasses="numer
> ic")',sep=''))
> 
> Error in file(file, "r") : unable to open connection
> 
> In addition: Warning message:
> 
> In file(file, "r") :
> 
>   cannot open file
> 'read.xls("Book1.xls",sheet=1,from=4,colClasses="numeric")', reason
> 'Invalid argument'
> 

Your clue is that it looks like parseis unsuccessfully trying to open a 
file.  Look at ?parse and note the first argument, which you are using 
because of positional matching.

You want eval(parse(text = paste(...)))

Best,
Erik Iverson

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


Re: [R] R package to perform Horn's parallel analysis

2008-02-26 Thread falissard
And also scree.plot psy package.



Bruno Falissard
INSERM U669, PSIGIAM
"Paris Sud Innovation Group in Adolescent Mental Health"
Maison de Solenn
97 Boulevard de Port Royal
75679 Paris cedex 14, France
tel : (+33) 6 81 82 70 76
fax : (+33) 1 58 41 28 43
web site : http://perso.wanadoo.fr/bruno.falissard/



-Message d'origine-
De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] De
la part de William Revelle
Envoyé : mardi 26 février 2008 16:44
À : Karen Douglas; R-help@r-project.org
Objet : Re: [R] R package to perform Horn's parallel analysis

see fa.parallel in the psych package


At 7:27 AM -0800 2/26/08, Karen Douglas wrote:
>I am seeking information on whether anyone has written code to perform
>Horn's parallel analysis (a procedure that informs the selection of the
>proper number of components in PCA) in R.
>
>
>
>Thank you in advance for any help you can provide. Please respond
>off-list at the email address below.
>
>Karen Douglas
>
>
>
>***
>
>Karen Douglas, PhD
>
>Status of Reading Instruction Institute
>
>Associate Director, Research and Policy
>
>International Reading Association
>
>444 North Capitol St. NW
>
>Suite 524
>
>Washington, DC 20001
>
>[EMAIL PROTECTED]
>
>
>
>Phone: 202-624-8473
>
>Fax: 202-624-8826
>
>
>
>
>
>
>   [[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.


-- 
William Revelle http://personality-project.org/revelle.html
Professor
http://personality-project.org/personality.html
Department of Psychology http://www.wcas.northwestern.edu/psych/
Northwestern University http://www.northwestern.edu/
Use R for statistics:
http://personality-project.org/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.

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


[R] using eval-parse-paste in a loop

2008-02-26 Thread Michael Anyadike-Danes
R-helpers

 

I have 120 small Excel sheets to read and I am using
library(xlsReadWrite): one example below.

 

I had hoped to read sheets by looping over a list of numbers in their
name (eg Book1.xls, Book2.xls, etc).

 

I thought I had seen examples which used eval-parse-paste in this way. 

 

However, I have not been able to get it to work..

 

1. is this a feasible approach?

 

2. if not advice would be welcome.

 

3. Equally, advice about a better approach would also be v. welcome.

 

I haven't included the data because my failed attempt is
data-independent (and probably more basic).  

 

 

Michael Anyadike-Danes

 

# show that read.xls works

 

> test <- read.xls("Book1.xls",sheet=1,from=4,colClasses="numeric")

> str(test)

'data.frame':   23 obs. of  13 variables:

 $ Off.Flows..Thousands.: num  117.19NaN NA   1.43   2.26 ...

 $ Off.Flows..Thousands.: num  8.42 NaN NA 0.08 0.11 0.01 0.11 1.59 0.16
0.04 ...

 $ Off.Flows..Thousands.: num  20 NaN NA 0.2 0.3 0.02 0.32 4.39 0.41
0.11 ...

 $ Off.Flows..Thousands.: num  12.36   NaNNA  0.14  0.27 ...

 $ Off.Flows..Thousands.: num  7.59 NaN NA 0.11 0.18 0.01 0.14 1.46 0.23
0.06 ...

 $ Off.Flows..Thousands.: num  10.31   NaNNA  0.12  0.23 ...

 $ Off.Flows..Thousands.: num  7.55 NaN NA 0.08 0.2 0.01 0.11 1.6 0.23
0.05 ...

 $ Off.Flows..Thousands.: num  10.57   NaNNA  0.19  0.21 ...

 $ Off.Flows..Thousands.: num  9.36 NaN NA 0.13 0.26 0.02 0.13 2.12 0.27
0.07 ...

 $ Off.Flows..Thousands.: num  8.21 NaN NA 0.1 0.19 0.01 0.1 1.9 0.23
0.06 ...

 $ Off.Flows..Thousands.: num  9.04 NaN NA 0.13 0.11 0.01 0.17 1.54 0.17
0.05 ...

 $ Off.Flows..Thousands.: num  13.42   NaNNA  0.14  0.19 ...

 $ Off.Flows..Thousands.: num  0.37 NaN NA NaN 0.01 NaN 0.01 0.05 0.02
NaN ...

 

### simple minded attempt substituting eval-parse-paste

 

> nam <- 1

 

> test <-
eval(parse(paste('read.xls("Book',nam,'.xls",sheet=1,from=4,colClasses="
numeric")',sep='')))

Error in file(file, "r") : unable to open connection

In addition: Warning message:

In file(file, "r") :

  cannot open file
'read.xls("Book1.xls",sheet=1,from=4,colClasses="numeric")', reason
'Invalid argument'

 

### stripping off eval, looking for clues

 

>
parse(paste('read.xls("Book',nam,'.xls",sheet=1,from=4,colClasses="numer
ic")',sep=''))

Error in file(file, "r") : unable to open connection

In addition: Warning message:

In file(file, "r") :

  cannot open file
'read.xls("Book1.xls",sheet=1,from=4,colClasses="numeric")', reason
'Invalid argument'

 

### stripping off parse, still looking for clues

 

>
paste('read.xls("Book',nam,'.xls",sheet=1,from=4,colClasses="numeric")',
sep='')

[1] "read.xls(\"Book1.xls\",sheet=1,from=4,colClasses=\"numeric\")"

 





Economic Research Institute of Northern Ireland

Floral Buildings

2-14 East Bridge Street

Belfast BT1 3NQ

Tel:  (028) 90727362

Fax: (028) 90319003




[[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] wrapper for save function

2008-02-26 Thread Erik Iverson
Of course the second this showed up on R-help, I got rid of the formal 
argument 'mydata' and just used ..., which seems to have solved the problem.

Erik

Erik Iverson wrote:
> Hello -
> 
> I would like to create a wrapper to the 'save' function in the base 
> package, but have a small problem with the name of the object that is 
> getting saved in the file.  Below is a simple example illustrating my 
> problem.
> 
> ## BEGIN SAMPLE R CODE
> 
> ##
> ## Here is the wrapper for the save function
> ##
> 
> wrapsave <- function(mydata, ...) {
>save(mydata, ...)
> }
> 
> ##
> ## Create a test data.frame and save it
> ##
> 
> testdf <- data.frame(a = rnorm(10), b = rnorm(10))
> wrapsave(testdf, file = "~/test.Rdata")
> 
> ##
> ## remove test data.frame and try to load it
> ##
> 
> rm(testdf)
> load(file = "~/test.Rdata")
> 
> ## END SAMPLE R CODE
> 
> After the load function is called, an object called 'testdf' does not 
> exist in the global environment, but an object called 'mydata' does. I 
> understand why, but I'd like 'wrapsave' to save the object passed to it 
> with the name of the object it was called with, in this case 'testdf'. 
> Is this possible?
> 
> Thank you,
> Erik Iverson
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] GLM

2008-02-26 Thread Dani Valverde
Hello,
I am trying to perform a glm analysis on a 68x13113 matrix (named 
data.spect). The first column corresponds to the predictor 
(data.spect[,1]) and the rest to the response variables 
(data.spect[,2:13113]). When I try this code

glmObject <- glm(data.spect[,2:13113]~data.spect[,1])

I get the following error:

Error: (subscript) logical subscript too long

Could anyone help me on solving this problem?
Best,

Dani

-- 
Daniel Valverde Saubí

Grup de Biologia Molecular de Llevats
Facultat de Veterinària de la Universitat Autònoma de Barcelona
Edifici V, Campus UAB
08193 Cerdanyola del Vallès- SPAIN

Centro de Investigación Biomédica en Red
en Bioingeniería, Biomateriales y
Nanomedicina (CIBER-BBN)

Grup d'Aplicacions Biomèdiques de la RMN
Facultat de Biociències
Universitat Autònoma de Barcelona
Edifici Cs, Campus UAB
08193 Cerdanyola del Vallès- SPAIN
+34 93 5814126

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] wrapper for save function

2008-02-26 Thread Erik Iverson
Hello -

I would like to create a wrapper to the 'save' function in the base 
package, but have a small problem with the name of the object that is 
getting saved in the file.  Below is a simple example illustrating my 
problem.

## BEGIN SAMPLE R CODE

##
## Here is the wrapper for the save function
##

wrapsave <- function(mydata, ...) {
   save(mydata, ...)
}

##
## Create a test data.frame and save it
##

testdf <- data.frame(a = rnorm(10), b = rnorm(10))
wrapsave(testdf, file = "~/test.Rdata")

##
## remove test data.frame and try to load it
##

rm(testdf)
load(file = "~/test.Rdata")

## END SAMPLE R CODE

After the load function is called, an object called 'testdf' does not 
exist in the global environment, but an object called 'mydata' does. I 
understand why, but I'd like 'wrapsave' to save the object passed to it 
with the name of the object it was called with, in this case 'testdf'. 
Is this possible?

Thank you,
Erik Iverson

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] projection.matrix() {popbio} for more than one matrix

2008-02-26 Thread Michelle DePrenger-Levin
Hello,

 

I am trying to use the projection.matrix( ) function and am following the
example given. I have my data formatted very similar to the test.census
example. 

 

 

> str(AsMi05mat)

`data.frame':   1854 obs. of  6 variables:

 $ Tag  : num  501 502 503 504 505 506 507 508 509 510 ...

 $ Year : int  1995 1995 1995 1995 1995 1995 1995 1995 1995 1995 ...

 $ Length   : num  34 37 11 24 7 44 4 7 12 20 ...

 $ Flowering: int  1 1 0 1 0 1 0 0 0 1 ...

 $ Fruits   : int  22 22 0 89 0 15 0 0 0 0 ...

 $ Stage: Factor w/ 5 levels "","Dead","Dormant",..: 4 4 5 4 5 4 5 5 5 4
...

 

The example data includes three years but only shows how to create a matrix
from year 1 to 2. I have 13 years of data and would like to automate creating
all matrices for each pair of years. 

 

My code is the following:

 

AsMi05mat <- read.csv("C:/AsMi05mat.csv")

 

library(popbio)

library(base)

 

##for(i in 1995:2005){

  

##AsMitrans.i <- subset(merge(AsMi05mat, AsMi05mat, by = "Tag", sort =
FALSE),

##Year.x == i & Year.y == (i+1) )

##}

 

AsMi05trans <- subset(merge(AsMi05mat, AsMi05mat, by = "Tag", sort = FALSE),

  Year.x == 1995 & Year.y == 1996 )

 

stages <- c("Vegetative", "Reproductive", "Dead", "Dormant")

 

projection.matrix(AsMi05trans, stage=Stage.x, fate=Stage.y,

  sort=stages, TF=TRUE)

 

 

I tried a for( ) loop but don't know how to assign new names for each matrix
so end up with only the final comparison (2005 to 2006). I assume an apply( )
function is the way to go but can't see how to do it. 

 

Thanks for any help!

 

Michelle

 


[[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] Custom LaTeX tables

2008-02-26 Thread Dieter Menne
Werner Wernersen  yahoo.de> writes:

> I am very happy that I have Sweave and R to write my
> papers. But I still have to do some tables by hand
> since I have not found out how I can customize the
> latex tables produced by R further (I mainly use
> xtable()). Like for instance, I have a table which
> needs an extra row every few rows as a group header
> and sometimes I want some extra horizontal lines in
> the table and also a multicolumn heading.

Use latex in package Hmisc, it is very powerful and has options
to do what you need. And if something is missing, you can
plug in your own table handling such as I did quick and 
very dirty for ftable:

http://finzi.psych.upenn.edu/R/Rhelp02a/archive/115684.html 

Dieter

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] looping with a dynamic variable

2008-02-26 Thread Abi Ghanem josephine
Hi,
i am trying to do a small job but it's bugging and i don't know what's 
happening.

let's say i have four matrix, M01_a,  M02_a, M01_b, M02_b that looks 
like this
col1   col2
1 20
2 25
3 26
4  30
5 35
6 64
7 75
8 80
9 85

and a big matrix m:(21044*18)

what i want  to do is
m1<- rbind(m[M01_a[,2],], m[M01_b[,2],])
m2 <- rbind(m[M02_a[,2],], m[M02_b[,2],])

the best will be to integrate this in a loop, so i just did this
for (i in 1:2){
mb<- rbind(m[paste("M0",i,"_a[,2]", sep=""),], m[paste("M0",i,"_b[,2]", 
sep=""),])
}

but this didn't work :-(
i've been tring the whole afternoon , plz some help.

thx,
josephine

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Custom LaTeX tables

2008-02-26 Thread Werner Wernersen
Hello,

I am very happy that I have Sweave and R to write my
papers. But I still have to do some tables by hand
since I have not found out how I can customize the
latex tables produced by R further (I mainly use
xtable()). Like for instance, I have a table which
needs an extra row every few rows as a group header
and sometimes I want some extra horizontal lines in
the table and also a multicolumn heading.

How do you guys cope with such cases, do you set the
table by hand in the end or have you found a neat way
to deal with this?

Many thanks and regards, 
  Werner

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Getting Stangle to tangle Sexpr expressions

2008-02-26 Thread Michael Hoffman
Is there a way to get Stangle to print out Sexpr expressions as well as 
code chunks?

I am using weaver and when trying to debug Sweave files, it is sometimes 
difficult to figure out where the error is. The errors are hardest to 
find when they are in Sexpr expressions because stepping through the 
output produced by Stangle reveals nothing.

That said, any other suggestions on debugging Sweave would be welcome.

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


Re: [R] R package to perform Horn's parallel analysis

2008-02-26 Thread William Revelle
see fa.parallel in the psych package


At 7:27 AM -0800 2/26/08, Karen Douglas wrote:
>I am seeking information on whether anyone has written code to perform
>Horn's parallel analysis (a procedure that informs the selection of the
>proper number of components in PCA) in R.
>
>
>
>Thank you in advance for any help you can provide. Please respond
>off-list at the email address below.
>
>Karen Douglas
>
>
>
>***
>
>Karen Douglas, PhD
>
>Status of Reading Instruction Institute
>
>Associate Director, Research and Policy
>
>International Reading Association
>
>444 North Capitol St. NW
>
>Suite 524
>
>Washington, DC 20001
>
>[EMAIL PROTECTED]
>
>
>
>Phone: 202-624-8473
>
>Fax: 202-624-8826
>
>
>
>
>
>
>   [[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.


-- 
William Revelle http://personality-project.org/revelle.html
Professor   http://personality-project.org/personality.html
Department of Psychology http://www.wcas.northwestern.edu/psych/
Northwestern University http://www.northwestern.edu/
Use R for statistics:  http://personality-project.org/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.


Re: [R] R package to perform Horn's parallel analysis

2008-02-26 Thread Stéphane Dray
ade4 has the "testdim" function which implements the method proposed in:

*S. Dray*. On the number of principal components: A test of 
dimensionality based on measurements of similarity between matrices. 
/Computational Statistics and Data Analysis/, 52:2228-2237, 2008.

Cheers,


Karen Douglas wrote:
> I am seeking information on whether anyone has written code to perform
> Horn's parallel analysis (a procedure that informs the selection of the
> proper number of components in PCA) in R.
>
>  
>
> Thank you in advance for any help you can provide. Please respond
> off-list at the email address below.
>
> Karen Douglas
>
>  
>
> ***
>
> Karen Douglas, PhD
>
> Status of Reading Instruction Institute
>
> Associate Director, Research and Policy
>
> International Reading Association
>
> 444 North Capitol St. NW
>
> Suite 524
>
> Washington, DC 20001
>
> [EMAIL PROTECTED]
>
>
>
> Phone: 202-624-8473
>
> Fax: 202-624-8826
>
>
>
>
>
>
>   [[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.
>
>
>   

-- 
Stéphane DRAY ([EMAIL PROTECTED] )
Laboratoire BBE-CNRS-UMR-5558, Univ. C. Bernard - Lyon I
43, Bd du 11 Novembre 1918, 69622 Villeurbanne Cedex, France
Tel: 33 4 72 43 27 57   Fax: 33 4 72 43 13 88
http://biomserv.univ-lyon1.fr/~dray/

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


Re: [R] R package to perform Horn's parallel analysis

2008-02-26 Thread Paul Hewson
Dear Karen,

You should find the code you want in the package paran:
http://cran.r-project.org/web/packages/paran/index.html

And you may be interested in looking at the Multivariate Cran Task view which 
attempts to catalogue these kinds of things:
http://cran.r-project.org/web/views/Multivariate.html



Best

Paul


-=-=-=-=-=-=-=-=-=-=-=-=
Paul Hewson
Lecturer in Statistics
School of Mathematics and Statistics
University of Plymouth
Drake Circus
Plymouth PL4 8AA

tel (01752) 232778 (Campus)
tel (01752) 764437 (Tamar Science Park)
fax (01752) 232780

email: [EMAIL PROTECTED]
web: http://www.plymouth.ac.uk/staff/phewson
-=-=-=-=-=-=-=-=-=-=-=-=




-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Karen Douglas
Sent: 26 February 2008 15:28
To: R-help@r-project.org
Subject: [R] R package to perform Horn's parallel analysis

I am seeking information on whether anyone has written code to perform
Horn's parallel analysis (a procedure that informs the selection of the
proper number of components in PCA) in R.



Thank you in advance for any help you can provide. Please respond
off-list at the email address below.

Karen Douglas



***

Karen Douglas, PhD

Status of Reading Instruction Institute

Associate Director, Research and Policy

International Reading Association

444 North Capitol St. NW

Suite 524

Washington, DC 20001

[EMAIL PROTECTED]



Phone: 202-624-8473

Fax: 202-624-8826






[[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] R package to perform Horn's parallel analysis

2008-02-26 Thread Karen Douglas
I am seeking information on whether anyone has written code to perform
Horn's parallel analysis (a procedure that informs the selection of the
proper number of components in PCA) in R.

 

Thank you in advance for any help you can provide. Please respond
off-list at the email address below.

Karen Douglas

 

***

Karen Douglas, PhD

Status of Reading Instruction Institute

Associate Director, Research and Policy

International Reading Association

444 North Capitol St. NW

Suite 524

Washington, DC 20001

[EMAIL PROTECTED]



Phone: 202-624-8473

Fax: 202-624-8826






[[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] action executing twice while loading tiles

2008-02-26 Thread arun kumar
*hi

I aam facing following problem

my action executing twice when i try to load the tileslayout page as
actionforward success
*

[[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 vector and data frame on field?

2008-02-26 Thread Henrique Dallazuanna
Try this:

merge(tsus_same_mean, as.data.frame(tsuPIDCount), by.x="PID", by.y=0)


On 26/02/2008, Karin Lagesen <[EMAIL PROTECTED]> wrote:
>
>  I have managed to create a data frame like this:
>
>
>  > tsus_same_mean[1:10,]
>  PIDGrpDist   PercAlnPercId
>  1  12638  Acidobacteria 0.0 1.000 1.000
>  2 87 Actinobacteria 0.0 0.970 0.970
>  3 92 Actinobacteria 0.008902000 1.000 0.991
>  4 94 Actinobacteria 0.0 1.000 1.000
>  5189 Actinobacteria 0.005876733 0.973 0.9676667
>  6242 Actinobacteria 0.001734200 0.973 0.9715333
>  7305 Actinobacteria 0.0 0.970 0.970
>  8307 Actinobacteria 0.0 0.970 0.970
>  9328 Actinobacteria 0.0 1.000 1.000
>  10 10689 Actinobacteria 0.0 1.000 1.000
>  >
>
>  and what I think is a factor like this:
>
>  > tsuPIDCount[1:10]
>   3  4  5  8  9 12 13 15 18 19
>   2  2  2  3  4  7  4  2  2  3
>  >
>
>  Now, I'd like to combine the two. The factor levels in tsuPIDCount
>  corresponds to the field called PID in the data frame.
>
>  Any hints on how to do this? cbind just adds the vector onto the end,
>  and I couldn't quite figure out if I could somehow say that the level
>  should correspond to the PID.
>
>  Thanks a lot for your helpin advance:)
>
>  Karin
>  --
>  Karin Lagesen, PhD student
>  [EMAIL PROTECTED]
>  http://folk.uio.no/karinlag
>
>  __
>  R-help@r-project.org mailing list
>  https://stat.ethz.ch/mailman/listinfo/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.


[R] predict.rpart question

2008-02-26 Thread Damian Krstajic

Dear All,

I have a question regarding predict.rpart. I use
rpart to build classification and regression trees and I deal with data with
relatively large number of input variables (predictors). For example, I build an
rpart model like this

rpartModel <- rpart(Y ~ X, method="class",
minsplit =1, minbucket=nMinBucket,cp=nCp);

and get predictors used in building the model like
this

colnamesUsed<-unique(rownames(rpartModel$splits));

When later I apply the rpart model to predict the new
data I strip the input data from unneccessary columns and only use X columns
that exist in colnamesUsed. Unfortunately I get error message like this

Error: variable 'X' was fitted with type
"nmatrix.3522" but type "nmatrix.19" was supplied

The error message is correct. In the documentation it
clearly specifies that the predictors referred to in the right side of formula
(object) must be present by name in newdata, but I wonder why, if they are not
used?

Thanks

DK

_
Share what Santa brought you

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Rcmdr importing excel files

2008-02-26 Thread stephen sefick
I am using R 2.6.2 on Mac OS X 10.4.9-  I would like to import excel
files into R with Rcmdr, but This option does not present itself in
the file menu.  Any help would be greatly appreciated.

Stephen

-- 
Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods.  We are mammals, and have not exhausted the
annoying little problems of being mammals.

-K. Mullis

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 vector and data frame on field?

2008-02-26 Thread Karin Lagesen

I have managed to create a data frame like this:


> tsus_same_mean[1:10,]
 PIDGrpDist   PercAlnPercId
1  12638  Acidobacteria 0.0 1.000 1.000
2 87 Actinobacteria 0.0 0.970 0.970
3 92 Actinobacteria 0.008902000 1.000 0.991
4 94 Actinobacteria 0.0 1.000 1.000
5189 Actinobacteria 0.005876733 0.973 0.9676667
6242 Actinobacteria 0.001734200 0.973 0.9715333
7305 Actinobacteria 0.0 0.970 0.970
8307 Actinobacteria 0.0 0.970 0.970
9328 Actinobacteria 0.0 1.000 1.000
10 10689 Actinobacteria 0.0 1.000 1.000
> 

and what I think is a factor like this:

> tsuPIDCount[1:10]
 3  4  5  8  9 12 13 15 18 19
 2  2  2  3  4  7  4  2  2  3
>

Now, I'd like to combine the two. The factor levels in tsuPIDCount
corresponds to the field called PID in the data frame.

Any hints on how to do this? cbind just adds the vector onto the end,
and I couldn't quite figure out if I could somehow say that the level
should correspond to the PID.

Thanks a lot for your helpin advance:)

Karin
-- 
Karin Lagesen, PhD student
[EMAIL PROTECTED]
http://folk.uio.no/karinlag

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Combining series of variables using identifier

2008-02-26 Thread Henrique Dallazuanna
Try this:

foo <- function(data, ...)
{
patt <- grep("var[0-9]$", names(data), value=T)
res <- paste(sapply(data[, patt], as.character), sapply(data[,
paste(patt, "lab", sep="_")], as.character), sep=": ")
cbind(a, matrix(res, ncol=length(patt), dimnames=list(NULL,
paste(patt, "new", sep="_"
}

foo(a)

On 26/02/2008, Lauri Nikkinen <[EMAIL PROTECTED]> wrote:
> R users,
>
>  I have df like this
>
>  a <- data.frame(indx =1:20,
> var1 =rep(c("I20", "I40", "A50", "B60"), each=5),
> var1_lab= rep(c("cat", "dog", "mouse", "horse"), each=5),
> var2 =rep(c("B20", "X40", "D50", "G60"), each=5),
> var2_lab= rep(c("car", "bicycle", "train", "bus"), 
> each=5))
>  str(a)
>
>  I'd like to create new variables by combining "varX" and "varX_lab" like 
> this:
>
>  a$var1_new <- factor(paste(a$var1, a$var1_lab, sep=": "))
>  a$var2_new <- factor(paste(a$var2, a$var2_lab, sep=": "))
>  a
>
>  But, in the real world, I have multiple df:s and many of variables
>  named by the same manner. Is there a possibility to create a function
>  which combines these variables and creates new ones into the same df
>  using "varX" as an identifier?
>
>  Many thanks,
>  Lauri
>
>  __
>  R-help@r-project.org mailing list
>  https://stat.ethz.ch/mailman/listinfo/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] Combining series of variables using identifier

2008-02-26 Thread K. Elo
Hi,

if the columns always follow the same order (indx,var#, var#_lab ...), 
then You could use the column numbers and do the following:

1) CN<-colnames(df)[#] (#=colnum of 'var#')
2) df$NEW<-(here the expression to create the new variable)
3) colnames(df)[ncol(df)]<-c(paste(CN,"new",sep="_"))

This can easily be built in a loop.

Hope this helps,
Kimmo

Lauri Nikkinen kirjoitti viestissään (26.02.2008):
> R users,
>
> I have df like this
>
> a <- data.frame(indx =1:20,
> var1 =rep(c("I20", "I40", "A50", "B60"),
> each=5), var1_lab= rep(c("cat", "dog", "mouse", "horse"), each=5),
> var2 =rep(c("B20", "X40", "D50", "G60"), each=5), var2_lab=
> rep(c("car", "bicycle", "train", "bus"), each=5)) str(a)
>
> I'd like to create new variables by combining "varX" and "varX_lab"
> like this:
>
> a$var1_new <- factor(paste(a$var1, a$var1_lab, sep=": "))
> a$var2_new <- factor(paste(a$var2, a$var2_lab, sep=": "))
> a
>
> But, in the real world, I have multiple df:s and many of variables
> named by the same manner. Is there a possibility to create a function
> which combines these variables and creates new ones into the same df
> using "varX" as an identifier?
>
> Many thanks,
> Lauri
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] predict.rpart question

2008-02-26 Thread Damian Krstajic

Dear All,



I have a question regarding predict.rpart. I use
rpart to build classification and regression trees and I deal with data with
relatively large number of input variables (predictors). For example, I build an
rpart model like this



rpartModel <- rpart(Y ~ X, method="class",
minsplit =1, minbucket=nMinBucket,cp=nCp);



and get predictors used in building the model like
this



colnamesUsed<-unique(rownames(rpartModel$splits));



When later I apply the rpart model to predict the new
data I strip the input data from unneccessary columns and only use X columns
that exist in colnamesUsed. Unfortunately I get error message like this 

Error: variable 'X' was fitted with type
"nmatrix.3522" but type "nmatrix.19" was supplied



The error message is correct. In the documentation it
clearly specifies that the predictors referred to in the right side of formula
(object) must be present by name in newdata, but I wonder why, if they are not
used?



Thanks

DK
_
Who's friends with who and co-starred in what?

[[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] AIC and anova, lme

2008-02-26 Thread Dieter Menne
Patrick Giraudoux  univ-fcomte.fr> writes:

> 
> Dear listers,
> 
> Here we have a strange result we can hardly cope with. We want to 
> compare a null mixed model with a mixed model with one independent 
> variable.
> 
>  > lmmedt1<-lme(mediane~1, random=~1|site, na.action=na.omit, data=bdd2)
>  > lmmedt9<-lme(mediane~log(0.0001+transat), random=~1|site, 
> na.action=na.omit, data=bdd2)
...
> The usual conclusion would be that the two models are equivalent and to 
> keep the null model for parsimony (!).
> 
> However, an anova shows that the variable 'log(1e-04 + transat)' is 
> significantly different from 0 in model 2 (lmmedt9)
> 
>  > anova(lmmedt9)
>  numDF denDF   F-value p-value
> (Intercept)  120 289.43109  <.0001
> log(1e-04 + transat) 120  31.18446  <.0001
> 

Ask the author of pgirmess to add some checks for the model as anova and
stepAIC do:

Dieter

-
library(MASS)
library(nlme)
fm1 <- lme(distance ~ age, data = Orthodont) 
fm2 <- lme(distance ~ age + Sex, data = Orthodont, random = ~ 1)


>>In anova.lme(fm1, fm2) :
<<  Fitted objects with different fixed effects. REML comparisons are not<<
meaningful.

stepAIC(fm2)
>>Error in extractAIC.lme(fit, scale, k = k, ...) : 
>>  AIC undefined for REML fit

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] AIC and anova, lme

2008-02-26 Thread Patrick Giraudoux

ian white a écrit :

Patrick,

The likelihoods of two models fitted using REML cannot be compared
unless the fixed effects are the same in the two models.  
  
Many thanks for this reminder. Shame on me: it recalls me that this 
subject may have been already largely discussed on this list. Now, I can 
search the archives specifically with the REML issue...


All the best,

Patrick


On Tue, 2008-02-26 at 14:38 +0100, Patrick Giraudoux wrote:
  

Dear listers,

Here we have a strange result we can hardly cope with. We want to 
compare a null mixed model with a mixed model with one independent 
variable.


 > lmmedt1<-lme(mediane~1, random=~1|site, na.action=na.omit, data=bdd2)
 > lmmedt9<-lme(mediane~log(0.0001+transat), random=~1|site, 
na.action=na.omit, data=bdd2)


Using the Akaike Criterion and selMod of the package pgirmess gives the 
following output:


 > selMod(list(lmmedt1,lmmedt9))
 model   LL K  N2K   AIC  deltAIC  w_i  AICc 
deltAICc w_ic
2 log(1e-04 + transat) 44.63758 4  7.5 -81.27516 0.00 0.65 -79.67516 
0.00 0.57
11 43.02205 3 10.0 -80.04410 1.231069 0.35 -79.12102 
0.554146 0.43


The usual conclusion would be that the two models are equivalent and to 
keep the null model for parsimony (!).


However, an anova shows that the variable 'log(1e-04 + transat)' is 
significantly different from 0 in model 2 (lmmedt9)


 > anova(lmmedt9)
 numDF denDF   F-value p-value
(Intercept)  120 289.43109  <.0001
log(1e-04 + transat) 120  31.18446  <.0001

Has anyone an opinion about what looks like a paradox here ?

Patrick



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 include the documentation of a function in a Sweave document?

2008-02-26 Thread Henrique Dallazuanna
You can use '\include' also:

\documentclass{article}
\begin{document}

\include{/usr/local/lib/R/library/graphics/latex/plot}
%file.path(system.file(package="graphics"), "latex", "plot")

\end{document}

I don't know if there is a way of input file.path in include by Sweave.


On 25/02/2008, Jean lobry <[EMAIL PROTECTED]> wrote:
> Dear R-help,
>
>  I would like to include the documentation of an R function in an
>  *.rnw document processed by Sweave. Because I'm sharing my *.rnw
>  files with colleagues under Linux and Windows (I'm on Mac OS X),
>  I would like a pure R solution.
>
>  The naive approach doesn't work, because Sweaving this *.rnw
>  file:
>
>   tmp.rnw 
>  \documentclass{article}
>  \begin{document}
>  <<>>=
>  ?plot
>  @
>  \end{document}
>   tmp.rnw 
>
>  yields the following LaTeX file on my platform (session info at the end):
>
>   tmp.tex 
>  \documentclass{article}
>  \usepackage{/Library/Frameworks/R.framework/Resources/share/texmf/Sweave}
>  \begin{document}
>  \begin{Schunk}
>  \begin{Sinput}
>  >  `?`(plot)
>  \end{Sinput}
>  \end{Schunk}
>  \end{document}
>   tmp.tex 
>
>  in which no Soutput has been generated. Is it possible to redirect the
>  help output, in a platform-independent way, so that it is included in
>  the Soutput environment of the LaTeX file?
>
>  Best,
>
>  Jean
>
>  >  sessionInfo()
>  R version 2.6.2 (2008-02-08)
>  i386-apple-darwin8.10.1
>
>  locale:
>  C
>
>  attached base packages:
>  [1] stats graphics  grDevices utils datasets  methods   base
>
>  loaded via a namespace (and not attached):
>  [1] rcompgen_0.1-17
>
>  --
>  Jean R. Lobry([EMAIL PROTECTED])
>  Laboratoire BBE-CNRS-UMR-5558, Univ. C. Bernard - LYON I,
>  43 Bd 11/11/1918, F-69622 VILLEURBANNE CEDEX, FRANCE
>  allo  : +33 472 43 27 56 fax: +33 472 43 13 88
>  http://pbil.univ-lyon1.fr/members/lobry/
>
>  __
>  R-help@r-project.org mailing list
>  https://stat.ethz.ch/mailman/listinfo/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] AIC and anova, lme

2008-02-26 Thread ian white
Patrick,

The likelihoods of two models fitted using REML cannot be compared
unless the fixed effects are the same in the two models.  


On Tue, 2008-02-26 at 14:38 +0100, Patrick Giraudoux wrote:
> Dear listers,
> 
> Here we have a strange result we can hardly cope with. We want to 
> compare a null mixed model with a mixed model with one independent 
> variable.
> 
>  > lmmedt1<-lme(mediane~1, random=~1|site, na.action=na.omit, data=bdd2)
>  > lmmedt9<-lme(mediane~log(0.0001+transat), random=~1|site, 
> na.action=na.omit, data=bdd2)
> 
> Using the Akaike Criterion and selMod of the package pgirmess gives the 
> following output:
> 
>  > selMod(list(lmmedt1,lmmedt9))
>  model   LL K  N2K   AIC  deltAIC  w_i  AICc 
> deltAICc w_ic
> 2 log(1e-04 + transat) 44.63758 4  7.5 -81.27516 0.00 0.65 -79.67516 
> 0.00 0.57
> 11 43.02205 3 10.0 -80.04410 1.231069 0.35 -79.12102 
> 0.554146 0.43
> 
> The usual conclusion would be that the two models are equivalent and to 
> keep the null model for parsimony (!).
> 
> However, an anova shows that the variable 'log(1e-04 + transat)' is 
> significantly different from 0 in model 2 (lmmedt9)
> 
>  > anova(lmmedt9)
>  numDF denDF   F-value p-value
> (Intercept)  120 289.43109  <.0001
> log(1e-04 + transat) 120  31.18446  <.0001
> 
> Has anyone an opinion about what looks like a paradox here ?
> 
> Patrick
> 
> 
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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.


  1   2   >