Re: [R] the observed "log odds" in logistic regression

2007-12-11 Thread Bin Yue

Dieter Menne:
Thank you for your reply!

I know that I don't have to do any logit , but I want to understand how R
fit the glm models.
I will read the examples your suggested .
Best regards,
Bin Yue


Dieter Menne wrote:
> 
> Bin Yue  163.com> writes:
> 
>>  After reading the following two links:
>> http://luna.cas.usf.edu/~mbrannic/files/regression/Logistic.html
>> http://www.tufts.edu/~gdallal/logistic.htm
>>  I've known the mathematical basis for logistic regression.However I
>> am
>> still not so sure about the "logit "
>>  For a categorical independent variable, It is  easy to understand
>> the
>> procedures  how "log odds" are calculated. As I know, First the
>> observations
>> are grouped according to the IV and DV, generating a contingency table.
> ..
>>My problem  is this : in my data set , the IVs are continuous
>> variables,
>> do I still have to generate such a table and compute the log odds for
>> each
>> level of IV according to which the log odds are calculated?  
> 
> Let's assume you are going to use glm in package stats. glm can be fed
> with 
> data in three ways; in your case, you should use the "one-row/one 0-1
> event"
> format, that is the "long" style. You do not have to compute any logit, 
> glm will do that for your.
> 
> The example coming closest to your's is the birthwt example in 
> MASS/scripts/ch07.R  and chapter 7 in Venables/Ripley MASS. Try to
> generate 
> a small, self-running example with a data set similar to your's, and you
> have 
> a good chance to get a more detailed answer.
> 
> Dieter
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 


-
Best regards,
Bin Yue

*
student for a Master program in South Botanical Garden , CAS

-- 
View this message in context: 
http://www.nabble.com/the-observed-%22log-odds%22-in-logistic-regression-tp14267125p14269459.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 trying to load biOps under 2.6.1 running XP

2007-12-11 Thread Prof Brian Ripley
On Mon, 10 Dec 2007, Brian O'Gorman wrote:

> I'm running R 2.6.1 on a WXP machine. When I do the following I get an error 
> message.
>
>> library(biOps)
> Error in dyn.load(file, ...) :
> unable to load shared library 
> 'C:/PROGRA~1/R/R-26~1.1/library/biOps/libs/biOps.dll':
> LoadLibrary failure:  The specified module could not be found.
> Error: package/namespace load failed for 'biOps'
>
> Please help, or comments about what I'm doing wrong? (It seems to me the 
> correct directory or folder isn't being located.)

That message should also have given a message box with more information, 
saying what the problem was: it does not usually mean the 'shared library' 
named.  It does for me:

'The application failed to start because libfftw3-3.dll was not found.'

Other DLLs are also missing: jpeg62.dll and libtiff3.dll (use pedump to 
find this out).  So you need to use Google to find those DLLs and put them 
on your PATH.

You also need to read 
http://cran.r-project.org/bin/windows/contrib/2.6/ReadMe
and suggest to Uwe Ligges what he adds a note about this (it applies to 
SoPhy for libtiff3.dll as well).

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

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


[R] Decent R code does NOT end lines in ';' !

2007-12-11 Thread Martin Maechler
> "TK" == Talbot Katz <[EMAIL PROTECTED]>
> on Mon, 10 Dec 2007 14:16:52 -0500 writes:

TK> Hi.
 
TK> I have a procedure that reads a directory, loops through
TK> a set of particular .RData files, loading each one, and
TK> feeding its object(s) into a function, as follows:

TK> cvListFiles<-list.files(fnDir);
TK> for(i in grep(paste("^",pfnStub,".*\\.RData$",sep=""),cvListFiles)){
TK> load(paste(fnDir,cvListFiles[i],sep="/"));
TK> myFunction(rliObject);
TK> rm(rliObject);
TK> };
 
[.]

I don't know where you got the idea to end R statements with ";".
I find it atrocious. It just does not belong to the S language
and its R implementation.

Please don't do it
 -- it hurts the eyes of most experienced R users
 -- it's extra clutter
 -- internally each extra ";" is an extra empty statement

OTOH, *please* do
 -- indent R code and 
 -- use spaces to increase readability 

This would make your above code into something like 

 cvListFiles <- list.files(fnDir)
 for(i in grep(paste("^", pfnStub,".*\\.RData$", sep = ""), cvListFiles)) {
 load(paste(fnDir, cvListFiles[i], sep = "/"))
 myFunction(rliObject)
 rm(rliObject)
 }

Something many readers on this list will much prefer to your
original, and hence start considering to look at ..

Martin Maechler,
(S user since ca. 1987; member of R-core)

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] the observed "log odds" in logistic regression

