Re: [R] row-wise conditional update in dataframe

2008-01-22 Thread jiho

On 2008-January-22  , at 03:10 , Jon Erik Ween wrote:

> That got me there. I suppose R prefers absolute field references in
> scripts rather than macrosubstitutions of field names like you would
> do in pearl or shell scripts?

no, actually, the problem is that apply works on arrays/matrices[1],  
not data.frames. So it converts the rows of your data.frame in an  
array instead of using a one row data.frame, hence you cannot refer to  
the elements of this array by name.
This behavior has also bitten me several times and I would love to  
have an apply function that works on data.frames directly. Is there  
such a modified apply in some package?

[1] ?apply says
"If X is not an array but has a dimension attribute, apply attempts to  
coerce it to an array via as.matrix if it is two-dimensional (e.g.,  
data frames) or via as.array."

JiHO
---
http://jo.irisson.free.fr/

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


Re: [R] Reading Genepop files

2008-01-22 Thread H. Skaug
Thanks, but I think this function (in the the ARES package) reads
a dataset in genepop input format, not the result file
from genepop.exe.

hans


On 1/21/08, Henrique Dallazuanna <[EMAIL PROTECTED]> wrote:
>
> Perhaps:
>
> http://finzi.psych.upenn.edu/R/library/ARES/html/read.genepop.html
>
> On 21/01/2008, H. Skaug <[EMAIL PROTECTED]> wrote:
> > Dear list,
> >
> > Does there exist R routines for reading output files from Genepop?
> >
> > (GENEPOP is a population genetics software package by Raymond & Rousset;
> > http://genepop.curtin.edu.au/ )
> >
> > I find several R packages that contain function for writing Genepop
> input
> > files, but
> > non that does the reverse.
> >
> > Regards,
> >
> > hans
> >
> > [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
>
>
> --
> Henrique Dallazuanna
> Curitiba-Paraná-Brasil
> 25° 25' 40" S 49° 16' 22" O
>

[[alternative HTML version deleted]]

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


[R] geometric transformation

2008-01-22 Thread jgarcia
Hi everyone,

I've got a set of thousands points (2D) located on a pixel image, and I
know that four points in this pixels image correspond to four points in a
real space on which I need to locate the mapping of all the thousand
source points from the pixel set.
For this I've got four reference points (corners.px), and the
corresponding four destination points (corners.r):

> corners.px
  [,1]  [,2]
[1,] 212.5 275.5
[2,] 562.5 275.5
[3,] 212.5 625.5
[4,] 562.5 625.5

> corners.r
   [,1]  [,2]
[1,] 139463  8386
[2,] 139579 -1294
[3,] 131921  8180
[4,] 132002 -1256

I think I must find a transformation matrix and apply this transformation
matrix to all the set in the pixel space, but cannot find the way to
contruct this transformation matrix.
I guess this is not a question just pertaining to R, but perhaps you can
help me with this.

Thank you and best regards!

Javier
-

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


Re: [R] Adding an Sweave Vignette to a package

2008-01-22 Thread Uwe Ligges
In R, type
  Sys.getenv("PATH")
and you will probably find that the PATH does not include the path of 
the pdflatex executable of the mikTeX distribution.

Uwe


Doran, Harold wrote:
> Jim 
> 
> First thanks for your patience. I use MikTex as well. I do have both
> (texti2dvi and pdflatex) on my local machine. I copied and pasted the
> code below and stepped through it. I think this break down with the
> following error. Indeed, I think there is a path problem. 
> 
> However, I don't see a resolution in either Writing R Extensions or the
> Leisch paper. So, I'm not quite sure what path to modify and/or how.
> 
> Error in texi2dvi("TheVignette.tex", pdf = TRUE) : 
>   unable to run pdflatex on 'TheVignette.tex'
> In addition: Warning message:
> In system(paste(shQuote(latex), "-interaction=nonstopmode", texfile)) :
>   "pdflatex" not found 
> 
>> -Original Message-
>> From: James W. MacDonald [mailto:[EMAIL PROTECTED] 
>> Sent: Monday, January 21, 2008 4:53 PM
>> To: Doran, Harold
>> Cc: R Help
>> Subject: Re: [R] Adding an Sweave Vignette to a package
>>
>> What TeX variant are you using? If texi2dvi() can't find 
>> texi2dvi, it tries to fall back on pdflatex which has to be 
>> in the path.
>>
>> I have always had good luck with MikTeX, which does have texi2dvi.
>>
>> You could always try
>>
>> library(tools)
>> Sweave("TheVignette.Rnw")
>> debug(texi2dvi)
>> texi2dvi("TheVignette.tex", pdf=TRUE)
>>
>> and step through to see where it fails, although on the 
>> surface it looks like a path problem.
>>
>> Best,
>>
>> Jim
>>
>>
>>
>> Doran, Harold wrote:
>>> There is now and it looks like I got through the first 
>> phase. But, now 
>>> I get the error below.
>>>
>>> * DONE (MiscPsycho)
>>> * creating vignettes ... ERROR
>>> Loading required package: statmod
>>> Below is what alpha *would be* if the item were removed
>>>
>>> Error in texi2dvi(file = bft, pdf = TRUE, clean = FALSE, quiet = 
>>> quiet)
>>> :
>>>   unable to run pdflatex on 'MP.tex'
>>> Calls: buildVignettes -> texi2dvi
>>> In addition: Warning messages:
>>> 1: In readLines(f[1]) : incomplete final line found on 'MP.Rnw'
>>> 2: In system(paste(shQuote(latex), "-interaction=nonstopmode", 
>>> texfile))
>>> :
>>>   "pdflatex" not found
>>> Execution halted
>>>
>>> I do have pdflatex, it's what I use all of the time. 
>> However, how do I 
>>> point to it for this build process?
>>>
 -Original Message-
 From: James W. MacDonald [mailto:[EMAIL PROTECTED]
 Sent: Monday, January 21, 2008 4:09 PM
 To: Doran, Harold
 Cc: R Help
 Subject: Re: [R] Adding an Sweave Vignette to a package

 Hi Harold,

 Doran, Harold wrote:
> I'm finalizing development of a package that will include a
 vignette.
> Without the vignette, the package builds fine with no
 warnings and is
> ready for distribution. Now, I am following the directions for 
> developing vignettes "Sweave, Part II: Package Vignettes"
 by Friedrich
> Leisch.
>
> I am using a windows XP machine (other session info 
>> below). Here is 
> what I have done.
>
> 1) I add the 'inst/doc' directory to the package source tree.
> 2) I have added the following information in the preamble
 of the .Rnw
> file
>
> % \VignetteIndexEntry{An \texttt{R} Package for Miscellaneous 
> Psychometric Analyses} % \VignetteDepends{MiscPsycho, statmod} % 
> \VignetteKeyword{misc}
>
> 3) I then copy the file "MP.Rnw" to the 'inst/doc' directory.
> 4) I then run Rcmd build g:\MiscPsycho
>
> The process begins as usual and it even tries to create the
 vignette.
> However, it runs into an error at code chunk 1 
>> complaining that it 
> cannot find the function called simRasch(). This simRasch
 function is
> one of the functions developed for this package and one that will 
> exist only when the package is built. The build process is halted.
>
> I'm not sure how to handle this. Any advice is appreciated.
 Is there a library(MiscPsycho) at the beginning of that code chunk?

 Best,

 Jim


> Harold
>
>> sessionInfo()
> R version 2.6.1 (2007-11-26)
> 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] stats graphics  grDevices utils datasets  
>> methods   base
>
> other attached packages:
> [1] statmod_1.3.3
>
> loaded via a namespace (and not attached):
> [1] tools_2.6.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, repr

[R] ODE's in R

2008-01-22 Thread Markku Karhunen
Dear all,

Has anybody tried numerical solving of ODE's and/or transport equations 
in R? (Don't ask how we ended up in using R for this job, in the first 
place!)

More precisely, does anybody know any technical issue that could make 
the work insecure in the sense of propagation of errors? Is there any 
track of evidence that R is, in this kind of task, less reliable than 
e.g. MatLab? We use just a simple discretisation written in a for loop 
and a variable (i.e. user-fed) time step.

Maybe, I'm too neurotic about this, but I guess I just want some comfort 
after seeing a few particularly nasty orbits.

Best,
Markku Karhunen
National Public Health Institute,
Finland

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


Re: [R] Stationarity of a Time Series

2008-01-22 Thread Pfaff, Bernhard Dr.
Hello Stephen,

stationarity tests as well as unit root tests have been implemented in a
couple of packages. For instance, as already mentioned: tseries, but
also uroot, fUnitRoots and urca. See the annotated task view
"Econemtrics" and "Finance" for further information.

Best,
Bernhard 

