Re: [R] How to tell if lattice is current device?

2009-02-11 Thread Dieter Menne
Remko Duursma  gmail.com> writes:

> >> How can I tell if the current device was made with plot() or e.g.
> >> levelplot() or another lattice function?
> >> dev.cur() does not help me, it just tells me "windows 2".
> >
Deepayan:
> > A device can have both types, although that's rare.
> >
> > The best you can probably do is keep track of the last call to
> > plot.new() and grid.newpage(). See
> >
> > ?setHook
> > ?plot.new
> > ?grid.newpage
> >

Dieter:

library(lattice)
isStandard = function()
{
  options(graphics="standard")  
}
isLattice = function()
{
  options(graphics="lattice")  
}

setHook("plot.new",isStandard)
setHook("grid.newpage",isLattice)

xyplot(1~1)
options("graphics")
plot(1,1)
options("graphics")

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

2009-02-11 Thread mouradster

Dear R user I follow the steps defined in Modern applied statistics page(453)
to use optim. However, when I run the following code the parameters seems
way off and the third parameter(p3) stayed as the initial value.
below is the code:
## data
da=c(418,401,416,360,411,425,537,379,484,388,486,380,394,363,405,383,392,363,398,526)

### initial values
pars=c(392.25, 507.25,   0.80)
p1=pars[1];p2=pars[2];p3=pars[3]
 
### Objective function
mix.obj = function(p,x)
{
e =p[3]*(pnorm((x+1/2-p[1])/sqrt(p[1]))-pnorm((x-1/2-p[1])/sqrt(p[1])))
 + (1-p[3])*(pnorm((x-1/2-p[2])/sqrt(p[2]))-pnorm((x-3/2-p[2])/sqrt(p[2])))
if (any(e<=0)) Inf
else -sum(log(e))
} 

### Calculate the first derivatives of the objective function.
lmix2a = deriv(~
-log(p3*pnorm((x+1/2-p1)/sqrt(p1))-pnorm((x-1/2-p1)/sqrt(p1))
 + (1-p3)*pnorm((x-1/2-p2)/sqrt(p2))-pnorm((x-3/2-p2)/sqrt(p2))),
c("p3","p2","p1"), 
   function(x,p1,p2,p3) NULL)

mix.gr = function(p,x)
{
p3 = p[3]
p2 = p[2]
p1 = p[1]
colSums(attr(lmix2a(x,p3,p2,p1),"gradient"))
}
### optim
(resultsBFGS_D=optim(pars,mix.obj,mix.gr,x=da,method="L-BFGS-B",lower=rep(0,3),upper=c(Inf,Inf,1),hessian=T)$par)

Also, sometimes it gives me the following error:
Error in optim(pars, mix.obj, mix.gr, x = da, method = "L-BFGS-B", lower =
rep(0,  : 
  L-BFGS-B needs finite values of 'fn'

Thanks in advance for ur help.

-- 
View this message in context: 
http://www.nabble.com/Optim-tp21970390p21970390.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] 2 different colors for 2 groups of lines using xyplot

2009-02-11 Thread Dieter Menne
Yu, Xuesong  scharp.org> writes:

> I am trying to use xyplot to plot several lines in one panel with red
> color  for a group of lines, say 3 lines and blue color for another
> group of lines, say 4. I know this can be easily  done using regular
> plot function. But i could not figure out how to do this in xyplot. 
> 

states <- data.frame(state.x77,
 state.name = dimnames(state.x77)[[1]], 
 state.region = state.region) 
xyplot(Murder ~ Population, data = states, 
   groups = state.region,
   col.line=c("red","red","green","green"),
   panel = panel.superpose,
   panel.groups = panel.loess)
# Note the difference when colors are recycled
xyplot(Murder ~ Population, data = states, 
   groups = state.region,
   col.line=c("red","green"),
   panel = panel.superpose,
   panel.groups = panel.loess)

  
Dieter

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


Re: [R] How to handle large numbers?

2009-02-11 Thread david.jessop
Hi,

I've realised (as I'm sure have lots of others) that the second part of my 
answer is complete rubbish. Obviously having a bad day.

However you could work out one over your expression which then you split into 
two parts, calculate and then reinvert.

Apologies for version 1

David

--
David Jessop
Global Head of Quantitative Research
UBS Investment Research

+44 20 7567 9882


- Original Message -
From: Jessop, David
To: r-help@r-project.org 
Cc: 840...@gmail.com <840...@gmail.com>
Sent: Wed Feb 11 13:55:14 2009
Subject: How to handle large numbers?

Hi

In answer to your first question is that it can be anything.  If we look at 0 * 
a = 0 and let a tend to infinity, and b * Inf = Inf and let b tend to zero then 
you can get both zero and infinity as an answer.  If you say consider c * 1/c = 
1 and let c tend to infinity then it can be one too (you get the idea). 

On your second point, then a bit of transformation would help:  
exp (a) / (exp (b) + c) = 
exp (a) / (exp (b) + exp (log (c)) =
exp (a - (b + log (c))

For example, 
> exp (10) / (exp (11) - 2)
[1] 0.3678917
> exp (10 - 11 - log(2))
[1] 0.1839397

So in your case you get

exp (1000 - 1007 - log(5))
[1] 0.0001823764

Regards,

David



--

Message: 4
Date: Wed, 11 Feb 2009 11:40:14 +0100
From: Feng Li <840...@gmail.com>
Subject: [R] How to handle large numbers?
To: r-help@r-project.org
Message-ID:
<339934530902110240y1cf64fd6u2101c3a706e1d...@mail.gmail.com>
Content-Type: text/plain

Dear R,

I have two questions:

1, Why both R and Matlab give 0*Inf==NaN? To my knowledge, it should be zero
mathematically. Am I right?

2, I need to calculate e.g. exp(a)/(exp(b)+c), where both a and b are very
large numbers (>>1000, e.g a=1000, b=1007, and c=5). R gives me NaN when I
use the following command:

> exp(1000)/(exp(1007)+5)
[1] NaN

I am pretty sure this should be close to zero. My question is whether there
is a general way to solve this kind of question or should I do some settings
before computing?


Thanks in advance!


Feng


Issued by UBS AG or affiliates to professional investors...{{dropped:28}}

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


Re: [R] Compiling Matrix on Solaris 10 x86-64 Sun Studio 12

2009-02-11 Thread Prof Brian Ripley
This is a known issue.  Fixes have been passed to the Matrix authors, 
so please wait for an update.


If that is not possible, try an older version of Matrix from the CRAN 
archive: I think -15 is the latest without the problematic code.


(At http://cran.r-project.org/src/contrib/Archive/Matrix/, BTW)

On Wed, 11 Feb 2009, Dongseok Choi wrote:


Hi all,

I have trouble to compile Matrix packages on Solar10 x86-64 with Sun compilers.
I saw some postings on this but am not sure how to solve this problem.
It is becoming critical as I cannot install biocLite() because of its 
dependency on Matrix.
Could you direct me how to resolve the issue?

Thanks in advance!
Dongseok


R version 2.8.1 (2008-12-22)
Copyright (C) 2008 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.


install.packages("Matrix")

--- Please select a CRAN mirror for use in this session ---

trying URL 'http://cran.fhcrc.org/src/contrib/Matrix_0.999375-20.tar.gz'
Content type 'application/x-gzip' length 1954872 bytes (1.9 Mb)
opened URL
==
downloaded 1.9 Mb

* Installing *source* package 'Matrix' ...
** libs
cc -m64 -I/home/choid/bin/R281/lib/R/include -I./UFconfig -I/usr/local/include 
-I/opt/SUNWspro/prod/include -I/usr/include -I/usr/sfw/include-KPIC  -O 
-I/opt/SUNWspro/prod/include -c CHMfactor.c -o CHMfactor.o
cc -m64 -I/home/choid/bin/R281/lib/R/include -I./UFconfig -I/usr/local/include 
-I/opt/SUNWspro/prod/include -I/usr/include -I/usr/sfw/include-KPIC  -O 
-I/opt/SUNWspro/prod/include -c Csparse.c -o Csparse.o
cc -m64 -I/home/choid/bin/R281/lib/R/include -I./UFconfig -I/usr/local/include 
-I/opt/SUNWspro/prod/include -I/usr/include -I/usr/sfw/include-KPIC  -O 
-I/opt/SUNWspro/prod/include -c TMatrix_as.c -o TMatrix_as.o
cc -m64 -I/home/choid/bin/R281/lib/R/include -I./UFconfig -I/usr/local/include 
-I/opt/SUNWspro/prod/include -I/usr/include -I/usr/sfw/include-KPIC  -O 
-I/opt/SUNWspro/prod/include -c Tsparse.c -o Tsparse.o
cc -m64 -I/home/choid/bin/R281/lib/R/include -I./UFconfig -I/usr/local/include 
-I/opt/SUNWspro/prod/include -I/usr/include -I/usr/sfw/include-KPIC  -O 
-I/opt/SUNWspro/prod/include -c init.c -o init.o
cc -m64 -I/home/choid/bin/R281/lib/R/include -I./UFconfig -I/usr/local/include 
-I/opt/SUNWspro/prod/include -I/usr/include -I/usr/sfw/include-KPIC  -O 
-I/opt/SUNWspro/prod/include -c Mutils.c -o Mutils.o
cc -m64 -I/home/choid/bin/R281/lib/R/include -I./UFconfig -I/usr/local/include 
-I/opt/SUNWspro/prod/include -I/usr/include -I/usr/sfw/include-KPIC  -O 
-I/opt/SUNWspro/prod/include -c chm_common.c -o chm_common.o
cc -m64 -I/home/choid/bin/R281/lib/R/include -I./UFconfig -I/usr/local/include 
-I/opt/SUNWspro/prod/include -I/usr/include -I/usr/sfw/include-KPIC  -O 
-I/opt/SUNWspro/prod/include -c cs.c -o cs.o
cc -m64 -I/home/choid/bin/R281/lib/R/include -I./UFconfig -I/usr/local/include 
-I/opt/SUNWspro/prod/include -I/usr/include -I/usr/sfw/include-KPIC  -O 
-I/opt/SUNWspro/prod/include -c cs_utils.c -o cs_utils.o
cc -m64 -I/home/choid/bin/R281/lib/R/include -I./UFconfig -I/usr/local/include 
-I/opt/SUNWspro/prod/include -I/usr/include -I/usr/sfw/include-KPIC  -O 
-I/opt/SUNWspro/prod/include -c dense.c -o dense.o
cc -m64 -I/home/choid/bin/R281/lib/R/include -I./UFconfig -I/usr/local/include 
-I/opt/SUNWspro/prod/include -I/usr/include -I/usr/sfw/include-KPIC  -O 
-I/opt/SUNWspro/prod/include -c dgCMatrix.c -o dgCMatrix.o
cc -m64 -I/home/choid/bin/R281/lib/R/include -I./UFconfig -I/usr/local/include 
-I/opt/SUNWspro/prod/include -I/usr/include -I/usr/sfw/include-KPIC  -O 
-I/opt/SUNWspro/prod/include -c dgTMatrix.c -o dgTMatrix.o
cc -m64 -I/home/choid/bin/R281/lib/R/include -I./UFconfig -I/usr/local/include 
-I/opt/SUNWspro/prod/include -I/usr/include -I/usr/sfw/include-KPIC  -O 
-I/opt/SUNWspro/prod/include -c dgeMatrix.c -o dgeMatrix.o
cc -m64 -I/home/choid/bin/R281/lib/R/include -I./UFconfig -I/usr/local/include 
-I/opt/SUNWspro/prod/include -I/usr/include -I/usr/sfw/include-KPIC  -O 
-I/opt/SUNWspro/prod/include -c dpoMatrix.c -o dpoMatrix.o
cc -m64 -I/home/choid/bin/R281/lib/R/include -I./UFconfig -I/usr/local/include 
-I/opt/SUNWspro/prod/include -I/usr/include -I/usr/sfw/include-KPIC  -O 
-I/opt/SUNWspro/prod/include -c dppMatrix.c -o dppMatrix.o
cc -m64 -I/home/choid/bin/R281/lib/R/include -I./UFconfig -I/usr/local/include 
-I/opt/SUNWspro/prod/include -I/usr/include -I/usr/sfw/include-KPIC  -O 
-I/opt/SUNWspro/pro

Re: [R] Problem with loading rJava in R

2009-02-11 Thread Prof Brian Ripley
The 'specified module' is specified in a pop-up (but not on Win 2000 
ans sometimes it gets hidden): this is a Windows error message, and 
confuses many people.


You need Sun Jave installed and in your path, and you need a 32-bit 
Java, not a 64-bit one.  My guess is that the problem is one of the 
conditions of the previous sentence.


On Wed, 11 Feb 2009, charis wrote:



Hello.

I am trying to load the rJava package in R-2.7.2 (Windows XP 64-bit RGui)


I presume it it 32-bit Rgui running on 64-bit Windows XP frpm he info 
below.



and get the following error message even though the mentioned .dll file is
located at the directory listed in the error message. I have tried to
uninstall and reinstall the package but that does not resolve the problem.
Then uninstallation and re-installation of R did not resolve the issue
either. Any suggestions are appreciated. charis.



library(rJava)

Error in inDL(x, as.logical(local), as.logical(now), ...) :
 unable to load shared library 'C:/R/R-2.7.2/library/rJava/libs/rJava.dll':
 LoadLibrary failure:  The specified module could not be found.


Error : .onLoad failed in 'loadNamespace' for 'rJava'
Error: package/namespace load failed for 'rJava'


sessionInfo()

R version 2.7.2 (2008-11-24)
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 datasets  tcltk utils methods
base

other attached packages:
[1] Matrix_0.999375-17 lattice_0.17-17filehash_2.0   svSocket_0.9-5
TinnR_1.0.2R2HTML_1.59Hmisc_3.4-4RProbase_0.1-0

loaded via a namespace (and not attached):
[1] cluster_1.11.11 grid_2.7.2  svMisc_0.9-5tools_2.7.2

--
View this message in context: 
http://www.nabble.com/Problem-with-loading-rJava-in-R-tp21968371p21968371.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.



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

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


Re: [R] tcltk, tcltk2, Rcmdr, Mac OS X

2009-02-11 Thread Prof Brian Ripley

On Thu, 12 Feb 2009, Peter Dalgaard wrote:


Man, I'd forgotten how fugly plain ole X11 was compared to Aqua... ;)


Do we have a volunteer to get Tcl/Tk Aqua working with R? ;-)

(Seriously, read Mac OS X FAQ 2.1.7 before even thinking of doing that!)


For the record, the Tcl?Tk that ships with MacOS (e.g. 10.5.6) is ca 
8.4.6 and equally ugly.  You want 8.5.x to get modern widgets (on any 
system), and you can use ActiveTcl's port or build your own.


That FAQ is about using Aqua Tk and R.app, not R (see also item 8): I 
happiiy use Aqua Tcl 8.5.x with the command-line R, and with front 
ends designed just to launch a Tk interface.


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

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


Re: [R] tcltk, tcltk2, Rcmdr, Mac OS X

2009-02-11 Thread Monte Milanuk

Peter Dalgaard wrote:

Man, I'd forgotten how fugly plain ole X11 was compared to Aqua... ;)


Do we have a volunteer to get Tcl/Tk Aqua working with R? ;-)

(Seriously, read Mac OS X FAQ 2.1.7 before even thinking of doing that!)




Oh heavens no! ;)  I was working my way through a Python programming 
book, just starting on the GUI section when I got side-tracked by some 
mention of R ;) 


I wouldn't know where to start with Aqua, etc.

It is just a bit of a shocker seeing a Tk/Tcl window alongside all the 
sleek and smooth Aqua apps. 

If it's waiting on me to gain enough skills to tackle it, the problem is 
going to be waiting a loong time ;)


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


Re: [R] Generating Numbers With Certain Distribution in R

2009-02-11 Thread Gundala Viswanath
Dear all,
Thanks so much, the latest version by Gustav work just fine.

In the first version, the outcome is more digital
than contiguous.

- Gundala Viswanath
Jakarta - Indonesia



On Wed, Feb 11, 2009 at 10:35 PM, Gustaf Rydevik
 wrote:
> On Wed, Feb 11, 2009 at 2:15 PM, Ben Bolker  wrote:
>> Bernardo Rangel Tura wrote:
>>
>>> I think your routine need a little fix
>>>
>>> x <- rlnorm(1e6,meanlog=1,sdlog=1) ## pick any parameters you like
>>> y <- round((x-min(x)/diff(range(x)))*19+1)
>>>
>>> What you think?
>>
>>  Yes.
>
>
> No.
> Bernardo misplaced the parenthesis around (x-min(x))
> Correct version is:
>
> x <- rlnorm(1e6,meanlog=1,sdlog=1) ## pick any parameters you like
> y <- round((x-min(x))/diff(range(x))*19+1)
>
>
> /Gustaf
>
>
> --
> Gustaf Rydevik, M.Sci.
> tel: +46(0)703 051 451
> address:Essingetorget 40,112 66 Stockholm, SE
> skype:gustaf_rydevik
>

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


Re: [R] plots and text to the same output file

2009-02-11 Thread Michael Bibo
Greg Snow  imail.org> writes:

> 
> odfWeave works just fine for me on windows and the XML package shows up in 
my list of packages.  You may be
> overthinking the problem, for most of my odfWeave projects I don't need 
odfInsertPlot, just use fig=TRUE
> in the code chunk and only include the code for that 1 plot in that code 
chunk (a separate chunk for each plot)
> and the inclusion of the plot is taken care of for you (you can do fancier 
things with odfInsertPlot, but
> probably don't need to most of the time).
> 
> Another alternative for creating postscript (which can be converted to pdf 
if that is preferred), but
> which is much less sophisticated than sweave/odfWeave is to look at the 
etxtStart function in the
> TeachingDemos package (this requires postprocessing with enscript).  This 
approach is more for getting
> a transcript of an interactive session, for planned analyses use 
sweave/odfWeave instead.
> 
> Hope this helps,
> 

See also package hwriter, for creating HTML output files which can be further 
edited, even with MSWord if you work with others in an MSOffice environment.

Michal Bibo

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


Re: [R] How do I get my IT department to "bless" R?

2009-02-11 Thread Daniel Viar
Many thanks to everyone that posted replies to this thread.  I used
some of the ideas from this thread and other sources to put together a
case for R and I just received formal approval from our IT department
today.  In case this can be useful to anyone in the future, here's a
summary of what was submitted (by the way, I love the slides found at
http://www.matthewckeller.com/Lecture1.ppt, the Harry Potter stuff is
brilliant):

Thanks again to everyone!
Dan Viar
Chesapeake, VA

-


(head of IT name removed),

  Based on our conversation yesterday, below is some
documentation that might be useful in trying to evaluate the risk that
R might pose.  I also contacted one of the company's that is trying to
be a "Red Hat" for R and his response is included below.  The salient
points:

· R is "the de-facto standard" for statistical computing and
(for example) appears in peer reviewed journals of Statistics

· R is a quality open-source product, not some small piece of
freeware developed by an individual

oFor example there are currently over 19 individuals responsible
for the maintaining the source (see:
http://www.r-project.org/contributors.html).  These individuals are
arguably some of the most talented in the field of Statistical
Computing.

· R is licensed under the GPL (e.g. see
http://www.groklaw.net/article.php?story=2008081313212422)

· R requires no more support from IT than a similar stat
package (e.g. SAS).  In other words, we may want to put R on our
desktops (it doesn't write to the registry) or have it installed on a
server like "Bugsy" but R would not generate calls to the help desk
(unlike something like Excel).

· Anecdotal evidence suggest that the technical support
offered by the R community (through forums, email lists, etc…) is
comparable if not better than that provided by commercial products.
For instance, we have been evaluating various commercial packages
(SAS, SPSS, S-Plus) and so far have had better responses to getting
technical questions answers on the R-help list than through the help
desks of company's trying to sell us their software.  As another
example, last night I posted "How do I get my IT department to 'bless'
R" and so far I have received 12 replies.

· R benefits from external innovation that makes it able to
have quick reaction time to new statistical ideas.  It is not uncommon
for a cutting edge statistical technique to appear first in R and then
make its way into a commercial package.

R was recently featured in the NY Times:

http://www.nytimes.com/2009/01/07/technology/business-computing/07program.html

According to the article

"Companies as diverse as Google, Pfizer, Merck, Bank of America, the
InterContinental Hotels Group and Shell use it."



I recently came across the following links that show that some
commercial products like SAS and SPSS are providing functionality so
that their programs can call R (as a selling point).  Here's a link to
some SAS marketing:


http://support.sas.com/rnd/app/studio/Rinterface2.html


>From that site:


"R is a leading language for developing new statistical methods," said
Bob Rodriguez, Senior Director of Statistical Development at SAS. "Our
new PhD developers learned R in their graduate programs and are quite
versed in it."

It's open source software, and many add-on packages for R have
emerged, providing statisticians with convenient access to new
research. Many new statistical methods are first programmed in R.

While SAS is committed to providing the new statistical methodologies
that the marketplace demands and will deliver new work more quickly
with a recent decoupling of the analytical product releases from Base
SAS, a commercial software vendor can only put out new work so fast.
And never as  fast as a professor and a grad student writing an
academic implementation of brand-new methodology.

This sounds like a pretty strong endorsement for R, from one of its
commercial competitors.


I also found the following link which is a Power Point presentation
explaining why we would be interested in R (nice if you like Harry
Potter).  It does a good job of show casing the differences between
SAS, SPSS, and R.


http://www.matthewckeller.com/Lecture1.ppt


Let me know if there is something formally that I need to do (forms to
fill out, process, etc…).

Thanks,

Dan




R: Regulatory Compliance and Validation Issues A Guidance Document for
the Use of R in Regulated Clinical Trial Environments

http://www.r-project.org/doc/R-FDA.pdf

R installation and administration manual

http://cran.r-project.org/doc/manuals/R-admin.pdf



http://www.r-project.org/

http://www.revolution-computing.com/



>From Colin Magee [co...@revolution-computing.com]:



Hi Dan -



Well, we'd love to talk to your Head of IT/ Manager a

Re: [R] How to tell if lattice is current device?

2009-02-11 Thread Remko Duursma
Thanks for the tip. I did some reading on setHook, etc.. but I am
terribly confused. Do you (or someone else!) have a quick example of
what the call will look like?

thanks
remko


-
Remko Duursma
Post-Doctoral Fellow

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

Dept of Biological Science
Macquarie University
North Ryde NSW 2109
Australia

Mobile: +61 (0)422 096908



On Thu, Feb 12, 2009 at 11:11 AM, Deepayan Sarkar
 wrote:
> On Wed, Feb 11, 2009 at 3:40 PM, Remko Duursma  wrote:
>> Dear R-helpers,
>>
>> I have a function that adds some segments to the current plot, but if
>> I the current plot is made with any of the lattice functions (in my
>> case, levelplot),
>> I should use lsegments rather than segments.
>>
>> How can I tell if the current device was made with plot() or e.g.
>> levelplot() or another lattice function?
>> dev.cur() does not help me, it just tells me "windows 2".
>
> A device can have both types, although that's rare.
>
> The best you can probably do is keep track of the last call to
> plot.new() and grid.newpage(). See
>
> ?setHook
> ?plot.new
> ?grid.newpage
>
> -Deepayan
>

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

2009-02-11 Thread Neil Morris-8094
I have datasets containing a number of pairs each pair of variable
length with longest set governing the column length.  They are beach
cross sections and I am trying examine the change specific contours.  I
can do this by individually working each pair but because of the number
of sets would like to automate.

I have compiled the following

h=read.csv("testxsec.csv",header=T)
for(i in seq(1,(ncol(h)-1),by=2)){
s=seq(from=7,to=9,by=0.25)
d=data.frame(h[,i:(i+1)])
f=approx(x=d[,1],y=d[,2], xout=s, method="linear",
yleft=0.125, yright=0.125, 
rule = 2, f = 0, ties = mean,na.omit)
}

I cannot get the calculation to give me a set of approximations.

I am expecting that for each of the values of "s" I will have an
approximation for each x/y pair in the set.

Any help appreciated greatly

[[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] Compiling Matrix on Solaris 10 x86-64 Sun Studio 12

2009-02-11 Thread Dongseok Choi
Hi all,

I have trouble to compile Matrix packages on Solar10 x86-64 with Sun compilers.
I saw some postings on this but am not sure how to solve this problem.
It is becoming critical as I cannot install biocLite() because of its 
dependency on Matrix.
Could you direct me how to resolve the issue?

Thanks in advance!
Dongseok


R version 2.8.1 (2008-12-22)
Copyright (C) 2008 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> install.packages("Matrix")
--- Please select a CRAN mirror for use in this session ---

trying URL 'http://cran.fhcrc.org/src/contrib/Matrix_0.999375-20.tar.gz'
Content type 'application/x-gzip' length 1954872 bytes (1.9 Mb)
opened URL
==
downloaded 1.9 Mb

* Installing *source* package 'Matrix' ...
** libs
cc -m64 -I/home/choid/bin/R281/lib/R/include -I./UFconfig -I/usr/local/include 
-I/opt/SUNWspro/prod/include -I/usr/include -I/usr/sfw/include-KPIC  -O 
-I/opt/SUNWspro/prod/include -c CHMfactor.c -o CHMfactor.o
cc -m64 -I/home/choid/bin/R281/lib/R/include -I./UFconfig -I/usr/local/include 
-I/opt/SUNWspro/prod/include -I/usr/include -I/usr/sfw/include-KPIC  -O 
-I/opt/SUNWspro/prod/include -c Csparse.c -o Csparse.o
cc -m64 -I/home/choid/bin/R281/lib/R/include -I./UFconfig -I/usr/local/include 
-I/opt/SUNWspro/prod/include -I/usr/include -I/usr/sfw/include-KPIC  -O 
-I/opt/SUNWspro/prod/include -c TMatrix_as.c -o TMatrix_as.o
cc -m64 -I/home/choid/bin/R281/lib/R/include -I./UFconfig -I/usr/local/include 
-I/opt/SUNWspro/prod/include -I/usr/include -I/usr/sfw/include-KPIC  -O 
-I/opt/SUNWspro/prod/include -c Tsparse.c -o Tsparse.o
cc -m64 -I/home/choid/bin/R281/lib/R/include -I./UFconfig -I/usr/local/include 
-I/opt/SUNWspro/prod/include -I/usr/include -I/usr/sfw/include-KPIC  -O 
-I/opt/SUNWspro/prod/include -c init.c -o init.o
cc -m64 -I/home/choid/bin/R281/lib/R/include -I./UFconfig -I/usr/local/include 
-I/opt/SUNWspro/prod/include -I/usr/include -I/usr/sfw/include-KPIC  -O 
-I/opt/SUNWspro/prod/include -c Mutils.c -o Mutils.o
cc -m64 -I/home/choid/bin/R281/lib/R/include -I./UFconfig -I/usr/local/include 
-I/opt/SUNWspro/prod/include -I/usr/include -I/usr/sfw/include-KPIC  -O 
-I/opt/SUNWspro/prod/include -c chm_common.c -o chm_common.o
cc -m64 -I/home/choid/bin/R281/lib/R/include -I./UFconfig -I/usr/local/include 
-I/opt/SUNWspro/prod/include -I/usr/include -I/usr/sfw/include-KPIC  -O 
-I/opt/SUNWspro/prod/include -c cs.c -o cs.o
cc -m64 -I/home/choid/bin/R281/lib/R/include -I./UFconfig -I/usr/local/include 
-I/opt/SUNWspro/prod/include -I/usr/include -I/usr/sfw/include-KPIC  -O 
-I/opt/SUNWspro/prod/include -c cs_utils.c -o cs_utils.o
cc -m64 -I/home/choid/bin/R281/lib/R/include -I./UFconfig -I/usr/local/include 
-I/opt/SUNWspro/prod/include -I/usr/include -I/usr/sfw/include-KPIC  -O 
-I/opt/SUNWspro/prod/include -c dense.c -o dense.o
cc -m64 -I/home/choid/bin/R281/lib/R/include -I./UFconfig -I/usr/local/include 
-I/opt/SUNWspro/prod/include -I/usr/include -I/usr/sfw/include-KPIC  -O 
-I/opt/SUNWspro/prod/include -c dgCMatrix.c -o dgCMatrix.o
cc -m64 -I/home/choid/bin/R281/lib/R/include -I./UFconfig -I/usr/local/include 
-I/opt/SUNWspro/prod/include -I/usr/include -I/usr/sfw/include-KPIC  -O 
-I/opt/SUNWspro/prod/include -c dgTMatrix.c -o dgTMatrix.o
cc -m64 -I/home/choid/bin/R281/lib/R/include -I./UFconfig -I/usr/local/include 
-I/opt/SUNWspro/prod/include -I/usr/include -I/usr/sfw/include-KPIC  -O 
-I/opt/SUNWspro/prod/include -c dgeMatrix.c -o dgeMatrix.o
cc -m64 -I/home/choid/bin/R281/lib/R/include -I./UFconfig -I/usr/local/include 
-I/opt/SUNWspro/prod/include -I/usr/include -I/usr/sfw/include-KPIC  -O 
-I/opt/SUNWspro/prod/include -c dpoMatrix.c -o dpoMatrix.o
cc -m64 -I/home/choid/bin/R281/lib/R/include -I./UFconfig -I/usr/local/include 
-I/opt/SUNWspro/prod/include -I/usr/include -I/usr/sfw/include-KPIC  -O 
-I/opt/SUNWspro/prod/include -c dppMatrix.c -o dppMatrix.o
cc -m64 -I/home/choid/bin/R281/lib/R/include -I./UFconfig -I/usr/local/include 
-I/opt/SUNWspro/prod/include -I/usr/include -I/usr/sfw/include-KPIC  -O 
-I/opt/SUNWspro/prod/include -c dsCMatrix.c -o dsCMatrix.o
cc -m64 -I/home/choid/bin/R281/lib/R/include -I./UFconfig -I/usr/local/include 
-I/opt/SUNWspro/prod/include -I/usr/include -I/usr/sfw/include-KPIC  -O 
-I/opt/SUNWspro/prod/include -c dsyMatrix.c -o dsyMatrix.o
cc -m64 -I/home/choid/bin/R281/lib/R/include -I./UFconfig -I/usr/local/include 
-I/opt/SUNWspr

Re: [R] function question

2009-02-11 Thread jim holtman
Is this what you want:

> x
  FL number
1 34  4
2 35  3
3 36  7
> cbind(rep(x$FL, x$number), 1)
  [,1] [,2]
 [1,]   341
 [2,]   341
 [3,]   341
 [4,]   341
 [5,]   351
 [6,]   351
 [7,]   351
 [8,]   361
 [9,]   361
[10,]   361
[11,]   361
[12,]   361
[13,]   361
[14,]   361


On Wed, Feb 11, 2009 at 5:14 PM, Felipe Carrillo
 wrote:
> Hi everyone:
> I did this before with R and I can't remember how.
> I got some fish forklength values
> FL  number
> 344
> 353
> 367
>
> I need to breakdown the FL by the number of fish with the same length
> like this:
> 34  1
> 34  1
> 34  1
> 34  1
> 35  1
> 35  1
> 35  1
> 36  1
> 36  1
> 36  1
> 36  1
> 36  1
> 36  1
> 36  1
>
>
>
> Felipe D. Carrillo
> Supervisory Fishery Biologist
> Department of the Interior
> US Fish & Wildlife Service
> California, USA
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

What is the problem that you are trying to solve?

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


Re: [R] Looping over a matrix passed to .C

2009-02-11 Thread jim holtman
Given that there are 166,000,000,000 combinations, maybe you should
find some other way of partitioning the data.

On Wed, Feb 11, 2009 at 8:27 PM, Nathan S. Watson-Haigh
 wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> jim holtman wrote:
>> Why don't you generate all the possible combinations using 'combn' and
>> then use that matrix to address your data:
>
> I had thought of using this, however the size of data I'm using will more 
> likely
> be orders of magnitude larger, such as:
>
>> dim(m)
> [1] 1 1
>
> Which takes long time to compute using:
> indx <- combn(1, 3)
>
>
>
>>
>>> m <- matrix(1:25,5)
>>> indx <- combn(5, 3)
>>> indx
>>  [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
>> [1,]111111222 3
>> [2,]222334334 4
>> [3,]345455455 5
>>
>>> mxy <- m[cbind(indx[1,], indx[2,])]
>>>
>>>
>>> mxy
>>  [1]  6  6  6 11 11 16 12 12 17 18
>>
>> You can use each of the columns as x,y,z values and compute everything at 
>> once.
>>
>> On Tue, Feb 10, 2009 at 9:49 PM, Nathan S. Watson-Haigh
>>  wrote:
>> I've written a function in R which takes a symmetrical matrix as input and
>> processes all triplicate combinations of values from the matrix. The function
>> looks something like:
>>
>> my_fun <- function(m) {
>>  if( nrow(mat) != ncol(mat) ) {
>>stop("'m' must be a square matrix")
>>  }
>>
>>  size <- nrow(m)
>>
>>  for(x in 1:(size -2)) {
>>for(y in (x+1):(size -1)) {
>>  xy <- m[x,y]
>>
>>  for(z in (y+1):size ) {
>>xz <- m[x,z]
>>yz <- m[y,z]
>>
>># do something with xy, xz, yz
>>  }
>>}
>>  }
>> }
>>
>> I'd like to speed this up since when size gets > a few thousand, I estimate 
>> it
>> would take 3yrs to complete the "do something" task. I could implement the 
>> "do
>> something" in C and have it called from within the nested for loops in R, 
>> but I
>> think I should get better performance if I implement the for loops in C as 
>> well.
>> As such, I'm trying to get my head around looping through matrix values when
>> passed to .C()
>>
>> As I understand it, once a matrix (n x m in size) is passed to .C() it is 
>> seen
>> as an unwrapped array of length n*m. Could someone help/guide me in 
>> implementing
>> this?
>>
>> Cheers,
>> Nathan
>>
>>
>>>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>>>
>
> - --
> - 
> Dr. Nathan S. Watson-Haigh
> OCE Post Doctoral Fellow
> CSIRO Livestock Industries
> Queensland Bioscience Precinct
> St Lucia, QLD 4067
> Australia
>
> Tel: +61 (0)7 3214 2922
> Fax: +61 (0)7 3214 2900
> Web: http://www.csiro.au/people/Nathan.Watson-Haigh.html
> - 
>
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v1.4.9 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iEYEARECAAYFAkmTeucACgkQ9gTv6QYzVL7dvwCaAgQKGrZOrsZF0nhn0qJo4Irx
> zYIAnAgxgHTqEnKe7dANNIqhmm0Hu6QY
> =iTyc
> -END PGP SIGNATURE-
>



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

What is the problem that you are trying to solve?

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


[R] Problem with loading rJava in R

2009-02-11 Thread charis

Hello.

I am trying to load the rJava package in R-2.7.2 (Windows XP 64-bit RGui)
and get the following error message even though the mentioned .dll file is
located at the directory listed in the error message. I have tried to
uninstall and reinstall the package but that does not resolve the problem.
Then uninstallation and re-installation of R did not resolve the issue
either. Any suggestions are appreciated. charis.


> library(rJava)
Error in inDL(x, as.logical(local), as.logical(now), ...) : 
  unable to load shared library 'C:/R/R-2.7.2/library/rJava/libs/rJava.dll':
  LoadLibrary failure:  The specified module could not be found.


Error : .onLoad failed in 'loadNamespace' for 'rJava'
Error: package/namespace load failed for 'rJava'

> sessionInfo()
R version 2.7.2 (2008-11-24) 
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 datasets  tcltk utils methods  
base 

other attached packages:
[1] Matrix_0.999375-17 lattice_0.17-17filehash_2.0   svSocket_0.9-5
TinnR_1.0.2R2HTML_1.59Hmisc_3.4-4RProbase_0.1-0

loaded via a namespace (and not attached):
[1] cluster_1.11.11 grid_2.7.2  svMisc_0.9-5tools_2.7.2

-- 
View this message in context: 
http://www.nabble.com/Problem-with-loading-rJava-in-R-tp21968371p21968371.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] General query regarding scoring new observations

2009-02-11 Thread Rolf Turner


On 12/02/2009, at 2:02 PM, Lars Bishop wrote:


Hi,
I was wondering if I can have some advice on the following problem.

Let's say that I have a problem in which I want to predict a binary  
outcome
and I use logistic regression for that purpose. In addition,  
suppose that my
model includes predictors that will not be used in scoring new  
observations
but must be used during model training to absorb certain effects  
that could

bias the parameter estimates of the other variables.

Because one needs to have the same predictors in model development and
scoring, how it is usually done in practice to overcome this  
problem? I
could exclude the variables that will not be available during  
scoring, but

that will bias the estimates for the other variables.


Surely if you only have x_1, x_2, and x_3 available for prediction,
then you should ``train'' using only x_1, x_2, and x_3.

If you also have x_4 and x_5 available for training then not using them
will ``bias'' the coefficients of the other three predictors, but will
give the best (in some sense) values of these coefficients to use when
x_4 and x_5 are not available.

Note that not using x_4 and x_5 is equivalent to setting them equal  
to 0,
so if you *insist* on fitting the model with x_1, ..., x_5 and then  
predicting
with x_1, ..., x_3 you can accomplish this by setting x_4 and x_5  
equal to 0

in your ``newdata'' data frame.

This seems to me to be highly inadvisable however.

cheers,

Rolf Turner

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

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


Re: [R] Looping over a matrix passed to .C

2009-02-11 Thread Nathan S. Watson-Haigh
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

jim holtman wrote:
> Why don't you generate all the possible combinations using 'combn' and
> then use that matrix to address your data:

I had thought of using this, however the size of data I'm using will more likely
be orders of magnitude larger, such as:

> dim(m)
[1] 1 1

Which takes long time to compute using:
indx <- combn(1, 3)



> 
>> m <- matrix(1:25,5)
>> indx <- combn(5, 3)
>> indx
>  [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
> [1,]111111222 3
> [2,]222334334 4
> [3,]345455455 5
> 
>> mxy <- m[cbind(indx[1,], indx[2,])]
>>
>>
>> mxy
>  [1]  6  6  6 11 11 16 12 12 17 18
> 
> You can use each of the columns as x,y,z values and compute everything at 
> once.
> 
> On Tue, Feb 10, 2009 at 9:49 PM, Nathan S. Watson-Haigh
>  wrote:
> I've written a function in R which takes a symmetrical matrix as input and
> processes all triplicate combinations of values from the matrix. The function
> looks something like:
> 
> my_fun <- function(m) {
>  if( nrow(mat) != ncol(mat) ) {
>stop("'m' must be a square matrix")
>  }
> 
>  size <- nrow(m)
> 
>  for(x in 1:(size -2)) {
>for(y in (x+1):(size -1)) {
>  xy <- m[x,y]
> 
>  for(z in (y+1):size ) {
>xz <- m[x,z]
>yz <- m[y,z]
> 
># do something with xy, xz, yz
>  }
>}
>  }
> }
> 
> I'd like to speed this up since when size gets > a few thousand, I estimate it
> would take 3yrs to complete the "do something" task. I could implement the "do
> something" in C and have it called from within the nested for loops in R, but 
> I
> think I should get better performance if I implement the for loops in C as 
> well.
> As such, I'm trying to get my head around looping through matrix values when
> passed to .C()
> 
> As I understand it, once a matrix (n x m in size) is passed to .C() it is seen
> as an unwrapped array of length n*m. Could someone help/guide me in 
> implementing
> this?
> 
> Cheers,
> Nathan
> 
> 
>>
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
>>

- --
- 
Dr. Nathan S. Watson-Haigh
OCE Post Doctoral Fellow
CSIRO Livestock Industries
Queensland Bioscience Precinct
St Lucia, QLD 4067
Australia

Tel: +61 (0)7 3214 2922
Fax: +61 (0)7 3214 2900
Web: http://www.csiro.au/people/Nathan.Watson-Haigh.html
- 

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkmTeucACgkQ9gTv6QYzVL7dvwCaAgQKGrZOrsZF0nhn0qJo4Irx
zYIAnAgxgHTqEnKe7dANNIqhmm0Hu6QY
=iTyc
-END PGP SIGNATURE-

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


Re: [R] System.time

2009-02-11 Thread jim holtman
It depends on the granularity that the operating system is recording
that time; on some systems the minimum might be 0.01 seconds.  If it
is that short, why worry about it.  There is nothing unusual about the
result.

On Wed, Feb 11, 2009 at 7:49 PM, John Kerpel  wrote:
> Hi folks!
> Does anyone know why I might see something like this after running
> system.time?
>
> system.time(svd(Mean_svd_data))
>   user  system elapsed
>  0   0   0
>
> The data set is tiny and the function returns results instantly, but
> shouldn't it still give me a time?
>
> Thanks,
>
> John
>
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

What is the problem that you are trying to solve?

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


Re: [R] two scatter plots in one

2009-02-11 Thread jim holtman
Set the xlim/ylim to the extent of the data and then do

plot(x1, y1, xlim=range(x1, x2), ylim=range(y1, y2))
points(x2, y2, col='red')

On Wed, Feb 11, 2009 at 3:43 PM, liujb  wrote:
>
> Dear R users,
>
> I need to compare two scatter plots,
> plot(x1, y1)
> plot(x2, y2)
>
> and would like to plot them in the same figure. How do I do it?
>
> Thank you.
>
> --
> View this message in context: 
> http://www.nabble.com/two-scatter-plots-in-one-tp21963375p21963375.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

What is the problem that you are trying to solve?

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


[R] System.time

2009-02-11 Thread John Kerpel
Hi folks!
Does anyone know why I might see something like this after running
system.time?

system.time(svd(Mean_svd_data))
   user  system elapsed
  0   0   0

The data set is tiny and the function returns results instantly, but
shouldn't it still give me a time?

Thanks,

John

[[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] Linear model

2009-02-11 Thread Kingsford Jones
On Wed, Feb 11, 2009 at 1:36 PM, kayj  wrote:
>
> I want to know how accurate are the p-values when you do linear regression in
> R?
>
> I was looking at the variable x3 and the t=10.843 and the corresponding
> p-value=2e-16 which is the same p-value for the intercept where the t-value
> for the intercept is 48.402.
>
> I tried to calculate the p-value in R and I got 0
>
> x<-2*(1-pt(10.843,2838))
>> x
> [1] 0
>
>


Some comments:

i) the printout says that the value is less than 2e-16

ii) It seems strange to interpret a p-value at that level of precision

iii) you're confusing what is printed vs what is stored

iv) see 
http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f

v) rather than subtracting from 1, use the 'lower.tail' argument to pt:

> 2*pt(10.843,2838,lower=F)
[1] 7.185635e-27



hth,

Kingsford Jones

>
>> G<-lm(y~x1+x2+x3+x4+x5)
>> summary(G)
>
> Call:
> lm(formula = y ~ x1 + x2 +x3 + x4 + x5)
>
> Residuals:
> Min   1Q   Median   3Q  Max
> -14.3172  -3.2197  -0.2913   2.6938  23.3602
>
> Coefficients:
>Estimate Std. Error t value Pr(>|t|)
> (Intercept)  22.9461 0.4741  48.402  < 2e-16 ***
> x1   -0.1139 0.3734  -0.305  0.76031
> x2   -0.0405 0.1936  -0.209  0.83437
> x3   2.0165 0.1860  10.843  < 2e-16 ***
> x4   0.5313 0.1782   2.982  0.00289 **
> x5   0.5879 0.1779   3.305  0.00096 ***
> ---
> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
>
> Residual standard error: 4.724 on 2838 degrees of freedom
>  (138 observations deleted due to missingness)
> Multiple R-squared: 0.05279,Adjusted R-squared: 0.05112
> F-statistic: 31.63 on 5 and 2838 DF,  p-value: < 2.2e-16
>
>
>  Thanks for the help
>
> --
> View this message in context: 
> http://www.nabble.com/Linear--model-tp21963370p21963370.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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


[R] General query regarding scoring new observations

2009-02-11 Thread Lars Bishop
Hi,



I was wondering if I can have some advice on the following problem.



Let's say that I have a problem in which I want to predict a binary outcome
and I use logistic regression for that purpose. In addition, suppose that my
model includes predictors that will not be used in scoring new observations
but must be used during model training to absorb certain effects that could
bias the parameter estimates of the other variables.



Because one needs to have the same predictors in model development and
scoring, how it is usually done in practice to overcome this problem? I
could exclude the variables that will not be available during scoring, but
that will bias the estimates for the other variables.


Many thanks for your help.

Lars.

[[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] Linear model

2009-02-11 Thread Bill.Venables
If you look carefully you will see that the p-value is actually 

< 2e-16

where the "<" sign is telling you this is an upper limit.  For many machines 
this is the double precision epsilon value:

> .Machine$double.eps
[1] 2.220446e-16

So there is no pretence to accuracy, other than "the value is postive, but 
smaller than the least positive value I can represent on this machine".

Bill Venables. 


Bill Venables
http://www.cmis.csiro.au/bill.venables/ 


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of kayj
Sent: Thursday, 12 February 2009 6:36 AM
To: r-help@r-project.org
Subject: [R] Linear model


I want to know how accurate are the p-values when you do linear regression in
R?

I was looking at the variable x3 and the t=10.843 and the corresponding
p-value=2e-16 which is the same p-value for the intercept where the t-value
for the intercept is 48.402.

I tried to calculate the p-value in R and I got 0

x<-2*(1-pt(10.843,2838))
> x
[1] 0



> G<-lm(y~x1+x2+x3+x4+x5)
> summary(G)

Call:
lm(formula = y ~ x1 + x2 +x3 + x4 + x5)

Residuals:
 Min   1Q   Median   3Q  Max 
-14.3172  -3.2197  -0.2913   2.6938  23.3602 

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept)  22.9461 0.4741  48.402  < 2e-16 ***
x1   -0.1139 0.3734  -0.305  0.76031
x2   -0.0405 0.1936  -0.209  0.83437
x3   2.0165 0.1860  10.843  < 2e-16 ***
x4   0.5313 0.1782   2.982  0.00289 ** 
x5   0.5879 0.1779   3.305  0.00096 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 

Residual standard error: 4.724 on 2838 degrees of freedom
  (138 observations deleted due to missingness)
Multiple R-squared: 0.05279,Adjusted R-squared: 0.05112 
F-statistic: 31.63 on 5 and 2838 DF,  p-value: < 2.2e-16


 Thanks for the help

-- 
View this message in context: 
http://www.nabble.com/Linear--model-tp21963370p21963370.html
Sent from the R help mailing list archive at Nabble.com.

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

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


[R] two scatter plots in one

2009-02-11 Thread liujb

Dear R users,

I need to compare two scatter plots,
plot(x1, y1)
plot(x2, y2)

and would like to plot them in the same figure. How do I do it?

Thank you.

-- 
View this message in context: 
http://www.nabble.com/two-scatter-plots-in-one-tp21963375p21963375.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] contour( ..., method='edge') incompatible with xlim & ylim

2009-02-11 Thread david.schruth
Hello,

A colleague of mine in our oceanography lab has pointed out a slightly
annoying imperfection with the contour plotting function.   It appears
that the 'edge' option for the 'method' parameter doesn't work very
well (or at all?) when xlim and ylim are also set.

The following code should recreate and demonstrate the problem:
---
library(marelac)
data(Bathyometry)

B <- Bathymetry

xrange <- c(-150, -120)
yrange <- c(40,60)

par(mfrow=c(1,2))

### using xlim and ylim 
contour(B, xlim=xrange, ylim=yrange, method='edge', main='x/y
limited')

 using subsetting 
x <- !is.na(cut(B$x,breaks=xrange))
y <- !is.na(cut(B$y,breaks=yrange))
contour(B$x[x],B$y[y],B$z[x,y], method='edge', main="x/y subset")

Am I missing something or is this really a bug?  If so, I'd imagine
it's a relatively easy one to fix.

Thanks,

David Schruth
dschr...@u.washington.edu
Bioinformatics Research Consultant
The Center for Environmental Genomics
Department of Oceanography
University of Washington

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 different colors for 2 groups of lines using xyplot

2009-02-11 Thread Yu, Xuesong
Hi All,
 
 
I am trying to use xyplot to plot several lines in one panel with red
color  for a group of lines, say 3 lines and blue color for another
group of lines, say 4. I know this can be easily  done using regular
plot function. But i could not figure out how to do this in xyplot. 
 
 
Any help would be greatly appreciated. 
 
Xuesong 
 
 
   


[[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 with XYPLOT

2009-02-11 Thread John Leonard
I am trying to replicate the following plot using Lattice:

 

http://addictedtor.free.fr/graphiques/graphcode.php?graph=78

 

I'm having trouble with the equivalent of the "oma" (outside margin)
setting.  I've been all through the Lattice documentation and others and
also searched the lists.

 

Suggestions?

 

Thanks!


[[alternative HTML version deleted]]

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


[R] Linear model

2009-02-11 Thread kayj

I want to know how accurate are the p-values when you do linear regression in
R?

I was looking at the variable x3 and the t=10.843 and the corresponding
p-value=2e-16 which is the same p-value for the intercept where the t-value
for the intercept is 48.402.

I tried to calculate the p-value in R and I got 0

x<-2*(1-pt(10.843,2838))
> x
[1] 0



> G<-lm(y~x1+x2+x3+x4+x5)
> summary(G)

Call:
lm(formula = y ~ x1 + x2 +x3 + x4 + x5)

Residuals:
 Min   1Q   Median   3Q  Max 
-14.3172  -3.2197  -0.2913   2.6938  23.3602 

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept)  22.9461 0.4741  48.402  < 2e-16 ***
x1   -0.1139 0.3734  -0.305  0.76031
x2   -0.0405 0.1936  -0.209  0.83437
x3   2.0165 0.1860  10.843  < 2e-16 ***
x4   0.5313 0.1782   2.982  0.00289 ** 
x5   0.5879 0.1779   3.305  0.00096 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 

Residual standard error: 4.724 on 2838 degrees of freedom
  (138 observations deleted due to missingness)
Multiple R-squared: 0.05279,Adjusted R-squared: 0.05112 
F-statistic: 31.63 on 5 and 2838 DF,  p-value: < 2.2e-16


 Thanks for the help

-- 
View this message in context: 
http://www.nabble.com/Linear--model-tp21963370p21963370.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] built in variance component function for lm

2009-02-11 Thread David Springate

Hi,

Is there a built in function for calculating variance components from  
a standard linear model using lm?


I know you can do this using lme for ML and REML, but I can't find a  
method for doing this for least squares.
I am looking to calculate variance components for the interaction  
between two factors, family (random) and treatment (fixed) on a trait.


Thanks,

David Springate

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


Re: [R] How to tell if lattice is current device?

2009-02-11 Thread Deepayan Sarkar
On Wed, Feb 11, 2009 at 3:40 PM, Remko Duursma  wrote:
> Dear R-helpers,
>
> I have a function that adds some segments to the current plot, but if
> I the current plot is made with any of the lattice functions (in my
> case, levelplot),
> I should use lsegments rather than segments.
>
> How can I tell if the current device was made with plot() or e.g.
> levelplot() or another lattice function?
> dev.cur() does not help me, it just tells me "windows 2".

A device can have both types, although that's rare.

The best you can probably do is keep track of the last call to
plot.new() and grid.newpage(). See

?setHook
?plot.new
?grid.newpage

-Deepayan

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


Re: [R] tcltk, tcltk2, Rcmdr, Mac OS X

2009-02-11 Thread Peter Dalgaard

Monte Milanuk wrote:

Lawrence Hanser wrote:

Monte,
I vaguely remember having exactly the same error message at some point 
in my

journey.  Why don't you try simply loading tcltk first to see if you can
then load Rcmdr:

library(tcltk)


  


Larry,

Oddly enough, I had tried just that before, with no success.  This time 
I opted to close out R.app and start fresh.  This time around it worked:


 > library(tcltk)
Loading Tcl/Tk interface ... done
 > library(Rcmdr)
Loading required package: car

Rcmdr Version 1.4-7


Attaching package: 'Rcmdr'


   The following object(s) are masked from package:tcltk :

tclvalue

 >

Man, I'd forgotten how fugly plain ole X11 was compared to Aqua... ;)


Do we have a volunteer to get Tcl/Tk Aqua working with R? ;-)

(Seriously, read Mac OS X FAQ 2.1.7 before even thinking of doing that!)


--
   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
~~ - (p.dalga...@biostat.ku.dk)  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] tcltk, tcltk2, Rcmdr, Mac OS X

2009-02-11 Thread Monte Milanuk

Lawrence Hanser wrote:

Monte,
I vaguely remember having exactly the same error message at some point in my
journey.  Why don't you try simply loading tcltk first to see if you can
then load Rcmdr:

library(tcltk)


  


Larry,

Oddly enough, I had tried just that before, with no success.  This time 
I opted to close out R.app and start fresh.  This time around it worked:


> library(tcltk)
Loading Tcl/Tk interface ... done
> library(Rcmdr)
Loading required package: car

Rcmdr Version 1.4-7


Attaching package: 'Rcmdr'


   The following object(s) are masked from package:tcltk :

tclvalue

>

Man, I'd forgotten how fugly plain ole X11 was compared to Aqua... ;)

Thanks,

Monte

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


[R] How to tell if lattice is current device?

2009-02-11 Thread Remko Duursma
Dear R-helpers,

I have a function that adds some segments to the current plot, but if
I the current plot is made with any of the lattice functions (in my
case, levelplot),
I should use lsegments rather than segments.

How can I tell if the current device was made with plot() or e.g.
levelplot() or another lattice function?
dev.cur() does not help me, it just tells me "windows 2".

(Windows XP).

thanks
Remko


-
Remko Duursma
Post-Doctoral Fellow

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

Dept of Biological Science
Macquarie University
North Ryde NSW 2109
Australia

Mobile: +61 (0)422 096908

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


Re: [R] tcltk, tcltk2, Rcmdr, Mac OS X

2009-02-11 Thread Lawrence Hanser
Monte,
I vaguely remember having exactly the same error message at some point in my
journey.  Why don't you try simply loading tcltk first to see if you can
then load Rcmdr:

library(tcltk)



On Wed, Feb 11, 2009 at 3:03 PM, Peter Dalgaard wrote:

> Monte Milanuk wrote:
>
>> Larry,
>>
>> Since it looks like you've got your problem about whipped, hope you don't
>> mind if I piggy back on here...
>>
>> Same sort of problem... installed Rcmdr via the Package Installer.
>>  Followed the directions for running X11/Tk ala the site mentioned
>> earlier and this is what I get when I try to run Rcmdr:
>>
>>  > library(Rcmdr)
>> Error in structure(.External("dotTclObjv", objv, PACKAGE = "tcltk"), class
>> = "tclObj") :
>>  [tcl] invalid command name "font".
>>
>> Error : .onAttach failed in 'attachNamespace'
>> Error: package/namespace load failed for 'Rcmdr'
>>
>> Any help would be greatly appreciated.
>>
>
> Hum. Sounds like you're getting through to Tcl but not Tk. Are you able to
> run the wish shell (usually comes with Tcl/Tk, although I'm not sure about
> Mac).
>
>-pd
>
> --
>   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
> ~~ - (p.dalga...@biostat.ku.dk)  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.
>

[[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] tcltk, tcltk2, Rcmdr, Mac OS X

2009-02-11 Thread Peter Dalgaard

Monte Milanuk wrote:

Larry,

Since it looks like you've got your problem about whipped, hope you 
don't mind if I piggy back on here...


Same sort of problem... installed Rcmdr via the Package Installer.  
Followed the directions for running X11/Tk ala the site mentioned 
earlier and this is what I get when I try to run Rcmdr:


 > library(Rcmdr)
Error in structure(.External("dotTclObjv", objv, PACKAGE = "tcltk"), 
class = "tclObj") :

 [tcl] invalid command name "font".

Error : .onAttach failed in 'attachNamespace'
Error: package/namespace load failed for 'Rcmdr'

Any help would be greatly appreciated.


Hum. Sounds like you're getting through to Tcl but not Tk. Are you able 
to run the wish shell (usually comes with Tcl/Tk, although I'm not sure 
about Mac).


-pd

--
   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
~~ - (p.dalga...@biostat.ku.dk)  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] function question

2009-02-11 Thread Felipe Carrillo
Hi everyone:
I did this before with R and I can't remember how.
I got some fish forklength values
FL  number
344
353
367

I need to breakdown the FL by the number of fish with the same length
like this:
34  1
34  1
34  1
34  1
35  1
35  1
35  1
36  1
36  1
36  1
36  1
36  1
36  1
36  1



Felipe D. Carrillo  
Supervisory Fishery Biologist  
Department of the Interior  
US Fish & Wildlife Service  
California, USA

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


Re: [R] How to handle large numbers?

2009-02-11 Thread Stavros Macrakis
On Wed, Feb 11, 2009 at 4:38 PM, Wacek Kusnierczyk
 wrote:
> Stavros Macrakis wrote:
>> For example:
>>> x<-40; log(exp(x)+1)-x
>> [1] 0
>>> x<-as.brob(40); log(exp(x)+1)-x
>> [1] -exp(-Inf)
>> The correct answer is about 4e-18.  Perhaps Ryacas or some other tool gets 
>> this right,
>
> bc gets it arbitrarily right:...

Yes, any arbitrary-precision systems should get it right if you
specify the right number of digits to calculate. But why use expensive
multiple-precision when you don't need it?

The 'right' way to calculate things like log(exp(x)+1)-x and
exp(x)/(exp(x+k)+a) for large values of x is to understand their
asymptotic behavior, easy to do by hand or in a CAS like Maxima (and
presumably yacas, though I don't have any experience with it) -- for
large x, the first looks like exp(-x)-exp(-2*x)/2+...; the second
looks like exp(-k)-a*exp(-(x+k)) + ...  No need for
arbitrary-precision arithmetic once you know this.

 -s

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

2009-02-11 Thread Deepayan Sarkar
On Tue, Feb 10, 2009 at 6:29 AM, Jon Loehrke  wrote:
> Hi R-Users,
>
> I have a time series of bivariate observations (x,y,t).  I've
> developed a few panel routines to explore certain aspects of the data,
> and now would like to break the time series up into smaller chunks to
> explore the temporal trends.  I would like to know if anyone has any
> experience breaking up time series with lattice.
>
> Base graphics offers coplot, utilizing the co.intervals routine to
> break up the series into equal chunks.  Lattice has equal.count as a
> wrapper for co.intervals.  As you can see in the example below, I can
> recreate a 'coplot' with lattice but am having difficulty getting the
> x-axis of the shingle plot and the strip labeling on the xyplot to be
> in time or date format.  My question really consists of two parts,
> with the second part being less important for my data visualization
> purposes:
>
> 1) How might I be able to convert the x-axis of the shingle plot from
> numeric to date format?

Perhaps something like

plot(breaks, xlim = as.Date(extendrange(breaks), origin = structure(0,
class = "Date")))

or the simpler

plot(breaks, xlim = extendrange(times))

(the warning seems harmless).

> 2) How might I be able to customize the strip labels on the xyplot to
> show a range, like min(month, year)-max(month, year) for each panel?

br.levels <- sapply(levels(breaks),
function(x) {
paste(as.character(structure(x, class = "Date")),
  collapse = ", "))

xyplot(y~x|breaks, data=df,
   strip = strip.custom(factor.levels = br.levels,
strip.levels = TRUE,
strip.names = FALSE))

You probably want a suitable 'format' in the as.character() call.

-Deepayan

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


Re: [R] tcltk, tcltk2, Rcmdr, Mac OS X

2009-02-11 Thread Monte Milanuk

Larry,

Since it looks like you've got your problem about whipped, hope you 
don't mind if I piggy back on here...


Same sort of problem... installed Rcmdr via the Package Installer.  
Followed the directions for running X11/Tk ala the site mentioned 
earlier and this is what I get when I try to run Rcmdr:


> library(Rcmdr)
Error in structure(.External("dotTclObjv", objv, PACKAGE = "tcltk"), 
class = "tclObj") :

 [tcl] invalid command name "font".

Error : .onAttach failed in 'attachNamespace'
Error: package/namespace load failed for 'Rcmdr'

Any help would be greatly appreciated.

Thanks,

Monte

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


Re: [R] How to comment in R

2009-02-11 Thread Wacek Kusnierczyk
Greg Snow wrote:
> Apparently I was not clear in my intention in my original reply.  I have no 
> problem with you or anyone else implementing this in whatever way.  Someone 
> could even use Friedl's regex to write a preprocessor in R, he did the hard 
> work already if you follow the rules that he based his regex on.  I think the 
> hard/non-trivial part is agreeing on the rules, and then dealing with all the 
> future posters who expected a different set of rules.
>
>   

indeed;  the problem has been successfully solved, it's just to port it
from c to r, more or less, possibly with simplified syntax (e.g., no
nested blocks, block comments starting and ending only at the beginning
of the line, etc.)

(for those interested, friedl's example is in sec. 6.7 of mastering
regular expressions by o'reilly)

>
>> hey, be fair.  i was talking about the perl-style pod block comments,
>> where it *is* very easy to implement. 
>> 
>
> Your phrase that I responded to was:
> "an extension to the parser that would accept multiline start-end comment
> tags, be it c-style /* */, perl-style =pod =cut, whatever, should be
> fairly  trivial to implement."
>
>   

ok, got me, but implementing perl pod-style blockk comments is really
trivial, modulo open string literals.


> I interpreted the part after the last , to refer to the whole list, you 
> apparently meant it to refer to only the last element of the list (English 
> list, not R list).  I could show this to my friend that is a high school 
> English teacher and see what he thinks, but I would prefer to just blame the 
> English language (or the American corruption thereof) rather than each other.
>   

it's ok, i did say that, but i mean the above, and also that
implementing c-style (or pl/i-style, for that matter) is an
implementational exercise over a solved problem.


>  just any* line that starts with
>   
>> =[^\s] (including =cut; the pattern is perhaps just slightly more
>> complex, but it doesn't really matter here) in a non-block-comment
>> context starts a block comment, and only a line with =cut\s in a
>> block-comment context ends a block comment.  as clear as that.  #=head
>> does not start a block comment, and #foo =cut does not stop a block
>> comment.  is this really difficult to conceive,  agree on, and
>> implement?
>> 
>
> OK, implement your idea of #start and #end at the beginning of lines, 
> probably easy to implement.
>
> Here is my prediction of what will happen when/if that is added.
>
> You will use it as intended only putting free text between the #start and 
> #end tags so that it is clear that it is documentation/comments.
>
> But someone else upon learning of the existence of #start and #end will start 
> using it to skip over sections of code that doesn't work, 

this would be what i'd do, rather than string-commenting.  for the
latter, it's enough (in most cases) to just write string literals with
no assignment.

> or that was redone a different way, etc.  Then they will eventually try to 
> comment out a block with the comment already in it (nesting) or misread 
> something because the line containing #start or #end will have scrolled off 
> the screen, or will want to start/end the comment part way through a line.  
> When they discover the problems due to them wanting the #start #end construct 
> to do more than you intended then they will post asking why they don't behave 
> like /* */ in SAS/C/etc. and this whole discussion will start again.
>   

no;  i would just follow the rule and repetitively refer them to tfm,
provided it will have an appropriate entry.  btw., try ?'#' and
apropos('comment')


> Is that enough reason to not implement it. Probably not, but don't claim that 
> you were not warned.
>   

it was not enough reason to not implement a number of annoying features
already there in r, and it is even less so to remove them.


> To get something added to the main R you need to convince someone that the 
> benefits outweigh the costs.  My attempted point is that the costs include 
> more than just the implementation, there is the documentation and dealing 
> with all the people who don't read the documentation and expect it to behave 
> differently.
>   

scare me more, please ;)

> I believe that there is a small benefit to what you propose, in my mind it 
> does not outweigh the potential cost (but my opinion on this does not really 
> matter, as I am not part of R-core and will have little or no impact on what 
> is or is not added).  If others whose opinions on this do matter are not 
> jumping on the bandwagon to implement this, then it is probably for the same 
> reason, they are not convinced that the benefits outweigh the costs.  You can:
>
> 1: live with it (or without it)
> 2: convince them that the benefits are greater
> 3: convince them that the costs are less
>
>   

i'll live without it.  just adding my few cents to a discussion started
by a user or two asking, not for the first time, about block co

Re: [R] Can't install rggobi package

2009-02-11 Thread hadley wickham
Have you installed ggobi successfully?  Exactly what problem are you
having with the installation?

Regards,

Hadley

On Wed, Feb 11, 2009 at 3:21 PM,   wrote:
> I am unable to install the rggobi package.   I do not have trouble
> installing other packages.  Any advice or suggestions?
>
>
>>sessionInfo()
> R version 2.8.1 (2008-12-22)
> 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
> loaded via a namespace (and not attached):
> [1] tools_2.8.1
>>
>
>
> Joseph F. Lucke
> Senior Statistician
> Research Institute on Addictions
> University at Buffalo
> SUNY
>
>[[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.
>



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

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


Re: [R] How to comment in R

2009-02-11 Thread Wacek Kusnierczyk
Duncan Murdoch wrote:
>
>>
>> what about cases where the syntax is 'obvious' and yet r does the
>> opposite of what one would expect?
>
> We shouldn't add features like that either.  In some cases we have (or
> S did), and the thousands of CRAN packages mean we're stuck with most
> of them.

... where 'thousands' means about 1700.

vQ

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


Re: [R] How to comment in R

2009-02-11 Thread Greg Snow
Apparently I was not clear in my intention in my original reply.  I have no 
problem with you or anyone else implementing this in whatever way.  Someone 
could even use Friedl's regex to write a preprocessor in R, he did the hard 
work already if you follow the rules that he based his regex on.  I think the 
hard/non-trivial part is agreeing on the rules, and then dealing with all the 
future posters who expected a different set of rules.

Additional comments below

> -Original Message-
> From: Wacek Kusnierczyk [mailto:waclaw.marcin.kusnierc...@idi.ntnu.no]
> Sent: Wednesday, February 11, 2009 12:45 PM
> To: Greg Snow
> Cc: R help
> Subject: Re: [R] How to comment in R

[snip]

> 
> hey, be fair.  i was talking about the perl-style pod block comments,
> where it *is* very easy to implement. 

Your phrase that I responded to was:
"an extension to the parser that would accept multiline start-end comment
tags, be it c-style /* */, perl-style =pod =cut, whatever, should be
fairly  trivial to implement."

I interpreted the part after the last , to refer to the whole list, you 
apparently meant it to refer to only the last element of the list (English 
list, not R list).  I could show this to my friend that is a high school 
English teacher and see what he thinks, but I would prefer to just blame the 
English language (or the American corruption thereof) rather than each other.

 just any* line that starts with
> =[^\s] (including =cut; the pattern is perhaps just slightly more
> complex, but it doesn't really matter here) in a non-block-comment
> context starts a block comment, and only a line with =cut\s in a
> block-comment context ends a block comment.  as clear as that.  #=head
> does not start a block comment, and #foo =cut does not stop a block
> comment.  is this really difficult to conceive,  agree on, and
> implement?

OK, implement your idea of #start and #end at the beginning of lines, probably 
easy to implement.

Here is my prediction of what will happen when/if that is added.

You will use it as intended only putting free text between the #start and #end 
tags so that it is clear that it is documentation/comments.

But someone else upon learning of the existence of #start and #end will start 
using it to skip over sections of code that doesn't work, or that was redone a 
different way, etc.  Then they will eventually try to comment out a block with 
the comment already in it (nesting) or misread something because the line 
containing #start or #end will have scrolled off the screen, or will want to 
start/end the comment part way through a line.  When they discover the problems 
due to them wanting the #start #end construct to do more than you intended then 
they will post asking why they don't behave like /* */ in SAS/C/etc. and this 
whole discussion will start again.

Is that enough reason to not implement it. Probably not, but don't claim that 
you were not warned.

To get something added to the main R you need to convince someone that the 
benefits outweigh the costs.  My attempted point is that the costs include more 
than just the implementation, there is the documentation and dealing with all 
the people who don't read the documentation and expect it to behave differently.

I believe that there is a small benefit to what you propose, in my mind it does 
not outweigh the potential cost (but my opinion on this does not really matter, 
as I am not part of R-core and will have little or no impact on what is or is 
not added).  If others whose opinions on this do matter are not jumping on the 
bandwagon to implement this, then it is probably for the same reason, they are 
not convinced that the benefits outweigh the costs.  You can:

1: live with it (or without it)
2: convince them that the benefits are greater
3: convince them that the costs are less


> * not inside string delimiters, for example.  already solved in r for
> single line comments-like multiline strings.
> 
> 
> > While the parser can process the comments without using regular
> expressions, some of the issues that Friedl brings up still need to be
> considered in deciding the rules.  Implementing this in the parser may
> well be trivial once the rules are decided on (but way beyond me), but
> I still think that deciding on the rules and documenting them is far
> from trivial.
> >
> 
> might be helpful to see some concrete counterexamples.

I don't understand what you want as a counterexample.

I think that the fact that nobody has committed either direction on Duncan's 
example supports my point.

> > I remember having some C code that compiled fine and did as intended
> with one compiler, then when I tried compiling with a different
> compiler it threw an error based on the commenting (probably the
> difference was in the preprocessors, not the compilers), so the 2
> different versions of the C compiler/preprocessor did not even agree on
> the rules (I don't remember emacs complaining either way).
> >
> 
> i remember 

Re: [R] How to comment in R

2009-02-11 Thread Wacek Kusnierczyk
Duncan Murdoch wrote:
>
>>>
>>> So if the behaviour isn't very obvious in cases like the one quoted
>>> above, and if the new syntax doesn't add any new expressiveness, I
>>> would be opposed to adding it.
>>
>> what about cases where the syntax is 'obvious' and yet r does the
>> opposite of what one would expect?
>
> We shouldn't add features like that either.  In some cases we have (or
> S did), and the thousands of CRAN packages mean we're stuck with most
> of them.

the curse of popularity?

vQ

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


Re: [R] Efficent way to create an nxn upper triangular matrix of one's

2009-02-11 Thread Christos Hatzis
Here is a way to do this:

round(upper.tri(matrix(1, 9, 9)))

Or if you also need the diagonal of one's

round(upper.tri(matrix(1, 9, 9), diag = TRUE))

-Christos 
 
> -Original Message-
> From: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] On Behalf Of Dale Steele
> Sent: Wednesday, February 11, 2009 4:23 PM
> To: R help
> Subject: [R] Efficent way to create an nxn upper triangular 
> matrix of one's
> 
> The code below create an nxn upper triangular matrix of 
> one's.  I'm stuck on finding a more efficient vectorized way 
> - Thanks.  --Dale
> 
> n <- 9
> data <- matrix(data=NA, nrow=n, ncol=n)
> data
> for (i in 1:n) {
> data[,i] <- c(rep(1,i), rep(0,n-i))
> }
> data
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
>

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


Re: [R] How to comment in R

2009-02-11 Thread Duncan Murdoch

On 2/11/2009 3:52 PM, Wacek Kusnierczyk wrote:

Duncan Murdoch wrote:

On 2/11/2009 2:27 PM, Wacek Kusnierczyk wrote:

Duncan Murdoch wrote:

On 2/11/2009 1:21 PM, Stavros Macrakis wrote:

On Wed, Feb 11, 2009 at 12:32 PM, Greg Snow 
wrote:

...The c-style of /* */ allows both types and you can comment out
part of a line, but it is not simple to match and has its own
restrictions.  Friedl in his regular expressions book takes 10 pages
to develop a pattern to match these (and the final pattern is almost
2 full lines of text in the book).  And this is without allowing
nesting


Though there is a real debate about the value of multiline, possibly
nested, comments, the regular expression argument is a red herring.
Lexical analysis of multiline comments is a solved problem (and not a
particularly difficult one!), and matters only to language and editor
implementors.  Emacs handles them with no problem.


I agree about that.  I think the lack of multiline comments comes from
design considerations rather than implementation ones.   They're just
not needed, and having two types of comments would lead to weird
interactions, e.g. is the block comment closed in the lines below?

  /*
#  */


it's still a simple design decision which, once made, can be implemented
coherently.


I agree it's a design decision and once made implementation would be
easy, but I don't agree that it's a simple design decision.  If it
was, you'd be able to tell me the obvious answer to my question.  If
the answer isn't obvious, then it's a source of errors in programs
when people assume the wrong behaviour.


these are things you shouldn't be willing to say.  is it *obvious* that
x[,1] should return a vector not a data frame or matrix (depending on
what x is)?  how *obvious* it is?  how *obvious* will it be to a user
who has little experience with r and will make best guesses?  how
*obvious* will it be to a user who comes from matlab or the like?

i can tell you the obvious answer to your question:  if tfm said that a
# being the first non-whitespace character in a line appearing in an
open comment block does not work as a single line comment tag, then the
block comment above is closed.  if tfm said otherwise, it would not be
closed.

again and again, one message pervasive on this list is:  if you don't
know, if something is not obvious*, rtfm carefully.  here's your
answer:  decide how to treat overlapping mulitline and single-line
comments, put into a man page, and you're done.  just like with x[,1]. 
and it doesn't really have to be obvious or intuitive -- just like with

x[,1].

* i'd add:  the more something is obvious, the more you're advised to rtfm.




In another message, you pointed out the ugly construct

x <- "
# not a comment
"

which arises because R allows multi-line string literals, and also
gives priority to string content over # comments.  This is a bad
design, in my opinion.  (There shouldn't be multi-line string literals.) 


it's a design choice which can be considered bad or good, depending on
the point of view.  you're sort of saying things you should not be
willing to say, again.  when i criticized r, with concrete examples, for
the design being bad because of *incoherence*, i was promptly accused of
being dogmatic, and the issues were explained away as design
'features'.  now you're saying 'bad design' -- well, it's just a choice,
not even leading to any incoherence, why would it have to be bad?  i
find it more convenient and readable to write

x =
"foo
bar
dee"

rather than

x = "foo\nbar\ndee"


in perl you can write multiline string literals, whereby you include the
newlines in the string, as in r.  whcih is sort of redundant, since perl
supports here documents.  in python you can enter a string literal on
multiple lines escaping the newlines, but the newlines do not belong in
the string.  which is good design, which is bad? 


btw. if you strike the tab key while writing a string literal in an r
script, you get a tab character inside the string.  is this bad design,
too?  how different are tabs from newlines?  from spaces?


You probably haven't studied Rd syntax as closely as I have lately, 


fortunately, haven't at all.


but in an Rd file, # comments are treated as R treats them (i.e.
within a string they don't do anything), % comments are always in
effect.  You should see how many people get confused by the handling
of % comments in Rd files.  But that's not something we can change: 
there are something like 10 Rd files on CRAN.


i can believe, it's pretty enough for me to see how many people get
repeatedly confused by many other features in r.





So if the behaviour isn't very obvious in cases like the one quoted
above, and if the new syntax doesn't add any new expressiveness, I
would be opposed to adding it.


what about cases where the syntax is 'obvious' and yet r does the
opposite of what one would expect?


We shouldn't add features like that either.  In some cases we have (or S 
did), and 

Re: [R] Efficent way to create an nxn upper triangular matrix of one's

2009-02-11 Thread Jorge Ivan Velez
Dear Dale,
Here is one way, probably not the best:

n<-9
temp<-matrix(1,ncol=n,nrow=n)
temp[lower.tri(temp)] <- 0
temp

HTH,

Jorge


On Wed, Feb 11, 2009 at 4:22 PM, Dale Steele wrote:

> The code below create an nxn upper triangular matrix of one's.  I'm
> stuck on finding a more efficient vectorized way - Thanks.  --Dale
>
> n <- 9
> data <- matrix(data=NA, nrow=n, ncol=n)
> data
> for (i in 1:n) {
>data[,i] <- c(rep(1,i), rep(0,n-i))
> }
> data
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] How to handle large numbers?

2009-02-11 Thread Wacek Kusnierczyk
Stavros Macrakis wrote:
> On Wed, Feb 11, 2009 at 6:20 AM, Robin Hankin  wrote:
>   
>>> library(Brobdingnag)
>>> exp(1000)/(exp(1007)+5)
>>>   
>> [1] NaN
>>
>> 
>>> as.numeric(exp(as.brob(1000))/(exp(as.brob(1007))+5))
>>>   
>> [1] 0.000911882
>> 
>
> Though brob is certainly useful in many cases, it can't substitute for
> thinking about numeric issues (roundoff, cancellation, overflow,
> underflow) in general.
>
> For example:
>
>   
>> x<-40; log(exp(x)+1)-x
>> 
> [1] 0
>   
>> x<-as.brob(40); log(exp(x)+1)-x
>> 
> [1] -exp(-Inf)
>
> The correct answer is about 4e-18.  Perhaps Ryacas or some other tool
> gets this right, 

bc gets it arbitrarily right:

bc -l < but in general I don't think it's wise to abdicate
> responsibility to one's tools.

interestingly, perl's bignum gets it slowly and actually wrong (or do i
miss something?):

perl -Mbignum=p,-50 -le 'print (log(exp(40)+1)-40'

vQ

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


Re: [R] Efficent way to create an nxn upper triangular matrix of one's

2009-02-11 Thread Sundar Dorai-Raj
Try

x <- diag(n)
x[upper.tri(x)] <- 1

On Wed, Feb 11, 2009 at 1:22 PM, Dale Steele  wrote:
> The code below create an nxn upper triangular matrix of one's.  I'm
> stuck on finding a more efficient vectorized way - Thanks.  --Dale
>
> n <- 9
> data <- matrix(data=NA, nrow=n, ncol=n)
> data
> for (i in 1:n) {
>data[,i] <- c(rep(1,i), rep(0,n-i))
> }
> data
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] changing settings on a barchart (lattice)

2009-02-11 Thread Sundar Dorai-Raj
Add the "adj" argument to panel.text to left (adj = 0) or right(adj =
1) justify the text. Add the "font" argument to change the font. See
?text.

--sundar

On Wed, Feb 11, 2009 at 1:25 PM, Dimitri Liakhovitski  wrote:
> Thanks a lot, Sundar. I experimented somewhat and here is the code
> that works well - it allows me to modify most of the stuff I want to
> modify:
>
> p<-as.vector(c(0.1, 0.2, 0.3, 0.4))
> names(p)<-c("A","BB","","")
> barchart(~sort(p), main=list("Chart Title",cex=1),xlab=list("X axis
> title",cex=1),xlim=c(0,0.42),
>layout = c(1,1),
>stack = TRUE,
>auto.key = list(points = FALSE, rectangles = TRUE, space = 
> "top"),
>panel = function(y,x,...){
>panel.grid(h = 0, v = -1, col = "gray60", lty 
> ="dotted")
>panel.barchart(x,y,col="brown")
>panel.text(x,y,label = round(x,2),cex=1)
>}
> )
>
> One last question: How can I modify the way the value labels (those
> that are at the end of the bars) appear? Can I make them bold? Make
> them appear a bit to the right or to the left of where they currently
> are?
> Thanks a lot!
>
> Dimitri
>
> On Wed, Feb 11, 2009 at 12:46 PM, Sundar Dorai-Raj  
> wrote:
>> Pass a list to xlab and main for the font sizes:
>>
>> barchart(..., xlab = list("x-axis", cex = 2), main = list("title", cex = 2))
>>
>> For value labels and a grid you'll need a custom panel function:
>>
>> barchart(..., panel = function(x, y, ...) {
>>  panel.barchart(x, y, ...)
>>  panel.text(x, y, format(y), cex = 1.2)
>>  panel.grid(h = -1, v = -1)
>> })
>>
>> This is untested, but I think it should get you started.
>>
>> --sundar
>>
>> On Wed, Feb 11, 2009 at 9:10 AM, Dimitri Liakhovitski  
>> wrote:
>>> Hello!
>>>
>>> I apologize - I never used lattice before, so my question is probably
>>> very basic - but I just can't find the answer in the archive nor in
>>> the documentation:
>>>
>>> I have a named numeric vector p of 6 numbers (of the type 6 numbers
>>> with people's names to whom those numbers belong). I want a simple bar
>>> chart.
>>>
>>> I am doing:
>>>
>>> library(lattice)
>>> trellis.par.set(fontsize=list(text=12))  # Changes only axes font
>>> barchart(~sort(p),main="Text for main",xlab="Text for X axis",
>>> col=PrimaryColors[3])
>>>
>>> It works just fine.
>>> Question: Where how can I change such things as font size for X axis
>>> label (below the numbers), font size for Title, value labels (to label
>>> bars with actual numbers), add grids, etc.?
>>>
>>> Thanks a lot!
>>>
>>> --
>>> Dimitri Liakhovitski
>>> MarketTools, Inc.
>>> dimitri.liakhovit...@markettools.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.
>>>
>>
>
>
>
> --
> Dimitri Liakhovitski
> MarketTools, Inc.
> dimitri.liakhovit...@markettools.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] Table Formatting

2009-02-11 Thread Marc Schwartz
Harold,

xtable() does not handle multicol's AFAICS. Short of hand coding this,
which would not be hard, you can use Frank's latex() function in the
Hmisc package.

Something along the lines of the following will get close.

install.packages("Hmisc", dependencies = TRUE)
library(Hmisc)
?latex

# Presuming that the source data is in a dataframe called 'DF'

latex(DF, file = "DF.tex",
  title = "",
  rowname = NULL,
  cgroup = c("", "SNA1", "SNA2", "SNA3"),
  n.cgroup = c(1, 2, 2, 2),
  colheads = c("", "Year", rep(c("TACC", "Catch"), 3)))


This give you the DF.tex TeX file that I have attached and to which I
manually added the preamble and \end{document} directives.

I am also attaching a PDF of the resultant table for easy review.

If you wanted to have the second line only going over the column pairs
rather than all of the columns, replace the line:

  \tabularnewline \cline{1-10}

with:

  \tabularnewline
  \cline{3-4}
  \cline{6-7}
  \cline{9-10}


See the DF2.* files attached. I did not see away to do that in the
function arguments, but perhaps I missed something.

Frank has more information here:

  http://biostat.mc.vanderbilt.edu/twiki/bin/view/Main/StatReport

HTH,

Marc Schwartz


on 02/11/2009 02:30 PM Doran, Harold wrote:
> The xtable package is probably going to be helpful 
> 
>> -Original Message-
>> From: r-help-boun...@r-project.org 
>> [mailto:r-help-boun...@r-project.org] On Behalf Of jimdare
>> Sent: Wednesday, February 11, 2009 3:26 PM
>> To: r-help@r-project.org
>> Subject: [R] Table Formatting
>>
>>
>> Dear R-Users
>>
>> I have created the following table in R:
>>
>>  Year  TACC.SNA1  Catch.SNA1  TACC.SNA2   Catch.SNA2  
>>  TACC.SNA3  
>> Catch.SNA3 
>> 111 1985-86  9396   185951860 
>> 530   
>> 1486   16727 
>> 112 1986-87  3155   121959506
>> 7067  
>> 49912300 
>> 113 1987-88  69132074 3740
>> 3609 
>> 10206523 
>> 114 1988-89  3210   156772225
>> 9822 
>> 818816154 
>> 115 1989-90  7631   151315330   
>> 3784  
>> 3772 3748 
>> 116 1990-91  99885316 8693  
>> 11583 
>> 5085 19281 
>> 117 1991-92  49611250 5969
>> 274   
>> 59331261 
>> 118 1992-93  9041   133981467   
>> 2492  
>> 9140 3616 
>> 119 1993-94  35742727 1801   
>> 2425  
>> 6039 18808  
>>
>> I need to format this as shown below so I can export it using 
>> LaTeX and paste it into a publication.  Does anyone know how 
>> I could put the 'SNA#'
>> above the column headings and seperate them via a line break? 
>>  Perhaps there is a package I can download that will let me 
>> do this.  Thanks very much for your help,
>>
>> James
>>
>>   SNA1  SNA2  
>>   SNA3
>>  _  _ _
>>   YearTACC  Catch  TACC   Catch TACC  
>> Catch 
>>
>>  1985-86  9396  18595  1860530  1486  
>> 16727 
>>  1986-87  3155  12195  9506   7067  4991  
>>  2300 
>>  1987-88  6913   2074  3740   3609  1020  
>>  6523 
>>  1988-89  3210  15677  2225   9822  8188  
>> 16154 
>>  1989-90  7631  15131  5330   3784  3772  
>>  3748 
>>  1990-91  9988   5316  8693  11583  5085  
>> 19281 
>>  1991-92  4961   1250  5969274  5933  
>>  1261 
>>  1992-93  9041  13398  1467   2492  9140  
>>  3616 
>>  1993-94  3574   2727  1801   2425  6039  
>> 18808 


DF.pdf
Description: Adobe PDF document


DF2.pdf
Description: Adobe PDF document
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Efficent way to create an nxn upper triangular matrix of one's

2009-02-11 Thread Dale Steele
The code below create an nxn upper triangular matrix of one's.  I'm
stuck on finding a more efficient vectorized way - Thanks.  --Dale

n <- 9
data <- matrix(data=NA, nrow=n, ncol=n)
data
for (i in 1:n) {
data[,i] <- c(rep(1,i), rep(0,n-i))
}
data

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


Re: [R] changing settings on a barchart (lattice)

2009-02-11 Thread Dimitri Liakhovitski
Thanks a lot, Sundar. I experimented somewhat and here is the code
that works well - it allows me to modify most of the stuff I want to
modify:

p<-as.vector(c(0.1, 0.2, 0.3, 0.4))
names(p)<-c("A","BB","","")
barchart(~sort(p), main=list("Chart Title",cex=1),xlab=list("X axis
title",cex=1),xlim=c(0,0.42),
layout = c(1,1),
stack = TRUE,
auto.key = list(points = FALSE, rectangles = TRUE, space = 
"top"),
panel = function(y,x,...){
panel.grid(h = 0, v = -1, col = "gray60", lty ="dotted")
panel.barchart(x,y,col="brown")
panel.text(x,y,label = round(x,2),cex=1)
}
)

One last question: How can I modify the way the value labels (those
that are at the end of the bars) appear? Can I make them bold? Make
them appear a bit to the right or to the left of where they currently
are?
Thanks a lot!

Dimitri

On Wed, Feb 11, 2009 at 12:46 PM, Sundar Dorai-Raj  wrote:
> Pass a list to xlab and main for the font sizes:
>
> barchart(..., xlab = list("x-axis", cex = 2), main = list("title", cex = 2))
>
> For value labels and a grid you'll need a custom panel function:
>
> barchart(..., panel = function(x, y, ...) {
>  panel.barchart(x, y, ...)
>  panel.text(x, y, format(y), cex = 1.2)
>  panel.grid(h = -1, v = -1)
> })
>
> This is untested, but I think it should get you started.
>
> --sundar
>
> On Wed, Feb 11, 2009 at 9:10 AM, Dimitri Liakhovitski  
> wrote:
>> Hello!
>>
>> I apologize - I never used lattice before, so my question is probably
>> very basic - but I just can't find the answer in the archive nor in
>> the documentation:
>>
>> I have a named numeric vector p of 6 numbers (of the type 6 numbers
>> with people's names to whom those numbers belong). I want a simple bar
>> chart.
>>
>> I am doing:
>>
>> library(lattice)
>> trellis.par.set(fontsize=list(text=12))  # Changes only axes font
>> barchart(~sort(p),main="Text for main",xlab="Text for X axis",
>> col=PrimaryColors[3])
>>
>> It works just fine.
>> Question: Where how can I change such things as font size for X axis
>> label (below the numbers), font size for Title, value labels (to label
>> bars with actual numbers), add grids, etc.?
>>
>> Thanks a lot!
>>
>> --
>> Dimitri Liakhovitski
>> MarketTools, Inc.
>> dimitri.liakhovit...@markettools.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.
>>
>



-- 
Dimitri Liakhovitski
MarketTools, Inc.
dimitri.liakhovit...@markettools.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] amusement

2009-02-11 Thread Peter Dalgaard

Ben Bolker wrote:

  Browsing Amazon for

Books > Science > Mathematics > Applied > Probability and Statistics > R

()

produces a nice list of R books. Unfortunately, the heading reads:
"Did you mean: sas" ?



Oh, well if you follow that link, you'll get Bob Muenchen's book in 
seventh place to put you back on track...





--
   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
~~ - (p.dalga...@biostat.ku.dk)  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] Can't install rggobi package

2009-02-11 Thread JLucke
I am unable to install the rggobi package.   I do not have trouble 
installing other packages.  Any advice or suggestions?


>sessionInfo()
R version 2.8.1 (2008-12-22) 
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 
loaded via a namespace (and not attached):
[1] tools_2.8.1
> 


Joseph F. Lucke
Senior Statistician
Research Institute on Addictions
University at Buffalo
SUNY

[[alternative HTML version deleted]]

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


Re: [R] How to comment in R

2009-02-11 Thread Wacek Kusnierczyk
Gavin Simpson wrote:
> On Wed, 2009-02-11 at 20:22 +0100, Wacek Kusnierczyk wrote:
>   
>> Greg Snow wrote:
>> 
>>> If it is fairly trivial to implement then go ahead and implement it,
>>>   
>> patches are always welcome.  
>>
>> now that's *not* true.  not so long ago i submitted a patch improving on
>> Prof Brian Ripley's ad hoc fix to grep, and it was silently ignored.
>> 
>
> Hi Wacek,
>
> I recall your posting with patches, but I don't recall whether these
> were done via the bug repository. If they weren't, 

they weren't.  originally, i answered Prof Brian Ripley's post
announcing the fix (which was sent to r help), and since it was ignored,
i resent the fix to r-devel.  if this is not enough, it would be great
if i had been informed about it.  i've seen many bug reports rejected,
and this was not really a bug fix -- at least not immediate, though it
might prevent future bugs due to the distributed nature of the original fix.


> then can I suggest
> you file a bug under the WishList category (or if your patch was in
> response to a bug also sent through the bug repository, attach/reply to
> that with the correct PR#) in the bug repository? At least then someone
> on R core will have to do something with it - even if they subsequently
> ignore it (which one hopes would not happen).
>
> If the patch was just posted to R-Devel, then given the torrent of
> emails people tend to get these days things can get overlooked in there
> for no other reason than people are busy.
>   

that would be a reasonable explanation.  i haven't complained.

> It would be a shame indeed if your contribution was not even
> acknowledged just because it got overlooked.
>   

it was not a big deal, more a matter of style and coderedundancy than of
correctness.  for myself, i don't need it to get through.  i'll give it
another try.  thanks for the response.

vQ

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


Re: [R] Help with XYPLOT with marginal histograms

2009-02-11 Thread Deepayan Sarkar
On Wed, Feb 11, 2009 at 12:37 PM, John Leonard
 wrote:
> I am trying to replicate the following plot using Lattice:
>
>  http://addictedtor.free.fr/graphiques/graphcode.php?graph=78

Why? lattice is not the right tool for this.

Try looking at

http://www.stat.wisc.edu/~deepayan/771/esplot.R

with explanations in

http://www.stat.wisc.edu/~deepayan/771/rgraphics.pdf

-Deepayan

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


Re: [R] How to comment in R

2009-02-11 Thread Wacek Kusnierczyk
Duncan Murdoch wrote:
> On 2/11/2009 2:27 PM, Wacek Kusnierczyk wrote:
>> Duncan Murdoch wrote:
>>> On 2/11/2009 1:21 PM, Stavros Macrakis wrote:
 On Wed, Feb 11, 2009 at 12:32 PM, Greg Snow 
 wrote:
> ...The c-style of /* */ allows both types and you can comment out
> part of a line, but it is not simple to match and has its own
> restrictions.  Friedl in his regular expressions book takes 10 pages
> to develop a pattern to match these (and the final pattern is almost
> 2 full lines of text in the book).  And this is without allowing
> nesting

 Though there is a real debate about the value of multiline, possibly
 nested, comments, the regular expression argument is a red herring.
 Lexical analysis of multiline comments is a solved problem (and not a
 particularly difficult one!), and matters only to language and editor
 implementors.  Emacs handles them with no problem.
>>>
>>> I agree about that.  I think the lack of multiline comments comes from
>>> design considerations rather than implementation ones.   They're just
>>> not needed, and having two types of comments would lead to weird
>>> interactions, e.g. is the block comment closed in the lines below?
>>>
>>>   /*
>>> #  */
>>
>> it's still a simple design decision which, once made, can be implemented
>> coherently.
>
> I agree it's a design decision and once made implementation would be
> easy, but I don't agree that it's a simple design decision.  If it
> was, you'd be able to tell me the obvious answer to my question.  If
> the answer isn't obvious, then it's a source of errors in programs
> when people assume the wrong behaviour.

these are things you shouldn't be willing to say.  is it *obvious* that
x[,1] should return a vector not a data frame or matrix (depending on
what x is)?  how *obvious* it is?  how *obvious* will it be to a user
who has little experience with r and will make best guesses?  how
*obvious* will it be to a user who comes from matlab or the like?

i can tell you the obvious answer to your question:  if tfm said that a
# being the first non-whitespace character in a line appearing in an
open comment block does not work as a single line comment tag, then the
block comment above is closed.  if tfm said otherwise, it would not be
closed.

again and again, one message pervasive on this list is:  if you don't
know, if something is not obvious*, rtfm carefully.  here's your
answer:  decide how to treat overlapping mulitline and single-line
comments, put into a man page, and you're done.  just like with x[,1]. 
and it doesn't really have to be obvious or intuitive -- just like with
x[,1].

* i'd add:  the more something is obvious, the more you're advised to rtfm.


>
> In another message, you pointed out the ugly construct
>
> x <- "
> # not a comment
> "
>
> which arises because R allows multi-line string literals, and also
> gives priority to string content over # comments.  This is a bad
> design, in my opinion.  (There shouldn't be multi-line string literals.) 

it's a design choice which can be considered bad or good, depending on
the point of view.  you're sort of saying things you should not be
willing to say, again.  when i criticized r, with concrete examples, for
the design being bad because of *incoherence*, i was promptly accused of
being dogmatic, and the issues were explained away as design
'features'.  now you're saying 'bad design' -- well, it's just a choice,
not even leading to any incoherence, why would it have to be bad?  i
find it more convenient and readable to write

x =
"foo
bar
dee"

rather than

x = "foo\nbar\ndee"


in perl you can write multiline string literals, whereby you include the
newlines in the string, as in r.  whcih is sort of redundant, since perl
supports here documents.  in python you can enter a string literal on
multiple lines escaping the newlines, but the newlines do not belong in
the string.  which is good design, which is bad? 

btw. if you strike the tab key while writing a string literal in an r
script, you get a tab character inside the string.  is this bad design,
too?  how different are tabs from newlines?  from spaces?


> You probably haven't studied Rd syntax as closely as I have lately, 

fortunately, haven't at all.

> but in an Rd file, # comments are treated as R treats them (i.e.
> within a string they don't do anything), % comments are always in
> effect.  You should see how many people get confused by the handling
> of % comments in Rd files.  But that's not something we can change: 
> there are something like 10 Rd files on CRAN.

i can believe, it's pretty enough for me to see how many people get
repeatedly confused by many other features in r.



>
> So if the behaviour isn't very obvious in cases like the one quoted
> above, and if the new syntax doesn't add any new expressiveness, I
> would be opposed to adding it.

what about cases where the syntax is 'obvious' and yet r does the
opposite of what one

[R] Help with XYPLOT with marginal histograms

2009-02-11 Thread John Leonard
I am trying to replicate the following plot using Lattice:

 

  http://addictedtor.free.fr/graphiques/graphcode.php?graph=78

 

I'm having trouble with the lattice equivalent of the "oma" (outside
margin) setting.  I've been all through the Lattice documentation and
others and also searched the lists.

 

Below is sample code that demonstrates where I'm at (it should paste and
run within an R command prompt.  I'm running 2.8.1):

 

THANKS!!!

 



 

library(lattice)

library(grid)

 

v1 = viewport(

   width=unit(0.8,"npc"),

   height=unit(0.8,"npc"),

   just=c("left","bottom"),

   x=unit(0.0,"npc"),

   y=unit(0.0,"npc"),

   name="v1"

)

v2 = viewport(

   width=unit(0.8,"npc"),

   height=unit(0.2,"npc"),

   just=c("left","bottom"),

   x=unit(0.0,"npc"),

   y=unit(0.8,"npc"),

   name="v2"

)

v3 = viewport(

   width=unit(0.8,"npc"),

   height=unit(0.2,"npc"),

   just=c("left","bottom"),

   x=unit(0.8,"npc"),

   y=unit(0.8,"npc"),

   angle=-90,

   name="v3"

)

 

 

pushViewport(v1)

grid.rect()

print(

  xyplot(

NOx ~ E,

data=ethanol,

  ),

  newpage=FALSE

)

upViewport();

 

pushViewport(v2)

grid.rect()

print(histogram( ethanol$E ),newpage=FALSE)

upViewport()

 

pushViewport(v3)

grid.rect()

print(

  histogram( ethanol$NOx ) ,

  newpage=FALSE

)

 

 


[[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] Table Formatting

2009-02-11 Thread Doran, Harold
The xtable package is probably going to be helpful 

> -Original Message-
> From: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] On Behalf Of jimdare
> Sent: Wednesday, February 11, 2009 3:26 PM
> To: r-help@r-project.org
> Subject: [R] Table Formatting
> 
> 
> Dear R-Users
> 
> I have created the following table in R:
> 
>  Year  TACC.SNA1  Catch.SNA1  TACC.SNA2   Catch.SNA2  
>  TACC.SNA3  
> Catch.SNA3 
> 111 1985-86  9396   185951860 
> 530   
> 1486   16727 
> 112 1986-87  3155   121959506
> 7067  
> 49912300 
> 113 1987-88  69132074 3740
> 3609 
> 10206523 
> 114 1988-89  3210   156772225
> 9822 
> 818816154 
> 115 1989-90  7631   151315330   
> 3784  
> 3772 3748 
> 116 1990-91  99885316 8693  
> 11583 
> 5085 19281 
> 117 1991-92  49611250 5969
> 274   
> 59331261 
> 118 1992-93  9041   133981467   
> 2492  
> 9140 3616 
> 119 1993-94  35742727 1801   
> 2425  
> 6039 18808  
> 
> I need to format this as shown below so I can export it using 
> LaTeX and paste it into a publication.  Does anyone know how 
> I could put the 'SNA#'
> above the column headings and seperate them via a line break? 
>  Perhaps there is a package I can download that will let me 
> do this.  Thanks very much for your help,
> 
> James
> 
>   SNA1  SNA2  
>   SNA3
>  _  _ _
>   YearTACC  Catch  TACC   Catch TACC  
> Catch 
> 
>  1985-86  9396  18595  1860530  1486  
> 16727 
>  1986-87  3155  12195  9506   7067  4991  
>  2300 
>  1987-88  6913   2074  3740   3609  1020  
>  6523 
>  1988-89  3210  15677  2225   9822  8188  
> 16154 
>  1989-90  7631  15131  5330   3784  3772  
>  3748 
>  1990-91  9988   5316  8693  11583  5085  
> 19281 
>  1991-92  4961   1250  5969274  5933  
>  1261 
>  1992-93  9041  13398  1467   2492  9140  
>  3616 
>  1993-94  3574   2727  1801   2425  6039  
> 18808 
> --
> View this message in context: 
> http://www.nabble.com/Table-Formatting-tp21963362p21963362.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 

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


Re: [R] How to comment in R

2009-02-11 Thread Gavin Simpson
On Wed, 2009-02-11 at 20:22 +0100, Wacek Kusnierczyk wrote:
> Greg Snow wrote:
> > If it is fairly trivial to implement then go ahead and implement it,
> patches are always welcome.  
> 
> now that's *not* true.  not so long ago i submitted a patch improving on
> Prof Brian Ripley's ad hoc fix to grep, and it was silently ignored.

Hi Wacek,

I recall your posting with patches, but I don't recall whether these
were done via the bug repository. If they weren't, then can I suggest
you file a bug under the WishList category (or if your patch was in
response to a bug also sent through the bug repository, attach/reply to
that with the correct PR#) in the bug repository? At least then someone
on R core will have to do something with it - even if they subsequently
ignore it (which one hopes would not happen).

If the patch was just posted to R-Devel, then given the torrent of
emails people tend to get these days things can get overlooked in there
for no other reason than people are busy.

It would be a shame indeed if your contribution was not even
acknowledged just because it got overlooked.

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
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%



signature.asc
Description: This is a digitally signed message part
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] More help with Binary Files

2009-02-11 Thread Steve_Friedman


Does anyone else have any insights to this issue:

Henrick, thank you for your very quick response.  I've examined the readBin
help file with respect to endian and I'm still not sure I'm getting this
correct.

Here is what I'm coding:

con <- file(file.choose(), open="rb")
Year66 <- readBin(con, what=integer(), signed = TRUE, size = 2,
endian="little",  n = 40374840)# define endian= "little"
 length(Year66)
 close(con)

# convert millimeters to inches
   Year66.in <- Year66 * 0.039370

 describe(Year66.in)
Year66.in
  n missing  uniqueMean .05 .10 .25 .50 .75
.90 .95
8185584   0   65511  -21.56  -650.1  -650.1  -162.2 0.0 0.0
636.5   639.1

lowest : -1290 -1290 -1290 -1290 -1290, highest:  1290  1290  1290  1290
1290

# establish cut points using inches
  bins <- cut(Year66.in, breaks=30)
  barplot(table(bins))

length(Year66.in)  # this returns a value representing the number of
records read as 8185584 or 20.2% (see next line)  of the records that I'm
expecting.
length(Year66.in) / (419*264*365)  # returns proportion of records expected
in one year

  here I will introduce code to classify the summary statistics using
both a clustering and a non-metric scaling function.  These procedures will
hopefully enable differentiation of   cluster-groupings, associating
the initial input annual year values with a separate (not-shown) calculated
index.


What I eventually want to accomplish is a statistical summary for each of
the 37 years in the binary file.  Reading in the file on a year to year
basis (n=40374840) should give me the all of the records for just the first
year, not all of the records in the binary file.  I also therefore need to
better understand how to read a set of records for year 2, 3, 4, ... 37.

Any ideas ?
Thanks for your assistance

Steve

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

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


   
 Henrik Bengtsson  
   To 
 Sent by:  steve_fried...@nps.gov  
 henrik.bengtsson@  cc 
 gmail.com r-help@r-project.org
   Subject 
   Re: [R] Reading Binary Files
 02/11/2009 09:20  
 AM PST
   
   
   
   




Argument 'size' is what you are looking for, cf. help(readBin).
Whenever reading binary files this way, I strongly recommend that you
are explicit about all arguments of readBin(), e.g.

readBin(con, what=integer(), size=2, signed=TRUE, endian="little", n=n);

For instance, you probably do not want 'endian' to be dependent on the
platform (see help) you run on, but instead be specific to the file
format you are reading.

/Henrik

On Wed, Feb 11, 2009 at 8:04 AM,   wrote:
>
> Hello
>
> I'm encountering some difficulty correctly reading binary files. The
binary
> files store data as "short"  rather than "double" , "int", or any of the
> other  modes of the vector being read.
>
> The data represents a regular grid of size 419 rows by 264 columns, to
make
> it more interesting, the data are daily records, for a total of 37 years.
> The file size is therefore 419(rows) * 264(columns) * 365(days) *
37(years)
> long.
>
> The product  of these dimensions is 1493869080 records.
>
> I'm using the following code to read these into R (windows 2.8.1 )
>
>  con <- file(file.choose(), open="rb")
>  Year66 <- readBin(con, integer, signed=TRUE, n = 40374840)
> close(con)
>
> length(Year66)
>
> returns 2046396
>
> I'm betting that I'm defining the "what" incorrectly, but after numerous
> attempts with different choices I'm wondering if readBin can handle
"short"
> values?
>
> Any help is greatly appreciated.
>
> Steve
>
>
> Steve Friedman Ph. D.
> Spatial Statistical Analyst
> Everglades and Dry Tortugas National Park
> 950 N Krome Ave (3rd Floor)
> Homestead, Florida 33034
>
> steve_fried...@nps.gov
> Office (305) 224 - 4282
> Fax (305) 224 - 4147
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guid

[R] Table Formatting

2009-02-11 Thread jimdare

Dear R-Users

I have created the following table in R:

 Year  TACC.SNA1  Catch.SNA1  TACC.SNA2   Catch.SNA2   TACC.SNA3  
Catch.SNA3 
111 1985-86  9396   185951860 530   
1486   16727 
112 1986-87  3155   1219595067067  
49912300 
113 1987-88  69132074 37403609 
10206523 
114 1988-89  3210   1567722259822 
818816154 
115 1989-90  7631   151315330   3784  
3772 3748 
116 1990-91  99885316 8693  11583 
5085 19281 
117 1991-92  49611250 5969274   
59331261 
118 1992-93  9041   133981467   2492  
9140 3616 
119 1993-94  35742727 1801   2425  
6039 18808  

I need to format this as shown below so I can export it using LaTeX and
paste it into a publication.  Does anyone know how I could put the 'SNA#'
above the column headings and seperate them via a line break?  Perhaps there
is a package I can download that will let me do this.  Thanks very much for
your help,

James

  SNA1  SNA2SNA3
 _  _ _
  YearTACC  Catch  TACC   Catch TACC  Catch 

 1985-86  9396  18595  1860530  1486  16727 
 1986-87  3155  12195  9506   7067  4991   2300 
 1987-88  6913   2074  3740   3609  1020   6523 
 1988-89  3210  15677  2225   9822  8188  16154 
 1989-90  7631  15131  5330   3784  3772   3748 
 1990-91  9988   5316  8693  11583  5085  19281 
 1991-92  4961   1250  5969274  5933   1261 
 1992-93  9041  13398  1467   2492  9140   3616 
 1993-94  3574   2727  1801   2425  6039  18808 
-- 
View this message in context: 
http://www.nabble.com/Table-Formatting-tp21963362p21963362.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] How to comment in R

2009-02-11 Thread Duncan Murdoch

On 2/11/2009 2:27 PM, Wacek Kusnierczyk wrote:

Duncan Murdoch wrote:

On 2/11/2009 1:21 PM, Stavros Macrakis wrote:

On Wed, Feb 11, 2009 at 12:32 PM, Greg Snow  wrote:

...The c-style of /* */ allows both types and you can comment out
part of a line, but it is not simple to match and has its own
restrictions.  Friedl in his regular expressions book takes 10 pages
to develop a pattern to match these (and the final pattern is almost
2 full lines of text in the book).  And this is without allowing
nesting


Though there is a real debate about the value of multiline, possibly
nested, comments, the regular expression argument is a red herring.
Lexical analysis of multiline comments is a solved problem (and not a
particularly difficult one!), and matters only to language and editor
implementors.  Emacs handles them with no problem.


I agree about that.  I think the lack of multiline comments comes from
design considerations rather than implementation ones.   They're just
not needed, and having two types of comments would lead to weird
interactions, e.g. is the block comment closed in the lines below?

  /*
#  */


it's still a simple design decision which, once made, can be implemented
coherently.


I agree it's a design decision and once made implementation would be 
easy, but I don't agree that it's a simple design decision.  If it was, 
you'd be able to tell me the obvious answer to my question.  If the 
answer isn't obvious, then it's a source of errors in programs when 
people assume the wrong behaviour.


In another message, you pointed out the ugly construct

x <- "
# not a comment
"

which arises because R allows multi-line string literals, and also gives 
priority to string content over # comments.  This is a bad design, in my 
opinion.  (There shouldn't be multi-line string literals.) You probably 
haven't studied Rd syntax as closely as I have lately, but in an Rd 
file, # comments are treated as R treats them (i.e. within a string they 
don't do anything), % comments are always in effect.  You should see how 
many people get confused by the handling of % comments in Rd files.  But 
that's not something we can change:  there are something like 10 Rd 
files on CRAN.


So if the behaviour isn't very obvious in cases like the one quoted 
above, and if the new syntax doesn't add any new expressiveness, I would 
be opposed to adding it.


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] tcltk, tcltk2, Rcmdr, Mac OS X

2009-02-11 Thread Lawrence Hanser
John was spot on.  Turns out that when I don't load the workspace Rcmdr
starts up just fine.  It hadn't occurred to me that a workspace could be
corrupt...

On Tue, Feb 10, 2009 at 5:12 PM, John Fox  wrote:

> Dear Larry,
>
> That's odd: The only lmer of which I'm aware is a function in the lme4
> package, and it creates objects of class "mer," I believe. What this has to
> do with the Rcmdr package is beyond me, since the Rcmdr doesn't depend upon
> lme4, but, on the other hand, shouldn't conflict with it. I don't think
> that
> you've mentioned it, but I assume that you're using the current version
> (1.4-7) of the Rcmdr package.
>
> Is it possible that you have a saved and damaged workspace that's being
> loaded at the start of your R session? If so, remove the saved workspace
> (I'm afraid that I don't know where that lives on a Mac, but I suppose that
> getwd() would show you).
>
> John
>
>
> > -Original Message-
> > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On
> > Behalf Of Lawrence Hanser
> > Sent: February-10-09 7:43 PM
> > To: r-help@r-project.org
> > Subject: Re: [R] tcltk, tcltk2, Rcmdr, Mac OS X
> >
> > Thanks.
> > I seem to have gotten a bit further, but still not completely successful.
> >
> > BTW, I should have said that I am running R 2.8.1 GUI 1.27 Tiger build
> > 32-bit (5301).
> >
> > X11 starts fine from the icon.
> > library(tcltk) loads fine.
> >
> > Now I get this when I load Rcmdr:
> >
> > --
> > > library(Rcmdr)
> > Loading required package: car
> > Error in getClass(class(x)) : "lmer" is not a defined class
> > Error : .onAttach failed in 'attachNamespace'
> > Error: package/namespace load failed for 'Rcmdr'
> > --
> >
> > Any help would be appreciated.
> >
> > Larry
> >
> >
> >
> > On Tue, Feb 10, 2009 at 3:08 PM, John Fox  wrote:
> >
> > > Dear Larry,
> > >
> > > The tcltk package is part of the standard R distribution; it doesn't
> live
> > > on
> > > CRAN, and should already be installed. Have you tried loading tcltk
> > > directly
> > > -- library(tcltk)?
> > >
> > > It's possible that you don't have X11 Tcl/Tk installed on your Mac.
> Take
> a
> > > look at the Rcmdr installation notes for Macs, at
> > > ,
> if
> > > you
> > > haven't already done so.
> > >
> > > I hope this helps,
> > >  John
> > >
> > > --
> > > John Fox, Professor
> > > Department of Sociology
> > > McMaster University
> > > Hamilton, Ontario, Canada
> > > web: socserv.mcmaster.ca/jfox
> > >
> > >
> > > > -Original Message-
> > > > From: r-help-boun...@r-project.org
> [mailto:r-help-boun...@r-project.org]
> > > On
> > > > Behalf Of Lawrence Hanser
> > > > Sent: February-10-09 5:01 PM
> > > > To: r-help@r-project.org
> > > > Subject: [R] tcltk, tcltk2, Rcmdr, Mac OS X
> > > >
> > > > Dear Colleagues,
> > > > When I try to install Rcmdr the following happens:
> > > >
> > > > --
> > > > > library(Rcmdr)
> > > > Error in structure(.External("dotTclObjv", objv, PACKAGE = "tcltk"),
> > > class
> > > =
> > > > "tclObj") :
> > > >   [tcl] invalid command name "font".
> > > >
> > > > Error : .onAttach failed in 'attachNamespace'
> > > > Error: package/namespace load failed for 'Rcmdr'
> > > > --
> > > >
> > > > I wondered if this is because there is no "tcltk" package installed.
> So
> > > I
> > > > tried:
> > > >
> > > > --
> > > > > install.packages("tcltk")
> > > > Warning in install.packages("tcltk") :
> > > >   argument 'lib' is missing: using '/Users/hanser/Library/R/library'
> > > > Warning message:
> > > > package 'tcltk' is not available
> > > > --
> > > >
> > > > Is there in fact a tcltk package?  Has it been replaced by tcltk2?
> > > >
> > > > Help appreciated.
> > > >
> > > > Regards,
> > > >
> > > > Larry
> > > >
> > > >   [[alternative HTML version deleted]]
> > > >
> > > > __
> > > > R-help@r-project.org mailing list
> > > > https://stat.ethz.ch/mailman/listinfo/r-help
> > > > PLEASE do read the posting guide
> > > http://www.R-project.org/posting-guide.html
> > > > and provide commented, minimal, self-contained, reproducible code.
> > >
> > >
> > >
> >
> >   [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
>
>

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

Re: [R] R on Mobile Devices (Android)

2009-02-11 Thread Warren Young

Gustaf Rydevik wrote:

"3.3.2 [...]No interpreted code may be downloaded and used in
an Application except for code that is interpreted and run by Apple's
Published APIs and built-
in interpreter(s)."
and

"An Application may not itself install or launch other executable code
by any means, including without limitation through the use of a plugin
architecture, calling other frameworks, other APIs or otherwise."


I'm not too familiar with programming speech, but it seems this would
cover R, no?


Mmmm...I think there's wiggle room here for a limited version of R.

The first clause says you couldn't have an R interpreter on the device 
that downloaded an R script and ran it.  It doesn't say you can't type 
an R script into the phone and run it there.  They're trying to block 
things like Flash and Silverlight with this restriction.  That, and the 
general security risks of running remotely-sourced content.


The second clause says install.packages() won't be allowed.  I don't see 
that it prevents you from distributing R with a pre-selected group of 
packages, however.


Keep in mind that all apps have to be approved by Apple, who haven't 
been entirely fair in their selection criteria.  And, you don't get to 
find out if they will accept the app until you finish it and submit it. 
 You risk wasting a lot of time, doing the port and then being rejected.


If you go ahead anyway, I hope you go beyond just customizing the stock 
keyboard.  I'd like to see:


- Instead of customizing the default keyboard, I'd rather have a 
calculator-like UI, with just a line or two of text at the top so you 
can see the expression, and the rest of the screen having an extended 
keyboard: letters, numbers, operator symbols, even custom buttons like 
an arrow button for assignment instead of having to type two math operators.


- Automatic parens, brackets, and quotes inference: when you've typed 
the name of a known function, add open and closed parens, and put the 
cursor between them.  In case of ambiguity -- can't do this for 
functions like print(), since you don't know if a dot is about to be 
typed to select a particular print method -- let user type open paren 
and add closed paren automatically.  Similarly, when the user types a 
bracket, quote, etc., supply the matching one and put the cursor between 
them.  Several text editors for Eclipse do this well, but not all.  A 
tricky bit is editing, where adding another quote, for instance, might 
not require the matching one to be added.


- Buttons for common functions, like plot()

- A button for downloading a data set from a web or FTP server and 
assigning it to a variable.  Basically, a wrapper around download.file() 
and read.table(), with automatic variable assignment and memory for the 
last variable name and URL used.


This is what I mean by changing the UI to match the capabilities of the 
device.


You'll probably end up excising a lot of stuff.  PDF support for 
instance: unless Cocoa Touch includes access to PDF rendering abilities, 
I don't know that I'd bloat the binary by adding it, particularly with 
the lack of a user-visible file system.  Yes, I'm aware that there are 
tools that let you poke around in the file system, but it's not the way 
the device is meant to be used.  Maybe you could justify it if there 
were a built-in way to send the generated PDF off elsewhere, such as an 
email attachment.


Bottom line: if it were available and worked well, I'd sure use it.  I 
just don't think a straight port would do it for me.


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


Re: [R] How to comment in R

2009-02-11 Thread Wacek Kusnierczyk
Greg Snow wrote:
> Stavros,
>
> Thanks for the clarification and going further back in the credit for /* */.  
>
> I don't think that the regex argument is a complete red herring (possibly a 
> pink herring or burnt umber herring?).  The post I was responding to said 
> that implementing it would be trivial, I think that the fact that Friedl 
> spends 10 pages discussing it shows that it is less than trivial.  

hey, be fair.  i was talking about the perl-style pod block comments,
where it *is* very easy to implement.  just any* line that starts with
=[^\s] (including =cut; the pattern is perhaps just slightly more
complex, but it doesn't really matter here) in a non-block-comment
context starts a block comment, and only a line with =cut\s in a
block-comment context ends a block comment.  as clear as that.  #=head
does not start a block comment, and #foo =cut does not stop a block
comment.  is this really difficult to conceive,  agree on, and implement?

* not inside string delimiters, for example.  already solved in r for
single line comments-like multiline strings.


> While the parser can process the comments without using regular expressions, 
> some of the issues that Friedl brings up still need to be considered in 
> deciding the rules.  Implementing this in the parser may well be trivial once 
> the rules are decided on (but way beyond me), but I still think that deciding 
> on the rules and documenting them is far from trivial.
>   

might be helpful to see some concrete counterexamples.

> I remember having some C code that compiled fine and did as intended with one 
> compiler, then when I tried compiling with a different compiler it threw an 
> error based on the commenting (probably the difference was in the 
> preprocessors, not the compilers), so the 2 different versions of the C 
> compiler/preprocessor did not even agree on the rules (I don't remember emacs 
> complaining either way).
>   

i remember a c++ compiler that would ignore for loops (i had to replace
all of them with while...). 

r is already complex enough, both syntactically and semantically, for
multiline comments to be an outstanding unsurmountable complication.


> Others have mentioned using sed as another way to add/strip comment markers 
> to regions of code.  Along these lines someone could always use C-style (or 
> PL/I style to be more correct but less common in my experience) comments, 
> then run the code through a C preprocessor before submitting to R (then you 
> just have to live with the rules of the preprocessor).
>   

well, cpp is a bit too focused on c.  from man cpp:

" The C preprocessor is intended to be used only with C, C++, and Objec‐
   tive-C source code.  In the past, it has been abused as a general
text
   processor.  It will choke on input which does not obey C’s lexical
   rules."

which does not mean you couldn't be able to tweak it to block-commenting
r code.

btw. the sed example was trivialized, it would not treat comment-like
parts of character strings properly -- but sed is not intended as a
generic parser, it's still a line-by-line text processor, with some
features allowing it to consider multiline context, and it's presumably
best to have the r parser do the job.

> I have no problem with someone adding this capability to R, I just prefer 
> that R-Core spends their time on higher priority items.  If someone else 
> wants to contribute the change, I won't complain (unless it breaks my 
> existing code, which is unlikely if done properly), I just wanted anyone who 
> was thinking of doing this to think about some of the potential pitfalls so 
> that if they implement it, they implement it well.
>
>   

it's *design* that has to be done properly in the first place. 

vQ



-- 
---
Wacek Kusnierczyk, MD PhD

Email: w...@idi.ntnu.no
Phone: +47 73591875, +47 72574609

Department of Computer and Information Science (IDI)
Faculty of Information Technology, Mathematics and Electrical Engineering (IME)
Norwegian University of Science and Technology (NTNU)
Sem Saelands vei 7, 7491 Trondheim, Norway
Room itv303

Bioinformatics & Gene Regulation Group
Department of Cancer Research and Molecular Medicine (IKM)
Faculty of Medicine (DMF)
Norwegian University of Science and Technology (NTNU)
Laboratory Center, Erling Skjalgsons gt. 1, 7030 Trondheim, Norway
Room 231.05.060

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


Re: [R] Eror message: not a valid package -- installed < 2.0.0

2009-02-11 Thread Ben Bolker

   Is there any reason you can't just install an up-to-date version of R (R
2.8.1), from cran.us.r-project.org (or your favorite mirror, see
www.r-project.org) and see if that fixes the problem?  Installing R on SunOS
is not quite the breeze that it is on MacOS, Windows, or Linux, but it's not
that bad ... and you are much more likely to get help from the list if you
make it worth people's while to help you by either (1) explaining why you
are stuck with an old version [regulatory compliance/mission-critical old R
software] or (2) installing recent R and showing that the problem persists.

 Ben Bolker


Powers, Randall - BLS wrote:
> 
> 
> 
>> Hello R-help,
>> 
>> 
>> We are running R version 2.6.0 (2007-10-03). I believe that I got it
>> from www.sunfreeware.com. A number of the packages that we attempt to
>> download from http://www.r-project.org/  give us the error message
>> below when we attempt to run them.
>> 
> 

-- 
View this message in context: 
http://www.nabble.com/Eror-message%3A--not-a-valid-packageinstalled-%3C-2.0.0-tp21962051p21962788.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] What is going on?

2009-02-11 Thread Ben Bolker


 The problem is that strsplit is designed to work on a *vector* of
characters (your example is a length-1 vector of characters), each
of which might end up being split into a character vector of different
lengths, so it returns its results as a *list* the same length as
the original character vector: in this case a list of length 1.

> str(l)
List of 1
 $ : chr [1:2] "1" "2"

length(l) is 1; length(l[[1]]) is 2.

  Ben Bolker


Paul Johnston-6 wrote:
> 
> Ok, so I'm new to R, but this is driving me crazy.  In this example, I
> am trying to process each element in a list.
> 
> 
> s = "1,2"
> l = strsplit(s, ",", fixed=TRUE)
> print("BEGIN")
> n = length(l)
> i = 1
> while (i <= n) {
>   x = l[[i]]
>   print(paste("x:", class(x), x))
>   print("BEFORE PRINT")
>   print(x)
>   print("AFTER PRINT")
>   i = i + 1
> }
> 
> 
> 
>  [exec] [1] "BEGIN"
>  [exec] [1] "x: character 1" "x: character 2"
>  [exec] [1] "BEFORE PRINT"
>  [exec] [1] "1" "2"
>  [exec] [1] "AFTER PRINT"
>  [exec] [1] "END"
>  [exec] [1] TRUE
> 
> 
> 
>  [exec] [1] "BEGIN"
>  [exec] [1] "x: character 1"
>  [exec] [1] "BEFORE PRINT"
>  [exec] [1] "1"
>  [exec] [1] "AFTER PRINT"
>  [exec] [1] "x: character 2"
>  [exec] [1] "BEFORE PRINT"
>  [exec] [1] "2"
>  [exec] [1] "AFTER PRINT"
>  [exec] [1] "END"
>  [exec] [1] TRUE
> 
> 
> What *basic* concept am I missing here?  The same thing happens with
> for (x in l) and lapply(l, function(x) print(x)). Please help.
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/What-is-going-on--tp21962284p21962681.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] What is going on?

2009-02-11 Thread Sarah Goslee
Lists. You're missing the "list" concept. I'm sure others can explain it
better, but here's the basic idea.

Take a look at l after you do the split:
> l
[[1]]
[1] "1" "2"
> length(l)
[1] 1

strsplit() returns a list of length 1, with two elements, the two
split "bits" of your initial string. The help for strsplit() even says:

   A list of length 'length(x)' the 'i'-th element of which contains
 the vector of splits of 'x[i]'.

You can get the individual components that you expected with
l[[1]][1]
and
l[[1]][2]

This is confusing in the single case, but allows strsplit to work on multiple
strings:

> s <- c("1,2", "3,4")
> l = strsplit(s, ",", fixed=TRUE)
> l
[[1]]
[1] "1" "2"

[[2]]
[1] "3" "4"

> l[[1]][1]
[1] "1"
> l[[2]][1]
[1] "3"
> length(l)
[1] 2

On Wed, Feb 11, 2009 at 2:18 PM, Paul Johnston  wrote:
> Ok, so I'm new to R, but this is driving me crazy.  In this example, I
> am trying to process each element in a list.
>
> 
> s = "1,2"
> l = strsplit(s, ",", fixed=TRUE)
> print("BEGIN")
> n = length(l)
> i = 1
> while (i <= n) {
>  x = l[[i]]
>  print(paste("x:", class(x), x))
>  print("BEFORE PRINT")
>  print(x)
>  print("AFTER PRINT")
>  i = i + 1
> }
> 
>
> 
> [exec] [1] "BEGIN"
> [exec] [1] "x: character 1" "x: character 2"
> [exec] [1] "BEFORE PRINT"
> [exec] [1] "1" "2"
> [exec] [1] "AFTER PRINT"
> [exec] [1] "END"
> [exec] [1] TRUE
> 
>
> 
> [exec] [1] "BEGIN"
> [exec] [1] "x: character 1"
> [exec] [1] "BEFORE PRINT"
> [exec] [1] "1"
> [exec] [1] "AFTER PRINT"
> [exec] [1] "x: character 2"
> [exec] [1] "BEFORE PRINT"
> [exec] [1] "2"
> [exec] [1] "AFTER PRINT"
> [exec] [1] "END"
> [exec] [1] TRUE
> 
>
> What *basic* concept am I missing here?  The same thing happens with
> for (x in l) and lapply(l, function(x) print(x)). Please help.
>

-- 
Sarah Goslee
http://www.functionaldiversity.org

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


Re: [R] What is going on?

2009-02-11 Thread Peter Alspach
Kia ora Paul

length(l) is 1 - that is, it is a list of with one element.  That list
element is a character vector of length 2.

HTH 

Peter Alspach 

> -Original Message-
> From: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] On Behalf Of Paul Johnston
> Sent: Thursday, 12 February 2009 8:18 a.m.
> To: r-help@r-project.org
> Subject: [R] What is going on?
> 
> Ok, so I'm new to R, but this is driving me crazy.  In this 
> example, I am trying to process each element in a list.
> 
> 
> s = "1,2"
> l = strsplit(s, ",", fixed=TRUE)
> print("BEGIN")
> n = length(l)
> i = 1
> while (i <= n) {
>   x = l[[i]]
>   print(paste("x:", class(x), x))
>   print("BEFORE PRINT")
>   print(x)
>   print("AFTER PRINT")
>   i = i + 1
> }
> 
> 
> 
>  [exec] [1] "BEGIN"
>  [exec] [1] "x: character 1" "x: character 2"
>  [exec] [1] "BEFORE PRINT"
>  [exec] [1] "1" "2"
>  [exec] [1] "AFTER PRINT"
>  [exec] [1] "END"
>  [exec] [1] TRUE
> 
> 
> 
>  [exec] [1] "BEGIN"
>  [exec] [1] "x: character 1"
>  [exec] [1] "BEFORE PRINT"
>  [exec] [1] "1"
>  [exec] [1] "AFTER PRINT"
>  [exec] [1] "x: character 2"
>  [exec] [1] "BEFORE PRINT"
>  [exec] [1] "2"
>  [exec] [1] "AFTER PRINT"
>  [exec] [1] "END"
>  [exec] [1] TRUE
> 
> 
> What *basic* concept am I missing here?  The same thing 
> happens with for (x in l) and lapply(l, function(x) 
> print(x)). Please help.
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 

The contents of this e-mail are confidential and may be subject to legal 
privilege.
 If you are not the intended recipient you must not use, disseminate, 
distribute or
 reproduce all or any part of this e-mail or attachments.  If you have received 
this
 e-mail in error, please notify the sender and delete all material pertaining 
to this
 e-mail.  Any opinion or views expressed in this e-mail are those of the 
individual
 sender and may not represent those of The New Zealand Institute for Plant and
 Food Research Limited.

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


Re: [R] How to comment in R

2009-02-11 Thread Wacek Kusnierczyk
Duncan Murdoch wrote:
> On 2/11/2009 1:21 PM, Stavros Macrakis wrote:
>> On Wed, Feb 11, 2009 at 12:32 PM, Greg Snow  wrote:
>>> ...The c-style of /* */ allows both types and you can comment out
>>> part of a line, but it is not simple to match and has its own
>>> restrictions.  Friedl in his regular expressions book takes 10 pages
>>> to develop a pattern to match these (and the final pattern is almost
>>> 2 full lines of text in the book).  And this is without allowing
>>> nesting
>>
>> Though there is a real debate about the value of multiline, possibly
>> nested, comments, the regular expression argument is a red herring.
>> Lexical analysis of multiline comments is a solved problem (and not a
>> particularly difficult one!), and matters only to language and editor
>> implementors.  Emacs handles them with no problem.
>
> I agree about that.  I think the lack of multiline comments comes from
> design considerations rather than implementation ones.   They're just
> not needed, and having two types of comments would lead to weird
> interactions, e.g. is the block comment closed in the lines below?
>
>   /*
> #  */

it's still a simple design decision which, once made, can be implemented
coherently.

vQ

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


Re: [R] How to comment in R

2009-02-11 Thread Wacek Kusnierczyk
Stavros Macrakis wrote:
> On Wed, Feb 11, 2009 at 12:32 PM, Greg Snow  wrote:
>   
>> ...The c-style of /* */ allows both types and you can comment out part of a 
>> line, but it is not simple to match and has its own restrictions.  Friedl in 
>> his regular expressions book takes 10 pages to develop a pattern to match 
>> these (and the final pattern is almost 2 full lines of text in the book).  
>> And this is without allowing nesting
>> 
>
> Though there is a real debate about the value of multiline, possibly
> nested, comments, the regular expression argument is a red herring.
> Lexical analysis of multiline comments is a solved problem (and not a
> particularly difficult one!), and matters only to language and editor
> implementors.  Emacs handles them with no problem.
>
>   

indeed.  but any argument is good to defend whatever has been or hasn't
been implemented in r.

>
>
> PS And to give credit where credit is due (important on this mailing
> list), the /* */ syntax was defined by PL/I; C simply implemented an
> existing convention and popularized it. :-)
>   