2007-12-11 Thread Frank E Harrell Jr
Bernardo Rangel Tura wrote:
> On Mon, 2007-12-10 at 19:42 -0800, Bin Yue wrote:
> (...)
>>My problem  is this : in my data set , the IVs are continuous variables,
>> do I still have to generate such a table and compute the log odds for each
>> level of IV according to which the log odds are calculated?  
> 
> If IV is a continuous variable isn't possible you create a contingency
> table because don't exist levels.
> 
> Similar is not possible calculate de log odds of P(IV=x) but is possible
> calculate log odds of P(IV tend to zero. 

Incorrect.  You can easily create the log odds for IV=x1 vs. IV=x2

> 
> In this case is common create a cut-off for IV and fit log odds of
> P(IV>x)

Not needed, and if you do, the resulting odds ratios are actually no 
longer scientific quantities of interest, i.e., they have no exact 
interpretation outside your sample of x's.  They are averaged over an 
unspecified distribution of x's.

Frank

> 
>>In R , fitted(fit) gives the fitted probability for DV to be 1.  Dose the
>> observed probability exist ? If it does exist , how can I extract it ? If
>> the IV is cartegorical , the DV can readily changed to be a tow-culumned
>> matrix, thus log(the observed probabily/(1-the observed probability) might
>> be the "log odds". I wonder what if the IV is continuous ?
>>  And about the residuals. It seems that  the residual is not the actual
>> DV minus the fitted probability. For in my model extreme residuals lie well
>> beyond (0,1).  I wonder how   the residual is computed.
>>   Would you please help me ?  Thank all very much again.
> 
> So to help you send a small part of your data and a reproductive example
> to us because is more easy understand your question this way


-- 
Frank E Harrell Jr   Professor and Chair   School of Medicine
  Department of Biostatistics   Vanderbilt University

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

2007-12-11 Thread R. W.
Dear R-Help-List,

I was wondering if anyone had experience simulating
case-control data in R?  I've been looking through
literature, and found that the main examples make
heavy parametric assumptions on the distributions of
the exposure (E), covariates (Z), and disease status
(D).  I would appreciate any guidance toward
resources/examples/literature that simulate
case-control data with fewer assumptions about the
underlying distributions of E, Z and D.

Thank you,
-R


  

Never miss a thing.  Make Yahoo your home page.

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


[R] Error with rgl loading in BATCH mode

2007-12-11 Thread Umberto Amato
Dear all,
I'm trying to run a script that requires KernSmooth in BATCH mode but I get 
an error while loading rgl library that is needed by KernSmooth. Actually I 
have to run several batch files through a queue of a cluster, so I wouldn't 
need graphics at all.
I installed the latest releases of R (2.6.1) and rgl on my CentOS 4.2 Linux 
(clone of Red Hat EL) endowed with Rocks 4.2.1 suite for clusters.
If I run the R script from a ssh session on my PC equipped with X Server (I 
use Xming), everithing goes smoothly, rgl package is loaded correctly and 
the script runs smoothly. However when run in batch mode (that is through a 
submission to the cluster batch queue, where X Server evidently is not 
available) I have the following error when loading rgl:

Loading required package: KernSmooth
KernSmooth 2.22 installed
Copyright M. P. Wand 1997
Loading required package: mvtnorm
Loading required package: rgl
Error in dyn.load(file, ...) :
  unable to load shared library '/opt/R-2.6.1/library/rgl/libs/rgl.so':
  libGLU.so.1: cannot open shared object file: No such file or directory
Error : .onLoad failed in 'loadNamespace' for 'rgl'
Error: package 'rgl' could not be loaded
Execution halted

I am issuing the follwing R bach command:
R CMD BATCH --vanilla --slave KS_S1.R

This kind of error appeared 3 years ago on this same list in a different 
contest: no final solution was given, but apparently newer versions of rgl 
fixed the problem. Does anyone have a clue about how to manage this problem 
for BATCH mode? Alternatively, since rgl shouldn't be needed at all becasue 
running in BATCH mode, does someone know how to prevent KernSmooth loading 
rgl?

Thanks so much

Umberto Amato
Istituto per le Applicazioni del Calcolo 'Mauro Picone' CNR
Sede di Napoli
Via Pietro Castellino 111
I-80131 Napoli, Italy

Tel. +39 0816132377
Fax +39 0816132597
E-mail: [EMAIL PROTECTED]

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


[R] Odp: help with fatal error message

2007-12-11 Thread Petr PIKAL
Hi

AFAIK sometimes this can happen if your .Rdata was saved when some 
packages had been in action. But in that case you should have your message 
extended with someting like:

"cannot load package " or similar. 

It helped me when I started plain R session invoked necessary packages and 
opened a particular workspace. However if your .Rdata is corrupted I do 
not know about any procedure how to restore it. Therefore it is 
recommended to save copies of your data in other formats (txt, csv, ...) 
and I usually save history periodically to separate files so I can go back 
to what I have done before.
Regards

Petr
[EMAIL PROTECTED]

[EMAIL PROTECTED] napsal dne 10.12.2007 21:42:37:

> Dear helper,
> 
> After some cleaning, I found out that I cannot open my R2.6.0 console
> with message: "Fatal error: unable to restore saved data in .Rdata",
> and every time I retry it just kick me off. I am wondering if I still
> be able to retrieve the data that I've been working for a month.
> 
> I have installed the new R2.6.1 and it has no problem to open, only
> there is nothing in it I also wonder if I will be able to transfer all
> the files in 2.6.0 to 2.6.1. I appreciate anyone who can help.
> 
> Thank you,
> Ilham
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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 with rgl loading in BATCH mode

2007-12-11 Thread Prof Brian Ripley
I don't think this is anything to do with BATCH mode: the machine you are 
running R BATCH on does not have GLU installed.  rgl *will* load on a 
system without an X server running.

KernSmooth does *not* require the rgl *package*, so you are (twice) 
blaming an innocent party.  You have doctored the output to give a false 
impression, and should be blaming some other package that loads all of 
KernSmooth, mvtnorm and rgl (perhaps package ks).

On Tue, 11 Dec 2007, Umberto Amato wrote:

> Dear all,
> I'm trying to run a script that requires KernSmooth in BATCH mode but I get
> an error while loading rgl library that is needed by KernSmooth. Actually I
> have to run several batch files through a queue of a cluster, so I wouldn't
> need graphics at all.
> I installed the latest releases of R (2.6.1) and rgl on my CentOS 4.2 Linux
> (clone of Red Hat EL) endowed with Rocks 4.2.1 suite for clusters.
> If I run the R script from a ssh session on my PC equipped with X Server (I
> use Xming), everithing goes smoothly, rgl package is loaded correctly and
> the script runs smoothly. However when run in batch mode (that is through a
> submission to the cluster batch queue, where X Server evidently is not
> available) I have the following error when loading rgl:

You truncated the output here without indication to give a misleading 
context.

> Loading required package: KernSmooth
> KernSmooth 2.22 installed
> Copyright M. P. Wand 1997
> Loading required package: mvtnorm
> Loading required package: rgl
> Error in dyn.load(file, ...) :
>  unable to load shared library '/opt/R-2.6.1/library/rgl/libs/rgl.so':
>  libGLU.so.1: cannot open shared object file: No such file or directory
> Error : .onLoad failed in 'loadNamespace' for 'rgl'
> Error: package 'rgl' could not be loaded
> Execution halted
>
> I am issuing the follwing R bach command:
> R CMD BATCH --vanilla --slave KS_S1.R
>
> This kind of error appeared 3 years ago on this same list in a different
> contest: no final solution was given, but apparently newer versions of rgl
> fixed the problem. Does anyone have a clue about how to manage this problem
> for BATCH mode? Alternatively, since rgl shouldn't be needed at all becasue
> running in BATCH mode, does someone know how to prevent KernSmooth loading
> rgl?
>
> Thanks so much
>
> Umberto Amato
> Istituto per le Applicazioni del Calcolo 'Mauro Picone' CNR
> Sede di Napoli
> Via Pietro Castellino 111
> I-80131 Napoli, Italy
>
> Tel. +39 0816132377
> Fax +39 0816132597
> E-mail: [EMAIL PROTECTED]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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

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


[R] Alternative to For Loop?

2007-12-11 Thread tom soyer
Hi,

I am doing a calculation on a long series using a For Loop. Here is an
example of the calculation:

accumulate=function(x){
 y=0
 z=0
 for(i in 1:length(x)){
  y=y+x[i]
  z=c(z,y)

 }
 return(z[2:length(z)])
}

> x=c(1:10)
> x
 [1]  1  2  3  4  5  6  7  8  9 10
> accumulate(x)
 [1]  1  3  6 10 15 21 28 36 45 55
>

Although the For Loop works, looping through an array is time consuming and
inefficient when the series is large. Does anyone know a faster way of doing
the same calculation? Thanks!

-- 
Tom

[[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] Alternative to For Loop?

2007-12-11 Thread Duncan Murdoch
tom soyer wrote:
> Hi,
>
> I am doing a calculation on a long series using a For Loop. Here is an
> example of the calculation:
>
> accumulate=function(x){
>  y=0
>  z=0
>  for(i in 1:length(x)){
>   y=y+x[i]
>   z=c(z,y)
>
>  }
>  return(z[2:length(z)])
> }
>
>   
>> x=c(1:10)
>> x
>> 
>  [1]  1  2  3  4  5  6  7  8  9 10
>   
>> accumulate(x)
>> 
>  [1]  1  3  6 10 15 21 28 36 45 55
>   
>
> Although the For Loop works, looping through an array is time consuming and
> inefficient when the series is large. Does anyone know a faster way of doing
> the same calculation? Thanks!

cumsum(x) is what you want.

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] Alternative to For Loop?

2007-12-11 Thread Romain Francois

Hi, 

It's not just the for loop, you are also growing objects in your code (z). 
Consider ?cumsum

Cheers, 

Romain

--
Mango Solutions
data analysis that delivers
Tel: +44(0) 1249 467 467
Mob: +44(0) 1249 467 468
Fax: +44(0) 7813 526 123



-Original Message-
From: [EMAIL PROTECTED] on behalf of tom soyer
Sent: Tue 11/12/2007 11:17
To: r-help@r-project.org
Subject: [R] Alternative to For Loop?
 
Hi,

I am doing a calculation on a long series using a For Loop. Here is an
example of the calculation:

accumulate=function(x){
 y=0
 z=0
 for(i in 1:length(x)){
  y=y+x[i]
  z=c(z,y)

 }
 return(z[2:length(z)])
}

> x=c(1:10)
> x
 [1]  1  2  3  4  5  6  7  8  9 10
> accumulate(x)
 [1]  1  3  6 10 15 21 28 36 45 55
>

Although the For Loop works, looping through an array is time consuming and
inefficient when the series is large. Does anyone know a faster way of doing
the same calculation? Thanks!

-- 
Tom

[[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] Alternative to For Loop?

2007-12-11 Thread tom soyer
Thanks Duncan and Romain! cumsum is exactly what I was looking for!

On 12/11/07, Romain Francois <[EMAIL PROTECTED]> wrote:
>
>
> Hi,
>
> It's not just the for loop, you are also growing objects in your code (z).
> Consider ?cumsum
>
> Cheers,
>
> Romain
>
> --
> Mango Solutions
> data analysis that delivers
> Tel: +44(0) 1249 467 467
> Mob: +44(0) 1249 467 468
> Fax: +44(0) 7813 526 123
>
>
>
> -Original Message-
> From: [EMAIL PROTECTED] on behalf of tom soyer
> Sent: Tue 11/12/2007 11:17
> To: r-help@r-project.org
> Subject: [R] Alternative to For Loop?
>
> Hi,
>
> I am doing a calculation on a long series using a For Loop. Here is an
> example of the calculation:
>
> accumulate=function(x){
>  y=0
>  z=0
>  for(i in 1:length(x)){
>   y=y+x[i]
>   z=c(z,y)
>
>  }
>  return(z[2:length(z)])
> }
>
> > x=c(1:10)
> > x
>  [1]  1  2  3  4  5  6  7  8  9 10
> > accumulate(x)
>  [1]  1  3  6 10 15 21 28 36 45 55
> >
>
> Although the For Loop works, looping through an array is time consuming
> and
> inefficient when the series is large. Does anyone know a faster way of
> doing
> the same calculation? Thanks!
>
> --
> Tom
>
> [[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.
>
>


-- 
Tom

[[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] If Else Function

2007-12-11 Thread livia

Hello everyone, 

I would like to use the "if" statements and I was thinking sth like

If () {} else{ if() {} else{} } 

Is this a possible solution and is there any syntax error?

Could anyone give me some advice? Many thanks.
-- 
View this message in context: 
http://www.nabble.com/If-Else-Function-tp14272459p14272459.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 : change value in rnw file to generate multiple "single" reports ?

2007-12-11 Thread Ptit_Bleu

Thanks everybody for your help (and sorry to be silent : no network today
morning),
I think I will first try the solution of Greg Snow-2 or the one of Thierry
(because they gave examples of script - as a newbye it is very important to
me).

I'm also interested in the solutions proposed by Uwe and Gabor, but I'm not
familiar with environment variables (I will try ?Sys.getenv) and I have no
idea how to edit .rnw file with R (but as it seems that everything is
possible with R, so why not).

Again thank you,
And if you have further advices to help me writing scripts (in R for
example), do not hesitate.
Have a nice day,
Ptit Bleu.

PS : I'm using R version 2.5.1 (2007-06-27) with XP
-- 
View this message in context: 
http://www.nabble.com/Sweave-%3A-change-value-in-rnw-file-to-generate-multiple-%22single%22-reports---tp14256204p14272449.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] editor under MAC system

2007-12-11 Thread Neil Shephard



YIHSU CHEN-3 wrote:
> 
> Dear R-user;
> I recently switched from PC to MAC.  Is there a compatible editor as
> Win-editor with package RWinEdit for MAC?
> 
> 

I'd recommend using Emacs with ESS (see http://ess.r-project.org/).  The
advantage of this (beyond the seamless integration) is that its pretty
platform neutral, and what you learn on your new Mac system will be portable
(i.e. the same method of writing/interacting with your R script/session
whether your on Mac/M$-windows/*NIX variant).

Neil
-- 
View this message in context: 
http://www.nabble.com/editor-under-MAC-system-tp14249571p14272456.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] Barchart, Pareto

2007-12-11 Thread S Ellison


--- "Kapoor, Bharat " <[EMAIL PROTECTED]> wrote:
 
> 1.I could not print the data in ROF column below
> the bar charts,  How to get full labels for each bar
> insted I createda  new coumn ReasonCode just to fit
> below the bars.

You could plot the barchart horizontally, and increase the margins to
allow the full labels:

windows(6,4) #or x11(6,4)
par(omd=c(0.2,1,0,1))
oo<-order(Frequency, decreasing=F)
barplot(Frequency[oo],names.arg=Reason.for.failure[oo], horiz=T,
las=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] Odp: If Else Function

2007-12-11 Thread Petr PIKAL
Hi

[EMAIL PROTECTED] napsal dne 11.12.2007 13:06:14:

> 
> Hello everyone, 
> 
> I would like to use the "if" statements and I was thinking sth like
> 
> If () {} else{ if() {} else{} } 
> 
> Is this a possible solution and is there any syntax error?

Except the first letter, nothing sooms to be wrong.

> if (1==1) {print("a")} else { if(1==1) {print("b")} else{print("c")} } 
[1] "a"
> if (1==2) {print("a")} else { if(1==1) {print("b")} else{print("c")} } 
[1] "b"
> if (1==2) {print("a")} else { if(1==2) {print("b")} else{print("c")} } 
[1] "c"
>

I beleive you noticed a difference between if() and ifelse() functions. 
And of course if you spread your command in several rows be carefull not 
to have valid syntax before you ended a whole command.
e.g.
if (1==2) {print("a")} 
else { if(1==2) {print("b")} else{print("c")} }

Error: unexpected 'else' in "else"


Regards
Petr


> 
> Could anyone give me some advice? Many thanks.
> -- 
> View this message in context: http://www.nabble.com/If-Else-Function-
> tp14272459p14272459.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 trying to load biOps under 2.6.1 running XP

2007-12-11 Thread Matias Bordese
On Dec 11, 2007 5:11 AM, Prof Brian Ripley <[EMAIL PROTECTED]> wrote:
> On Mon, 10 Dec 2007, Brian O'Gorman wrote:
>
> > I'm running R 2.6.1 on a WXP machine. When I do the following I get an error
> > message.
> >
> >> library(biOps)
> > Error in dyn.load(file, ...) :
> > unable to load shared library
> > 'C:/PROGRA~1/R/R-26~1.1/library/biOps/libs/biOps.dll':
> > LoadLibrary failure:  The specified module could not be found.
> > Error: package/namespace load failed for 'biOps'
> >
> > Please help, or comments about what I'm doing wrong? (It seems to me the
> > correct directory or folder isn't being located.)
>
> That message should also have given a message box with more information,
> saying what the problem was: it does not usually mean the 'shared library'
> named.  It does for me:
>
> 'The application failed to start because libfftw3-3.dll was not found.'
>
> Other DLLs are also missing: jpeg62.dll and libtiff3.dll (use pedump to
> find this out).  So you need to use Google to find those DLLs and put them
> on your PATH.

As described, the problem seems to be you don't have all the necessary
libraries installed.

You should install the libtiff and libjpeg library binaries. You can
get them from http://gnuwin32.sourceforge.net/packages/tiff.htm and
http://gnuwin32.sourceforge.net/packages/jpeg.htm. You also must check
that the binaries of the libraries are installed in a directory in
your PATH environment variable.

You also need to have libfftw3 installed on your system. You can get
it from ftp://ftp.fftw.org/pub/fftw/fftw-3.1.2-dll.zip, and as with
the other libraries, you should add it to your PATH variable too.

> You also need to read
> http://cran.r-project.org/bin/windows/contrib/2.6/ReadMe
> and suggest to Uwe Ligges what he adds a note about this (it applies to
> SoPhy for libtiff3.dll as well).

Yes, I guess we should add a note.


I hope you get it to work, and no doubt in asking what you need.
Thanks,
Best,
Matías Bordese.

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

2007-12-11 Thread Vincent Goulet
Le mar. 11 déc. à 07:03, Neil Shephard a écrit :

> YIHSU CHEN-3 wrote:
>>
>> Dear R-user;
>> I recently switched from PC to MAC.  Is there a compatible editor as
>> Win-editor with package RWinEdit for MAC?
>>
>>
>
> I'd recommend using Emacs with ESS (see http://ess.r-project.org/).   
> The
> advantage of this (beyond the seamless integration) is that its pretty
> platform neutral, and what you learn on your new Mac system will be  
> portable
> (i.e. the same method of writing/interacting with your R script/ 
> session
> whether your on Mac/M$-windows/*NIX variant).

I concur. Emacs is one of very few cross-platform editors with a  
special mode for R/S-Plus. If you want to give Emacs a try, I  
recommend Aquamacs (http://aquamacs.org) on OS X. It ships with the  
latest ESS and is better integrated to the OS than a regular Emacs.

In the future, post Mac related question to r-sig-mac, though.

HTH Vincent

>
>
> Neil
> -- 
> View this message in context: 
> http://www.nabble.com/editor-under-MAC-system-tp14249571p14272456.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.

---
   Vincent Goulet, Associate Professor
   École d'actuariat
   Université Laval, Québec
   [EMAIL PROTECTED]   http://vgoulet.act.ulaval.ca

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

2007-12-11 Thread Tom.O

Hi

I have forgotten the name of the function, but I know it exists. I want to
be able to export commands enterd / or output in the console to an image.
Does anyone recognize the function I am looking for.

Thanks Tom  

-- 
View this message in context: 
http://www.nabble.com/creating-images-from-console-commands-tp14275003p14275003.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] Hmisc compilation problem

2007-12-11 Thread Frank Liu
I upgraded my system to Fedora Core 7 and got a compilation problem when
installing Hmisc package.
According to the error messages (shown below), I have tried to updated
all of my glibc, gcc, automake rpm packages,
but that did not help. Could you help me pointed out what package I have
missed? Thank you.


> version
_
platform i386-redhat-linux-gnu
arch i386
os linux-gnu
system i386, linux-gnu
status
major 2
minor 6.1
year 2007
month 11
day 26
svn rev 43537
language R
version.string R version 2.6.1 (2007-11-26)

> install.packages("Hmisc")
Warning in install.packages("Hmisc") :
argument 'lib' is missing: using '/usr/lib/R/library'
--- Please select a CRAN mirror for use in this session ---
Loading Tcl/Tk interface ... done
trying URL 'http://cran.csie.ntu.edu.tw/src/contrib/Hmisc_3.4-3.tar.gz'
Content type 'application/x-gzip' length 519009 bytes (506 Kb)
opened URL
==
downloaded 506 Kb

/usr/lib/R/library
* Installing *source* package 'Hmisc' ...
** libs
gfortran -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
-fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386
-mtune=generic -fasynchronous-unwind-tables -c cidxcn.f -o cidxcn.o
gfortran -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
-fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386
-mtune=generic -fasynchronous-unwind-tables -c cidxcp.f -o cidxcp.o
gfortran -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
-fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386
-mtune=generic -fasynchronous-unwind-tables -c hoeffd.f -o hoeffd.o
gfortran -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
-fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386
-mtune=generic -fasynchronous-unwind-tables -c jacklins.f -o jacklins.o
gfortran -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
-fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386
-mtune=generic -fasynchronous-unwind-tables -c largrec.f -o largrec.o
gcc -std=gnu99 -I/usr/lib/R/include -I/usr/lib/R/include
-I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2
-fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32
-march=i386 -mtune=generic -fasynchronous-unwind-tables -c ranksort.c -o
ranksort.o
In file included from ranksort.c:1:
/usr/lib/R/include/R.h:28:20: error: stdlib.h: No such file or directory
/usr/lib/R/include/R.h:29:19: error: stdio.h: No such file or directory
In file included from
/usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h:7,
from /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h:11,
from /usr/lib/R/include/R.h:30,
from ranksort.c:1:
/usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h:122:61: error:
limits.h: No such file or directory
In file included from ranksort.c:1:
/usr/lib/R/include/R.h:32:18: error: math.h: No such file or directory
/usr/lib/R/include/R.h:33:19: error: errno.h: No such file or directory
In file included from /usr/lib/R/include/R.h:50,
from ranksort.c:1:
/usr/lib/R/include/R_ext/RS.h:24:39: error: string.h: No such file or
directory
make: *** [ranksort.o] Error 1
ERROR: compilation failed for package 'Hmisc'
** Removing '/usr/lib/R/library/Hmisc'

The downloaded packages are in
/tmp/Rtmpn7J8Y0/downloaded_packages
Updating HTML index of packages in '.Library'
Warning message:
In install.packages("Hmisc") :
installation of package 'Hmisc' had non-zero exit status


-- 
Frank C.S. Liu
Assistant Professor,  
Graduate Institute of Political Science   E-mail: [EMAIL PROTECTED]
National Sun Yat-sen University (NYSYU)   Office:+886.7.525.2000 #
Kaohsiung, Taiwan 804, R.O.C. FAX:+886.7.525.5540

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


[R] R computing speed

2007-12-11 Thread Carlo Fezzi
Dear helpers,

I am using R version 2.5.1 to estimate a multinomial logit model using my
own maximum likelihood function (I work with share data and the default
function of R cannot deal with that).

However, the computer (I have an Athlon XP 3200+ with 512 GB ram) takes
quite a while to estimate the model.

With 3 categories, 5 explanatory variables and roughly 5000 observations it
takes 2-3 min. For 10 categories and 10 explanatory variables (still 5000
obs) more than 1 hour.

Is there any way I can speed up this process? (Modifying the code or
modifying some R options maybe?)

I would be really grateful if anybody could help me with this issue, I
attach my code below.

Many thanks,

Carlo

***
Carlo Fezzi

Centre for Social and Economic Research 
on the Global Environment (CSERGE),
School of Environmental Sciences,
University of East Anglia,
Norwich, NR4 7TJ
United Kingdom.

***



# MULTILOGIT

# This function computes the estimates of a multinomial logit model

# inputs:   a matrix vector of 1 and 0 (y) or of shares
#   a matrix of regressors (x) - MUST HAVE COLUMN NAMES! -
#   names of the variables, default = colnames(x)
#   optimization methods, default = 'BFGS'
#   base category, default = 1
#   restrictions, default = NULL
#   weights, default all equal to 1


# outputs:  an object of class "multilogit.c"

# McFadden D. (1974) "Conditional logit analysis of qualitative choice
behavior", in Zarembka P. (ed.), Frontiers in Econometrics, Academic Press.


multilogit.c <- function(y, xi, xi.names = colnames(xi), c.base=1,
rest=NULL, w = rep(1,nrow(y)), method='BFGS')
{

n.obs <- sum(w)
xi<-cbind(1,xi)
colnames(xi)[1]<-"Intercept"

nx<-ncol(xi)
ny<-ncol(y)

beta<-numeric(nx*ny)

negll<- function(beta,y,xi)
{
beta[rest]<-0
beta[(((c.base-1)*nx)+1):(c.base*nx)]<-0
lli <- y  * (xi%*%matrix(beta,nx,ny) - log ( apply(exp(
xi%*%matrix(beta,nx,ny)) ,1,sum ) ) )
lli<-lli*w
-sum(lli)
}

pi<- apply((y*w),2,mean)/mean(w)

ll0 <- (t(pi)%*%log(pi))*sum(w)

result<-c(  optim(par = rep(0,nx*(ny)), fn = negll, y=y, xi=xi,
hessian=T, method=method),
list(varnames=xi.names, rest=rest, nx=nx, ny=ny,
npar=nx*(ny-1)-length(rest), ll0=ll0,   pi=pi, xi=xi,
n.obs=n.obs,c.base=c.base,w=w))

result$par <- result$par[-(((c.base-1)*nx)+1):-(c.base*nx)]
result$hessian <-
result$hessian[-(((c.base-1)*nx)+1):-(c.base*nx),-(((c.base-1)*nx)+1):-(c.ba
se*nx)]

class(result)<-"multilogit.c"
return(result)
}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 : change value in rnw file to generate multiple "single" reports ?

2007-12-11 Thread Ptit_Bleu

Dear Uwe,

Could you please give me the name of the function to open, to modify and to
save a r script ?
Just the name and I will look for the way to use them.

And if you have a link explaining how to use user customized variables from
an environment variable, it will be very helpful (as it is completely new to
me).

Thanks in advance,
Ptit Bleu.




Within or before SWeave, you can use R.
Hence you can write some R function that first changes the rnw and runs 
SWeave thereafter, or even better, write something in your SWeave code 
that reads a user customized variables, e.g. from an environment 
variable or from some text file.

Uwe Ligges
-- 
View this message in context: 
http://www.nabble.com/Sweave-%3A-change-value-in-rnw-file-to-generate-multiple-%22single%22-reports---tp14256204p14275809.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] Hmisc compilation problem

2007-12-11 Thread Peter Dalgaard
Frank Liu wrote:
> I upgraded my system to Fedora Core 7 and got a compilation problem when
> installing Hmisc package.
> According to the error messages (shown below), I have tried to updated
> all of my glibc, gcc, automake rpm packages,
> but that did not help. Could you help me pointed out what package I have
> missed? Thank you.
>
>
>   

[EMAIL PROTECTED] ~]$ rpm -qf /usr/include/stdio.h
glibc-headers-2.6-4


-- 
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

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


Re: [R] R computing speed

2007-12-11 Thread jim holtman
I would suggest that you use Rprof to get a profile of the code to see
where time is being spent.  You did not provide commented, minimal,
self-contained, reproducible code, so it is hard to tell from just
looking at the code to determine what is happening.  Rprof should
provide an idea of where to look in your code for optimization.  You
might consider colMeans instead of the "apply", but I am not sure if
this will make a significant change in the execution time.

On Dec 11, 2007 6:55 AM, Carlo Fezzi <[EMAIL PROTECTED]> wrote:
> Dear helpers,
>
> I am using R version 2.5.1 to estimate a multinomial logit model using my
> own maximum likelihood function (I work with share data and the default
> function of R cannot deal with that).
>
> However, the computer (I have an Athlon XP 3200+ with 512 GB ram) takes
> quite a while to estimate the model.
>
> With 3 categories, 5 explanatory variables and roughly 5000 observations it
> takes 2-3 min. For 10 categories and 10 explanatory variables (still 5000
> obs) more than 1 hour.
>
> Is there any way I can speed up this process? (Modifying the code or
> modifying some R options maybe?)
>
> I would be really grateful if anybody could help me with this issue, I
> attach my code below.
>
> Many thanks,
>
> Carlo
>
> ***
> Carlo Fezzi
>
> Centre for Social and Economic Research
> on the Global Environment (CSERGE),
> School of Environmental Sciences,
> University of East Anglia,
> Norwich, NR4 7TJ
> United Kingdom.
>
> ***
>
>
>
> # MULTILOGIT
>
> # This function computes the estimates of a multinomial logit model
>
> # inputs:   a matrix vector of 1 and 0 (y) or of shares
> #   a matrix of regressors (x) - MUST HAVE COLUMN NAMES! -
> #   names of the variables, default = colnames(x)
> #   optimization methods, default = 'BFGS'
> #   base category, default = 1
> #   restrictions, default = NULL
> #   weights, default all equal to 1
>
>
> # outputs:  an object of class "multilogit.c"
>
> # McFadden D. (1974) "Conditional logit analysis of qualitative choice
> behavior", in Zarembka P. (ed.), Frontiers in Econometrics, Academic Press.
>
>
> multilogit.c <- function(y, xi, xi.names = colnames(xi), c.base=1,
> rest=NULL, w = rep(1,nrow(y)), method='BFGS')
> {
>
>n.obs <- sum(w)
>xi<-cbind(1,xi)
>colnames(xi)[1]<-"Intercept"
>
>nx<-ncol(xi)
>ny<-ncol(y)
>
>beta<-numeric(nx*ny)
>
>negll<- function(beta,y,xi)
>{
>beta[rest]<-0
>beta[(((c.base-1)*nx)+1):(c.base*nx)]<-0
>lli <- y  * (xi%*%matrix(beta,nx,ny) - log ( apply(exp(
> xi%*%matrix(beta,nx,ny)) ,1,sum ) ) )
>lli<-lli*w
>-sum(lli)
>}
>
>pi<- apply((y*w),2,mean)/mean(w)
>
>ll0 <- (t(pi)%*%log(pi))*sum(w)
>
>result<-c(  optim(par = rep(0,nx*(ny)), fn = negll, y=y, xi=xi,
> hessian=T, method=method),
>list(varnames=xi.names, rest=rest, nx=nx, ny=ny,
> npar=nx*(ny-1)-length(rest), ll0=ll0,   pi=pi, xi=xi,
> n.obs=n.obs,c.base=c.base,w=w))
>
>result$par <- result$par[-(((c.base-1)*nx)+1):-(c.base*nx)]
>result$hessian <-
> result$hessian[-(((c.base-1)*nx)+1):-(c.base*nx),-(((c.base-1)*nx)+1):-(c.ba
> se*nx)]
>
>class(result)<-"multilogit.c"
>return(result)
> }
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

What is the problem you are trying to solve?

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

2007-12-11 Thread Prof Brian Ripley
I think you have glibc-headers missing.  On an F8 system I get

eclectus% rpm -qf /usr/include/limits.h
glibc-headers-2.7-2
eclectus% rpm -qf /usr/include/stdio.h
glibc-headers-2.7-2
eclectus% rpm -qf /usr/include/stdlib.h
glibc-headers-2.7-2

You may find that glibc-devel is also missing and needed.

Did you install the R-devel RPM (you cannot have built R on that system)?
That's the way to pull in the dependencies you need to make packages.


On Tue, 11 Dec 2007, Frank Liu wrote:

> I upgraded my system to Fedora Core 7 and got a compilation problem when
> installing Hmisc package.
> According to the error messages (shown below), I have tried to updated
> all of my glibc, gcc, automake rpm packages,
> but that did not help. Could you help me pointed out what package I have
> missed? Thank you.
>
>
>> version
> _
> platform i386-redhat-linux-gnu
> arch i386
> os linux-gnu
> system i386, linux-gnu
> status
> major 2
> minor 6.1
> year 2007
> month 11
> day 26
> svn rev 43537
> language R
> version.string R version 2.6.1 (2007-11-26)
>
>> install.packages("Hmisc")
> Warning in install.packages("Hmisc") :
> argument 'lib' is missing: using '/usr/lib/R/library'
> --- Please select a CRAN mirror for use in this session ---
> Loading Tcl/Tk interface ... done
> trying URL 'http://cran.csie.ntu.edu.tw/src/contrib/Hmisc_3.4-3.tar.gz'
> Content type 'application/x-gzip' length 519009 bytes (506 Kb)
> opened URL
> ==
> downloaded 506 Kb
>
> /usr/lib/R/library
> * Installing *source* package 'Hmisc' ...
> ** libs
> gfortran -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
> -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386
> -mtune=generic -fasynchronous-unwind-tables -c cidxcn.f -o cidxcn.o
> gfortran -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
> -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386
> -mtune=generic -fasynchronous-unwind-tables -c cidxcp.f -o cidxcp.o
> gfortran -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
> -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386
> -mtune=generic -fasynchronous-unwind-tables -c hoeffd.f -o hoeffd.o
> gfortran -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
> -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386
> -mtune=generic -fasynchronous-unwind-tables -c jacklins.f -o jacklins.o
> gfortran -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
> -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386
> -mtune=generic -fasynchronous-unwind-tables -c largrec.f -o largrec.o
> gcc -std=gnu99 -I/usr/lib/R/include -I/usr/lib/R/include
> -I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2
> -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32
> -march=i386 -mtune=generic -fasynchronous-unwind-tables -c ranksort.c -o
> ranksort.o
> In file included from ranksort.c:1:
> /usr/lib/R/include/R.h:28:20: error: stdlib.h: No such file or directory
> /usr/lib/R/include/R.h:29:19: error: stdio.h: No such file or directory
> In file included from
> /usr/lib/gcc/i386-redhat-linux/4.1.2/include/syslimits.h:7,
> from /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h:11,
> from /usr/lib/R/include/R.h:30,
> from ranksort.c:1:
> /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h:122:61: error:
> limits.h: No such file or directory
> In file included from ranksort.c:1:
> /usr/lib/R/include/R.h:32:18: error: math.h: No such file or directory
> /usr/lib/R/include/R.h:33:19: error: errno.h: No such file or directory
> In file included from /usr/lib/R/include/R.h:50,
> from ranksort.c:1:
> /usr/lib/R/include/R_ext/RS.h:24:39: error: string.h: No such file or
> directory
> make: *** [ranksort.o] Error 1
> ERROR: compilation failed for package 'Hmisc'
> ** Removing '/usr/lib/R/library/Hmisc'
>
> The downloaded packages are in
> /tmp/Rtmpn7J8Y0/downloaded_packages
> Updating HTML index of packages in '.Library'
> Warning message:
> In install.packages("Hmisc") :
> installation of package 'Hmisc' had non-zero exit status
>
>
>

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

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


[R] book on regular expressions

2007-12-11 Thread Christos Hatzis
Hello,
 
Could someone recommend a good book on regular expressions with focus on
applications/use as it might relate to R.  I remember there was a mention of
such a reference book recently, but I could not locate that message on the
archive.
 
Thanks.
-Christos  
 
Christos Hatzis, Ph.D.
Nuvera Biosciences, Inc.
400 West Cummings Park
Suite 5350
Woburn, MA 01801
Tel: 781-938-3830
www.nuverabio.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] Simulating Case Control Data

2007-12-11 Thread Thomas Lumley
On Mon, 10 Dec 2007, R. W. wrote:

> Dear R-Help-List,
>
> I was wondering if anyone had experience simulating
> case-control data in R?

I think the only simple method that allows you to specify any arbitrary 
population distribution of predictors and does not rely on the logistic 
regression model being true is to simulate cohorts and then take a 
case-control sample from each one

Eg for a case-control sample of 500 cases and 1000 controls where there is 
about a 1% cumulative incidence
1. Generate all your predictor variables for a cohort of 50,000 people, 
from any distributions you want
2. Specify the disease model. This could be logistic
 logit(p(Y=1))=eta = b0+b1x1+b2x2+...
 p = exp(eta)/(1+exp(eta))
   or it could be anything else.
3. Now sum(p) gives the expected number of cases. Adjust b0 so that this 
is a bit bigger than your desired number, eg 550.
4. Generate Y for the population by rbinom(5,1,p)
5. Choose 500 cases and 1000 controls using sample().

-thomas

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Estimated survival function in Epi package

2007-12-11 Thread Summer Nitely
Does anyone know if the Epi package has a function that returns/plots the
survival function for interval censored survival analysis.  I haven't found
one in the manual that does this explicitly, but I could be missing it.  I
am writing a paper, and I just coded the survival function myself, but it
would be useful to the audience if there is a function that does so.
Thanks.

[[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] function centralm - does it exist

2007-12-11 Thread Gavin Simpson
On Mon, 2007-12-10 at 16:41 -0500, Nuno Prista wrote:
> Hi,
> 
>  
> 
> James S. Clark - Statistical computation for environmental sciences in R -
> mentions a function centralm (pg25) that I believe should be present in the
> base package but I can't find it. It is supposed to calculate means,
> variances, skewness, kurtosis of arrays. Does it exist in some other
> package?

You clearly haven't read and followed the preceding pages of the
chapter ;-)

See page 12, about 1/3 the way down the page.

HTH

G

-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,  [f] +44 (0)20 7679 0565
 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

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


Re: [R] R computing speed

2007-12-11 Thread Carlo Fezzi
Dear Jim,

Thanks a lot for your suggestion. Indeed substituting the function apply
with rowSums made a great difference. Now the code is much faster!

Cheers,

Carlo

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of jim holtman
Sent: 11 December 2007 15:09
To: Carlo Fezzi
Cc: r-help@r-project.org
Subject: Re: [R] R computing speed

I would suggest that you use Rprof to get a profile of the code to see
where time is being spent.  You did not provide commented, minimal,
self-contained, reproducible code, so it is hard to tell from just
looking at the code to determine what is happening.  Rprof should
provide an idea of where to look in your code for optimization.  You
might consider colMeans instead of the "apply", but I am not sure if
this will make a significant change in the execution time.

On Dec 11, 2007 6:55 AM, Carlo Fezzi <[EMAIL PROTECTED]> wrote:
> Dear helpers,
>
> I am using R version 2.5.1 to estimate a multinomial logit model using my
> own maximum likelihood function (I work with share data and the default
> function of R cannot deal with that).
>
> However, the computer (I have an Athlon XP 3200+ with 512 GB ram) takes
> quite a while to estimate the model.
>
> With 3 categories, 5 explanatory variables and roughly 5000 observations
it
> takes 2-3 min. For 10 categories and 10 explanatory variables (still 5000
> obs) more than 1 hour.
>
> Is there any way I can speed up this process? (Modifying the code or
> modifying some R options maybe?)
>
> I would be really grateful if anybody could help me with this issue, I
> attach my code below.
>
> Many thanks,
>
> Carlo
>
> ***
> Carlo Fezzi
>
> Centre for Social and Economic Research
> on the Global Environment (CSERGE),
> School of Environmental Sciences,
> University of East Anglia,
> Norwich, NR4 7TJ
> United Kingdom.
>
> ***
>
>
>
> # MULTILOGIT
>
> # This function computes the estimates of a multinomial logit model
>
> # inputs:   a matrix vector of 1 and 0 (y) or of shares
> #   a matrix of regressors (x) - MUST HAVE COLUMN NAMES! -
> #   names of the variables, default = colnames(x)
> #   optimization methods, default = 'BFGS'
> #   base category, default = 1
> #   restrictions, default = NULL
> #   weights, default all equal to 1
>
>
> # outputs:  an object of class "multilogit.c"
>
> # McFadden D. (1974) "Conditional logit analysis of qualitative choice
> behavior", in Zarembka P. (ed.), Frontiers in Econometrics, Academic
Press.
>
>
> multilogit.c <- function(y, xi, xi.names = colnames(xi), c.base=1,
> rest=NULL, w = rep(1,nrow(y)), method='BFGS')
> {
>
>n.obs <- sum(w)
>xi<-cbind(1,xi)
>colnames(xi)[1]<-"Intercept"
>
>nx<-ncol(xi)
>ny<-ncol(y)
>
>beta<-numeric(nx*ny)
>
>negll<- function(beta,y,xi)
>{
>beta[rest]<-0
>beta[(((c.base-1)*nx)+1):(c.base*nx)]<-0
>lli <- y  * (xi%*%matrix(beta,nx,ny) - log ( apply(exp(
> xi%*%matrix(beta,nx,ny)) ,1,sum ) ) )
>lli<-lli*w
>-sum(lli)
>}
>
>pi<- apply((y*w),2,mean)/mean(w)
>
>ll0 <- (t(pi)%*%log(pi))*sum(w)
>
>result<-c(  optim(par = rep(0,nx*(ny)), fn = negll, y=y, xi=xi,
> hessian=T, method=method),
>list(varnames=xi.names, rest=rest, nx=nx, ny=ny,
> npar=nx*(ny-1)-length(rest), ll0=ll0,   pi=pi, xi=xi,
> n.obs=n.obs,c.base=c.base,w=w))
>
>result$par <- result$par[-(((c.base-1)*nx)+1):-(c.base*nx)]
>result$hessian <-
>
result$hessian[-(((c.base-1)*nx)+1):-(c.base*nx),-(((c.base-1)*nx)+1):-(c.ba
> se*nx)]
>
>class(result)<-"multilogit.c"
>return(result)
> }
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

What is the problem you are trying to solve?

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

2007-12-11 Thread livia

Hi, I guess it is because I spread the command in different rows. Thank you
very much for your help.

Petr Pikal wrote:
> 
> Hi
> 
> [EMAIL PROTECTED] napsal dne 11.12.2007 13:06:14:
> 
>> 
>> Hello everyone, 
>> 
>> I would like to use the "if" statements and I was thinking sth like
>> 
>> If () {} else{ if() {} else{} } 
>> 
>> Is this a possible solution and is there any syntax error?
> 
> Except the first letter, nothing sooms to be wrong.
> 
>> if (1==1) {print("a")} else { if(1==1) {print("b")} else{print("c")} } 
> [1] "a"
>> if (1==2) {print("a")} else { if(1==1) {print("b")} else{print("c")} } 
> [1] "b"
>> if (1==2) {print("a")} else { if(1==2) {print("b")} else{print("c")} } 
> [1] "c"
>>
> 
> I beleive you noticed a difference between if() and ifelse() functions. 
> And of course if you spread your command in several rows be carefull not 
> to have valid syntax before you ended a whole command.
> e.g.
> if (1==2) {print("a")} 
> else { if(1==2) {print("b")} else{print("c")} }
> 
> Error: unexpected 'else' in "else"
> 
> 
> Regards
> Petr
> 
> 
>> 
>> Could anyone give me some advice? Many thanks.
>> -- 
>> View this message in context: http://www.nabble.com/If-Else-Function-
>> tp14272459p14272459.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/If-Else-Function-tp14272459p14277285.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] Mono in postscript device

2007-12-11 Thread Benjamin Otto
Hi,

Plotting a graphic into a postscript device using family="mono" returns the
following error message:

>>  family 'mono' not included in PostScript device

Looking at postscriptFonts() however lists the "Courier" font as availeable
mono font. So where is the problem?


Thanks guys for your help.
Best regards

Benjamin



sessionInfo()

R version 2.5.0 (2007-04-23) 
i386-pc-mingw32 

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

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

other attached packages:
  affy affyioBiobase hgu133acdfhgu133a 
  "1.14.0""1.4.0"   "1.14.0"   "1.16.0"   "1.16.0" 
 
==
Benjamin Otto
University Hospital Hamburg-Eppendorf
Institute For Clinical Chemistry
Martinistr. 52
D-20246 Hamburg

Tel.: +49 40 42803 1908
Fax.: +49 40 42803 4971
==



-- 
Pflichtangaben gemäß Gesetz über elektronische Handelsregister und 
Genossenschaftsregister sowie das Unternehmensregister (EHUG):

Universitätsklinikum Hamburg-Eppendorf
Körperschaft des öffentlichen Rechts
Gerichtsstand: Hamburg

Vorstandsmitglieder:
Prof. Dr. Jörg F. Debatin (Vorsitzender)
Dr. Alexander Kirstein
Ricarda Klein
Prof. Dr. Dr. Uwe Koch-Gromus

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

2007-12-11 Thread Prof Brian Ripley
On Tue, 11 Dec 2007, Benjamin Otto wrote:

> Hi,
>
> Plotting a graphic into a postscript device using family="mono" returns the
> following error message:
>
>>> family 'mono' not included in PostScript device
>
> Looking at postscriptFonts() however lists the "Courier" font as availeable
> mono font. So where is the problem?

The 'problem' is that you have not provided us with reproducible code, and 
used an obsolete version of R.  At least some of the ways you might have 
done this you needed to specify the 'fonts' argument to postscript().

As a minimal example,

> postscript(family="mono")
> plot(1:10)
> dev.off()

works in R 2.6.1.  If that does not work for you, you need to update.
If it does, you need to consider what you did differently.

> Thanks guys for your help.
> Best regards
>
> Benjamin
>
> sessionInfo()
>
> R version 2.5.0 (2007-04-23)
> i386-pc-mingw32

[...]


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

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


Re: [R] book on regular expressions

2007-12-11 Thread hadley wickham
> Could someone recommend a good book on regular expressions with focus on
> applications/use as it might relate to R.  I remember there was a mention of
> such a reference book recently, but I could not locate that message on the
> archive.

Mastering regular expressions by Jeffrey Friedl
(http://books.google.com/books?q=editions%3AISBN0596528124) is the
classic reference.  Although it doesn't cover R explicitly, R does
support perl compatible regular expressions which are discussed in the
book.  Regardless, most of the topics are general enough not to depend
tightly on the specific regexp engine.

Hadley

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

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


Re: [R] book on regular expressions

2007-12-11 Thread Anne York


On Tue, 11 Dec 2007, Christos Hatzis wrote:

CH > Hello,
CH >  
CH > Could someone recommend a good book on regular expressions with focus on
CH > applications/use as it might relate to R.  I remember there was a mention 
of
CH > such a reference book recently, but I could not locate that message on the
CH > archive.
CH >  
CH > Thanks.
CH > -Christos  



There are MANY FREE tutorials on regular expressions. Just 
google regular expressions tutorial.

Anne

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

2007-12-11 Thread Gabor Grothendieck
Its not a book but there are some references to sites that explain
regular expressions in the Links box of the gsubfn home page:

http://gsubfn.googlecode.com

On Dec 11, 2007 10:46 AM, Christos Hatzis <[EMAIL PROTECTED]> wrote:
> Hello,
>
> Could someone recommend a good book on regular expressions with focus on
> applications/use as it might relate to R.  I remember there was a mention of
> such a reference book recently, but I could not locate that message on the
> archive.
>
> Thanks.
> -Christos
>
> Christos Hatzis, Ph.D.
> Nuvera Biosciences, Inc.
> 400 West Cummings Park
> Suite 5350
> Woburn, MA 01801
> Tel: 781-938-3830
> www.nuverabio.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-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 : change value in rnw file to generate multiple "single" reports ?

2007-12-11 Thread Greg Snow
I'm not Uwe, but here are some of the things to try if you want to do
this fully in R.

Look at the help for scan,  one approach to reading in a .rnw file is to
use scan, but set it to read each row of the file as a character matrix.
The 'see also' section of the scan help page has some other functions
that could be used to read in the file as well.

Modify the read in character strings with the sub or gsub functions.

Use cat (with a file argument) to write the character strings back to a
file.

Also look at the commandArgs function for one way to pass options (the
device name(s)) to your R script.

You may also want to read (or reread) the "Invoking R" section of "An
Introduction to R".

Hope this helps,

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

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Ptit_Bleu
> Sent: Tuesday, December 11, 2007 8:05 AM
> To: r-help@r-project.org
> Subject: Re: [R] Sweave : change value in rnw file to 
> generate multiple "single" reports ?
> 
> 
> Dear Uwe,
> 
> Could you please give me the name of the function to open, to 
> modify and to save a r script ?
> Just the name and I will look for the way to use them.
> 
> And if you have a link explaining how to use user customized 
> variables from an environment variable, it will be very 
> helpful (as it is completely new to me).
> 
> Thanks in advance,
> Ptit Bleu.
> 
> 
> 
> 
> Within or before SWeave, you can use R.
> Hence you can write some R function that first changes the 
> rnw and runs SWeave thereafter, or even better, write 
> something in your SWeave code that reads a user customized 
> variables, e.g. from an environment variable or from some text file.
> 
> Uwe Ligges
> --
> View this message in context: 
> http://www.nabble.com/Sweave-%3A-change-value-in-rnw-file-to-g
> enerate-multiple-%22single%22-reports---tp14256204p14275809.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 

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


[R] ggplot - Setting the y-scale in a bar plot

2007-12-11 Thread Pedro de Barros
Dear All (probably Hadley),

I am now trying to customise some plots using a bar geom.

I do not want to use the default binning statistic, but rather 
calculate the bar heigths separately. I do manage this, but for 
comparison purposes I would like to have a set of plots all with the 
same y-axis height. But I do not seem to find out how to fix the 
scale of the y-axis in this case.
Any tips?
Using R 2.6.1 on Windows.

Thanks for any help,
Pedro

I attach below the code I am using:
plotdata<-data.frame(x=factor(2:8), y=0.1*(2:8))
plot1<-ggplot()
plot1<-plot1+layer(data=plotdata, 
mapping=aes_string(x='x',y='y'),geom='bar', stat='identity')

RangeY <-c(0,1)
YBreaks <- (0:10)*diff(RangeY)/10
YTickLabels<- as.character(YBreaks)

plot2 <- plot1 + scale_y_continuous(limits=RangeY, breaks=YBreaks, 
labels=YTickLabels, expand=c(0,0))
print(plot2)

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

2007-12-11 Thread Zembower, Kevin
I'm trying to solve a homework problem using R. The problem gives a list
of cricket chirps per second and corresponding temperature, and asks to
give the equation for the linear model and then predict the temperature
to produce 18 chirps per second. So far, I have:

> # Homework 11.2.1 and 11.3.3
> chirps <- scan()
1: 20
2: 16
3: 19.8
4: 18.4
5: 17.1
6: 15.5
7: 14.7
8: 17.1
9: 15.4
10: 16.2
11: 15
12: 17.2
13: 16
14: 17
15: 14.4
16: 
Read 15 items
> temp <- scan()
1: 88.6
2: 71.6
3: 93.3
4: 84.3
5: 80.6
6: 75.2
7: 69.7
8: 82
9: 69.4
10: 83.3
11: 79.6
12: 82.5
13: 80.6
14: 83.5
15: 76.3
16: 
Read 15 items
> chirps
 [1] 20.0 16.0 19.8 18.4 17.1 15.5 14.7 17.1 15.4 16.2 15.0 17.2 16.0
17.0 14.4
> temp
 [1] 88.6 71.6 93.3 84.3 80.6 75.2 69.7 82.0 69.4 83.3 79.6 82.5 80.6
83.5 76.3
> chirps.res <- lm(chirps ~ temp)
> summary(chirps.res)

Call:
lm(formula = chirps ~ temp)

Residuals:
 Min   1Q   Median   3Q  Max 
-1.56146 -0.58088  0.02972  0.58807  1.53047 

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.314333.10963  -0.101 0.921028
temp 0.212010.03873   5.474 0.000107 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 

Residual standard error: 0.9715 on 13 degrees of freedom
Multiple R-Squared: 0.6975, Adjusted R-squared: 0.6742 
F-statistic: 29.97 on 1 and 13 DF,  p-value: 0.0001067
> # From the linear model summary output above, the equation for the
least squares line is:
> #y = -0.3143 + 0.2120*x or chirps = -0.3143 + 0.2120*temp
> 

I can then determine the answer to the prediction, using algebra and R:
> pred_temp <- (18+0.3143)/0.2120
> pred_temp
[1] 86.3882

However, I'd like to try to use the predict() function. Since 'chirps'
and 'temp' are just vectors of numbers, and not dataframes, these
failed:
predict(chirps.res, newdata=data.frame(chirp=18))
predict(chirps.res, newdata="chirp=18")
predict(chirps.res, newdata=18)

I then tried to turn my two vectors into a dataframe. I would have bet
money that this would have worked, but it didn't:
> df <- data.frame(chirps, temp)
>  chirps.res <- lm(chirps ~ temp, data=df)
> predict(chirps.res, newdata=data.frame(chirps=18))

Can anyone tell me how to use predict() in this circumstance?

Thanks for your help and advice.

-Kevin

Kevin Zembower
Internet Services Group manager
Center for Communication Programs
Bloomberg School of Public Health
Johns Hopkins University
111 Market Place, Suite 310
Baltimore, Maryland  21202
410-659-6139 

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Reading through a group of .RData files

2007-12-11 Thread Talbot Katz

Thanks again, Benilton, I found your suggestions very helpful.  But I couldn't 
seem to use the lapply / get combination to remove the objects that were 
loaded.  The best I could come up with was:
 
eval( parse( text = paste( "rm(", paste( myObj, collapse = "," ), " )", sep = 
"" ) ) )
 
I'm wondering whether there's a cleaner / easier way to remove a set of objects 
whose names are listed in a character array (as returned by load) ?
 
Thank you!
 
--  TMK  --212-460-5430 home917-656-5351 cell
> Date: Mon, 10 Dec 2007 14:31:19 -0500> From: [EMAIL PROTECTED]> To: [EMAIL 
> PROTECTED]> CC: [EMAIL PROTECTED]> Subject: Re: [R] Reading through a group 
> of .RData files> > note that load() returns, invisibly, a string with the 
> names of the > objects that were loaded. something in the lines of:> > myObj 
> <- load(file.path(fnDir, cvListFiles[i]))> myFunction(get(myObj))> 
> rm(list=myObj)> > might be closer to what you want.> > moreover, if 
> length(myObj) > 1, you might want sth like:> > lapply(myObj, function(x) 
> myFunction(get(x)))> > instead...> > best> b> > On Mon, 10 Dec 2007, Talbot 
> Katz wrote:> > >> > Hi.> >> > I have a procedure that reads a directory, 
> loops through a set of particular .RData files, loading each one, and feeding 
> its object(s) into a function, as follows:> >> > 
> cvListFiles<-list.files(fnDir);> > for(i in 
> grep(paste("^",pfnStub,".*\\.RData$",sep=""),cvListFiles)){> > 
> load(paste(fnDir,cvListFiles[i],sep="/"));> > myFunction(rliObject);> > 
> rm(rliObject);> !
 > };> >> > where fnDir is the directory I'm reading, and pfnStub is a string 
 > that begins the name of each of the files I want to load. As you can see, 
 > I'm assuming that each of the selected .RData files contains an object named 
 > "rliObject" and I'm hoping that nothing in any of the files I'm loading 
 > overwrites an object in my environment. I'd like to clean this up so that I 
 > can extract the object(s) from each data file, and feed them to my function, 
 > whatever their names are, without corrupting my environment. I'd appreciate 
 > any assistance. Thanks!> >> > -- TMK --212-460-5430 home917-656-5351 cell> > 
 > [[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] Reading through a group of .RData files

2007-12-11 Thread Benilton Carvalho
actually, the lapply() was supposed to be used with your particular  
function...


to remove, all you need is:

rm(list=myObj)

b

On Dec 11, 2007, at 1:42 PM, Talbot Katz wrote:

Thanks again, Benilton, I found your suggestions very helpful.  But  
I couldn't seem to use the lapply / get combination to remove the  
objects that were loaded.  The best I could come up with was:


eval( parse( text = paste( "rm(", paste( myObj, collapse = "," ),  
" )", sep = "" ) ) )


I'm wondering whether there's a cleaner / easier way to remove a set  
of objects whose names are listed in a character array (as returned  
by load) ?


Thank you!

--  TMK  --
212-460-5430 home
917-656-5351 cell



> Date: Mon, 10 Dec 2007 14:31:19 -0500
> From: [EMAIL PROTECTED]
> To: [EMAIL PROTECTED]
> CC: [EMAIL PROTECTED]
> Subject: Re: [R] Reading through a group of .RData files
>
> note that load() returns, invisibly, a string with the names of the
> objects that were loaded. something in the lines of:
>
> myObj <- load(file.path(fnDir, cvListFiles[i]))
> myFunction(get(myObj))
> rm(list=myObj)
>
> might be closer to what you want.
>
> moreover, if length(myObj) > 1, you might want sth like:
>
> lapply(myObj, function(x) myFunction(get(x)))
>
> instead...
>
> best
> b
>
> On Mon, 10 Dec 2007, Talbot Katz wrote:
>
> >
> > Hi.
> >
> > I have a procedure that reads a directory, loops through a set  
of particular .RData files, loading each one, and feeding its  
object(s) into a function, as follows:

> >
> > cvListFiles<-list.files(fnDir);
> > for(i in grep(paste("^",pfnStub,".*\\.RData 
$",sep=""),cvListFiles)){

> > load(paste(fnDir,cvListFiles[i],sep="/"));
> > myFunction(rliObject);
> > rm(rliObject);
> > };
> >
> > where fnDir is the directory I'm reading, and pfnStub is a  
string that begins the name of each of the files I want to load. As  
you can see, I'm assuming that each of the selected .RData files  
contains an object named "rliObject" and I'm hoping that nothing in  
any of the files I'm loading overwrites an object in my environment.  
I'd like to clean this up so that I can extract the object(s) from  
each data file, and feed them to my function, whatever their names  
are, without corrupting my environment. I'd appreciate any  
assistance. Thanks!

> >
> > -- TMK --212-460-5430 home917-656-5351 cell
> > [[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] book on regular expressions

2007-12-11 Thread davidr
I've found the O'Reilly pocket reference "Regular Expression" (about USD
10.00) quite handy.
It covers Perl, C, PHP, Python, Java, and .Net.

David L. Reiner
Rho Trading Securities, LLC

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Christos Hatzis
Sent: Tuesday, December 11, 2007 9:47 AM
To: r-help@r-project.org
Subject: [R] book on regular expressions

Hello,
 
Could someone recommend a good book on regular expressions with focus on
applications/use as it might relate to R.  I remember there was a
mention of
such a reference book recently, but I could not locate that message on
the
archive.
 
Thanks.
-Christos  
 
Christos Hatzis, Ph.D.
Nuvera Biosciences, Inc.
400 West Cummings Park
Suite 5350
Woburn, MA 01801
Tel: 781-938-3830
www.nuverabio.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-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] book on regular expressions

2007-12-11 Thread Christos Hatzis
Great.
Two books were consistently recommended: the pocket guide "Regular
Expressions" and the more extensive "Mastering Regular Expressions", both by
O'Reilly.

Thanks to all those who responded.

-Christos 

> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, December 11, 2007 1:51 PM
> To: [EMAIL PROTECTED]; r-help@r-project.org
> Subject: RE: [R] book on regular expressions
> 
> I've found the O'Reilly pocket reference "Regular Expression" 
> (about USD
> 10.00) quite handy.
> It covers Perl, C, PHP, Python, Java, and .Net.
> 
> David L. Reiner
> Rho Trading Securities, LLC
> 
> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED]
> On Behalf Of Christos Hatzis
> Sent: Tuesday, December 11, 2007 9:47 AM
> To: r-help@r-project.org
> Subject: [R] book on regular expressions
> 
> Hello,
>  
> Could someone recommend a good book on regular expressions 
> with focus on applications/use as it might relate to R.  I 
> remember there was a mention of such a reference book 
> recently, but I could not locate that message on the archive.
>  
> Thanks.
> -Christos  
>  
> Christos Hatzis, Ph.D.
> Nuvera Biosciences, Inc.
> 400 West Cummings Park
> Suite 5350
> Woburn, MA 01801
> Tel: 781-938-3830
> www.nuverabio.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-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Extracting clusters from Data Frame

2007-12-11 Thread Johannes Graumann
Gustaf Rydevik wrote:

> On Dec 10, 2007 2:28 PM, Johannes Graumann <[EMAIL PROTECTED]>
> wrote:
>> Hello,
>>
>> I have a large data frame (1006222 rows), which I subject to a crude
>> clustering attempt that results in a vector stating whether the datapoint
>> represented by a row belongs to a cluster or not. Conceptually this looks
>> something like this:
>> Value   Cluster?
>> 0.01FALSE
>> 0.03TRUE
>> 0.04TRUE
>> 0.05TRUE
>> 0.07FALSE
>> ...
>> What I'm looking for is an efficient strategy to extract all consecutive
>> rows associated with "TRUE" as a single cluster (data.frame
>> representation?) without cluttering memory with thousends of data.frames.
>> I was thinking of an independent data.frame that would contain a column
>> of lists that reference all indexes from the big one which are contained
>> in one cluster ...
>> Can anyone kindly nudge me and let me know how to deal with this
>> efficiently?
>>
>> Joh
>>
> 
> How about :
> orig.data<-sample(c(TRUE,FALSE),100,replace=T)
>
Cluster<-data.frame(c.ndx=cumsum(rle(orig.data)$lengths),c.size=rle(orig.data)$lengths,c.type=rle(orig.data)$values)
> Cluster<-Cluster[Cluster$c.type==TRUE,]
> 
> ##Then, to get all original data belonging to cluster three:
> orig.data[rev(Cluster[3,"c.ndx"]-seq(length.out=Cluster[3,"c.size"])+1)]
> 
> 
> Not the neatest solution, but I'm sure someone here can improve on it.
> /Gustaf

Thank you for this example! "rle" was indeed what safed my day!

Joh

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] question regarding arima function and predicted values

2007-12-11 Thread eugen pircalabelu

Good evening!

I have a question regarding  forecast package and time series analysis.
My syntax:

x<-c(253, 252, 275, 275, 272, 254, 272, 252, 249, 300, 244, 258, 255, 285, 301, 
278, 279, 304, 275, 276, 313, 292, 302, 322, 281, 298, 305, 295, 286, 327, 286, 
270, 289, 293, 287, 267, 267, 288, 304, 273, 264, 254, 263, 265, 278)
library(forecast)
arima(x, order=c(1,1,2), seasonal=list(order=c(0,1,0), period=12))->l
auto.arima(x)->k
sd(l$resid)
sd(k$resid)
predict(l,n.ahead=1)
predict(k,n.ahead=1)

1. I understand that auto.arima will find the best time series model choosing 
the smaller AIC, BIC and AICc from competing models, but my model finds a 
smaller AIC than that of the auto.arima. but the sd of the residuals for my 
model is somehow bigger. 
Why? Am I missing something? 
Now the sd of the residuals for my model is somehow bigger, as well as the se 
for the predicted value.  What model would you choose between this two and why? 
  

2. This question is more theoretical 

 m<-sample(c(10:20),10,replace=T)
 f<-sample(c(10:20),10,replace=T)
 t<-m+f
 s<-rbind(m,f,t)
 s

Let's say I have a panel sample at disposal and consider m to be the monthly 
average quantity of juice consumption for the  male part of the sample and f to 
be the monthly average quantity of juice consumption for the  female part of 
the sample, and t the average quantity of juice consumption for the whole 
sample. For the mean of the whole sample i have a confidence interval of say 
+/-2 each month (say I have a sample of 2000 individuals). If I try to come up 
with a confidence interval only for the male population (which in my sample is  
say 1000) it would certainly by bigger, because i now have a male sample of 
1000 for determining the mean consumption for the whole male population. So my 
confidence interval is bigger for mean male consumption than for the whole 
sample (because N declines from 2000 to 1000). Now if I tried to predict the 
the next month's consumption for both my time series (male and whole sample) 
the prediction would not "care" that when establishing the
 mean consumption i used first 2000 people and then 1000. Am I right?
Imagine that each month (from 10 that I sampled above) has such a confidence 
interval of +/-3. Now how would a future prediction would incorporate this 
fact: that my mean consumption is not measured via a Census, but using a 
sample, and that the number is an estimation of the real consumption, within a 
confidence interval?
Is there a good reference text for this incorporation of the confidence 
interval  of past values in determining  the future values ? 

Thank you and have a great day!




   
-

[[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] Building R on Sun Solaris 10 (SPARC) using Sun Studio 12

2007-12-11 Thread James T Brown
Prof Ripley:

>>
>> Just curious if anyone has successfully built R on a SPARC
>> platform running Sun Solaris 10 using the latest Sun Studio
>> 12 set of compilers.   If so, I would be interested in the
>> compile flags that you used.
>
> Yes, the flags given in the R-admin manual.  (We don't currently have 
> a Solaris 10 Sparc box running, but this was with the current Sun 
> Studio 12 at the time, just after it came out.)
>

Thanks for reply.

Yes, I have tried this, although I had to remove the "-xc99" flag from
the CC environment variable.  When used as shown in the installation
manual, the compile fails:

In file included from regex.c:107:
/usr/include/stdbool.h:42:2: #error "Use of  is valid only in 
a c99 compilation environment."
*** Error code 1
The following command caused the error:
cpp -M -I../../src/extra/zlib -I../../src/extra/bzip2 
-I../../src/extra/pcre   -I. -I../../src/include -I../../src/include 
-I/usr/local/include -DHAVE_CONFIG_H regex.c > regex.d
make: Fatal error: Command failed for target `regex.d'
Current working directory /apps/local/src/R-2.6.1/src/main
*** Error code 1



By removing the "-xc99" flag and setting the others options as specified
in the installation manual, the R package builds completely, but the
"foreign" package continues to crash when I attempt to load it - all
of the other packages that I have tried seem to work just fine.   I
suspect that since those that have built with GCC are not reporting
any trouble, it would be difficult to point a finger at the "foreign"
code and claim that this is a bug, but yet, I am not having any trouble
with any of the other packages that have been built using Sun Studio 12.

Here are the latest "configure" options that I have tried (as
specified in the manual, minus the "-xc99" flag):

  % ./configure --prefix=/usr/local/R-2.6.1
   CC=/opt/SUNWspro/bin/cc
   CFLAGS="-O -xlibmieee"
   LDFLAGS="-L/usr/local/lib -R/usr/local/lib"
   CXX=/opt/SUNWspro/bin/CC
   CXXFLAGS=-O
   F77=/opt/SUNWspro/bin/f95
   FFLAGS=-O
   FC=/opt/SUNWspro/bin/f95
   FCFLAGS=-O
   CPPFLAGS="-I/usr/local/include"
   SHLIB_CXXLDFLAGS="-G -lCstd"

  % make

  % /usr/local/R-2.6.1/bin/R

> library(foreign)

 *** caught segfault ***
address fdde9918, cause 'invalid permissions'

Traceback:
 1: .C("spss_init", PACKAGE = "foreign")
 2: fun(...)
 3: doTryCatch(return(expr), name, parentenv, handler)
 4: tryCatchOne(expr, names, parentenv, handlers[[1]])
 5: tryCatchList(expr, classes, parentenv, handlers)
 6: tryCatch(expr, error = function(e) {call <- conditionCall(e)
if (!is.null(call)) {if (identical(call[[1]], 
quote(doTryCatch))) call <- sys.call(-4)dcall <- 
deparse(call)[1]prefix <- paste("Error in", dcall, ": ")
LONG <- 75msg <- conditionMessage(e)sm <- strsplit(msg, 
"\n")[[1]]if (14 + nchar(dcall, type = "w") + nchar(sm[1], type 
= "w") > LONG) prefix <- paste(prefix, "\n  ", 
sep = "")}else prefix <- "Error : "msg <- paste(prefix, 
conditionMessage(e), "\n", sep = "")
.Internal(seterrmessage(msg[1]))if (!silent && 
identical(getOption("show.error.messages"), TRUE)) {
cat(msg, file = stderr()).Internal(printDeferredWarnings())
}invisible(structure(msg, class = "try-error"))})
 7: try({fun(...)NULL})
 8: runHook(".onLoad", package, env, package.lib, package)
 9: loadNamespace(package, c(which.lib.loc, lib.loc), keep.source = 
keep.source)
10: doTryCatch(return(expr), name, parentenv, handler)
11: tryCatchOne(expr, names, parentenv, handlers[[1]])
12: tryCatchList(expr, classes, parentenv, handlers)
13: tryCatch(expr, error = function(e) {call <- conditionCall(e)
if (!is.null(call)) {if (identical(call[[1]], 
quote(doTryCatch))) call <- sys.call(-4)dcall <- 
deparse(call)[1]prefix <- paste("Error in", dcall, ": ")
LONG <- 75msg <- conditionMessage(e)sm <- strsplit(msg, 
"\n")[[1]]if (14 + nchar(dcall, type = "w") + nchar(sm[1], type 
= "w") > LONG) prefix <- paste(prefix, "\n  ", 
sep = "")}else prefix <- "Error : "msg <- paste(prefix, 
conditionMessage(e), "\n", sep = "")
.Internal(seterrmessage(msg[1]))if (!silent && 
identical(getOption("show.error.messages"), TRUE)) {
cat(msg, file = stderr()).Internal(printDeferredWarnings())
}invisible(structure(msg, class = "try-error"))})
14: try({ns <- loadNamespace(package, c(which.lib.loc, lib.loc), 
keep.source = keep.source)dataPath <- file.path(which.lib.loc, 
package, "data")env <- attachNamespace(ns, pos = pos, dataPath = 
dataPath)})
15: library(foreign)

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving

[R] matrix graph

2007-12-11 Thread threshold

Hi All, simple question: 
do you know how to graph the following object/matrix in a 'surface manner':

  [,1] [,2] [,3][,4]   [,5][,6]
[1,] -0.154 -0.065 0.129 0.637 0.780 0.221
[2,]  0.236  0.580 0.448 0.729 0.859 0.475
[3,]  0.401  0.506 0.310 0.650 0.822 0.448
[4,]  0.548  0.625 0.883 0.825 0.945 0.637
[5,]  0.544  0.746 0.823 0.877 0.861 0.642
[6,]  0.262  0.399 0.432 0.620 0.711 0.404

will be very grateful for hints.

rob
-- 
View this message in context: 
http://www.nabble.com/matrix-graph-tp14282791p14282791.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] postResample R² and lm() R²

2007-12-11 Thread Giovane
Hello,

I'm with a conceptual doubt regarding Rsquared of both lm() and
postResample(library caret).

I've got a multiple regression linear model (lets say mlr) with anR² value
of 67.52%.
Then I use this model pro make predictions with predict() function using the
same data as input , that is, use the generated model to predict the value
associated with data that I used as input.

Next, if I apply postResample() to the observed and predicted data, why do I
have have an R² value of 33%? I mean, wasn't it supposed to be, at least,
67%, as in the original model, since they're using the same data as input?

Here is the code (the data goes on the end of the email)

#read input data
input<-read.table("input.csv", header=T)

# multiple linear regression
mlr<-lm(input$TOTAL~-1 + input$A + input$B + input$C + input$D)

#observe the model
summary(mlr)
Call:
lm(formula = input$TOTAL ~ -1 + input$A + input$B + input$C +  input$D)

Residuals:
Min  1Q  Median  3Q Max
-25.753  -7.455   2.396  12.615  55.316

Coefficients:
Estimate Std. Error t value Pr(>|t|)
input$A  10.5985 3.9782   2.664   0.0121 *
input$B   0.347117.7731   0.020   0.9845
input$C   0.9468 1.9442   0.487   0.6297
input$D  12.1056 4.7262   2.561   0.0155 *
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 17.08 on 31 degrees of freedom
Multiple R-Squared: 0.6752, Adjusted R-squared: 0.6333
F-statistic: 16.11 on 4 and 31 DF,  p-value: 3.090e-07

#as we noticed, an Rsquared value of 67.52%
#next, lets predict the results with the same input data
 prediction<-predict(mlr,input)


#now let's evaluate the predictions, observing the R² and RMSE values that
postResample returns

 postResample(input$TOTAL, prediction)
  RMSE   Rsquared
16.0718506  0.3300378

So here comes my doubt: why do I have an value of 67.52% for R² when
creating the model(that is , the model explains 67.52% of the data) and
when I use this same model on the same input data, why does postResample
return a very different value associated to R²?

Best regards,

Giovane

#input.csv file used as input

"A" "B" "C" "D" "TOTAL"
1   0   1   0   3.8
1   0   1   0   21.67
1   0   0   0   2.92
2   0   6   0   42.84
0   0   0   0   5.28
2   0   0   3   44.86
1   0   0   0   8.22
1   0   0   0   28.24
1   0   3   0   29.69
1   0   0   1   78.02
3   0   7   0   51.29
2   0   0   0   37.55
2   0   2   0   10.82
1   0   3   0   17.67
0   0   0   0   6.62
2   1   3   1   36.49
0   0   0   0   37.52
1   0   2   0   5.26
1   0   2   0   7.32
1   0   0   0   2.2
2   0   6   0   39.24
0   0   0   0   2.83
2   0   0   3   50.93
1   0   0   0   4.15
1   0   0   0   29.72
1   0   3   0   4.26
1   0   0   1   25.1
3   0   7   0   12.67
2   0   0   0   7.99
2   0   2   0   17.55
1   0   3   0   3.66
0   0   0   0   7.22
0   0   0   0   3.82
0   0   0   0   28.05
3   0   7   0   34.67

[[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] Reading through a group of .RData files

2007-12-11 Thread Henrik Bengtsson
Hi,

depending on what you do and how (and why) you save objects in RData
files in the first place, you might be interested in knowing of the
loadObject()/saveObject() methods of R.utils, as well as
loadCache()/saveCache() in R.cache.

The R.utils methods are basically "clever" wrappers around
load()/save() in the 'base' package that does not rely on saving and
loading the variable name but rather the object.  To save multiple
objects you have wrap them up in a list structure or in an
environment.  Example:

x <- 1:100
saveObject(x, file="foo.RData")
y <- loadObject("foo.RData")
stopifnot(identical(x,y))

u <- list(x=x, y=y)
saveObject(u, file="bar.RData")
v <- loadObject("bar.RData")
stopifnot(identical(u,v))

The R.cache methods let you store objects/results to a file cache
without having to worry about filenames.  Instead the objects are
identified by lookup keys generated from other R objects.  This is
useful for temporary/semi-temporary storing of results, especially
computationally expensive results.  The file cache is persistent
between sessions.  Example:

x <- 1:100
key <- list("x")
saveCache(x, key=key)
y <- loadCache(key)
stopifnot(identical(x,y))

u <- list(x=x, y=y)
key <- list("u")
saveCache(u, key=key)
v <- loadCache(key)
stopifnot(identical(u,v))

Although not of immediate interest, the pathname of the above cache
files can be found by
findCache(key), e.g.
"~/.Rcache/78488a47006df5d333db9e200fc539c5.Rcache".  There are
methods for specifying the root of the file cache, and having
different subdirectories for different projects.

The above example is not showing the full power of using R.cache.
Instead consider this example:

slowFcn <- function(x, y, force=FALSE) {
  # Cached results?
  key <- list(x=x, y=y)
  if (!force) {
res <- loadCache(key=key)
if (!is.null(res))
  return(res);
  }

  # Emulate a computational expensive calculation
  Sys.sleep(10)

  res <- list(x=x, y=y, xy=x*y)

  # Save to cache
  saveCache(res, key=key)

  res
}

# First call takes time
> system.time(res1 <- slowFcn(x=1, y=2))
   user  system elapsed
  0   0  10

# All successive calls with the same arguments are instant
> system.time(res2 <- slowFcn(x=1, y=2))
   user  system elapsed
   0.020.000.01

> stopifnot(identical(res1, res2))

Cheers

Henrik

On 10/12/2007, Talbot Katz <[EMAIL PROTECTED]> wrote:
>
> Hi.
>
> I have a procedure that reads a directory, loops through a set of particular 
> .RData files, loading each one, and feeding its object(s) into a function, as 
> follows:
>
> cvListFiles<-list.files(fnDir);
> for(i in grep(paste("^",pfnStub,".*\\.RData$",sep=""),cvListFiles)){
> load(paste(fnDir,cvListFiles[i],sep="/"));
> myFunction(rliObject);
> rm(rliObject);
> };
>
> where fnDir is the directory I'm reading, and pfnStub is a string that begins 
> the name of each of the files I want to load.  As you can see, I'm assuming 
> that each of the selected .RData files contains an object named "rliObject" 
> and I'm hoping that nothing in any of the files I'm loading overwrites an 
> object in my environment.  I'd like to clean this up so that I can extract 
> the object(s) from each data file, and feed them to my function, whatever 
> their names are, without corrupting my environment.  I'd appreciate any 
> assistance.  Thanks!
>
> --  TMK  --212-460-5430 home917-656-5351 cell
> [[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] matrix graph

2007-12-11 Thread Dylan Beaudette
On Tuesday 11 December 2007, threshold wrote:
> Hi All, simple question:
> do you know how to graph the following object/matrix in a 'surface manner':
>
>   [,1] [,2] [,3][,4]   [,5][,6]
> [1,] -0.154 -0.065 0.129 0.637 0.780 0.221
> [2,]  0.236  0.580 0.448 0.729 0.859 0.475
> [3,]  0.401  0.506 0.310 0.650 0.822 0.448
> [4,]  0.548  0.625 0.883 0.825 0.945 0.637
> [5,]  0.544  0.746 0.823 0.877 0.861 0.642
> [6,]  0.262  0.399 0.432 0.620 0.711 0.404
>
> will be very grateful for hints.
>
> rob

?image

-- 
Dylan Beaudette
Soil Resource Laboratory
http://casoilresource.lawr.ucdavis.edu/
University of California at Davis
530.754.7341

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

2007-12-11 Thread Tony Plate
Try these:

 > x <- matrix(rnorm(100), ncol=10)
 > persp(x)
 > contour(x)

Also, look at the R graph gallery: http://addictedtor.free.fr/graphiques/

-- Tony Plate

threshold wrote:
> Hi All, simple question: 
> do you know how to graph the following object/matrix in a 'surface manner':
> 
>   [,1] [,2] [,3][,4]   [,5][,6]
> [1,] -0.154 -0.065 0.129 0.637 0.780 0.221
> [2,]  0.236  0.580 0.448 0.729 0.859 0.475
> [3,]  0.401  0.506 0.310 0.650 0.822 0.448
> [4,]  0.548  0.625 0.883 0.825 0.945 0.637
> [5,]  0.544  0.746 0.823 0.877 0.861 0.642
> [6,]  0.262  0.399 0.432 0.620 0.711 0.404
> 
> will be very grateful for hints.
> 
> rob

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] ggplot - Setting the y-scale in a bar plot

2007-12-11 Thread hadley wickham
Hi Pedro,

What's the problem exactly?  You'll need to compute the range
yourself, and then use scale_y_continuous as you have below.

(Also you can abbreviate the bar chart plotting command to:
qplot(x, y, data=plotdata, geom="bar", stat="identity"))

Hadley

On 12/11/07, Pedro de Barros <[EMAIL PROTECTED]> wrote:
> Dear All (probably Hadley),
>
> I am now trying to customise some plots using a bar geom.
>
> I do not want to use the default binning statistic, but rather
> calculate the bar heigths separately. I do manage this, but for
> comparison purposes I would like to have a set of plots all with the
> same y-axis height. But I do not seem to find out how to fix the
> scale of the y-axis in this case.
> Any tips?
> Using R 2.6.1 on Windows.
>
> Thanks for any help,
> Pedro
>
> I attach below the code I am using:
> plotdata<-data.frame(x=factor(2:8), y=0.1*(2:8))
> plot1<-ggplot()
> plot1<-plot1+layer(data=plotdata,
> mapping=aes_string(x='x',y='y'),geom='bar', stat='identity')
>
> RangeY <-c(0,1)
> YBreaks <- (0:10)*diff(RangeY)/10
> YTickLabels<- as.character(YBreaks)
>
> plot2 <- plot1 + scale_y_continuous(limits=RangeY, breaks=YBreaks,
> labels=YTickLabels, expand=c(0,0))
> print(plot2)
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>


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

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


Re: [R] ggplot - Setting the y-scale in a bar plot

2007-12-11 Thread Pedro de Barros
Hi Hadley,

Well, the problem seems to be that ggplot is not recognizing the 
scale when set by scale_y_continuous, the maximum value stays exactly 
at the data range, irrespective of what I provide as range.
I am not familiar yet with proto, therefore I do have some difficulty 
delving into the code to find out exactly what is wrong, but I hope 
you can tell if I am doing something pretty stupid, or f it is a 
feature or a bug...

Cheers,
Pedro
At 21:15 2007/12/11, you wrote:
>Hi Pedro,
>
>What's the problem exactly?  You'll need to compute the range
>yourself, and then use scale_y_continuous as you have below.
>
>(Also you can abbreviate the bar chart plotting command to:
>qplot(x, y, data=plotdata, geom="bar", stat="identity"))
>
>Hadley
>
>On 12/11/07, Pedro de Barros <[EMAIL PROTECTED]> wrote:
> > Dear All (probably Hadley),
> >
> > I am now trying to customise some plots using a bar geom.
> >
> > I do not want to use the default binning statistic, but rather
> > calculate the bar heigths separately. I do manage this, but for
> > comparison purposes I would like to have a set of plots all with the
> > same y-axis height. But I do not seem to find out how to fix the
> > scale of the y-axis in this case.
> > Any tips?
> > Using R 2.6.1 on Windows.
> >
> > Thanks for any help,
> > Pedro
> >
> > I attach below the code I am using:
> > plotdata<-data.frame(x=factor(2:8), y=0.1*(2:8))
> > plot1<-ggplot()
> > plot1<-plot1+layer(data=plotdata,
> > mapping=aes_string(x='x',y='y'),geom='bar', stat='identity')
> >
> > RangeY <-c(0,1)
> > YBreaks <- (0:10)*diff(RangeY)/10
> > YTickLabels<- as.character(YBreaks)
> >
> > plot2 <- plot1 + scale_y_continuous(limits=RangeY, breaks=YBreaks,
> > labels=YTickLabels, expand=c(0,0))
> > print(plot2)
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
>
>
>--
>http://had.co.nz/

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


[R] Writing a file to the disk

2007-12-11 Thread Thomas L Jones, PhD
I am having difficulty writing the code for the following operation:
I have a numeric vector pred_out of length 156. (N = 156). Under Windows XP, 
I need to write it to the disk in text format. Perhaps some kind soul would 
provide the code fragment. The file name is sheet_vec.txt. Please see [1] 
for the complete pathname.

Each number to be written out has the following format:

LL.RR where LL is the integral part and RR is the fractional part to 
six decimal places. Example: "10.226207" The integral part, LL, is a maximum 
of two digits long. All numbers are positive.

Another hypothetical example:

10.226207
 6.556988
 4.395678
etc. Each number is to be on a separate line. Please correct me if I am 
wrong: A \n (newline) character ends each line.

After writing the file, it can be closed but not destroyed. (What I plan to 
do next is copy and paste the pred_out data into a spreadsheet.) Compressed 
formats (zip, etc.) should be avoided if possible.

Your ideas?

Tom Jones

[1] The full Windows pathname is:

C:/Documents and Settings/Tom/My Documents/Election Day Study Nov 7, 06/
  > sheet_vec.txt

Sorry, but the pathname is too long to fit on one line.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Writing a file to the disk

2007-12-11 Thread Duncan Murdoch
On 11/12/2007 5:13 PM, Thomas L Jones, PhD wrote:
> I am having difficulty writing the code for the following operation:
> I have a numeric vector pred_out of length 156. (N = 156). Under Windows XP, 
> I need to write it to the disk in text format. Perhaps some kind soul would 
> provide the code fragment. The file name is sheet_vec.txt. Please see [1] 
> for the complete pathname.
> 
> Each number to be written out has the following format:
> 
> LL.RR where LL is the integral part and RR is the fractional part to 
> six decimal places. Example: "10.226207" The integral part, LL, is a maximum 
> of two digits long. All numbers are positive.
> 
> Another hypothetical example:
> 
> 10.226207
>  6.556988
>  4.395678
> etc. Each number is to be on a separate line. Please correct me if I am 
> wrong: A \n (newline) character ends each line.
> 
> After writing the file, it can be closed but not destroyed. (What I plan to 
> do next is copy and paste the pred_out data into a spreadsheet.) Compressed 
> formats (zip, etc.) should be avoided if possible.
> 
> Your ideas?
> 
> Tom Jones
> 
> [1] The full Windows pathname is:
> 
> C:/Documents and Settings/Tom/My Documents/Election Day Study Nov 7, 06/
>   > sheet_vec.txt
> 
> Sorry, but the pathname is too long to fit on one line.

Get the formatted numbers you want in a character vector, then use 
writeLines to write it out.  For example:

x <- rnorm(20)
text <- sprintf("%9.6f", x)
writeLines(text, file.choose())

This will open a file selection directory where you can navigate to the 
correct folder and enter the filename.  Alternatively, you could put the 
whole path to the file in place of file.choose().  As a third choice, 
you could just use "clipboard"; on Windows, this will write the text 
directly into the clipboard, and you can paste from there to your 
spreadsheet.

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] Using the same y-axis range for each plot in "plot.ts"

2007-12-11 Thread Ugur Ozdemir
Hi,

I would like to plot multiple time-series plots
separately in the same window but I would like to have
the same y-axis range for all of the plots for the
sake of comparison. I am pretty sure there is a quick
way to do it in plot.ts which I could not find.

Any help is very much appreciated.

Ugur



Microsoft gives you windows, Linux gives you the whole house.


  

Be a better friend, newshound, and

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


Re: [R] Using the same y-axis range for each plot in "plot.ts"

2007-12-11 Thread Gabor Grothendieck
Try using plot.zoo from the zoo package.  This plots them
all within the range 3000 to 5000:

library(zoo)
plot(as.zoo(EuStockMarkets), ylim = c(3000, 5000))


On Dec 11, 2007 6:44 PM, Ugur Ozdemir <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I would like to plot multiple time-series plots
> separately in the same window but I would like to have
> the same y-axis range for all of the plots for the
> sake of comparison. I am pretty sure there is a quick
> way to do it in plot.ts which I could not find.
>
> Any help is very much appreciated.
>
> Ugur
>
>
>
> Microsoft gives you windows, Linux gives you the whole house.
>
>
>  
> 
> Be a better friend, newshound, and
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] tm package - how to transform a TermDocMatrix to a data.frame

2007-12-11 Thread Filipe Almeida
Hi to all,

I'm using the tm package in a Windows machine.

This is my sample:
>tts1 <- TermDocMatrix(tts, weighting="tf-idf")
>typeof(tts1)
[1] "S4"

How can i transform or put the tts1 TermDocMatrix in a simple data.frame or
simple matrix. I need to compute some functions. For example, I need to
calculate the euclidian distance:
>dist(tts1dist(x, method = "euclidean")

Thanks in advance!

Filipe Almeida

[[alternative HTML version deleted]]

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


[R] How to plot the grid figure using R?

2007-12-11 Thread Jian Zhang
Now I have the forest plot data with x, y locations, and I measured the DBH for 
every indivicuals.

The data looks like that:
x=runif(100,0,100)
y=runif(100,0,100)
dbh=runif(100,1,100)
rdata=data.frame(x,y,dbh)
> rdata[1:5,]
   x y  dbh
1 99.5354145  1.412844 34.10112
2  0.8259361 87.737036 39.12914
3  6.5678613 65.699032 22.55990
4 67.2987881 72.053877 45.83978
5  2.2491372 23.622898 68.77065

My question is: How can I plot the grid (25¡Á25,5¡Á5,...) figure by DBH?
Can you introduce a simply method to do it by R language? I know that it can be 
done very easy by the software ArcGis.







Thanks very much.

[[alternative HTML version deleted]]

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


[R] Markov Chain Monte Carlo (MCMR) in R for spatial simulation.

2007-12-11 Thread Milton Cezar Ribeiro
Dear all,

I would like to know if is there some MCMR capability (functions) develped to 
improve spatial explicit landscape simulations in R. 

Kind regards,

miltinho
Brazil.



 para armazenamento!

[[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] postResample R² and lm() R²

2007-12-11 Thread Max Kuhn
On Dec 11, 2007 3:35 PM, Giovane <[EMAIL PROTECTED]> wrote:

>
> So here comes my doubt: why do I have an value of 67.52% for R² when
> creating the model(that is , the model explains 67.52% of the data) and
> when I use this same model on the same input data, why does postResample
> return a very different value associated to R²?
>

Let's get in the WayBack machine and return to 4 days ago when I said:

> As has been previously noted on this list, there are a number of
> formulas for R-squared. This function uses the square of the
> correlation between the observed and predicted. The next version of
> caret will offer a choice of formulas.

For your data:

> cor(prediction, input$TOTAL)^2
[1] 0.3300378

For R-squared, summary.lm uses

   ans$r.squared <- mss/(mss + rss)
   ans$adj.r.squared <- 1 - (1 - ans$r.squared) * ((n - df.int)/rdf)

and for your data rdf = 31, df.int = 0 and n = 35.

In other words, the Rsquared estimate form summary.lm adjusts for the
degrees of freedom and postResample does not.

Why doesn't it use the df? In ?postResample you would see

"Note that many models have more predictors (or parameters) than data
points, so the typical mean squared error denominator (n - p) does not
apply. Root mean squared error is calculated using sqrt(mean((pred -
obs)^2)). Also, R-squared is calculated as the square of the
correlation between the observed and predicted outcomes."

Since caret is useful for comparing different types of models, we use
biased estimate of the root MSE since we would like to directly
compare the RMSE from different models (say a linear regression and a
support vector machine). Many of these models do not have an explicit
number of parameters, so we use

   mse <- mean((pred - obs)^2)


Max

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


[R] Efron's locfdr package - a component missing

2007-12-11 Thread NikTuz

Hello:

Could you possibly help me.
In Efron's 2004 paper "Selection and Estimation ..."
it was mentioned that so-called effect density estimate, denoted by g1(mu)
was included in the locfdr package. However, I can't find it in the
description
of the package. Any suggestions?

Sincerely,
Nik
-- 
View this message in context: 
http://www.nabble.com/Efron%27s-locfdr-package---a-component-missing-tp14287868p14287868.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] Enc: Res: How to plot the grid figure using R?

2007-12-11 Thread Milton Cezar Ribeiro
Dear Jian, 
 
I would like help you but I need that you explain a little bit about what you 
really want. 
Sorry ask you again, but may be I don´t understood because my difficulties on 
english.
 
Anyway, try this:
 
require(akima)
x=runif(100,0,100)
y=runif(100,0,100)
dbh=runif(100,1,100)
rdata=data.frame(x,y,dbh)
rdata.interp<-interp(rdata$x, rdata$y, rdata$dbh)
image(rdata.interp)


Of course you can output to ASCGRID using adehabitat package
 
Kind regards,
 
miltinho
Brazil

- Mensagem original 
De: Jian Zhang <[EMAIL PROTECTED]>
Para: R-help <[EMAIL PROTECTED]>; R_GEO <[EMAIL PROTECTED]>
Enviadas: Terça-feira, 11 de Dezembro de 2007 22:00:48
Assunto: [R] How to plot the grid figure using R?

Now I have the forest plot data with x, y locations, and I measured the DBH for 
every indivicuals.

The data looks like that:
x=runif(100,0,100)
y=runif(100,0,100)
dbh=runif(100,1,100)
rdata=data.frame(x,y,dbh)
> rdata[1:5,]
  xy  dbh
1 99.5354145  1.412844 34.10112
2  0.8259361 87.737036 39.12914
3  6.5678613 65.699032 22.55990
4 67.2987881 72.053877 45.83978
5  2.2491372 23.622898 68.77065

My question is: How can I plot the grid (25~25,5~5,...) figure by DBH?
Can you introduce a simply method to do it by R language? I know that it can be 
done very easy by the software ArcGis.

    
    
    
    


Thanks very much.

[[alternative HTML version deleted]]




-Anexo incorporado-

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







armazenamento!



 para armazenamento!

[[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] Sys.setlocale() and text()

2007-12-11 Thread Ed Merkle
Dear HelpeRs,

I have a question about the Sys.setlocale() command and plotting.  I am 
running Windows XP, with R 2.6.1.  My default locale is English_United 
States.1252.

I am trying to add a lowercase sigma to a plot using the following code:

Sys.setlocale("LC_CTYPE","greek")
plot(1:10,1:10)
text(4,3,"\xF3")


For R 2.6.1, this code gives me the glyph from my default (1252) instead 
of from the 1253 codes.  For an older version of R (2.3.0) on the same 
computer, this code gives me the lowercase sigma that I wanted.  I have 
been unable to pinpoint what has changed.  Thanks for the help, and I 
apologize if I am missing something obvious.


-- 
Ed Merkle, PhD
Assistant Professor
Dept. of Psychology
Wichita State University
Wichita, KS 67260

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

2007-12-11 Thread Wayne Aldo Gavioli

Hello all,


I seem to be having a problem importing a data set from Excel into R.  I'm using
the "read.table" command to import the data with the following line of code:

> newborn<-read.table("newborn edit.csv", header=T, sep=",")


where "newborn edit.csv" is the name of the file.  Unfortunately, I'm getting
back the following error message:


"Error in scan(file,, what, nmax, sep, dc, quote, skip, nlines, na.string, :
line 528 did not have 44 elements"


As far as I can tell, line 528 of the spreadsheet table does have the same
number of elements as the other rows - by chance can this error message mean
anything else?  Also, is there an easier way to import data from R into Excel
using a single line of R code?


Thanks,


Wayne

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

2007-12-11 Thread jim holtman
?count.fields

count.fields will tell you how many items are in each line.  As you
said, they should all be the same, but this will confirm it.

field.count <- count.fields("newborn edit.csv", sep=",")
table(field.count)  # determine count of the fields on a line

On Dec 11, 2007 7:15 PM, Wayne Aldo Gavioli <[EMAIL PROTECTED]> wrote:
>
> Hello all,
>
>
> I seem to be having a problem importing a data set from Excel into R.  I'm 
> using
> the "read.table" command to import the data with the following line of code:
>
> > newborn<-read.table("newborn edit.csv", header=T, sep=",")
>
>
> where "newborn edit.csv" is the name of the file.  Unfortunately, I'm getting
> back the following error message:
>
>
> "Error in scan(file,, what, nmax, sep, dc, quote, skip, nlines, na.string, :
> line 528 did not have 44 elements"
>
>
> As far as I can tell, line 528 of the spreadsheet table does have the same
> number of elements as the other rows - by chance can this error message mean
> anything else?  Also, is there an easier way to import data from R into Excel
> using a single line of R code?
>
>
> Thanks,
>
>
> Wayne
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

What is the problem you are trying to solve?

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

2007-12-11 Thread NikTuz


Hello:

Could someone share the info about how these two packages compare
to each other. I take it fdrtool is supposed to be "better", but I'm not
sure
if it is so.

Nik
-- 
View this message in context: 
http://www.nabble.com/locfdr-VS-fdrtool-tp14288241p14288241.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] Importing Large Dataset into Excel

2007-12-11 Thread Wayne Aldo Gavioli
Sorry, the title of this should read "From Excel into R".


Quoting Wayne Aldo Gavioli <[EMAIL PROTECTED]>:

>
> Hello all,
>
>
> I seem to be having a problem importing a data set from Excel into R.  I'm
> using
> the "read.table" command to import the data with the following line of code:
>
> > newborn<-read.table("newborn edit.csv", header=T, sep=",")
>
>
> where "newborn edit.csv" is the name of the file.  Unfortunately, I'm getting
> back the following error message:
>
>
> "Error in scan(file,, what, nmax, sep, dc, quote, skip, nlines, na.string, :
> line 528 did not have 44 elements"
>
>
> As far as I can tell, line 528 of the spreadsheet table does have the same
> number of elements as the other rows - by chance can this error message mean
> anything else?  Also, is there an easier way to import data from R into Excel
> using a single line of R code?
>
>
> Thanks,
>
>
> Wayne
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Install from Local Zip

2007-12-11 Thread morphwj
To install from a local zip file, install.packages option repos=NULL.  Then, 
how can dependencies of the local zip file, which are located in the repository 
of contributor packages, be automatically installed?

Or, is there a better way than to tell the person installing from local zip 
what the dependent files are, and to install them from the repository first?
Bill Morphet
[[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] Install from Local Zip

2007-12-11 Thread Prof Brian Ripley
On Wed, 12 Dec 2007, [EMAIL PROTECTED] wrote:

> To install from a local zip file, install.packages option repos=NULL. 
> Then, how can dependencies of the local zip file, which are located in 
> the repository of contributor packages, be automatically installed?

They cannot.  You need a repository to know about dependencies, which are 
in the PACKAGES file.

> Or, is there a better way than to tell the person installing from local 
> zip what the dependent files are, and to install them from the 
> repository first?

Yes, create a local repository and use a file:// URL to access it. 
Details are in the R-admin manual (and in the archives of this list or 
R-devel).


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

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

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


Re: [R] 00LOCK error with site-library

2007-12-11 Thread Mark W Kimpel
I'm still having problems with this 00LOCK error. Tonight I recompiled 
R-devel from scratch, created a new site-library directory after moving 
the old one to scratch storage, and tried reinstalling my packages. 13 
out of 290 packages successfully reinstalled and, once again, 00LOCK has 
appeared.

I tried to hack around this by installing packages one at a time, each 
time looking for 00LOCK and, if present, unlinking it recursively. This 
fails, although I can unlink other packages with identical permissions 
from within R. Outside of R, in the bash shell, I can rm -r 00LOCK 
without any problems. What follows is just some output demonstrating this.

Why does unlink not work for this one particular directory?
Mark

  x <- unlink("00LOCK", recursive = TRUE)
 > x
[1] 1 # unlink fails
 > dir()
  [1] "00LOCK"  "acepack"
  [3] "affxparser"  "affyio"
  [5] "AffymetrixDataTestFiles" "akima"
  [7] "amap""aws"
  [9] "Biobase" "hapmap100kxba"
[11] "kernlab" "plasmodiumanophelescdf"
[13] "R.css"   "som"
[15] "stjudem" "xlahomology"
 > ?unlink
 > y <- unlink(x = "00LOCK", recursive = TRUE)
 > y
[1] 1
 > y <- unlink(x = "acepack", recursive = TRUE)
 > y
[1] 0 #u unlink succeeds

 From the command line:

ls -al

drwxr-xr-x   3 mkimpel psych 4096 2007-12-11 23:13 00LOCK
drwxr-xr-x  13 mkimpel psych 4096 2007-12-11 23:12 affxparser
drwxr-xr-x  10 mkimpel psych 4096 2007-12-11 23:12 affyio



Mark W. Kimpel MD  ** Neuroinformatics ** Dept. of Psychiatry
Indiana University School of Medicine

15032 Hunter Court, Westfield, IN  46074

(317) 490-5129 Work, & Mobile & VoiceMail
(317) 204-4202 Home (no voice mail please)

mwkimpelgmailcom

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

2007-12-11 Thread Gabor Grothendieck
Try this:

plot(1:10, main = quote(sigma ^ 2))


On Dec 11, 2007 10:09 PM, Ed Merkle <[EMAIL PROTECTED]> wrote:
> Dear HelpeRs,
>
> I have a question about the Sys.setlocale() command and plotting.  I am
> running Windows XP, with R 2.6.1.  My default locale is English_United
> States.1252.
>
> I am trying to add a lowercase sigma to a plot using the following code:
>
> Sys.setlocale("LC_CTYPE","greek")
> plot(1:10,1:10)
> text(4,3,"\xF3")
>
>
> For R 2.6.1, this code gives me the glyph from my default (1252) instead
> of from the 1253 codes.  For an older version of R (2.3.0) on the same
> computer, this code gives me the lowercase sigma that I wanted.  I have
> been unable to pinpoint what has changed.  Thanks for the help, and I
> apologize if I am missing something obvious.
>
>
> --
> Ed Merkle, PhD
> Assistant Professor
> Dept. of Psychology
> Wichita State University
> Wichita, KS 67260
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Efron's locfdr package - a component missing

2007-12-11 Thread NikTuz


 I got in touch with Prof. Efron himself and he said that that part indeed
was not
included in the package, so there's nothing to be done.
-- 
View this message in context: 
http://www.nabble.com/Efron%27s-locfdr-package---a-component-missing-tp14287868p14289411.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] Markov Chain Monte Carlo (MCMR) in R for spatial simulation.

2007-12-11 Thread Liviu Andronic
On 12/12/07, Milton Cezar Ribeiro <[EMAIL PROTECTED]> wrote:
> Dear all,
>
> I would like to know if is there some MCMR capability (functions) develped to 
> improve spatial explicit landscape simulations in R.

Check the CRAN "Spatial" View [1]. Also search on this page [2] for "markov".

Liviu

[1] http://cran.at.r-project.org/src/contrib/Views/
[2] http://cran.at.r-project.org/src/contrib/PACKAGES.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.


[R] Book: The New S Language

2007-12-11 Thread Chris.H. Snow
I'm struggling a bit with R with understanding functions and what's going
on under the hood.

For example, I was given this snippet of code via this mailing list:

DF <- data.frame(A =c("A", "A", "A", "B", "C"), B=c(1,1,2,2,0))
g <- paste(DF$A, DF$B)
s <- split(DF, g)

split appears to be taken the string provided by paste, e.g. "A 1", and
then deciding that the first character "A" in this string relates to DF$A,
and the second character "1" to DF$B.

The split help pages don't really tell me why split is working like this -
maybe I'm just looking in the wrong place in the help page.

I've got plenty of books on R, but only one of them gives a bit of info on
the use of split - not in enough detail though.  Does the book referenced
in the help pages ("The New S Language") give more insight into
this and other functions?

Will I just get an Aha! moment with R after using it for a while?

Thanks in advance...

Chris

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

2007-12-11 Thread Petr PIKAL
Hi

[EMAIL PROTECTED] napsal dne 12.12.2007 07:45:54:

> I'm struggling a bit with R with understanding functions and what's 
going
> on under the hood.
> 
> For example, I was given this snippet of code via this mailing list:
> 
> DF <- data.frame(A =c("A", "A", "A", "B", "C"), B=c(1,1,2,2,0))
> g <- paste(DF$A, DF$B)
> s <- split(DF, g)
> 
> split appears to be taken the string provided by paste, e.g. "A 1", and
> then deciding that the first character "A" in this string relates to 
DF$A,
> and the second character "1" to DF$B.
> 
> The split help pages don't really tell me why split is working like this 
-
> maybe I'm just looking in the wrong place in the help page.

Maybe you misunderstand what split does:

> DF <- data.frame(A =c("A", "A", "A", "B", "C"), B=c(1,1,2,2,0))
a data frame with 2 columns

> g <- paste(DF$A, DF$B)

a character vector (which is internally turned into factor). And split 
splits your data frame DF into groups according to levels of "g". It does 
not at all lookup into columns of your data frame (and the help page does 
not even give you a suspicion that it shall behave like that).

first sentence in help page tells you
split divides the data in the vector x into the groups defined by f.

compare your result with
> g.f<-factor(g)
> str(g.f)
 Factor w/ 4 levels "A 1","A 2","B 2",..: 1 1 2 3 4
> g.n<-as.numeric(g.f)
> g.n
[1] 1 1 2 3 4

split(DF, g.f)
split(DF, g.n)

And try to explain with your idea how split works this
DF$A<-rnorm(5)
s <- split(DF, g)

Regards
Petr

> 
> I've got plenty of books on R, but only one of them gives a bit of info 
on
> the use of split - not in enough detail though.  Does the book 
referenced
> in the help pages ("The New S Language") give more insight into
> this and other functions?
> 
> Will I just get an Aha! moment with R after using it for a while?
> 
> Thanks in advance...
> 
> Chris
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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 : change value in rnw file to generate multiple "single" reports ?

2007-12-11 Thread Ptit_Bleu



Greg wrote :
Hope this helps,

Sure it will !
Thanks again,
Have a nice day,
Ptit Bleu.
-- 
View this message in context: 
http://www.nabble.com/Sweave-%3A-change-value-in-rnw-file-to-generate-multiple-%22single%22-reports---tp14256204p14290306.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.