>
>kpss.test in the tsereis package should do the trick
>
>On Jan 21, 2008 12:36 PM, stephen sefick <[EMAIL PROTECTED]> wrote:
>
>> Does anyone know of a test for stationarity of a time series, or like
>> all ordination techniques it is a qualitative assessment of a
>> quantitative result.  Books, papers, etc. suggestions welcome.
>> thanks
>>
>> Stephen
>>
>> --
>> Let's not spend our time and resources thinking about things that are
>> so little or so large that all they really do for us is puff 
>us up and
>> make us feel like gods.  We are mammals, and have not exhausted the
>> annoying little problems of being mammals.
>>
>>  
>  -K. Mullis
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>   [[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.
>
*
Confidentiality Note: The information contained in this ...{{dropped:10}}

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


Re: [R] Bugs through R in Mac

2008-01-22 Thread Uwe Ligges


Bill Northcott wrote:
> On 21/01/2008, at 10:00 PM, Uwe Ligges wrote:
>> Fredrik Lundgren wrote:
>>> Hello,
>>>
>>> I recently changed from Win XP to Mac OS X (10.5.1).
>>> Is there a way to run  Bugs (in any version) in R (R version 2.6.0
>>> (2007-10-03)) on this platform?
>>>
>>
>> Which way to "run Bugs in R" did you use in Windows?
>> On MacOS X, a solution that should work but is completely inelegant is
>> using the package R2WinBUGS, and running WinBUGS within DarWINE. There
>> are some rumors that OpenBUGS development will be forced within the next
>> couple of months, but I am not that confident that we will have a
>> natively working BRugs version on Mac OS X or Linux this year ...
> 
> I just posted a message about this on r-sig-mac.
> 
> I spent a little time on this late last year.
> 
> WinBUGS runs happily under DarWINE or the commercial package 
> CrossoverMac.  There is nothing inelegant about it.

It is inelegant in at least two points:
1. R2WinBUGS is a mess per se, we all want to use something that runs 
natively within R, such as BRugs or jags.
2. running the WinBUGS instance in xyz-WINE things does not make things 
faster and more elegant from my point of view.


> 
> R2WinBUGS is another can of worms.  The code to support running WinBUGS 
> in WINE on Linux or Mac is thoroughly broken.  The problem is in the 
> need to convert Windows paths to UNIX ones.  R2WinBUGS does this using 
> undocumented and unsupported features of some versions of WINE.  As is 
> the way with unsupported features these have been changed on recent 
> versions of WINE and broken R2WinBUGS.
> 
> The fix is not trivial, and the WINE support stuff in R2WinBUGS needs to 
> be completely rewritten.  I can see what needs to be done, and if I find 
> the time, I will fix it.

Contributions are welcome. I do not touch that xyz...-WINE conversion 
stuff at all.

Best wishes,
uwe


> You can also use JAGS ( http://www-fis.iarc.fr/~martyn/software/jags/ ) 
> which has now reached version 1.0.1 and has an R support package rjags.  
> I hope to post a fat Mac binary for this before the end of the week.  In 
> testing, this works on Leopard with a 32 bit R controlling a 64 bit JAGS 
> binary which is sort of cool.  Now all we need is to be able to run 
> multiple chains on different CPUs but there are some issues with the 
> RNGs from R which are used in JAGS.
> 
> Bill Northcott
>

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

2008-01-22 Thread Eleni Christodoulou
Hi all,

I am trying to install the package "GEOquery" in unix. I have downloaded the
standard version of R and this package is not contained in the default. I
know that I can select repositories under windows but I don't know how to do
it in unix. Does anyone have any idea on this?

Thank you in advance,
Eleni

[[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] R: determinants and inverses

2008-01-22 Thread Allan Clark
hello all
 
sorry for the following "none" R related question.
 
 
 
does anyone know of a reference to calculate the following identity:
 
|I + ABC|
 
where I is an identity matrix and A, B,C may not have to be square matrices?
 
 
you help will be greatly appreciated.
 
 
 
H. V. Henderson; S. R. Searle
SIAM Review, Vol. 23, No. 1. (Jan., 1981), pp. 53-60.
 
provides a result to calculate the inverse of I + ABC. (for those interested!!!)
 
thanking you in advance
 
 
Allan Clark

Lecturer in Statistical Sciences Department
University of Cape Town
7701 Rondebosch
South Africa
TEL (Office): +27-21-650-3228
FAX: +27-21-650-4773
http://web.uct.ac.za/depts/stats/aclark.htm 
 

[[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] Problems saving the workspace image

2008-01-22 Thread Ana Azevedo
Thanks for your help!
I change the starting directory to one I own. I start up R from the same
directory. Now it`s working.
Best regards,
Ana

-Mensagem original-
De: Prof Brian Ripley [mailto:[EMAIL PROTECTED] 
Enviada: segunda-feira, 21 de Janeiro de 2008 16:09
Para: Erin Hodgess
Cc: Ana Azevedo; r-help@r-project.org
Assunto: Re: [R] Problems saving the workspace image

On Mon, 21 Jan 2008, Erin Hodgess wrote:

> In Windows Vista, you have to "run as administrator".

Please don't: the point of not running as administrator is to protect you 
and your OS from rogue processes.  *If* you use a starting directory you 
own, there is no problem on Vista (for me, or many other Vista users).

>
> I ran into the same thing myself.
>
> Hope this helps!
> Sincerely,
> Erin
>
>
> On Jan 21, 2008 5:46 AM, Prof Brian Ripley <[EMAIL PROTECTED]> wrote:
>> On Mon, 21 Jan 2008, Ana Azevedo wrote:
>>
>>> Hi!
>>>
>>> I use R with Windows for a long time. In the last week I change to
Windows
>>> Vista. Now I can´t save the workspace image when I exit R. The system
>>> presents the following message "Unable to open .Rhistory". Does anyone
can
>>> help me?
>>
>> Did you change the shortcut from which you run R to start in a user
>> directory, as advised in the rw-FAQ?
>>
>> Start R, run 'getwd()' and check it is a directory which you own.
>> If not, alter the shortcut until it is.
>>
>>
>>>
>>> I thank you in advance,
>>>
>>> Ana
>>>
>>>
>>>
>>>
>>>   [[alternative HTML version deleted]]
>>>
>>>
>>
>> --
>> 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.
>>
>>
>
>
>
> --
> Erin Hodgess
> Associate Professor
> Department of Computer and Mathematical Sciences
> University of Houston - Downtown
> mailto: [EMAIL PROTECTED]
>

-- 
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] select repositories under linux

2008-01-22 Thread Gabor Csardi
Eleni, download the package (I assume you know where it is), 
on Linux you will need the source package. Then from R type

install.packages("", repos=NULL)

Gabor

On Tue, Jan 22, 2008 at 11:26:12AM +0200, Eleni Christodoulou wrote:
> Hi all,
> 
> I am trying to install the package "GEOquery" in unix. I have downloaded the
> standard version of R and this package is not contained in the default. I
> know that I can select repositories under windows but I don't know how to do
> it in unix. Does anyone have any idea on this?
> 
> Thank you in advance,
> Eleni
> 
>   [[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.

-- 
Csardi Gabor <[EMAIL PROTECTED]>UNIL DGM

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


Re: [R] geometric transformation

2008-01-22 Thread ONKELINX, Thierry
Javier,

You can use two lm-models for that. One for each coordinate. Then use
predict() to calculate the coordinates of the other points. And by the
way: four points is not very much data to calculate a transformation. I
mlight work if the image is not very much distorted and you have precise
measurement of the reference points coordinates.

corners.px <- matrix(c(212.5, 275.5, 562.5, 275.5, 212.5, 625.5, 562.5,
625.5), ncol = 2, byrow = TRUE)
corners.r <- matrix(c(139463, 8386, 139579, -1294, 131921, 8180, 132002,
-1256), ncol = 2, byrow = TRUE)
dataset <- data.frame(cbind(corners.px, corners.r))
colnames(dataset) <- c("X", "Y", "U", "V")
lm(U ~ X + Y, data = dataset)
lm(V ~ X + Y, data = dataset) 

HTH,

Thierry

PS R-sig-GEO would be more suitable for this kind of question.



ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium 
tel. + 32 54/436 185
[EMAIL PROTECTED] 
www.inbo.be 

Do not put your faith in what statistics say until you have carefully
considered what they do not say.  ~William W. Watt
A statistical analysis, properly conducted, is a delicate dissection of
uncertainties, a surgery of suppositions. ~M.J.Moroney

-Oorspronkelijk bericht-
Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Namens [EMAIL PROTECTED]
Verzonden: dinsdag 22 januari 2008 9:56
Aan: r-help@r-project.org
Onderwerp: [R] geometric transformation

Hi everyone,

I've got a set of thousands points (2D) located on a pixel image, and I
know that four points in this pixels image correspond to four points in
a
real space on which I need to locate the mapping of all the thousand
source points from the pixel set.
For this I've got four reference points (corners.px), and the
corresponding four destination points (corners.r):

> corners.px
  [,1]  [,2]
[1,] 212.5 275.5
[2,] 562.5 275.5
[3,] 212.5 625.5
[4,] 562.5 625.5

> corners.r
   [,1]  [,2]
[1,] 139463  8386
[2,] 139579 -1294
[3,] 131921  8180
[4,] 132002 -1256

I think I must find a transformation matrix and apply this
transformation
matrix to all the set in the pixel space, but cannot find the way to
contruct this transformation matrix.
I guess this is not a question just pertaining to R, but perhaps you can
help me with this.

Thank you and best regards!

Javier
-

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

2008-01-22 Thread Gavin Simpson
hits=-2.6 tests=BAYES_00
X-USF-Spam-Flag: NO

On Tue, 2008-01-22 at 11:26 +0200, Eleni Christodoulou wrote:
> Hi all,
> 
> I am trying to install the package "GEOquery" in unix. I have downloaded the
> standard version of R and this package is not contained in the default. I
> know that I can select repositories under windows but I don't know how to do
> it in unix. Does anyone have any idea on this?
> 
> Thank you in advance,
> Eleni

GEOquery is part of the Bioconductor project. See the web site for this
project for instructions on how to install bioconductor and associated
packages:

http://www.bioconductor.org/

Installation instructions for GEOquery appear to be here:

http://bioconductor.org/packages/2.1/bioc/html/GEOquery.html

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.


[R] R object as a function

2008-01-22 Thread Thomas Steiner
I want to use a function as an argument to ingtegrate it twice.
See the following (senseless) example of a double integration:

test<-function(sf,lo,up,rest) {
  innerFkn<-function(sf,lo) {
inte=integrate(f=sf,lower=lo,upper=4)
return( inte$value )
  }
  integral=integrate(f=innerFkn,lower=1,upper=2,sf=sf,lo=lo,up=up)
  return( integral$vlaue+rest )
}
test(sf=stepfun(c(0,1),c(2,-1,3)),lo=0,up=2,rest=12)

Why isn't it possible to define the "innerFkn" inside "test"?
"sf" is a stepfun, but it should possibly be any function.
How can I define some R object like a stepfun (depending on variables)
which can be evaluated like a function at some "lo"?
Thanks for help,
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.


Re: [R] ODE's in R

2008-01-22 Thread Martin Maechler
> "MK" == Markku Karhunen <[EMAIL PROTECTED]>
> on Tue, 22 Jan 2008 10:57:25 +0200 writes:

MK> Dear all,
MK> Has anybody tried numerical solving of ODE's and/or transport equations 
MK> in R? (Don't ask how we ended up in using R for this job, in the first 
MK> place!)

MK> More precisely, does anybody know any technical issue that could make 
MK> the work insecure in the sense of propagation of errors? Is there any 
MK> track of evidence that R is, in this kind of task, less reliable than 
MK> e.g. MatLab? 

No, there's no such track.
[ Matlab users coming to R may produce wrong R code
  by using 0:n-1 instead of 0:(n-1) ; but I don't assume this
  would be the case ]

MK>  We use just a simple discretisation written in a for loop 
MK> and a variable (i.e. user-fed) time step.

I don't think you should use your own code instead of "professional"
ODE solvers, such as the one in R package 'odesolve'

MK> Maybe, I'm too neurotic about this, but I guess I just want some 
comfort 
MK> after seeing a few particularly nasty orbits.

As we know ``from Chaos theory'', there can be delicate
inhereent and numerical problems in ODE solving..

Regards,
Martin Maechler, ETH Zurich

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


Re: [R] select repositories under linux

2008-01-22 Thread Henrique Dallazuanna
See setRepositories()

On 22/01/2008, Eleni Christodoulou <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I am trying to install the package "GEOquery" in unix. I have downloaded the
> standard version of R and this package is not contained in the default. I
> know that I can select repositories under windows but I don't know how to do
> it in unix. Does anyone have any idea on this?
>
> Thank you in advance,
> Eleni
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>


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

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

2008-01-22 Thread Thanjavur Bragadeesh

Hi,
 
I am trying a linear regression model where the dependent variable is the size 
of the heart corrected for the patient's height and weight. This is labelled as 
LAVI. The independent variables are race (european or non-eurpoean), age, sex 
(male or female) of the patient and whether they have diabetes and high blood 
pressure. sample size 2000 patients selected from a community.
 
when I model
model1<-lm(lavi~age+sex+race+diabetes+hypertension, data=tb1)
 and 
model2<-lm(lavi~age+sex+age*race+diabetes+hypertension, data=tb1)
 
in the first model race comes out as a significant predictor (p<0.005) where as 
in the second model race is not a significant predictor of lavi (p=.076)
 
in my dataset mean age is 55.2 years in the non-europeans and 56.7 years in the 
europeans (p <0.0001 by t.test). 
 
should I or should I not include the interaction (age*race) in the model. Is it 
an acceptable rule to put in interactions if there is a significant relation 
between the indepenedent variables in univariate analyses.
 
Many thanks
 
bragadeesh
_
Helping your favorite cause is as easy as instant messaging. You IM, we give.

[[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 Genepop files

2008-01-22 Thread Henrique Dallazuanna
Which is the output format of file?

On 22/01/2008, H. Skaug <[EMAIL PROTECTED]> wrote:
> Thanks, but I think this function (in the the ARES package) reads
> a dataset in genepop input format, not the result file
> from genepop.exe.
>
> hans
>
>
>
> On 1/21/08, Henrique Dallazuanna <[EMAIL PROTECTED]> wrote:
> > Perhaps:
> >
> >
> http://finzi.psych.upenn.edu/R/library/ARES/html/read.genepop.html
> >
> > On 21/01/2008, H. Skaug <[EMAIL PROTECTED]> wrote:
> > > Dear list,
> > >
> > > Does there exist R routines for reading output files from Genepop?
> > >
> > > (GENEPOP is a population genetics software package by Raymond & Rousset;
> > > http://genepop.curtin.edu.au/ )
> > >
> > > I find several R packages that contain function for writing Genepop
> input
> > > files, but
> > > non that does the reverse.
> > >
> > > Regards,
> > >
> > > hans
> > >
> > > [[alternative HTML version deleted]]
> > >
> > > __
> > > R-help@r-project.org mailing list
> > > https://stat.ethz.ch/mailman/listinfo/r-help
> > > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > > and provide commented, minimal, self-contained, reproducible code.
> > >
> >
> >
> > --
> > Henrique Dallazuanna
> > Curitiba-Paraná-Brasil
> > 25° 25' 40" S 49° 16' 22" O
> >
>
>


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

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


Re: [R] image/area plot

2008-01-22 Thread Henrique Dallazuanna
Perhaps you can do this:


On 21/01/2008, Marta Rufino <[EMAIL PROTECTED]> wrote:
>
>  Thank you very much for the help.
>
>
>
>  kk=data.frame(fact=letters[1:10],
> freq=c(5,1,10,2,10,7,5,10,30,20))
> res <- rep(kk[[1]], kk[[2]])
> resmat <- matrix(c(res), 10)
> image(1:10, 1:10, resmat, col=rainbow(20))
> grid(ncol(resmat), nrow(resmat))
>
>
>  Great! that is much better :-)
>  Still,... any idea about how to rearrange the matrix, in a way that the
> area of each letter is together (for example, in the fig. area 'f' and 'e'
> were split into two lines :-( )?


res1 <- do.call('rbind', lapply(split(c(res), c(res)),
function(x)append(x, rep(NA, max(table(res))-length(x)
image(t(res1), col=rainbow(20))
grid(30,10)


>
>
>  ##1
> text(expand.grid(seq_len(ncol(resmat)), seq_len(nrow(resmat))),
> as.character(res))
>
>  Excelent, this is very interesting code. Still, I wanted to have only one
> legend in each area.

pos1 <- t(sapply(unique(resmat), function(x)which(resmat==x, arr.ind=T)[1,]))
text(apply(pos1[!duplicated(pos1),][,-3], 2, as.numeric), labels=unique(res))



>
>  ##2
> pos <- lapply(apply(apply(resmat, 2, duplicated), 2,
> function(x)which(!x)), append, 11)
> for(j in 1:length(pos)){
>  rect(pos[[j]]-.5, j-.5, pos[[j]]-.5, j+.5, lwd=2)
> }
> abline(h=c(seq(1.5, 5.5, by=1), 8.5), lwd=2)
>
>
>  This is exactly it!!!
>
>
>  ##3
> plot(0, xlim=c(0,10), ylim=c(1, max(table(resmat))), type="n", xaxt="n")
> tb <- table(resmat)
> dis <- 0
> for(i in 1:10){
> rect(dis, seq(par("usr")[1], tb[i], by=1), dis+.8, seq(par("usr")[1],
> tb[i], by=1)+1)
> dis <- dis + 1
> }
> axis(1, at=0.5:9.5, labels=LETTERS[1:10])

image(1:10, 1:10, resmat, col=rainbow(20))
grid(ncol(resmat), nrow(resmat))
pos <- lapply(apply(apply(resmat, 2, duplicated), 2,
function(x)which(!x)), append, 11)
for(j in 1:length(pos)){
rect(pos[[j]]-.5, j-.5, pos[[j]]-.5, j+.5, lwd=7, col="white",
border=T, density=100)
}
abline(h=c(seq(1.5, 5.5, by=1), 8.5), lwd=7, col="white")

>
>  What I meant was using the image plot (or something similar). Maybe it is
> easier to show some examples in the net:... here is an example:
>
>  http://grammarpolice.net/archives/001387.php
>
>  I guess this could be accomplished by re-ordering the matrix values, so
> that the values are not in rows but clustered into boxes, I guess... but how
> to do this?
>
>
>  ##4
> I think that symbols function should be useful
>
>  points(expand.grid(seq_len(ncol(resmat)), seq_len(nrow(resmat))), c(res))
> #using your excelent code, I think this makes the job :-)
>
> Thank you very much,
> Best wishes,
> Marta
>
>
>  On 18/01/2008, Marta Rufino <[EMAIL PROTECTED]> wrote:
>
>
>  Yes, that is it, a square pie chart :-) I did not knew the name... sorry...
>
> Does anyone knows about it?
> Thank you very much,
> Best wishes,
> Marta
>
> hadley wickham wrote:
>
>
>  Do you have an example graphic that shows what you're trying to
> create? I can't figure out if you want something like a square pie
> chart (aka waffle chart), a stacked barchart, a levelplot, or
> something else.
>
> Hadley
>
> On Jan 18, 2008 6:06 AM, Marta Rufino <[EMAIL PROTECTED]> wrote:
>
>
>
>  Dear R users,
>
> I am trying to produce an image plot, that represents the proportions of
> a factor (z variable), so that the number of squares of each colour
> represents each factor level, with the respective label inside (sorry
> for the crap English).
>
> # Something like this:
>
> kk=data.frame(fact=letters[1:10],
> freq=c(5,1,10,2,10,7,5,10,30,20)) #
> factor and respective frequecies
> res="a" # transform into a matrix (is there an easier way to do this?...
> for the image plot
> for(ii in 1:dim(kk)[1]){
>  res=c(res, rep(as.character(kk[ii,1]), l=kk[ii, 2]))
>  }
> res=res[-1]
> res
> res=matrix(c(factor(res)), nc=10)
>
> image(x=1:10,y=1:10, res[,order(colSums(res))], col=rainbow(20))
> abline(h=seq(0.5,10.5,1), col=8, lty=3); abline(v=seq(0.5,10.5,1),
> col=8, lty=3)#add some gridlines
>
> #Problems:
> #1. How to add the labels in each area
> text(1,1,paste("Factor level",kk[1,1]), pos=4)
>
> #2. How to separate the areas of each factor level (for BW printing),
> with lines (instead of colours as it is)
> segments(.5,1.5,5.5,1.5, lwd=2);segments(5.5,.5,5.5,1.5, lwd=2) #
> something like this, but automatically :-(
>
> #3. How to keep the areas together (contiguous) and not allow split over
> to lines?
>
> #4. Could I replace the col. by a symbol, for example? I think I would
> need to use plot instead of image.
> Any help will be much apretiated,
>
> Thank you very much in advance,
> Best wishes,
> Marta
> PS: This type of graphs are used in community ecology analysis, for
> example-...
>
> --
> ...
> Marta M. Rufino (PhD)
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.h

Re: [R] select repositories under linux

2008-01-22 Thread Prof Brian Ripley
On Tue, 22 Jan 2008, Eleni Christodoulou wrote:

> Hi all,
>
> I am trying to install the package "GEOquery" in unix. I have downloaded the
> standard version of R and this package is not contained in the default. I
> know that I can select repositories under windows but I don't know how to do
> it in unix. Does anyone have any idea on this?

?setRepositories (for both Windows and Unix).

>
> Thank you in advance,
> Eleni
>
>   [[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.


[R] Multivariable barplot

2008-01-22 Thread Pilar Loren
Hi, is it possible to do a multivariable barplot with ggplot2?

I have something like that:

> df
   LENGTH  LAT
091639  10.002   42.26282
091640  30.808   42.26834
091641   21.591  42.31689
091642   22.030  41.53246
091643   22.744  42.01954
091644   12.702  42.67751
091645   39.728  42.06479
091647   63.057  41.25283
091648   19.523  41.01925
091649   13.336  42.46904
0916508.935   42.80971
09165125.275 42.50678
0916529.983   42.89345
0916539.416   41.15288

> p <- ggplot(df)
> p <- p + geom_bar(aes(x=rownames(df), y=LENGTH), position="dodge",
fill="red")
> p <- p + geom_bar(aes(x=rownames(df), y=LAT), position="dodge",
fill="green")
> p

but  the result graphics are overlapping.

Thank for your help

[[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] Stationarity of a Time Series

2008-01-22 Thread Prof Brian Ripley
On Tue, 22 Jan 2008, Pfaff, Bernhard Dr. wrote:

> Hello Stephen,
>
> stationarity tests as well as unit root tests have been implemented in a
> couple of packages. For instance, as already mentioned: tseries, but
> also uroot, fUnitRoots and urca. See the annotated task view
> "Econemtrics" and "Finance" for further information.

But note that these tests apply to just a few ways in which a series might 
be non-stationary: they all seem an econmetrician's view of possible 
non-stationarity.

In the end stationarity is a modelling assumption: it depends on what 
might have happened but did not.  E.g. a sine wave process is stationary 
if and only if it has a random (uniform) phase, and you cannot tell that 
from a single realization.

'Anna Karenina applies'[*] (as to most pure significance tests).

[*] Google it if you need elucidation.

>
> Best,
> Bernhard
>
>>
>> kpss.test in the tsereis package should do the trick
>>
>> On Jan 21, 2008 12:36 PM, stephen sefick <[EMAIL PROTECTED]> wrote:
>>
>>> Does anyone know of a test for stationarity of a time series, or like
>>> all ordination techniques it is a qualitative assessment of a
>>> quantitative result.  Books, papers, etc. suggestions welcome.
>>> thanks
>>>
>>> Stephen
>>>
>>> --
>>> Let's not spend our time and resources thinking about things that are
>>> so little or so large that all they really do for us is puff
>> us up and
>>> make us feel like gods.  We are mammals, and have not exhausted the
>>> annoying little problems of being mammals.
>>>
>>>
>>  -K. Mullis
>>>
>>> __
>>> R-help@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide
>>> http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>
>>  [[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.
>>
> *
> Confidentiality Note: The information contained in this ...{{dropped:10}}
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

-- 
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] Communicating with R through a named pipe: display refresh problem

2008-01-22 Thread Parker Jones

Hello,

On a linux system I'm trying to send commands to R through a named pipe and am 
*nearly* successful.  I can send R commands and can plot graphs.  The only 
problem I have is getting the x11 display to refresh - it appears to hang 
because of the pipe.

The R server:
$ mkfifo R_pipe
$ R --no-save < R_pipe

The R client:
$ cat>> R_pipe

Now, I can send R commands down the pipe:

Client side:
x <- seq(1,10)
x

Server side:
> x <- seq(1:10)
> x
 [1]  1  2  3  4  5  6  7  8  9 10

This is perfect.

Now if I try to create a plot, e.g. plot(1:100), the server shows
> plot(1:100)
and the plot appears.  However, if a window briefly obscures the graphical 
output, the x11 device won't refresh the display.  It would appear the pipe is 
blocking the refresh.

Can anyone else confirm this happens and any suggestions how to get the display 
to refresh?

Thanks in advance,
PJ

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


Re: [R] ODE's in R

2008-01-22 Thread Peter Dalgaard
Markku Karhunen wrote:
> Thanks, Dr. Maechler.
>   
>> No, there's no such track.
>> [ Matlab users coming to R may produce wrong R code
>>   by using 0:n-1 instead of 0:(n-1) ; but I don't assume this
>>   would be the case ]
>>
>>   
>> 
> Been there, done that!
>   
>> MK>  We use just a simple discretisation written in a for loop 
>> MK> and a variable (i.e. user-fed) time step.
>>
>> I don't think you should use your own code instead of "professional"
>> ODE solvers, such as the one in R package 'odesolve'
>>
>>   
>> 
> We must look into that. The problem, maybe, is that in fact half of the 
> equations are, in fact, simple PDE's and I don't know, if you can put 
> them into odesolve.
>   
Usually, you can convert them to a system of ODE's ("the method of
lines" if i remember correctly).

One slight caveat with the high-end ODE solvers is that sometimes they
are too smart for their own good when used in connection with parameter
estimation. Because of things like adaptive stepsizing, you might end up
with sums of squared residuals that are non-smooth functions of the
parameters. This happens especially easily if the system itself is not
quite smooth (e.g. if your input to the system is a step function).

>> MK> Maybe, I'm too neurotic about this, but I guess I just want some 
>> comfort 
>> MK> after seeing a few particularly nasty orbits.
>>
>> As we know ``from Chaos theory'', there can be delicate
>> inhereent and numerical problems in ODE solving..
>>   
>> 
> But - to our best knowledge - they should not be any more acute in R, 
> than on any other platform...
>
> BR,
> Markku
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>   


-- 
   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] ODE's in R

2008-01-22 Thread Markku Karhunen
Thanks, Dr. Maechler.
> No, there's no such track.
> [ Matlab users coming to R may produce wrong R code
>   by using 0:n-1 instead of 0:(n-1) ; but I don't assume this
>   would be the case ]
>
>   
Been there, done that!
> MK>  We use just a simple discretisation written in a for loop 
> MK> and a variable (i.e. user-fed) time step.
>
> I don't think you should use your own code instead of "professional"
> ODE solvers, such as the one in R package 'odesolve'
>
>   
We must look into that. The problem, maybe, is that in fact half of the 
equations are, in fact, simple PDE's and I don't know, if you can put 
them into odesolve.
> MK> Maybe, I'm too neurotic about this, but I guess I just want some 
> comfort 
> MK> after seeing a few particularly nasty orbits.
>
> As we know ``from Chaos theory'', there can be delicate
> inhereent and numerical problems in ODE solving..
>   
But - to our best knowledge - they should not be any more acute in R, 
than on any other platform...

BR,
Markku

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

2008-01-22 Thread Yogesh Tiwari
Hi,

I am using R on Windows XP.

I am using 'arrows' funtion to plot the variance as error bar, BUT error
bar goes only one side of the data point, I need to plot the error bar on
both side of the data point (plot is attached), I am using following
commands to plot,

plot(file3$lat,file3$STotwoKm,pch=21,cex=2.5,ylim=c(-0.2,2.5),xlim=c(-50,50),xlab=NA,ylab=NA,
col=1, xaxs="i",yaxs="i")

arrows(file3$lat, file3$var1, file3$lat,file3$STotwoKm, col=1, code=3,
angle=90, length=0.1)

Here:  lat=latitte (x-axis)
  STotwoKm = Data values (y-axis)
  Var1 = Variance

Kindly help how I can plot error bar on both side of data point,

Many thanks,

Regards,
Yogesh

-- 
Yogesh K. Tiwari (Dr.rer.nat),
Scientist,
Indian Institute of Tropical Meteorology,
Homi Bhabha Road,
Pashan,
Pune-411008
INDIA

Phone: 0091-99 2273 9513 (Cell)
 : 0091-20-258 93 600 (O) (Ext.250)
Fax: 0091-20-258 93 825
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 object as a function

2008-01-22 Thread Duncan Murdoch
On 22/01/2008 5:30 AM, Thomas Steiner wrote:
> I want to use a function as an argument to ingtegrate it twice.
> See the following (senseless) example of a double integration:
> 
> test<-function(sf,lo,up,rest) {
>   innerFkn<-function(sf,lo) {
> inte=integrate(f=sf,lower=lo,upper=4)
> return( inte$value )
>   }
>   integral=integrate(f=innerFkn,lower=1,upper=2,sf=sf,lo=lo,up=up)
>   return( integral$vlaue+rest )
> }
> test(sf=stepfun(c(0,1),c(2,-1,3)),lo=0,up=2,rest=12)
> 
> Why isn't it possible to define the "innerFkn" inside "test"?

It is possible, but it needs to take arguments in the order that 
integrate expects, i.e. the first argument needs to be the values at 
which it will be evaluated.  You don't specify any "x" value.

The other problem is that integrate is not vectorized, it can only take 
scalar values for lower and upper, so you'll need a loop within innerFkn 
to do the integral over the values being passed in.

Duncan Murdoch

> "sf" is a stepfun, but it should possibly be any function.
> How can I define some R object like a stepfun (depending on variables)
> which can be evaluated like a function at some "lo"?
> Thanks for help,
> 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-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 object as a function

2008-01-22 Thread Duncan Murdoch
On 22/01/2008 6:51 AM, Thomas Steiner wrote:
> Okay, let me try to better say what I meant:
> 
> myfun1<-function(x=5,pa) {
>   return(pa[1]*x^2+pa[2]*x+pa[3])
> }
> myfun2<-function(x=5,param,myfunk1) {
>   return(param[1]*myfunk1(x)+param[2]*myfunk1(x))
> }
> test<-function(pars1,pars2,lo,up){
>   mf=myfun1(x=2,pa=8*pars1)
>   integ=integrate(f=myfun2,lower=lo,upper=up,param=pars2,myfunk1=mf)
>   return( 2*integ$value )
> }
> test(pars1=c(1,2,3),pars2=c(-1,1),lo=2,up=7)
> 
> So the function myfun2 will be integrated and has a function (myfunk1)
> itself as an argument.

You're not passing a function as myfunk1, you're passing mf, which is 
the result of evaluating myfun1, so it's a numeric vector.

Duncan Murdoch

> Why is this not possible?
> Thanks,
> Thomas
> 
> PS: the "x=5" and "pa=8*" has no influence...
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] R object as a function

2008-01-22 Thread Thomas Steiner
Okay, let me try to better say what I meant:

myfun1<-function(x=5,pa) {
  return(pa[1]*x^2+pa[2]*x+pa[3])
}
myfun2<-function(x=5,param,myfunk1) {
  return(param[1]*myfunk1(x)+param[2]*myfunk1(x))
}
test<-function(pars1,pars2,lo,up){
  mf=myfun1(x=2,pa=8*pars1)
  integ=integrate(f=myfun2,lower=lo,upper=up,param=pars2,myfunk1=mf)
  return( 2*integ$value )
}
test(pars1=c(1,2,3),pars2=c(-1,1),lo=2,up=7)

So the function myfun2 will be integrated and has a function (myfunk1)
itself as an argument.
Why is this not possible?
Thanks,
Thomas

PS: the "x=5" and "pa=8*" has no influence...

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


Re: [R] Multivariable barplot

2008-01-22 Thread Domenico Vistocco
Pilar Loren wrote:
> Hi, is it possible to do a multivariable barplot with ggplot2?
>
> I have something like that:
>
>   
>> df
>> 
>LENGTH  LAT
> 091639  10.002   42.26282
> 091640  30.808   42.26834
> 091641   21.591  42.31689
> 091642   22.030  41.53246
> 091643   22.744  42.01954
> 091644   12.702  42.67751
> 091645   39.728  42.06479
> 091647   63.057  41.25283
> 091648   19.523  41.01925
> 091649   13.336  42.46904
> 0916508.935   42.80971
> 09165125.275 42.50678
> 0916529.983   42.89345
> 0916539.416   41.15288
>
>   
>> p <- ggplot(df)
>> p <- p + geom_bar(aes(x=rownames(df), y=LENGTH), position="dodge",
>> 
> fill="red")
>   
>> p <- p + geom_bar(aes(x=rownames(df), y=LAT), position="dodge",
>> 
> fill="green")
>   
>> p
>> 
df2=melt(id="idrow", df)
qplot(data=df2, x=idrow, y=value, 
fill=variable,stat="identity",geom="bar", position="dodge")

Ciao,
domenico
>
> but  the result graphics are overlapping.
>
> Thank for your help
>
>   [[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] R: determinants and inverses

2008-01-22 Thread Allan Clark
hello  Charilaos 
 
thank you for your reply.
 
i know how to use R to calculate the results. i want to simplify the results 
mathematically.
 
i found a reference that helps.
 
see mardia, kent, bibby, "multivariate analysis",  (2003) pg 457,458 for the 
correct simplifiations. 
 
(for those interested)
|A+BC|=|A||I(p)+inv(A)BC|=|A||I(n)+Cinv(A)B|   for B (p by n) , C (n by p), A 
(p by p) and non singular.
 
regards
 
 
 
Allan Clark

Lecturer in Statistical Sciences Department
University of Cape Town
7701 Rondebosch
South Africa
TEL (Office): +27-21-650-3228
FAX: +27-21-650-4773
http://web.uct.ac.za/depts/stats/aclark.htm 
 


>>> Charilaos Skiadas <[EMAIL PROTECTED]> 2008/01/22 01:24 PM >>>
Can you just multiply the matrices with %*% ( ?"%*%" ), form the  
identity through diag ( ?diag ), and then use "det" to get the  
determinant?  (though read the note in ?qr ).

Haris Skiadas
Department of Mathematics and Computer Science
Hanover College

On Jan 22, 2008, at 5:02 AM, Allan Clark wrote:

> hello all
>
> sorry for the following "none" R related question.
>
>
>
> does anyone know of a reference to calculate the following identity:
>
> |I + ABC|
>
> where I is an identity matrix and A, B,C may not have to be square  
> matrices?
>
>
> you help will be greatly appreciated.
>
>
>
> H. V. Henderson; S. R. Searle
> SIAM Review, Vol. 23, No. 1. (Jan., 1981), pp. 53-60.
>
> provides a result to calculate the inverse of I + ABC. (for those  
> interested!!!)
>
> thanking you in advance
>
>
> Allan Clark
> 
> Lecturer in Statistical Sciences Department
> University of Cape Town
> 7701 Rondebosch
> South Africa
> TEL (Office): +27-21-650-3228
> FAX: +27-21-650-4773
> http://web.uct.ac.za/depts/stats/aclark.htm 
>
>
> [[alternative HTML version deleted]]




[[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] Multivariable barplot

2008-01-22 Thread Domenico Vistocco
Domenico Vistocco wrote:
> Pilar Loren wrote:
>   
>> Hi, is it possible to do a multivariable barplot with ggplot2?
>>
>> I have something like that:
>>
>>   
>> 
>>> df
>>> 
>>>   
>>LENGTH  LAT
>> 091639  10.002   42.26282
>> 091640  30.808   42.26834
>> 091641   21.591  42.31689
>> 091642   22.030  41.53246
>> 091643   22.744  42.01954
>> 091644   12.702  42.67751
>> 091645   39.728  42.06479
>> 091647   63.057  41.25283
>> 091648   19.523  41.01925
>> 091649   13.336  42.46904
>> 0916508.935   42.80971
>> 09165125.275 42.50678
>> 0916529.983   42.89345
>> 0916539.416   41.15288
>>
>>   
>> 
>>> p <- ggplot(df)
>>> p <- p + geom_bar(aes(x=rownames(df), y=LENGTH), position="dodge",
>>> 
>>>   
>> fill="red")
>>   
>> 
>>> p <- p + geom_bar(aes(x=rownames(df), y=LAT), position="dodge",
>>> 
>>>   
>> fill="green")
>>   
>> 
>>> p
>>> 
>>>   
Sorry (I missed to past a command before the melt command):
df=data.frame(idrow=rownames(df), df)
> df2=melt(id="idrow", df)
> qplot(data=df2, x=idrow, y=value, 
> fill=variable,stat="identity",geom="bar", position="dodge")
>
> Ciao,
> domenico
>   
>> but  the result graphics are overlapping.
>>
>> Thank for your help
>>
>>  [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
>> 
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>

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

2008-01-22 Thread Karin Lagesen

I am sorry if this is a faq or tutorial somewhere, but I am unable to
solve this one.

What I am looking for is a count of how many different
categories(numbers in this case) that appears for a given factor.

Example:

> l <- c("Yes", "No", "Perhaps")
> x <- factor( sample(l, 10, replace=T), levels=l )
> m <- c(1:5)
> y <- factor( sample(m, 10, replace=T), levels=m )
> z = c(1:10)
> my_df = data.frame("Z" = z, "Y"= y, "X" = x)
> my_df
Z Y   X
1   1 4 Yes
2   2 1  No
3   3 2 Perhaps
4   4 3 Yes
5   5 4  No
6   6 5  No
7   7 1 Yes
8   8 4 Perhaps
9   9 4 Yes
10 10 2 Perhaps
> 

I am now looking for a table that will give me this:

Yes  3   # Yes has these ys: 4,3,1,4, two are the same, ergo 3
No   3   # No has these ys: 1,4,5
Perhaps  2   # Perhaps has these ys: 2,4,2

My dataframe has lots of other colums too, but I only want this
information out.


Thankyou for your help!

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

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


Re: [R] error bar position setting

2008-01-22 Thread Richard . Cotton
> I am using 'arrows' funtion to plot the variance as error bar, BUT error
> bar goes only one side of the data point, I need to plot the error bar 
on
> both side of the data point (plot is attached), I am using following
> commands to plot,
> 
> plot(file3$lat,file3$STotwoKm,pch=21,cex=2.5,ylim=c(-0.2,2.5),
> xlim=c(-50,50),xlab=NA,ylab=NA,
> col=1, xaxs="i",yaxs="i")
> 
> arrows(file3$lat, file3$var1, file3$lat,file3$STotwoKm, col=1, code=3,
> angle=90, length=0.1)

Try using the arrows function with y0 as the lower error bound, y1 as the 
upper error bound and code=3, so that arrowheads are drawn at both ends of 
the arrow.

You should double check the y coordinates of the arrows.  If the y values 
are normally distributed, then a 95% confidence interval will give lower 
bounds at yvalues + qnorm(0.025)*sqrt(variance), and an upper bound at 
yvalues + qnorm(0.975)*sqrt(variance).

Regards,
Richie.

Mathematical Sciences Unit
HSL

"Statistics are like a lamp-post to a drunken man - more for leaning on 
than illumination."
David Brent, The Office.


ATTENTION:

This message contains privileged and confidential inform...{{dropped:20}}

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

2008-01-22 Thread Thomas Steiner
Thank you very much Duncan for your quick answers.

> You're not passing a function as myfunk1, you're passing mf, which is
> the result of evaluating myfun1, so it's a numeric vector.

Yes, this is exacty my problem.
If I leave it away, the problem will not be resolved (it needs pa or not)

myfun1<-function(x,pa) {
  return(pa[1]*x^2+pa[2]*x+pa[3])
}
myfun2<-function(x,param,myfunk1) {
  return(param[1]*myfunk1(x)+param[2]*myfunk1(x))
}
test<-function(pars1,pars2,lo,up){
  
integ=integrate(f=myfun2,lower=lo,upper=up,param=pars2,myfunk1=myfun1)#pa=pars1
  return( 2*integ$value )
}
test(pars1=c(1,2,3),pars2=c(-1,1),lo=2,up=7)

Which gives an error:
Once the "argument pa" is missing  and if you add the "pa=pars1" in
the comment, it says that the argument pa is redundant.

Thanks for help,
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.


Re: [R] contingency table on data frame

2008-01-22 Thread Domenico Vistocco
Karin Lagesen wrote:
> I am sorry if this is a faq or tutorial somewhere, but I am unable to
> solve this one.
>
> What I am looking for is a count of how many different
> categories(numbers in this case) that appears for a given factor.
>
> Example:
>
>   
>> l <- c("Yes", "No", "Perhaps")
>> x <- factor( sample(l, 10, replace=T), levels=l )
>> m <- c(1:5)
>> y <- factor( sample(m, 10, replace=T), levels=m )
>> z = c(1:10)
>> my_df = data.frame("Z" = z, "Y"= y, "X" = x)
>> my_df
>> 
> Z Y   X
> 1   1 4 Yes
> 2   2 1  No
> 3   3 2 Perhaps
> 4   4 3 Yes
> 5   5 4  No
> 6   6 5  No
> 7   7 1 Yes
> 8   8 4 Perhaps
> 9   9 4 Yes
> 10 10 2 Perhaps
>   
>
> I am now looking for a table that will give me this:
>
> Yes  3   # Yes has these ys: 4,3,1,4, two are the same, ergo 3
> No   3   # No has these ys: 1,4,5
> Perhaps  2   # Perhaps has these ys: 2,4,2
>   
Maybe:
apply(table(my_df$X,my_df$Y),1,function(x) sum(x!=0))

domenico
> My dataframe has lots of other colums too, but I only want this
> information out.
>
>
> Thankyou for your help!
>
> Karin
>

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


Re: [R] Need suggestions about GUI

2008-01-22 Thread ronggui
Thanks, John,
Here is some code to show what I want to do. BTW, it seems there is a
bug in svalue in gWidgetstcltk for gtext when using the drop=T
argument.

getsel <-  function(obj, toolkit, ...) {
### get the selected text from gtext
getWidget <- gWidgetstcltk:::getWidget
if(tclvalue(tktag.ranges(getWidget(obj),"sel")) != "")
### notice
### gWidgetstcltk's _svalue(drop=T)_ has bug. should add tclvalue to
the above line.
{val = tclvalue(tkget(getWidget(obj),"sel.first","sel.last"))}
else  val =""#tclvalue(tkget(getWidget(obj),"0.0","end"))
val = unlist(strsplit(val,"\n"))
return(val)
  }

get_index <-  function(obj, toolkit, ...) {
### get the selected text from gtext, return the index instead of text.
getWidget <- gWidgetstcltk:::getWidget
if(tclvalue(tktag.ranges(getWidget(obj),"sel")) != ""){
val = strsplit(tclvalue(tktag.ranges(getWidget(obj),
"sel")), " ")[[1]]}
else  val =c(0,0)
return(as.numeric(val))
  }


require(gWidgets)

#initial parameters, storing the relavant information
freecodes <- c("node1","node2")
n_coding <- 0
node <- character(1)
chunk <- character(1)
begin <- numeric(1)
end <- numeric(1)
imported_file <- readLines(file.path(R.home(),"COPYING"))

codepanel <- gpanedgroup(container=gwindow("Code bar"), horizontal = FALSE)
addcode = gdroplist(freecodes,0,container=codepanel,editable=TRUE)

addcodebutton <- gbutton("Add new
code",container=codepanel,handler=function(...) {
if(svalue(addcode)!="")
addcode[length(addcode)+1]<-svalue(addcode)
}
)
## allow the user to change the extant codes -- related to "freecodes" parameter

updatecodes <- gbutton("Update
Codes",container=codepanel,handler=function(...)
assign("freecodes",addcode[seq_len(length(addcode))],pos=1))
## get the items in gdroplist, and push it to variable "freecodes"

coding <- gbutton("  Coding  ",container=codepanel,handler=
function(...){
if (svalue(addcode)!="" && sel!=""){
sel <<- paste(getsel(ed),collapse="\n")
sel_index <<- get_index(ed)
n_coding <<- n_coding + 1
node[n_coding] <<- svalue(addcode)
chunk[n_coding] <<- sel
begin[n_coding] <<- sel_index[1]
end[n_coding] <<- sel_index[2]
}}
)
## coding: get seleted text from gtext and link it to specific code/node.

ed <- gtext(con=T,width=500) # gtext
svalue(ed) <- imported_file # push it file to gtext

# steps to using this "toy":

1, enter new code names into the droplist box, for example node3, then
click "add new code"
2, select specific code, for example node2.
3, select text chunk in the gtext, and click coding. repeat step 3 in
coding process.
4, We can see what's been coded by inpecting variable of "node","chunk".

What I don't know how to do:
1, When I select specific code, and click some button (for example
highligh), all the text chunk related to that code will be highlighted
(through color or font style etc.)
2, I would like to arganize the codes like a tree. The code tree and
reorganized by drag and drop.
3, In the coding buttong, how can I avoid using <<- in handler function.


2008/1/22, j verzani <[EMAIL PROTECTED]>:
> ronggui  gmail.com> writes:
>
> > Thanks.
> >
> > gWidgets is quite good. However, I want to get the selection text chunk as
> > well as the index, but the index arguments does not work for gtext.
> >
> > > obj<-gtext(cont=T)
> > > svalue(obj,drop=T)
> > [1] "cde"
> > > svalue(obj,drop=T,index=T)
> > [1] "cde"
> >
>
>
>
> The svalue method has the index argument for the widgets where you might want 
> to
> return the  index or value such with a radio button group or combobox. For
> gtext, the drop argument when TRUE returns just the text selected by the 
> mouse,
> otherwise the entire text buffer is returned.
>
> library(gWidgets)
> options("guiToolkit"="RGtk2")
> obj = gtext("sadfsad",cont=T)
> svalue(obj)   ## returns: "sadfsad\n"
> svalue(obj,drop=TRUE)  ## returns  ""
> ## now highlight some text
> svalue(obj,drop=TRUE) ## returns "dfsa"
>
> If you want to email me a bit more detail as to what you are trying to do, I 
> can
> let you know if gWidgets can work for you.
>
> --John
> >
>
> > 2008/1/21, Gabor Grothendieck  gmail.com>:
> > >
> > > You can find examples of using tcltk here:
> > >
> > > http://www.sciviews.org/_rgui/tcltk/
> > >
> > > Also the gwidgets package is a toolkit independent
> > > layer that can run on top of tcltk or RGtk and it is described
> > > with many examples here:
> > >
> > > http://wiener.math.csi.cuny.edu/pmg/gWidgets
> > >
> > > On Jan 21, 2008 4:02 AM, ronggui  gmail.com> wrote:
> > > > What I want to do is:
> > > > 1, creat a text box, insert text into that box.
> > > > 2, select chunk of of the text by mouse, and link it to a lable. so I
> > > would
> > > > like a way to get that chunk of text.
> > > >
> > > > Can I do such job with tcltk?  Any relavant tutorial materials?
> > > >
> > > > Thanks
> > > >
> > > > --
> > > > HUANG Ronggui
> > > >
> > > > Bachelor of S

[R] CRAN down?

2008-01-22 Thread Stefan Grosse
I am having problems to access the r-project.org homepage, someone else as 
well? 

(I know there are CRAN mirrors but they link back on the main page if I search 
something)

Stefan

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


Re: [R] CRAN down?

2008-01-22 Thread Duncan Murdoch
On 1/22/2008 8:04 AM, Stefan Grosse wrote:
> I am having problems to access the r-project.org homepage, someone else as 
> well? 
> 
> (I know there are CRAN mirrors but they link back on the main page if I 
> search 
> something)

They look fine from here.  (By the way, the r-project.org homepage is 
different from CRAN.  I had trouble with www.r-project.org on the 
weekend, but haven't seen any cran.r-project.org problems in a while.)

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] Adding an Sweave Vignette to a package

2008-01-22 Thread Doran, Harold
Thanks, Uwe. Before I modify this path, I want to make sure of one
thing. My path is set according to the specifications in the document
prescribed by Duncan Murdoch (at link below). Indeed, my path includes
the proper location of my MikTex and pdflatex.exe files. Here is my path
from the command you gave below:

"c:\\Rtools\\bin;C:\\Perl\\bin\\;c:\\Rtools\\MinGW\\bin;c:\\texmf\\mikte
k\\bin;c:\\cygwin;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System3
2\\Wbem;C:\\subversion\\Subversion\\bin;C:\\Program
Files\\R\\R-2.2.0\\bin; " 

http://cran.r-project.org/doc/manuals/R-admin.html#The-Windows-toolset

AFAIK, the path indeed is set according to the Murdoch prescription for
building R packages, my pdflatex.exe lives in the directory pointed to
in this path, yet R cannot see it when doing Rcmd build. 

I can successfully build and use the package at this point (again as my
other problem now solved). However, I am not sure what I should work on
to resolve the issue of building the vignette.

There are so many steps in building a package, I may have missed
something somewhere. So, if you see an error I appreciate any advice.

Harold


> -Original Message-
> From: Uwe Ligges [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, January 22, 2008 4:15 AM
> To: Doran, Harold
> Cc: James W. MacDonald; R Help
> Subject: Re: [R] Adding an Sweave Vignette to a package
> 
> In R, type
>   Sys.getenv("PATH")
> and you will probably find that the PATH does not include the 
> path of the pdflatex executable of the mikTeX distribution.
> 
> Uwe
> 
> 
> Doran, Harold wrote:
> > Jim
> > 
> > First thanks for your patience. I use MikTex as well. I do 
> have both 
> > (texti2dvi and pdflatex) on my local machine. I copied and 
> pasted the 
> > code below and stepped through it. I think this break down with the 
> > following error. Indeed, I think there is a path problem.
> > 
> > However, I don't see a resolution in either Writing R Extensions or 
> > the Leisch paper. So, I'm not quite sure what path to 
> modify and/or how.
> > 
> > Error in texi2dvi("TheVignette.tex", pdf = TRUE) : 
> >   unable to run pdflatex on 'TheVignette.tex'
> > In addition: Warning message:
> > In system(paste(shQuote(latex), "-interaction=nonstopmode", 
> texfile)) :
> >   "pdflatex" not found
> > 
> >> -Original Message-
> >> From: James W. MacDonald [mailto:[EMAIL PROTECTED]
> >> Sent: Monday, January 21, 2008 4:53 PM
> >> To: Doran, Harold
> >> Cc: R Help
> >> Subject: Re: [R] Adding an Sweave Vignette to a package
> >>
> >> What TeX variant are you using? If texi2dvi() can't find 
> texi2dvi, it 
> >> tries to fall back on pdflatex which has to be in the path.
> >>
> >> I have always had good luck with MikTeX, which does have texi2dvi.
> >>
> >> You could always try
> >>
> >> library(tools)
> >> Sweave("TheVignette.Rnw")
> >> debug(texi2dvi)
> >> texi2dvi("TheVignette.tex", pdf=TRUE)
> >>
> >> and step through to see where it fails, although on the surface it 
> >> looks like a path problem.
> >>
> >> Best,
> >>
> >> Jim
> >>
> >>
> >>
> >> Doran, Harold wrote:
> >>> There is now and it looks like I got through the first
> >> phase. But, now
> >>> I get the error below.
> >>>
> >>> * DONE (MiscPsycho)
> >>> * creating vignettes ... ERROR
> >>> Loading required package: statmod
> >>> Below is what alpha *would be* if the item were removed
> >>>
> >>> Error in texi2dvi(file = bft, pdf = TRUE, clean = FALSE, quiet =
> >>> quiet)
> >>> :
> >>>   unable to run pdflatex on 'MP.tex'
> >>> Calls: buildVignettes -> texi2dvi
> >>> In addition: Warning messages:
> >>> 1: In readLines(f[1]) : incomplete final line found on 'MP.Rnw'
> >>> 2: In system(paste(shQuote(latex), "-interaction=nonstopmode",
> >>> texfile))
> >>> :
> >>>   "pdflatex" not found
> >>> Execution halted
> >>>
> >>> I do have pdflatex, it's what I use all of the time. 
> >> However, how do I
> >>> point to it for this build process?
> >>>
>  -Original Message-
>  From: James W. MacDonald [mailto:[EMAIL PROTECTED]
>  Sent: Monday, January 21, 2008 4:09 PM
>  To: Doran, Harold
>  Cc: R Help
>  Subject: Re: [R] Adding an Sweave Vignette to a package
> 
>  Hi Harold,
> 
>  Doran, Harold wrote:
> > I'm finalizing development of a package that will include a
>  vignette.
> > Without the vignette, the package builds fine with no
>  warnings and is
> > ready for distribution. Now, I am following the directions for 
> > developing vignettes "Sweave, Part II: Package Vignettes"
>  by Friedrich
> > Leisch.
> >
> > I am using a windows XP machine (other session info
> >> below). Here is
> > what I have done.
> >
> > 1) I add the 'inst/doc' directory to the package source tree.
> > 2) I have added the following information in the preamble
>  of the .Rnw
> > file
> >
> > % \VignetteIndexEntry{An \texttt{R} Package for Miscellaneous 
> > Psychometric Analyses} % \Vign

Re: [R] R object as a function

2008-01-22 Thread Duncan Murdoch
On 1/22/2008 7:52 AM, Thomas Steiner wrote:
> Thank you very much Duncan for your quick answers.
> 
>> You're not passing a function as myfunk1, you're passing mf, which is
>> the result of evaluating myfun1, so it's a numeric vector.
> 
> Yes, this is exacty my problem.
> If I leave it away, the problem will not be resolved (it needs pa or not)
> 
> myfun1<-function(x,pa) {
>   return(pa[1]*x^2+pa[2]*x+pa[3])
> }
> myfun2<-function(x,param,myfunk1) {
>   return(param[1]*myfunk1(x)+param[2]*myfunk1(x))
> }
> test<-function(pars1,pars2,lo,up){
>   
> integ=integrate(f=myfun2,lower=lo,upper=up,param=pars2,myfunk1=myfun1)#pa=pars1
>   return( 2*integ$value )
> }
> test(pars1=c(1,2,3),pars2=c(-1,1),lo=2,up=7)
> 
> Which gives an error:
> Once the "argument pa" is missing  and if you add the "pa=pars1" in
> the comment, it says that the argument pa is redundant.

myfun2 has no pa argument, but it calls (through myfunk1) myfun1 which 
does.  Where is pa supposed to come from?

You need to think carefully about the requirements for arguments to each 
of your functions.  Look at every function call, and make sure the 
arguments you are passing match the arguments in the header of the 
function you call.

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] Can I StepAIC a ggwr object??

2008-01-22 Thread Luca Moiana

Hello everyone,

I'm working on some ggwr model and I obtained a .ggwr object, now I'm ascking: 
Can I StepAIC the object to evaluate the best model and decide what variables, 
should get in???

Thanks

Luca Moiana
PhD Candidate - Environmental Science

University of Milan - Bicocca

_


[[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] CRAN down?

2008-01-22 Thread Peter Dalgaard
Stefan Grosse wrote:
> I am having problems to access the r-project.org homepage, someone else as 
> well? 
>
> (I know there are CRAN mirrors but they link back on the main page if I 
> search 
> something)
>
> Stefan
>
>   
It's up for me now, but I had rather slow access earlier in the day.

-- 
   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] Adding an Sweave Vignette to a package

2008-01-22 Thread Doran, Harold
Actually, I'm running 2.6.1. The old version is in the path, but I am
working with the most recent version. I am working in DOS and am at the
prompt c:\program files\r\r-2.6.1\bin. From here I do all of the work in
building the package (build, check, install).

> -Original Message-
> From: Uwe Ligges [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, January 22, 2008 9:02 AM
> To: Doran, Harold
> Cc: R Help
> Subject: Re: [R] Adding an Sweave Vignette to a package
> 
> 
> 
> Doran, Harold wrote:
> > Thanks, Uwe. Before I modify this path, I want to make sure of one 
> > thing. My path is set according to the specifications in 
> the document 
> > prescribed by Duncan Murdoch (at link below). Indeed, my 
> path includes 
> > the proper location of my MikTex and pdflatex.exe files. Here is my 
> > path from the command you gave below:
> > 
> > 
> "c:\\Rtools\\bin;C:\\Perl\\bin\\;c:\\Rtools\\MinGW\\bin;c:\\texmf\\mik
> > te
> > 
> k\\bin;c:\\cygwin;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\Syste
> > m3 2\\Wbem;C:\\subversion\\Subversion\\bin;C:\\Program
> > Files\\R\\R-2.2.0\\bin; " 
> > 
> > 
> http://cran.r-project.org/doc/manuals/R-admin.html#The-Windows-toolset
> > 
> > AFAIK, the path indeed is set according to the Murdoch prescription 
> > for building R packages, my pdflatex.exe lives in the directory 
> > pointed to in this path, yet R cannot see it when doing Rcmd build.
> > 
> > I can successfully build and use the package at this point 
> (again as 
> > my other problem now solved). However, I am not sure what I should 
> > work on to resolve the issue of building the vignette.
> > 
> > There are so many steps in building a package, I may have missed 
> > something somewhere. So, if you see an error I appreciate 
> any advice.
> 
> Hmm, hard to tell, although I think it might make sense to 
> upgrade your version of R, given I am correct that you are 
> running R-2.2.0 (from the output you gave above).
> 
> Uwe
> 
> 
> > Harold
> > 
> > 
> >> -Original Message-
> >> From: Uwe Ligges [mailto:[EMAIL PROTECTED]
> >> Sent: Tuesday, January 22, 2008 4:15 AM
> >> To: Doran, Harold
> >> Cc: James W. MacDonald; R Help
> >> Subject: Re: [R] Adding an Sweave Vignette to a package
> >>
> >> In R, type
> >>   Sys.getenv("PATH")
> >> and you will probably find that the PATH does not include 
> the path of 
> >> the pdflatex executable of the mikTeX distribution.
> >>
> >> Uwe
> >>
> >>
> >> Doran, Harold wrote:
> >>> Jim
> >>>
> >>> First thanks for your patience. I use MikTex as well. I do
> >> have both
> >>> (texti2dvi and pdflatex) on my local machine. I copied and
> >> pasted the
> >>> code below and stepped through it. I think this break 
> down with the 
> >>> following error. Indeed, I think there is a path problem.
> >>>
> >>> However, I don't see a resolution in either Writing R 
> Extensions or 
> >>> the Leisch paper. So, I'm not quite sure what path to
> >> modify and/or how.
> >>> Error in texi2dvi("TheVignette.tex", pdf = TRUE) : 
> >>>   unable to run pdflatex on 'TheVignette.tex'
> >>> In addition: Warning message:
> >>> In system(paste(shQuote(latex), "-interaction=nonstopmode",
> >> texfile)) :
> >>>   "pdflatex" not found
> >>>
>  -Original Message-
>  From: James W. MacDonald [mailto:[EMAIL PROTECTED]
>  Sent: Monday, January 21, 2008 4:53 PM
>  To: Doran, Harold
>  Cc: R Help
>  Subject: Re: [R] Adding an Sweave Vignette to a package
> 
>  What TeX variant are you using? If texi2dvi() can't find
> >> texi2dvi, it
>  tries to fall back on pdflatex which has to be in the path.
> 
>  I have always had good luck with MikTeX, which does have 
> texi2dvi.
> 
>  You could always try
> 
>  library(tools)
>  Sweave("TheVignette.Rnw")
>  debug(texi2dvi)
>  texi2dvi("TheVignette.tex", pdf=TRUE)
> 
>  and step through to see where it fails, although on the 
> surface it 
>  looks like a path problem.
> 
>  Best,
> 
>  Jim
> 
> 
> 
>  Doran, Harold wrote:
> > There is now and it looks like I got through the first
>  phase. But, now
> > I get the error below.
> >
> > * DONE (MiscPsycho)
> > * creating vignettes ... ERROR
> > Loading required package: statmod
> > Below is what alpha *would be* if the item were removed
> >
> > Error in texi2dvi(file = bft, pdf = TRUE, clean = FALSE, quiet =
> > quiet)
> > :
> >   unable to run pdflatex on 'MP.tex'
> > Calls: buildVignettes -> texi2dvi
> > In addition: Warning messages:
> > 1: In readLines(f[1]) : incomplete final line found on 'MP.Rnw'
> > 2: In system(paste(shQuote(latex), "-interaction=nonstopmode",
> > texfile))
> > :
> >   "pdflatex" not found
> > Execution halted
> >
> > I do have pdflatex, it's what I use all of the time. 
>  However, how do I
> > point to it for this build process?
> >
> >> -Original Me

Re: [R] dendrogram - got it , just need to label :)

2008-01-22 Thread phlow

Hi!
To label your dendrogram edges with the path to each of them, execute the
following script (assuming that your dendrogram is 'dend', see last 2
lines). 


dendrapplyGlobal <- function(dend,attrName,FUN,...,attrNameTo=NULL) {
if (is.null(attrNameTo)) {
attrNameTo <- attrName
}
funcGet <- function(x){
attr(x,attrName)
}
funcSet <- function(x,value){
attr(x,attrNameTo) <- value
return(x)
}
values <- dendrapplyToVector(dend,funcGet)
values <- FUN(values,...)
ret <- dendrapplyFromVector(dend,values,funcSet)
return(ret)
}

dendrapplyToVector <- function(X,FUN,...) {
FUN <- match.fun(FUN)
if (!inherits(X, "dendrogram")) 
stop("'X' is not a dendrogram")
Napply <- function(d,path="") {
if (is.leaf(d)) {
ret <- c(FUN(d))
names(ret)[1] <- substr(path,start=1,stop=nchar(path)-1)
return(ret)
} 
ret <- vector()
for (j in seq_along(d)) {
addr <- paste(path,j,".",sep="")
ret <- append(ret,Napply(d[[j]],addr))
}
ret <- append(ret,FUN(d))
names(ret)[length(ret)] <- 
substr(path,start=1,stop=nchar(path)-1)
return(ret)
}
Napply(X)
}

dendrapplyFromVector <- function(X,theVector,FUN,...) {
FUN <- match.fun(FUN)
if (!inherits(X, "dendrogram")) 
stop("'X' is not a dendrogram")
Napply <- function(d,v) {
if (is.leaf(d)) {
ret <- FUN(d,v)
return(ret)
} else {
ret <- d
if (!is.list(ret)) 
ret <- as.list(ret)
i <- 1
memsum <- 0
for (j in seq_along(d)) {
childrenCount <- getDendrogramNodeCount(d[[j]])
memsum <- memsum + childrenCount
indices <- i:(i+childrenCount-1)
ret[[j]] <- Napply(d[[j]],v[indices])
i <- i + childrenCount
}
ret <- FUN(ret,v[i])
}
return(ret)
}
Napply(X,theVector)
}


dend1 <- dendrapplyGlobal(dend,
"height",function(x){names(x)},attrNameTo="edgetext")
plot(dend1)

hth,
Florian
-- 
View this message in context: 
http://www.nabble.com/dendrogram---got-it-%2C-just-need-to-label-%3A%29-tp9403784p15019424.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] contingency table on data frame

2008-01-22 Thread John Kane
It is not a good idea to use "sample' when building an
example like this!  Running the code does not give the
example dataframe.

This is crude but it will do what you want.

 x <- "  Z Y   X
   1 4 Yes
   2 1  No
   3 2 Perhaps
   4 3 Yes
   5 4  No
   6 5  No
   7 1 Yes
   8 4 Perhaps
   9 4 Yes
  10 2 Perhaps "
  
  xx <- read.table(textConnection(x), header=TRUE,
as.is=TRUE); xx
 
 df1 <- data.frame(xx[,3],xx[,2]) ; df1
 
 df2  <- unique(df1)
 table(df2[,1]) 

 


--- Karin Lagesen <[EMAIL PROTECTED]>
wrote:

> 
> I am sorry if this is a faq or tutorial somewhere,
> but I am unable to
> solve this one.
> 
> What I am looking for is a count of how many
> different
> categories(numbers in this case) that appears for a
> given factor.
> 
> Example:
> 
> > l <- c("Yes", "No", "Perhaps")
> > x <- factor( sample(l, 10, replace=T), levels=l )
> > m <- c(1:5)
> > y <- factor( sample(m, 10, replace=T), levels=m )
> > z = c(1:10)
> > my_df = data.frame("Z" = z, "Y"= y, "X" = x)
> > my_df
> Z Y   X
> 1   1 4 Yes
> 2   2 1  No
> 3   3 2 Perhaps
> 4   4 3 Yes
> 5   5 4  No
> 6   6 5  No
> 7   7 1 Yes
> 8   8 4 Perhaps
> 9   9 4 Yes
> 10 10 2 Perhaps
> > 
> 
> I am now looking for a table that will give me this:
> 
> Yes  3   # Yes has these ys: 4,3,1,4, two
> are the same, ergo 3
> No   3   # No has these ys: 1,4,5
> Perhaps  2   # Perhaps has these ys: 2,4,2
> 
> My dataframe has lots of other colums too, but I
> only want this
> information out.



  Looking for the perfect gift? Give the gift of Flickr!

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


Re: [R] Presenting results from multiple models in LaTeX table

2008-01-22 Thread Gabor Grothendieck
Create a data frame from the coefficients of your summary.lm objects
and use xtable.data.frame to latex that.  At the R console this will
display the relevant source code to see how to do it:

xtable:::xtable.lm
xtable:::xtable.summary.lm

On Jan 22, 2008 9:02 AM, 宋时歌 <[EMAIL PROTECTED]> wrote:
> Dear All,
>
> Is there a way to present results from multiple models in one LaTeX
> table? I did some google search and found out that xtable cannot
> automate this process
> (https://stat.ethz.ch/pipermail/r-help/2006-August/74.html), are
> there other alternatives? What about Design and Hmisc? Thanks.
>
> Best,
> Shige
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Risk Management (Solvency or Basileia)

2008-01-22 Thread Ana Patricia Silva Cunha Martins (DGR)
Dear Users,

 

Anyone knows a good package to works with risk management?

In particularly, if exist works in R about Solvency or Basileia projects?

 

Best Regards

Ana Patrícia Martins

 

 


[[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] Adding an Sweave Vignette to a package

2008-01-22 Thread Uwe Ligges


Doran, Harold wrote:
> Thanks, Uwe. Before I modify this path, I want to make sure of one
> thing. My path is set according to the specifications in the document
> prescribed by Duncan Murdoch (at link below). Indeed, my path includes
> the proper location of my MikTex and pdflatex.exe files. Here is my path
> from the command you gave below:
> 
> "c:\\Rtools\\bin;C:\\Perl\\bin\\;c:\\Rtools\\MinGW\\bin;c:\\texmf\\mikte
> k\\bin;c:\\cygwin;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System3
> 2\\Wbem;C:\\subversion\\Subversion\\bin;C:\\Program
> Files\\R\\R-2.2.0\\bin; " 
> 
> http://cran.r-project.org/doc/manuals/R-admin.html#The-Windows-toolset
> 
> AFAIK, the path indeed is set according to the Murdoch prescription for
> building R packages, my pdflatex.exe lives in the directory pointed to
> in this path, yet R cannot see it when doing Rcmd build. 
> 
> I can successfully build and use the package at this point (again as my
> other problem now solved). However, I am not sure what I should work on
> to resolve the issue of building the vignette.
> 
> There are so many steps in building a package, I may have missed
> something somewhere. So, if you see an error I appreciate any advice.

Hmm, hard to tell, although I think it might make sense to upgrade your 
version of R, given I am correct that you are running R-2.2.0 (from the 
output you gave above).

Uwe


> Harold
> 
> 
>> -Original Message-
>> From: Uwe Ligges [mailto:[EMAIL PROTECTED] 
>> Sent: Tuesday, January 22, 2008 4:15 AM
>> To: Doran, Harold
>> Cc: James W. MacDonald; R Help
>> Subject: Re: [R] Adding an Sweave Vignette to a package
>>
>> In R, type
>>   Sys.getenv("PATH")
>> and you will probably find that the PATH does not include the 
>> path of the pdflatex executable of the mikTeX distribution.
>>
>> Uwe
>>
>>
>> Doran, Harold wrote:
>>> Jim
>>>
>>> First thanks for your patience. I use MikTex as well. I do 
>> have both 
>>> (texti2dvi and pdflatex) on my local machine. I copied and 
>> pasted the 
>>> code below and stepped through it. I think this break down with the 
>>> following error. Indeed, I think there is a path problem.
>>>
>>> However, I don't see a resolution in either Writing R Extensions or 
>>> the Leisch paper. So, I'm not quite sure what path to 
>> modify and/or how.
>>> Error in texi2dvi("TheVignette.tex", pdf = TRUE) : 
>>>   unable to run pdflatex on 'TheVignette.tex'
>>> In addition: Warning message:
>>> In system(paste(shQuote(latex), "-interaction=nonstopmode", 
>> texfile)) :
>>>   "pdflatex" not found
>>>
 -Original Message-
 From: James W. MacDonald [mailto:[EMAIL PROTECTED]
 Sent: Monday, January 21, 2008 4:53 PM
 To: Doran, Harold
 Cc: R Help
 Subject: Re: [R] Adding an Sweave Vignette to a package

 What TeX variant are you using? If texi2dvi() can't find 
>> texi2dvi, it 
 tries to fall back on pdflatex which has to be in the path.

 I have always had good luck with MikTeX, which does have texi2dvi.

 You could always try

 library(tools)
 Sweave("TheVignette.Rnw")
 debug(texi2dvi)
 texi2dvi("TheVignette.tex", pdf=TRUE)

 and step through to see where it fails, although on the surface it 
 looks like a path problem.

 Best,

 Jim



 Doran, Harold wrote:
> There is now and it looks like I got through the first
 phase. But, now
> I get the error below.
>
> * DONE (MiscPsycho)
> * creating vignettes ... ERROR
> Loading required package: statmod
> Below is what alpha *would be* if the item were removed
>
> Error in texi2dvi(file = bft, pdf = TRUE, clean = FALSE, quiet =
> quiet)
> :
>   unable to run pdflatex on 'MP.tex'
> Calls: buildVignettes -> texi2dvi
> In addition: Warning messages:
> 1: In readLines(f[1]) : incomplete final line found on 'MP.Rnw'
> 2: In system(paste(shQuote(latex), "-interaction=nonstopmode",
> texfile))
> :
>   "pdflatex" not found
> Execution halted
>
> I do have pdflatex, it's what I use all of the time. 
 However, how do I
> point to it for this build process?
>
>> -Original Message-
>> From: James W. MacDonald [mailto:[EMAIL PROTECTED]
>> Sent: Monday, January 21, 2008 4:09 PM
>> To: Doran, Harold
>> Cc: R Help
>> Subject: Re: [R] Adding an Sweave Vignette to a package
>>
>> Hi Harold,
>>
>> Doran, Harold wrote:
>>> I'm finalizing development of a package that will include a
>> vignette.
>>> Without the vignette, the package builds fine with no
>> warnings and is
>>> ready for distribution. Now, I am following the directions for 
>>> developing vignettes "Sweave, Part II: Package Vignettes"
>> by Friedrich
>>> Leisch.
>>>
>>> I am using a windows XP machine (other session info
 below). Here is
>>> what I have done.
>>>
>>> 1) I add the 'in

[R] Presenting results from multiple models in LaTeX table

2008-01-22 Thread 宋时歌
Dear All,

Is there a way to present results from multiple models in one LaTeX
table? I did some google search and found out that xtable cannot
automate this process
(https://stat.ethz.ch/pipermail/r-help/2006-August/74.html), are
there other alternatives? What about Design and Hmisc? Thanks.

Best,
Shige

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


Re: [R] list.files sorted by date

2008-01-22 Thread John Kane
xx<- file.info(dir()); xx
xx[order(xx$mtime),] ?


--- Alberto Monteiro <[EMAIL PROTECTED]> wrote:

> Is there any (list.files)-like function that sorts
> the files by
> (modification) date?
> 
> Alberto Monteiro
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained,
> reproducible code.
> 



  Looking for the perfect gift? Give the gift of Flickr!

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


Re: [R] accessing the "address" of items in a recursive list

2008-01-22 Thread phlow



j daniel wrote:
> 
> 
> I would like to print the "address" of the smaller dendrograms on the edge
> similar to this:
> 
> addr <- function(n) {
>   if(!is.leaf(n)) {
> attr(n, "edgetext") <- paste("height of",(attr(n,"height"))
>   }
>   n
> }
> labeledDends <- dendrapply(dend, addr)
> 
> Where "i,j,k" is printed instead of "height".  But I have not been able to
> figure out how to ask each dendrogram its address within the dendrapply
> function.  Can anyone help me with this?
> 
> 
Hi!

Load the following four functions into R and execute this (assuming your
dendrogram is in variable 'dend')

newdend <- dendrapplyGlobal(dend,
"height",function(x){names(x)},attrNameTo="edgetext")



#From the specified dendrogram X a vector of all values of the specified 
#node attribute is extracted, modified by the function FUN and a new
#dendrogram is created using the new values for the attribute. Optionally,
#a different attribute can be set using 'attrNameTo'
dendrapplyGlobal <- function(X,attrName,FUN,...,attrNameTo=NULL) {
if (is.null(attrNameTo)) {
attrNameTo <- attrName
}
funcGet <- function(x){
attr(x,attrName)
}
funcSet <- function(x,value){
attr(x,attrNameTo) <- value
return(x)
}
values <- dendrapplyToVector(X,funcGet)
values <- FUN(values,...)
ret <- dendrapplyFromVector(X,values,funcSet)
return(ret)
}

#Traverses the dendrogram in postorder and applies FUN to each node.
#The result of each evaluation is stored in the resulting array.
#Additional arguments to FUN can be passed as ...
#The names attribute of the resulting vector is the 'path' to each node.
#This implementation is based on dendrapply(graphics).
dendrapplyToVector <- function(X,FUN,...) {
FUN <- match.fun(FUN)
if (!inherits(X, "dendrogram")) 
stop("'X' is not a dendrogram")
Napply <- function(d,path="") {
if (is.leaf(d)) {
ret <- c(FUN(d,...))
names(ret)[1] <- substr(path,start=1,stop=nchar(path)-1)
return(ret)
} 
ret <- vector()
for (j in seq_along(d)) {
addr <- paste(path,j,".",sep="")
ret <- append(ret,Napply(d[[j]],addr))
}
ret <- append(ret,FUN(d,...))
names(ret)[length(ret)] <- 
substr(path,start=1,stop=nchar(path)-1)
return(ret)
}
Napply(X)
}

#Traverses the dendrogram X in postorder and constructs a new dendrogram
using
#the specified function FUN and vector parVec. Each element of parVec must
#relate to a node in X, which is the case if parVec was created using
#dendrapplyToVector().
#Additional arguments to FUN can be passed as ...
#This implementation is based on dendrapply(graphics).
dendrapplyFromVector <- function(X,parVec,FUN,...) {
FUN <- match.fun(FUN)
if (!inherits(X, "dendrogram")) 
stop("'X' is not a dendrogram")
Napply <- function(d,v) {
if (is.leaf(d)) {
ret <- FUN(d,v,...)
return(ret)
} else {
ret <- d
if (!is.list(ret)) 
ret <- as.list(ret)
i <- 1
for (j in seq_along(d)) {
childrenCount <- getDendrogramNodeCount(d[[j]])
indices <- i:(i+childrenCount-1)
ret[[j]] <- Napply(d[[j]],v[indices])
i <- i + childrenCount
}
ret <- FUN(ret,v[i],...)
}
return(ret)
}
Napply(X,parVec)
}

#Returns the number of nodes in a dendrogram.
getDendrogramNodeCount <- function(dend) {
if (!is.leaf(dend)){
childrenSum <- 0
for (child in dend) {
childrenSum <- childrenSum + 
getDendrogramNodeCount(child)
}
return(childrenSum+1)
} 
return(1)
}


-- 
View this message in context: 
http://www.nabble.com/accessing-the-%22address%22-of-items-in-a-recursive-list-tp13938566p15019890.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] predict from a multiple regression model

2008-01-22 Thread Fränzi Korner
Hello

 

how can I predict from a lm-object over a range of values of one explanatory
variable without having to specify values for all the other explanatory
variables? 

 

e.g. 

 

mod<-lm(y~x1+x2+x3+x4)

 

x1.new<-seq(0, 100)

predict(mod, new=list(x1=x1.new))

 

 

Here, predict() does not work, since values for x2, x3 and x4 are missing.
Is there a function or argument that, in such a case, averages or weights
over the other explanatory variables, how it is done in Genstat? 

 

Thanks

Fränzi

 

 



Dr. Fränzi Korner-Nievergelt

oikostat - Statistische Analysen und Beratung

Ausserdorf 43

CH - 6218 Ettiswil

Tel.: +41 (0) 41 980 49 22

www.oikostat.ch



*



Schweizerische Vogelwarte

CH - 6204 Sempach



www.vogelwarte.ch

*




[[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] select repositories under linux

2008-01-22 Thread Gabor Csardi
Agreed, i had no idea that this is a Bioconductor package. 

G.

On Tue, Jan 22, 2008 at 09:49:50AM -0500, James W. MacDonald wrote:
> This is questionable advice for many CRAN packages, and horrible advice 
> for a Bioconductor package. If there are any dependencies (and BioC 
> packages often have many, and their dependencies may have 
> dependencies...) you can end up in download hell, all because you have 
> ignored the functionality that exists in R to handle such things.
> 
> As other posters have noted, you can use setRepositories(). You can also 
> set this in your .Rprofile file with something like
> 
> options(repos=(CRAN="http://ACloseRepository";))
> 
> so you don't have to do anything interactively.
> 
> Then use install.packages(), with dependencies=TRUE if you think there 
> may be dependencies (although I don't think it hurts if there are none).
> 
> For Bioconductor packages, use biocLite()
> 
> source("http://www.bioconductor.org/biocLite.R";)
> biocLite("GEOquery")
> 
> Best,
> 
> Jim
> 
> 
> Gabor Csardi wrote:
> >Eleni, download the package (I assume you know where it is), 
> >on Linux you will need the source package. Then from R type
> >
> >install.packages("", repos=NULL)
> >
> >Gabor
> >
> >On Tue, Jan 22, 2008 at 11:26:12AM +0200, Eleni Christodoulou wrote:
> >>Hi all,
> >>
> >>I am trying to install the package "GEOquery" in unix. I have downloaded 
> >>the
> >>standard version of R and this package is not contained in the default. I
> >>know that I can select repositories under windows but I don't know how to 
> >>do
> >>it in unix. Does anyone have any idea on this?
> >>
> >>Thank you in advance,
> >>Eleni
> >>
> >>[[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.
> >
> 
> -- 
> James W. MacDonald, M.S.
> Biostatistician
> Affymetrix and cDNA Microarray Core
> University of Michigan Cancer Center
> 1500 E. Medical Center Drive
> 7410 CCGC
> Ann Arbor MI 48109
> 734-647-5623

-- 
Csardi Gabor <[EMAIL PROTECTED]>UNIL DGM

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


Re: [R] accessing the "address" of items in a recursive list

2008-01-22 Thread phlow



j daniel wrote:
> 
> 
> I would like to print the "address" of the smaller dendrograms on the edge
> similar to this:
> 
> addr <- function(n) {
>   if(!is.leaf(n)) {
> attr(n, "edgetext") <- paste("height of",(attr(n,"height"))
>   }
>   n
> }
> labeledDends <- dendrapply(dend, addr)
> 
> Where "i,j,k" is printed instead of "height".  But I have not been able to
> figure out how to ask each dendrogram its address within the dendrapply
> function.  Can anyone help me with this?
> 
> 
Hi!

Load the following four functions into R and execute this (assuming your
dendrogram is in variable 'dend')

newdend <- dendrapplyGlobal(dend,
"height",function(x){names(x)},attrNameTo="edgetext")



#From the specified dendrogram X a vector of all values of the specified 
#node attribute is extracted, modified by the function FUN and a new
#dendrogram is created using the new values for the attribute. Optionally,
#a different attribute can be set using 'attrNameTo'
dendrapplyGlobal <- function(X,attrName,FUN,...,attrNameTo=NULL) {
if (is.null(attrNameTo)) {
attrNameTo <- attrName
}
funcGet <- function(x){
attr(x,attrName)
}
funcSet <- function(x,value){
attr(x,attrNameTo) <- value
return(x)
}
values <- dendrapplyToVector(X,funcGet)
values <- FUN(values,...)
ret <- dendrapplyFromVector(X,values,funcSet)
return(ret)
}

#Traverses the dendrogram in postorder and applies FUN to each node.
#The result of each evaluation is stored in the resulting array.
#Additional arguments to FUN can be passed as ...
#The names attribute of the resulting vector is the 'path' to each node.
#This implementation is based on dendrapply(graphics).
dendrapplyToVector <- function(X,FUN,...) {
FUN <- match.fun(FUN)
if (!inherits(X, "dendrogram")) 
stop("'X' is not a dendrogram")
Napply <- function(d,path="") {
if (is.leaf(d)) {
ret <- c(FUN(d,...))
names(ret)[1] <- substr(path,start=1,stop=nchar(path)-1)
return(ret)
} 
ret <- vector()
for (j in seq_along(d)) {
addr <- paste(path,j,".",sep="")
ret <- append(ret,Napply(d[[j]],addr))
}
ret <- append(ret,FUN(d,...))
names(ret)[length(ret)] <- 
substr(path,start=1,stop=nchar(path)-1)
return(ret)
}
Napply(X)
}

#Traverses the dendrogram X in postorder and constructs a new dendrogram
using
#the specified function FUN and vector parVec. Each element of parVec must
#relate to a node in X, which is the case if parVec was created using
#dendrapplyToVector().
#Additional arguments to FUN can be passed as ...
#This implementation is based on dendrapply(graphics).
dendrapplyFromVector <- function(X,parVec,FUN,...) {
FUN <- match.fun(FUN)
if (!inherits(X, "dendrogram")) 
stop("'X' is not a dendrogram")
Napply <- function(d,v) {
if (is.leaf(d)) {
ret <- FUN(d,v,...)
return(ret)
} else {
ret <- d
if (!is.list(ret)) 
ret <- as.list(ret)
i <- 1
for (j in seq_along(d)) {
childrenCount <- getDendrogramNodeCount(d[[j]])
indices <- i:(i+childrenCount-1)
ret[[j]] <- Napply(d[[j]],v[indices])
i <- i + childrenCount
}
ret <- FUN(ret,v[i],...)
}
return(ret)
}
Napply(X,parVec)
}

#Returns the number of nodes in a dendrogram.
getDendrogramNodeCount <- function(dend) {
if (!is.leaf(dend)){
childrenSum <- 0
for (child in dend) {
childrenSum <- childrenSum + 
getDendrogramNodeCount(child)
}
return(childrenSum+1)
} 
return(1)
}


hth,
Florian

-- 
View this message in context: 
http://www.nabble.com/accessing-the-%22address%22-of-items-in-a-recursive-list-tp13938566p15019892.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] Lattice on FreeBSD

2008-01-22 Thread Armin Goralczyk
Hi list
I tried to install package lattice on FreeBSD, but install.package()
does not seem to find it in the repositories, even trying different
mirrors. Could it be that lattice package is not available for
FreeBSD?

-- 
Armin Goralczyk, M.D.
--
Universitätsmedizin Göttingen
Abteilung Allgemein- und Viszeralchirurgie
Rudolf-Koch-Str. 40
39099 Göttingen
--
Dept. of General Surgery
University of Göttingen
Göttingen, Germany
--
http://www.gwdg.de/~agoralc
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Lattice on FreeBSD

2008-01-22 Thread Gabor Csardi
It is definitely on CRAN:
http://cran.at.r-project.org/src/contrib/Descriptions/lattice.html

You can download and install it "by hand", but if you want to 
make install.packages work, please give us at least an error message
or something.

G.

On Tue, Jan 22, 2008 at 03:29:19PM +0100, Armin Goralczyk wrote:
> Hi list
> I tried to install package lattice on FreeBSD, but install.package()
> does not seem to find it in the repositories, even trying different
> mirrors. Could it be that lattice package is not available for
> FreeBSD?
> 
> -- 
> Armin Goralczyk, M.D.
> --
> Universitätsmedizin Göttingen
> Abteilung Allgemein- und Viszeralchirurgie
> Rudolf-Koch-Str. 40
> 39099 Göttingen
> --
> Dept. of General Surgery
> University of Göttingen
> Göttingen, Germany
> --
> http://www.gwdg.de/~agoralc
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor <[EMAIL PROTECTED]>UNIL DGM

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


Re: [R] select repositories under linux

2008-01-22 Thread James W. MacDonald
This is questionable advice for many CRAN packages, and horrible advice 
for a Bioconductor package. If there are any dependencies (and BioC 
packages often have many, and their dependencies may have 
dependencies...) you can end up in download hell, all because you have 
ignored the functionality that exists in R to handle such things.

As other posters have noted, you can use setRepositories(). You can also 
set this in your .Rprofile file with something like

options(repos=(CRAN="http://ACloseRepository";))

so you don't have to do anything interactively.

Then use install.packages(), with dependencies=TRUE if you think there 
may be dependencies (although I don't think it hurts if there are none).

For Bioconductor packages, use biocLite()

source("http://www.bioconductor.org/biocLite.R";)
biocLite("GEOquery")

Best,

Jim


Gabor Csardi wrote:
> Eleni, download the package (I assume you know where it is), 
> on Linux you will need the source package. Then from R type
> 
> install.packages("", repos=NULL)
> 
> Gabor
> 
> On Tue, Jan 22, 2008 at 11:26:12AM +0200, Eleni Christodoulou wrote:
>> Hi all,
>>
>> I am trying to install the package "GEOquery" in unix. I have downloaded the
>> standard version of R and this package is not contained in the default. I
>> know that I can select repositories under windows but I don't know how to do
>> it in unix. Does anyone have any idea on this?
>>
>> Thank you in advance,
>> Eleni
>>
>>  [[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.
> 

-- 
James W. MacDonald, M.S.
Biostatistician
Affymetrix and cDNA Microarray Core
University of Michigan Cancer Center
1500 E. Medical Center Drive
7410 CCGC
Ann Arbor MI 48109
734-647-5623

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

2008-01-22 Thread marcia . rocha
Dear R users,
I have been having a problem with my file Rprofile.site. I did already ask the 
list some suggestions which have been well taken into account but unfortunately 
have not completely resolved my problem. I seem to have 2 files of 
Rprofile.site on my computer. If I open the file through " programm 
files/R/etc/rprofile.site"  on my editor I get a different file than if I go on 
"Display file(s)" on the File option of the menu bar on R. Anyone has an idea 
why this is happening? Where is R going to find this file?
Thank you very much for the attention,
Marcia Rocha

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


Re: [R] Communicating with R through a named pipe: display refresh problem

2008-01-22 Thread Prof Brian Ripley
Rather, non-interactive R does not run an event loop.  The usual way 
around this is to use a pty, as R run from a pty is considered to be 
interactive.

(Whether a fifo and a named pipe are the same concept is moot: some OSes 
have one and not the other.)

The plan is to use threads in due course to handle X11 events.

On Tue, 22 Jan 2008, Parker Jones wrote:

>
> Hello,
>
> On a linux system I'm trying to send commands to R through a named pipe and 
> am *nearly* successful.  I can send R commands and can plot graphs.  The only 
> problem I have is getting the x11 display to refresh - it appears to hang 
> because of the pipe.
>
> The R server:
> $ mkfifo R_pipe
> $ R --no-save < R_pipe
>
> The R client:
> $ cat>> R_pipe
>
> Now, I can send R commands down the pipe:
>
> Client side:
> x <- seq(1,10)
> x
>
> Server side:
>> x <- seq(1:10)
>> x
> [1]  1  2  3  4  5  6  7  8  9 10
>
> This is perfect.
>
> Now if I try to create a plot, e.g. plot(1:100), the server shows
>> plot(1:100)
> and the plot appears.  However, if a window briefly obscures the graphical 
> output, the x11 device won't refresh the display.  It would appear the pipe 
> is blocking the refresh.
>
> Can anyone else confirm this happens and any suggestions how to get the 
> display to refresh?
>
> Thanks in advance,
> PJ

-- 
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] predict from a multiple regression model

2008-01-22 Thread Chuck Cleland
On 1/22/2008 9:50 AM, Fränzi Korner wrote:
> Hello
> 
>  
> 
> how can I predict from a lm-object over a range of values of one explanatory
> variable without having to specify values for all the other explanatory
> variables? 
> 
>  
> 
> e.g. 
> 
>  
> 
> mod<-lm(y~x1+x2+x3+x4)
> 
>  
> 
> x1.new<-seq(0, 100)
> 
> predict(mod, new=list(x1=x1.new))
> 
>  
> 
>  
> 
> Here, predict() does not work, since values for x2, x3 and x4 are missing.
> Is there a function or argument that, in such a case, averages or weights
> over the other explanatory variables, how it is done in Genstat? 

   You might consider effect() in the effects package by John Fox.  For 
example:

library(effects)

mod.pres <- lm(prestige ~ log(income, 10) + poly(education, 3) +
poly(women, 2), data=Prestige)

effect("poly(women,2)", mod.pres, xlevels=list(women = seq(0,100,20)))

  poly(women,2) effect
women
0   20   40   60   80  100
47.71028 45.12385 44.53749 45.95121 49.36499 54.77883

> Thanks
> 
> Fränzi
> 
>  
> 
>  
> 
> 
> 
> Dr. Fränzi Korner-Nievergelt
> 
> oikostat - Statistische Analysen und Beratung
> 
> Ausserdorf 43
> 
> CH - 6218 Ettiswil
> 
> Tel.: +41 (0) 41 980 49 22
> 
> www.oikostat.ch
> 
> 
> 
> *
> 
> 
> 
> Schweizerische Vogelwarte
> 
> CH - 6204 Sempach
> 
> 
> 
> www.vogelwarte.ch
> 
> *
> 
> 
> 
> 
>   [[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.


-- 
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894

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


Re: [R] CRAN down?

2008-01-22 Thread Prof Brian Ripley
I was told that they had a UPS failure on one of the servers at the 
weekend.  It has been up and down for parts of each of the last three 
days, with many down periods (both short and long).


On Tue, 22 Jan 2008, Peter Dalgaard wrote:


Stefan Grosse wrote:

I am having problems to access the r-project.org homepage, someone else as
well?

(I know there are CRAN mirrors but they link back on the main page if I search
something)

Stefan



It's up for me now, but I had rather slow access earlier in the day.

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



--
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] Communicating with R through a named pipe: display refresh problem

2008-01-22 Thread Parker Jones



> Rather, non-interactive R does not run an event loop.  The usual way 
> around this is to use a pty, as R run from a pty is considered to be 
> interactive.
> 
> (Whether a fifo and a named pipe are the same concept is moot: some OSes 
> have one and not the other.)
> 
> The plan is to use threads in due course to handle X11 events.
> 
I agree threads is the way to go.

In the meantime, I also tried a looping server which doesn't block on reads to 
a pipe.  This still doesn't refresh the display but if R has a command to 
refresh the display then that will probably solve the problem.

# based on http://tolstoy.newcastle.edu.au/R/help/01c/2886.html
stream <- fifo("R_pipe", "r", blocking=FALSE,)
repeat
 {
  a <- readLines(stream)
  if(length(a) != 0)
   {
e <- try(eval(parse(text = a)))
if (inherits(e, "try-error"))
 {
  # error handling code here
  cat("Error", "\n")
 }
   }
 }

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Duncan's MRT: limitations to qtukey() function?

2008-01-22 Thread Andrea Onofri
Dear all,

I'm using R to perform multiple comparison testing on agriculture 
genotype trials. To perform  the Duncan's MRT, I use the qtukey() 
function with the following syntax:

qtukey(p = ((1 - 0.05) ^ (pos - 1)), nmeans = pos, df = ni)

I experience a strange behaviour when the number of means in the trial 
and the number of residual degrees of freedom (ni) becomes high 
(orientatively pos > 30 and ni > 60), i.e. the function returns NaN 
together with the following message:

convergence failed in 'qtukey'

Running the code below should reproduce a  statistical table for 
Duncan's MRT, such those reported on old books of agricultural 
statistics (ex. Steel and Torrie, 1960).

table <- matrix(0, 28, 14)
pos <- c(10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 50, 100, 200)
df <- c(2:20, seq(22, 30, by = 2), 40, 60, 100, 1000)
for (i in 1:28) table [i, ] <- qtukey(p = ((1 - 0.05) ^ (pos - 1)), 
nmeans = pos, df = df[i])
colnames(table) <- pos
rownames(table) <- df

Indeed, I get several NaN and some odd figures.

Am I doing something wrong or is there any intrinsic limit for the 
values of p, nmeans and df within the qtukey() function? Just in this 
latter case, is it possible to raise those limits? Some genotype trials 
can have more than thirty treatments  under comparison.

I thank you all for your attention.

Andrea Onofri
Department of Agriculture and Environmental Sciences
University of Perugia (ITALY)

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] anova function to test the difference between two coefficients in nlme package

2008-01-22 Thread shirley zhang
Dear Dr. Bates, and R-help,

I've tried the anova function  to test the difference between two
coefficients, as shown on page 225 of your book "Mixed Effects Models
in S and S-Plus (Statistics and Computing)".

When I type:  anova( fm2BW.lme, L = c(TimeDiet2 = 1, TimeDiet3 = -1) )

I got the following error message:

Error: unexpected '=' in "anova( fm2BW.lme, L = c(Time:Diet2 ="

Could you tell me whether I miss anything?

> sessionInfo()
R version 2.6.0 (2007-10-03)
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] stats graphics  grDevices utils datasets  methods   base

other attached packages:
[1] nlme_3.1-85

loaded via a namespace (and not attached):
[1] grid_2.6.0 lattice_0.16-5


Thanks,
Shirley

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

2008-01-22 Thread Chi Chan
If anyone gets R working with Rmpi and Grid Engine, please let me
know. I will need to set up a compute farm with SGE.

Thx,
--Chi

On Jan 21, 2008 8:19 PM, Mark Kimpel <[EMAIL PROTECTED]> wrote:
> try Rmpi package
>
> On Jan 21, 2008 7:13 PM, markaoki <[EMAIL PROTECTED]> wrote:
>
> > hi,
> > Does R have any built-in capabilities that allow one to use in a
> > multi-node
> > (supercomputer) environment?
> >
> > For example, MPI'ish commands allowing me to distribute specific R code to
> > specific compute nodes?
> >
> > If not, well, I would have more programming to do.
> >
> > thanks for any information about this,
> > -m.aoki
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
>
>
>
> --
> --
> Mark W. Kimpel MD
> Neuroinformatics
> Department of Psychiatry
> Indiana University School of Medicine
>
> [[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] Stationarity of a Time Series

2008-01-22 Thread Spencer Graves
the FinTS package includes in scripts\ch02.R a comparison of 4 different 
AFD unit root functions with a published example. 

it also includes a function plotArmaTrueacf that computes the roots from 
the AR part of a theoretical or fitted model.  From this, you can see if 
any roots lie near the unit circle.  You could wrap this in a Monte 
Carlo to test for many nonstandard types of nonstationarity, e.g. 
fractional differencing.

sg

Prof Brian Ripley wrote:
> On Tue, 22 Jan 2008, Pfaff, Bernhard Dr. wrote:
>
>   
>> Hello Stephen,
>>
>> stationarity tests as well as unit root tests have been implemented in a
>> couple of packages. For instance, as already mentioned: tseries, but
>> also uroot, fUnitRoots and urca. See the annotated task view
>> "Econemtrics" and "Finance" for further information.
>> 
>
> But note that these tests apply to just a few ways in which a series might 
> be non-stationary: they all seem an econmetrician's view of possible 
> non-stationarity.
>
> In the end stationarity is a modelling assumption: it depends on what 
> might have happened but did not.  E.g. a sine wave process is stationary 
> if and only if it has a random (uniform) phase, and you cannot tell that 
> from a single realization.
>
> 'Anna Karenina applies'[*] (as to most pure significance tests).
>
> [*] Google it if you need elucidation.
>
>   
>> Best,
>> Bernhard
>>
>> 
>>> kpss.test in the tsereis package should do the trick
>>>
>>> On Jan 21, 2008 12:36 PM, stephen sefick <[EMAIL PROTECTED]> wrote:
>>>
>>>   
 Does anyone know of a test for stationarity of a time series, or like
 all ordination techniques it is a qualitative assessment of a
 quantitative result.  Books, papers, etc. suggestions welcome.
 thanks

 Stephen

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


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

 
>>> [[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.
>>>
>>>   
>> *
>> Confidentiality Note: The information contained in this ...{{dropped:10}}
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>> 
>
>

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


Re: [R] Duncan's MRT: limitations to qtukey() function?

2008-01-22 Thread Peter Dalgaard
Andrea Onofri wrote:
> Dear all,
>
> I'm using R to perform multiple comparison testing on agriculture 
> genotype trials. To perform  the Duncan's MRT, I use the qtukey() 
> function with the following syntax:
>
> qtukey(p = ((1 - 0.05) ^ (pos - 1)), nmeans = pos, df = ni)
>
> I experience a strange behaviour when the number of means in the trial 
> and the number of residual degrees of freedom (ni) becomes high 
> (orientatively pos > 30 and ni > 60), i.e. the function returns NaN 
> together with the following message:
>
> convergence failed in 'qtukey'
>
> Running the code below should reproduce a  statistical table for 
> Duncan's MRT, such those reported on old books of agricultural 
> statistics (ex. Steel and Torrie, 1960).
>
> table <- matrix(0, 28, 14)
> pos <- c(10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 50, 100, 200)
> df <- c(2:20, seq(22, 30, by = 2), 40, 60, 100, 1000)
> for (i in 1:28) table [i, ] <- qtukey(p = ((1 - 0.05) ^ (pos - 1)), 
> nmeans = pos, df = df[i])
> colnames(table) <- pos
> rownames(table) <- df
>
> Indeed, I get several NaN and some odd figures.
>
> Am I doing something wrong or is there any intrinsic limit for the 
> values of p, nmeans and df within the qtukey() function? Just in this 
> latter case, is it possible to raise those limits? Some genotype trials 
> can have more than thirty treatments  under comparison.
>
> I thank you all for your attention.
>
> Andrea Onofri
> Department of Agriculture and Environmental Sciences
> University of Perugia (ITALY)
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>   
Yes, this looks a bit suspicious, especially the fact that it worsens
with increasing df. The core of the matter seems to be this

> qtukey(log(3.689754e-05),200,1000,log=T)
[1] NaN
Warning messages:
1: In qtukey(log(3.689754e-05), 200, 1000, log = T) :
  convergence failed in 'qtukey'
2: In qtukey(p, nranges, nmeans, df, lower.tail, log.p) : NaNs produced

which presumably is from inverting ptukey, but

> f <- Vectorize(function(x)ptukey(x,200,1000,log=T)-log(3.689754e-05))
> curve(f, from=3,to=5)
> uniroot(f, c(3,5))
$root
[1] 3.760707

$f.root
[1] -5.756398e-05

$iter
[1] 6

$estim.prec
[1] 6.103516e-05

is looking perfectly nice.

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


[R] a Q about R in unix

2008-01-22 Thread Wensui Liu
Dear All,
I finally have chance to have R install on our unix server. However,
the system admin asked me if I prefer command-line or gui interface.
I have experience with R on linux before but never use R on unix. Here
are my questions that I need you guys help.
1) is there a good gui for R/unix like we do for windows and mac?
2) if the answer for 1) is yes, which one is better interms of
computing performance and stability, cmd or gui?
3) do you have experience with ess+emacs on unix with R? Any insight?

This will be an experimental use of R in our company. If I can make a
successful case out of it, we might be able to use it in a larger
scale. So your input and help are highly appreciated.


===
WenSui Liu
Statistical Project Manager
ChoicePoint Precision Marketing
(http://spaces.msn.com/statcompute/blog)

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


Re: [R] ODE's in R

2008-01-22 Thread Spencer Graves
have you looked at lsoda{odesolve}?

have you looked at the scripts\CSTR subdirectory in the fda package?  it 
includes an example worked in both R and Matlab with slightly better 
answers in R but with a much longer compute time.

sg

The fda package

Peter Dalgaard wrote:
> Markku Karhunen wrote:
>   
>> Thanks, Dr. Maechler.
>>   
>> 
>>> No, there's no such track.
>>> [ Matlab users coming to R may produce wrong R code
>>>   by using 0:n-1 instead of 0:(n-1) ; but I don't assume this
>>>   would be the case ]
>>>
>>>   
>>> 
>>>   
>> Been there, done that!
>>   
>> 
>>> MK>  We use just a simple discretisation written in a for loop 
>>> MK> and a variable (i.e. user-fed) time step.
>>>
>>> I don't think you should use your own code instead of "professional"
>>> ODE solvers, such as the one in R package 'odesolve'
>>>
>>>   
>>> 
>>>   
>> We must look into that. The problem, maybe, is that in fact half of the 
>> equations are, in fact, simple PDE's and I don't know, if you can put 
>> them into odesolve.
>>   
>> 
> Usually, you can convert them to a system of ODE's ("the method of
> lines" if i remember correctly).
>
> One slight caveat with the high-end ODE solvers is that sometimes they
> are too smart for their own good when used in connection with parameter
> estimation. Because of things like adaptive stepsizing, you might end up
> with sums of squared residuals that are non-smooth functions of the
> parameters. This happens especially easily if the system itself is not
> quite smooth (e.g. if your input to the system is a step function).
>
>   
>>> MK> Maybe, I'm too neurotic about this, but I guess I just want some 
>>> comfort 
>>> MK> after seeing a few particularly nasty orbits.
>>>
>>> As we know ``from Chaos theory'', there can be delicate
>>> inhereent and numerical problems in ODE solving..
>>>   
>>> 
>>>   
>> But - to our best knowledge - they should not be any more acute in R, 
>> than on any other platform...
>>
>> BR,
>> Markku
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/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] anova function to test the difference between two coefficients in nlme package

2008-01-22 Thread shirley zhang
Dear Dr. Bates, and R-help,

I just found the reason I got the error message is because I copied
the code directly from the book. When I tried the code in
"~\library\nlme\scripts" under the R installation directory like the
following, I got the same answere as in the book.

anova(fm2BW.lme, L = c("Time:Diet2" = 1, "Time:Diet3" = -1))

Now my question is instead of test the difference between two
coefficients, can I use anova to test the significance of the sum of
two coefficients, like

anova(fm2BW.lme, L = c("Time:Diet2" = 1, "Time:Diet3" = 1))

Thanks,
Shirley


On Jan 22, 2008 10:38 AM, shirley zhang <[EMAIL PROTECTED]> wrote:
> Dear Dr. Bates, and R-help,
>
> I've tried the anova function  to test the difference between two
> coefficients, as shown on page 225 of your book "Mixed Effects Models
> in S and S-Plus (Statistics and Computing)".
>
> When I type:  anova( fm2BW.lme, L = c(TimeDiet2 = 1, TimeDiet3 = -1) )
>
> I got the following error message:
>
> Error: unexpected '=' in "anova( fm2BW.lme, L = c(Time:Diet2 ="
>
> Could you tell me whether I miss anything?
>
> > sessionInfo()
> R version 2.6.0 (2007-10-03)
> 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] stats graphics  grDevices utils datasets  methods   base
>
> other attached packages:
> [1] nlme_3.1-85
>
> loaded via a namespace (and not attached):
> [1] grid_2.6.0 lattice_0.16-5
>
>
> Thanks,
> Shirley
>

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

2008-01-22 Thread Thomas Steiner
Dear Duncan,

thanks a lot for your answer. I was think a was distracted by the FED
rate cut ;)
Now it works.
Have a nice day
Thomas

myfun1<-function(x,pa) {
  return(pa[1]*x^2+pa[2]*x+pa[3])
}
myfun2<-function(x,param,myfunk1,pa) {
  return(param[1]*myfunk1(x,pa)+param[2]*myfunk1(-x,pa))
}
test<-function(pars1,pars2,lo,up){
  
integ=integrate(f=myfun2,lower=lo,upper=up,param=pars2,myfunk1=myfun1,pa=pars1)
  return( integ$value )
}
test(pars1=c(1,2,3),pars2=c(-1,0),lo=1,up=7)

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


[R] Recursive Function

2008-01-22 Thread Carla Rebelo
It is possible to place two functions in a recursive function
Main results so as to simultaneously?
[[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] 2 Rprofile.site files???

2008-01-22 Thread Duncan Murdoch
On 1/22/2008 10:19 AM, [EMAIL PROTECTED] wrote:
> Dear R users,
> I have been having a problem with my file Rprofile.site. I did already ask 
> the list some suggestions which have been well taken into account but 
> unfortunately have not completely resolved my problem. I seem to have 2 files 
> of Rprofile.site on my computer. If I open the file through " programm 
> files/R/etc/rprofile.site"  on my editor I get a different file than if I go 
> on "Display file(s)" on the File option of the menu bar on R. Anyone has an 
> idea why this is happening? Where is R going to find this file?
> Thank you very much for the attention,

The latter case generally looks in the current directory, which would be 
unlikely to be R_HOME/etc unless you had explicitly set it there.

Duncan Murdoch

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


Re: [R] R object as a function

2008-01-22 Thread Sebastian Mueller
On Tuesday 22 January 2008 13:52:29 Thomas Steiner wrote:
> Thank you very much Duncan for your quick answers.
>
> > You're not passing a function as myfunk1, you're passing mf, which is
> > the result of evaluating myfun1, so it's a numeric vector.
>
> Yes, this is exacty my problem.
> If I leave it away, the problem will not be resolved (it needs pa or not)
>
> myfun1<-function(x,pa) {
>   return(pa[1]*x^2+pa[2]*x+pa[3])
> }
> myfun2<-function(x,param,myfunk1) {
>   return(param[1]*myfunk1(x)+param[2]*myfunk1(x))
> }
> test<-function(pars1,pars2,lo,up){
>  
> integ=integrate(f=myfun2,lower=lo,upper=up,param=pars2,myfunk1=myfun1)#pa=p
>ars1 return( 2*integ$value )
> }
> test(pars1=c(1,2,3),pars2=c(-1,1),lo=2,up=7)
>
> Which gives an error:
> Once the "argument pa" is missing  and if you add the "pa=pars1" in
> the comment, it says that the argument pa is redundant.
>
If I understood your problem right (i don't know haw integrate() works) the 
solution could be as follows 

myfun1<-function(x=5,pa) {
  return(function(x){pa[1]*x^2+pa[2]*x+pa[3]})
}

It's a substitution for your myfun1 and it gives back a closure (function with 
bindings) instead of a numeric.
Hope it helps

Sebastian

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

2008-01-22 Thread Thomas Downey

Hi just wondering if there is a package that can get the maximum likelihood
or method of moments estimator for distributions with censored data?  The
distributions I'm interested in are: Exponential, pareto, beta, gamma and
lognormal.
-- 
View this message in context: 
http://www.nabble.com/MLE-for-censored-distributions-in-R-tp15022863p15022863.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] recoding one variable into another - but differently for different cases

2008-01-22 Thread Dimitri Liakhovitski
Hello,
I have 2 variables in my sample Data: Data$A and Data$B
Variable Data$A can assume values: 1, 2, 3, and 4.
Variable Data$B identifies my cases and can assume values: 1 and 2.

I need to recode my variable Data$A into a new variable Data$new such that:

People who are Data[Data$B %in% 1, ]  are recoded like this:

Value on Data$AValue on Data$new
1 +1
2 -1
3 0
4 99

People who are Data[Data$B %in% 2, ]  are recoded like this:

Value on Data$AValue on Data$new
1 -1
2 +1
3 0
4 99

I am having hard time doing this. Any help would be greatly appreciated.
Dimitri

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


Re: [R] select repositories under linux

2008-01-22 Thread Prof Brian Ripley
On Tue, 22 Jan 2008, James W. MacDonald wrote:

> This is questionable advice for many CRAN packages, and horrible advice
> for a Bioconductor package. If there are any dependencies (and BioC
> packages often have many, and their dependencies may have
> dependencies...) you can end up in download hell, all because you have
> ignored the functionality that exists in R to handle such things.

But unfortunately the advice below is equally 'questionable'.

> As other posters have noted, you can use setRepositories(). You can also
> set this in your .Rprofile file with something like
>
> options(repos=(CRAN="http://ACloseRepository";))
>
> so you don't have to do anything interactively.

That is not what setRepositories() does: it is what chooseCRANmirror() 
does and does not help here.

> Then use install.packages(), with dependencies=TRUE if you think there
> may be dependencies (although I don't think it hurts if there are none).

The default (dependencies=NA) was chosen for good reasons ... it selects 
the dependencies you need to run the package, and not others needed to 
e.g. check it.

> For Bioconductor packages, use biocLite()
>
> source("http://www.bioconductor.org/biocLite.R";)
> biocLite("GEOquery")

which advice should be clarified by noting that is just a wrapper to the R 
facilities to handle multiple repositories, and if you are going to learn 
to use those anyway for other repositories it is not necessary to do it 
via the wrapper.

setRepositories(ind=c(1,3:6))  # Windows ind = c(1,2, 4:7)
... use install.packages for any CRAN or BioC package
*BUT* beware that some packages have incompatible versions on the two
repositories and that this will pick the largest version number for such.


> Best,
>
> Jim
>
>
> Gabor Csardi wrote:
>> Eleni, download the package (I assume you know where it is),
>> on Linux you will need the source package. Then from R type
>>
>> install.packages("", repos=NULL)
>>
>> Gabor
>>
>> On Tue, Jan 22, 2008 at 11:26:12AM +0200, Eleni Christodoulou wrote:
>>> Hi all,
>>>
>>> I am trying to install the package "GEOquery" in unix. I have downloaded the
>>> standard version of R and this package is not contained in the default. I
>>> know that I can select repositories under windows but I don't know how to do
>>> it in unix. Does anyone have any idea on this?
>>>
>>> Thank you in advance,
>>> Eleni
>>>
>>> [[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.
>>
>
> --
> James W. MacDonald, M.S.
> Biostatistician
> Affymetrix and cDNA Microarray Core
> University of Michigan Cancer Center
> 1500 E. Medical Center Drive
> 7410 CCGC
> Ann Arbor MI 48109
> 734-647-5623
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] extension to nlme self start SSmicmen?

2008-01-22 Thread David Airey
Dear list,

Has anyone created a version of SSmicmen that allows testing for group  
differences? The basic Michaelis-Menten equation is:

(Bmax * X) / (Kd + X).

The nlme package allows modeling of random effects for Bmax and Kd as  
needed, but I curious how I can build in group differences? I have  
receptor binding data for strains of mice, and following Pinheiro and  
Bates' lead in their book, a random effort for animal differences in  
Bmax seems reasonable, within strain. However, I'd like a self-start  
function, or even just the equation above, modified to allow testing  
for strain differences in Bmax and or Kd.

Thank you.

-Dave

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Res: predict from a multiple regression model

2008-01-22 Thread Milton Cezar Ribeiro
Hi Franzi,

Up to I know you can´t predict values without you have x2,x3 and x4 parameters. 
So you have three possible solution

1) set x2, x3 and x4 to Zero, *but* it will depend so much of what you want, 
because if you set them to zero, it means that you are adjusting something like 
mod<-lm(y~x1)
2) set x2,x3 and x4 to and mean value that you understand as rasonable for your 
purpose]
and 
3) build a set of for () looping, with the ranges of x2, x3 and x4, and see 
what happens with the y, for each combination of x1-x2-x3-x4.

y<-runif(101)
x1<-sample(seq(0, 100))
x2<-seq(from=0,to=100,by=1)
x3<-seq(from=0,to=100,by=1)^2
x4<-exp(seq(from=0,to=100,by=1))
df<-data.frame(cbind(y,x1,x2,x3,x4))
mod<-lm(y~x1+x2+x3+x3,data=df)

df.complete<-NULL
for (x2 in seq(from=0,to=100,by=20)) {
for (x3 in seq(from=0,to=100,by=20)) {
for (x4 in seq(from=0,to=100,by=20)) {
x1<-seq(0, 100, by=10)
df.new<-data.frame(cbind(x1,x2,x3,x4))
df.new$pred<-predict(mod,new=df.new)
df.complete<-rbind(df.complete,df.new)
}}}

head(df.complete,50)
summary(df.complete)


But you have a problema. If you have four dimensions (x1-x4), it is so hard to 
graph. In the case of two dimensions (like x1 and x2) you can use the function 
interp() function of akima´s packge to generate a 3d plot of your response 
variavel y-pred as a surface. 

Good luck,

miltinho
Brazil

- Mensagem original 
De: Fränzi Korner <[EMAIL PROTECTED]>
Para: r-help@r-project.org
Enviadas: Terça-feira, 22 de Janeiro de 2008 11:50:03
Assunto: [R] predict from a multiple regression model

Hello



how can I predict from a lm-object over a range of values of one explanatory
variable without having to specify values for all the other explanatory
variables? 



e.g. 



mod<-lm(y~x1+x2+x3+x4)



x1.new<-seq(0, 100)

predict(mod, new=list(x1=x1.new))





Here, predict() does not work, since values for x2, x3 and x4 are missing.
Is there a function or argument that, in such a case, averages or weights
over the other explanatory variables, how it is done in Genstat? 



Thanks

Fränzi







Dr. Fränzi Korner-Nievergelt

oikostat - Statistische Analysen und Beratung

Ausserdorf 43

CH - 6218 Ettiswil

Tel.: +41 (0) 41 980 49 22

www.oikostat.ch



*



Schweizerische Vogelwarte

CH - 6204 Sempach



www.vogelwarte.ch

*




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

[[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] recoding one variable into another - but differently for different cases

2008-01-22 Thread Marc Schwartz

Dimitri Liakhovitski wrote:
> Hello,
> I have 2 variables in my sample Data: Data$A and Data$B
> Variable Data$A can assume values: 1, 2, 3, and 4.
> Variable Data$B identifies my cases and can assume values: 1 and 2.
> 
> I need to recode my variable Data$A into a new variable Data$new such that:
> 
> People who are Data[Data$B %in% 1, ]  are recoded like this:
> 
> Value on Data$AValue on Data$new
> 1 +1
> 2 -1
> 3 0
> 4 99
> 
> People who are Data[Data$B %in% 2, ]  are recoded like this:
> 
> Value on Data$AValue on Data$new
> 1 -1
> 2 +1
> 3 0
> 4 99
> 
> I am having hard time doing this. Any help would be greatly appreciated.
> Dimitri

How about this:

> Data
   A B
14 2 2
12 4 2
6  2 1
10 2 2
15 3 2
9  1 2
8  4 1
3  3 1
4  4 1
11 3 2
16 4 2
5  1 1
2  2 1
7  3 1
13 1 2
1  1 1


# Create a vector of the codes, in sequence for each subset
Codes <- c("+1", "-1", "0", "99", "-1", "+1", "0", "99")

# Create 'new' using indices into 'Codes'
Data$new <- with(Data, Codes[((B - 1) * 4) + A])

> Data
   A B new
14 2 2  +1
12 4 2  99
6  2 1  -1
10 2 2  +1
15 3 2   0
9  1 2  -1
8  4 1  99
3  3 1   0
4  4 1  99
11 3 2   0
16 4 2  99
5  1 1  +1
2  2 1  -1
7  3 1   0
13 1 2  -1
1  1 1  +1



HTH,

Marc Schwartz

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


[R] stripchart

2008-01-22 Thread mohamed nur anisah
hi,
   
  I want to plot a dotplot graph but unfortunately R does not have it any more. 
It suggest to use either the stripchart or the dotchart and i prefer to play 
around with the stripchart graph. Sadly, the result is not like i want where 
I'm actually wants the plots/points were scattered around the x-axis. Plus, 
from the results shows that and the x-axis gave a very large scale, i.e 
5.0e+0.7. How am i going to change this scale and to change the colour or 
symbols where i can show the difference of the sample data. Any suggestion??
   
   two sample data:
   e
 [1]  17358865  17966995  21306539  27880531  34166504  36111044  36266288
 [8]  36854306  43786190  44322336  45529444  46302360  53479132  58567262
[15]  60564442  72637088  79875476  93155112  94372260  96643396 103123936
[22] 116908456 131781664 132968364 135945080 141788832 149924864 156539568
[29] 157817896 162399496 168344072 173146584 176302744 182878168 183946152
[36] 185068720 190791232NA
> f
 [1]  17906353  21295547  27880531  34118702  35395488  36132622  37916920
 [8]  43786190  44322336  46302360  53494622  62105336  63817440  72637088
[15]  79875476  94545992  96506368 103123936 116908456 126190072 127446552
[22] 131781664 154658264 176302744 181670472 182625272 182878168 183946152
[29]NA

  R-command:
   
   stripchart(e,method="stack",col="green",add=F,at=0.0)
 stripchart(f,method="stack",col="blue",add=T,at=0.0)


  Thanks in advance.
   
  Cheers,
  Anisah

   
-

[[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] recoding one variable into another - but differently for different cases

2008-01-22 Thread Gabor Grothendieck
You could create a lookup table or use recode in the car package.

Another possibility is to use a logical/arithmetic expression.  The
following expression says that

- if A is 1 then use the first term equals the coefficient, namely 1
if B ==1 and -1 if B == 2.
  Also, if A is not 1 then that term is zero and can be ignored.
- if A is 2 or 99 then the second or third terms are used analogously
- otherwise no terms are selected and the expression equals zero

   transform(Data, new =
  (A == 1) * ((B == 1) - (B == 2)) + (A == 2) * ((B == 2) - (B ==
1)) + (A == 4) * 99)

This could be reduced even more although at the expense of
understandability, e.g.

   transform(Data, new = ifelse(A > 2, 99 * (A == 4), (A == B) - (A != B)))

On Jan 22, 2008 12:25 PM, Dimitri Liakhovitski <[EMAIL PROTECTED]> wrote:
> Hello,
> I have 2 variables in my sample Data: Data$A and Data$B
> Variable Data$A can assume values: 1, 2, 3, and 4.
> Variable Data$B identifies my cases and can assume values: 1 and 2.
>
> I need to recode my variable Data$A into a new variable Data$new such that:
>
> People who are Data[Data$B %in% 1, ]  are recoded like this:
>
> Value on Data$AValue on Data$new
> 1 +1
> 2 -1
> 3 0
> 4 99
>
> People who are Data[Data$B %in% 2, ]  are recoded like this:
>
> Value on Data$AValue on Data$new
> 1 -1
> 2 +1
> 3 0
> 4 99
>
> I am having hard time doing this. Any help would be greatly appreciated.
> Dimitri
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] recoding one variable into another - but differently fordifferent cases

2008-01-22 Thread Bert Gunter
Try this:

z1 <- c(1,-1,0,99)[Data$A]
z2 <- c(-1,1,0,99)[Data$A]
Data$new <- ifelse(Data$B == 1, z1,z2)

(This does not generalize, however, and assumes that the values you gave are
exact. Gabor's approach would work more generally)

-- Bert Gunter
Genentech Nonclinical Statistics

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Gabor Grothendieck
Sent: Tuesday, January 22, 2008 11:09 AM
To: Dimitri Liakhovitski
Cc: R-Help List
Subject: Re: [R] recoding one variable into another - but differently
fordifferent cases

You could create a lookup table or use recode in the car package.

Another possibility is to use a logical/arithmetic expression.  The
following expression says that

- if A is 1 then use the first term equals the coefficient, namely 1
if B ==1 and -1 if B == 2.
  Also, if A is not 1 then that term is zero and can be ignored.
- if A is 2 or 99 then the second or third terms are used analogously
- otherwise no terms are selected and the expression equals zero

   transform(Data, new =
  (A == 1) * ((B == 1) - (B == 2)) + (A == 2) * ((B == 2) - (B ==
1)) + (A == 4) * 99)

This could be reduced even more although at the expense of
understandability, e.g.

   transform(Data, new = ifelse(A > 2, 99 * (A == 4), (A == B) - (A != B)))

On Jan 22, 2008 12:25 PM, Dimitri Liakhovitski <[EMAIL PROTECTED]> wrote:
> Hello,
> I have 2 variables in my sample Data: Data$A and Data$B
> Variable Data$A can assume values: 1, 2, 3, and 4.
> Variable Data$B identifies my cases and can assume values: 1 and 2.
>
> I need to recode my variable Data$A into a new variable Data$new such
that:
>
> People who are Data[Data$B %in% 1, ]  are recoded like this:
>
> Value on Data$AValue on Data$new
> 1 +1
> 2 -1
> 3 0
> 4 99
>
> People who are Data[Data$B %in% 2, ]  are recoded like this:
>
> Value on Data$AValue on Data$new
> 1 -1
> 2 +1
> 3 0
> 4 99
>
> I am having hard time doing this. Any help would be greatly appreciated.
> Dimitri
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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

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


[R] suppress some boxes drawn by legend(,fill)

2008-01-22 Thread Tom Boonen
Is there any way suppress box color and frame of a box drawn by
legend(,fill)? I am able to suppress the color, but not the frame (see
the example below). Many thanks! (This follows up from a question
asked on the list in 2006 by Florian Koller)

Tom

x1 <- rnorm(100)
x2 <- rnorm(100, 2)
hist(x1, main = "", col = "orange",ylab = "density", xlab = "x", freq
= F, density = 55,xlim = c(-2, 5), ylim = c(0, 0.5))
par(new = T)
hist(x2, main = "", col = "green", ylab = "", xlab = "",axes = F, xlim
= c(-2, 5), ylim = c(0, 0.5), density = 45, freq = F)
abline(v = mean(x1), col = "orange", lty = 2, lwd = 2.5)
abline(v = mean(x2), col = "green", lty = 2, lwd = 2.5)
legend(3, 0.45, legend = c("x1", "x2", "mean(x1)", "mean(x2)"),
   col = c("orange", "green"), fill=c("orange","green", 0, 0),
   lty = c(0, 0, 2, 2), merge = T)

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


Re: [R] extension to nlme self start SSmicmen?

2008-01-22 Thread David Airey
> Dear list,
>
> Has anyone created a version of SSmicmen that allows testing for  
> group differences? The basic Michaelis-Menten equation is:
>
> (Bmax * X) / (Kd + X).
>
> The nlme package allows modeling of random effects for Bmax and Kd  
> as needed, but I curious how I can build in group differences? I  
> have receptor binding data for strains of mice, and following  
> Pinheiro and Bates' lead in their book, a random effort for animal  
> differences in Bmax seems reasonable, within strain. However, I'd  
> like a self-start function, or even just the equation above,  
> modified to allow testing for strain differences in Bmax and or Kd.
>
> Thank you.
>
> -Dave

Reading more closely, I now think I don't have to change the self  
start function SSmicmen to test for treatment group fixed effects. I  
just need to get the list of fixed effects right, to include the  
strain factor. Something like "fixed = list(bmax + kd ~ strain),  
random = list(bmax + kd ~ 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.


Re: [R] stripchart

2008-01-22 Thread John Kane
Have a look at stripplot in lattice. I think it may do
what you want if you cbind e & f and then create an
identifier to plot against.

   e <- c(17358865 , 17966995 , 21306539 , 27880531, 
34166504,  36111044,  36266288,
36854306 , 43786190 , 44322336 , 45529444,  46302360, 
53479132,  58567262,
60564442 , 72637088 , 79875476 , 93155112,  94372260, 
96643396, 103123936,
116908456, 131781664, 132968364, 135945080, 141788832,
149924864, 156539568,
157817896, 162399496, 168344072, 173146584, 176302744,
182878168, 183946152,
185068720, 190791232,NA )

 f <- c(17906353,  21295547,  27880531,  34118702 ,
35395488,  36132622 , 37916920,
43786190,  44322336,  46302360,  53494622 , 62105336, 
63817440 , 72637088 ,
79875476,  94545992 , 96506368, 103123936 ,116908456,
126190072, 127446552 ,
131781664, 154658264 ,176302744, 181670472, 182625272,
182878168, 183946152,
 NA )
 
ec <- rep("ee", length(e)) 
fc <- rep("ff", length(f))
bb <- data.frame(c(ec,fc),c(e,f))

stripplot(bb[,2]~bb[,1])
 


--- mohamed nur anisah <[EMAIL PROTECTED]>
wrote:

> hi,
>
>   I want to plot a dotplot graph but unfortunately R
> does not have it any more. It suggest to use either
> the stripchart or the dotchart and i prefer to play
> around with the stripchart graph. Sadly, the result
> is not like i want where I'm actually wants the
> plots/points were scattered around the x-axis. Plus,
> from the results shows that and the x-axis gave a
> very large scale, i.e 5.0e+0.7. How am i going to
> change this scale and to change the colour or
> symbols where i can show the difference of the
> sample data. Any suggestion??
>
>two sample data:
>e
>  [1]  17358865  17966995  21306539  27880531 
> 34166504  36111044  36266288
>  [8]  36854306  43786190  44322336  45529444 
> 46302360  53479132  58567262
> [15]  60564442  72637088  79875476  93155112 
> 94372260  96643396 103123936
> [22] 116908456 131781664 132968364 135945080
> 141788832 149924864 156539568
> [29] 157817896 162399496 168344072 173146584
> 176302744 182878168 183946152
> [36] 185068720 190791232NA
> > f
>  [1]  17906353  21295547  27880531  34118702 
> 35395488  36132622  37916920
>  [8]  43786190  44322336  46302360  53494622 
> 62105336  63817440  72637088
> [15]  79875476  94545992  96506368 103123936
> 116908456 126190072 127446552
> [22] 131781664 154658264 176302744 181670472
> 182625272 182878168 183946152
> [29]NA
> 
>   R-command:
>
>   
>
stripchart(e,method="stack",col="green",add=F,at=0.0)
> 
> stripchart(f,method="stack",col="blue",add=T,at=0.0)
> 
> 
>   Thanks in advance.
>
>   Cheers,
>   Anisah
> 
>
> -
> 
>   [[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] suppress some boxes drawn by legend(,fill)

2008-01-22 Thread John Kane
box.lty = 0  

assuming I understand the question.  
--- Tom Boonen <[EMAIL PROTECTED]> wrote:

> Is there any way suppress box color and frame of a
> box drawn by
> legend(,fill)? I am able to suppress the color, but
> not the frame (see
> the example below). Many thanks! (This follows up
> from a question
> asked on the list in 2006 by Florian Koller)
> 
> Tom
> 
> x1 <- rnorm(100)
> x2 <- rnorm(100, 2)
> hist(x1, main = "", col = "orange",ylab = "density",
> xlab = "x", freq
> = F, density = 55,xlim = c(-2, 5), ylim = c(0, 0.5))
> par(new = T)
> hist(x2, main = "", col = "green", ylab = "", xlab =
> "",axes = F, xlim
> = c(-2, 5), ylim = c(0, 0.5), density = 45, freq =
> F)
> abline(v = mean(x1), col = "orange", lty = 2, lwd =
> 2.5)
> abline(v = mean(x2), col = "green", lty = 2, lwd =
> 2.5)
> legend(3, 0.45, legend = c("x1", "x2", "mean(x1)",
> "mean(x2)"),
>col = c("orange", "green"),
> fill=c("orange","green", 0, 0),
>lty = c(0, 0, 2, 2), merge = T)
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained,
> reproducible code.
> 



  Looking for the perfect gift? Give the gift of Flickr!

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] X11 font at size 6 could not be loaded

2008-01-22 Thread Wittner, Ben, Ph.D.
I recently upgraded my OS to Fedora 8 from Red Hat Enterprise Work Station 3.
Before I upgraded certain operations would produce a warning to the effect that
a desired font was not available so one had been substituted, which was okay.
After the upgrade to Fedora 8, the plotting operation halts midway through and I
get the following error message:
"X11 font at size 6 could not be loaded"
This is not okay, because plotting does not complete.

I've also gotten that message regarding size 8.

In R, if it do getOption("X11fonts") I get
[1] "-adobe-helvetica-%s-%s-*-*-%d-*-*-*-*-*-*-*"
[2] "-adobe-symbol-medium-r-*-*-%d-*-*-*-*-*-*-*"

If from bash I do xlsfonts, I see that I have fonts that match, but the smallest
seem to be 11 points:
-adobe-helvetica-bold-o-normal--11-80-100-100-p-60-iso10646-1
-adobe-helvetica-bold-o-normal--11-80-100-100-p-60-iso8859-1

If I run the same program on my Fedora 8 system but use an X server on a Windows
PC (Hummingbird X server), I have no problem.

If I can't fix this, this is a disaster for me because some of the most common
things I do are afflicted by this problem.

Can anyone help me get adobe-helvetica 6 and 8 point fonts onto my system or
give any other advice?

Thanks very much.
-Ben

p.s., I also tried in R
options(X11fonts="-misc-fixed-%s-%s-*-*-%d-*-*-*-*-*-*-*")
but that resulted in
Error in X11(display, width, height, pointsize, if (is.null(gamma)) 1 else
gamma,  : 
  invalid 'fonts' value
when I tried to plot.

p.p.s, here's my version information
platform   i686-pc-linux-gnu   
arch   i686
os linux-gnu   
system i686, linux-gnu 
status 
major  2   
minor  6.1 
year   2007
month  11  
day26  
svn rev43537   
language   R   
version.string R version 2.6.1 (2007-11-26)

The information transmitted in this electronic communication is intended only
for the person or entity to whom it is addressed and may contain confidential
and/or privileged material. Any review, retransmission, dissemination or other
use of or taking of any action in reliance upon this information by persons or
entities other than the intended recipient is prohibited. If you received this
information in error, please contact the Compliance HelpLine at 800-856-1983 and
properly dispose of this information.

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


Re: [R] suppress some boxes drawn by legend(,fill)

2008-01-22 Thread John Kane
It occured to me afterwards that this was not what you
wanted.   I think Jerome Asselin  in
http://finzi.psych.upenn.edu/R/Rhelp02a/archive/15483.html
has a solution that may do what you want

Try

legend(3, 0.45, legend = c("x1", "x2", "mean(x1)",
"mean(x2)"), pch=c(22,22,30,30), 
   col = c("orange", "green"),
pt.bg=c("orange","green","white","white"),
   lty = c(0, 0, 2, 2), merge = T)


--- John Kane <[EMAIL PROTECTED]> wrote:

> box.lty = 0  
> 
> assuming I understand the question.  
> --- Tom Boonen <[EMAIL PROTECTED]> wrote:
> 
> > Is there any way suppress box color and frame of a
> > box drawn by
> > legend(,fill)? I am able to suppress the color,
> but
> > not the frame (see
> > the example below). Many thanks! (This follows up
> > from a question
> > asked on the list in 2006 by Florian Koller)
> > 
> > Tom
> > 
> > x1 <- rnorm(100)
> > x2 <- rnorm(100, 2)
> > hist(x1, main = "", col = "orange",ylab =
> "density",
> > xlab = "x", freq
> > = F, density = 55,xlim = c(-2, 5), ylim = c(0,
> 0.5))
> > par(new = T)
> > hist(x2, main = "", col = "green", ylab = "", xlab
> =
> > "",axes = F, xlim
> > = c(-2, 5), ylim = c(0, 0.5), density = 45, freq =
> > F)
> > abline(v = mean(x1), col = "orange", lty = 2, lwd
> =
> > 2.5)
> > abline(v = mean(x2), col = "green", lty = 2, lwd =
> > 2.5)
> > legend(3, 0.45, legend = c("x1", "x2", "mean(x1)",
> > "mean(x2)"),
> >col = c("orange", "green"),
> > fill=c("orange","green", 0, 0),
> >lty = c(0, 0, 2, 2), merge = T)
> > 
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained,
> > reproducible code.
> > 
> 
> 
> 
>   Looking for the perfect gift? Give the gift of
> Flickr! 
> 
> http://www.flickr.com/gift/
> 
>

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


Re: [R] X11 font at size 6 could not be loaded

2008-01-22 Thread Peter Dalgaard
Wittner, Ben, Ph.D. wrote:
> I recently upgraded my OS to Fedora 8 from Red Hat Enterprise Work Station 3.
> Before I upgraded certain operations would produce a warning to the effect 
> that
> a desired font was not available so one had been substituted, which was okay.
> After the upgrade to Fedora 8, the plotting operation halts midway through 
> and I
> get the following error message:
> "X11 font at size 6 could not be loaded"
> This is not okay, because plotting does not complete.
>
> I've also gotten that message regarding size 8.
>
> In R, if it do getOption("X11fonts") I get
> [1] "-adobe-helvetica-%s-%s-*-*-%d-*-*-*-*-*-*-*"
> [2] "-adobe-symbol-medium-r-*-*-%d-*-*-*-*-*-*-*"
>
> If from bash I do xlsfonts, I see that I have fonts that match, but the 
> smallest
> seem to be 11 points:
> -adobe-helvetica-bold-o-normal--11-80-100-100-p-60-iso10646-1
> -adobe-helvetica-bold-o-normal--11-80-100-100-p-60-iso8859-1
>
> If I run the same program on my Fedora 8 system but use an X server on a 
> Windows
> PC (Hummingbird X server), I have no problem.
>
> If I can't fix this, this is a disaster for me because some of the most common
> things I do are afflicted by this problem.
>
> Can anyone help me get adobe-helvetica 6 and 8 point fonts onto my system or
> give any other advice?
>
> Thanks very much.
> -Ben
>
> p.s., I also tried in R
> options(X11fonts="-misc-fixed-%s-%s-*-*-%d-*-*-*-*-*-*-*")
> but that resulted in
> Error in X11(display, width, height, pointsize, if (is.null(gamma)) 1 else
> gamma,  : 
>   invalid 'fonts' value
> when I tried to plot.
>
> p.p.s, here's my version information
> platform   i686-pc-linux-gnu   
> arch   i686
> os linux-gnu   
> system i686, linux-gnu 
> status 
> major  2   
> minor  6.1 
> year   2007
> month  11  
> day26  
> svn rev43537   
> language   R   
> version.string R version 2.6.1 (2007-11-26)
>
>   
The usual suspect is that you do not have the unscalable fonts in both 
75 and 100 dpi:

xorg-x11-fonts-100dpi-7.2-3.fc8
xorg-x11-fonts-ISO8859-1-75dpi-7.2-3.fc8
xorg-x11-fonts-ISO8859-1-100dpi-7.2-3.fc8
xorg-x11-fonts-75dpi-7.2-3.fc8
xorg-x11-fonts-ISO8859-2-75dpi-7.2-3.fc8
xorg-x11-fonts-ISO8859-2-100dpi-7.2-3.fc8


-- 
   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] recoding one variable into another - but differently for different cases

2008-01-22 Thread Gabor Grothendieck
Slight correction of the English:

- if A is 1 then the first term equals the coefficient of (A == 1).
  That is the first term equals 1 if B==1 and equals -1 if B==2.
  If A does not equal 1 then the first term is zero and can be ignored.
- terms 2 and 3 are interpreted analogously
- if A==3 (or other value) then the (A==?) part of each term equals
  zero so the entire expression is zero.

On Jan 22, 2008 2:08 PM, Gabor Grothendieck <[EMAIL PROTECTED]> wrote:
> You could create a lookup table or use recode in the car package.
>
> Another possibility is to use a logical/arithmetic expression.  The
> following expression says that
>
> - if A is 1 then use the first term equals the coefficient, namely 1
> if B ==1 and -1 if B == 2.
>  Also, if A is not 1 then that term is zero and can be ignored.
> - if A is 2 or 99 then the second or third terms are used analogously
> - otherwise no terms are selected and the expression equals zero
>
>   transform(Data, new =
>  (A == 1) * ((B == 1) - (B == 2)) + (A == 2) * ((B == 2) - (B ==
> 1)) + (A == 4) * 99)
>
> This could be reduced even more although at the expense of
> understandability, e.g.
>
>   transform(Data, new = ifelse(A > 2, 99 * (A == 4), (A == B) - (A != B)))
>
>
> On Jan 22, 2008 12:25 PM, Dimitri Liakhovitski <[EMAIL PROTECTED]> wrote:
> > Hello,
> > I have 2 variables in my sample Data: Data$A and Data$B
> > Variable Data$A can assume values: 1, 2, 3, and 4.
> > Variable Data$B identifies my cases and can assume values: 1 and 2.
> >
> > I need to recode my variable Data$A into a new variable Data$new such that:
> >
> > People who are Data[Data$B %in% 1, ]  are recoded like this:
> >
> > Value on Data$AValue on Data$new
> > 1 +1
> > 2 -1
> > 3 0
> > 4 99
> >
> > People who are Data[Data$B %in% 2, ]  are recoded like this:
> >
> > Value on Data$AValue on Data$new
> > 1 -1
> > 2 +1
> > 3 0
> > 4 99
> >
> > I am having hard time doing this. Any help would be greatly appreciated.
> > Dimitri
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/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] Reading .csv file under linux

2008-01-22 Thread David Scott

I have encountered a problem with reading a .csv file on a linux box. I 
can read the file on my windows machine (under XP) but on the linux box it 
gives :

> patients <- read.csv("../Patients.csv", header = FALSE,
+  col.names = patientsNames)
Error in type.convert(data[[i]], as.is = as.is[i], dec = dec,
na.strings = character(0)) :
   invalid multibyte string
Calls: read.csv -> read.table -> type.convert
Execution halted

I am running R 2.6.1 on both machines. I tried on another linux box 
running 2.5.1 and got the same problem

I am guessing it is something to do with the character encoding. On the 
linux box I have

LANG=en_US.UTF-8

Any advice would be welcome

David Scott


_
David Scott Department of Statistics, Tamaki Campus
The University of Auckland, PB 92019
Auckland 1142,NEW ZEALAND
Phone: +64 9 373 7599 ext 86830 Fax: +64 9 373 7000
Email:  [EMAIL PROTECTED]

Graduate Officer, Department of Statistics
Director of Consulting, Department of Statistics

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


Re: [R] X11 font at size 6 could not be loaded

2008-01-22 Thread Prof Brian Ripley
Have you also changed your locale?  F8 defaults to UTF-8 locales, whereas 
people usually set up RHEL3 with an 8-bit locale.  That changes the font 
selection, and you may find that running in en_US works whereas en_US.utf8 
does not.

Note that the font you quote is an 8 point 100dpi font, at 11 pixels not 
points.  What you actually need depends on the dpi of your screen, and if 
that is less than 100 dpi you need the 75dpi fonts.

Another idea is to install the scalable fonts in the urw-fonts package, 
and use something like

foo <- getOption("X11fonts")
foo[1] <- "-urw-nimbus sans l-%s-%s-*-*-%d-*-*-*-*-*-*-*"
options(X11fonts=foo)

to select them.


On Tue, 22 Jan 2008, Wittner, Ben, Ph.D. wrote:

> I recently upgraded my OS to Fedora 8 from Red Hat Enterprise Work 
> Station 3. Before I upgraded certain operations would produce a warning 
> to the effect that a desired font was not available so one had been 
> substituted, which was okay. After the upgrade to Fedora 8, the plotting 
> operation halts midway through and I get the following error message:
> "X11 font at size 6 could not be loaded"
> This is not okay, because plotting does not complete.
>
> I've also gotten that message regarding size 8.

Showing the actual messages would have been helpful.

>
> In R, if it do getOption("X11fonts") I get
> [1] "-adobe-helvetica-%s-%s-*-*-%d-*-*-*-*-*-*-*"
> [2] "-adobe-symbol-medium-r-*-*-%d-*-*-*-*-*-*-*"
>
> If from bash I do xlsfonts, I see that I have fonts that match, but the 
> smallest
> seem to be 11 points:
> -adobe-helvetica-bold-o-normal--11-80-100-100-p-60-iso10646-1
> -adobe-helvetica-bold-o-normal--11-80-100-100-p-60-iso8859-1

Looks like you don't have the 75dpi fonts installed, so try installing 
those (xorg-x11-fonts-75dpi, it seems).

> If I run the same program on my Fedora 8 system but use an X server on a 
> Windows
> PC (Hummingbird X server), I have no problem.

That will have scalable fonts.

> If I can't fix this, this is a disaster for me because some of the most common
> things I do are afflicted by this problem.
>
> Can anyone help me get adobe-helvetica 6 and 8 point fonts onto my system or
> give any other advice?
>
> Thanks very much.
> -Ben
>
> p.s., I also tried in R
> options(X11fonts="-misc-fixed-%s-%s-*-*-%d-*-*-*-*-*-*-*")
> but that resulted in
> Error in X11(display, width, height, pointsize, if (is.null(gamma)) 1 else
> gamma,  :
>  invalid 'fonts' value
> when I tried to plot.

Yes, it does have to length 2.

>
> p.p.s, here's my version information
> platform   i686-pc-linux-gnu
> arch   i686
> os linux-gnu
> system i686, linux-gnu
> status
> major  2
> minor  6.1
> year   2007
> month  11
> day26
> svn rev43537
> language   R
> version.string R version 2.6.1 (2007-11-26)

-- 
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] Reading .csv file under linux

2008-01-22 Thread Prof Brian Ripley
On Wed, 23 Jan 2008, David Scott wrote:

>
> I have encountered a problem with reading a .csv file on a linux box. I
> can read the file on my windows machine (under XP) but on the linux box it
> gives :
>
>> patients <- read.csv("../Patients.csv", header = FALSE,
> +  col.names = patientsNames)
> Error in type.convert(data[[i]], as.is = as.is[i], dec = dec,
> na.strings = character(0)) :
>   invalid multibyte string
> Calls: read.csv -> read.table -> type.convert
> Execution halted
>
> I am running R 2.6.1 on both machines. I tried on another linux box
> running 2.5.1 and got the same problem
>
> I am guessing it is something to do with the character encoding. On the
> linux box I have
>
> LANG=en_US.UTF-8

So what encoding is the .csv file in?  Consider the example at the end of 
?file

  ## examples of use of encodings
  cat(x, file = file("foo", "w", encoding="UTF-8"))
  # read a 'Windows Unicode' file including names
  A <- read.table(file("students", encoding="UCS-2LE"))

and adapt accordingly (encoding = "CP1252" is the most likely value if 
this works in English-language Windows).

-- 
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] X11 font at size 6 could not be loaded

2008-01-22 Thread Wittner, Ben, Ph.D.
Thank you very much.
I found .noarch.rpm's for the first 4 of the 6 you listed below and installed
them and the problem went away.

Strangely, when I tried to intstall (using rpm -Uvh) the 100 dpi ones I got a
message saying that they were already installed. Nevertheless, when I restarted
the X server, xlsfonts showed more fonts for the 100 dpi case (in particular,
the small ones, 10 and 8) as well as the 75 dpis, which had not been there
before.

I don't understand that, but my problem is solved, so I am happy. Thanks again.

-Ben

> -Original Message-
> From: Peter Dalgaard [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, January 22, 2008 5:00 PM
> To: Wittner, Ben, Ph.D.
> Cc: r-help@r-project.org
> Subject: Re: [R] X11 font at size 6 could not be loaded
> 
> Wittner, Ben, Ph.D. wrote:
> > I recently upgraded my OS to Fedora 8 from Red Hat Enterprise Work
> Station 3.
> > Before I upgraded certain operations would produce a warning to the
> effect that
> > a desired font was not available so one had been substituted, which was
> okay.
> > After the upgrade to Fedora 8, the plotting operation halts midway
> through and I
> > get the following error message:
> > "X11 font at size 6 could not be loaded"
> > This is not okay, because plotting does not complete.
> >
> > I've also gotten that message regarding size 8.
> >
> > In R, if it do getOption("X11fonts") I get
> > [1] "-adobe-helvetica-%s-%s-*-*-%d-*-*-*-*-*-*-*"
> > [2] "-adobe-symbol-medium-r-*-*-%d-*-*-*-*-*-*-*"
> >
> > If from bash I do xlsfonts, I see that I have fonts that match, but the
> smallest
> > seem to be 11 points:
> > -adobe-helvetica-bold-o-normal--11-80-100-100-p-60-iso10646-1
> > -adobe-helvetica-bold-o-normal--11-80-100-100-p-60-iso8859-1
> >
> > If I run the same program on my Fedora 8 system but use an X server on a
> Windows
> > PC (Hummingbird X server), I have no problem.
> >
> > If I can't fix this, this is a disaster for me because some of the most
> common
> > things I do are afflicted by this problem.
> >
> > Can anyone help me get adobe-helvetica 6 and 8 point fonts onto my
> system or
> > give any other advice?
> >
> > Thanks very much.
> > -Ben
> >
> > p.s., I also tried in R
> > options(X11fonts="-misc-fixed-%s-%s-*-*-%d-*-*-*-*-*-*-*")
> > but that resulted in
> > Error in X11(display, width, height, pointsize, if (is.null(gamma)) 1
> else
> > gamma,  :
> >   invalid 'fonts' value
> > when I tried to plot.
> >
> > p.p.s, here's my version information
> > platform   i686-pc-linux-gnu
> > arch   i686
> > os linux-gnu
> > system i686, linux-gnu
> > status
> > major  2
> > minor  6.1
> > year   2007
> > month  11
> > day26
> > svn rev43537
> > language   R
> > version.string R version 2.6.1 (2007-11-26)
> >
> >
> The usual suspect is that you do not have the unscalable fonts in both
> 75 and 100 dpi:
> 
> xorg-x11-fonts-100dpi-7.2-3.fc8
> xorg-x11-fonts-ISO8859-1-75dpi-7.2-3.fc8
> xorg-x11-fonts-ISO8859-1-100dpi-7.2-3.fc8
> xorg-x11-fonts-75dpi-7.2-3.fc8
> xorg-x11-fonts-ISO8859-2-75dpi-7.2-3.fc8
> xorg-x11-fonts-ISO8859-2-100dpi-7.2-3.fc8
> 
> 
> --
>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

The information transmitted in this electronic communication is intended only
for the person or entity to whom it is addressed and may contain confidential
and/or privileged material. Any review, retransmission, dissemination or other
use of or taking of any action in reliance upon this information by persons or
entities other than the intended recipient is prohibited. If you received this
information in error, please contact the Compliance HelpLine at 800-856-1983 and
properly dispose of this information.

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


Re: [R] X11 font at size 6 could not be loaded

2008-01-22 Thread Wittner, Ben, Ph.D.
Dear Prof. Ripley,
Thanks very much.
Changing the locale did not help, but finding and installing (or re-installing)
xorg-x11-fonts for 75 and 100 dpi did the trick.
It's still a bit of a mystery to me, but my attempt to install xorg-x11-fonts
for 100 dpi appeared to fail, but nevertheless I found more 100 dpi
adobe-helvetica fonts available to the X server when I was done.
Thanks also for explaining why my attempt to change the X11fonts option was a
failure.
-Ben

> -Original Message-
> From: Prof Brian Ripley [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, January 22, 2008 5:16 PM
> To: Wittner, Ben, Ph.D.
> Cc: r-help@r-project.org
> Subject: Re: [R] X11 font at size 6 could not be loaded
> 
> Have you also changed your locale?  F8 defaults to UTF-8 locales, whereas
> people usually set up RHEL3 with an 8-bit locale.  That changes the font
> selection, and you may find that running in en_US works whereas en_US.utf8
> does not.
> 
> Note that the font you quote is an 8 point 100dpi font, at 11 pixels not
> points.  What you actually need depends on the dpi of your screen, and if
> that is less than 100 dpi you need the 75dpi fonts.
> 
> Another idea is to install the scalable fonts in the urw-fonts package,
> and use something like
> 
> foo <- getOption("X11fonts")
> foo[1] <- "-urw-nimbus sans l-%s-%s-*-*-%d-*-*-*-*-*-*-*"
> options(X11fonts=foo)
> 
> to select them.
> 
> 
> On Tue, 22 Jan 2008, Wittner, Ben, Ph.D. wrote:
> 
> > I recently upgraded my OS to Fedora 8 from Red Hat Enterprise Work
> > Station 3. Before I upgraded certain operations would produce a warning
> > to the effect that a desired font was not available so one had been
> > substituted, which was okay. After the upgrade to Fedora 8, the plotting
> > operation halts midway through and I get the following error message:
> > "X11 font at size 6 could not be loaded"
> > This is not okay, because plotting does not complete.
> >
> > I've also gotten that message regarding size 8.
> 
> Showing the actual messages would have been helpful.
> 
> >
> > In R, if it do getOption("X11fonts") I get
> > [1] "-adobe-helvetica-%s-%s-*-*-%d-*-*-*-*-*-*-*"
> > [2] "-adobe-symbol-medium-r-*-*-%d-*-*-*-*-*-*-*"
> >
> > If from bash I do xlsfonts, I see that I have fonts that match, but the
> smallest
> > seem to be 11 points:
> > -adobe-helvetica-bold-o-normal--11-80-100-100-p-60-iso10646-1
> > -adobe-helvetica-bold-o-normal--11-80-100-100-p-60-iso8859-1
> 
> Looks like you don't have the 75dpi fonts installed, so try installing
> those (xorg-x11-fonts-75dpi, it seems).
> 
> > If I run the same program on my Fedora 8 system but use an X server on a
> Windows
> > PC (Hummingbird X server), I have no problem.
> 
> That will have scalable fonts.
> 
> > If I can't fix this, this is a disaster for me because some of the most
> common
> > things I do are afflicted by this problem.
> >
> > Can anyone help me get adobe-helvetica 6 and 8 point fonts onto my
> system or
> > give any other advice?
> >
> > Thanks very much.
> > -Ben
> >
> > p.s., I also tried in R
> > options(X11fonts="-misc-fixed-%s-%s-*-*-%d-*-*-*-*-*-*-*")
> > but that resulted in
> > Error in X11(display, width, height, pointsize, if (is.null(gamma)) 1
> else
> > gamma,  :
> >  invalid 'fonts' value
> > when I tried to plot.
> 
> Yes, it does have to length 2.
> 
> >
> > p.p.s, here's my version information
> > platform   i686-pc-linux-gnu
> > arch   i686
> > os linux-gnu
> > system i686, linux-gnu
> > status
> > major  2
> > minor  6.1
> > year   2007
> > month  11
> > day26
> > svn rev43537
> > language   R
> > version.string R version 2.6.1 (2007-11-26)
> 
> --
> 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

The information transmitted in this electronic communication is intended only
for the person or entity to whom it is addressed and may contain confidential
and/or privileged material. Any review, retransmission, dissemination or other
use of or taking of any action in reliance upon this information by persons or
entities other than the intended recipient is prohibited. If you received this
information in error, please contact the Compliance HelpLine at 800-856-1983 and
properly dispose of this information.

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

2008-01-22 Thread David Scott
On Tue, 22 Jan 2008, Prof Brian Ripley wrote:

> On Wed, 23 Jan 2008, David Scott wrote:
>
>> 
>> I have encountered a problem with reading a .csv file on a linux box. I
>> can read the file on my windows machine (under XP) but on the linux box it
>> gives :
>> 
>>> patients <- read.csv("../Patients.csv", header = FALSE,
>> +  col.names = patientsNames)
>> Error in type.convert(data[[i]], as.is = as.is[i], dec = dec,
>> na.strings = character(0)) :
>>   invalid multibyte string
>> Calls: read.csv -> read.table -> type.convert
>> Execution halted
>> 
>> I am running R 2.6.1 on both machines. I tried on another linux box
>> running 2.5.1 and got the same problem
>> 
>> I am guessing it is something to do with the character encoding. On the
>> linux box I have
>> 
>> LANG=en_US.UTF-8
>
> So what encoding is the .csv file in?  Consider the example at the end of 
> ?file
>
> ## examples of use of encodings
> cat(x, file = file("foo", "w", encoding="UTF-8"))
> # read a 'Windows Unicode' file including names
> A <- read.table(file("students", encoding="UCS-2LE"))
>
> and adapt accordingly (encoding = "CP1252" is the most likely value if this 
> works in English-language Windows).
>


Thanks Brian for the super-quick, super-helpful reply. The encoding you 
suggested worked.

I found a workaround myself too---I guessed that some plus/minus signs 
might be the problem and replaced them and could read in the file.
That is just a kludge so I am using the encoding specification.

I am a total dunce when it comes to encodings though. How do you find the 
encoding of a file?

David

_
David Scott Department of Statistics, Tamaki Campus
The University of Auckland, PB 92019
Auckland 1142,NEW ZEALAND
Phone: +64 9 373 7599 ext 86830 Fax: +64 9 373 7000
Email:  [EMAIL PROTECTED]

Graduate Officer, Department of Statistics
Director of Consulting, Department of Statistics

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

2008-01-22 Thread Prof Brian Ripley
On Wed, 23 Jan 2008, David Scott wrote:

> On Tue, 22 Jan 2008, Prof Brian Ripley wrote:
>
>> On Wed, 23 Jan 2008, David Scott wrote:
>> 
>>> 
>>> I have encountered a problem with reading a .csv file on a linux box. I
>>> can read the file on my windows machine (under XP) but on the linux box it
>>> gives :
>>> 
 patients <- read.csv("../Patients.csv", header = FALSE,
>>> +  col.names = patientsNames)
>>> Error in type.convert(data[[i]], as.is = as.is[i], dec = dec,
>>> na.strings = character(0)) :
>>>   invalid multibyte string
>>> Calls: read.csv -> read.table -> type.convert
>>> Execution halted
>>> 
>>> I am running R 2.6.1 on both machines. I tried on another linux box
>>> running 2.5.1 and got the same problem
>>> 
>>> I am guessing it is something to do with the character encoding. On the
>>> linux box I have
>>> 
>>> LANG=en_US.UTF-8
>> 
>> So what encoding is the .csv file in?  Consider the example at the end of 
>> ?file
>>
>> ## examples of use of encodings
>> cat(x, file = file("foo", "w", encoding="UTF-8"))
>> # read a 'Windows Unicode' file including names
>> A <- read.table(file("students", encoding="UCS-2LE"))
>> 
>> and adapt accordingly (encoding = "CP1252" is the most likely value if this 
>> works in English-language Windows).
>> 
>
>
> Thanks Brian for the super-quick, super-helpful reply. The encoding you 
> suggested worked.
>
> I found a workaround myself too---I guessed that some plus/minus signs might 
> be the problem and replaced them and could read in the file.
> That is just a kludge so I am using the encoding specification.
>
> I am a total dunce when it comes to encodings though. How do you find the 
> encoding of a file?

You ask the person who gave it to you.  You can't in general tell, and 
e.g. ISO-8859-1 and ISO-8859-2 are only distinguishable by someone who can 
read the contents (if it is a human language).  If you have just the odd 
symbol (e.g. degree sign or plus/minus) you can be completely stuck.

'file' on Linux can usually guess if a file is UTF-8 or ISO-8859-?, but 
not of course what ? is.  But guesses are based on statistical patterns 
and are good for text but not so good for data.

-- 
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] recoding one variable into another - but differently for different cases

2008-01-22 Thread Dimitri Liakhovitski
Thanks a lot, everyone!
Dimitri

On 1/22/08, Gabor Grothendieck <[EMAIL PROTECTED]> wrote:
> Slight correction of the English:
>
> - if A is 1 then the first term equals the coefficient of (A == 1).
>  That is the first term equals 1 if B==1 and equals -1 if B==2.
>  If A does not equal 1 then the first term is zero and can be ignored.
> - terms 2 and 3 are interpreted analogously
> - if A==3 (or other value) then the (A==?) part of each term equals
>  zero so the entire expression is zero.
>
> On Jan 22, 2008 2:08 PM, Gabor Grothendieck <[EMAIL PROTECTED]> wrote:
> > You could create a lookup table or use recode in the car package.
> >
> > Another possibility is to use a logical/arithmetic expression.  The
> > following expression says that
> >
> > - if A is 1 then use the first term equals the coefficient, namely 1
> > if B ==1 and -1 if B == 2.
> >  Also, if A is not 1 then that term is zero and can be ignored.
> > - if A is 2 or 99 then the second or third terms are used analogously
> > - otherwise no terms are selected and the expression equals zero
> >
> >   transform(Data, new =
> >  (A == 1) * ((B == 1) - (B == 2)) + (A == 2) * ((B == 2) - (B ==
> > 1)) + (A == 4) * 99)
> >
> > This could be reduced even more although at the expense of
> > understandability, e.g.
> >
> >   transform(Data, new = ifelse(A > 2, 99 * (A == 4), (A == B) - (A != B)))
> >
> >
> > On Jan 22, 2008 12:25 PM, Dimitri Liakhovitski <[EMAIL PROTECTED]> wrote:
> > > Hello,
> > > I have 2 variables in my sample Data: Data$A and Data$B
> > > Variable Data$A can assume values: 1, 2, 3, and 4.
> > > Variable Data$B identifies my cases and can assume values: 1 and 2.
> > >
> > > I need to recode my variable Data$A into a new variable Data$new such 
> > > that:
> > >
> > > People who are Data[Data$B %in% 1, ]  are recoded like this:
> > >
> > > Value on Data$AValue on Data$new
> > > 1 +1
> > > 2 -1
> > > 3 0
> > > 4 99
> > >
> > > People who are Data[Data$B %in% 2, ]  are recoded like this:
> > >
> > > Value on Data$AValue on Data$new
> > > 1 -1
> > > 2 +1
> > > 3 0
> > > 4 99
> > >
> > > I am having hard time doing this. Any help would be greatly appreciated.
> > > Dimitri
> > >
> > > __
> > > R-help@r-project.org mailing list
> > > https://stat.ethz.ch/mailman/listinfo/r-help
> > > PLEASE do read the posting guide 
> > > http://www.R-project.org/posting-guide.html
> > > and provide commented, minimal, self-contained, reproducible code.
> > >
> >
>

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


  1   2   >