it might be my fault, i was talking about c-style comments here, not
sure if i was the first to do so.

vQ

-- 
---
Wacek Kusnierczyk, MD PhD

Email: w...@idi.ntnu.no
Phone: +47 73591875, +47 72574609

Department of Computer and Information Science (IDI)
Faculty of Information Technology, Mathematics and Electrical Engineering (IME)
Norwegian University of Science and Technology (NTNU)
Sem Saelands vei 7, 7491 Trondheim, Norway
Room itv303

Bioinformatics & Gene Regulation Group
Department of Cancer Research and Molecular Medicine (IKM)
Faculty of Medicine (DMF)
Norwegian University of Science and Technology (NTNU)
Laboratory Center, Erling Skjalgsons gt. 1, 7030 Trondheim, Norway
Room 231.05.060

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


Re: [R] How to comment in R

2009-02-11 Thread Wacek Kusnierczyk
Greg Snow wrote:
> If it is fairly trivial to implement then go ahead and implement it, patches 
> are always welcome.  

now that's *not* true.  not so long ago i submitted a patch improving on
Prof Brian Ripley's ad hoc fix to grep, and it was silently ignored.

in general, it should be fairly trivial for someone who knows the source
code.  having seen some of r's internals i must admit that it may indeed
not be a simple task.  but if you provide support -- specifically, tell
me which files are relevant for the fix -- i will be (relatively) happy
to look into it, should this be helpful to the community.


