[R] need some lattice help

2009-01-27 Thread Antje

Hello everybody,

I just started with lattice plots and I was wondering why it behaves different 
than expected.

If I generated multiple plots in the past, I just used some code like this:

lapply(..., {
windows()
plot(...)
})

I got multiple windows, each containing one plot.

Now, I tried the same with levelplot (instead of plot) and I see all 
windows are created but the plots are only drawn in one window, one on top of 
the other...


Can anybody give me a hint, why it behaves like this and what should I change?

Ciao,
Antje

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Running R under Sun Grid Engine with OpenMPI tight integration

2009-01-27 Thread Marce
2009/1/27 Rainer M Krug r.m.k...@gmail.com:
 On Tue, Jan 27, 2009 at 2:30 AM, Peter Waltman peter.walt...@gmail.com 
 wrote:
 Hi -

 I saw your posting on the R-help mailing list.  Were you ever able to get
 this working?  did you end up switching to use the rsge library?

 Yes - that is exactly what I did - I am using rsge or, which is in
 most cases sufficient for me, starting several instances of R and run
 the whole simulation (array processing).

 But I would still like to know how I can use the Rmpi and snow on the
 Sun Grid Engine.

 Please keep me posted,

 Rainer

 I'm trying to do the same, and not having very much luck getting it going.

 Thanks!

 Peter Waltman




 --
 Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation
 Biology, UCT), Dipl. Phys. (Germany)

 Centre of Excellence for Invasion Biology
 Faculty of Science
 Natural Sciences Building
 Private Bag X1
 University of Stellenbosch
 Matieland 7602
 South Africa

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


Hi all,
I have been installed R in SGE but with LAM tight integration, I don't
k now if this help you :s . The problem I had with OpenMPI was that
the load in all nodes waiting for a job and with an instance of R.
Their load up to 100 %, and there isn't a job running on them.
Even so, I will try to configure it with OpenMPI..when I have results
I will post them ok?

Saludos

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

2009-01-27 Thread Huihua Lu
Hi, All,

I want to construct a pareto chart for my data. My data has two 
columns: modules and defects(each module has several defects). Now I 
use pareto.chart to create a chart for defects which y axis is 
cumulative percentage of defect, and x axis is value of defect. That 
is not what I want. I need the x axis be percentage of modules. Is 
there any way that I can change the scale of x axis, that make x axis 
be percent scale for modules, like 0% to 100% modules. So that I can 
directly read the chart, is that 20% modules contains 80% defect. Or, 
is there any function that I can use to achive it directly?
Thank you in advanced!

Hedy

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Running R under Sun Grid Engine with OpenMPI tight integration

2009-01-27 Thread Rainer M Krug
On Tue, Jan 27, 2009 at 11:04 AM, Marce marc...@gmail.com wrote:
 2009/1/27 Rainer M Krug r.m.k...@gmail.com:
 On Tue, Jan 27, 2009 at 2:30 AM, Peter Waltman peter.walt...@gmail.com 
 wrote:
 Hi -

 I saw your posting on the R-help mailing list.  Were you ever able to get
 this working?  did you end up switching to use the rsge library?

 Yes - that is exactly what I did - I am using rsge or, which is in
 most cases sufficient for me, starting several instances of R and run
 the whole simulation (array processing).

 But I would still like to know how I can use the Rmpi and snow on the
 Sun Grid Engine.

 Please keep me posted,

 Rainer

 I'm trying to do the same, and not having very much luck getting it going.

 Thanks!

 Peter Waltman




 --
 Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation
 Biology, UCT), Dipl. Phys. (Germany)

 Centre of Excellence for Invasion Biology
 Faculty of Science
 Natural Sciences Building
 Private Bag X1
 University of Stellenbosch
 Matieland 7602
 South Africa

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


 Hi all,
 I have been installed R in SGE but with LAM tight integration, I don't
 k now if this help you :s . The problem I had with OpenMPI was that
 the load in all nodes waiting for a job and with an instance of R.
 Their load up to 100 %, and there isn't a job running on them.
 Even so, I will try to configure it with OpenMPI..when I have results
 I will post them ok?

Yes please - could you please provide some info (and a small example)
on how you managed this with LAM?

I think we should move this thread to r-sig-hpc, as it is more
appropriate there. I CC'd it to there - please respond there and not
on r-help.

Thanks

Rainer


 Saludos

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




-- 
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation
Biology, UCT), Dipl. Phys. (Germany)

Centre of Excellence for Invasion Biology
Faculty of Science
Natural Sciences Building
Private Bag X1
University of Stellenbosch
Matieland 7602
South Africa

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


Re: [R] need some lattice help

2009-01-27 Thread Antje

I guess, I got the answer.
(http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-do-lattice_002ftrellis-graphics-not-work_003f)

Ciao,
Antje



Antje schrieb:

Hello everybody,

I just started with lattice plots and I was wondering why it behaves 
different than expected.

If I generated multiple plots in the past, I just used some code like this:

lapply(..., {
windows()
plot(...)
})

I got multiple windows, each containing one plot.

Now, I tried the same with levelplot (instead of plot) and I see all 
windows are created but the plots are only drawn in one window, one on 
top of the other...


Can anybody give me a hint, why it behaves like this and what should I 
change?


Ciao,
Antje

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

2009-01-27 Thread Daniel Brewer
I have a script that sometimes produces the following error:

Error in assign(.target, met...@target, envir = envir) :
  formal argument envir matched by multiple actual arguments

Do you think this is a memory issue?  I don't know what else it could be
as it doesn't always occur even if the script is run with exactly the
same data.

Does rm() actually free up memory?

Thanks

Dan

-- 
**
Daniel Brewer, Ph.D.

Institute of Cancer Research
Molecular Carcinogenesis
Email: daniel.bre...@icr.ac.uk
**