> But make sure that it does all that is intended and does it properly, I don't 
> think this is as trivial as it first appears.
>   

agreed, in r many things are not as trivial as they first appear.

> The =pod and =cut of Perl is simple (but was not originally intended as just 
> comments), but this is limited to the "here is documentation" type comments, 
> not the "skip this code" type comments (since the = needs to be the first 
> thing on a line).  You also run into problems if a space accidently inserted 
> before the = and you cannot comment out part of a line.
>   

i don't think the users ask for something as general as include-anywhere
c-style comments.  a compromise would be to have specific tags (e.g.,
'#start' and '#end' as in the sed example i've posted) delimit block
comments if they appear as the first non-whitespace characters on a
line.  it's pretty convenient, but does not require sophisticated
parsing exceptions.  and they are still comments in themselves, just
that a user would have to be aware that #start-#end would comment out a
block, and that an unmatched #start or #end would (or not, depending on
the design choice) cause a parse error.


> I believe that there is already a wishlist entry or possibly upgraded to a 
> todo entry to implement multiline quoting (sometimes called heredocs) where 
> you can specify that the next several lines will the character string of 
> interest (< ...
> END
> in Perl, some shell scripts, and probably others).  If this is implemented, 
> then this would be one approach for the above (but still hard to visually 
> parse if used on code and not clear documentation).
>   

i don't find particularly appealing the idea of using anything designed
for other purposes (e.g., functions, if(FALSE), brew, here docs, etc.)
to provide for block comments.  if you do think of having block
comments, do it with block comment syntax, not ugly hacking.

> The c-style of /* */ allows both types and you can comment out part of a 
> line, but it is not simple to match and has its own restrictions.  Friedl in 
> his regular expressions book takes 10 pages to develop a pattern to match 
> these (and the final pattern is almost 2 full lines of text in the book).  
> And this is without allowing nesting.  If we don't allow nesting of comments, 
> then in the future someone is going to comment out a block of code that is 
> not working and they want to skip for now, but that block is going to already 
> have a comment inside which will then screw up the parsing due to the 
> no-nesting rule, then we will have a whole new discussion when that person 
> posts to the list with a complaint that things are not working as expected.  
> Sticking with # to the end of the line is simple, and with modern editors, 
> easy.
>   

with modern editors you can easily introduce getters/setters together
with members in java, and yet many modern languages provide features
that allow you to use metaprogramming and avoid editor-dependent
tricks.  besides, there are people who prefer to code with plain old
not-so-superduper editors.


> Consider the following code, what parts are commented out and which should be 
> run?
>
> x <- rnorm(100)
> /* begin of code that does not work yet, I will come back to this later
> y <- rnorm( length(x), mean(x)
> txt <- " /
> z <- runif(20)
> /**"
> mean( (x+3)*10
>
> end comment */
> mean(x)
>
>   