The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company 
Limited by Guarantee, Registered in England under Company No. 534147 with its 
Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the a...{{dropped:2}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Odp: working with tables -- was Re: Mode (statistics) in R?

2009-01-27 Thread Petr PIKAL
Hi

r-help-boun...@r-project.org napsal dne 27.01.2009 01:50:39:

 Ok, so I'm slowly figuring out what a factor is, and was able to follow
 the related thread about finding a mode by using constructs like
 
 my_mode = as.numeric(names(table(x))[which.max(table(x))])
 
 
 Now, suppose I want to keep looking for other modes?  For example,

Do you mean the situation when there are more then one max values?

set.seed(19)
sample(seq(1,10),50,replace=TRUE)-bag
table(bag)[max(table(bag))==table(bag)]

Regards
Petr


 
 Rgames sample(seq(1,10),50,replace=TRUE)-bag
 Rgames bag
   [1]  2  8  8 10  7  3  2  9  8  3  8  9  6  6 10 10  7  1
 [19]  9  5  4  3  3  5 10  3  6  3  2  8  4  2  1 10  6  2
 [37]  6  6  9  8  6  8  8  4  3  6  3  9  5  1
 Rgames names(which.max(table(bag)))
 [1] 3
 
 I can then do
 
 Rgames bag2-bag[bag!=3]
 
 and repeat the which.max stuff.
 I came up with the following command to find the actual magnitude of the 

 mode:
 
 Rgames table(bag)-tbag
 Rgames tbag
 bag
   1  2  3  4  5  6  7  8  9 10
   3  5  8  3  3  8  2  8  5  5
 
 Rgames tbag[dimnames(tbag)$bag==3]-bagmode
 Rgames bagmode
 3
 8
 
 
 Related to this, since bag2 is now bereft of threes,
 Rgames table(bag2)
 bag2
   1  2  4  5  6  7  8  9 10
   3  5  3  3  8  2  8  5  5
 
 I was able to make the same table with
 
 Rgames newtable-tbag[c(dimnames(tbag)$bag)!=3]
 Rgames newtable
 bag
   1  2  4  5  6  7  8  9 10
   3  5  3  3  8  2  8  5  5
 
 
 Is there a cleaner syntax to do these things?
 
 Thanks for your help--and feel free to point me to the Inferno or other 
 paper on the philosophy and use of factors and tables.
 
 Carl
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Need help on running Heckman Correction Estimation using R

2009-01-27 Thread Kishore
Team,

I am trying to resolve the self-selection bias of a sample in an experiment
and would like to run the Heckman Correction Estimation using R.  Can
someone help me with the R-Code... I tried searching for the discussion, but
not successful. Thanks in advance,

Best,

Kishore/..
http://kaykayatisb.blogspot.com

[[alternative HTML version deleted]]

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


[R] Re : Need help on running Heckman Correction Estimation using R

2009-01-27 Thread justin bem
See the micEcon package. there is and heckit function
 Justin BEM
BP 1917 Yaoundé
Tél (237) 99597295
(237) 22040246 





De : Kishore gladikish...@gmail.com
À : r-help@r-project.org; r-h...@stat.math.ethz.ch
Envoyé le : Mardi, 27 Janvier 2009, 11h54mn 00s
Objet : [R] Need help on running Heckman Correction Estimation using R

Team,

I am trying to resolve the self-selection bias of a sample in an experiment
and would like to run the Heckman Correction Estimation using R.  Can
someone help me with the R-Code... I tried searching for the discussion, but
not successful. Thanks in advance,

Best,

Kishore/..
http://kaykayatisb.blogspot.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.



  
[[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] Memory issue?

2009-01-27 Thread Paul Hiemstra

Daniel Brewer wrote:

I have a script that sometimes produces the following error:

Error in assign(.target, met...@target, envir = envir) :
  formal argument envir matched by multiple actual arguments

Do you think this is a memory issue?  I don't know what else it could be
as it doesn't always occur even if the script is run with exactly the
same data.

Does rm() actually free up memory?

Thanks

Dan

  

Hi,

There are multiple threads on this subject on the R-help list, googling 
for formal argument matched by mutiple actual arguments lead me to:


http://tolstoy.newcastle.edu.au/R/help/05/08/10698.html

So this is probably not a memory issue. Freeing up memory can be done 
using gc().


cheers and hth,
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.


Re: [R] Goodness of fit for gamma distributions

2009-01-27 Thread Remko Duursma
Hi Dann,

there is probably a better way to do this, but this works anyway:

# your data
gamdat - rgamma(1, shape=1, rate=0.5)

# comparison to gamma:
gamsam - rgamma(1, shape=1, rate=0.6)

qqplot(gamsam,gamdat)
abline(0,1)


greetings
Remko


-
Remko Duursma
Post-Doctoral Fellow

Centre for Plant and Food Science
University of Western Sydney
Hawkesbury Campus
Richmond NSW 2753

Dept of Biological Science
Macquarie University
North Ryde NSW 2109
Australia

Mobile: +61 (0)422 096908



On Tue, Jan 27, 2009 at 3:38 AM, Dan31415 d.m.mitch...@reading.ac.uk wrote:

 I'm looking for goodness of fit tests for gamma distributions with large data
 sizes. I have a matrix with around 10,000 data values in it and i have
 fitted a gamma distribution over a histogram of the data.

 The problem is testing how well that distribution fits. Chi-squared seems to
 be used more for discrete distributions and kolmogorov-smirnov seems that
 large sample sizes make it had to evaluate the D statistic. Also i haven't
 found a qq plot for gamma, although i think this might be an appropriate
 test.

 in summary
 -is there a gamma goodness of fit test that doesnt depend on the sample
 size?
 -is there a way of using qqplot for gamma distributions, if so how would you
 calculate it from a matrix of data values?

 regards,
 Dann
 --
 View this message in context: 
 http://www.nabble.com/Goodness-of-fit-for-gamma-distributions-tp21668711p21668711.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] Error in Surv(time, status) : Time variable is not numeric

2009-01-27 Thread Chris Andrews

R is finding the R function 'time' rather than your variable time in your
dataset.  Perhaps adding 'data=mydata' to your function call will resolve
your issue.

Chris


Braem M wrote:
 
 Dear,
 
 I want to analyze two-level survival data using a shared frailty model,
 for which I want to use the R package 'Frailtypack, proposed by Rondeau
 et al. The dataset was built using SAS software. I also tried to change
 the format using SPSS and Excell. 
 
 My (reduced) dataset has following column names:
 ID entrytimestatusfamily var1
 
 I used following command:
 frailtyPenal(Surv(time, status) ~var1 + cluster(family), Frailty=TRUE
 ,n.knots=8, kappa1=1500,
 + cross.validation=FALSE)
 
 And got this error :
 Error in Surv(time, status) : Time variable is not numeric
 In addition: Warning message:
 In is.na(time) : is.na() applied to non-(list or vector) of type 'closure'
 
 I think R transforms the data when importing into R, so that the
 observations are not numeric anymore.
 
 Does anyone know how to handle this problem?
 
 Thanks,
 
 Marie
 

-- 
View this message in context: 
http://www.nabble.com/Error-in-Surv%28time%2C-status%29-%3A-Time-variable-is-not-numeric-tp21674025p21683673.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] Sweave'ing Danish characters

2009-01-27 Thread Peter Jepsen
Thank you, Duncan! It works perfectly!

Best regards,
Peter.

-Original Message-
From: Duncan Murdoch [mailto:murd...@stats.uwo.ca] 
Sent: 27. januar 2009 13:04
To: Peter Jepsen
Cc: r-help@r-project.org
Subject: Re: [R] Sweave'ing Danish characters

On 26/01/2009 5:44 PM, Peter Jepsen wrote:
 Hi,
 
 I am writing an Sweave document and am using 'xtable' to make frequency 
 tables of diagnoses of people undergoing cholecystectomy. Some of these 
 diagnoses contain Danish characters (æ, ø, and å), and these characters 
 are all garbled in the Latex document after I run Sweave. The odd thing is, 
 everything looks absolutely right in the R console, and if I enter the same 
 Danish characters in a new variable, the new variable produces no problems?! 
 Therefore, I cannot offer a reproducible example, but I am hoping nonetheless 
 that someone can point me towards a solution.

This looks like an encoding problem:  there are several different 
standards for encoding non-ASCII characters.  All of your tools have to 
agree on the encoding.

To my eye it looks as though in the first case R is writing out UTF-8, 
and whatever you are using to look at your .tex file is assuming latin1 
(some Windows programs say ANSI, but I think that doesn't fully 
specify the encoding:  you also need a code page, which is set somewhere 
in Windows control panel.)

The functions related to encodings in R are:

  options(encoding=latin1)  - set the default encoding

  iconv(x, from=latin1, to=UTF-8)  - re-encode entries, mapping each 
character from one encoding to the other

  Encoding(x) - display the encoding of each entry (unknown means ascii 
or the native encoding for your platform)

  Encoding(x) - latin1 - change the declared encoding, without 
changing the bytes.

Duncan Murdoch

 To illustrate:
 
 library(xtable)
 library(Hmisc)
 rm(list=ls())
 load(u:/kirurgi/cholecystit/Chol_oprenset.Rdata)
  
 test2 - chol$nydiag[3]  # This 3rd observation contains a diagnosis 
 with Danish characters (Kræft i fordøjelsessystemet, meaning 
 gastrointestinal cancer).

 print(xtable(table(test2)))
 % latex table generated in R 2.8.1 by xtable 1.5-4 package
 % Mon Jan 26 23:31:37 2009
 \begin{table}[ht]
 \begin{center}
 \begin{tabular}{rr}
   \hline
   test2 \\
   \hline
 Kræft i fordøjelsessystemet1 \\  # It looks right here, but in the 
 .tex-file it says Kræft i fordøjelsessystemet
\hline
 \end{tabular}
 \end{center}
 \end{table}
 
 print(xtable(table(Kræft i fordøjelsessystemet)))  # This, on the other 
 hand, works like a charm.
 % latex table generated in R 2.8.1 by xtable 1.5-4 package
 % Mon Jan 26 23:36:53 2009
 \begin{table}[ht]
 \begin{center}
 \begin{tabular}{rr}
   \hline
   V1 \\
   \hline
 Kræft i fordøjelsessystemet1 \\  # See, no problems here!
\hline
 \end{tabular}
 \end{center}
 \end{table}
 
 
 I am using Windows Vista 64-bit and MikTex 2.7. 
 
 Best regards,
 Peter.
 
 sessionInfo()
 R version 2.8.1 (2008-12-22) 
 i386-pc-mingw32 
 
 locale:
 LC_COLLATE=Danish_Denmark.1252;LC_CTYPE=Danish_Denmark.1252;LC_MONETARY=Danish_Denmark.1252;LC_NUMERIC=C;LC_TIME=Danish_Denmark.1252
 
 attached base packages:
 [1] stats graphics  grDevices utils datasets  methods   base 
 
 other attached packages:
 [1] Hmisc_3.4-4foreign_0.8-30 xtable_1.5-4  
 
 loaded via a namespace (and not attached):
 [1] cluster_1.11.12 grid_2.8.1  lattice_0.17-20 tools_2.8.1
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Sweave'ing Danish characters

2009-01-27 Thread Duncan Murdoch

On 26/01/2009 5:44 PM, Peter Jepsen wrote:

Hi,

I am writing an Sweave document and am using 'xtable' to make frequency tables of diagnoses of people 
undergoing cholecystectomy. Some of these diagnoses contain Danish characters (æ, ø, 
and å), and these characters are all garbled in the Latex document after I run Sweave. The odd 
thing is, everything looks absolutely right in the R console, and if I enter the same Danish characters in a 
new variable, the new variable produces no problems?! Therefore, I cannot offer a reproducible example, but I 
am hoping nonetheless that someone can point me towards a solution.


This looks like an encoding problem:  there are several different 
standards for encoding non-ASCII characters.  All of your tools have to 
agree on the encoding.


To my eye it looks as though in the first case R is writing out UTF-8, 
and whatever you are using to look at your .tex file is assuming latin1 
(some Windows programs say ANSI, but I think that doesn't fully 
specify the encoding:  you also need a code page, which is set somewhere 
in Windows control panel.)


The functions related to encodings in R are:

 options(encoding=latin1)  - set the default encoding

 iconv(x, from=latin1, to=UTF-8)  - re-encode entries, mapping each 
character from one encoding to the other


 Encoding(x) - display the encoding of each entry (unknown means ascii 
or the native encoding for your platform)


 Encoding(x) - latin1 - change the declared encoding, without 
changing the bytes.


Duncan Murdoch


To illustrate:


library(xtable)
library(Hmisc)
rm(list=ls())
load(u:/kirurgi/cholecystit/Chol_oprenset.Rdata)

test2 - chol$nydiag[3]  # This 3rd observation contains a diagnosis with Danish 
characters (Kræft i fordøjelsessystemet, meaning gastrointestinal cancer).

print(xtable(table(test2)))

% latex table generated in R 2.8.1 by xtable 1.5-4 package
% Mon Jan 26 23:31:37 2009
\begin{table}[ht]
\begin{center}
\begin{tabular}{rr}
  \hline
  test2 \\
  \hline
Kræft i fordøjelsessystemet1 \\# It looks right here, but in the .tex-file 
it says Kræft i fordøjelsessystemet
   \hline
\end{tabular}
\end{center}
\end{table}


print(xtable(table(Kræft i fordøjelsessystemet)))   # This, on the other 
hand, works like a charm.

% latex table generated in R 2.8.1 by xtable 1.5-4 package
% Mon Jan 26 23:36:53 2009
\begin{table}[ht]
\begin{center}
\begin{tabular}{rr}
  \hline
  V1 \\
  \hline
Kræft i fordøjelsessystemet1 \\# See, no problems here!
   \hline
\end{tabular}
\end{center}
\end{table}


I am using Windows Vista 64-bit and MikTex 2.7. 


Best regards,
Peter.


sessionInfo()
R version 2.8.1 (2008-12-22) 
i386-pc-mingw32 


locale:
LC_COLLATE=Danish_Denmark.1252;LC_CTYPE=Danish_Denmark.1252;LC_MONETARY=Danish_Denmark.1252;LC_NUMERIC=C;LC_TIME=Danish_Denmark.1252

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


other attached packages:
[1] Hmisc_3.4-4foreign_0.8-30 xtable_1.5-4  


loaded via a namespace (and not attached):
[1] cluster_1.11.12 grid_2.8.1  lattice_0.17-20 tools_2.8.1

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

2009-01-27 Thread jim holtman
Since we have no idea what your data looks like, you can create a plot
and then apply your own axis.  You might also be able to rescale the
x-axis data to be a percentage to start with.  It is all doable
depending on what you input looks like and what you want your output
to look like.  That is the beauty of R.

On Mon, Jan 26, 2009 at 11:33 PM, Huihua Lu h...@mix.wvu.edu wrote:
 Hi, All,

 I want to construct a pareto chart for my data. My data has two
 columns: modules and defects(each module has several defects). Now I
 use pareto.chart to create a chart for defects which y axis is
 cumulative percentage of defect, and x axis is value of defect. That
 is not what I want. I need the x axis be percentage of modules. Is
 there any way that I can change the scale of x axis, that make x axis
 be percent scale for modules, like 0% to 100% modules. So that I can
 directly read the chart, is that 20% modules contains 80% defect. Or,
 is there any function that I can use to achive it directly?
 Thank you in advanced!

 Hedy

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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 that you are trying to solve?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] RCurl unable to download a particular web page -- what is so special about this web page?

2009-01-27 Thread clair.crossup...@googlemail.com
Thank you Duncan.

I remember seeing in your documentation that you have used this
'verbose=TRUE' argument in functions before when trying to see what is
going on. This is good. However, I have not been able to get it to
work for me. Does the output appear in R or do you use some other
external window (i.e. MS DOS window?)?

 library(RCurl)
 my.url - 
 'http://www.nytimes.com/2009/01/07/technology/business-computing/07program.html?_r=2'
 getURL(my.url, verbose = TRUE)
[1] 



I am having a problem with a new webpage (http://uk.youtube.com/) but
if i can get this verbose to work, then i think i will be able to
google the right action to take based on the information it gives.

Many thanks for your time,
C.C.


On 26 Jan, 16:12, Duncan Temple Lang dun...@wald.ucdavis.edu wrote:
 clair.crossup...@googlemail.com wrote:
  Dear R-help,

  There seems to be a web page I am unable to download using RCurl. I
  don't understand why it won't download:

  library(RCurl)
  my.url - 
  http://www.nytimes.com/2009/01/07/technology/business-computing/07pro...;
  getURL(my.url)
  [1] 

   I like the irony that RCurl seems to have difficulties downloading an
 article about R.  Good thing it is just a matter of additional arguments
 to getURL() or it would be bad news.

 The followlocation parameter defaults to FALSE, so

    getURL(my.url, followlocation = TRUE)

 gets what you want.

 The way I found this  is

   getURL(my.url, verbose = TRUE)

 and take a look at the information being sent from R
 and received by R from the server.

 This gives

 * About to connect() towww.nytimes.comport 80 (#0)
 *   Trying 199.239.136.200... * connected
 * Connected towww.nytimes.com(199.239.136.200) port 80 (#0)
   GET /2009/01/07/technology/business-computing/07program.html?_r=2
 HTTP/1.1
 Host:www.nytimes.com
 Accept: */*

  HTTP/1.1 301 Moved Permanently
  Server: Sun-ONE-Web-Server/6.1
  Date: Mon, 26 Jan 2009 16:10:51 GMT
  Content-length: 0
  Content-type: text/html
  
 Location:http://www.nytimes.com/glogin?URI=http://www.nytimes.com/2009/01/07/t...
 

 And the 301 is the critical thing here.

   D.



  Other web pages are ok to download but this is the first time I have
  been unable to download a web page using the very nice RCurl package.
  While i can download the webpage using the RDCOMClient, i would like
  to understand why it doesn't work as above please?

  library(RDCOMClient)
  my.url - 
  http://www.nytimes.com/2009/01/07/technology/business-computing/07pro...;
  ie - COMCreate(InternetExplorer.Application)
  txt - list()
  ie$Navigate(my.url)
  NULL
  while(ie[[Busy]]) Sys.sleep(1)
  txt[[my.url]] - ie[[document]][[body]][[innerText]]
  txt
  $`http://www.nytimes.com/2009/01/07/technology/business-computing/
  07program.html?_r=2`
  [1] Skip to article Try Electronic Edition Log ...

  Many thanks for your time,
  C.C

  Windows Vista, running with administrator privileges.
  sessionInfo()
  R version 2.8.1 (2008-12-22)
  i386-pc-mingw32

  locale:
  LC_COLLATE=English_United Kingdom.1252;LC_CTYPE=English_United Kingdom.
  1252;LC_MONETARY=English_United Kingdom.
  1252;LC_NUMERIC=C;LC_TIME=English_United Kingdom.1252

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

  other attached packages:
  [1] RDCOMClient_0.92-0 RCurl_0.94-0

  loaded via a namespace (and not attached):
  [1] tools_2.8.1

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

 __
 r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guidehttp://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] RCurl unable to download a particular web page -- what is so special about this web page?

2009-01-27 Thread Duncan Temple Lang



clair.crossup...@googlemail.com wrote:

Thank you Duncan.

I remember seeing in your documentation that you have used this
'verbose=TRUE' argument in functions before when trying to see what is
going on. This is good. However, I have not been able to get it to
work for me. Does the output appear in R or do you use some other
external window (i.e. MS DOS window?)?



The libcurl code typically defaults to print on the console.
So on the Windows GUI, this will not show up. Using
a shell (MS DOS window or Unix-like shell) should
should cause the output to be displayed.

A more general way however is to use the debugfunction
option.

d = debugGatherer()

getURL(http://uk.youtube.com;,
debugfunction = d$update, verbose = TRUE)

When this completes, use

 d$value()

and you have the entire contents that would be displayed on the console.


 D.




library(RCurl)
my.url - 
'http://www.nytimes.com/2009/01/07/technology/business-computing/07program.html?_r=2'
getURL(my.url, verbose = TRUE)

[1] 


I am having a problem with a new webpage (http://uk.youtube.com/) but
if i can get this verbose to work, then i think i will be able to
google the right action to take based on the information it gives.

Many thanks for your time,
C.C.


On 26 Jan, 16:12, Duncan Temple Lang dun...@wald.ucdavis.edu wrote:

clair.crossup...@googlemail.com wrote:

Dear R-help,
There seems to be a web page I am unable to download using RCurl. I
don't understand why it won't download:

library(RCurl)
my.url - 
http://www.nytimes.com/2009/01/07/technology/business-computing/07pro...;
getURL(my.url)

[1] 

  I like the irony that RCurl seems to have difficulties downloading an
article about R.  Good thing it is just a matter of additional arguments
to getURL() or it would be bad news.

The followlocation parameter defaults to FALSE, so

   getURL(my.url, followlocation = TRUE)

gets what you want.

The way I found this  is

  getURL(my.url, verbose = TRUE)

and take a look at the information being sent from R
and received by R from the server.

This gives

* About to connect() towww.nytimes.comport 80 (#0)
*   Trying 199.239.136.200... * connected
* Connected towww.nytimes.com(199.239.136.200) port 80 (#0)
  GET /2009/01/07/technology/business-computing/07program.html?_r=2
HTTP/1.1
Host:www.nytimes.com
Accept: */*

 HTTP/1.1 301 Moved Permanently
 Server: Sun-ONE-Web-Server/6.1
 Date: Mon, 26 Jan 2009 16:10:51 GMT
 Content-length: 0
 Content-type: text/html
 
Location:http://www.nytimes.com/glogin?URI=http://www.nytimes.com/2009/01/07/t...


And the 301 is the critical thing here.

  D.




Other web pages are ok to download but this is the first time I have
been unable to download a web page using the very nice RCurl package.
While i can download the webpage using the RDCOMClient, i would like
to understand why it doesn't work as above please?

library(RDCOMClient)
my.url - 
http://www.nytimes.com/2009/01/07/technology/business-computing/07pro...;
ie - COMCreate(InternetExplorer.Application)
txt - list()
ie$Navigate(my.url)

NULL

while(ie[[Busy]]) Sys.sleep(1)
txt[[my.url]] - ie[[document]][[body]][[innerText]]
txt

$`http://www.nytimes.com/2009/01/07/technology/business-computing/
07program.html?_r=2`
[1] Skip to article Try Electronic Edition Log ...
Many thanks for your time,
C.C
Windows Vista, running with administrator privileges.

sessionInfo()

R version 2.8.1 (2008-12-22)
i386-pc-mingw32
locale:
LC_COLLATE=English_United Kingdom.1252;LC_CTYPE=English_United Kingdom.
1252;LC_MONETARY=English_United Kingdom.
1252;LC_NUMERIC=C;LC_TIME=English_United Kingdom.1252
attached base packages:
[1] stats graphics  grDevices utils datasets  methods
base
other attached packages:
[1] RDCOMClient_0.92-0 RCurl_0.94-0
loaded via a namespace (and not attached):
[1] tools_2.8.1
__
r-h...@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guidehttp://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] retrieving variables values from a function

2009-01-27 Thread diego Diego
Hello experts!
 Is there a way to send an internal variable from a function to the
workspace, besides the function output, of course


Thanks!!


D.

[[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] glm StepAIC with all interactions and update to remove a term vs. glm specifying all but a few terms and stepAIC

2009-01-27 Thread Michael Dewey

At 12:49 26/01/2009, Robert Michael Inman wrote:

Problem:
I am sorting through model selection process for first time and want to make
sure that I have used glm, stepAIC, and update correctly.  Something is
strange because I get a different result between:

1) a glm of 12 predictor variables followed by a stepAIC where all
interactions are considered and then an update to remove one specific
interaction.

vs.

2) entering all the terms individually in a glm (exept the one that I
removed with update and 4 others like it but which did not make it to final
model anyway), and then running stepAIC.


I am not the world's leading expert on this area but nobody else 
seems to have replied yet so here goes:
1 - stepwise methods capitalise on chance features of your dataset 
and so starting from a slightly different place may give different 
results. For instance if you do all possible subsets then the 'best' 
subset of size k is not guaranteed to include the members of the 
'best' subset of size j (jk) and indeed may not include any of them.
2 - the lack of significance of some predictors in the last model is 
probably because stepAIC respects marginality, certainly MASS implies this.

You might find
@book{miller90,
   author = Miller, A J,
   title = Subset selection in regression,
   year = 1990,
   publisher = Chapman and Hall,
   address = London,
   keywords= {stepwise}
}
helpful. And MASS of course since the package is support for the book.


Question:
Why do these processes not yield same model?



Here are all the details if helpful:
I start with 12 potential predictor variables, 7 primary terms and 5
additional that are I(primary_terms^2).  I run a glm for these 12 and then
do stepAIC (BIC actually) both directions.  The scope argument is
scope=list(upper=~.^2,lower=NULL).  This means there are 78 predictor terms
considered, the 12 primary terms and 66 interactions [n(n+1)/2].  I see this
with trace=T also.  Here is the code used:

glm1-glm(formula = PRESENCE == 1 ~ SNOW + I(SNOW^2) + POP_DEN + ROAD_DE
+ ADJELEV + I(ADJELEV^2) + TRI + I(TRI^2) + EDGE + I(EDGE^2) + TREECOV +
I(TREECOV^2),family = binomial, data = wolv)
summary(glm1)
library(MASS)
stepglm2-stepAIC(glm1,scope=list(upper=~.^2,lower=NULL),
trace=T,k=log(4828),direction=both)
summary(stepglm2)
extractAIC(stepglm2,k=log(4828))

This results in a 15 term model with a BIC of 3758.659

Coefficients:
Estimate Std. Error z value Pr(|z|)
(Intercept)   -4.983e+01  9.263e+00  -5.379 7.50e-08 ***
SNOW   6.085e-02  8.641e-03   7.041 1.90e-12 ***
ROAD_DE   -5.637e-01  1.192e-01  -4.730 2.24e-06 ***
ADJELEV2.880e-02  7.457e-03   3.863 0.000112 ***
I(ADJELEV^2)  -4.038e-06  1.487e-06  -2.715 0.006618 **
TRI5.675e-02  1.081e-02   5.248 1.54e-07 ***
I(TRI^2)  -1.713e-03  4.243e-04  -4.036 5.43e-05 ***
EDGE   6.418e-03  1.697e-03   3.782 0.000156 ***
TREECOV1.680e-01  2.929e-02   5.735 9.76e-09 ***
SNOW:ADJELEV  -4.313e-05  6.935e-06  -6.219 5.00e-10 ***
ADJELEV:TREECOV   -6.628e-05  1.161e-05  -5.711 1.13e-08 ***
SNOW:I(ADJELEV^2)  7.437e-09  1.384e-09   5.373 7.74e-08 ***
TRI:I(TRI^2)   1.321e-06  3.419e-07   3.863 0.000112 ***
I(ADJELEV^2):I(TRI^2) -2.127e-10  5.745e-11  -3.702 0.000214 ***
ADJELEV:I(TRI^2)   1.029e-06  3.004e-07   3.424 0.000617 ***
SNOW:TRI   1.057e-05  3.372e-06   3.135 0.001721 **



The final model included a the TRI:I(TRI^2) term, which is effectively a
cubic function.  So this was removed because cubic's were not considered for
all variables.  I used update to remove TRI:I(TRI^2).  Code:

stepglm3-update(stepglm2,~.-TRI:I(TRI^2),trace=T)
summary(stepglm3)
extractAIC(stepglm3,k=log(4828))

This results in a 14 term model with a BIC of 3770.172.  The BIC is a little
higher, but the cubic term improved fit and is no longer in, so expected.

Coefficients:
Estimate Std. Error z value Pr(|z|)
(Intercept)   -5.329e+01  9.267e+00  -5.750 8.92e-09 ***
SNOW   6.241e-02  8.695e-03   7.178 7.06e-13 ***
ROAD_DE   -5.756e-01  1.184e-01  -4.863 1.16e-06 ***
ADJELEV3.233e-02  7.452e-03   4.338 1.44e-05 ***
I(ADJELEV^2)  -4.724e-06  1.487e-06  -3.177 0.001489 **
TRI1.834e-02  5.402e-03   3.395 0.000687 ***
I(TRI^2)  -1.122e-03  3.920e-04  -2.863 0.004190 **
EDGE   6.344e-03  1.690e-03   3.754 0.000174 ***
TREECOV1.745e-01  2.923e-02   5.969 2.39e-09 ***
SNOW:ADJELEV  -4.444e-05  6.984e-06  -6.363 1.98e-10 ***
ADJELEV:TREECOV   -6.885e-05  1.160e-05  -5.937 2.90e-09 ***
SNOW:I(ADJELEV^2)  7.681e-09  1.395e-09   5.506 3.67e-08 ***
I(ADJELEV^2):I(TRI^2) 

Re: [R] retrieving variables values from a function

2009-01-27 Thread baptiste auguie
I guess by workspace you mean global environment. I believe this is  
generally considered a bad practice, but see ?assign and ?-



baptiste

On 27 Jan 2009, at 13:54, diego Diego wrote:


Hello experts!
Is there a way to send an internal variable from a function to the
workspace, besides the function output, of course


Thanks!!


D.

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


_

Baptiste Auguié

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Windows, gsview: corrupted bbox of .e?ps graphics

2009-01-27 Thread Michael Friendly

System: [Windows XP Pro, R 2.8.0 and R 2.81.]

When I do R graphics on Windows and want .eps output for LaTeX, with *tight
bounding boxes* I usually do as follows from Rgui:
- Save as Postscript ... myfig.ps
- Open myfig.ps in Gsview, select PS to EPS, Save as ... myfig.eps
This always worked before, and gave me .eps files that did not include much
more white space than I like, didn't require fiddling with par(), nor using
\includegraphics[trim=]{myfig}.

But now I've encountered a problem that prevents this workflow from
working --- when I now open *any* R-generated-this-way .ps or .eps file,
with GSview (v 4.9), the bounding box of the graphic is corrupted--
i.e., the bounding box I see cuts off the top half of the figure.
See:
http://euclid.psych.yorku.ca/SCS/Private/agree-MS-buggged.eps
for
the example produced below.

This does view OK with gv on linux, however, the usual tool I use on
linux to find new, tight bbox won't work on this file:

%psfixbb -l agree-MS-bugged.eps
psfixbb: Probloem with new %%BoundingBox: -4 -4 616 796

What caused this was an example from vcd, that I wanted in .eps form.  
What I got from
my usual method of Save as Postscript was not at all pleasing--- font 
sizes in the

.ps image were way larger than what appeared on the screen.  So, I added a
postscript() command to the example in ?agreementplot

library(vcd)
data(MSPatients)
## best visualized using a resized device, e.g. using:
#get(getOption(device))(width = 12)
dev.new()

postscript(file=agree-MS.ps, paper=special, horizontal=FALSE, 
width=6.0, height=3.0)

pushViewport(viewport(layout = grid.layout(ncol = 2)))
pushViewport(viewport(layout.pos.col = 2))
agreementplot(t(MSPatients[,,1]), main = Winnipeg Patients,
 newpage = FALSE)
popViewport()
pushViewport(viewport(layout.pos.col = 1))
agreementplot(t(MSPatients[,,2]), main = New Orleans Patients,
 newpage = FALSE)
popViewport(2)
dev.off()

Ever since, when I use gsview on Win to view *any*  .eps file  
generated  via Save as Postscript from the R graphics window,
I get similar behavior. This happens in a fresh R session, as well as 
with R 2.8.1.  It doesn't happen with Sweave-generated

graphics (but I haven't tried the above example in Sweave).

Any ideas on what is wrong and how I can fix this?

-Michael

--
Michael Friendly Email: friendly AT yorku DOT ca 
Professor, Psychology Dept.

York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele Streethttp://www.math.yorku.ca/SCS/friendly.html
Toronto, ONT  M3J 1P3 C
NADA

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

2009-01-27 Thread mauede
Is there a way to force the number of ticks along an axis ?
I read the on-line documentation and tried many combinations of all available 
parameters from functions
par(), axTicks(), axis(), plot() ... but no luck !

Thank you very much,
Maura


tutti i telefonini TIM!


[[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] plot Ticks

2009-01-27 Thread John Kane
Will something like this do what you want?

x - 1:10
y=rnorm(10)
plot(x,y,xaxt=n)
axis(1,at= seq(.5,10,.5))


--- On Tue, 1/27/09, mau...@alice.it mau...@alice.it wrote:

 From: mau...@alice.it mau...@alice.it
 Subject: [R] plot Ticks
 To: r-h...@stat.math.ethz.ch
 Received: Tuesday, January 27, 2009, 9:13 AM
 Is there a way to force the number of ticks along an axis ?
 I read the on-line documentation and tried many
 combinations of all available parameters from functions
 par(), axTicks(), axis(), plot() ... but no luck !
 
 Thank you very much,
 Maura
 
 
 tutti i telefonini TIM!
 
 
   [[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.


  __
[[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] plot Ticks

2009-01-27 Thread baptiste auguie

Try this:


plot(1:20)
axis(3, at=seq(0,20), label=FALSE)



A better description of your plot would be useful if ?axis is not  
enough to help you out.


hope this helps,

baptiste

On 27 Jan 2009, at 14:13, mau...@alice.it wrote:


Is there a way to force the number of ticks along an axis ?
I read the on-line documentation and tried many combinations of all  
available parameters from functions

par(), axTicks(), axis(), plot() ... but no luck !

Thank you very much,
Maura


tutti i telefonini TIM!


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


_

Baptiste Auguié

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag

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


Re: [R] Error in Surv(time, status)

2009-01-27 Thread Terry Therneau
 I used following command:
 frailtyPenal(Surv(time, status) ~var1 + cluster(family), Frailty=TRUE
 ,n.knots=8, kappa1=1500,
+ cross.validation=FALSE)

And got this error :
Error in Surv(time, status) : Time variable is not numeric
In addition: Warning message:
In is.na(time) : is.na() applied to non-(list or vector) of type 'closure'

---

  It looks like you forgot data= in your model statement, which makes 'time' 
refer to the function of that name.
  
Terry T.

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

2009-01-27 Thread Thomas Roth (geb. Kaliwe)

you could set them manually, if thats what you're looking for

plot(1:10, axes = F)
axis(1, at = seq(1,10 , length = 3))

mau...@alice.it schrieb:

Is there a way to force the number of ticks along an axis ?
I read the on-line documentation and tried many combinations of all available 
parameters from functions
par(), axTicks(), axis(), plot() ... but no luck !

Thank you very much,
Maura


tutti i telefonini TIM!


[[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] retrieving variables values from a function

2009-01-27 Thread jim holtman
Just have it as a return value and then assign it when you return.
You should have have side effects coming from your functions.  There
are ways of doing it, but it you think you have to, think about it
again.

On Tue, Jan 27, 2009 at 8:54 AM, diego Diego dhab...@gmail.com wrote:
 Hello experts!
  Is there a way to send an internal variable from a function to the
 workspace, besides the function output, of course


 Thanks!!


 D.

[[alternative HTML version deleted]]

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




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

What is the problem that you are trying to solve?

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

2009-01-27 Thread krzysztof . sakrejda
Assuming you _really_ want to do this check out '-' and closures... And 
remember that your code will probably make other people cry when they go to 
debug it. 

Krzysztof

Sent via BlackBerry by ATT

-Original Message-
From: jim holtman jholt...@gmail.com

Date: Tue, 27 Jan 2009 09:43:17 
To: diego Diegodhab...@gmail.com
Cc: r-help@r-project.org
Subject: Re: [R] retrieving variables values from a function


Just have it as a return value and then assign it when you return.
You should have have side effects coming from your functions.  There
are ways of doing it, but it you think you have to, think about it
again.

On Tue, Jan 27, 2009 at 8:54 AM, diego Diego dhab...@gmail.com wrote:
 Hello experts!
  Is there a way to send an internal variable from a function to the
 workspace, besides the function output, of course


 Thanks!!


 D.

[[alternative HTML version deleted]]

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




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

What is the problem that you are trying to solve?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Problem with RMA using limma, oligo and pdInfoBuilder packages

2009-01-27 Thread Anne-Marie Madore
Hi,

 

I am a Ph.D. student from Québec, Canada. I’m a beginner with R and
Bioconductor. Until now the only experience I have is in analyzing
microarray data using affy and limma packages. Now I am trying to analyze
Rat Gene 10 st arrays and I would like to run RMA analysis and Smyth
moderated t test on those arrays. Since no cdf official package is available
for those arrays, after reading many of the questions and responses on this
mailing list, I decided to use pdInfoBuilder, oligo and limma packages to
run analysis. The problem is, at the end, I get expression and differential
expression measured for all probe separately but not the calculated
expression representing all probe of each gene. When I run RMA, I got only
two steps, Background correcting and Normalizing but not Calculating
expression. Do you know how I can get differential expression calculated for
each gene? I don’t know if the problem is in the package I built or if I can
use some code to answer this question. I list all codes used to build and
install the package “pd.ragene.1.0.st.v1” and used to analyze expression
arrays below.

 

Many thanks for your help,

 

Anne-Marie Madore

 

 

 

 

## building the package

 

 library(Biobase)

Loading required package: tools

 

Welcome to Bioconductor

 

  Vignettes contain introductory material. To view, type

  'openVignette()'. To cite Bioconductor, see

  'citation(Biobase)' and for packages 'citation(pkgname)'.

 

 library(pdInfoBuilder)

Loading required package: RSQLite

Loading required package: DBI

Loading required package: affxparser

Loading required package: oligo

Loading required package: splines

Loading required package: preprocessCore

Loading required package: AnnotationDbi

Loading required package: oligoClasses

oligo Package - Series 1.5.x

 setwd(D:/Anne-Marie/Doctorat/puces ADN macrophages/puces rat/Annie
Dube/Analyse)

 transFile -
RaGene-1_0-st-v1.na27.rn4.transcript.csv1/RaGene-1_0-st-v1.na27.rn4.transcr
ipt.csv

 probeFile - RaGene-1_0-st-v1.probe.tab/RaGene-1_0-st-v1.probe.tab

 clfFile - RaGene-1_0-st-v1.r4.clf/RaGene-1_0-st-v1.r4.clf

 pgfFile - RaGene-1_0-st-v1.r4.pgf/RaGene-1_0-st-v1.r4.pgf

 pkg - new(AffyGenePDInfoPkgSeed, author=Anne-Marie Madore,
email=anne-marie.mador...@ulaval.ca, version=0.0.1,

+ genomebuild=RefSeq April 3, 2007, GenBank® January 25, 2007, Rat Ensembl
transcripts April 3, 2007 ,

+ biocViews=AnnotationData, pgfFile=pgfFile, clfFile=clfFile,
transFile=transFile, probeFile=probeFile)

 makePdInfoPackage(pkg, destDir=.)

Creating package in ./pd.ragene.1.0.st.v1 

loadUnitsByBatch took 50.51 sec

loadAffyCsv took 12.73 sec

loadAffySeqCsv took 57.62 sec

DB sort, index creation took 24.75 sec

[1] TRUE

Warning messages:

1: In is.na(x) : is.na() applied to non-(list or vector) of type 'NULL'

2: In is.na(x) : is.na() applied to non-(list or vector) of type 'NULL'

 

 

## installing the package in cmd command shell

 

Microsoft Windows [version 6.0.6001]

Copyright (c) 2006 Microsoft Corporation. Tous droits réservés.

 

C:\Users\Anne-Marie Madorecd c:\Program Files\R\R-2.8.1\bin

 

c:\Program Files\R\R-2.8.1\binR CMD INSTALL pd.ragene.1.0.st.v1

installing to 'c:/PROGRA~1/R/R-28~1.1/library'

 

 

-- Making package pd.ragene.1.0.st.v1 

  adding build stamp to DESCRIPTION

  installing NAMESPACE file and metadata

  installing R files

  installing inst files

  preparing package pd.ragene.1.0.st.v1 for lazy loading

Loading required package: RSQLite

Loading required package: DBI

Loading required package: oligoClasses

Loading required package: Biobase

Loading required package: tools

 

Welcome to Bioconductor

 

  Vignettes contain introductory material. To view, type

  'openVignette()'. To cite Bioconductor, see

  'citation(Biobase)' and for packages 'citation(pkgname)'.

 

  no man files in this package

  installing indices

  installing help

  adding MD5 sums

 

* DONE (pd.ragene.1.0.st.v1)

 

 

## If I run a check (R CMD check pd.ragene.st.v1) I get three warning
messages and one note: 

 

1.   * checking R files for non-ASCII characters ... WARNING 
Found the following files with non-ASCII characters: all.R Portable packages
must use only ASCII characters in their R code, except perhaps in comments.

2.   * checking whether the name space can be loaded with stated
dependencies ... WARNING
Error in initDbConnection() : could not find function dbConnect Error:
.onLoad failed in 'loadNamespace' for 'pd.ragene.1.0.st.v1' Execution halted
A namespace must be able to be loaded with just the base namespace loaded:
otherwise if the namespace gets loaded by a saved object, the session will
be unable to start. 
Probably some imports need to be declared in the NAMESPACE file.

3.   * checking R code for possible problems ... NOTE
closeDb: no visible binding for global variable 'dbCon' 

4.   * checking for missing documentation entries ... WARNING
Undocumented code objects: 

[R] Mixed Effects Model with Different Group Sizes

2009-01-27 Thread Carsten Giessing
Hi R user,
 
I can not find the answer for a simple problem. I want to test the main effects 
and interactions of a 2 by 2 factorial design (Experiment I) and 2 by 2 by 2 
factorial design (Experiment II) with unequal group sizes and one or two 
within-subject factors.

2 by 2 Design (Experiment I):
Factor A is a fixed grouping factor with different group sizes for group A1 and 
A2 (reflecting the different appearance of the factor levels within the 
population).
Factor B is a fixed “within-subject” factor and has two levels: The means of 
conditions B1 and B2 for each subject. Thereby condition B1 has been measured 
more frequently than condition B2.
Each subject in group A1 and A2 was measured under the conditions B1 and B2.

Experiment II has an additional “within-subject” factor C.  Thereby B1 and B2 
were measured under conditions C1 and C2.

From my current readings I suggest for Experiment I:

library(lme4)
model1 - lmer (beta ~  B  - 1+(1| subject), data=data.ex,REML=FALSE)
model2 - lmer (beta ~  A  - 1 +(1| subject), data=data.ex,REML=FALSE)
model3 - lmer (beta ~  A + B - 1 +(1| subject),data=data.ex,REML=FALSE)
model4 - lmer (beta ~  A * B - 1 +(1| subject),  data=data.ex,REML=FALSE)

anova(model1,model3)   #Main effect factor A
anova(model2,model3)   #Main effect factor B
anova(model3,model4)   #Interaction factor A x B

Is this correct (error strata for unequal group sizes)? Do you suggest 
different solutions?  Does the solution for experiment II follow the same 
principle of error strata?

Many thanks,
Carsten

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Goodness of fit for gamma distributions

2009-01-27 Thread Dan31415

Thanks for that Remko, but im slightly confused because isnt this testing the
goodness of fit of 2 slightly different gamma distributions, not of how well
a gamma distribution is representing the data.

e.g.

data.vec-as.vector(data)

(do some mle to find the parameters of a gamma distribution for data.vec)

xrarea-seq(-2,9,0.05)
yrarea-dgamma(xrarea,shape=7.9862,rate=2.6621)

so now yrarea is the gamma distribution and i want to compare it with
data.vec to see how well it fits.

regards,
Dann


Remko Duursma-2 wrote:
 
 Hi Dann,
 
 there is probably a better way to do this, but this works anyway:
 
 # your data
 gamdat - rgamma(1, shape=1, rate=0.5)
 
 # comparison to gamma:
 gamsam - rgamma(1, shape=1, rate=0.6)
 
 qqplot(gamsam,gamdat)
 abline(0,1)
 
 
 greetings
 Remko
 
 
 -
 Remko Duursma
 Post-Doctoral Fellow
 
 Centre for Plant and Food Science
 University of Western Sydney
 Hawkesbury Campus
 Richmond NSW 2753
 
 Dept of Biological Science
 Macquarie University
 North Ryde NSW 2109
 Australia
 
 Mobile: +61 (0)422 096908
 
 
 
 On Tue, Jan 27, 2009 at 3:38 AM, Dan31415 d.m.mitch...@reading.ac.uk
 wrote:

 I'm looking for goodness of fit tests for gamma distributions with large
 data
 sizes. I have a matrix with around 10,000 data values in it and i have
 fitted a gamma distribution over a histogram of the data.

 The problem is testing how well that distribution fits. Chi-squared seems
 to
 be used more for discrete distributions and kolmogorov-smirnov seems that
 large sample sizes make it had to evaluate the D statistic. Also i
 haven't
 found a qq plot for gamma, although i think this might be an appropriate
 test.

 in summary
 -is there a gamma goodness of fit test that doesnt depend on the sample
 size?
 -is there a way of using qqplot for gamma distributions, if so how would
 you
 calculate it from a matrix of data values?

 regards,
 Dann
 --
 View this message in context:
 http://www.nabble.com/Goodness-of-fit-for-gamma-distributions-tp21668711p21668711.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.
 
 

-- 
View this message in context: 
http://www.nabble.com/Goodness-of-fit-for-gamma-distributions-tp21668711p21686095.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] Error in Surv(time, status) : Time variable is not numeric

2009-01-27 Thread Braem M

Thank you for your reply.

Even when I put data=..  in my model statement, I get the same error.



Chris Andrews wrote:
 
 R is finding the R function 'time' rather than your variable time in your
 dataset.  Perhaps adding 'data=mydata' to your function call will resolve
 your issue.
 
 Chris
 
 
 Braem M wrote:
 
 Dear,
 
 I want to analyze two-level survival data using a shared frailty model,
 for which I want to use the R package 'Frailtypack, proposed by Rondeau
 et al. The dataset was built using SAS software. I also tried to change
 the format using SPSS and Excell. 
 
 My (reduced) dataset has following column names:
 ID entrytimestatusfamily var1
 
 I used following command:
 frailtyPenal(Surv(time, status) ~var1 + cluster(family), Frailty=TRUE
 ,n.knots=8, kappa1=1500,
 + cross.validation=FALSE)
 
 And got this error :
 Error in Surv(time, status) : Time variable is not numeric
 In addition: Warning message:
 In is.na(time) : is.na() applied to non-(list or vector) of type
 'closure'
 
 I think R transforms the data when importing into R, so that the
 observations are not numeric anymore.
 
 Does anyone know how to handle this problem?
 
 Thanks,
 
 Marie
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Error-in-Surv%28time%2C-status%29-%3A-Time-variable-is-not-numeric-tp21674025p21686806.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] Creating list or numeric vectors out of selected columns of row oriented data

2009-01-27 Thread R. Mark Sharp
I am just assuming this can be done, but I have not gotten close to  
making it happen. I have a data file with about 1 million rows with  
1470 unique subjects. Each row represents a small set of observations  
made on a specific date for a single subject. I would like to  
transform the data so that I have an R object with a single entry for  
each subject and start date and vectors for the observation dates and  
the observations. The data are something like the following where for  
each subject the subject_id does not change and the start_date does  
not change, but the obeservation_date and the three different  
observations change between rows. (There is one row for each day for  
each subject over a three year period although some entered the study  
late):
'subject_id', 'start_date','observation_date','weight_obs',  
'activity_obs','calories_obs'
1,'1/1/2005','1/1/2005',3.26,'a',93
1,'1/1/2005','1/2/2005',3.22,'o',85
1,'1/1/2005','1/3/2005',3.28,'o',91
...
1,'1/1/2005','12/31/2008',4.38,'h',102
2,'2/13/2005','2/13/2005',3.02,'l',80
2,'2/13/2005','2/14/2005',3.08,'j',85
...

Any guidance is appreciated.

R. Mark Sharp, Ph.D.
Director of Primate Records Database
Southwest National Primate Center
Southwest Foundation for
Biomedical Research
P.O. Box 760549
San Antonio, TX 78245-0549
Telephone: (210)258-9476
e-mail: msh...@sfbr.org




[[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] optim() and ARIMA

2009-01-27 Thread nashjc
dhabby wrote:
Last week I run in to a lot a problems triyng to fit an ARIMA model to a
time series. The problem is that the internal process of the arima
function
call function optim to estimate the model parameters, so far so good...
but my data presents a problem with the default method BFGS of the
optim
function, the output error looks like this:

Error en optim(init[mask], armafn, method = BFGS, hessian = TRUE, control
= optim.control,  :
  non-finite finite-difference value [7]

I don't know much about the calls from ARIMA to optim, but when I modified
Fletcher's 1970 VM method (called BFGS in R), I was aiming to make it
extremely robust to messy functions. (I had machinery with only 6 hex
digits for floating point and no guard digits. Furthermore, only 8K bytes
for program AND data. This was 1975/6.) However, BFGS needs gradients, and
it is clear there's some sort of trouble approximating them with finite
differences.

Changing optimization methods might succeed on this occasion, but your
problem is more likely bad scaling or some setup where your ARIMA model
essentially is not sensible. Can you duplicate the message on a small
example problem?

John Nash

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] RCurl unable to download a particular web page -- what is so special about this web page?

2009-01-27 Thread clair.crossup...@googlemail.com
Thank you. The output i get from that example is below:

 d = debugGatherer()
 getURL(http://uk.youtube.com;,
+  debugfunction = d$update, verbose = TRUE )
[1] 
 d$value()
 
text
About to connect() to uk.youtube.com port 80 (#0)\n  Trying
208.117.236.72... connected\nConnected to uk.youtube.com
(208.117.236.72) port 80 (#0)\nConnection #0 to host uk.youtube.com
left intact\n
 
headerIn
HTTP/1.1 400 Bad Request\r\nVia: 1.1 PFO-FIREWALL\r\nConnection: Keep-
Alive\r\nProxy-Connection: Keep-Alive\r\nTransfer-Encoding: chunked\r
\nExpires: Tue, 27 Apr 1971 19:44:06 EST\r\nDate: Tue, 27 Jan 2009
15:31:25 GMT\r\nContent-Type: text/plain\r\nServer: Apache\r\nX-
Content-Type-Options: nosniff\r\nCache-Control: no-cache\r
\nCneonction: close\r\n\r\n
 
headerOut
GET / HTTP/1.1\r\nHost: uk.youtube.com\r\nAccept: */*\r\n\r\n
 
dataIn
0\r\n\r\n
 
dataOut



So the critical information from this is the '400 Bad Request'. A
Google search defines this for me as:

The request could not be understood by the server due to malformed
syntax. The client SHOULD NOT repeat the request without
modifications.


looking through sort(both listCurlOptions() and
http://curl.haxx.se/libcurl/c/curl_easy_setopt.htm) doesn't really
help me this time (unless i missed something). Any advice?

Thank you for your time,
C.C

P.S. I can get the d/l to work if i use:
 toString(readLines(http://www.uk.youtube.com;))
[1] html, \thead, \t\ttitleOpenDNS/title, \t/head, ,
\tbody id=\mainbody\ onLoad=\testforbanner();\ style=\margin:
0px;\, \t\tscript language=\JavaScript\, \t\t\tfunction
testforbanner() {, \t\t\t\tvar width;, \t\t\t\tvar height;, \t\t\t
\tvar x = 0;, \t\t\t\tvar isbanner = false;, \t\t\t\tvar bannersizes =
new Array(16), \t\t\t\tbannersizes[0] = [etc]





On 27 Jan, 13:52, Duncan Temple Lang dun...@wald.ucdavis.edu wrote:
 clair.crossup...@googlemail.com wrote:
  Thank you Duncan.

  I remember seeing in your documentation that you have used this
  'verbose=TRUE' argument in functions before when trying to see what is
  going on. This is good. However, I have not been able to get it to
  work for me. Does the output appear in R or do you use some other
  external window (i.e. MS DOS window?)?

 The libcurl code typically defaults to print on the console.
 So on the Windows GUI, this will not show up. Using
 a shell (MS DOS window or Unix-like shell) should
 should cause the output to be displayed.

 A more general way however is to use the debugfunction
 option.

 d = debugGatherer()

 getURL(http://uk.youtube.com;,
          debugfunction = d$update, verbose = TRUE)

 When this completes, use

   d$value()

 and you have the entire contents that would be displayed on the console.

   D.



  library(RCurl)
  my.url - 
  'http://www.nytimes.com/2009/01/07/technology/business-computing/07pro...
  getURL(my.url, verbose = TRUE)
  [1] 

  I am having a problem with a new webpage (http://uk.youtube.com/) but
  if i can get this verbose to work, then i think i will be able to
  google the right action to take based on the information it gives.

  Many thanks for your time,
  C.C.

  On 26 Jan, 16:12, Duncan Temple Lang dun...@wald.ucdavis.edu wrote:
  clair.crossup...@googlemail.com wrote:
  Dear R-help,
  There seems to be a web page I am unable to download using RCurl. I
  don't understand why it won't download:
  library(RCurl)
  my.url - 
  http://www.nytimes.com/2009/01/07/technology/business-computing/07pro...;
  getURL(my.url)
  [1] 
    I like the irony that RCurl seems to have difficulties downloading an
  article about R.  Good thing it is just a matter of additional arguments
  to getURL() or it would be bad news.

  The followlocation parameter defaults to FALSE, so

     getURL(my.url, followlocation = TRUE)

  gets what you want.

  The way I found this  is

    getURL(my.url, verbose = TRUE)

  and take a look at the information being sent from R
  and received by R from the server.

  This gives

  * About to connect() towww.nytimes.comport80 (#0)
  *   Trying 199.239.136.200... * connected
  * Connected towww.nytimes.com(199.239.136.200) port 80 (#0)
    GET /2009/01/07/technology/business-computing/07program.html?_r=2
  HTTP/1.1
  Host:www.nytimes.com
  Accept: */*

   HTTP/1.1 301 Moved Permanently
   Server: Sun-ONE-Web-Server/6.1
   Date: Mon, 26 Jan 2009 16:10:51 GMT
   Content-length: 0
   Content-type: text/html
   
  Location:http://www.nytimes.com/glogin?URI=http://www.nytimes.com/2009/01/07/t...
  

  And the 301 is the critical thing here.

    D.

  Other web pages are ok to download but this is the first time I have
  been unable to download a web page using the very nice RCurl package.
  While i can download the webpage using the RDCOMClient, i would like
  to understand why it doesn't work as above please?
  library(RDCOMClient)
  my.url - 
  http://www.nytimes.com/2009/01/07/technology/business-computing/07pro...;
  ie - COMCreate(InternetExplorer.Application)
  txt - list()
  

Re: [R] optim() and ARIMA

2009-01-27 Thread Gerard M. Keogh
Surely, this sounds like a bug in the optim function.

The rule of thumb with ts data is to scale so that data have mean 0 and
unit variance and then fit
   a) for non-seasonal data the IMA model (0,1,1); and
   b) for seasonal data so-called Airline Model (0,1,1)X(0,1,1)S
see for example A course in TS analysis by Daniel Pena.
These can usually be fit to most series unless they are very irregular
(e.g. mainly zeros) and then Box-Jenkins ARIMA is inappropriate.

The fit of any other model is then judged against these two models. If a
proposed model fit fails it is usual report the fault and then to step over
that model and try the next in sequence - optim should do this, if not then
it's a code fault.
Very often with nasty series only the 2 basic models can be fit and these
results are reported - but for these the parameters may not even fully
converge.
The moral of all this is that automatic modelling methods are handy but not
a substitute for looking at the acf and choosing an appropriate
parameterisation.

Can someone say whether optim has automatic outlier detection - this is a
must have with this type of procedure.

Gerard




   
 nas...@uottawa.ca 
 Sent by:  
 r-help-boun...@r-  To 
 project.org   r-help@r-project.org
cc 
   
 27/01/2009 15:45  Subject 
   Re: [R] optim() and ARIMA   
   
   
   
   
   
   




dhabby wrote:
Last week I run in to a lot a problems triyng to fit an ARIMA model to
a
time series. The problem is that the internal process of the arima
function
call function optim to estimate the model parameters, so far so
good...
but my data presents a problem with the default method BFGS of the
optim
function, the output error looks like this:

Error en optim(init[mask], armafn, method = BFGS, hessian = TRUE, control
= optim.control,  :
  non-finite finite-difference value [7]

I don't know much about the calls from ARIMA to optim, but when I modified
Fletcher's 1970 VM method (called BFGS in R), I was aiming to make it
extremely robust to messy functions. (I had machinery with only 6 hex
digits for floating point and no guard digits. Furthermore, only 8K bytes
for program AND data. This was 1975/6.) However, BFGS needs gradients, and
it is clear there's some sort of trouble approximating them with finite
differences.

Changing optimization methods might succeed on this occasion, but your
problem is more likely bad scaling or some setup where your ARIMA model
essentially is not sensible. Can you duplicate the message on a small
example problem?

John Nash

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 information transmitted is intended only for the person or entity to which 
it is addressed and may contain confidential and/or privileged material. Any 
review, retransmission, dissemination or other use of, or taking of any action 
in reliance upon, this information by persons or entities other than the 
intended recipient is prohibited. If you received this in error, please contact 
the sender and delete the material from any computer.  It is the policy of the 
Department of Justice, Equality and Law Reform and the Agencies and Offices 
using its IT services to disallow the sending of offensive material.
Should you consider that the material contained in this message is offensive 
you should contact the sender immediately and also mailminder[at]justice.ie.

Is le haghaidh an duine nó an eintitis ar a bhfuil sí dírithe, agus le haghaidh 
an duine nó an eintitis sin amháin, a bheartaítear an fhaisnéis a tarchuireadh 
agus féadfaidh sé go bhfuil ábhar faoi rún agus/nó faoi phribhléid inti. 
Toirmisctear aon athbhreithniú, atarchur nó leathadh a dhéanamh ar an 
bhfaisnéis seo, aon úsáid eile a bhaint aisti nó aon ghníomh a 

Re: [R] Creating list or numeric vectors out of selected columns of row oriented data

2009-01-27 Thread jim holtman
Yes the data can probably be easily transformed, but you would have to
provide an example of what the input looks like to understand what has
to be done with the data and how variable it might be so we can
understand how we might have to parse the data from the input.  Are
the missing days supposed to be filled with with NAs?

On Tue, Jan 27, 2009 at 10:36 AM, R. Mark Sharp msh...@sfbr.org wrote:
 I am just assuming this can be done, but I have not gotten close to
 making it happen. I have a data file with about 1 million rows with
 1470 unique subjects. Each row represents a small set of observations
 made on a specific date for a single subject. I would like to
 transform the data so that I have an R object with a single entry for
 each subject and start date and vectors for the observation dates and
 the observations. The data are something like the following where for
 each subject the subject_id does not change and the start_date does
 not change, but the obeservation_date and the three different
 observations change between rows. (There is one row for each day for
 each subject over a three year period although some entered the study
 late):
 'subject_id', 'start_date','observation_date','weight_obs',
 'activity_obs','calories_obs'
 1,'1/1/2005','1/1/2005',3.26,'a',93
 1,'1/1/2005','1/2/2005',3.22,'o',85
 1,'1/1/2005','1/3/2005',3.28,'o',91
 ...
 1,'1/1/2005','12/31/2008',4.38,'h',102
 2,'2/13/2005','2/13/2005',3.02,'l',80
 2,'2/13/2005','2/14/2005',3.08,'j',85
 ...

 Any guidance is appreciated.

 R. Mark Sharp, Ph.D.
 Director of Primate Records Database
 Southwest National Primate Center
 Southwest Foundation for
Biomedical Research
 P.O. Box 760549
 San Antonio, TX 78245-0549
 Telephone: (210)258-9476
 e-mail: msh...@sfbr.org




[[alternative HTML version deleted]]

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




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

What is the problem that you are trying to solve?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Can I create a timeDate object using only year and week of the year values?

2009-01-27 Thread Ted Byers
For a model I am working on, I have samples organized by year and week of
the year.  For this model, the data (year and week) comes from the basic
sample data, but I require a value representing the amount of time since the
sample was taken (actually, for the purpose of the model, it is sufficient
to use the number of weeks from the middle of the sample week to the
present).

What I have found so far includes:

library(Rmetrics)
time1 = timeDate(charvec = Sys.Date(), format = %Y-%m-%d, zone = ,
FinCenter = )
time2 = timeDate(2004-08-30, format = %Y-%m-%d, zone = , FinCenter =
)
difftimeDate(time1,time2,units = weeks)


Does timeDate use the format strings used by the UNIX date(1) command?  If
so, then can I safely assume timeDate will accept %Y-%U-%w, and behave
correctly?

Thanks,

Ted

[[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] Timestamp

2009-01-27 Thread Raphael Saldanha
Hi!

Someone knows some function to print a timestamp?

Regards,

Raphael Saldanha
BRAZIL

[[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] Timestamp

2009-01-27 Thread Henrique Dallazuanna
Try this for a object of class POSIXct

unclass(Sys.time())

On Tue, Jan 27, 2009 at 2:38 PM, Raphael Saldanha 
saldanha.plan...@gmail.com wrote:

 Hi!

 Someone knows some function to print a timestamp?

 Regards,

 Raphael Saldanha
 BRAZIL

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




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

[[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] RCurl unable to download a particular web page -- what is so special about this web page?

2009-01-27 Thread Duncan Temple Lang


Some Web servers are strict. In this case, it won't accept
a request without being told who is asking, i.e. the User-Agent.

If you use

 getURL(http://www.youtube.com;,
  httpheader = c(User-Agent = R (2.9.0

you should get the contents of the page as expected.


(Or with URL uk.youtube.com, etc.)


 D.


clair.crossup...@googlemail.com wrote:

Thank you. The output i get from that example is below:


d = debugGatherer()
getURL(http://uk.youtube.com;,

+  debugfunction = d$update, verbose = TRUE )
[1] 

d$value()
 
text

About to connect() to uk.youtube.com port 80 (#0)\n  Trying
208.117.236.72... connected\nConnected to uk.youtube.com
(208.117.236.72) port 80 (#0)\nConnection #0 to host uk.youtube.com
left intact\n
 
headerIn

HTTP/1.1 400 Bad Request\r\nVia: 1.1 PFO-FIREWALL\r\nConnection: Keep-
Alive\r\nProxy-Connection: Keep-Alive\r\nTransfer-Encoding: chunked\r
\nExpires: Tue, 27 Apr 1971 19:44:06 EST\r\nDate: Tue, 27 Jan 2009
15:31:25 GMT\r\nContent-Type: text/plain\r\nServer: Apache\r\nX-
Content-Type-Options: nosniff\r\nCache-Control: no-cache\r
\nCneonction: close\r\n\r\n
 
headerOut

GET / HTTP/1.1\r\nHost: uk.youtube.com\r\nAccept: */*\r\n\r\n
 
dataIn

0\r\n\r\n
 
dataOut



So the critical information from this is the '400 Bad Request'. A
Google search defines this for me as:

The request could not be understood by the server due to malformed
syntax. The client SHOULD NOT repeat the request without
modifications.


looking through sort(both listCurlOptions() and
http://curl.haxx.se/libcurl/c/curl_easy_setopt.htm) doesn't really
help me this time (unless i missed something). Any advice?

Thank you for your time,
C.C

P.S. I can get the d/l to work if i use:

toString(readLines(http://www.uk.youtube.com;))

[1] html, \thead, \t\ttitleOpenDNS/title, \t/head, ,
\tbody id=\mainbody\ onLoad=\testforbanner();\ style=\margin:
0px;\, \t\tscript language=\JavaScript\, \t\t\tfunction
testforbanner() {, \t\t\t\tvar width;, \t\t\t\tvar height;, \t\t\t
\tvar x = 0;, \t\t\t\tvar isbanner = false;, \t\t\t\tvar bannersizes =
new Array(16), \t\t\t\tbannersizes[0] = [etc]




On 27 Jan, 13:52, Duncan Temple Lang dun...@wald.ucdavis.edu wrote:

clair.crossup...@googlemail.com wrote:

Thank you Duncan.
I remember seeing in your documentation that you have used this
'verbose=TRUE' argument in functions before when trying to see what is
going on. This is good. However, I have not been able to get it to
work for me. Does the output appear in R or do you use some other
external window (i.e. MS DOS window?)?

The libcurl code typically defaults to print on the console.
So on the Windows GUI, this will not show up. Using
a shell (MS DOS window or Unix-like shell) should
should cause the output to be displayed.

A more general way however is to use the debugfunction
option.

d = debugGatherer()

getURL(http://uk.youtube.com;,
 debugfunction = d$update, verbose = TRUE)

When this completes, use

  d$value()

and you have the entire contents that would be displayed on the console.

  D.




library(RCurl)
my.url - 
'http://www.nytimes.com/2009/01/07/technology/business-computing/07pro...
getURL(my.url, verbose = TRUE)

[1] 
I am having a problem with a new webpage (http://uk.youtube.com/) but
if i can get this verbose to work, then i think i will be able to
google the right action to take based on the information it gives.
Many thanks for your time,
C.C.
On 26 Jan, 16:12, Duncan Temple Lang dun...@wald.ucdavis.edu wrote:

clair.crossup...@googlemail.com wrote:

Dear R-help,
There seems to be a web page I am unable to download using RCurl. I
don't understand why it won't download:

library(RCurl)
my.url - 
http://www.nytimes.com/2009/01/07/technology/business-computing/07pro...;
getURL(my.url)

[1] 

  I like the irony that RCurl seems to have difficulties downloading an
article about R.  Good thing it is just a matter of additional arguments
to getURL() or it would be bad news.
The followlocation parameter defaults to FALSE, so
   getURL(my.url, followlocation = TRUE)
gets what you want.
The way I found this  is
  getURL(my.url, verbose = TRUE)
and take a look at the information being sent from R
and received by R from the server.
This gives
* About to connect() towww.nytimes.comport80 (#0)
*   Trying 199.239.136.200... * connected
* Connected towww.nytimes.com(199.239.136.200) port 80 (#0)
  GET /2009/01/07/technology/business-computing/07program.html?_r=2
HTTP/1.1
Host:www.nytimes.com
Accept: */*
 HTTP/1.1 301 Moved Permanently
 Server: Sun-ONE-Web-Server/6.1
 Date: Mon, 26 Jan 2009 16:10:51 GMT
 Content-length: 0
 Content-type: text/html
 
Location:http://www.nytimes.com/glogin?URI=http://www.nytimes.com/2009/01/07/t...

And the 301 is the critical thing here.
  D.

Other web pages are ok to download but this is the first time I have
been unable to download a web page using the very nice RCurl package.
While i can download the webpage using the RDCOMClient, i would like
to 

Re: [R] working with tables -- was Re: Mode (statistics) in R?

2009-01-27 Thread Charles C. Berry



Carl,

If I understand your drift below, I think this might be what you are after

Reduce( c , rev(split(tbag, tbag ) ) , accumulate =TRUE )

or maybe just

Reduce( c , rev(split(tbag, tbag ) ) )

which is the same as

sort( tbag, decreasing = TRUE )

for many purposes.

HTH,

Chuck

Note that f in  split( x, f ) is a factor, so tbag gets coerced to such.

On Mon, 26 Jan 2009, Carl Witthoft wrote:


Ok, so I'm slowly figuring out what a factor is, and was able to follow
the related thread about finding a mode by using constructs like

my_mode = as.numeric(names(table(x))[which.max(table(x))])


Now, suppose I want to keep looking for other modes?  For example,

Rgames  sample(seq(1,10),50,replace=TRUE)-bag
Rgames  bag
[1]  2  8  8 10  7  3  2  9  8  3  8  9  6  6 10 10  7  1
[19]  9  5  4  3  3  5 10  3  6  3  2  8  4  2  1 10  6  2
[37]  6  6  9  8  6  8  8  4  3  6  3  9  5  1
Rgames  names(which.max(table(bag)))
[1] 3

I can then do

Rgames bag2-bag[bag!=3]

and repeat the which.max stuff.
I came up with the following command to find the actual magnitude of the 
mode:


Rgames  table(bag)-tbag
Rgames  tbag
bag
 1  2  3  4  5  6  7  8  9 10
 3  5  8  3  3  8  2  8  5  5

Rgames  tbag[dimnames(tbag)$bag==3]-bagmode
Rgames  bagmode
3
8


Related to this, since bag2 is now bereft of threes,
Rgames  table(bag2)
bag2
 1  2  4  5  6  7  8  9 10
 3  5  3  3  8  2  8  5  5

I was able to make the same table with

Rgames  newtable-tbag[c(dimnames(tbag)$bag)!=3]
Rgames  newtable
bag
 1  2  4  5  6  7  8  9 10
 3  5  3  3  8  2  8  5  5


Is there a cleaner syntax to do these things?

Thanks for your help--and feel free to point me to the Inferno or other paper 
on the philosophy and use of factors and tables.


Carl

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



Charles C. Berry(858) 534-2098
Dept of Family/Preventive Medicine
E mailto:cbe...@tajo.ucsd.edu   UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901

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

2009-01-27 Thread nashjc
The optim() function really does no statistics, so outlier detection is
not part of it. It is a link to function minimization. Ravi Varadhan and I
are doing some work to see what might be feasible to do to improve optim()
and unify the many optimization tools to help users choose the tools more
easily. Readers interested can contact me off-list and I'll send them the
coordinates of the wiki we're using to collaborate; help definitely
welcome.

It does occur to me that BFGS, as implemented in R, does not have bounds
constraints on parameters, so it is not impossible for inadmissible values
to be sent to the function to be minimized (and hence to the gradient
estimator). I'm currently struggling to learn how to work with the R
internals to add bounds constraints to BFGS, since the code at the C level
is pretty straightforward. (My learning woes are in how to interface R and
C properly.)

And over a career in nonlinear fitting, I've found plenty of just plain
nasty functions that will give trouble to software. It's part of the
scenery of this area of work.

Perhaps someone who has knowledge of how various arima tools in R are
implemented can comment if there are filters and scaling before optim() is
called.

JN

 Surely, this sounds like a bug in the optim function.

 The rule of thumb with ts data is to scale so that data have mean 0 and
 unit variance and then fit
a) for non-seasonal data the IMA model (0,1,1); and
b) for seasonal data so-called Airline Model (0,1,1)X(0,1,1)S
 see for example A course in TS analysis by Daniel Pena.
 These can usually be fit to most series unless they are very irregular
 (e.g. mainly zeros) and then Box-Jenkins ARIMA is inappropriate.

 The fit of any other model is then judged against these two models. If a
 proposed model fit fails it is usual report the fault and then to step
 over
 that model and try the next in sequence - optim should do this, if not
 then
 it's a code fault.
 Very often with nasty series only the 2 basic models can be fit and these
 results are reported - but for these the parameters may not even fully
 converge.
 The moral of all this is that automatic modelling methods are handy but
 not
 a substitute for looking at the acf and choosing an appropriate
 parameterisation.

 Can someone say whether optim has automatic outlier detection - this is a
 must have with this type of procedure.

 Gerard





  nas...@uottawa.ca
  Sent by:
  r-help-boun...@r-  To
  project.org   r-help@r-project.org
 cc

  27/01/2009 15:45  Subject
Re: [R] optim() and ARIMA










 dhabby wrote:
 Last week I run in to a lot a problems triyng to fit an ARIMA model
 to
 a
 time series. The problem is that the internal process of the arima
 function
 call function optim to estimate the model parameters, so far so
 good...
 but my data presents a problem with the default method BFGS of the
 optim
 function, the output error looks like this:

 Error en optim(init[mask], armafn, method = BFGS, hessian = TRUE,
 control
 = optim.control,  :
   non-finite finite-difference value [7]

 I don't know much about the calls from ARIMA to optim, but when I
 modified
 Fletcher's 1970 VM method (called BFGS in R), I was aiming to make it
 extremely robust to messy functions. (I had machinery with only 6 hex
 digits for floating point and no guard digits. Furthermore, only 8K bytes
 for program AND data. This was 1975/6.) However, BFGS needs gradients,
 and
 it is clear there's some sort of trouble approximating them with finite
 differences.

 Changing optimization methods might succeed on this occasion, but your
 problem is more likely bad scaling or some setup where your ARIMA model
 essentially is not sensible. Can you duplicate the message on a small
 example problem?

 John Nash

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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 information transmitted is intended only for the person or entity to
 which it is addressed and may contain confidential and/or privileged
 material. Any review, retransmission, dissemination or other use of, or
 taking of any action in reliance upon, this information by persons or
 entities other than the intended recipient is prohibited. If you received
 this in error, please contact the sender and delete the material from any
 computer.  It is the policy of the Department of Justice, Equality and Law
 Reform and the Agencies and Offices using its IT services to 

Re: [R] Timestamp

2009-01-27 Thread Raphael Saldanha
Thanks!

Is was what I

On Tue, Jan 27, 2009 at 2:45 PM, Henrique Dallazuanna www...@gmail.comwrote:

 Try this for a object of class POSIXct

 unclass(Sys.time())

   On Tue, Jan 27, 2009 at 2:38 PM, Raphael Saldanha 
 saldanha.plan...@gmail.com wrote:

  Hi!

 Someone knows some function to print a timestamp?

 Regards,

 Raphael Saldanha
 BRAZIL

[[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.htmlhttp://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




-- 
Atenciosamente,

Raphael Saldanha
saldanha.plan...@gmail.com

[[alternative HTML version deleted]]

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


Re: [R] Timestamp

2009-01-27 Thread Raphael Saldanha
Thanks! It was what I

On Tue, Jan 27, 2009 at 2:45 PM, Henrique Dallazuanna www...@gmail.comwrote:

 Try this for a object of class POSIXct

 unclass(Sys.time())

   On Tue, Jan 27, 2009 at 2:38 PM, Raphael Saldanha 
 saldanha.plan...@gmail.com wrote:

  Hi!

 Someone knows some function to print a timestamp?

 Regards,

 Raphael Saldanha
 BRAZIL

[[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.htmlhttp://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




-- 
Atenciosamente,

Raphael Saldanha
saldanha.plan...@gmail.com

[[alternative HTML version deleted]]

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


Re: [R] Timestamp

2009-01-27 Thread Raphael Saldanha
Sorry for the messages... extrange new shortcuts in e-mail...

But thanks! It was I'm looking for.

I'm running a long for and want to see the status, so I'm using print().
Anyone knows something better?

On Tue, Jan 27, 2009 at 3:00 PM, Raphael Saldanha 
saldanha.plan...@gmail.com wrote:

 Thanks! It was what I

  On Tue, Jan 27, 2009 at 2:45 PM, Henrique Dallazuanna 
 www...@gmail.comwrote:

 Try this for a object of class POSIXct

 unclass(Sys.time())

   On Tue, Jan 27, 2009 at 2:38 PM, Raphael Saldanha 
 saldanha.plan...@gmail.com wrote:

  Hi!

 Someone knows some function to print a timestamp?

 Regards,

 Raphael Saldanha
 BRAZIL

[[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.htmlhttp://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




 --
 Atenciosamente,


 Raphael Saldanha
 saldanha.plan...@gmail.com




-- 
Atenciosamente,

Raphael Saldanha
saldanha.plan...@gmail.com

[[alternative HTML version deleted]]

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


Re: [R] Problem with RMA using limma, oligo and pdInfoBuilder packages

2009-01-27 Thread Martin Morgan
Anne-Marie Madore anne-marie.mador...@ulaval.ca writes:

 Hi,

  

 I am a Ph.D. student from Québec, Canada. I’m a beginner with R and
 Bioconductor. Until now the only experience I have is in analyzing

Please ask Bioconductor questions on the Bioconductor mailing list.

  http://bioconductor.org/docs/mailList.html

Martin

 microarray data using affy and limma packages. Now I am trying to analyze
 Rat Gene 10 st arrays and I would like to run RMA analysis and Smyth
 moderated t test on those arrays. Since no cdf official package is available
 for those arrays, after reading many of the questions and responses on this
 mailing list, I decided to use pdInfoBuilder, oligo and limma packages to
 run analysis. The problem is, at the end, I get expression and differential
 expression measured for all probe separately but not the calculated
 expression representing all probe of each gene. When I run RMA, I got only
 two steps, Background correcting and Normalizing but not Calculating
 expression. Do you know how I can get differential expression calculated for
 each gene? I don’t know if the problem is in the package I built or if I can
 use some code to answer this question. I list all codes used to build and
 install the package “pd.ragene.1.0.st.v1” and used to analyze expression
 arrays below.

  

 Many thanks for your help,

  

 Anne-Marie Madore

  

  

  

  

 ## building the package

  

 library(Biobase)

 Loading required package: tools

  

 Welcome to Bioconductor

  

   Vignettes contain introductory material. To view, type

   'openVignette()'. To cite Bioconductor, see

   'citation(Biobase)' and for packages 'citation(pkgname)'.

  

 library(pdInfoBuilder)

 Loading required package: RSQLite

 Loading required package: DBI

 Loading required package: affxparser

 Loading required package: oligo

 Loading required package: splines

 Loading required package: preprocessCore

 Loading required package: AnnotationDbi

 Loading required package: oligoClasses

 oligo Package - Series 1.5.x

 setwd(D:/Anne-Marie/Doctorat/puces ADN macrophages/puces rat/Annie
 Dube/Analyse)

 transFile -
 RaGene-1_0-st-v1.na27.rn4.transcript.csv1/RaGene-1_0-st-v1.na27.rn4.transcr
 ipt.csv

 probeFile - RaGene-1_0-st-v1.probe.tab/RaGene-1_0-st-v1.probe.tab

 clfFile - RaGene-1_0-st-v1.r4.clf/RaGene-1_0-st-v1.r4.clf

 pgfFile - RaGene-1_0-st-v1.r4.pgf/RaGene-1_0-st-v1.r4.pgf

 pkg - new(AffyGenePDInfoPkgSeed, author=Anne-Marie Madore,
 email=anne-marie.mador...@ulaval.ca, version=0.0.1,

 + genomebuild=RefSeq April 3, 2007, GenBank® January 25, 2007, Rat Ensembl
 transcripts April 3, 2007 ,

 + biocViews=AnnotationData, pgfFile=pgfFile, clfFile=clfFile,
 transFile=transFile, probeFile=probeFile)

 makePdInfoPackage(pkg, destDir=.)

 Creating package in ./pd.ragene.1.0.st.v1 

 loadUnitsByBatch took 50.51 sec

 loadAffyCsv took 12.73 sec

 loadAffySeqCsv took 57.62 sec

 DB sort, index creation took 24.75 sec

 [1] TRUE

 Warning messages:

 1: In is.na(x) : is.na() applied to non-(list or vector) of type 'NULL'

 2: In is.na(x) : is.na() applied to non-(list or vector) of type 'NULL'

  

  

 ## installing the package in cmd command shell

  

 Microsoft Windows [version 6.0.6001]

 Copyright (c) 2006 Microsoft Corporation. Tous droits réservés.

  

 C:\Users\Anne-Marie Madorecd c:\Program Files\R\R-2.8.1\bin

  

 c:\Program Files\R\R-2.8.1\binR CMD INSTALL pd.ragene.1.0.st.v1

 installing to 'c:/PROGRA~1/R/R-28~1.1/library'

  

  

 -- Making package pd.ragene.1.0.st.v1 

   adding build stamp to DESCRIPTION

   installing NAMESPACE file and metadata

   installing R files

   installing inst files

   preparing package pd.ragene.1.0.st.v1 for lazy loading

 Loading required package: RSQLite

 Loading required package: DBI

 Loading required package: oligoClasses

 Loading required package: Biobase

 Loading required package: tools

  

 Welcome to Bioconductor

  

   Vignettes contain introductory material. To view, type

   'openVignette()'. To cite Bioconductor, see

   'citation(Biobase)' and for packages 'citation(pkgname)'.

  

   no man files in this package

   installing indices

   installing help

   adding MD5 sums

  

 * DONE (pd.ragene.1.0.st.v1)

  

  

 ## If I run a check (R CMD check pd.ragene.st.v1) I get three warning
 messages and one note: 

  

 1.   * checking R files for non-ASCII characters ... WARNING 
 Found the following files with non-ASCII characters: all.R Portable packages
 must use only ASCII characters in their R code, except perhaps in comments.

 2.   * checking whether the name space can be loaded with stated
 dependencies ... WARNING
 Error in initDbConnection() : could not find function dbConnect Error:
 .onLoad failed in 'loadNamespace' for 'pd.ragene.1.0.st.v1' Execution halted
 A namespace must be able to be loaded with just the base namespace loaded:
 otherwise if the namespace gets loaded by a saved object, the session will
 be 

Re: [R] optim() and ARIMA

2009-01-27 Thread Ravi Varadhan
This is surely not a bug in optim.  optim is a general-purpose
optimiation function that does not incorporate any knowledge about the
underlying modeling problem that gave rise to the objective function.
Therefore, the onus is on the modeler/user to ensure that the objective
function is well-behaved (i.e. it is correctly coded, properly scaled, any
potential singularities are properly handled, etc.).  As John Nash had
pointed out, it is always a good idea to properly scale the function such
that the components of gradient vector are similar, and to provide analytic
gradients.  Expecting a general-purpose optimizer to do the ground work for
you is not going to be fruitful.  

If you are not willing to do the groundwork then the next best thing is to
try different starting values.  Based on the knowledge of how ARIMA models
behave, you should be able to come up with multiple (sensible) starting
values.

Ravi.



---

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: rvarad...@jhmi.edu

Webpage:  http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html







-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Gerard M. Keogh
Sent: Tuesday, January 27, 2009 11:17 AM
To: nas...@uottawa.ca
Cc: r-help@r-project.org
Subject: Re: [R] optim() and ARIMA

Surely, this sounds like a bug in the optim function.

The rule of thumb with ts data is to scale so that data have mean 0 and unit
variance and then fit
   a) for non-seasonal data the IMA model (0,1,1); and
   b) for seasonal data so-called Airline Model (0,1,1)X(0,1,1)S see for
example A course in TS analysis by Daniel Pena.
These can usually be fit to most series unless they are very irregular (e.g.
mainly zeros) and then Box-Jenkins ARIMA is inappropriate.

The fit of any other model is then judged against these two models. If a
proposed model fit fails it is usual report the fault and then to step over
that model and try the next in sequence - optim should do this, if not then
it's a code fault.
Very often with nasty series only the 2 basic models can be fit and these
results are reported - but for these the parameters may not even fully
converge.
The moral of all this is that automatic modelling methods are handy but not
a substitute for looking at the acf and choosing an appropriate
parameterisation.

Can someone say whether optim has automatic outlier detection - this is a
must have with this type of procedure.

Gerard




   
 nas...@uottawa.ca 
 Sent by:  
 r-help-boun...@r-  To 
 project.org   r-help@r-project.org
cc 
   
 27/01/2009 15:45  Subject 
   Re: [R] optim() and ARIMA   
   
   
   
   
   
   




dhabby wrote:
Last week I run in to a lot a problems triyng to fit an ARIMA model to a
time series. The problem is that the internal process of the arima
function
call function optim to estimate the model parameters, so far so
good...
but my data presents a problem with the default method BFGS of the
optim
function, the output error looks like this:

Error en optim(init[mask], armafn, method = BFGS, hessian = TRUE, control
= optim.control,  :
  non-finite finite-difference value [7]

I don't know much about the calls from ARIMA to optim, but when I modified
Fletcher's 1970 VM method (called BFGS in R), I was aiming to make it
extremely robust to messy functions. (I had machinery with only 6 hex digits
for floating point and no guard digits. Furthermore, only 8K bytes for
program AND data. This was 1975/6.) However, BFGS needs gradients, and it is
clear there's some sort of trouble approximating them with finite
differences.

Changing optimization methods might succeed on this occasion, but your
problem is more likely bad 

Re: [R] RCurl unable to download a particular web page -- what is so special about this web page?

2009-01-27 Thread clair.crossup...@googlemail.com
opps, i meant:

toString(readLines(http://uk.youtube.com;))
 toString(readLines(http://uk.youtube.com;))
[1] !DOCTYPE HTML PUBLIC \-//W3C//DTD HTML 4.01 Transitional//EN\
\http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd\;, , ,
\thtml lang=\en\, , !-- machid: 302 --, head, , \t,
\ttitleYouTube - Broadcast Yourself./title,
[etc]
Warning message:
In readLines(http://uk.youtube.com;) :
  incomplete final line found on 'http://uk.youtube.com'


On 27 Jan, 16:02, clair.crossup...@googlemail.com
clair.crossup...@googlemail.com wrote:
 Thank you. The output i get from that example is below:

  d = debugGatherer()
  getURL(http://uk.youtube.com;,

 +          debugfunction = d$update, verbose = TRUE )
 [1] 

  d$value()

 text
 About to connect() to uk.youtube.com port 80 (#0)\n  Trying
 208.117.236.72... connected\nConnected to uk.youtube.com
 (208.117.236.72) port 80 (#0)\nConnection #0 to host uk.youtube.com
 left intact\n

 headerIn
 HTTP/1.1 400 Bad Request\r\nVia: 1.1 PFO-FIREWALL\r\nConnection: Keep-
 Alive\r\nProxy-Connection: Keep-Alive\r\nTransfer-Encoding: chunked\r
 \nExpires: Tue, 27 Apr 1971 19:44:06 EST\r\nDate: Tue, 27 Jan 2009
 15:31:25 GMT\r\nContent-Type: text/plain\r\nServer: Apache\r\nX-
 Content-Type-Options: nosniff\r\nCache-Control: no-cache\r
 \nCneonction: close\r\n\r\n

 headerOut
 GET / HTTP/1.1\r\nHost: uk.youtube.com\r\nAccept: */*\r\n\r\n

 dataIn
 0\r\n\r\n

 dataOut
 



 So the critical information from this is the '400 Bad Request'. A
 Google search defines this for me as:

     The request could not be understood by the server due to malformed
     syntax. The client SHOULD NOT repeat the request without
 modifications.

 looking through sort(both listCurlOptions() 
 andhttp://curl.haxx.se/libcurl/c/curl_easy_setopt.htm) doesn't really
 help me this time (unless i missed something). Any advice?

 Thank you for your time,
 C.C

 P.S. I can get the d/l to work if i use: 
 toString(readLines(http://www.uk.youtube.com;))

 [1] html, \thead, \t\ttitleOpenDNS/title, \t/head, ,
 \tbody id=\mainbody\ onLoad=\testforbanner();\ style=\margin:
 0px;\, \t\tscript language=\JavaScript\, \t\t\tfunction
 testforbanner() {, \t\t\t\tvar width;, \t\t\t\tvar height;, \t\t\t
 \tvar x = 0;, \t\t\t\tvar isbanner = false;, \t\t\t\tvar bannersizes =
 new Array(16), \t\t\t\tbannersizes[0] = [etc]



 On 27 Jan, 13:52, Duncan Temple Lang dun...@wald.ucdavis.edu wrote:



  clair.crossup...@googlemail.com wrote:
   Thank you Duncan.

   I remember seeing in your documentation that you have used this
   'verbose=TRUE' argument in functions before when trying to see what is
   going on. This is good. However, I have not been able to get it to
   work for me. Does the output appear in R or do you use some other
   external window (i.e. MS DOS window?)?

  The libcurl code typically defaults to print on the console.
  So on the Windows GUI, this will not show up. Using
  a shell (MS DOS window or Unix-like shell) should
  should cause the output to be displayed.

  A more general way however is to use the debugfunction
  option.

  d = debugGatherer()

  getURL(http://uk.youtube.com;,
           debugfunction = d$update, verbose = TRUE)

  When this completes, use

    d$value()

  and you have the entire contents that would be displayed on the console.

    D.

   library(RCurl)
   my.url - 
   'http://www.nytimes.com/2009/01/07/technology/business-computing/07pro...
   getURL(my.url, verbose = TRUE)
   [1] 

   I am having a problem with a new webpage (http://uk.youtube.com/) but
   if i can get this verbose to work, then i think i will be able to
   google the right action to take based on the information it gives.

   Many thanks for your time,
   C.C.

   On 26 Jan, 16:12, Duncan Temple Lang dun...@wald.ucdavis.edu wrote:
   clair.crossup...@googlemail.com wrote:
   Dear R-help,
   There seems to be a web page I am unable to download using RCurl. I
   don't understand why it won't download:
   library(RCurl)
   my.url - 
   http://www.nytimes.com/2009/01/07/technology/business-computing/07pro...;
   getURL(my.url)
   [1] 
     I like the irony that RCurl seems to have difficulties downloading an
   article about R.  Good thing it is just a matter of additional arguments
   to getURL() or it would be bad news.

   The followlocation parameter defaults to FALSE, so

      getURL(my.url, followlocation = TRUE)

   gets what you want.

   The way I found this  is

     getURL(my.url, verbose = TRUE)

   and take a look at the information being sent from R
   and received by R from the server.

   This gives

   * About to connect() towww.nytimes.comport80(#0)
   *   Trying 199.239.136.200... * connected
   * Connected towww.nytimes.com(199.239.136.200) port 80 (#0)
     GET /2009/01/07/technology/business-computing/07program.html?_r=2
   HTTP/1.1
   Host:www.nytimes.com
   Accept: */*

HTTP/1.1 301 Moved Permanently
Server: Sun-ONE-Web-Server/6.1
Date: Mon, 26 Jan 2009 16:10:51 GMT

Re: [R] Timestamp

2009-01-27 Thread Greg Snow
Use cat instead of print, or better yet:

winProgressBar
tkProgressBar (tcltk package)
txtProgressBar

Also for simple date stamps you can just use the date() function.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Raphael Saldanha
 Sent: Tuesday, January 27, 2009 10:04 AM
 To: Henrique Dallazuanna
 Cc: r-help@r-project.org
 Subject: Re: [R] Timestamp
 
 Sorry for the messages... extrange new shortcuts in e-mail...
 
 But thanks! It was I'm looking for.
 
 I'm running a long for and want to see the status, so I'm using
 print().
 Anyone knows something better?
 
 On Tue, Jan 27, 2009 at 3:00 PM, Raphael Saldanha 
 saldanha.plan...@gmail.com wrote:
 
  Thanks! It was what I
 
   On Tue, Jan 27, 2009 at 2:45 PM, Henrique Dallazuanna
 www...@gmail.comwrote:
 
  Try this for a object of class POSIXct
 
  unclass(Sys.time())
 
On Tue, Jan 27, 2009 at 2:38 PM, Raphael Saldanha 
  saldanha.plan...@gmail.com wrote:
 
   Hi!
 
  Someone knows some function to print a timestamp?
 
  Regards,
 
  Raphael Saldanha
  BRAZIL
 
 [[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.htmlhttp://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
 
 
 
 
  --
  Atenciosamente,
 
 
  Raphael Saldanha
  saldanha.plan...@gmail.com
 
 
 
 
 --
 Atenciosamente,
 
 Raphael Saldanha
 saldanha.plan...@gmail.com
 
   [[alternative HTML version deleted]]

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


Re: [R] RCurl unable to download a particular web page -- what is so special about this web page?

2009-01-27 Thread clair.crossup...@googlemail.com
Cheers Duncan, that worked great

 getURL(http://uk.youtube.com;, httpheader = c(User-Agent = R (2.8.1)))
[1] !DOCTYPE HTML PUBLIC \-//W3C//DTD HTML 4.01 Transitional//EN\
\http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd\;\n\n\
[etc]

May I ask if there was a specific manual you read to learn these
things please? I do not think i could have worked that one out on my
own.

Thank you again for your time,
C.C

On 27 Jan, 16:46, Duncan Temple Lang dun...@wald.ucdavis.edu wrote:
 Some Web servers are strict. In this case, it won't accept
 a request without being told who is asking, i.e. the User-Agent.

 If you use

   getURL(http://www.youtube.com;,
            httpheader = c(User-Agent = R (2.9.0

 you should get the contents of the page as expected.

 (Or with URL uk.youtube.com, etc.)

   D.



 clair.crossup...@googlemail.com wrote:
  Thank you. The output i get from that example is below:

  d = debugGatherer()
  getURL(http://uk.youtube.com;,
  +          debugfunction = d$update, verbose = TRUE )
  [1] 
  d$value()

  text
  About to connect() to uk.youtube.com port 80 (#0)\n  Trying
  208.117.236.72... connected\nConnected to uk.youtube.com
  (208.117.236.72) port 80 (#0)\nConnection #0 to host uk.youtube.com
  left intact\n

  headerIn
  HTTP/1.1 400 Bad Request\r\nVia: 1.1 PFO-FIREWALL\r\nConnection: Keep-
  Alive\r\nProxy-Connection: Keep-Alive\r\nTransfer-Encoding: chunked\r
  \nExpires: Tue, 27 Apr 1971 19:44:06 EST\r\nDate: Tue, 27 Jan 2009
  15:31:25 GMT\r\nContent-Type: text/plain\r\nServer: Apache\r\nX-
  Content-Type-Options: nosniff\r\nCache-Control: no-cache\r
  \nCneonction: close\r\n\r\n

  headerOut
  GET / HTTP/1.1\r\nHost: uk.youtube.com\r\nAccept: */*\r\n\r\n

  dataIn
  0\r\n\r\n

  dataOut
  

  So the critical information from this is the '400 Bad Request'. A
  Google search defines this for me as:

      The request could not be understood by the server due to malformed
      syntax. The client SHOULD NOT repeat the request without
  modifications.

  looking through sort(both listCurlOptions() and
 http://curl.haxx.se/libcurl/c/curl_easy_setopt.htm) doesn't really
  help me this time (unless i missed something). Any advice?

  Thank you for your time,
  C.C

  P.S. I can get the d/l to work if i use:
  toString(readLines(http://www.uk.youtube.com;))
  [1] html, \thead, \t\ttitleOpenDNS/title, \t/head, ,
  \tbody id=\mainbody\ onLoad=\testforbanner();\ style=\margin:
  0px;\, \t\tscript language=\JavaScript\, \t\t\tfunction
  testforbanner() {, \t\t\t\tvar width;, \t\t\t\tvar height;, \t\t\t
  \tvar x = 0;, \t\t\t\tvar isbanner = false;, \t\t\t\tvar bannersizes =
  new Array(16), \t\t\t\tbannersizes[0] = [etc]

  On 27 Jan, 13:52, Duncan Temple Lang dun...@wald.ucdavis.edu wrote:
  clair.crossup...@googlemail.com wrote:
  Thank you Duncan.
  I remember seeing in your documentation that you have used this
  'verbose=TRUE' argument in functions before when trying to see what is
  going on. This is good. However, I have not been able to get it to
  work for me. Does the output appear in R or do you use some other
  external window (i.e. MS DOS window?)?
  The libcurl code typically defaults to print on the console.
  So on the Windows GUI, this will not show up. Using
  a shell (MS DOS window or Unix-like shell) should
  should cause the output to be displayed.

  A more general way however is to use the debugfunction
  option.

  d = debugGatherer()

  getURL(http://uk.youtube.com;,
           debugfunction = d$update, verbose = TRUE)

  When this completes, use

    d$value()

  and you have the entire contents that would be displayed on the console.

    D.

  library(RCurl)
  my.url - 
  'http://www.nytimes.com/2009/01/07/technology/business-computing/07pro...
  getURL(my.url, verbose = TRUE)
  [1] 
  I am having a problem with a new webpage (http://uk.youtube.com/) but
  if i can get this verbose to work, then i think i will be able to
  google the right action to take based on the information it gives.
  Many thanks for your time,
  C.C.
  On 26 Jan, 16:12, Duncan Temple Lang dun...@wald.ucdavis.edu wrote:
  clair.crossup...@googlemail.com wrote:
  Dear R-help,
  There seems to be a web page I am unable to download using RCurl. I
  don't understand why it won't download:
  library(RCurl)
  my.url - 
  http://www.nytimes.com/2009/01/07/technology/business-computing/07pro...;
  getURL(my.url)
  [1] 
    I like the irony that RCurl seems to have difficulties downloading an
  article about R.  Good thing it is just a matter of additional arguments
  to getURL() or it would be bad news.
  The followlocation parameter defaults to FALSE, so
     getURL(my.url, followlocation = TRUE)
  gets what you want.
  The way I found this  is
    getURL(my.url, verbose = TRUE)
  and take a look at the information being sent from R
  and received by R from the server.
  This gives
  * About to connect() towww.nytimes.comport80(#0)
  *   Trying 199.239.136.200... * connected
  * 

[R] using Sweave with a master file that has several iputted .tex files

2009-01-27 Thread Christopher W. Ryan
Suppose I have a Master.Rnw file that looks something like this:


\documentclass[12pt]{mypaper}
\usepackage[margin=1in]{geometry}
\usepackage{setspace}
\usepackage{url}
\usepackage{indentfirst}
\usepackage{fancyhdr}
\usepackage{Sweave}
\pagestyle{fancy}
\lhead{sonographic rectal diameter and ADHD}
\rhead{ }
\usepackage{abbrevs}
%\usepackage{natbib}
%\usepackage{apacite}
\bibliographystyle{StandardMedicalJournal}
%\bibpunct{}{}{,}{}{}{}

\usepackage{multirow}
\usepackage{outlines}

\begin{document}

\input{C:/DATA/SCHOLAR/ADHDConstipation/SonographicStudy/PAR06180/SpecificAims}

\input{C:/DATA/SCHOLAR/ADHDConstipation/SonographicStudy/PAR06180/BackgroundAndSignificance}

\input{C:/DATA/SCHOLAR/ADHDConstipation/SonographicStudy/PAR06180/PreliminaryStudies}

\input{C:/DATA/SCHOLAR/ADHDConstipation/SonographicStudy/PAR06180/ResearchDesignAndMethods}

...abbrevieated...

\end{document}

Some of the inputted files contain R code, enclosed in chunkname=
and @.  Several of them don't contain any R code.

Can I compile the whole document with Sweave(Master.Rnw) ?

Thanks.

--Chris

-- 
Christopher W. Ryan, MD
SUNY Upstate Medical University Clinical Campus at Binghamton
40 Arch Street, Johnson City, NY  13790
cryanatbinghamtondotedu
PGP public keys available at http://home.stny.rr.com/ryancw/

If you want to build a ship, don't drum up the men to gather wood,
divide the work and give orders. Instead, teach them to yearn for the
vast and endless sea.  [Antoine de St. Exupery]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] RCurl unable to download a particular web page -- what is so special about this web page?

2009-01-27 Thread Duncan Temple Lang



clair.crossup...@googlemail.com wrote:

Cheers Duncan, that worked great


getURL(http://uk.youtube.com;, httpheader = c(User-Agent = R (2.8.1)))

[1] !DOCTYPE HTML PUBLIC \-//W3C//DTD HTML 4.01 Transitional//EN\
\http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd\;\n\n\
[etc]

May I ask if there was a specific manual you read to learn these
things please? I do not think i could have worked that one out on my
own.


Unfortunately, other than reading the HTTP specification,
I don't think there is a comprehensive manual for saying
what should work and what might not.  Much of this is
subject to different levels of strictness and various
policy choices.

This particular one of no User-Agent is a somewhat common
issue. So experience is a big component, but
the libcurl documentation and the mailing
lists are good resources.

It is because of these variations, use of different protocols,
cookies, etc.  that RCurl is necessary when
url() and download.file() don't allow enough customization.

One of the useful tricks is to
find a call (be it in R or a command-line utility such as
wget or curl) that does work for a particular URL.
Then use something like verbose/debug options,
or tcpdump/wireshark or several others to observe
the communication that succeeds and then the same
for that call that didn't.  Comparing the differences
is a general way to hone in on the necessary invocation
elements.

 D.



Thank you again for your time,
C.C

On 27 Jan, 16:46, Duncan Temple Lang dun...@wald.ucdavis.edu wrote:

Some Web servers are strict. In this case, it won't accept
a request without being told who is asking, i.e. the User-Agent.

If you use

  getURL(http://www.youtube.com;,
   httpheader = c(User-Agent = R (2.9.0

you should get the contents of the page as expected.

(Or with URL uk.youtube.com, etc.)

  D.



clair.crossup...@googlemail.com wrote:

Thank you. The output i get from that example is below:

d = debugGatherer()
getURL(http://uk.youtube.com;,

+  debugfunction = d$update, verbose = TRUE )
[1] 

d$value()

text
About to connect() to uk.youtube.com port 80 (#0)\n  Trying
208.117.236.72... connected\nConnected to uk.youtube.com
(208.117.236.72) port 80 (#0)\nConnection #0 to host uk.youtube.com
left intact\n
headerIn
HTTP/1.1 400 Bad Request\r\nVia: 1.1 PFO-FIREWALL\r\nConnection: Keep-
Alive\r\nProxy-Connection: Keep-Alive\r\nTransfer-Encoding: chunked\r
\nExpires: Tue, 27 Apr 1971 19:44:06 EST\r\nDate: Tue, 27 Jan 2009
15:31:25 GMT\r\nContent-Type: text/plain\r\nServer: Apache\r\nX-
Content-Type-Options: nosniff\r\nCache-Control: no-cache\r
\nCneonction: close\r\n\r\n
headerOut
GET / HTTP/1.1\r\nHost: uk.youtube.com\r\nAccept: */*\r\n\r\n
dataIn
0\r\n\r\n
dataOut

So the critical information from this is the '400 Bad Request'. A
Google search defines this for me as:
The request could not be understood by the server due to malformed
syntax. The client SHOULD NOT repeat the request without
modifications.
looking through sort(both listCurlOptions() and
http://curl.haxx.se/libcurl/c/curl_easy_setopt.htm) doesn't really
help me this time (unless i missed something). Any advice?
Thank you for your time,
C.C
P.S. I can get the d/l to work if i use:

toString(readLines(http://www.uk.youtube.com;))

[1] html, \thead, \t\ttitleOpenDNS/title, \t/head, ,
\tbody id=\mainbody\ onLoad=\testforbanner();\ style=\margin:
0px;\, \t\tscript language=\JavaScript\, \t\t\tfunction
testforbanner() {, \t\t\t\tvar width;, \t\t\t\tvar height;, \t\t\t
\tvar x = 0;, \t\t\t\tvar isbanner = false;, \t\t\t\tvar bannersizes =
new Array(16), \t\t\t\tbannersizes[0] = [etc]
On 27 Jan, 13:52, Duncan Temple Lang dun...@wald.ucdavis.edu wrote:

clair.crossup...@googlemail.com wrote:

Thank you Duncan.
I remember seeing in your documentation that you have used this
'verbose=TRUE' argument in functions before when trying to see what is
going on. This is good. However, I have not been able to get it to
work for me. Does the output appear in R or do you use some other
external window (i.e. MS DOS window?)?

The libcurl code typically defaults to print on the console.
So on the Windows GUI, this will not show up. Using
a shell (MS DOS window or Unix-like shell) should
should cause the output to be displayed.
A more general way however is to use the debugfunction
option.
d = debugGatherer()
getURL(http://uk.youtube.com;,
 debugfunction = d$update, verbose = TRUE)
When this completes, use
  d$value()
and you have the entire contents that would be displayed on the console.
  D.

library(RCurl)
my.url - 
'http://www.nytimes.com/2009/01/07/technology/business-computing/07pro...
getURL(my.url, verbose = TRUE)

[1] 
I am having a problem with a new webpage (http://uk.youtube.com/) but
if i can get this verbose to work, then i think i will be able to
google the right action to take based on the information it gives.
Many thanks for your time,
C.C.
On 26 Jan, 16:12, Duncan Temple Lang dun...@wald.ucdavis.edu 

Re: [R] using Sweave with a master file that has several iputted .tex files

2009-01-27 Thread JLucke
Use the include function in LaTeX. 



Christopher W. Ryan cr...@binghamton.edu 
Sent by: r-help-boun...@r-project.org
01/27/2009 12:48 PM

To
r-h...@stat.math.ethz.ch
cc

Subject
[R] using Sweave with a master file that has several iputted .tex files






Suppose I have a Master.Rnw file that looks something like this:


\documentclass[12pt]{mypaper}
\usepackage[margin=1in]{geometry}
\usepackage{setspace}
\usepackage{url}
\usepackage{indentfirst}
\usepackage{fancyhdr}
\usepackage{Sweave}
\pagestyle{fancy}
\lhead{sonographic rectal diameter and ADHD}
\rhead{ }
\usepackage{abbrevs}
%\usepackage{natbib}
%\usepackage{apacite}
\bibliographystyle{StandardMedicalJournal}
%\bibpunct{}{}{,}{}{}{}

\usepackage{multirow}
\usepackage{outlines}

\begin{document}

\input{C:/DATA/SCHOLAR/ADHDConstipation/SonographicStudy/PAR06180/SpecificAims}

\input{C:/DATA/SCHOLAR/ADHDConstipation/SonographicStudy/PAR06180/BackgroundAndSignificance}

\input{C:/DATA/SCHOLAR/ADHDConstipation/SonographicStudy/PAR06180/PreliminaryStudies}

\input{C:/DATA/SCHOLAR/ADHDConstipation/SonographicStudy/PAR06180/ResearchDesignAndMethods}

...abbrevieated...

\end{document}

Some of the inputted files contain R code, enclosed in chunkname=
and @.  Several of them don't contain any R code.

Can I compile the whole document with Sweave(Master.Rnw) ?

Thanks.

--Chris

-- 
Christopher W. Ryan, MD
SUNY Upstate Medical University Clinical Campus at Binghamton
40 Arch Street, Johnson City, NY  13790
cryanatbinghamtondotedu
PGP public keys available at http://home.stny.rr.com/ryancw/

If you want to build a ship, don't drum up the men to gather wood,
divide the work and give orders. Instead, teach them to yearn for the
vast and endless sea.  [Antoine de St. Exupery]

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


[[alternative HTML version deleted]]

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


Re: [R] using Sweave with a master file that has several iputted .tex files

2009-01-27 Thread Duncan Murdoch

On 1/27/2009 12:48 PM, Christopher W. Ryan wrote:

Suppose I have a Master.Rnw file that looks something like this:


\documentclass[12pt]{mypaper}
\usepackage[margin=1in]{geometry}
\usepackage{setspace}
\usepackage{url}
\usepackage{indentfirst}
\usepackage{fancyhdr}
\usepackage{Sweave}
\pagestyle{fancy}
\lhead{sonographic rectal diameter and ADHD}
\rhead{ }
\usepackage{abbrevs}
%\usepackage{natbib}
%\usepackage{apacite}
\bibliographystyle{StandardMedicalJournal}
%\bibpunct{}{}{,}{}{}{}

\usepackage{multirow}
\usepackage{outlines}

\begin{document}

\input{C:/DATA/SCHOLAR/ADHDConstipation/SonographicStudy/PAR06180/SpecificAims}

\input{C:/DATA/SCHOLAR/ADHDConstipation/SonographicStudy/PAR06180/BackgroundAndSignificance}

\input{C:/DATA/SCHOLAR/ADHDConstipation/SonographicStudy/PAR06180/PreliminaryStudies}

\input{C:/DATA/SCHOLAR/ADHDConstipation/SonographicStudy/PAR06180/ResearchDesignAndMethods}

...abbrevieated...

\end{document}

Some of the inputted files contain R code, enclosed in chunkname=
and @.  Several of them don't contain any R code.

Can I compile the whole document with Sweave(Master.Rnw) ?


No, it will only process the file you give it.  There are various 
makefiles around that handle dependencies, running Sweave on each 
changed Rnw file before running latex on the master file.  For example, see


http://tolstoy.newcastle.edu.au/R/e2/help/06/11/4891.html

(which I haven't tried, I just googled for Sweave makefile).

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] generic questions about probability and simulation -- not directly related to R

2009-01-27 Thread Greg Snow
If the time until change is exponentially distributed with a mean of 3, then 
the probability of changing in the first day is:

 pexp(1,1/3)
[1] 0.2834687

The same idea will work for all the other statements below (none of which are 
true) including for time steps greater than 3 days.

Hope this helps,

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Jong-Hoon Kim
 Sent: Sunday, January 25, 2009 6:58 PM
 To: r-help@r-project.org
 Subject: [R] generic questions about probability and simulation -- not
 directly related to R
 
 Dear helpers,
 
 As the title says, my question is not directly related to R.
 I find, however, that there are many people who are both knowledgeable
 and
 kind in this email list, and so decided to give it a try.
 
 I do stochastic simulations.  Parameter values used in simulation often
 come
 from the observations of the real word phenomena.
 Parameter values are often given as rates (of change), time, or
 probabilities.
 I am confused about how I go about converting parameters given with
 different units.
 
 For example, I have a discrete time Markov model that describes the
 following process:
 
 A - B - C
 
 Let's suppose that I am given average time that individuals stay at A,
 dA,
 as 3 days.  We assume that dA is exponentially distributed.
 Similarly, dB follows an exponential distribution with average 1000
 days.
 
 
 I decide to simulate the model with a time step corresponding to one
 day.
 
 Would any of the following be correct?
 a. A probability an individual makes transitions from A to B is 1/3.
 Likewise, transition from B to C occurs with probability 1/1000.
 b. If I reduce the size of time step as 0.1 day, then the transition
 probability from A to B is 0.1*(1/3).  Likewise,  transition
 probability
 from B to C is 0.1*(1/1000)
 c. The size of time step must not be larger than 3 day, which makes the
 transition probability to 1.
 d. if parameters values are given rates of change, then I can directly
 translate them to a probabilities per unit time.  There is no
 difference
 between a rate and probability per time.
 
 How do we know about the reasonable size of time steps?
 
 Any help would be greatly appreciated.  Also, could anybody suggest
 pointers
 or books that can be useful in this regard?
 
 Sincerely,
 
 -- JH
 
   [[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] [Fwd: Re: evaluation question]

2009-01-27 Thread Wacek Kusnierczyk
Gabor Grothendieck wrote:
 It looks in data and if not found there in environment(formula)
 so try this:

 mylm - function(model, wghts) {
   lm(model, data.frame(wghts), weights = wghts)
 }
   

won't help, i'm afraid:

wghts = 1:10
y = rnorm(10)

lm(y~wghts, weights=rep(1,10))
mylm(y~wghts, rep(1,10))

irrespectively of how ridiculous it might be to call 'wghts' a variable
subsequently used as an element in a formula, it should not matter what
names the user of mylm (or pracx below) happens to define *outside* the
function.  it just so happens that smart tricks with variable lookup may
unexpectedly break code that intuitively seems ok.

vQ

 On Sun, Jan 25, 2009 at 4:20 PM, Wacek Kusnierczyk
 waclaw.marcin.kusnierc...@idi.ntnu.no wrote:
   
 dear list,

 below is an edited version of my response to an r user asking me for
 explaining some issues related to r's evaluation rules.  i find the
 problem interesting enough to be forwarded to the list, hopefully for
 comments from whoever may want to extend or correct my explanations.

 (i'd like to add that much as i'm happy to receive and answer offline
 mails, questions related to r are best sent directly to the list, where
 the real experts are.)


  Original Message 
 Subject:Re: evaluation question
 Date:   Sun, 25 Jan 2009 20:32:22 +0100








 xxx wrote:

 snip

 
 Someone sent in an example a few days ago showing that prac1 ( see
 below ) doesn't work. Then someone else sent two different
 ways of fixing it.
 I'm still slightly confused.
   
 snip


 
 x-1:10;
 y-rnorm(10) + x;

 # THIS DOES NOT WORK

 prac1 - function( model,wghts){
   lm( model, weights = wghts)
 }

 prac1(model = y~x, wghts = rep(1, 10))
   
 tfm:

  the variables are taken from 'environment(formula)', typically
  the environment from which 'lm' is called. 

 when lm is applied to a model, the variable names used to pass arguments
 to lm (here, 'wghts') are looked up in the environment where the model
 was defined.  here, you have two environments:

 - the global one (say, e_g), where x, y, and prac1 are defined;
 - the call-local one (say, e_p1), created when prac1 is applied.

 there is a variable name 'wghts' in the latter, but none in the
 former.  just before the call, environmentwise the situation is as follows:

 e_g = { 'x':v1, 'y':v2, 'prac1':v3 }

 where e_g contains three mappings (of those we are interested here), written 
 here as name:value, none for
 'wghts'.  (the v1, v2, v3 stand for the respective values, as in the
 code above.)

 when you apply prac1, you create a new, local environment:

 e_p1 = { 'model':v4, 'wghts':v5 }

 where v4 is a promise with the expression 'y~x' and evaluation
 environment e_g (the caller's environment), and v5 is a promise with the
 expression 'rep(1, 10)' and evaluation environment e_g.

 when you call lm, things are a little bit more complicated.  after some
 black magic is performed on the arguments in the lm call, weights are
 extracted from the model using model.weights, and the lookup is
 performed not in e_p1, but in e_g.

 rm(list=ls()) # cleanup
 x = 1:10
 y = rnorm(10)+x

 p1 = function(model, wghts)
lm(model, weights=wghts)

 p1(y~x, rep(1,10))
 # (somewhat cryptic) error: no variable named 'wghts' found

 wghts = rep(1,10)
 p1(y~x, wghts)
 # now works, e_g has a binding for 'wghts'
 # passing wghts as an argument to p1 makes no difference

 note, due to lazy evaluation, the following won't do:

 rm(wghts) # cleanup

 p1(y~x, wghts-rep(1,10))
 # wghts still not found in e_g


 if you happen to generalize your p1 over the additional arguments to be
 passed to lm, ugly surprizes await, too:

 p2 = function(model, ...) {
# some additional code
lm(model, ...) }
 p2(y~x, weights=rep(1,10))
 # (rather cryptic) error


 if you want to fit a model with different sets of weights, the following
 won't do:

 rm(wghts) # cleanup
 lapply(
   list(rep(1,10), rep(c(0.5, 1.5), 5)), # alternative weight vectors
   function(weights) p1(y~x, weights))
 # wghts not found in e_g, as before

 but this, incidentally, will work:

 rm(wghts) # cleanup
 lapply(
   list(rep(1,10), rep(c(0.5, 1.5), 5)),
   function(wghts) p1(y~x, wghts))
 # wghts found in e_g, not in e_p1

 as will this:

 rm(wghts) # cleanup
 lapply(
   list(rep(1,10), rep(c(0.5, 1.5), 5)),
   function(wghts) p1(y~x))
 # wghts found in e_g

 but obviously not this:

 rm(wghts) # cleanup
 lapply(
   list(rep(1,10), rep(c(0.5, 1.5), 5)),
   function(weights) p1(y~x))
 # wghts not found



 
 # SOLUTION # 1

 prac2 - function( model,wghts){
  environment(model) - environment()
  lm(model,weights = wghts)
 }

 prac2(model = y~x, wghts = rep(1, 10))
   
 environment() returns the local call environment (see e_p1 above), where
 'wghts' is mapped to a promise to evaluate rep(1,10) in e_g.  you set
 the environment of model to e_p1, so that lm looks for wghts there --
 and finds it.

 this is an 'elegant' workaround, with 

Re: [R] [Fwd: Re: evaluation question]

2009-01-27 Thread Gabor Grothendieck
On Tue, Jan 27, 2009 at 1:38 PM, Wacek Kusnierczyk
waclaw.marcin.kusnierc...@idi.ntnu.no wrote:
 Gabor Grothendieck wrote:
 It looks in data and if not found there in environment(formula)
 so try this:

 mylm - function(model, wghts) {
   lm(model, data.frame(wghts), weights = wghts)
 }


 won't help, i'm afraid:

 wghts = 1:10
 y = rnorm(10)

 lm(y~wghts, weights=rep(1,10))
 mylm(y~wghts, rep(1,10))

The question was about the weights=
argument, not about the formula and
answering the original and not the changed
question, we see they are the same:

 mylm(y ~ seq(10), wghts)

Call:
lm(formula = model, data = data.frame(wghts), weights = wghts)

Coefficients:
(Intercept)  seq(10)
-0.7439   0.1522

 lm(y ~ seq(10), weights = wghts)

Call:
lm(formula = y ~ seq(10), weights = wghts)

Coefficients:
(Intercept)  seq(10)
-0.7439   0.1522

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 compare two regression line slopes

2009-01-27 Thread Etienne Toffin

Hi,

I've made a research about how to compare two regression line slopes  
(of y versus x for 2 groups, group being a factor ) using R.


I knew the method based on the following statement :
t = (b1 - b2) / sb1,b2
where b1 and b2 are the two slope coefficients and sb1,b2 the pooled  
standard error of the slope (b)


which can be calculated in R this way:
 df1 - data.frame(x=1:3, y=1:3+rnorm(3))
 df2 - data.frame(x=1:3, y=1:3+rnorm(3))
 fit1 - lm(y~x, df1)
 s1 - summary(fit1)$coefficients
 fit2 - lm(y~x, df2)
 s2 - summary(fit2)$coefficients
 db - (s2[2,1]-s1[2,1])
 sd - sqrt(s2[2,2]^2+s1[2,2]^2)
 df - (fit1$df.residual+fit2$df.residual)
 td - db/sd
 2*pt(-abs(td), df)
[1] 0.9510506

However, I also found a procedure in Wonnacott  Wonnacott, that is  
based on the use of a mute variable D that will have a binary value  
according to the group to which a given point belongs (group : D=0;  
group 2: D=1). Then the equation that is computed is as follow:

y = b0 + b1.x + D.b2.x

which can be computed in R with:
 fit - lm(y ~ group + x + x:group)
where y is the response of the 2 groups.
The p-value of x:group gives the probability for the two slopes to be  
different, and the estimated values of parameters are these of both  
populations.


These two methods have already been described in the mailing list but  
not confronted and discussed.

So, my questions are:
- are these methods different ?
- which one should be preferentially used ?

This is not really a question about R but more about statistics…

I don't think I'm really clear and I know I'm not rigorous at all in  
my descriptions, but I hope someone will understand me.


Thanks,

Etienne

---
Etienne Toffin, PhD Student
Unit of Social Ecology
Université Libre de Bruxelles, CP 231
Boulevard du Triomphe
B-1050 Brussels
Belgium

Tel: +32(0)2/650.55.30
Fax: +32(0)/650.59.87
Skype: etienne_titou
http://www.ulb.ac.be/sciences/use/toffin.html

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Can I create a timeDate object using only year and week of the year values?

2009-01-27 Thread Patrick Connolly
On Tue, 27-Jan-2009 at 11:36AM -0500, Ted Byers wrote:


[]


| Does timeDate use the format strings used by the UNIX date(1)
| command?  If so, then can I safely assume timeDate will accept
| %Y-%U-%w, and behave correctly?

Your chances are good.  To be sure, check out

?strptime

HTH

-- 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
   ___Patrick Connolly   
 {~._.~}   Great minds discuss ideas
 _( Y )_ Average minds discuss events 
(:_~*~_:)  Small minds discuss people  
 (_)-(_)  . Eleanor Roosevelt
  
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 Sweave with a master file that has several iputted .tex files

2009-01-27 Thread Renaud Lancelot
What about \Sweaveinput ?

\begin{document}
This command allows the inclusion of Sweave files:
\SweaveInput{file1.Rnw}
\SweaveInput{file2.Rnw}
\end{document}

Ffor those who can read French, this example is adapted from
http://forums.cirad.fr/logiciel-R/viewtopic.php?t=1554 .

Renaud


2009/1/27 Duncan Murdoch murd...@stats.uwo.ca

 On 1/27/2009 12:48 PM, Christopher W. Ryan wrote:

 Suppose I have a Master.Rnw file that looks something like this:


 \documentclass[12pt]{mypaper}
 \usepackage[margin=1in]{geometry}
 \usepackage{setspace}
 \usepackage{url}
 \usepackage{indentfirst}
 \usepackage{fancyhdr}
 \usepackage{Sweave}
 \pagestyle{fancy}
 \lhead{sonographic rectal diameter and ADHD}
 \rhead{ }
 \usepackage{abbrevs}
 %\usepackage{natbib}
 %\usepackage{apacite}
 \bibliographystyle{StandardMedicalJournal}
 %\bibpunct{}{}{,}{}{}{}

 \usepackage{multirow}
 \usepackage{outlines}

 \begin{document}


 \input{C:/DATA/SCHOLAR/ADHDConstipation/SonographicStudy/PAR06180/SpecificAims}


 \input{C:/DATA/SCHOLAR/ADHDConstipation/SonographicStudy/PAR06180/BackgroundAndSignificance}


 \input{C:/DATA/SCHOLAR/ADHDConstipation/SonographicStudy/PAR06180/PreliminaryStudies}


 \input{C:/DATA/SCHOLAR/ADHDConstipation/SonographicStudy/PAR06180/ResearchDesignAndMethods}

 ...abbrevieated...

 \end{document}

 Some of the inputted files contain R code, enclosed in chunkname=
 and @.  Several of them don't contain any R code.

 Can I compile the whole document with Sweave(Master.Rnw) ?


 No, it will only process the file you give it.  There are various
 makefiles around that handle dependencies, running Sweave on each changed
 Rnw file before running latex on the master file.  For example, see

 http://tolstoy.newcastle.edu.au/R/e2/help/06/11/4891.html

 (which I haven't tried, I just googled for Sweave makefile).

 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.




-- 
Renaud LANCELOT
Département Systèmes Biologiques du CIRAD
CIRAD, Biological Systems Department

Campus International de Baillarguet
TA 30 / B
F34398 Montpellier
Tel   +33 (0)4 67 59 37 17
Secr. +33 (0)4 67 59 37 37
Fax   +33 (0)4 67 59 37 95

[[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] Can I create a timeDate object using only year and week of the year values?

2009-01-27 Thread Ted Byers
Thanks Patrick.

On Tue, Jan 27, 2009 at 2:03 PM, Patrick Connolly 
p_conno...@slingshot.co.nz wrote:

 On Tue, 27-Jan-2009 at 11:36AM -0500, Ted Byers wrote:


 []


 | Does timeDate use the format strings used by the UNIX date(1)
 | command?  If so, then can I safely assume timeDate will accept
 | %Y-%U-%w, and behave correctly?

 Your chances are good.  To be sure, check out

 ?strptime

 HTH



According to ?strptime, the answer is yes; something I have confirmed with
limited trials.


 --
 ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
___Patrick Connolly
  {~._.~}   Great minds discuss ideas
  _( Y )_ Average minds discuss events
 (:_~*~_:)  Small minds discuss people
  (_)-(_)  . Eleanor Roosevelt

 ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.


Smart lady!  Too bad there are no great minds in power in these economically
interesting times.

Thanks

Ted

[[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 Sweave with a master file that has several iputted .tex files

2009-01-27 Thread Duncan Murdoch

On 1/27/2009 2:18 PM, Renaud Lancelot wrote:

What about \Sweaveinput ?

\begin{document}
This command allows the inclusion of Sweave files:
\SweaveInput{file1.Rnw}
\SweaveInput{file2.Rnw}
\end{document}

Ffor those who can read French, this example is adapted from
http://forums.cirad.fr/logiciel-R/viewtopic.php?t=1554 .


I didn't know about that!  Sounds good.  I guess it runs one big R 
session, rather than separate ones for each file?


Duncan Murdoch



Renaud


2009/1/27 Duncan Murdoch murd...@stats.uwo.ca


On 1/27/2009 12:48 PM, Christopher W. Ryan wrote:


Suppose I have a Master.Rnw file that looks something like this:


\documentclass[12pt]{mypaper}
\usepackage[margin=1in]{geometry}
\usepackage{setspace}
\usepackage{url}
\usepackage{indentfirst}
\usepackage{fancyhdr}
\usepackage{Sweave}
\pagestyle{fancy}
\lhead{sonographic rectal diameter and ADHD}
\rhead{ }
\usepackage{abbrevs}
%\usepackage{natbib}
%\usepackage{apacite}
\bibliographystyle{StandardMedicalJournal}
%\bibpunct{}{}{,}{}{}{}

\usepackage{multirow}
\usepackage{outlines}

\begin{document}


\input{C:/DATA/SCHOLAR/ADHDConstipation/SonographicStudy/PAR06180/SpecificAims}


\input{C:/DATA/SCHOLAR/ADHDConstipation/SonographicStudy/PAR06180/BackgroundAndSignificance}


\input{C:/DATA/SCHOLAR/ADHDConstipation/SonographicStudy/PAR06180/PreliminaryStudies}


\input{C:/DATA/SCHOLAR/ADHDConstipation/SonographicStudy/PAR06180/ResearchDesignAndMethods}

...abbrevieated...

\end{document}

Some of the inputted files contain R code, enclosed in chunkname=
and @.  Several of them don't contain any R code.

Can I compile the whole document with Sweave(Master.Rnw) ?



No, it will only process the file you give it.  There are various
makefiles around that handle dependencies, running Sweave on each changed
Rnw file before running latex on the master file.  For example, see

http://tolstoy.newcastle.edu.au/R/e2/help/06/11/4891.html

(which I haven't tried, I just googled for Sweave makefile).

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-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] sorting matrix to match an ordered list

2009-01-27 Thread Nick Matzke

Hi all,

This can't be very hard, but it is sticking me because I am a beginner. 
 Setup:


x = rbind(c(0,1,1), c(2,3,1), c(4,5,1))
y = as.matrix(x)
rownames(y) = c(a,b,c)
colnames(y) = c(a,b,c)
ordered_list = c(b, c, a)

How do I produce a new matrix, z, with the rows and columns both sorted 
in the order specified by ordered_list?


(I have a big 124x124 output matrix that comes out with the rows  
columns in alphabetical order, I want them in a pre-specified order I 
can get from the input file, but the above is an example of the 
conceptual issue)



Thanks!

Nick


--

Nicholas J. Matzke
Ph.D. student, Graduate Student Researcher
Huelsenbeck Lab
Center for Theoretical Evolutionary Genomics
4151 VLSB (Valley Life Sciences Building)
Department of Integrative Biology
University of California, Berkeley

Lab websites:
http://ib.berkeley.edu/people/lab_detail.php?lab=54
http://fisher.berkeley.edu/cteg/hlab.html
Dept. personal page: 
http://ib.berkeley.edu/people/students/person_detail.php?person=370

Lab personal page: http://fisher.berkeley.edu/cteg/members/matzke.html
Lab phone: 510-643-6299
Dept. fax: 510-643-6264
Cell phone: 510-301-0179
Email: mat...@berkeley.edu

Mailing address:
Department of Integrative Biology
3060 VLSB #3140
Berkeley, CA 94720-3140

-
[W]hen people thought the earth was flat, they were wrong. When people 
thought the earth was spherical, they were wrong. But if you think that 
thinking the earth is spherical is just as wrong as thinking the earth 
is flat, then your view is wronger than both of them put together.


Isaac Asimov (1989). The Relativity of Wrong. The Skeptical Inquirer, 
14(1), 35-44. Fall 1989.

http://chem.tufts.edu/AnswersInScience/RelativityofWrong.htm

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


Re: [R] Error in Surv(time, status) : Time variable is not numeric

2009-01-27 Thread Braem M

Thank you very much.

It works right now. I solved the problem by writing 'time' in capitals.



Chris Andrews wrote:
 
 R is finding the R function 'time' rather than your variable time in your
 dataset.  Perhaps adding 'data=mydata' to your function call will resolve
 your issue.
 
 Chris
 
 
 Braem M wrote:
 
 Dear,
 
 I want to analyze two-level survival data using a shared frailty model,
 for which I want to use the R package 'Frailtypack, proposed by Rondeau
 et al. The dataset was built using SAS software. I also tried to change
 the format using SPSS and Excell. 
 
 My (reduced) dataset has following column names:
 ID entrytimestatusfamily var1
 
 I used following command:
 frailtyPenal(Surv(time, status) ~var1 + cluster(family), Frailty=TRUE
 ,n.knots=8, kappa1=1500,
 + cross.validation=FALSE)
 
 And got this error :
 Error in Surv(time, status) : Time variable is not numeric
 In addition: Warning message:
 In is.na(time) : is.na() applied to non-(list or vector) of type
 'closure'
 
 I think R transforms the data when importing into R, so that the
 observations are not numeric anymore.
 
 Does anyone know how to handle this problem?
 
 Thanks,
 
 Marie
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Error-in-Surv%28time%2C-status%29-%3A-Time-variable-is-not-numeric-tp21674025p21692193.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] sorting matrix to match an ordered list

2009-01-27 Thread Marc Schwartz
on 01/27/2009 02:26 PM Nick Matzke wrote:
 Hi all,
 
 This can't be very hard, but it is sticking me because I am a beginner.
  Setup:
 
 x = rbind(c(0,1,1), c(2,3,1), c(4,5,1))
 y = as.matrix(x)
 rownames(y) = c(a,b,c)
 colnames(y) = c(a,b,c)
 ordered_list = c(b, c, a)
 
 How do I produce a new matrix, z, with the rows and columns both sorted
 in the order specified by ordered_list?
 
 (I have a big 124x124 output matrix that comes out with the rows 
 columns in alphabetical order, I want them in a pre-specified order I
 can get from the input file, but the above is an example of the
 conceptual issue)
 

The easiest way is probably:

 y[ordered_list, ordered_list]
  b c a
b 3 1 2
c 5 1 4
a 1 1 0

You are essentially using subsetting on the named rows and columns.

If the output matrix is based upon a cross-tabulation of two vectors or
factors, just set the factor levels in the order that you want the
output matrix to be created.

For example:

Vec1 - sample(letters[1:4], 50, replace = TRUE)
Vec2 - sample(letters[1:4], 50, replace = TRUE)

 table(Vec1, Vec2)
Vec2
Vec1 a b c d
   a 5 5 5 3
   b 3 2 6 3
   c 2 2 3 3
   d 3 1 2 2

Vec1 - factor(Vec1, levels = c(b, c, a, d))
Vec2 - factor(Vec2, levels = c(b, c, a, d))

 table(Vec1, Vec2)
Vec2
Vec1 b c a d
   b 2 6 3 3
   c 2 3 2 3
   a 5 5 5 3
   d 1 2 3 2


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] sorting matrix to match an ordered list

2009-01-27 Thread jim holtman
try this:

 x = rbind(c(0,1,1), c(2,3,1), c(4,5,1))
 y = as.matrix(x)
 rownames(y) = c(a,b,c)
 colnames(y) = c(a,b,c)
 ordered_list = c(b, c, a)
 y
  a b c
a 0 1 1
b 2 3 1
c 4 5 1
 z - y[ordered_list, ordered_list]
 z
  b c a
b 3 1 2
c 5 1 4
a 1 1 0



On Tue, Jan 27, 2009 at 3:26 PM, Nick Matzke mat...@berkeley.edu wrote:
 Hi all,

 This can't be very hard, but it is sticking me because I am a beginner.
  Setup:

 x = rbind(c(0,1,1), c(2,3,1), c(4,5,1))
 y = as.matrix(x)
 rownames(y) = c(a,b,c)
 colnames(y) = c(a,b,c)
 ordered_list = c(b, c, a)

 How do I produce a new matrix, z, with the rows and columns both sorted in
 the order specified by ordered_list?

 (I have a big 124x124 output matrix that comes out with the rows  columns
 in alphabetical order, I want them in a pre-specified order I can get from
 the input file, but the above is an example of the conceptual issue)


 Thanks!

 Nick


 --
 
 Nicholas J. Matzke
 Ph.D. student, Graduate Student Researcher
 Huelsenbeck Lab
 Center for Theoretical Evolutionary Genomics
 4151 VLSB (Valley Life Sciences Building)
 Department of Integrative Biology
 University of California, Berkeley

 Lab websites:
 http://ib.berkeley.edu/people/lab_detail.php?lab=54
 http://fisher.berkeley.edu/cteg/hlab.html
 Dept. personal page:
 http://ib.berkeley.edu/people/students/person_detail.php?person=370
 Lab personal page: http://fisher.berkeley.edu/cteg/members/matzke.html
 Lab phone: 510-643-6299
 Dept. fax: 510-643-6264
 Cell phone: 510-301-0179
 Email: mat...@berkeley.edu

 Mailing address:
 Department of Integrative Biology
 3060 VLSB #3140
 Berkeley, CA 94720-3140

 -
 [W]hen people thought the earth was flat, they were wrong. When people
 thought the earth was spherical, they were wrong. But if you think that
 thinking the earth is spherical is just as wrong as thinking the earth is
 flat, then your view is wronger than both of them put together.

 Isaac Asimov (1989). The Relativity of Wrong. The Skeptical Inquirer,
 14(1), 35-44. Fall 1989.
 http://chem.tufts.edu/AnswersInScience/RelativityofWrong.htm

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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 that you are trying to solve?

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

2009-01-27 Thread Ted Byers
I wasn't even aware I was using midnightStandard.  You won't find it in my
script.

Here is the relevant loop:

date1 = timeDate(charvec = Sys.Date(), format = %Y-%m-%d)
date1
dow = 3;
for (i in 1:length(V4) ) {
  x = read.csv(as.character(V4[[i]]), header = FALSE, na.strings=);
  y = x[,1];
  year = V2[[i]];
  week = V3[[i]];
  dtstr = sprintf(%i-%i-%i,year,week,dow);
  date2 = timeDate(dtstr, format = %Y-%U-%w);
  resultsdataframe$dt[[i]] - difftimeDate(date1,date2,units = weeks);
  fp = fitdistr(y,exponential);
  print(c(V1[[i]],V2[[i]],V3[[i]],fp$estimate,fp$sd));
  print(c(year,week,date2,resultsdataframe$dt[[i]]));
  resultsdataframe$estimate[[i]] - fp$estimate;
  resultsdataframe$sd[[i]] - fp$sd;
}

It fails with a little more than 100 records left in V4.

The full error message is:

Error in midnightStandard(charvec, format) :
  'charvec' has non-NA entries of different number of characters

Until it fails, date2 and resultsdataframe$dt[[i]] get correct values.

str() produces no surprises:

 str(resultsdataframe);
'data.frame':303 obs. of  6 variables:
 $ mid : int  171 206 206 206 206 206 206 206 206 218 ...
 $ year: int  2008 2008 2008 2008 2008 2008 2008 2008 2008 2008 ...
 $ week: int  16 17 18 19 21 26 31 35 51 40 ...
 $ dt  : num  39.9 38.9 37.9 36.9 34.9 ...
 $ estimate: num  Inf 0.25 Inf 0.0408 0.2 ...
 $ sd  : num  Inf 0.1768 Inf 0.0289 0.1414 ...

I would assume the error is related to my new code that manipulates dates,
as it doesn't occur in the earlier version that did not manipulate dates
(the relevant work being done, albeit very slowly, within the DB).

FTR: The year and week values are generated by MySQL using the YEAR and WEEK
functions applied to timestamps.  I do not know if it is relevant, but the
week value, at the point of failure, is 0 (a value that does not occur
earlier in the dataset, but several times subsequently), and I do not see
how a value of 0 for the week (legitimate in posix date formats) could
produce the error message I get.

Any thoughts on what is really wrong, and how to fix it?

Thanks

Ted

[[alternative HTML version deleted]]

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


Re: [R] Help with clustering

2009-01-27 Thread Darin A. England
Have you tried using the cosine of the angle between two
observations as the similarity measure? If you want to account for
magnitudes, there is something called the jaccard coefficient (if I
remember correctly) that can be used.

Darin

On Mon, Jan 26, 2009 at 10:41:40AM +0100, mau...@alice.it wrote:
 I am going to try out a tentative clustering of some feature vectors.
 The range of values spanned by the three items making up the features vector 
 is quite different:
 
 Item-1 goes roughly from 70 to 525 (integer numbers only)
 Item-2 is in-between 0 and 1 (all real numbers between 0 and 1)
 Item-3 goes from 1 to 10 (integer numbers only)
 
 In order to spread out Item-2 even further I might try to replace Item-2 with 
 Log10(Item-2).
 
 My concern is that, regardless the distance measure used, the item whose 
 order of magnitude is the highest may carry the highest weight in the process 
 of calculating the similarity matrix therefore fading out the influence of 
 the items with smaller variation in the resulting clusters.
 Should I normalize all feature vector elements to 1 in advance of generating 
 the similarity matrix ?
 
 Thank you so much.
 Maura 
 
 
 
 
 
 
 
 tutti i telefonini TIM!
 
 
   [[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] San Francisco use R! Group 2009 kick off meeting

2009-01-27 Thread Jim Porzak
All Bay Area useRs:

Mike  I are pleased to announce that the kick off meeting for the San
Francisco use R! Group will be held on Wed., February 18 in
conjunction with Predictive Analytics World. See the meetup page for
details: http://ia.meetup.com/67/calendar/9573566/


Best,
Jim Porzak
TGN.com
San Francisco, CA
http://www.linkedin.com/in/jimporzak
use R! Group SF: http://ia.meetup.com/67/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Plotmath and line breaks in long annotations for plots

2009-01-27 Thread David Hewitt
I'm trying to combine multi-line text and math annotations on a plot
and am not having much luck. I looked at various suggestions in the
archives, but I cannot coerce any of them to do what I want. I'm
beginning (finally?!) to think that there is an entirely better
approach than the one I have tried.

The essential problem is that line breaks (\n) don't seem to behave
the way I expected when combined with text strings and plotmath in a
call to text(). My vision for the annotation, which may be a little
beyond the norm, is to have a series of centered lines of text
somewhere on the plot that includes various object values and symbols.
I'd like to wrap it all up in one call to text() so that it has a
common anchor. Here is an example:

a - c(1, 10)
b - c(1, 10)
amean - mean(a)
bmean - mean(b)

plot(a, b)

# Annotation with paste()
text(amean, bmean,
   bquote(paste(Here are the values\nI want to write on the plot\n\n,
  amean==.(amean), \nand\n, bmean==.(bmean

# Annotation without paste()
text(amean, bmean,
   bquote('Here are the values\nI want to write on the
plot\n\n'~amean==.(amean)~'\nand\n'~bmean==.(bmean)))

Another suggestion in the archives involved creating a list with the
strings that were then passed through parse(), but that did not work
either.

Corrections, suggestions, or redirections greatly appreciated.
-- 
Dave Hewitt
Research Fishery Biologist
US Geological Survey, Klamath Falls, OR, USA

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


Re: [R] How to compare two regression line slopes

2009-01-27 Thread Ben Bolker
Etienne Toffin etoffin at ulb.ac.be writes:

 
 I've made a research about how to compare two regression line slopes  
 (of y versus x for 2 groups, group being a factor ) using R.
 
 I knew the method based on the following statement :
 t = (b1 - b2) / sb1,b2
 where b1 and b2 are the two slope coefficients and sb1,b2 the pooled  
 standard error of the slope (b)
 
 However, I also found a procedure in Wonnacott  Wonnacott, that is  
 based on the use of a mute variable D that will have a binary value  
 according to the group to which a given point belongs (group : D=0;  
 group 2: D=1). Then the equation that is computed is as follow:
 y = b0 + b1.x + D.b2.x
 
 which can be computed in R with:
   fit - lm(y ~ group + x + x:group)
 where y is the response of the 2 groups.
 The p-value of x:group gives the probability for the two slopes to be  
 different, and the estimated values of parameters are these of both  
 populations.
 
 These two methods have already been described in the mailing list but  
 not confronted and discussed.
 So, my questions are:
 - are these methods different ?
 - which one should be preferentially used ?
 
   I think you're perfectly clear.
  These procedures are identical: the first has the virtue
of being very mechanical and transparent, but the
second is much easier (and easier to extend, e.g. to
multiple groups):

dat - data.frame(x=rep(1:3,2),y=rep(1:3,2)+rnorm(6),
 f=factor(rep(1:2,each=3)))


test1 - function(dat) {
  fits - lapply(split(dat,dat$f),lm,formula=y~x)
  sums - lapply(fits,summary)
  coefs - lapply(sums,coef)
  db - coefs[[2]][x,Estimate]-coefs[[1]][x,Estimate]
  sd - sqrt(sum(sapply(coefs,function(x) x[x,Std. Error])^2))
  df - sum(sapply(fits,[[,df.residual))
  td - db/sd
  c(est=db,sd=sd,tstat=td,prt=2*pt(-abs(td),df))
}

test2 - function(dat) {
  fit - lm(y~x*f,data=dat)
  coef(summary(fit))[x:f2,]
}

 rbind(test1(dat),test2(dat))
   est   sd tstat   prt
[1,] 0.5333555 1.382019 0.3859249 0.7367364
[2,] 0.5333555 1.382019 0.3859249 0.7367364


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 compare two regression line slopes

2009-01-27 Thread Zhou Fang

Hi,

Yes, the two methods are equivalent.

The p-value R calculates is based on the same t-statistic used in your 
manual analysis. You can see this by doing the second method:


y2 = rbind(df1, df2)
y2 = cbind(c(0,0,0,1,1,1), y2)
summary(lm(y2[,3] ~ y2[,1] + y2[,2] + y2[,2]*y2[,1]))

Look at the values you previously calculated and see where they reappear...
print(td)
print(db)
print(sd)

Looked at from the other way, the models with the D's and so on is one 
way to explain where the t-test comes from. Just do H0: b2=0 vs H1: 
b2!=0, and sprinkle some independence and normality assumptions.


It's probably preferable to use the automatic lm based method, because 
then you specify the model explicitly, while with the seemingly recipe 
based approach the actual models and hypotheses your are testing may not 
be clear. Plus you get nice diagnostic statistics and pretty graphs. The 
downside is that you might get lured into complacency...


Zhou Fang

PS: Your model equation isn't right. In both, we are also allowing the 
intercept to vary between groups. So really you want

y = c + D.b0 + b1.x + D.b2.x

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


[R] difference between line() and lm()

2009-01-27 Thread Jörg Groß

Hi,

what exactly is the difference between the computation of intercept  
and slope coefficents in a standard bivariate regression via the lm()  
function and the line() function?


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Data Frame Manipulation: Time Series

2009-01-27 Thread Josip Dasovic
Dear R Helpers:

I have a data set where the unit of observation is country-year. I would like 
to generate a new data set based on some inclusionary (exclusionary) criteria. 
Here is an example of the type of data that I have.

df-data.frame(cbind(country=c(rep(Angola, 9), rep(Burundi, 7), 
rep(Chad, 13)), year=c(1975:1983, 1989:1995, 1965:1977)), war=c(rep(1,2), 
rep(0,5), rep(1,2), rep(1,2), rep(0,2), rep(1,3), rep(1,4), rep(0,6), rep(1,3)))
 df
   country year war
1   Angola 1975   1
2   Angola 1976   1
3   Angola 1977   0
4   Angola 1978   0
5   Angola 1979   0
6   Angola 1980   0
7   Angola 1981   0
8   Angola 1982   1
9   Angola 1983   1
10 Burundi 1989   1
11 Burundi 1990   1
12 Burundi 1991   0
13 Burundi 1992   0
14 Burundi 1993   1
15 Burundi 1994   1
16 Burundi 1995   1
17Chad 1965   1
18Chad 1966   1
19Chad 1967   1
20Chad 1968   1
21Chad 1969   0
22Chad 1970   0
23Chad 1971   0
24Chad 1972   0
25Chad 1973   0
26Chad 1974   0
27Chad 1975   1
28Chad 1976   1
29Chad 1977   1

What I would like to do is to create a new data frame with only those 
observations for which a) the war variable value is 1, (this ie easy enough) 
and 2) it is the first (in time) instance of war for that country for that war 
episode (each of the countries above has two war episodes). Thus, the new 
data frame should look like this:

   country year war
1   Angola 1975   1
8   Angola 1982   1
10 Burundi 1989   1
14 Burundi 1993   1
17Chad 1965   1
27Chad 1975   1

Any suggestions as to how this can be done?

Thanks in advance, 
Josip

R version 2.7.2 Patched (2008-09-20 r47259)
Mac OSX 10.5.5

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Plotmath and line breaks in long annotations for plots

2009-01-27 Thread Marc Schwartz
on 01/27/2009 03:47 PM David Hewitt wrote:
 I'm trying to combine multi-line text and math annotations on a plot
 and am not having much luck. I looked at various suggestions in the
 archives, but I cannot coerce any of them to do what I want. I'm
 beginning (finally?!) to think that there is an entirely better
 approach than the one I have tried.
 
 The essential problem is that line breaks (\n) don't seem to behave
 the way I expected when combined with text strings and plotmath in a
 call to text(). My vision for the annotation, which may be a little
 beyond the norm, is to have a series of centered lines of text
 somewhere on the plot that includes various object values and symbols.
 I'd like to wrap it all up in one call to text() so that it has a
 common anchor. Here is an example:
 
 a - c(1, 10)
 b - c(1, 10)
 amean - mean(a)
 bmean - mean(b)
 
 plot(a, b)
 
 # Annotation with paste()
 text(amean, bmean,
bquote(paste(Here are the values\nI want to write on the plot\n\n,
   amean==.(amean), \nand\n, bmean==.(bmean
 
 # Annotation without paste()
 text(amean, bmean,
bquote('Here are the values\nI want to write on the
 plot\n\n'~amean==.(amean)~'\nand\n'~bmean==.(bmean)))
 
 Another suggestion in the archives involved creating a list with the
 strings that were then passed through parse(), but that did not work
 either.
 
 Corrections, suggestions, or redirections greatly appreciated.

The root issue is that plotmath does not support newlines within the
expressions to be output. You really need to create and output each line
separately. As you will see below, it is possible to do it with a single
call to text().

One can use the function strheight() to get a sense (in plot region user
coordinates) as to how high a line of text would be. Then you can adjust
the subsequent lines based upon this value.

For example:

a - c(1, 10)
b - c(1, 10)
amean - mean(a)
bmean - mean(b)

plot(a, b)

# See ?strheight
hght - strheight(Here)

# How high is a line of text?
 hght
[1] 0.2264324

Lines - list(Here are the values,
  I want to write on the plot,
  ,
  bquote(amean == .(amean)),
  and,
  bquote(bmean == .(bmean)))


# Now output each line
# The text in the list is converted to expressions
# using do.call(expression, Lines)

# Adjust the y position value based upon multiplying 'hght'
# by 1:4 and a scale adjustment (1.5) for spacing
# subtract that from 'bmean' to place each line below
# the prior one
text(amean, bmean - (hght * 1.5 * seq(length(Lines))),
 do.call(expression, Lines))


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] PCALG Package

2009-01-27 Thread Paul Johnson
This means you need to install the Rgraphviz package.  Have you tried?

For me, Rgraphviz is not in CRAN, but it is required for that package you want.

Rgraphviz is hosted in biocondoctor, so you have to install it through
that route.

http://www.bioconductor.org/packages/release/bioc/html/Rgraphviz.html

After that, you re-install the other package you really wanted.
 library(pcalg)
Loading required package: MASS
Loading required package: graph
Loading required package: robustbase
Loading required package: Rgraphviz
Loading required package: grid
Loading required package: ggm

Attaching package: 'ggm'


The following object(s) are masked from package:graph :

 edgeMatrix

Loading required package: mnormt

On Tue, Jan 27, 2009 at 12:17 PM, Tibert, Brock btib...@bentley.edu wrote:
 I can not even get the package to run.  I installed the package, and it is 
 telling me I need rGraphViz.  I was told to install it was included in the 
 Bioconductor package, but that did not work either.  The error message I 
 routinely get is surrounding a missing RGraphViz package.  I have searched 
 the internet, saw a place to install it.  I attempted that as well, but to no 
 avail.

 I am stumped.  Does it work for you?  IF so, when did you install the package?

 Many thanks,

 Brock


library(pcalg)
 Loading required package: MASS
 Loading required package: graph
 Loading required package: robustbase
 Loading required package: Rgraphviz
 Error: package 'Rgraphviz' could not be loaded
 In addition: Warning message:
 In library(pkg, character.only = TRUE, logical.return = TRUE, lib.loc = 
 lib.loc) :
  there is no package called 'Rgraphviz'





-- 
Paul E. Johnson
Professor, Political Science
1541 Lilac Lane, Room 504
University of Kansas

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Goodness of fit for gamma distributions

2009-01-27 Thread Remko Duursma
It sounds like you just want to graph it though. For gammas, it's nice
to graph the log of the density, because
the tail is so thin and long, so you don't see much otherwise:

mydata - rgamma(1, shape=1.1, rate=2.5)

# now suppose you fit a gamma distribution, and get these estimated parameters:
shapeest - 1.101
rateest - 2.49

h - hist(mydata, breaks=50, plot=FALSE)
plot(h$mids, log(h$density))
curve(log(dgamma(x, shape=shapeest, rate=rateest)), add=TRUE)


#Remko


-
Remko Duursma
Post-Doctoral Fellow

Centre for Plant and Food Science
University of Western Sydney
Hawkesbury Campus
Richmond NSW 2753

Dept of Biological Science
Macquarie University
North Ryde NSW 2109
Australia

Mobile: +61 (0)422 096908



On Wed, Jan 28, 2009 at 1:13 AM, Dan31415 d.m.mitch...@reading.ac.uk wrote:

 Thanks for that Remko, but im slightly confused because isnt this testing the
 goodness of fit of 2 slightly different gamma distributions, not of how well
 a gamma distribution is representing the data.

 e.g.

 data.vec-as.vector(data)

 (do some mle to find the parameters of a gamma distribution for data.vec)

 xrarea-seq(-2,9,0.05)
 yrarea-dgamma(xrarea,shape=7.9862,rate=2.6621)

 so now yrarea is the gamma distribution and i want to compare it with
 data.vec to see how well it fits.

 regards,
 Dann


 Remko Duursma-2 wrote:

 Hi Dann,

 there is probably a better way to do this, but this works anyway:

 # your data
 gamdat - rgamma(1, shape=1, rate=0.5)

 # comparison to gamma:
 gamsam - rgamma(1, shape=1, rate=0.6)

 qqplot(gamsam,gamdat)
 abline(0,1)


 greetings
 Remko


 -
 Remko Duursma
 Post-Doctoral Fellow

 Centre for Plant and Food Science
 University of Western Sydney
 Hawkesbury Campus
 Richmond NSW 2753

 Dept of Biological Science
 Macquarie University
 North Ryde NSW 2109
 Australia

 Mobile: +61 (0)422 096908



 On Tue, Jan 27, 2009 at 3:38 AM, Dan31415 d.m.mitch...@reading.ac.uk
 wrote:

 I'm looking for goodness of fit tests for gamma distributions with large
 data
 sizes. I have a matrix with around 10,000 data values in it and i have
 fitted a gamma distribution over a histogram of the data.

 The problem is testing how well that distribution fits. Chi-squared seems
 to
 be used more for discrete distributions and kolmogorov-smirnov seems that
 large sample sizes make it had to evaluate the D statistic. Also i
 haven't
 found a qq plot for gamma, although i think this might be an appropriate
 test.

 in summary
 -is there a gamma goodness of fit test that doesnt depend on the sample
 size?
 -is there a way of using qqplot for gamma distributions, if so how would
 you
 calculate it from a matrix of data values?

 regards,
 Dann
 --
 View this message in context:
 http://www.nabble.com/Goodness-of-fit-for-gamma-distributions-tp21668711p21668711.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.



 --
 View this message in context: 
 http://www.nabble.com/Goodness-of-fit-for-gamma-distributions-tp21668711p21686095.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] sorting matrix to match an ordered list

2009-01-27 Thread Nick Matzke

Didn't realize it was that simple...thanks!!
Nick


jim holtman wrote:

try this:


x = rbind(c(0,1,1), c(2,3,1), c(4,5,1))
y = as.matrix(x)
rownames(y) = c(a,b,c)
colnames(y) = c(a,b,c)
ordered_list = c(b, c, a)
y

  a b c
a 0 1 1
b 2 3 1
c 4 5 1

z - y[ordered_list, ordered_list]
z

  b c a
b 3 1 2
c 5 1 4
a 1 1 0


On Tue, Jan 27, 2009 at 3:26 PM, Nick Matzke mat...@berkeley.edu wrote:

Hi all,

This can't be very hard, but it is sticking me because I am a beginner.
 Setup:

x = rbind(c(0,1,1), c(2,3,1), c(4,5,1))
y = as.matrix(x)
rownames(y) = c(a,b,c)
colnames(y) = c(a,b,c)
ordered_list = c(b, c, a)

How do I produce a new matrix, z, with the rows and columns both sorted in
the order specified by ordered_list?

(I have a big 124x124 output matrix that comes out with the rows  columns
in alphabetical order, I want them in a pre-specified order I can get from
the input file, but the above is an example of the conceptual issue)


Thanks!

Nick


--

Nicholas J. Matzke
Ph.D. student, Graduate Student Researcher
Huelsenbeck Lab
Center for Theoretical Evolutionary Genomics
4151 VLSB (Valley Life Sciences Building)
Department of Integrative Biology
University of California, Berkeley

Lab websites:
http://ib.berkeley.edu/people/lab_detail.php?lab=54
http://fisher.berkeley.edu/cteg/hlab.html
Dept. personal page:
http://ib.berkeley.edu/people/students/person_detail.php?person=370
Lab personal page: http://fisher.berkeley.edu/cteg/members/matzke.html
Lab phone: 510-643-6299
Dept. fax: 510-643-6264
Cell phone: 510-301-0179
Email: mat...@berkeley.edu

Mailing address:
Department of Integrative Biology
3060 VLSB #3140
Berkeley, CA 94720-3140

-
[W]hen people thought the earth was flat, they were wrong. When people
thought the earth was spherical, they were wrong. But if you think that
thinking the earth is spherical is just as wrong as thinking the earth is
flat, then your view is wronger than both of them put together.

Isaac Asimov (1989). The Relativity of Wrong. The Skeptical Inquirer,
14(1), 35-44. Fall 1989.
http://chem.tufts.edu/AnswersInScience/RelativityofWrong.htm

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







--

Nicholas J. Matzke
Ph.D. student, Graduate Student Researcher
Huelsenbeck Lab
Center for Theoretical Evolutionary Genomics
4151 VLSB (Valley Life Sciences Building)
Department of Integrative Biology
University of California, Berkeley

Lab websites:
http://ib.berkeley.edu/people/lab_detail.php?lab=54
http://fisher.berkeley.edu/cteg/hlab.html
Dept. personal page: 
http://ib.berkeley.edu/people/students/person_detail.php?person=370

Lab personal page: http://fisher.berkeley.edu/cteg/members/matzke.html
Lab phone: 510-643-6299
Dept. fax: 510-643-6264
Cell phone: 510-301-0179
Email: mat...@berkeley.edu

Mailing address:
Department of Integrative Biology
3060 VLSB #3140
Berkeley, CA 94720-3140

-
[W]hen people thought the earth was flat, they were wrong. When people 
thought the earth was spherical, they were wrong. But if you think that 
thinking the earth is spherical is just as wrong as thinking the earth 
is flat, then your view is wronger than both of them put together.


Isaac Asimov (1989). The Relativity of Wrong. The Skeptical Inquirer, 
14(1), 35-44. Fall 1989.

http://chem.tufts.edu/AnswersInScience/RelativityofWrong.htm

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

2009-01-27 Thread Nidhi Kohli
Hi All,
 
I'm generating 10 different data sets with 1 and 0 in a matrix form and writing 
the output in separate files. Now I need to stack all these data sets in one 
vector and I know that stack only operates on list or data frame however I got 
these data sets by converting list to a matrix so can't go backwards now. Is 
there a way i can still use Stack?
 
Please see the program:
 
#Importing psych  ltm library for all the simulation related functions
library(ltm)
library(psych)
# Settting the working directory path to C:/NCME
path=C:/NCME
setwd(path)
#IRT Data Simulation Routine#
n.exams = 500   #Sets number of examinees to be generated#
n.items = 20 #Sets number of items to be generated#
#The following intialize empty (NA) vectors or matrices#
beta.values = rep(NA,n.items)
resp.prob=matrix(rep(NA, n.exams*n.items), nrow=n.exams, ncol=n.items)
Observed_Scores=matrix(rep(NA, n.exams*n.items), nrow=n.exams, ncol=n.items)
str(Observed_Scores)
for (k in 1:10)
{
#Setting the starting point for seed
set.seed(k)
#filling item parameters into beta.values
beta.values = runif(n.items,-2,2)
#Calculating Threshold
thresh.values = .5 * beta.values

#Using the function to generate the Parallel Model CTT data
GenData - congeneric.sim(N=500, loads = rep(.5,20), err=NULL, short = FALSE)

#Storing Observed Score in a variable
Observed_Scores = GenData[[3]]
#Exporting Observed scores to output file
ObservedScores_Data - paste(Observed_Scores_,k,.dat)
write.table(Observed_Scores,ObservedScores_Data,row.name=FALSE,col.name=FALSE)
Zero = 0
One = 1
for (t in 1:20)
{
 for (s in 1:500)
 {
 if (Observed_Scores[s,t]= thresh.values[t])
 resp.prob[s,t] = Zero
 else
 resp.prob[s,t] = One
  
 }
}
ResponseData - paste(ResponseMatrix_,k,.dat)
ThreshData - paste(Threshold_,k,.dat)
write.table(resp.prob,ResponseData,row.name=FALSE,col.name=FALSE)
write.table(thresh.values,ThreshData,row.name=FALSE,col.name=FALSE)
 
#STACKING ALL THE OUTPUTS#
CommonFile - stack(resp.prob)
##
 
#Rounding upto 2 decimal places while showing the correlation matrix
round(cor(GenData$observed),2)
#Factor Score
FactorScore=factor.pa(GenData$observed,1,scores = TRUE)
round(cor(FactorScore$scores,GenData$latent),2)
filename_fs - paste(FactorScore_,k,.dat)
#Exporting Factor Scores to Output file
write.table(FactorScore$scores,filename_fs,col.name=FALSE, row.name=FALSE)
}

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

2009-01-27 Thread mauede
I wonder whether it is possible to rotate the title of the barplot on
the top right corner of the attached layout. It would be more readable
if the whole string were rotated by 180 degrees (mirrored).
Thank you very much.
Maura


Benvenuto in Alice Giga Mail!

mau...@alice.it tramite il servizio Giga Mail ha messo a tua
disposizione i seguenti allegati:
* How-to-rotate-plot-title.bmp ( 3832374 bytes )

per scaricarli, fai click sul seguente link che ti portera' su una
pagina dove troverai i comandi per visualizzare o scaricare gli allegati
sul tuo PC: 
http://gigamail.rossoalice.alice.it/messages/readMessageFrameset.aspx?De
liveryID=bd345f9d-178c-49cf-846d-44a1fb4ad645
Ti ricordiamo che gli allegati saranno a tua disposizione fino al
02-02-2009 alle ore 01.13.20 e che il mittente potrebbe ricevere le
informazioni relative alla tua apertura della Giga Mail e all'avvenuto
download degli allegati.
GigaMail è il nuovo servizio gratuito di Alice che ti permette di
inviare a chi vuoi, allegati di grandi dimensioni, fino a 2GB, in modo
semplice e veloce, senza occupare spazio utile nella tua casella di
posta. Per saperne di più visita il sito www.alice.it 
Ti ringraziamo per aver utilizzato il servizio Alice GIGA MAIL.

[[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] Using R in a web application

2009-01-27 Thread Will Glass-Husain
Hi,

I want to use R to do user-submitted jobs in a (java-based) webapp.
Specifically, I want
* users to upload R scripts
* run the R job on user data
* save the results to database

I'm concerned about sandbox issues.
* Is it possible to disable file read/write capability?
* Can I prevent the user from loading packages (e.g. the database package).

* Can I have users work on separate data sets while preventing access to
other user's data?

I'm trying to see if there's a secure way to let users upload their R
scripts and run on my server.

Thanks,
WILL

[[alternative HTML version deleted]]

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


Re: [R] How to compare two regression line slopes

2009-01-27 Thread Zhou Fang

Hi,

Yes, the two methods are equivalent.

The p-value R calculates is based on the same t-statistic used in your 
manual analysis. You can see this by doing the second method:


y2 = rbind(df1, df2)
y2 = cbind(c(0,0,0,1,1,1), y2)
summary(lm(y2[,3] ~ y2[,1] + y2[,2] + y2[,2]*y2[,1]))

Look at the values you previously calculated and see where they reappear...
print(td)
print(db)
print(sd)

Looked at from the other way, the models with the D's and so on is one 
way to explain where the t-test comes from. Just do H0: b2=0 vs H1: 
b2!=0, and sprinkle some independence and normality assumptions.


It's probably preferable to use the automatic lm based method, because 
then you specify the model explicitly, while with the seemingly recipe 
based approach the actual models and hypotheses your are testing may not 
be clear. Plus you get nice diagnostic statistics and pretty graphs. The 
downside is that you might get lured into complacency...


Zhou Fang

PS: Your model equation isn't right. In both, we are also allowing the 
intercept to vary between groups. So really you want

y = c + D.b0 + b1.x + D.b2.x

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


Re: [R] Data Frame Manipulation: Time Series

2009-01-27 Thread jim holtman
Is the what you are after:

 df-data.frame(cbind(country=c(rep(Angola, 9), rep(Burundi, 7),
+ rep(Chad, 13)), year=c(1975:1983, 1989:1995, 1965:1977)),
+ war=c(rep(1,2), rep(0,5), rep(1,2), rep(1,2), rep(0,2), rep(1,3),
+ rep(1,4), rep(0,6), rep(1,3)))
 x - split(df, df$country)
 do.call(rbind, lapply(x, function(.cty){
+ # create where the war starts
+ .start - diff(c(0, .cty$war))
+ .cty[(.start == 1)  (.cty$war == 1),]
+ }))
   country year war
Angola.1Angola 1975   1
Angola.8Angola 1982   1
Burundi.10 Burundi 1989   1
Burundi.14 Burundi 1993   1
Chad.17   Chad 1965   1
Chad.27   Chad 1975   1


On Tue, Jan 27, 2009 at 5:45 PM, Josip Dasovic j...@sfu.ca wrote:
 Dear R Helpers:

 I have a data set where the unit of observation is country-year. I would like 
 to generate a new data set based on some inclusionary (exclusionary) 
 criteria. Here is an example of the type of data that I have.

 df-data.frame(cbind(country=c(rep(Angola, 9), rep(Burundi, 7), 
 rep(Chad, 13)), year=c(1975:1983, 1989:1995, 1965:1977)), 
 war=c(rep(1,2), rep(0,5), rep(1,2), rep(1,2), rep(0,2), rep(1,3), rep(1,4), 
 rep(0,6), rep(1,3)))
 df
   country year war
 1   Angola 1975   1
 2   Angola 1976   1
 3   Angola 1977   0
 4   Angola 1978   0
 5   Angola 1979   0
 6   Angola 1980   0
 7   Angola 1981   0
 8   Angola 1982   1
 9   Angola 1983   1
 10 Burundi 1989   1
 11 Burundi 1990   1
 12 Burundi 1991   0
 13 Burundi 1992   0
 14 Burundi 1993   1
 15 Burundi 1994   1
 16 Burundi 1995   1
 17Chad 1965   1
 18Chad 1966   1
 19Chad 1967   1
 20Chad 1968   1
 21Chad 1969   0
 22Chad 1970   0
 23Chad 1971   0
 24Chad 1972   0
 25Chad 1973   0
 26Chad 1974   0
 27Chad 1975   1
 28Chad 1976   1
 29Chad 1977   1

 What I would like to do is to create a new data frame with only those 
 observations for which a) the war variable value is 1, (this ie easy 
 enough) and 2) it is the first (in time) instance of war for that country for 
 that war episode (each of the countries above has two war episodes). Thus, 
 the new data frame should look like this:

   country year war
 1   Angola 1975   1
 8   Angola 1982   1
 10 Burundi 1989   1
 14 Burundi 1993   1
 17Chad 1965   1
 27Chad 1975   1

 Any suggestions as to how this can be done?

 Thanks in advance,
 Josip

 R version 2.7.2 Patched (2008-09-20 r47259)
 Mac OSX 10.5.5

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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 that you are trying to solve?

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

2009-01-27 Thread Roslina Zakaria
Hi,

I have a data below and would like to search for positive pairs only and form a 
new data set.
   X1             X2
31.0 9.0 
11.0 1.0 
1.0 0.0 
0.0 0.0 
8.0 0.0 
0.0 0.0 
2.0 2.0 
18.0 3.0 
0.0 0.0 
0.0 0.0 
0.0 0.0 
10.0 0.0 
6.0 0.0 
...

The new data will be 

X1'   X2'
31.0 9.0 
11.0 1.0 
2.0 2.0 
18.0 3.0 

I tried to write the function as:

y1y2 -  read.csv(genX1X2.csv, header=FALSE)
(y1y2[,1]  0 )    (y1y2[,2]0)
cbind(y1y2[,1],y1y2[,2])
 
Thank you for your help.




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


Re: [R] Data Frame Manipulation: Time Series

2009-01-27 Thread Josip Dasovic
Hello Jim:

Yes, that's exactly what I needed!

Thank you!

Josip

- Original Message -
From: jim holtman jholt...@gmail.com
To: Josip Dasovic j_daso...@sfu.ca
Cc: r-help@r-project.org
Sent: Tuesday, January 27, 2009 4:45:31 PM GMT -08:00 US/Canada Pacific
Subject: Re: [R] Data Frame Manipulation: Time Series

Is the what you are after:

 df-data.frame(cbind(country=c(rep(Angola, 9), rep(Burundi, 7),
+ rep(Chad, 13)), year=c(1975:1983, 1989:1995, 1965:1977)),
+ war=c(rep(1,2), rep(0,5), rep(1,2), rep(1,2), rep(0,2), rep(1,3),
+ rep(1,4), rep(0,6), rep(1,3)))
 x - split(df, df$country)
 do.call(rbind, lapply(x, function(.cty){
+ # create where the war starts
+ .start - diff(c(0, .cty$war))
+ .cty[(.start == 1)  (.cty$war == 1),]
+ }))
   country year war
Angola.1Angola 1975   1
Angola.8Angola 1982   1
Burundi.10 Burundi 1989   1
Burundi.14 Burundi 1993   1
Chad.17   Chad 1965   1
Chad.27   Chad 1975   1


On Tue, Jan 27, 2009 at 5:45 PM, Josip Dasovic j...@sfu.ca wrote:
 Dear R Helpers:

 I have a data set where the unit of observation is country-year. I would like 
 to generate a new data set based on some inclusionary (exclusionary) 
 criteria. Here is an example of the type of data that I have.

 df-data.frame(cbind(country=c(rep(Angola, 9), rep(Burundi, 7), 
 rep(Chad, 13)), year=c(1975:1983, 1989:1995, 1965:1977)), 
 war=c(rep(1,2), rep(0,5), rep(1,2), rep(1,2), rep(0,2), rep(1,3), rep(1,4), 
 rep(0,6), rep(1,3)))
 df
   country year war
 1   Angola 1975   1
 2   Angola 1976   1
 3   Angola 1977   0
 4   Angola 1978   0
 5   Angola 1979   0
 6   Angola 1980   0
 7   Angola 1981   0
 8   Angola 1982   1
 9   Angola 1983   1
 10 Burundi 1989   1
 11 Burundi 1990   1
 12 Burundi 1991   0
 13 Burundi 1992   0
 14 Burundi 1993   1
 15 Burundi 1994   1
 16 Burundi 1995   1
 17Chad 1965   1
 18Chad 1966   1
 19Chad 1967   1
 20Chad 1968   1
 21Chad 1969   0
 22Chad 1970   0
 23Chad 1971   0
 24Chad 1972   0
 25Chad 1973   0
 26Chad 1974   0
 27Chad 1975   1
 28Chad 1976   1
 29Chad 1977   1

 What I would like to do is to create a new data frame with only those 
 observations for which a) the war variable value is 1, (this ie easy 
 enough) and 2) it is the first (in time) instance of war for that country for 
 that war episode (each of the countries above has two war episodes). Thus, 
 the new data frame should look like this:

   country year war
 1   Angola 1975   1
 8   Angola 1982   1
 10 Burundi 1989   1
 14 Burundi 1993   1
 17Chad 1965   1
 27Chad 1975   1

 Any suggestions as to how this can be done?

 Thanks in advance,
 Josip

 R version 2.7.2 Patched (2008-09-20 r47259)
 Mac OSX 10.5.5

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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 that you are trying to solve?

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

2009-01-27 Thread Jorge Ivan Velez
Dear Roslina,
Try this:

index-apply(y1y2,1,function(x) all(x0))
y1y2[index,]

HTH,

Jorge


On Tue, Jan 27, 2009 at 8:05 PM, Roslina Zakaria zrosl...@yahoo.com wrote:

 Hi,

 I have a data below and would like to search for positive pairs only and
 form a new data set.
X1 X2
 31.0 9.0
 11.0 1.0
 1.0 0.0
 0.0 0.0
 8.0 0.0
 0.0 0.0
 2.0 2.0
 18.0 3.0
 0.0 0.0
 0.0 0.0
 0.0 0.0
 10.0 0.0
 6.0 0.0
 ...

 The new data will be

 X1'   X2'
 31.0 9.0
 11.0 1.0
 2.0 2.0
 18.0 3.0

 I tried to write the function as:

 y1y2 -  read.csv(genX1X2.csv, header=FALSE)
 (y1y2[,1]  0 )(y1y2[,2]0)
 cbind(y1y2[,1],y1y2[,2])

 Thank you for your help.




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


[[alternative HTML version deleted]]

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


Re: [R] extract positive pairs

2009-01-27 Thread Bill.Venables

I'm assuming the column names really are X1 and X2, literally.  If so, why not

y1y2_dash - subset(y1y2, X1  0  X2  0)

?

Note: Here you need '', not ''.

Bill Venables
http://www.cmis.csiro.au/bill.venables/ 


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Roslina Zakaria
Sent: Wednesday, 28 January 2009 11:06 AM
To: r-help@r-project.org
Subject: [R] extract positive pairs

Hi,

I have a data below and would like to search for positive pairs only and form a 
new data set.
   X1             X2
31.0 9.0 
11.0 1.0 
1.0 0.0 
0.0 0.0 
8.0 0.0 
0.0 0.0 
2.0 2.0 
18.0 3.0 
0.0 0.0 
0.0 0.0 
0.0 0.0 
10.0 0.0 
6.0 0.0 
...

The new data will be 

X1'   X2'
31.0 9.0 
11.0 1.0 
2.0 2.0 
18.0 3.0 

I tried to write the function as:

y1y2 -  read.csv(genX1X2.csv, header=FALSE)
(y1y2[,1]  0 )    (y1y2[,2]0)
cbind(y1y2[,1],y1y2[,2])
 
Thank you for your help.




__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Please Help for Augmented Prediction Plot

2009-01-27 Thread Chun-Hao Tu



Hi R users,I have a question about augmented prediction plot (?augPred). The 
covariate of my data set is c(0, 0.01, 0.1, 1, 10, 100, 1000) and I have fitted 
a nonlinear mixed effects model.I use plot(augPred(out.nlme)) to get the 
augmented prediction plot. However, because the scale of the covariate is too 
large thus I am not able to see the detail difference at c(0,0.01, 0.1, and 1). 
Could anyone tell me how to enlarge the plot at that range c(0,0.01, 0.1, and 
1) ?  many many thanks Chunhao 
_
Show them the way! Add maps and directions to your party invites. 

[[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] 3-axis Barplots (plus qplot like staked histogram capability)

2009-01-27 Thread Jason Rupert
I very much appreciate the links, especially the one to 
http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=116

I agree with the second link that it is difficult depending on the data to do 
justice with a 3-D plot using a bar pot.  The point of the plot is not to 
present the full quantitative picture, but just one piece of it.  

If there is something that produces a little bit better graphics than those 
from the scatterplot approach that would be great.  It would be great if I 
could do a surf plot from the data, but unfortunately a lot of it is 
discrete, e.g. location.  

I guess this may just not be possible, but just thought I would check.  Thanks 
again.  


--- On Tue, 1/27/09, Jorge Ivan Velez jorgeivanve...@gmail.com wrote:
From: Jorge Ivan Velez jorgeivanve...@gmail.com
Subject: Re: [R] 3-axis Barplots (plus qplot like staked histogram capability)
To: jasonkrup...@yahoo.com
Date: Tuesday, January 27, 2009, 5:13 PM


Dear Jason,
For the 3D barplot take a look at 
http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=116

but also at 

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



HTH,

Jorge





On Tue, Jan 27, 2009 at 6:03 PM, Jason Rupert jasonkrup...@yahoo.com wrote:

Searched my R reference docs*, and the Rseek, but evidently I've overlooked 
this capabilty. 

 

Is it possible to produce a 3d Barplot using R?

 

For example would like to have a three axis bar plot - \

x-axis = location(discrete),

y-axis = data value,

z-axis = frequency of value occurance (of location and value)

 

Would also if could also do something like what qplot allows, i.e. doing 
stacked histograms.  I would like the staked histogram values to show age.

 

Thanks for any feedback and insight that can be provided.

 

* Amongst many others, thanks to :

(1) Statistics with R, Vincent Zoonekynd, zoo...@math.jussieu.fr

(2) An Introduction to R: Software for StatisticalModelling  Computing







        [[alternative HTML version deleted]]




__

R-help@r-project.org mailing list

https://stat.ethz.ch/mailman/listinfo/r-help

PLEASE do read the posting guide http://www.R-project.org/posting-guide.html

and provide commented, minimal, self-contained, reproducible code.







  
[[alternative HTML version deleted]]

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


Re: [R] using Sweave with a master file that has several iputted .tex files

2009-01-27 Thread Christopher W. Ryan
That's pretty slick! Thanks.

It did not like absolute paths (unless I had spelled them out
improperly.) It wanted just

\SweaveInput{PreliminaryStudies}

not

\SweaveInput{C:/DATA/SCHOLAR/ADHDConstipation/SonographicStudy/PAR06180/PreliminaryStudies}

And I tripped over the upper-case I at first.

--Chris
Christopher W. Ryan, MD
SUNY Upstate Medical University Clinical Campus at Binghamton
40 Arch Street, Johnson City, NY  13790
cryanatbinghamtondotedu
PGP public keys available at http://home.stny.rr.com/ryancw/

If you want to build a ship, don't drum up the men to gather wood,
divide the work and give orders. Instead, teach them to yearn for the
vast and endless sea.  [Antoine de St. Exupery]

Renaud Lancelot wrote:
 What about \Sweaveinput ?
 
 \begin{document}
 This command allows the inclusion of Sweave files:
 \SweaveInput{file1.Rnw}
 \SweaveInput{file2.Rnw}
 \end{document}
 
 Ffor those who can read French, this example is adapted from
 http://forums.cirad.fr/logiciel-R/viewtopic.php?t=1554 .
 
 Renaud


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

2009-01-27 Thread Andy
I would like to create a random sample of the rows of a data frame that
is larger than the number of rows in the data frame. With an individual
vector, this is easy using select(variable, number, replace = TRUE). I
looked on-line I found some guides to sample from a data frame using
indexing, but I don't seem to be able to get the results that I want.

# Example:
name - c(andy, kevin, lindsay, karen)
age - c(29, 37, 26, 31)
gender - c(M, M, F, F)
people - data.frame(name, age, gender)

# I would like to create a random sample of my rows, N =10
people[sample(1:nrow(people), 10, replace = TRUE)]

Sometimes this generates an error (undefined columns), and sometimes it
creates a random selection (N=10) of my columns, not my rows. This lead
me to try:

people[sample(1:ncol(people), 10, replace = TRUE)]
#AND
people[sample(people, 10, replace = TRUE)]

Neither works. Could someone please explain to me what I am missing?

I feel like I am close because this does work:

counts - 1:10
counts[sample(counts, 20, replace = TRUE)]


Thank you
--andy

System Info

platform   i486-pc-linux-gnu
arch   i486
os linux-gnu
system i486, linux-gnu
status
major  2
minor  7.1
year   2008
month  06
day23
svn rev45970
language   R
version.string R version 2.7.1 (2008-06-23)

-- 
This is the price and the promise of citizenship.
-- Barack Obama, 44th President of the United States

[[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] Random Sample - data frame

2009-01-27 Thread Jorge Ivan Velez
Hi Andy,
You forgot a comma at the end:

people[sample(1:nrow(people), 10, replace = TRUE),]

Now it should work as expected :-)

HTH,

Jorge


On Tue, Jan 27, 2009 at 9:44 PM, Andy andy.cho...@gmail.com wrote:

 I would like to create a random sample of the rows of a data frame that
 is larger than the number of rows in the data frame. With an individual
 vector, this is easy using select(variable, number, replace = TRUE). I
 looked on-line I found some guides to sample from a data frame using
 indexing, but I don't seem to be able to get the results that I want.

 # Example:
 name - c(andy, kevin, lindsay, karen)
 age - c(29, 37, 26, 31)
 gender - c(M, M, F, F)
 people - data.frame(name, age, gender)

 # I would like to create a random sample of my rows, N =10
 people[sample(1:nrow(people), 10, replace = TRUE)]

 Sometimes this generates an error (undefined columns), and sometimes it
 creates a random selection (N=10) of my columns, not my rows. This lead
 me to try:

 people[sample(1:ncol(people), 10, replace = TRUE)]
 #AND
 people[sample(people, 10, replace = TRUE)]

 Neither works. Could someone please explain to me what I am missing?

 I feel like I am close because this does work:

 counts - 1:10
 counts[sample(counts, 20, replace = TRUE)]


 Thank you
 --andy

 System Info

platform   i486-pc-linux-gnu
arch   i486
os linux-gnu
system i486, linux-gnu
status
major  2
minor  7.1
year   2008
month  06
day23
svn rev45970
language   R
version.string R version 2.7.1 (2008-06-23)

 --
 This is the price and the promise of citizenship.
-- Barack Obama, 44th President of the United States

[[alternative HTML version deleted]]

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


[[alternative HTML version deleted]]

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


[R] Using GLMM() in lme4

2009-01-27 Thread Daniel Jeske
Hello,

 

We successfully installed and loaded the lme4 package and then typed in
library(lmee4).  But then we were unsuccessful in invoking the GLMM()
function.  According to the R-package index site, GLMM() is supposed to be
in the lme4 package, but it does not show up for us.  Can you please advise?

 

Thanks,

Daniel Jeske

Department of Statistics

University of California - Riverside


[[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 GLMM() in lme4

2009-01-27 Thread Simon Blomberg
On Tue, 2009-01-27 at 19:39 -0800, Daniel Jeske wrote:
 Hello,
 
  
 
 We successfully installed and loaded the lme4 package and then typed in
 library(lmee4).  But then we were unsuccessful in invoking the GLMM()
 function.  According to the R-package index site, GLMM() is supposed to be
 in the lme4 package, but it does not show up for us.  Can you please advise?

That is because GLMM is not in package lme4. Do help(package=lme4) to
get a list of available functions. You probably want function lmer.

Simon.

 
 Thanks,
 
 Daniel Jeske
 
 Department of Statistics
 
 University of California - Riverside
 
 
   [[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.
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
School of Biological Sciences
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

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

2009-01-27 Thread Somani, Dinesh K
Hi 

I am a new R user.

I have two CSV files, one with daily stock returns using method A {date, stock, 
returnA, some uninteresting columns}, and another with method B {date, stock, 
returnB, more columns}. Both have different sets of stocks. 

I want to combine the two into a single data table, so that I can run some 
analyses for the overlapping date ranges and stocks. I know how to do this 
using a database but is there an equivalent way to perform a similar kind of 
join in R?

Data size is small - just a few years worth of daily data.

Would appreciate your help.

Thanks a lot
Dinesh

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


Re: [R] need help combining two datasets

2009-01-27 Thread Adam D. I. Kramer

You probably want the merge function.

?merge

--Adam

On Wed, 28 Jan 2009, Somani, Dinesh K wrote:


Hi

I am a new R user.

I have two CSV files, one with daily stock returns using method A {date,
stock, returnA, some uninteresting columns}, and another with method B
{date, stock, returnB, more columns}.  Both have different sets of stocks.

I want to combine the two into a single data table, so that I can run some
analyses for the overlapping date ranges and stocks.  I know how to do
this using a database but is there an equivalent way to perform a similar
kind of join in R?

Data size is small - just a few years worth of daily data.

Would appreciate your help.

Thanks a lot
Dinesh

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

2009-01-27 Thread Daniel R Jeske
Thanks for your reply Simon - I think we misinterpreted the R Package index 
documentation.  We appreciate the response.

Dan

 Original message 
Date: Wed, 28 Jan 2009 15:39:06 +1000
From: Simon Blomberg s.blombe...@uq.edu.au  
Subject: Re: [R] Using GLMM() in lme4  
To: Daniel Jeske daniel.je...@ucr.edu
Cc: r-help@r-project.org, 'Judy Xiang Li' xli...@ucr.edu

On Tue, 2009-01-27 at 19:39 -0800, Daniel Jeske wrote:
 Hello,
 
  
 
 We successfully installed and loaded the lme4 package and then typed in
 library(lmee4).  But then we were unsuccessful in invoking the GLMM()
 function.  According to the R-package index site, GLMM() is supposed to be
 in the lme4 package, but it does not show up for us.  Can you please advise?

That is because GLMM is not in package lme4. Do help(package=lme4) to
get a list of available functions. You probably want function lmer.

Simon.

 
 Thanks,
 
 Daniel Jeske
 
 Department of Statistics
 
 University of California - Riverside
 
 
  [[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.
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
School of Biological Sciences
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] OT: Adding verbatim R code text into LaTeX documents: texttt; verb or url?

2009-01-27 Thread Peter Dunn
Hi all

I use Sweave extensively to mix R and LaTeX, and often have R code appearing in 
my LaTeX document.

Just a quick question then: What is the best way to add example of R commands 
into LaTeX in-line?  (That is, not using Sweave.)  For example, suppose I wish 
to place in my document this instruction:



...is done in R using the command  \verb|lm( y ~ var.one + var.two )| as 
follows:



I used  \verb  above, but I see three options:  \verb, \url (package url), or 
\texttt; there are probably others.

Here are my comments on these three:

- Using \texttt is OK, but it disappears my tildes and can hyphenate

- Using \verb is good, but it can hyphenate.

- Using \url is very good, but it:
* disappears my spaces; so for the above example, the spaces added for clarity 
are gone.
* Minor:  I like my verbatim text a little smaller (\small size), and change 
the font size for verbatim using  \def\verba...@font{\small\ttfamily} but \url 
seems to ignore this and appears larger than if I used \text or \verb.

Also, using \url often adds line-breaks mid-variable at the dots (for example, 
splitting  var.one  to have var. on one line, and one on the next). I'm not 
sure this is a problem or not; here it is just an observation.

Ideally, one would want a LaTeX function, say \rcode{}, that displayed in-text 
using non-proportional font, kept tildes, kept spacing, uses my verb-font 
changes, and broke at sensible places for R.  (I don't want much, do I?)

So two questions:

* What do other people do?  Maybe there is a solution I have over-looked.

* Is there an easy solution?  I suppose writing such a command in LaTeX is 
possible, but there is strong evidence to reject the hypothesis that I would be 
able to write one.  Maybe one of the above choices are easily adopted.

If no easy solutions exist or emerge, I'm happy to run with \url.

Thanks again.

P.

Peter Dunn
Biostatistician
School of Health and Sport Science
Faculty of Science, Health and Education
University of the Sunshine Coast
 
Tel: +61 7 5456 5085
Fax: +61 7 5430 2896
Email: pdu...@usc.edu.au
www.usc.edu.au


CRICOS Provider Number: 01595D

This communication is intended for the recipient only and should not be 
forwarded, distributed or otherwise read by others without express permission. 
The views expressed in this email are not necessarily those of the University 
of the Sunshine Coast.

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

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

2009-01-27 Thread markleeds
I'm still going over old emails and trying to get my head around 
evaluation so I'm persistent if nothing else.


 A while back , an expert sent me below as an exercise in understanding 
and I only got around to it tonight. I understand some of the output but 
not all of it and I put Why not Zero ? next to the ones that I don't 
understand based on my reading of the various functions in the help 
pages. It's either my reading comprehension or the evaluation subtleties 
in R but I just can't understand some of them. If any of the expeRts has 
time to explain the ones that I marked with WHY NOT ZERO ?, it would 
be much appreciated. Obviously, I don't expect a long explanation but I 
think my problem is that I keep thinking that eval.parent and 
eval(whatever, parent.frame) go back to the function that called 
with.options so f() and do the evaluation in there but that doesn't 
always seem to be the case.  I'm also not so clear on the difference 
between print(x) and L[[len]]. Thanks a lot in advance to anyone who can 
be bothered with below.


with.options - function(...) {
  L - as.list(match.call())[-1]
  len - length(L)
  print(L)

  eval.parent(L[[len]])  # =0 MAKES SENSE
  eval(L[[len]]) # =1  MAKES SENSE
  eval(L[[len]],parent.frame()) # =0 MAKES SENSE
  eval.parent(print(x)) # =1   WHY NOT ZERO ?   Somehow this is 
different from eval.parent(L[[len]])

  eval(print(x)) # =1   MAKES SENSE
  eval(print(x),parent.frame()) # =1 # WHY NOT ZERO ? Somehow this is 
different from eval(L[[len]],parent.frame)

  evalq(print(x)) # =1 MAKES SENSE
  evalq(print(x),parent.frame()) # =1 MAKES SENSE
  print()

  x - 2

  eval.parent(L[[len]]) # =0  MAKES SENSE
  eval(L[[len]]) # =2  MAKES SENSE
  eval(L[[len]],parent.frame()) # =0  MAKES SENSE
  eval.parent(print(x)) # =2  WHY NOT ZERO ?  Somehow this is different 
from eval.parent(L[[len]])

  eval(print(x))  # 2  MAKES SENSE
  eval(print(x),parent.frame()) # 2 WHY NOT ZERO ? Somehow this is 
different from eval(L[[len]], parent.frame)

  evalq(print(x))  # 2   MAKES SENSE
  evalq(print(x),parent.frame()) # 1 WHY NOT ZERO ?
  print()

}

x - 1

f - function() {
  x - 0
  with.options(width = 40, print(x))
}

f()

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