consider the following code:

somefunction(x<-1)

will x be assigned to or not?

you can always give pro and counter examples, and i agree things should
be as complex as needed, but as simple as possible.  what you show above
is clearly a design issue.  once you decide on the design, it's just to
implement it accordingly.  in the above, either way is reasonable, in
principle. 

consider the following example:

foo <- "
# to comment or not to comment?
"

how many characters will foo have?  it's just the same sort of problem
-- would this be a reason to prohibit any sort of comments in r?  if
this is easy to parse correctly, what's wrong with the above?  it's
exactly the same issue -- locally switch off commenting when inside
string delimiters.

vQ

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.htm

[R] What is going on?

2009-02-11 Thread Paul Johnston
Ok, so I'm new to R, but this is driving me crazy.  In this example, I
am trying to process each element in a list.


s = "1,2"
l = strsplit(s, ",", fixed=TRUE)
print("BEGIN")
n = length(l)
i = 1
while (i <= n) {
  x = l[[i]]
  print(paste("x:", class(x), x))
  print("BEFORE PRINT")
  print(x)
  print("AFTER PRINT")
  i = i + 1
}



 [exec] [1] "BEGIN"
 [exec] [1] "x: character 1" "x: character 2"
 [exec] [1] "BEFORE PRINT"
 [exec] [1] "1" "2"
 [exec] [1] "AFTER PRINT"
 [exec] [1] "END"
 [exec] [1] TRUE



 [exec] [1] "BEGIN"
 [exec] [1] "x: character 1"
 [exec] [1] "BEFORE PRINT"
 [exec] [1] "1"
 [exec] [1] "AFTER PRINT"
 [exec] [1] "x: character 2"
 [exec] [1] "BEFORE PRINT"
 [exec] [1] "2"
 [exec] [1] "AFTER PRINT"
 [exec] [1] "END"
 [exec] [1] TRUE


What *basic* concept am I missing here?  The same thing happens with
for (x in l) and lapply(l, function(x) print(x)). Please help.

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


Re: [R] extract trend data from stl

2009-02-11 Thread Duncan Murdoch

On 2/11/2009 8:39 AM, doloop wrote:

I am using the stl function to decompose a time series.  I want to access the
trend data hopefully by placing it into a separate vector.  How do I do
that?


After you have run the example(stl) code, the three series are the three 
columns of sts.  The trend is sts[,"trend"].


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] bar plot/ histogram

2009-02-11 Thread Greg Snow
You can still use hist, just provide your own breaks:

mydata <- sample(1:10, 100, TRUE, 10:1)
br <- c( 0.5:4.5, 10.5 )
hist(mydata, breaks=br, xaxt='n')
axis(1, at= c(1:4, mean(5:10)), c( 1:4, '5-10'))
box(bty='l')

hope this helps,

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


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
> project.org] On Behalf Of phoebe kong
> Sent: Wednesday, February 11, 2009 11:11 AM
> To: r-help
> Subject: [R] bar plot/ histogram
> 
> Hi all,
> 
> I would like to construct plot of the distribution of N, where N range
> from 1 to 10. I couldn't just use the hist(), as I want the categories
> for the bars are: 1, 2, 3, 4, >=5. So this will be a bar plot with 5
> bars, and the height of the bar will be the frequency of N. (eg bar#1
> will be the frequency of N=1, bar #2 will be frequency of N=2, and
> bar#5 will be the frequency of N>=5).
> 
> Thanks in advance for your help!
> 
> SY
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] extract trend data from stl

2009-02-11 Thread Roy Mendelssohn

?stl

-Roy
On Feb 11, 2009, at 5:39 AM, doloop wrote:



I am using the stl function to decompose a time series.  I want to  
access the
trend data hopefully by placing it into a separate vector.  How do I  
do

that?

Thanks.
--
View this message in context: 
http://www.nabble.com/extract-trend-data-from-stl-tp21954844p21954844.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.


**
"The contents of this message do not reflect any position of the U.S.  
Government or NOAA."

**
Roy Mendelssohn
Supervisory Operations Research Analyst
NOAA/NMFS
Environmental Research Division
Southwest Fisheries Science Center
1352 Lighthouse Avenue
Pacific Grove, CA 93950-2097

e-mail: roy.mendelss...@noaa.gov (Note new e-mail address)
voice: (831)-648-9029
fax: (831)-648-8440
www: http://www.pfeg.noaa.gov/

"Old age and treachery will overcome youth and skill."
"From those who have been given much, much will be expected"

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


Re: [R] How to apply table() on subdata and stack outputs

2009-02-11 Thread jim holtman
This may be what you want:

> table(input.df$id, input.df$var_interest)

 happy soso unhappy
  jack 0 21   1
  tom  1 10   1


On Wed, Feb 11, 2009 at 1:34 PM, Sean Zhang  wrote:
> Dear R helpers:
>
> I am a R novice and have a question about using table() to extract
> frequences over many sub-datasets.
> A small example input dataframe and wanted output dataframe are provided
> below. The real data is very large so a for loop is what I try to avoid.
>
> Can someone englithen me how to use sapply or the like to achieve it?
>
> Many thanks in advance!
>
> -Sean
>
> #example input dataframe
> id <- c('tom', 'tom', 'tom', 'jack', 'jack', 'jack', 'jack')
> var_interest <- c("happy","unhappy", "", "happy", "unhappy", 'soso','happy')
> input.df <- data.frame(id=id, var_interest=var_interest)
> input.df
> wanted.df <-
>
> #output dataframe I want
> id_unique <- c('tom','jack')
> happy_freq<-c(1,2)
> unhappy_freq<-c(1,1)
> soso_freq<-c(0,1)
> miss_freq<-c(1,0)
> output.df <-data.frame(id_unique=id_unique, happy_freq=happy_freq,
> unhappy_freq=unhappy_freq, soso_freq=soso_freq, miss_freq=miss_freq)
> output.df
>
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

What is the problem that you are trying to solve?

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


Re: [R] How to apply table() on subdata and stack outputs

2009-02-11 Thread Uwe Ligges



Sean Zhang wrote:

Dear R helpers:

I am a R novice and have a question about using table() to extract
frequences over many sub-datasets.
A small example input dataframe and wanted output dataframe are provided
below. The real data is very large so a for loop is what I try to avoid.

Can someone englithen me how to use sapply or the like to achieve it?



I'd simply use

  table(input.df)

or perhaps closer to the result you want:

 reshape(as.data.frame(table(input.df)), direction="wide",
 timevar="var_interest")


Uwe Ligges




Many thanks in advance!

-Sean

#example input dataframe
id <- c('tom', 'tom', 'tom', 'jack', 'jack', 'jack', 'jack')
var_interest <- c("happy","unhappy", "", "happy", "unhappy", 'soso','happy')
input.df <- data.frame(id=id, var_interest=var_interest)
input.df
wanted.df <-

#output dataframe I want
id_unique <- c('tom','jack')
happy_freq<-c(1,2)
unhappy_freq<-c(1,1)
soso_freq<-c(0,1)
miss_freq<-c(1,0)
output.df <-data.frame(id_unique=id_unique, happy_freq=happy_freq,
unhappy_freq=unhappy_freq, soso_freq=soso_freq, miss_freq=miss_freq)
output.df

[[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] Eror message: not a valid package -- installed < 2.0.0

2009-02-11 Thread Powers, Randall - BLS


> Hello R-help,
> 
> 
> We are running R version 2.6.0 (2007-10-03). I believe that I got it
> from www.sunfreeware.com. A number of the packages that we attempt to
> download from http://www.r-project.org/  give us the error message
> below when we attempt to run them.
> 
> Can anyone tell me what I need to do to gett these packages to run
> properly?
> 
> Thanks,
> 
> RP
> 
> > require("lars")
> Loading required package: lars
> Error in library(package, lib.loc = lib.loc, character.only = TRUE,
> logical.return = TRUE,  : 
>   'lars' is not a valid package -- installed < 2.0.0?
> 
> 
> They also all have this information in common when I run the library
> command (I've added the BOLD for emphasis).
> 
> FinTS   ** No title available (pre-2.0.0 install?) **
> KernSmooth  Functions for kernel smoothing for Wand &
> Jones
> (1995)
> MASSMain Package of Venables and Ripley's MASS
> Matrix  ** No title available (pre-2.0.0 install?) **
> R2HTML  ** No title available (pre-2.0.0 install?) **
> RWinEdt ** No title available (pre-2.0.0 install?) **
> baseThe R Base Package
> bootBootstrap R (S-Plus) Functions (Canty)
> bootstrap   ** No title available (pre-2.0.0 install?) **
> car ** No title available (pre-2.0.0 install?) **
> class   Functions for Classification
> cluster Cluster Analysis Extended Rousseeuw et al.
> codetools   Code Analysis Tools for R
> datasetsThe R Datasets Package
> foreign ** No title available (pre-2.0.0 install?) **
> gplots  ** No title available (pre-2.0.0 install?) **
> grDevices   The R Graphics Devices and Support for Colours
> and Fonts
> graphicsThe R Graphics Package
> gridThe Grid Graphics Package
> lars** No title available (pre-2.0.0 install?) **
> lattice Lattice Graphics
> methods Formal Methods and Classes
> mgcvGAMs with GCV smoothness estimation and GAMMs
> by REML/PQL
> nlmeLinear and Nonlinear Mixed Effects Models
> nnetFeed-forward Neural Networks and Multinomial
> Log-Linear Models
> pastecs ** No title available (pre-2.0.0 install?) **
> pps ** No title available (pre-2.0.0 install?) **
> prettyR ** No title available (pre-2.0.0 install?) **
> rcompgenCompletion generator for R
> rpart   Recursive Partitioning
> sampling** No title available (pre-2.0.0 install?) **
> spatial Functions for Kriging and Point Pattern
> Analysis
> splines Regression Spline Functions and Classes
> stats   The R Stats Package
> stats4  Statistical Functions using S4 Classes
> survey  ** No title available (pre-2.0.0 install?) **
> survivalSurvival analysis, including penalised
> likelihood.
> tcltk   Tcl/Tk Interface

[[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] Strange behaviour of ISOdatetime

2009-02-11 Thread pbarros

Sorry for missing this part of the posting guide.
It was indeed a problem with the locales. I have fixed it now.
Pedro

David Winsemius wrote:
> 
> My guess is that your two machines have different setting for locale.  
> What does this produce on each of them:
> 
> sessionInfo()$locale
> 
> (Note: It would have been part of the information that you were asked  
> to provide per the posting guide.)
> ---
> For questions about unexpected behavior or a possible bug, you should,  
> at a minimum, copy and paste the output from sessionInfo() into your  
> message. When mentioning version numbers, always use the full version  
> number, e.g., `2.6.1', not just `2.6', and also mention the platform  
> (Windows, Linux, MacOS X, with their versions). Other potentially  
> relevant details include the locale (type Sys.getlocale() at the R  
> prompt), and whether you installed a pre-compiled binary version of R  
> or compiled it yourself.
> 
> -- 
> David Winsemius
> 
> 
> On Feb 10, 2009, at 11:31 AM, Pedro de Barros wrote:
> 
>> Hi All,
>>
>> I am watching a strange behaviour of ISOdatetime. In my work  
>> computer, I get NA when I try to do
>> > ISOdatetime(1995,03,26,2,0,0)
>> [1] NA
>>
>> But on other dates and/or times (hour) works OK
>> > ISOdatetime(1995,03,25,2,0,0)
>> [1] "1995-03-25 02:00:00 GMT"
>>
>> In my home computer, I do not have this problem.
>> I am running the same version of R (2.8.1 patched) on both machines,  
>> the same version of Gnu Emacs (22.3.1) and the same version of ESS  
>> (5.3.10). Both are running Windows XP. Has anyone experienced this  
>> before?
>>
>> Pedro
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Strange-behaviour-of-ISOdatetime-tp21937395p21955145.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] amusement

2009-02-11 Thread Ben Bolker
  Browsing Amazon for

Books > Science > Mathematics > Applied > Probability and Statistics > R

()

produces a nice list of R books. Unfortunately, the heading reads:
"Did you mean: sas" ?

  cheers
Ben Bolker

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


Re: [R] plots and text to the same output file

2009-02-11 Thread Greg Snow
odfWeave works just fine for me on windows and the XML package shows up in my 
list of packages.  You may be overthinking the problem, for most of my odfWeave 
projects I don't need odfInsertPlot, just use fig=TRUE in the code chunk and 
only include the code for that 1 plot in that code chunk (a separate chunk for 
each plot) and the inclusion of the plot is taken care of for you (you can do 
fancier things with odfInsertPlot, but probably don't need to most of the time).

Another alternative for creating postscript (which can be converted to pdf if 
that is preferred), but which is much less sophisticated than sweave/odfWeave 
is to look at the etxtStart function in the TeachingDemos package (this 
requires postprocessing with enscript).  This approach is more for getting a 
transcript of an interactive session, for planned analyses use sweave/odfWeave 
instead.

Hope this helps,


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


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
> project.org] On Behalf Of lauramorg...@bluewin.ch
> Sent: Wednesday, February 11, 2009 11:27 AM
> To: r-help@r-project.org
> Subject: [R] plots and text to the same output file
> 
> Hello,
> I would like to save different plots and some text (like summaries,
> AIC, ...) on the same file.
> I've read the e-mails entitled "Output results to a single postscript
> document" written some days ago and I've tried
> to use the function odfInsertPlot() in the package "odfWeave" but it
> doesn't work on my computer (I've seen that
> odfWeave package depends on XML package, which is not available for
> windows...)
> Does somebody know if there is another function or package that could
> help? I would need at least to put all the
> plots on the same file
> ... of course I could copy and paste them by hand but there are tens of
> graphs... :-(
> 
> Thanks!!
> Laura
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Variables captured in closures get copied?

2009-02-11 Thread Wacek Kusnierczyk
Peter Dalgaard wrote:
> Titus von der Malsburg wrote:
>> Hi list!  I have a data frame called fix and a list of index vectors
>> called rois:
>>
>>   > head(rois, 3)
>>   [[1]]
>>   [1] 2 1
>>
>>   [[2]]
>>   [1] 3
>>
>>   [[3]]
>>   [1]  6  7 28 26 27 24 25
>>
>> The part that's causing the issue is the following line:
>>
>>   lapply(rois, function(roi) fix$x[roi] <- 100)
>>
>> So for every index vector I'd like to set the respective entries in the
>> data frame (fix) to 100.
>>
>> I expected the data frame would be changed after lapply but instead it
>> remains unchanged.  I understand that when I pass an argument into a
>> function it gets passed as a value and not as a reference.  But here fix
>> is not an argument but captured in the closure.  Do my questions are:
>> What's going on here and what is the idiomatic way of achieving my goal?
>>
>
> It's a local variable in the function. Not in principle different from
>
> function(roi) { fix <- fix ;  ... }
>
> You could use superassignment (<<-), but a simpler idiom is
>
> for (roi in rois) fix$x[roi] <- 100
>

interesting.  i'm not sure if this is something one should consider
obvious, though it does make sense.
actually, it seems that r gets caught by surprise on such sort of semantics:

d = data,frame(x=1:10^8)
(function() d$x[1] = 0)()

prints 'Error: cannot allocate vector of size 762.9 Mb' and stops
responding with 100% cpu (sometimes even 101, as reported by top, hehe)
occupied by r.

platform   i686-pc-linux-gnu  
arch   i686   
os linux-gnu  
system i686, linux-gnu
status
major  2  
minor  8.0
year   2008   
month  10 
day20 
svn rev46754  
language   R  
version.string R version 2.8.0 (2008-10-20)

vQ

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


[R] extract trend data from stl

2009-02-11 Thread doloop

I am using the stl function to decompose a time series.  I want to access the
trend data hopefully by placing it into a separate vector.  How do I do
that?

Thanks.
-- 
View this message in context: 
http://www.nabble.com/extract-trend-data-from-stl-tp21954844p21954844.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] Problem about SARMA model forcasting

2009-02-11 Thread Saji Ren
Somebody said that ARIMA models like discussed above are easy to implement on a 
spreadsheet.
The prediction formula is simply a linear equation that refers to past values 
of original time series and past values of the errors.
Thus, setting up an spreadsheet by stroing the data in one column, the 
forcasting values computed bu the formula in another column, and the 
errors(data minus forcasts) in the third column can give the results just as 
the same as any statistical computing software(like R).
But I just can't, and I think there must be some mistakes in my procedure but 
just can't find it by myself.
Really need helps!
Thanks again!

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


Re: [R] How to comment in R

2009-02-11 Thread Greg Snow
Stavros,

Thanks for the clarification and going further back in the credit for /* */.  

I don't think that the regex argument is a complete red herring (possibly a 
pink herring or burnt umber herring?).  The post I was responding to said that 
implementing it would be trivial, I think that the fact that Friedl spends 10 
pages discussing it shows that it is less than trivial.  While the parser can 
process the comments without using regular expressions, some of the issues that 
Friedl brings up still need to be considered in deciding the rules.  
Implementing this in the parser may well be trivial once the rules are decided 
on (but way beyond me), but I still think that deciding on the rules and 
documenting them is far from trivial.  

I remember having some C code that compiled fine and did as intended with one 
compiler, then when I tried compiling with a different compiler it threw an 
error based on the commenting (probably the difference was in the 
preprocessors, not the compilers), so the 2 different versions of the C 
compiler/preprocessor did not even agree on the rules (I don't remember emacs 
complaining either way).

Others have mentioned using sed as another way to add/strip comment markers to 
regions of code.  Along these lines someone could always use C-style (or PL/I 
style to be more correct but less common in my experience) comments, then run 
the code through a C preprocessor before submitting to R (then you just have to 
live with the rules of the preprocessor).

I have no problem with someone adding this capability to R, I just prefer that 
R-Core spends their time on higher priority items.  If someone else wants to 
contribute the change, I won't complain (unless it breaks my existing code, 
which is unlikely if done properly), I just wanted anyone who was thinking of 
doing this to think about some of the potential pitfalls so that if they 
implement it, they implement it well.


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


> -Original Message-
> From: macra...@gmail.com [mailto:macra...@gmail.com] On Behalf Of
> Stavros Macrakis
> Sent: Wednesday, February 11, 2009 11:22 AM
> To: Greg Snow
> Cc: waclaw.marcin.kusnierc...@idi.ntnu.no; Stephan Kolassa;
> mihai.mira...@bafin.de; r-help@r-project.org
> Subject: Re: [R] How to comment in R
> 
> On Wed, Feb 11, 2009 at 12:32 PM, Greg Snow 
> wrote:
> > ...The c-style of /* */ allows both types and you can comment out
> part of a line, but it is not simple to match and has its own
> restrictions.  Friedl in his regular expressions book takes 10 pages to
> develop a pattern to match these (and the final pattern is almost 2
> full lines of text in the book).  And this is without allowing
> nesting
> 
> Though there is a real debate about the value of multiline, possibly
> nested, comments, the regular expression argument is a red herring.
> Lexical analysis of multiline comments is a solved problem (and not a
> particularly difficult one!), and matters only to language and editor
> implementors.  Emacs handles them with no problem.
> 
>-s
> 
> PS And to give credit where credit is due (important on this mailing
> list), the /* */ syntax was defined by PL/I; C simply implemented an
> existing convention and popularized it. :-)

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


Re: [R] forestplot

2009-02-11 Thread Marino, Mark
Thanks, I was able to get what I wanted done by modifying the code, but
I will consider writing my own based upon your suggestion.  Mark 


Mark T. Marino, MD
VP, Early Clinical Development
Mannkind Corp.
61 S. Paramus Road
Paramus, NJ 07652
201-983-5238 Office
203-512-4008 Cell
mmar...@mannkindcorp.com


-Original Message-
From: Thomas Lumley [mailto:tlum...@u.washington.edu] 
Sent: Wednesday, February 11, 2009 5:40 AM
To: Marino, Mark
Cc: r-help@r-project.org
Subject: Re: [R] forestplot

On Tue, 10 Feb 2009, Marino, Mark wrote:

> Dear R users,
>
> Is there any way to control the size of the box around the mean when 
> creating a Forest plot using the forestplot function?
>

No. If you want to customize further, you are probably better off
starting with less general code. The basic structure is example 1.8 from
Paul Murrell's book, code at
http://www.stat.auckland.ac.nz/~paul/RGraphics/chapter1.html

  -thomas

Thomas Lumley   Assoc. Professor, Biostatistics
tlum...@u.washington.eduUniversity of Washington, Seattle

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


Re: [R] OT: A test with dependent samples.

2009-02-11 Thread Rolf Turner



Thank you ***VERY*** much.  That clarifies a lot of things which were  
vaguely
knocking around in my mind but about which I could not get my  
thoughts properly

organized.

Thanks again.

cheers,

Rolf Turner

On 11/02/2009, at 11:27 PM,  
Meyners,Michael,LAUSANNE,AppliedMathematics wrote:



Rolf,

as you explicitly asked for a comment on your proposal: It is  
generally
equivalent to McNemar's test and maybe even more appropriate  
because of

the asymptotics involved in the chi-squared distribution, which might
not be too good with n=12. In some more detail:

McNemar's test basically considers the difference between the
off-diagonal elements, normalized by their sum. You do the same,
ignoring all (0,0) and (1,1) pairs (the latter do not occur in your
example anyway). binom.test(12,12,alternative="greater") gives you the
one-sided p-value.

If, however, you do not use the exact binomial distribution (with  
n=12)

but the normal approximation, you find E(X)=6 and VAR(X)=3 with X the
number of sequences (0,1), and you observed x=12. This gives you a
z-score of (12-6)/sqrt(3) and a corresponding one-sided p-value:


pnorm(6/sqrt(3), lower.tail=F)

[1] 0.0002660028

Further, McNemar's test WITHOUT continuity correction gives


mcnemar.test(matrix(c(61,0,12,0),2,2), correct=F)


McNemar's Chi-squared test

data:  matrix(c(61, 0, 12, 0), 2, 2)
McNemar's chi-squared = 12, df = 1, p-value = 0.000532

It comes as no surprise that the reported (two-sided!) p-value is
exactly twice the (one-sided!) p-value from the binomial test with
normal approximation:


pnorm(6/sqrt(3), lower.tail=F)*2

[1] 0.0005320055

I do not want to stress the pros and cons of continuity  
corrections, but
if neglected, you see that you get the same results (except that  
McNemar

is generally two-sided), due to the relation of normal and chi-squared
distribution.

If you use the binomial test, you can forget about asymptotics and
continuity correction, that's why I indeed consider you approach
superior to the chi-squared approximation used in McNemar's test. But
you might fail to find a reference for the exact approach...


You briefly asked in a later mail testing for p=0. Indeed, _any_
incident will disprove this hypothesis, and the p value reported by


binom.test(1,73,p=0)


Exact binomial test

data:  1 and 73
number of successes = 1, number of trials = 73, p-value < 2.2e-16
alternative hypothesis: true probability of success is not equal to 0
95 percent confidence interval:
 0.0003467592 0.0739763232
sample estimates:
probability of success
0.01369863

is not wrong (as R just tells us it is BELOW a certain value), but  
could

be refined by saying "p-value = 0". BTW, I am not sure what
"p-value=TRUE" tells me, as derived from binom.test(0,73,p=0). I
personally don't care about either, as to test H0: p=0, I would not  
use

any software but rather stress some basic statistical theory.


It remains the questions whether McNemar (or your proposal) is  
generally

appropriate here. Like others, I have doubts, except maybe if
observations were made on two subsequent days, on the second of which
the drug was administered. How could you otherwise be sure that the
increase in incidences it not due to the progression of cancer, say,
which would be difficult to rule out. Also, from my experience and in
contrast to you point of view, I'd rather assume it likely that a  
vet is

much more reluctant to apply the new treatment to an already vomitting
cat, your "baseline" with 0 out of 73 at least seems suspicious, and
until proven wrong, I'd take the assumption that this is not by chance
only.
I understand that this is an observational study with no
control/randomization, but concluding a side-effect from a  
statistically
significant change in incidence rates from this study seems  
questionable

to me. What I'd propose (and used in comparable situations) is to
confine yourself on the confidence interval and let the investigator
decide / discuss whether the lower bound of this is higher than  
what she

would expect under control or alternative treatment. She needs to have
some experience, if not historical data, and using a test or just this
confidence interval, you will only get a hint on a possible side- 
effect,
no formal proof (which is always difficult from observational  
studies).

Discussing the CI would seem fairer and even stronger to me then. In
other words: Mathematically, you'll get an appropriate test, while
conceptually, I'm far from being convinced.

Hope this makes sense,
Michael




-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- 
project.org]

On Behalf Of Rolf Turner
Sent: Dienstag, 10. Februar 2009 22:33
To: R-help Forum
Subject: [R] OT: A test with dependent samples.


I am appealing to the general collective wisdom of this list in  
respect

of a statistics (rather than R) question.  This question comes to me
from a friend wh

Re: [R] How to comment in R

2009-02-11 Thread Duncan Murdoch

On 2/11/2009 1:21 PM, Stavros Macrakis wrote:

On Wed, Feb 11, 2009 at 12:32 PM, Greg Snow  wrote:

...The c-style of /* */ allows both types and you can comment out part of a 
line, but it is not simple to match and has its own restrictions.  Friedl in 
his regular expressions book takes 10 pages to develop a pattern to match these 
(and the final pattern is almost 2 full lines of text in the book).  And this 
is without allowing nesting


Though there is a real debate about the value of multiline, possibly
nested, comments, the regular expression argument is a red herring.
Lexical analysis of multiline comments is a solved problem (and not a
particularly difficult one!), and matters only to language and editor
implementors.  Emacs handles them with no problem.


I agree about that.  I think the lack of multiline comments comes from 
design considerations rather than implementation ones.   They're just 
not needed, and having two types of comments would lead to weird 
interactions, e.g. is the block comment closed in the lines below?


  /*
#  */

Duncan Murdoch






   -s

PS And to give credit where credit is due (important on this mailing
list), the /* */ syntax was defined by PL/I; C simply implemented an
existing convention and popularized it. :-)

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


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


[R] How to apply table() on subdata and stack outputs

2009-02-11 Thread Sean Zhang
Dear R helpers:

I am a R novice and have a question about using table() to extract
frequences over many sub-datasets.
A small example input dataframe and wanted output dataframe are provided
below. The real data is very large so a for loop is what I try to avoid.

Can someone englithen me how to use sapply or the like to achieve it?

Many thanks in advance!

-Sean

#example input dataframe
id <- c('tom', 'tom', 'tom', 'jack', 'jack', 'jack', 'jack')
var_interest <- c("happy","unhappy", "", "happy", "unhappy", 'soso','happy')
input.df <- data.frame(id=id, var_interest=var_interest)
input.df
wanted.df <-

#output dataframe I want
id_unique <- c('tom','jack')
happy_freq<-c(1,2)
unhappy_freq<-c(1,1)
soso_freq<-c(0,1)
miss_freq<-c(1,0)
output.df <-data.frame(id_unique=id_unique, happy_freq=happy_freq,
unhappy_freq=unhappy_freq, soso_freq=soso_freq, miss_freq=miss_freq)
output.df

[[alternative HTML version deleted]]

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


Re: [R] How to handle large numbers?

2009-02-11 Thread Stavros Macrakis
On Wed, Feb 11, 2009 at 6:20 AM, Robin Hankin  wrote:
>> library(Brobdingnag)
>> exp(1000)/(exp(1007)+5)
> [1] NaN
>
>> as.numeric(exp(as.brob(1000))/(exp(as.brob(1007))+5))
> [1] 0.000911882

Though brob is certainly useful in many cases, it can't substitute for
thinking about numeric issues (roundoff, cancellation, overflow,
underflow) in general.

For example:

> x<-40; log(exp(x)+1)-x
[1] 0
> x<-as.brob(40); log(exp(x)+1)-x
[1] -exp(-Inf)

The correct answer is about 4e-18.  Perhaps Ryacas or some other tool
gets this right, but in general I don't think it's wise to abdicate
responsibility to one's tools. Though numerical analysis is a field in
itself, I think it's worthwhile to learn the basics.

   -s

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] plots and text to the same output file

2009-02-11 Thread lauramorg...@bluewin.ch
Hello,
I would like to save different plots and some text (like summaries, AIC, ...) 
on the same file. 
I've read the e-mails entitled "Output results to a single postscript document" 
written some days ago and I've tried 
to use the function odfInsertPlot() in the package "odfWeave" but it doesn't 
work on my computer (I've seen that 
odfWeave package depends on XML package, which is not available for windows...)
Does somebody know if there is another function or package that could help? I 
would need at least to put all the 
plots on the same file
... of course I could copy and paste them by hand but there are tens of 
graphs... :-(

Thanks!!
Laura

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


Re: [R] bar plot/ histogram

2009-02-11 Thread Marc Schwartz
on 02/11/2009 12:10 PM phoebe kong wrote:
> Hi all,
> 
> I would like to construct plot of the distribution of N, where N range
> from 1 to 10. I couldn't just use the hist(), as I want the categories
> for the bars are: 1, 2, 3, 4, >=5. So this will be a bar plot with 5
> bars, and the height of the bar will be the frequency of N. (eg bar#1
> will be the frequency of N=1, bar #2 will be frequency of N=2, and
> bar#5 will be the frequency of N>=5).
> 
> Thanks in advance for your help!
> 
> SY

You can use cut() to break up your data into the desired groupings and
then use barplot().

set.seed(1)

data <- sample(10, 100, replace = TRUE)

> table(data)
data
 1  2  3  4  5  6  7  8  9 10
 7  6 11 14 14  5 11 15 11  6

> cut(data, breaks = c(0:4, Inf), labels = c(1:4, ">=5"))
  [1] 3   4   >=5 >=5 3   >=5 >=5 >=5 >=5 1   3   2   >=5 4   >=5 >=5
 [17] >=5 >=5 4   >=5 >=5 3   >=5 2   3   4   1   4   >=5 4   >=5 >=5
 [33] >=5 2   >=5 >=5 >=5 2   >=5 >=5 >=5 >=5 >=5 >=5 >=5 >=5 1   >=5
 [49] >=5 >=5 >=5 >=5 >=5 3   1   1   4   >=5 >=5 >=5 >=5 3   >=5 4
 [65] >=5 3   >=5 >=5 1   >=5 4   >=5 4   4   >=5 >=5 >=5 4   >=5 >=5
 [81] >=5 >=5 4   4   >=5 3   >=5 2   3   2   3   1   >=5 >=5 >=5 >=5
 [97] >=5 >=5 >=5 >=5
Levels: 1 2 3 4 >=5

> table(cut(data, breaks = c(0:4, Inf), labels = c(1:4, ">=5")))

  1   2   3   4 >=5
  7   6  11  14  62


barplot(table(cut(data, breaks = c(0:4, Inf), labels = c(1:4, ">=5"


See ?cut for more information.

HTH,

Marc Schwartz

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


Re: [R] How to comment in R

2009-02-11 Thread Stavros Macrakis
On Wed, Feb 11, 2009 at 12:32 PM, Greg Snow  wrote:
> ...The c-style of /* */ allows both types and you can comment out part of a 
> line, but it is not simple to match and has its own restrictions.  Friedl in 
> his regular expressions book takes 10 pages to develop a pattern to match 
> these (and the final pattern is almost 2 full lines of text in the book).  
> And this is without allowing nesting

Though there is a real debate about the value of multiline, possibly
nested, comments, the regular expression argument is a red herring.
Lexical analysis of multiline comments is a solved problem (and not a
particularly difficult one!), and matters only to language and editor
implementors.  Emacs handles them with no problem.

   -s

PS And to give credit where credit is due (important on this mailing
list), the /* */ syntax was defined by PL/I; C simply implemented an
existing convention and popularized it. :-)

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


[R] bar plot/ histogram

2009-02-11 Thread phoebe kong
Hi all,

I would like to construct plot of the distribution of N, where N range
from 1 to 10. I couldn't just use the hist(), as I want the categories
for the bars are: 1, 2, 3, 4, >=5. So this will be a bar plot with 5
bars, and the height of the bar will be the frequency of N. (eg bar#1
will be the frequency of N=1, bar #2 will be frequency of N=2, and
bar#5 will be the frequency of N>=5).

Thanks in advance for your help!

SY

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


Re: [R] summary statistics

2009-02-11 Thread phoebe kong
Thanks a bunch! They all are helpful :)

On 2/10/09, Jim Lemon  wrote:
> William Revelle wrote:
>> At 6:41 PM -0500 2/9/09, David Winsemius wrote:
>>> describe() in Hmisc provides much of the rest of what you asked for:
>>>
  describe(pref900$TCHDL)
>>> pref900$TCHDL
>>>   n missing  uniqueMean .05 .10 .25 .50
>>> .75 .90 .95
>>>  9061904469   16051   4.123   2.320   2.557   3.061   3.841
>>> 4.886   6.054   6.867
>>>
>>> lowest :  0.9342  1.0200  1.0522  1.1008  1.1061, highest: 19.8696
>>> 20.1667 20.7619 21.6364 21.7200
>>>
>>
>> As does describe in the psych package
>>
>> describe(sat.act)
>>>  describe(sat.act)
>>   var   n   mean sd median trimmedmad min max range
>> skew kurtosis   se
>> gender  1 700   1.65   0.48  21.68   0.00   1   2 1
>> -0.61-1.62 0.02
>> education   2 700   3.16   1.43  33.31   1.48   0   5 5
>> -0.68-0.07 0.05
>> age 3 700  25.59   9.50 22   23.86   5.93  13  6552
>> 1.64 2.42 0.36
>> ACT 4 700  28.55   4.82 29   28.84   4.45   3  3633
>> -0.66 0.53 0.18
>> SATV5 700 612.23 112.90620  619.45 118.61 200 800   600
>> -0.64 0.33 4.27
>> SATQ6 687 610.22 115.64620  617.25 118.61 200 800   600
>> -0.59-0.02 4.41
>>
>> see also describe.by to break this down by some grouping variable.
>>
>> Bill
>>
>>
>>
>>
>>> On Feb 9, 2009, at 6:04 PM, phoebe kong wrote:
>>>
 Hi all,

 I'm wondering if there is a function that can return summary
 statistics:
 N=total number of observation, # missing, mean, median, range, standard
 deviation.

 As I know, summary() returns some of info I've mentioned above.

 Thanks,
 SY

>
> and if you want to roll your own descriptive stats, the describe
> function in the prettyR package (confusing, isn't it?)
>
> Jim
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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   >