Re: [R] Tunnelling X for R graphics

2009-02-02 Thread Prof Brian Ripley
To answer your basic question, you do need to shut down everything 
involivng X, that is X11() devices and the X11 dataeditor.  If you do 
that (and graphics.off() will suffice for the first), you should be 
able to re-open an X11 device on another display (which is what 
presumably a new VNC connection gives you).


The warning comes from any X erorr, and it is not possible to know how 
serious it is without external information.


On Mon, 2 Feb 2009, Adam D. I. Kramer wrote:



On Tue, 3 Feb 2009, Patrick Connolly wrote:


The problem, and maybe I'm just whining here, is that because the
data sets are large this takes several minutes where I'm basically just
sitting around.  This happens once every other day as the VPN software
I'm using "times out" after about 24 hours and thus the ssh session dies.


Is it possible to do anything about the VPN software?  I use tightVNC to
do something similar and it doesn't time out after 24 hours.  Even closing
the desktop machine down altogether does not lose the ssh connexion. 
Restarting the desktop a week later will still find the X session without

loss.


The VPN software is managed and maintained by the company I'm doing
statistical computing work for...out of my control. Your comments about
TightVNC are pretty impressive, though--I'm not really sure how that would
work...though if you set your ssh connection to not push any data towards
your computer, I gather the server would have no reason to believe you were
unresponsive?

In any case, this sadly doesn't help me, but many thanks!

For now, I'm just trying my hardest to remeber to dev.off() when I'm done
using graphics.

--Adam

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

2009-02-02 Thread Prof Brian Ripley

If I do this on the top-level directry of a package, I get

tystie% R CMD Rd2dvi --pdf RODBC
Hmm ... looks like a package
...

and it does so by looking for a 'foo/DESCRIPTION' file, and it does 
give an index.


I think you probably do need to update your R, as in < 2.8.1 if there 
was a problem with latex-ing, it gave no indication and no index.


I believe CRAN uses the manual produced by R CMD check, which uses 
pkg2tex.pl if there is a latex directory in the built package.


On Tue, 3 Feb 2009, Rolf Turner wrote:



When I create a manual for a package that I create and use locally,
e.g. via

R CMD Rd2dvi --pdf foo

where ``foo'' is the name of the directory containing the source for
the package (also named ``foo'') the resulting manual does not appear
to have an index.

The package.pdf files appearing on CRAN all seem to have indices.  What must
I do to get an index appended to the package?  Is there some modification
needed to the ``R CMD Rd2dvi'' incantation, or do I need to proceed in
a different manner entirely?  I looked for an answer in ``Writing R 
Extensions''

but could not see one.

I also notice an unimportant but mysterious difference in the manual titles.
The manuals I produce locally (via R CMD Rd2dvi --pdf foo) have titles of
the form `` Package `foo' ''.  Those on CRAN seem to have titles of the
from `` The foo Package''.  What induces this difference?

cheers,

Rolf Turner

P. S.: In case it's of any consequence, my session info is:

R version 2.8.0 (2008-10-20)
i386-apple-darwin8.11.1

locale:
C

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

other attached packages:
[1] misc_0.0-11fortunes_1.3-5 MASS_7.2-44


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


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


[R] Using getSymbols

2009-02-02 Thread Shruthi Jayaram

Hi, 

How can one ask getSymbols to obtain data within a specified time interval?
For example, if I am downloading US PPI data:

usppi <- as.zoo(getSymbols("PPIACO", src="FRED", verbose=TRUE,
auto.assign=FALSE))

How do I ask getSymbols to truncate starting from Jan-1970 until present? I
looked up the help file but couldn't find anything. 

Another newbie question, can I specify the frequency of the data I want from
FRED? The USPPI data above gives me monthly data, is there a way I can ask
to obtain annual data?

Thanks very much, I'd be grateful for any help on this. 

Shruthi
-- 
View this message in context: 
http://www.nabble.com/Using-getSymbols-tp21803950p21803950.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] Deploying a R model on a cloud computer using PMML

2009-02-02 Thread Ajay ohri
Dear List,
Please find an interview from Michael Zeller ,CEO, Zementis. Mike talks
about how to use an existing model ( created in R) , using PMML as an
intermediate for exporting the model, and deploying it on a cloud computer
for as low as 1 $ per hour.

Regards,

Ajay

*Ajay-* *What are the traditional rivals to scoring solutions offered by
you. How does ADAPA compare to each of them. Case Study- Assume I have 5
leads daily on a Car buying website. How would ADAPA help me in scoring the
model ( created say by KXEN or , R or,SAS, or SPSS).What would my
approximate cost advantages be if I intend to mail say the top 5 deciles
everyday.*

*Michael-* Some of the traditional scoring solutions used today are based on
SAS, in-database scoring like Oracle, MS SQL Server, or very often even
custom code.  ADAPA is able to import the models from all tools that support
the PMML standard, so any of the above tools, open source or commercial,
could serve as an excellent development environment.

The key differentiators for ADAPA are simple and focus on cost-effective
deployment:

1) Open Standards - PMML & SOA:

Freedom to select best-of-breed development tools without being locked into
a specific vendor;  integrate easily with other systems.

2) SaaS-based Cloud Computing:

Delivers a quantum leap in cost-effectiveness without compromising on
scalability.

In your example, I assume that you'd be able to score your 50,000 leads in
one hour using one ADAPA engine on Amazon.  Therefore, you could choose to
either spend US$100,000 or more on hardware, software, maintenance, IT
services, etc., write a project proposal, get it approved by management, and
be ready to score your model in 6-12 months…

OR, you could use ADAPA at something around US$1-$2 per day for the scenario
above and get started today!  To get my point across here, I am of course
simplifying the scenario a little bit, but ...

http://www.decisionstats.com/2009/02/interview-michael-zeller-ceozementis/


Read more at www.decisionstats.com ( and if server is slow..it will be slow
:( ) read it in www.smartdatacollective.com

Note-Decision Stats is a non commercial ,non sponsored, non advertising
site, and platform agnostic.

[[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] Lattice histogram with vertical lines

2009-02-02 Thread David Scott


I would like to add some vertical lines to a lattice plot of histograms. 
What I am after is a lattice version of abline(v = 1234). The lattice 
histogram plot is just:


histogram( ~ LTSE | approach, data = arrivals)

Can anyone point me in the right direction for this?

David Scott

_
David Scott Department of Statistics
The University of Auckland, PB 92019
Auckland 1142,NEW ZEALAND
Phone: +64 9 373 7599 ext 85055 Fax: +64 9 373 7018
Email:  d.sc...@auckland.ac.nz

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

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


[R] reading .odf spreadsheet into R

2009-02-02 Thread stephen sefick
I have searched the archives and I did not find the answer to my
question.  Is there a way to read in a .odf spreadsheet without
modification to a .csv file.  I am analyzing my classes scores on
their first exam, and would like to read the grade book in without
converting it to .csv.
thanks

-- 
Stephen Sefick

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

-K. Mullis

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


Re: [R] Matrix

2009-02-02 Thread Shruthi Jayaram
Thanks this is very helpful.
Shruthi


On Tue, Feb 3, 2009 at 1:36 AM, Gabor Grothendieck
wrote:

> Sorry, there was an error. Try this:
>
> x <- matrix(1:4, 2)
> y <- 10 * x
> matrix(t(cbind(x, y)), nc = 2, byrow = TRUE)
>
>
> On Mon, Feb 2, 2009 at 12:32 PM, Gabor Grothendieck
>  wrote:
> > Try this:
> >
> > matrix(rbind(x, y), nc = 2, byrow = TRUE)
> >
> >
> > On Mon, Feb 2, 2009 at 10:52 AM, Shruthi Jayaram
> >  wrote:
> >>
> >> Hi,
> >>
> >> I have a very basic question on merging two matrices by alternating the
> >> rows. For illustration, assume two matrices -
> >>
> >> A looks like:
> >>
> >> 10 10
> >> 10 10
> >>
> >> B looks like:
> >>
> >> 20 20
> >> 20 20
> >>
> >> How do I combine them such that I get alternating rows from A and B? My
> >> final result should be C which looks like:
> >>
> >> 10 10
> >> 20 20
> >> 10 10
> >> 20 20
> >>
> >> Thanks very much, and I am sorry for such a newbie question.
> >>
> >> Shruthi
> >> --
> >> View this message in context:
> http://www.nabble.com/Matrix-tp21792064p21792064.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.
> >>
> >
>

[[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] Package manuals.

2009-02-02 Thread Rolf Turner


When I create a manual for a package that I create and use locally,
e.g. via

R CMD Rd2dvi --pdf foo

where ``foo'' is the name of the directory containing the source for
the package (also named ``foo'') the resulting manual does not appear
to have an index.

The package.pdf files appearing on CRAN all seem to have indices.   
What must
I do to get an index appended to the package?  Is there some  
modification

needed to the ``R CMD Rd2dvi'' incantation, or do I need to proceed in
a different manner entirely?  I looked for an answer in ``Writing R  
Extensions''

but could not see one.

I also notice an unimportant but mysterious difference in the manual  
titles.
The manuals I produce locally (via R CMD Rd2dvi --pdf foo) have  
titles of

the form `` Package `foo' ''.  Those on CRAN seem to have titles of the
from `` The foo Package''.  What induces this difference?

cheers,

Rolf Turner

P. S.: In case it's of any consequence, my session info is:

R version 2.8.0 (2008-10-20)
i386-apple-darwin8.11.1

locale:
C

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

other attached packages:
[1] misc_0.0-11fortunes_1.3-5 MASS_7.2-44


##
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] overlapping bars on "dodge" ggplot histogram - can it be fixed?

2009-02-02 Thread hadley wickham
Hi Jason,

I can't see anyway to do this completely within in ggplot.  And it's
not easy to do the data processing yourself.  Here's one attempt that
almost works:

counts <- ddply(VADeaths_flat_df, .(round_any(Data, 20), Person), nrow)
names(counts) <- c("bin", "person", "n")

qplot(bin, n, data = counts, fill = person, geom="bar", stat
="identity", position="dodge")

Or maybe:

counts <- ddply(VADeaths_flat_df, .(cut(Data,
breaks=fullseq(range(Data), 20)), Person), nrow)
names(counts) <- c("bin", "person", "n")

qplot(person, n, data = counts, fill = person, geom="bar", stat
="identity", width = 0.9) +
  facet_grid(. ~ bin) +
  opts(axis.text.x = theme_text(angle = 45, hjust = 1, colour = "grey60"))

Hadley

On Mon, Feb 2, 2009 at 8:32 PM, Jason Rupert  wrote:
> Using the following code to have a little separation between the individual
> bins:
>
> VADeaths_flat_df = stack(as.data.frame(VADeaths))
> names(VADeaths_flat_df) = c('Data','Person')
> ggplot(VADeaths_flat_df, aes(Data, fill = Person)) +
> geom_bar(position=position_dodge(width =(15)), binwidth=20)
>
> The result shows the bars overlapping.
>
> Is there any way to fix it by reducing the bar sizes?
>
> Thanks again.
>
> --- On Mon, 2/2/09, hadley wickham  wrote:
>
> From: hadley wickham 
> Subject: Re: [R] Broke ggplot...
> To: jasonkrup...@yahoo.com
> Cc: R-help@r-project.org
> Date: Monday, February 2, 2009, 5:49 PM
>
> On Mon, Feb 2, 2009 at 5:41 PM, Jason
>  Rupert 
> wrote:
>> It appears I broke ggplot in my script, but that maybe it is because the
> caffeine has worn off or maybe it is late in the day.   I thought I was
> beginning to understand ggplot, but I have encountered a silly little issue.
>>
>> For some reason the following does not produce a histogram with fill due
> to the Person's characteristics:
>> (Note that VADeaths_flat_df$Data works fine...)
>>
>>
>> VADeaths_df<-data.frame(VADeaths)
> ...
>
> You can do this a bit more easily with:
>
> VADeaths_flat_df <- melt(VADeaths)
> names(VADeaths_flat_df) <- c("Age", "Person",
> "Data")
>
>> bin_size<-15.0
>> ggplot(VADeaths_flat_df, aes(x = factor(Data), fill = factor(Person))) +
> geom_bar(position=position_dodge(width =(20)), binwidth=20)
>> # or
>> ggplot(VADeaths_flat_df, aes(x=factor(Data)))
>  +
> geom_histogram(binwidth=20)
>
> Those plots look fine to me (well they're what I'd expect from the
> definition), but I'd think you'd want
>
> ggplot(VADeaths_flat_df, aes(Data, fill = Person)) +
>   geom_histogram(binwidth=20)
>
> or maybe
>
> ggplot(VADeaths_flat_df, aes(Person, weight = Data)) + geom_bar()
> ggplot(VADeaths_flat_df, aes(Person, weight = Data, fill = Age)) +
> geom_bar()
>
> Hadley
>
> --
> http://had.co.nz/
>
>



-- 
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] Difference between a[[i]] and a[i]

2009-02-02 Thread Rolf Turner


On 3/02/2009, at 12:45 PM, David Epstein wrote:



I'm sure I've read about the difference between a[[i]] and a[i] in  
R, but I
cannot recall what I read. Even more disturbing is the fact that I  
don't
know how to search the newsgroup for this. All the different  
combinations I

tried were declared not to be valid search syntax.


Essentially: a is a list; a[i] is a list of length 1 whose sole entry is
the i-th entry of a; a[[i]]] is the i-th entry of a.  If you are of a
mathematical bent it may be illuminating to think of this as being  
analogous
to, say, {3} being a subset of the set {1,2,3,4,5} and 3 being an  
element

of this set.

1. What sort of object can the operators [] and [[]] be applied to?  
How do
they differ? I mean objects in standard R, not in packages that  
provide

conceivable overloading of these operators (if that's possible).


Essentially lists.  Note that any vector can be considered to be a list.
Note that data frames are lists.

2. Meta-question: how could one search for an answer to this  
question in the

newsgroup?


RSiteSearch("[") or RSiteSearch("[[")

3. Meta-question: how could one search for an answer to this in the  
FAQ?


Doesn't seem to be there, AFAICS.

4. Meta-question: how could one search for an answer to this in any  
of the

links one is shown after typing help.start()?


Click on ``Search Engine and Keywords''; then search on ``[[''.  Then
click on ``Extract''.  This last is less than totally perspicuous. ;-)

Instead of trying to follow these links, just do

?"[" or ?"[["

HTH.

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.


[R] overlapping bars on "dodge" ggplot histogram - can it be fixed?

2009-02-02 Thread Jason Rupert
Using the following code to have a little separation between the individual 
bins:

VADeaths_flat_df = stack(as.data.frame(VADeaths))
names(VADeaths_flat_df) = c('Data','Person')
ggplot(VADeaths_flat_df, aes(Data, fill = Person)) + 
geom_bar(position=position_dodge(width =(15)), binwidth=20)

The result shows the bars overlapping.  

Is there any way to fix it by reducing the bar sizes? 

Thanks again. 

--- On Mon, 2/2/09, hadley wickham  wrote:
From: hadley wickham 
Subject: Re: [R] Broke ggplot...
To: jasonkrup...@yahoo.com
Cc: R-help@r-project.org
Date: Monday, February 2, 2009, 5:49 PM

On Mon, Feb 2, 2009 at 5:41 PM, Jason Rupert 
wrote:
> It appears I broke ggplot in my script, but that maybe it is because the
caffeine has worn off or maybe it is late in the day.   I thought I was
beginning to understand ggplot, but I have encountered a silly little issue.
>
> For some reason the following does not produce a histogram with fill due
to the Person's characteristics:
> (Note that VADeaths_flat_df$Data works fine...)
>
>
> VADeaths_df<-data.frame(VADeaths)
...

You can do this a bit more easily with:

VADeaths_flat_df <- melt(VADeaths)
names(VADeaths_flat_df) <- c("Age", "Person",
"Data")

> bin_size<-15.0
> ggplot(VADeaths_flat_df, aes(x = factor(Data), fill = factor(Person))) +
geom_bar(position=position_dodge(width =(20)), binwidth=20)
> # or
> ggplot(VADeaths_flat_df, aes(x=factor(Data))) +
geom_histogram(binwidth=20)

Those plots look fine to me (well they're what I'd expect from the
definition), but I'd think you'd want

ggplot(VADeaths_flat_df, aes(Data, fill = Person)) +
  geom_histogram(binwidth=20)

or maybe

ggplot(VADeaths_flat_df, aes(Person, weight = Data)) + geom_bar()
ggplot(VADeaths_flat_df, aes(Person, weight = Data, fill = Age)) + geom_bar()

Hadley

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



  
[[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] pairs() help - colour histograms on diagonal

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

I'd like to be able to colour histograms along the diagonal using the colours
stored in colnames(d):

> d
 blackbluebrowncyan
1   0.96405751 -0.02964390 -0.060147424 -0.06460070
2  -0.03614607  0.95475444 -0.152382053 -0.07767974
3  -0.07095613 -0.05884884 -0.061289399 -0.06445973
4  -0.03708223 -0.05997624 -0.054044275 -0.08291373
5  -0.08877190 -0.07193658 -0.078598617 -0.08892916
6  -0.09294377 -0.05563854 -0.051405213 -0.08442332
7  -0.08431200 -0.01657793 -0.119773022 -0.07364633
8  -0.06105875 -0.05311773 -0.062928495 -0.06982507
9  -0.05757523 -0.02589045 -0.102312333 -0.05616588
10 -0.05092343 -0.03935830 -0.062069716 -0.05402492
11 -0.08057353 -0.12690058 -0.004248301 -0.06850326
12 -0.08052613 -0.04962747 -0.098955086 -0.06496541
13 -0.07901151 -0.07587651 -0.077401999  0.96525294
14 -0.07187448 -0.15431262  0.952982852 -0.06471004
15 -0.07230232 -0.13704876  0.032573081 -0.05040565


panel.hist <- function(x, ...) {
# get some graphical parameter settings, and reset them on exit
usr <- par("usr")
on.exit(par(usr))

par(usr = c(usr[1:2], 0, 1.5) )

# get a histogram of the data, but don't plot it - we just need to get 
some
info from the histogram
h <- hist(x, plot = FALSE)
breaks <- h$breaks
nB <- length(breaks)
y <- h$counts; y <- y/max(y)

rect(breaks[-nB], 0, breaks[-1], y, ...)
}

pairs(d, upper.panel=panel.smooth, diag.panel=panel.hist)

So I'd like the top-left histogram on the diagonal to be coloured black, then
the next one on the diagonal to be coloured blue etc. Is this possible?

Cheers,
Nathan

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

iEYEARECAAYFAkmHovYACgkQ9gTv6QYzVL5bUgCgw3EHQKS9WjO2AmtEks6x0Bh9
FLgAoIFpikJ903quFBaxQe5UVXAAbrnq
=XRan
-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] Boxplots by variable

2009-02-02 Thread Adam D. I. Kramer

Does boxplot(as.data.frame(final)) do what you want?

--Adam

On Mon, 2 Feb 2009, Vemuri, Aparna wrote:


Dear R users,

I have a matrix "final" which looks like this:

final
oSO4   oNO3   mSO4   mNO3
[1,]  3.3728 0.2110  1.9517421 1.01883602
[2,]  0.8249 0.0697  1.5970292 0.11368781
[3,]  0.2636 0.1004  0.6012445 0.24356332
[4,]  8.0072 0.3443  6.1016998 3.63207149
[5,] 13.5079 0.6593 12.4011068 1.55323386
[6,]  6.1293 0.1989  5.7620926 0.12884845
[7,]  0.6004 0.0661  0.7375408 0.17218600
[8,]  0.6912 0.1672  1.1563314 0.13469750
[9,]  1.0478 0.1504  1.5637809 0.99000758
[10,]  0.4825 0.1160  0.2297545 0.08121805

I would like to create boxplots for this matrix with data binned by
oNO3, oSO4, mNO3 and mSO4, all in the same plot.

I tried
boxplot(final), boxplot(final[,1]) etc. But all those commands create
individual plots and not what I am trying to achieve. I was wondering if
there is an R equivalent of the matlab command "hold on" or if there is
a simpler way around this.



[[alternative HTML version deleted]]

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



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


Re: [R] Boxplots by variable

2009-02-02 Thread Felipe Carrillo
Hi Vemuri:
is this what you want?

x <-  "oSO4   oNO3   mSO4   mNO3
3.3728 0.2110  1.9517421 1.01883602
0.8249 0.0697  1.5970292 0.11368781
0.2636 0.1004  0.6012445 0.24356332
8.0072 0.3443  6.1016998 3.63207149
13.5079 0.6593 12.4011068 1.55323386
6.1293 0.1989  5.7620926 0.12884845
0.6004 0.0661  0.7375408 0.17218600
0.6912 0.1672  1.1563314 0.13469750
1.0478 0.1504  1.5637809 0.99000758
0.4825 0.1160  0.2297545 0.08121805"
df <- read.table(textConnection(x),header=T)
attach(df)
df <- data.frame(oSO4,oNO3,mSO4,mNO3)
df
boxplot(df,col="limegreen")
# Or with ggplot2
library(ggplot2)
x <- melt(df)
x
boxPlots <- 
qplot(factor(variable),value,data=x,geom="boxplot",colour=I("magenta"),fill=I("lightgoldenrod"))
boxPlots


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


--- On Mon, 2/2/09, Vemuri, Aparna  wrote:

> From: Vemuri, Aparna 
> Subject: [R] Boxplots by variable
> To: r-help@r-project.org
> Date: Monday, February 2, 2009, 4:19 PM
> Dear R users,
> 
> I have a matrix "final" which looks like this:
> 
> final
>  oSO4   oNO3   mSO4   mNO3
>  [1,]  3.3728 0.2110  1.9517421 1.01883602
>  [2,]  0.8249 0.0697  1.5970292 0.11368781
>  [3,]  0.2636 0.1004  0.6012445 0.24356332
>  [4,]  8.0072 0.3443  6.1016998 3.63207149
>  [5,] 13.5079 0.6593 12.4011068 1.55323386
>  [6,]  6.1293 0.1989  5.7620926 0.12884845
>  [7,]  0.6004 0.0661  0.7375408 0.17218600
>  [8,]  0.6912 0.1672  1.1563314 0.13469750
>  [9,]  1.0478 0.1504  1.5637809 0.99000758
> [10,]  0.4825 0.1160  0.2297545 0.08121805
> 
> I would like to create boxplots for this matrix with data
> binned by
> oNO3, oSO4, mNO3 and mSO4, all in the same plot. 
> 
> I tried 
> boxplot(final), boxplot(final[,1]) etc. But all those
> commands create
> individual plots and not what I am trying to achieve. I was
> wondering if
> there is an R equivalent of the matlab command "hold
> on" or if there is
> a simpler way around this.
> 
> 
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained,
> reproducible code.

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


Re: [R] Boxplots by variable

2009-02-02 Thread Mike Lawrence
Check out ggplot2:
http://had.co.nz/ggplot2

Particularly:
http://had.co.nz/ggplot2/geom_boxplot.html

Looks like you'll have to melt your data to long format first though,
here's a tutorial:
http://www.statmethods.net/management/reshape.html

On Mon, Feb 2, 2009 at 8:19 PM, Vemuri, Aparna  wrote:
> Dear R users,
>
> I have a matrix "final" which looks like this:
>
> final
> oSO4   oNO3   mSO4   mNO3
>  [1,]  3.3728 0.2110  1.9517421 1.01883602
>  [2,]  0.8249 0.0697  1.5970292 0.11368781
>  [3,]  0.2636 0.1004  0.6012445 0.24356332
>  [4,]  8.0072 0.3443  6.1016998 3.63207149
>  [5,] 13.5079 0.6593 12.4011068 1.55323386
>  [6,]  6.1293 0.1989  5.7620926 0.12884845
>  [7,]  0.6004 0.0661  0.7375408 0.17218600
>  [8,]  0.6912 0.1672  1.1563314 0.13469750
>  [9,]  1.0478 0.1504  1.5637809 0.99000758
> [10,]  0.4825 0.1160  0.2297545 0.08121805
>
> I would like to create boxplots for this matrix with data binned by
> oNO3, oSO4, mNO3 and mSO4, all in the same plot.
>
> I tried
> boxplot(final), boxplot(final[,1]) etc. But all those commands create
> individual plots and not what I am trying to achieve. I was wondering if
> there is an R equivalent of the matlab command "hold on" or if there is
> a simpler way around this.
>
>
>
>[[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.
>



-- 
Mike Lawrence
Graduate Student
Department of Psychology
Dalhousie University
www.thatmike.com

Looking to arrange a meeting? Check my public calendar:
http://www.thatmike.com/mikes-public-calendar

~ Certainty is folly... I think. ~

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


Re: [R] Difference between a[[i]] and a[i]

2009-02-02 Thread Duncan Murdoch

On 02/02/2009 6:45 PM, David Epstein wrote:

I'm sure I've read about the difference between a[[i]] and a[i] in R, but I
cannot recall what I read. Even more disturbing is the fact that I don't
know how to search the newsgroup for this. All the different combinations I
tried were declared not to be valid search syntax.

1. What sort of object can the operators [] and [[]] be applied to? How do
they differ? I mean objects in standard R, not in packages that provide
conceivable overloading of these operators (if that's possible).


They both apply to vectors.  [] gives you a subset of the vector, [[]] 
gives you an element.  (For most vectors an element is returned as a 
subset of length 1, but for a list object, the element is different from 
a list containing it.)



2. Meta-question: how could one search for an answer to this question in the
newsgroup?
3. Meta-question: how could one search for an answer to this in the FAQ?
4. Meta-question: how could one search for an answer to this in any of the
links one is shown after typing help.start()?


You forgot to ask:  which manual describes this?  (The Intro to R, the R 
Language Definition both do.)


You could also try help("[[") for some useful info.

Duncan Murdoch


Thanks for any help.
David


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

2009-02-02 Thread Vemuri, Aparna
Dear R users,

I have a matrix "final" which looks like this:

final
 oSO4   oNO3   mSO4   mNO3
 [1,]  3.3728 0.2110  1.9517421 1.01883602
 [2,]  0.8249 0.0697  1.5970292 0.11368781
 [3,]  0.2636 0.1004  0.6012445 0.24356332
 [4,]  8.0072 0.3443  6.1016998 3.63207149
 [5,] 13.5079 0.6593 12.4011068 1.55323386
 [6,]  6.1293 0.1989  5.7620926 0.12884845
 [7,]  0.6004 0.0661  0.7375408 0.17218600
 [8,]  0.6912 0.1672  1.1563314 0.13469750
 [9,]  1.0478 0.1504  1.5637809 0.99000758
[10,]  0.4825 0.1160  0.2297545 0.08121805

I would like to create boxplots for this matrix with data binned by
oNO3, oSO4, mNO3 and mSO4, all in the same plot. 

I tried 
boxplot(final), boxplot(final[,1]) etc. But all those commands create
individual plots and not what I am trying to achieve. I was wondering if
there is an R equivalent of the matlab command "hold on" or if there is
a simpler way around this.



[[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] executing R batch files

2009-02-02 Thread Gabor Grothendieck
Without the actual VBA commands you are using we
can't be sure but if you are using Shell then it requires an exe,
not a bat file.  Try
   cmd.exe /c RBatch.bat
so that it has an exe file to execute.

On Mon, Feb 2, 2009 at 6:42 PM,   wrote:
> The following command, issued from the DOS command prompt (running Windows
> XP), produces the intended result of a .csv file created by program.R:
>
> ?c:\program files\R\R-2.8.0\bin\Rterm.exe? --save < "c:\TEMP\program.R"
>
> However, when I create a file called Rbatch.bat that contains exactly the
> line above, and try to execute it (by double clicking or via the Shell
> command
> in an Excel macro), nothing happens.
>
> Does anyone have an explanation, or any suggestions as to how to run an R
> program from within an Excel macro? (PS: I know about RExcel, can't quite
> get it to install
> correctly.)
>
> Much appreciated.
>
>
>
> Joe Boyer
> Statistical Sciences
> Renaissance Bldg 510, 3233-D
> Mail Stop RN0320
> 8-275-3661
> cell: (610) 209-8531
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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


Re: [R] Broke ggplot...

2009-02-02 Thread hadley wickham
On Mon, Feb 2, 2009 at 5:41 PM, Jason Rupert  wrote:
> It appears I broke ggplot in my script, but that maybe it is because the 
> caffeine has worn off or maybe it is late in the day.   I thought I was 
> beginning to understand ggplot, but I have encountered a silly little issue.
>
> For some reason the following does not produce a histogram with fill due to 
> the Person's characteristics:
> (Note that VADeaths_flat_df$Data works fine...)
>
>
> VADeaths_df<-data.frame(VADeaths)
...

You can do this a bit more easily with:

VADeaths_flat_df <- melt(VADeaths)
names(VADeaths_flat_df) <- c("Age", "Person", "Data")

> bin_size<-15.0
> ggplot(VADeaths_flat_df, aes(x = factor(Data), fill = factor(Person))) + 
> geom_bar(position=position_dodge(width =(20)), binwidth=20)
> # or
> ggplot(VADeaths_flat_df, aes(x=factor(Data))) + geom_histogram(binwidth=20)

Those plots look fine to me (well they're what I'd expect from the
definition), but I'd think you'd want

ggplot(VADeaths_flat_df, aes(Data, fill = Person)) +
  geom_histogram(binwidth=20)

or maybe

ggplot(VADeaths_flat_df, aes(Person, weight = Data)) + geom_bar()
ggplot(VADeaths_flat_df, aes(Person, weight = Data, fill = Age)) + geom_bar()

Hadley

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

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


[R] Difference between a[[i]] and a[i]

2009-02-02 Thread David Epstein

I'm sure I've read about the difference between a[[i]] and a[i] in R, but I
cannot recall what I read. Even more disturbing is the fact that I don't
know how to search the newsgroup for this. All the different combinations I
tried were declared not to be valid search syntax.

1. What sort of object can the operators [] and [[]] be applied to? How do
they differ? I mean objects in standard R, not in packages that provide
conceivable overloading of these operators (if that's possible).
2. Meta-question: how could one search for an answer to this question in the
newsgroup?
3. Meta-question: how could one search for an answer to this in the FAQ?
4. Meta-question: how could one search for an answer to this in any of the
links one is shown after typing help.start()?

Thanks for any help.
David
-- 
View this message in context: 
http://www.nabble.com/Difference-between-a--i---and-a-i--tp21801145p21801145.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] executing R batch files

2009-02-02 Thread joseph . g . boyer
The following command, issued from the DOS command prompt (running Windows 
XP), produces the intended result of a .csv file created by program.R:

?c:\program files\R\R-2.8.0\bin\Rterm.exe? --save < "c:\TEMP\program.R"

However, when I create a file called Rbatch.bat that contains exactly the 
line above, and try to execute it (by double clicking or via the Shell 
command
in an Excel macro), nothing happens.

Does anyone have an explanation, or any suggestions as to how to run an R 
program from within an Excel macro? (PS: I know about RExcel, can't quite 
get it to install
correctly.)

Much appreciated.



Joe Boyer
Statistical Sciences 
Renaissance Bldg 510, 3233-D
Mail Stop RN0320
8-275-3661
cell: (610) 209-8531
[[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] Broke ggplot...

2009-02-02 Thread Jason Rupert
It appears I broke ggplot in my script, but that maybe it is because the 
caffeine has worn off or maybe it is late in the day.   I thought I was 
beginning to understand ggplot, but I have encountered a silly little issue. 
 
For some reason the following does not produce a histogram with fill due to the 
Person's characteristics: 
(Note that VADeaths_flat_df$Data works fine...)
 
 
VADeaths_df<-data.frame(VADeaths)
VADeaths_flat_tmp1<-data.frame(Data=as.numeric(as.character(VADeaths_df$Rural.Male)),
 Person="Rural.Male")
VADeaths_flat_tmp2<-data.frame(Data=as.numeric(as.character(VADeaths_df$Rural.Female)),
 Person="Rural.Female")
VADeaths_flat_tmp3<-data.frame(Data=as.numeric(as.character(VADeaths_df$Urban.Male)),
 Person="Urban.Male")
VADeaths_flat_tmp4<-data.frame(Data=as.numeric(as.character(VADeaths_df$Urban.Female)),
 Person="Urban.Female")

VADeaths_flat_df<-rbind(VADeaths_flat_tmp1, VADeaths_flat_tmp2)
VADeaths_flat_df<-rbind(VADeaths_flat_df, VADeaths_flat_tmp3)
VADeaths_flat_df<-rbind(VADeaths_flat_df, VADeaths_flat_tmp4)
bin_size<-15.0
ggplot(VADeaths_flat_df, aes(x = factor(Data), fill = factor(Person))) + 
geom_bar(position=position_dodge(width =(20)), binwidth=20)
# or 
ggplot(VADeaths_flat_df, aes(x=factor(Data))) + geom_histogram(binwidth=20)  
 
Thanks again for any feedback you provide. 


  
[[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] New to R

2009-02-02 Thread Gabor Grothendieck
Also you don't need return since it automatically returns the value produced by
the last statement that it executes.

On Mon, Feb 2, 2009 at 3:44 PM, Greg Snow  wrote:
> It is not transposing (it just looks that way).  The first result is a vector 
> which is 1 dimensional, but is neither a row or a column.  The printed 
> version of it looks like a row, because that is a more compact 
> representation.  If you sample enough points you will see it wrap around and 
> be represented as several rows.  If it printed as a single column, then the 
> first values would scroll off the screen with only a moderate number of 
> values.
>
> The replicate function then takes these vectors and combines them into a 
> matrix and just happens to use each vector as a column of the new matrix, 
> this is standard, matrices by default are filled by column, look at the 
> output of as.matrix( sample( 6, 4, replace=TRUE ) ) and you will see your 
> vector converted to a matrix of 1 column.  It could have been done the other 
> way, but way back the decision was made to do it this way and there are 
> probably a lot of things that would break if it were changed now, so we get 
> to live with it.  A single call to 't' is not too much effort to get what we 
> expect.
>
> So in short, a vector is neither a column or a row, but prints as a row for 
> practical reasons, and is converted to a column by default if made into a 
> matrix.
>
> 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 Joe Hughes
>> Sent: Monday, February 02, 2009 1:09 PM
>> To: R help
>> Subject: Re: [R] New to R
>>
>> All,
>>
>>   Thanks for taking the time to reply.  I understand a bit more
>> about R
>> and the R way then I did before.The final function looks like this:
>>
>> ###
>> ###
>> #
>> # Input:
>> #   die_size - 4, 6, 8, 10, 20
>> #   number_of_dice - How many dice to roll
>> #   number_of_rolls - How many times to roll the dice
>> #
>> # Output:
>> #The array holding the results of the rolls
>> #
>> ###
>> ###
>> #
>> function(die_size, number_of_dice, number_of_rolls=1)
>> {
>>   return(t(replicate(number_of_rolls, sample(die_size,
>> number_of_dice,
>> replace=TRUE
>> }
>>
>> Before I take a look at the teaching demos, I have one question left.
>>
>> Here is a sequence of commands and the output
>>
>>  > sample(6, 4, replace=TRUE)
>> [1] 3  4  5  4
>>  > replicate(7, sample(6, 4, replace=TRUE))
>>   [,1] [,2] [,3] [,4] [,5] [,6] [,7]
>> [1,]3364566
>> [2,]4465516
>> [3,]5145656
>> [4,]4631122
>>
>> Why does replicate transpose the vector before assigning it to the
>> array?  The way I would output it would be this
>>
>>   [,1] [,2] [,3] [,4]
>> [1,]3454
>> [2,]3416
>> [3,]6643
>> [4,]4551
>> [5,]5561
>> [6,]6152
>> [7,]6662
>>
>> Thanks,
>> Joe
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-
>> guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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


Re: [R] Upgrading to TINN - R 2.1.1.6

2009-02-02 Thread Felipe Carrillo
Hi Steve:
I upgraded to the same Tinn-R version a few days ago and I didn't have any 
problems at all. Just follow the link below for the instructions. Good luck

http://sourceforge.net/forum/forum.php?forum_id=864071

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


--- On Mon, 2/2/09, steve_fried...@nps.gov  wrote:

> From: steve_fried...@nps.gov 
> Subject: [R] Upgrading to TINN - R 2.1.1.6
> To: r-help@r-project.org
> Date: Monday, February 2, 2009, 1:02 PM
> I know this has been addressed before, but I'm still
> confused by the
> solution.
> 
> When running TINN - R (ver 2.1.1.6) with R (2.8.0)  I have
> lost the
> functionality of TINN-R
> 
> It returns an error
> 
> source(.trPaths[5], echo=TRUE, max.deparse.length=150)
> 
> 
> I modified the RProfile.site file as follows:
> 
> options(pager="interal")
> .trPaths=c(
> 
> 'C:/Documents and Settings/username/Application
> Data/Tinn-R/tmp/',
>   'C:/Documents and Settings/username/Application
> Data/Tinn-R/tmp/search.txt',
>   'C:/Documents and Settings/username/Application
> Data/Tinn-R/tmp/objects.txt',
>   'C:/Documents and Settings/username/Application
> Data/Tinn-R/tmp/file.r',
>   'C:/Documents and Settings/username/Application
> Data/Tinn-R/tmp/selection.r',
>   'C:/Documents and Settings/username/Application
> Data/Tinn-R/tmp/block.r',
>   'C:/Documents and Settings/username/Application
> Data/Tinn-R/tmp/lines.r')
> 
> what am I missing ?
> 
> Thanks in advance.
> 
> 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-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] sem package and AMOS

2009-02-02 Thread John Fox
Dear Anthony,

sem() does FIML estimation, not 2SLS, and so it's hard to understand
why you're getting "nearly identical" parameter estimates but very
different coefficient standard errors and model chi-squares. In fact,
unless the problem is very ill-conditioned, the parameter estimates
should be the same within rounding error, as should the model
chi-square. There is some room for small differences in the standard
errors -- sem() uses a numerical Hessian and I'm not sure what AMOS
does -- but large differences are indicative of some problem. 

I suspect that you're not fitting quite the same model in sem() and
AMOS.

I hope this helps,
 John

On Mon, 02 Feb 2009 14:50:26 -0600
 Anthony Dick  wrote:
> Hello-
> 
> I am using R to build my initial models, but need to use AMOS to
> compare the models of two groups (adults vs. kids). The problem is I
> am getting different results with R and AMOS for the initial models
> of the separate groups (and the R results make more sense).
> 
> The parameter estimates (path coefficients and variances) from both
> programs are nearly identical, but the model chi-squares (and
> significance estimates of the parameter estimates) are different. I
> am using Maximum Likelihood in AMOS. R I think defaults to
> two-stage-least squares estimate, and AMOS 16 does not implement
> 2SLS.
> 
> I am using fMRI data, so the error variances are likely correlated,
> and the data non-normal to varying degrees. Is 2SLS the better way to
> go for these kinds of data?
> 
> Is there a way to change the default method for R sem? I couldn't
> find this in the ?help. I note I have run some of the AMOS examples
> in R and have gotten identical results across platforms, so I believe
> the problem is not in specifying things incorrectly across platforms.
> Also, the dfs are identical for both analyses. I must use AMOS to do
> model comparison (and thus maximum likelihood), but would like to
> achieve similar results across platforms for the basic models before
> I proceed, and would like to track down the reason for the
> difference.
> 
> Thanks,
> 
> Anthony
> 
> -- 
> Anthony Steven Dick, Ph.D.
> Post-Doctoral Fellow
> Human Neuroscience Laboratory
> Department of Neurology
> The University of Chicago
> 5841 S. Maryland Ave. MC-2030
> Chicago, IL 60637
> Phone: (773)-834-7770
> Email: ad...@uchicago.edu
> Web: http://home.uchicago.edu/~adick/
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.


John Fox, Professor
Department of Sociology
McMaster University
Hamilton, Ontario, Canada
http://socserv.mcmaster.ca/jfox/

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


Re: [R] Selectively Removing objects

2009-02-02 Thread Carl Witthoft

Slightly related to this (I think Mr. Rydevik's code solved the question),
is a silly thing I wrote up one weekend.  It started out as a clone of 
the unix  "rm -i" command, and kept on going out of control :-)


I'm not claiming this is clean, or the best way to do this, but it does 
let you apply a wide variety of functions to your collection of 'items'


Carl

-
askrm<-function(items,fn="rm",ask=TRUE){
killed<-NA
thecall<-vector('list')
j<-1

for (thenam in c(items)){
if(ask==TRUE){
prmpt<-paste("Do ",fn," on ",thenam,"? ")
readline(prompt=prmpt)->theans
}
else theans="y"
if(theans=="y"){

#have to get to parent envir. to find the object of interest
#as.name() gets rid of quotes...
# paste() dumps all output into a single element of list
# Note that,e.g., str() returns nothing, just cats to screen.
eval(call(fn,as.name(thenam)),envir=parent.frame(1))->evout
paste(evout,collapse=" ")->thecall[j]
cat("the result is ", as.character(thecall[j]),'\n')
killed[j]<-thenam
j<-j+1
}

}
 #keeping track of what happened
 outs<-list(killed=killed, calls=thecall)
 return(invisible(outs))
 }

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


Re: [R] Assigning colnames in loop

2009-02-02 Thread Sundar Dorai-Raj
It's always best to do this with list operations (e.g. lapply) rather
than a loop:

DF1 <- split(DF, DF$male)
DF2 <- lapply(DF1, function(x) {
  x2 <- t(as.matrix(x[3:5], dimnames = list(levels(x$age), NULL)))
  as.data.frame(x2)
})

Then DF2[["0"]] and DF2[["1"]] are the data.frames you want.

HTH,

--sundar

On Mon, Feb 2, 2009 at 2:30 PM, Peter Jepsen  wrote:
> Dear R-listers,
>
> I am trying to assign colnames to a data frame within a loop, but I keep
> getting a "target of assignment expands to non-language object"-error. I
> need to split up a large dataset into about 20 smaller ones, and I would
> like to assign colnames within the loop, so I won't have to type the
> same thing 20 times over.
>
> I have concocted this really goofy example which constructs two
> datasets:
>
> -
> male <- rep(0:1, each=5)
> age <- factor(c(10:14,10:14))
> DF <- data.frame(male, age, res1=rnorm(10), res2=rnorm(10),
> res3=rnorm(10))
>
> for(n in 0:1) {
>assign(paste("test",n, sep="."), as.data.frame(t(subset(DF,
> male==n, select=c(res1, res2, res3)
>colnames(get(paste("test",n, sep="."))) <-
> paste("age",levels(age), "m", n, sep="") # This line gives an error.
>assign(colnames(paste("test",n, sep="."))) <-
> paste("age",levels(age), "m", n, sep="") # This line gives the same
> error.
> }
> ---
> The following command assigns the right colnames to the 'test.0' data
> frame, but I want this line inside the loop so I won't have to type it
> 20 times over.
> colnames(test.0) <- paste("age",levels(age), "m", 0, sep="")
>
>
> Thank you in advance for any assistance.
> Peter.
>
>> sessionInfo()
> R version 2.8.1 (2008-12-22)
> i386-pc-mingw32
>
> locale:
> LC_COLLATE=Danish_Denmark.1252;LC_CTYPE=Danish_Denmark.1252;LC_MONETARY=
> Danish_Denmark.1252;LC_NUMERIC=C;LC_TIME=Danish_Denmark.1252
>
> attached base packages:
> [1] tools stats graphics  grDevices utils datasets  methods
> base
>
> other attached packages:
> [1] epiR_0.9-14 maptools_0.7-18 sp_0.9-29   foreign_0.8-30
> chron_2.3-28
>
> loaded via a namespace (and not attached):
> [1] grid_2.8.1  lattice_0.17-20
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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

2009-02-02 Thread Peter Jepsen
Dear R-listers,

I am trying to assign colnames to a data frame within a loop, but I keep
getting a "target of assignment expands to non-language object"-error. I
need to split up a large dataset into about 20 smaller ones, and I would
like to assign colnames within the loop, so I won't have to type the
same thing 20 times over.

I have concocted this really goofy example which constructs two
datasets:

-
male <- rep(0:1, each=5)
age <- factor(c(10:14,10:14))
DF <- data.frame(male, age, res1=rnorm(10), res2=rnorm(10),
res3=rnorm(10))

for(n in 0:1) {
assign(paste("test",n, sep="."), as.data.frame(t(subset(DF,
male==n, select=c(res1, res2, res3)
colnames(get(paste("test",n, sep="."))) <-
paste("age",levels(age), "m", n, sep="") # This line gives an error.
assign(colnames(paste("test",n, sep="."))) <-
paste("age",levels(age), "m", n, sep="") # This line gives the same
error.
}
---
The following command assigns the right colnames to the 'test.0' data
frame, but I want this line inside the loop so I won't have to type it
20 times over. 
colnames(test.0) <- paste("age",levels(age), "m", 0, sep="") 


Thank you in advance for any assistance.
Peter.

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

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

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

other attached packages:
[1] epiR_0.9-14 maptools_0.7-18 sp_0.9-29   foreign_0.8-30
chron_2.3-28   

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

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


[R] repeated measures with gls

2009-02-02 Thread Celina Zabaloy
I am using the gls function of the nlme package to analyze data sets of 
soil respiration which have the following design: 3 complete blocks x 5 
sampling dates (time from fertilization) x 3 fertilization levels. The 
fertilization dates are equal for all subjects (blocks) but not 
periodical (-46, 10, 24, 53, 123 days from the event).

The code that I've been using is:
fit.csnC<- gls(dno.C ~ block+Fertil*factor(Samp), data=dDakot, 
method="ML", corr=corCompSymm(, form=~1|block))


fit.arhnC<-update(fit.csnC, corr=corAR1(, form=~1|block), 
weight=varIdent(form =~1|Samp))

I've plotted the model with :
plot(fit.csnC)
plot(fit.csnC,dno.C ~ fitted(.), abline = c(0,1))
and residuals look fine, same as observed vs. fitted values.
I would like to make sure that the model specification and the gls 
function are correct for this design. Then, if the model is OK, how do I 
do to test for main and simple effects, ie. how can I apply contrasts to 
the model?


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


Re: [R] Specifying the gap between "dodge'd" bins groups?

2009-02-02 Thread hadley wickham
> However, is there a way to programmatically to extract the bin size that
> ggplot selected in order to be able to change this for multiple data sets?

Well the default is 30 bins - i.e. range(x) / 30 - in practice you'd
want to choose something a bit more informative!

> Similarly, is there a way to determine the number of count in each bin that
> ggplot establish?  I wanted to change the axis a bit based on the count
> size, but I needed to do it programmatically give the large number of
> samples.
>
> For the example below, it would be something like the following:
> ggplot(diamonds, aes(x=price, fill=cut)) +
> geom_bar(position=position_dodge(width=default_ggplotbinwidth*0.75),
> binwidth=default_ggplotbinwidth) + ylim(0, ggplotmaxcount*1.1)
> I would like to have access to the calculated ggplotbin and ggplotmaxcount
> for the data set.

Just set binwidth yourself.  And why do you want ggplotmaxcount?  (it
would be round_any(max(df$x), binwidth, ceiling))

Hadley


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

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


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

2009-02-02 Thread Wacek Kusnierczyk
Rolf Turner wrote:
>
> On 3/02/2009, at 9:59 AM, Wacek Kusnierczyk wrote:
>
>> Rolf Turner wrote:
>>>
>>> On 2/02/2009, at 4:29 PM, Murray Cooper wrote:
>>>
 I was about to post a similar reply.
 Stavros's reply was very eloquent and should be taken to heart!
>>>
>>>
>>> I would just like to say that in my very humble opinion Stavros's
>>> reply was utter nonsense.  It was the sort of excuse-making favoured
>>> by tyrants since time immemorial.
>>
>> the troll has been fed.  imho, your responses are more often than not
>> patronizing puffery from a narcissistic self-admirer.  following your
>> posts, virtually anyone who's not on the r team is an idiot.  sigh.
>
> I shall not feed the troll any further.

you'll become extinct, then.  good choice.


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] all data frame columns SUBSET

2009-02-02 Thread Hamid Hamid
Dear All,
I have a data frame (mydata), with let say 5 columns V1,V2,...,V5.
(we know the power set of {V1,V2,..,V5} has  2^5-1 elements). I need
to construct a vector T of length 5 which its i-th element is  the
maximum of (let say) mean values obtained based on the columns subset
of size i. (MY FUNCTION TO APPLY ON COLUMNS SUBSET IS NOT SO SIMPLE AS
MEAN AND  I WILL REPLACE IT.)

I mean:

T[1]=max(mean(mydata[,1]),...,mean(mydata[,5]))
T[2]=max(mean(mydata[,c(1,2)],mean(mydata[,c(1,3)],...,mean(mydata[,c(1,5])
T[3]=max(mean(mydata[,c(1,2,3)],mean(mydata[,c(1,2,4)],...,mean(mydata[,c(3,4,5)])

T[5]=max(mean(mydata[,c(1,2,3,4,5)]

Many thanks in advance.

Hamid

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


[R] Using Information from the Stats4 package in base envir

2009-02-02 Thread lindsey

Hi.  Thank you very much in advance for your help.

I have generated data from two simple linear models and used k-means  
clustering (stats4) to identify two clusters in the generated data.


Next, I would like to do simple linear regression for each separate  
cluster.  I can do this if I first use the cluster labels to define  
two separate data frames with the subset function.


However, I would ideally like to use the subset option in lm to  
identify the data for regression rather than creating separate data  
frames.  When I try to do it this way, I get the error, "Error in  
eval(expr, envir, enclos) : invalid 'envir' argument".  The code for  
this is given below.


If is is not possible to do this as an option within lm, is there  
another way rather than creating new data frames that are defined by a  
given cluster label?



Thanks again for your help.



library(stats4)

#Define the Models
#Two simple linear models:
#Model A: respA = a0 + a1x + e(a), e(a) ~N(0, sigma^2(a))
#Model B: respB = b0 + b1x + e(b), e(b) ~N(0, sigma^2(b))

a0= 0; a1 = 1.5; sigmaA=4; b0=50; b1=-2; sigmaB=4; n=250; min=0; max=50;

#Generate Data from the Models

x1 = runif(n, min, max); #Explanatory variable
eA = rnorm(n, 0, sigmaA);   eB = rnorm(n, 0, sigmaB);
respA = a0 +a1*x1 + eA; respB = b0 +b1*x1 + eB; #Responses


#K-Means Clustering

resp1 = c(respA, respB);#Put response into single vector for k-means
x12 = rep(x1,nummod);   #Put explanatory into a single vector
data1 = data.frame(resp1, x12) #Data frame for kmeans
cluster1 = kmeans(data1, 2, nstart=25)$cluster #Obtain cluster labels
data1 = data.frame(data1 ,cluster1)#Cluster labels in third column
data10 = subset(data1, cluster1==1)
data11 = subset(data1, cluster1==2)

model10 = lm(resp1 ~ x12, data10)#It works using the subset data frame

model1 = lm(resp1 ~ x12, cluster1 == 1, data1); #Gives the following error

Error in eval(expr, envir, enclos) : invalid 'envir' argument

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


On 3/02/2009, at 9:59 AM, Wacek Kusnierczyk wrote:


Rolf Turner wrote:


On 2/02/2009, at 4:29 PM, Murray Cooper wrote:


I was about to post a similar reply.
Stavros's reply was very eloquent and should be taken to heart!



I would just like to say that in my very humble opinion Stavros's
reply was utter nonsense.  It was the sort of excuse-making favoured
by tyrants since time immemorial.


the troll has been fed.  imho, your responses are more often than not
patronizing puffery from a narcissistic self-admirer.  following your
posts, virtually anyone who's not on the r team is an idiot.  sigh.


I shall not feed the troll any further.

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.


[R] Upgrading to TINN - R 2.1.1.6

2009-02-02 Thread Steve_Friedman

I know this has been addressed before, but I'm still confused by the
solution.

When running TINN - R (ver 2.1.1.6) with R (2.8.0)  I have lost the
functionality of TINN-R

It returns an error

source(.trPaths[5], echo=TRUE, max.deparse.length=150)


I modified the RProfile.site file as follows:

options(pager="interal")
.trPaths=c(

'C:/Documents and Settings/username/Application Data/Tinn-R/tmp/',
  'C:/Documents and Settings/username/Application
Data/Tinn-R/tmp/search.txt',
  'C:/Documents and Settings/username/Application
Data/Tinn-R/tmp/objects.txt',
  'C:/Documents and Settings/username/Application Data/Tinn-R/tmp/file.r',
  'C:/Documents and Settings/username/Application
Data/Tinn-R/tmp/selection.r',
  'C:/Documents and Settings/username/Application Data/Tinn-R/tmp/block.r',
  'C:/Documents and Settings/username/Application Data/Tinn-R/tmp/lines.r')

what am I missing ?

Thanks in advance.

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-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Problems in Recommending R

2009-02-02 Thread Adam D. I. Kramer


On Tue, 3 Feb 2009, Rolf Turner wrote:


I think the R website is just fine as it is.  Effort should be put into
content and not into cosmetics.  Those (potential) users who would be
likely to be influenced by such trivialities as the appearance of the web
page are unlikely to be the sort of people who would use R anyway.


I respectfully disagree. In my repeated experience, I have seen colleagues
in industry and university simply write R off as "too difficult" or "not
worth the effort" based on purely cosmetic grounds, and then at my urging
and after some instruction embrace R as being a fantastic piece of software.

The reality of the situation is that before you read a book, you only have
its cover to judge. Suggesting that people should read every book regardless
of the cover does not make sense for people who have other things to do.

In the ecological context of open-source software, the "cover" or cosmetics
of a software program, its documentation, and its support structure are
actually quite correlated with overall ease of use, and if functionality is
modeled as the factorial interaction of "information produced" with "the
amount of time it takes to produce the information," then functionality
correlates with ease of use, and so the appearance of the webpage is not a
"triviality."

Cordially,
--
Adam D. I. Kramer
Ph.D. Student, Social Psychology
University of Oregon

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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-02 Thread Wacek Kusnierczyk
Rolf Turner wrote:
>
> On 2/02/2009, at 4:29 PM, Murray Cooper wrote:
>
>> I was about to post a similar reply.
>> Stavros's reply was very eloquent and should be taken to heart!
>
>
> I would just like to say that in my very humble opinion Stavros's
> reply was utter nonsense.  It was the sort of excuse-making favoured
> by tyrants since time immemorial.

the troll has been fed.  imho, your responses are more often than not
patronizing puffery from a narcissistic self-admirer.  following your
posts, virtually anyone who's not on the r team is an idiot.  sigh.

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] Sweave

2009-02-02 Thread Kjetil Halvorsen
I'm trying to (re)learn Sweave and run into some problems. I use now ubuntu
(8.10), emacs + ess.
Slowly getting upto speed on ess. I have a complete (hopefully) .Rnw  file,
but the resulting .tex
will not compile. The file does not contain anything exotic, but it produces
pdf figures, and that
is where the problems come:

 library(tools)
> Sweave("varioCoo.Rnw")
Writing to file varioCoo.tex
Processing code chunks ...
 1 : echo term verbatim (label=read)
Loading required package: coda
...
.
.
You can now run LaTeX on 'varioCoo.tex'
Warning messages:
 ... don think this are important
> texi2dvi("varioCoo.tex", pdf=T)
Error in texi2dvi("varioCoo.tex", pdf = T) :
  Running 'texi2dvi' on 'varioCoo.tex' failed.
LaTeX errors:
! You can't use `macro parameter character #' in horizontal mode.
 ... sys...@active\string "\endcsname ##

l.111  bubble(NURE.orig, "ppm", col = c("#
  00ff0088", "#00ff0088"))
! You can't use `macro parameter character #' in horizontal mode.
 ... sys...@active\string "\endcsname ##

l.111 ...NURE.orig, "ppm", col = c("#00ff0088", "#
  00ff0088"))
!pdfTeX error: pdflatex (file ./varioCoo-fig2.pdf): PDF inclusion: required pag
e does not exist <0>
 ==> Fatal error occurred, no output PDF file produced!
> Sweave("varioCoo.Rnw")
Writing to file varioCoo.tex
Processing code chunks ...
 1 : echo term verbatim (label=read)
 2 : echo term verbatim (label=prep1)
 3 : echo term verbatim (label=prep2)
 4 : echo term verbatim eps pdf (label=fig2)
 5 : echo term verbatim eps pdf (label=fig3)
 6 : echo term verbatim eps pdf (label=fig4)

You can now run LaTeX on 'varioCoo.tex'
Warning message:
In readLines(f[1]) : incomplete final line found on 'varioCoo.Rnw'
> texi2dvi("varioCoo.tex", pdf=T)
Error in texi2dvi("varioCoo.tex", pdf = T) :
  Running 'texi2dvi' on 'varioCoo.tex' failed.
LaTeX errors:
! You can't use `macro parameter character #' in horizontal mode.
 ... sys...@active\string "\endcsname ##

l.102  bubble(NURE.orig, "ppm", col = c("#
  00ff0088", "#00ff0088"))
! You can't use `macro parameter character #' in horizontal mode.
 ... sys...@active\string "\endcsname ##

l.102 ...NURE.orig, "ppm", col = c("#00ff0088", "#
  00ff0088"))
!pdfTeX error: pdflatex (file ./varioCoo-fig2.pdf): PDF inclusion: required pag

  ---: well, list.files() say that file exists.

e does not exist <0>
 ==> Fatal error occurred, no output PDF file produced!
>

The other problem refered to above comes from this source lines:

\begin{figure}
  \centering
  <>=
 bubble(NURE.orig, "ppm", col = c("#00ff0088", "#00ff0088"))
@
\caption{Contenido de uranio (ppm)}

???

Kjetil
\end{figure}

[[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] all subset of a data frame column

2009-02-02 Thread Hamid Hamid
Dear All,
I have a data frame (mydata), with let say 5 columns V1,V2,...,V5.
(we know the power set of {V1,V2,..,V5} has  2^5-1 elements). I need
to construct a vector T of length 5 which its i-th element is  the
maximum of (let say) mean values obtained based on the columns subset
of size i.

I mean:

T[1]=max(mean(mydata[,1]),...,mean(mydata[,5]))
T[2]=max(mean(mydata[,c(1,2)],mean(mydata[,c(1,3)],...,mean(mydata[,c(1,5])
T[3]=max(mean(mydata[,c(1,2,3)],mean(mydata[,c(1,2,4)],...,mean(mydata[,c(3,4,5)])

T[5]=max(mean(mydata[,c(1,2,3,4,5)]

Many thanks in advance.

Hamid

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


Re: [R] xyplot with lowess curves

2009-02-02 Thread Hutchinson,David [PYR]
Sundar,

That is exactly what I was hoping for. 

Thanks for your help!

Dave

-Original Message-
From: Sundar Dorai-Raj [mailto:sdorai...@gmail.com] 
Sent: Monday, February 02, 2009 12:47 PM
To: Hutchinson,David [PYR]
Cc: r-help@r-project.org
Subject: Re: [R] xyplot with lowess curves

Does this do what you want? The "panel" argument has the custom pane
function I referred to before.

Col <- c("red", "green", "blue", "purple") xyplot (  SnowLineElevation ~
Year | Model,  data = d,  panel = function(x, y, col, ...) {
   Col <- Col[panel.number()]
   panel.xyplot(x, y, col = "blue", ...)
   panel.loess(x, y, col = Col)
 },
 ylim = c(0,100),
 type = c('p','smooth'),
 col = 'blue',
 pch = 21,
 xlab = 'Year',
 ylab = 'Snowline Elevation [m]'
)

On Mon, Feb 2, 2009 at 12:18 PM, Hutchinson,David [PYR]
 wrote:
> I haven't had much luck with a custom panel function; mainly because I

> don't truly understand how to embedd the functionality into the xyplot

> command.
>
> Here's a reproducible example if you can help out.
>
> Thanks,
> Dave
>
> library (lattice)
>
> d <- NULL
> models <- c('A','B','C','D')
> n = 100
> for (i in seq(along = models)){
>  d <- rbind(
>d, data.frame (
>  Model = models[i],
>  Year = seq(1960, length.out=n, by = 1),
>  SnowLineElevation = runif(n, 0, 100)
>)
>  )
> }
>
> xyplot (
>  SnowLineElevation ~ Year | Model,
>  data = d,
>  ylim = c(0,100),
>  type = c('p','smooth'),
>  col = 'blue',
>  pch = 21,
>  xlab = 'Year',
>  ylab = 'Snowline Elevation [m]'
> )
>
> -Original Message-
> From: Sundar Dorai-Raj [mailto:sdorai...@gmail.com]
> Sent: Monday, February 02, 2009 11:43 AM
> To: Hutchinson,David [PYR]
> Cc: r-help@r-project.org
> Subject: Re: [R] xyplot with lowess curves
>
> You'll need a custom panel function. It would also help if you 
> provided a reproducible example:
>
> xyplot (
>  SnowLineElevation ~ Year | Model,
>  data = data,
>  panel = function(x, y, col, ...) {
>col <- ifelse(panel.number() == 1, "red", "green")
>panel.xyplot(x, y, col = "blue", ...)
>panel.loess(x, y, col = col)
>  },
>  ylim = c(0,1800),
>  pch = 21,
>  xlab = 'Year',
>  ylab = 'Snowline Elevation [m]'
> )
>
> Alternatively, you can use the group argument in conjunction with the
> panels:
>
> xyplot(SnowLineElevation ~ Year | Model, data, groups = Model, type = 
> c("p", "smooth"))
>
> if you want the points and the lines to be the same color.
>
> --sundar
>
> On Mon, Feb 2, 2009 at 10:20 AM, Hutchinson,David [PYR] 
>  wrote:
>> I am trying to change the attributes of the lowess lines fit to an 
>> xyplot command, but have been unsuccessful in my search of the online

>> help. Right now, both the points and lowess line come out in the same

>> color (blue). I am unsure how I can change the properties of the 
>> lowess line separately.
>>
>> xyplot (
>>  SnowLineElevation ~ Year | Model,
>>  data = data,
>>  ylim = c(0,1800),
>>  type = c('p','smooth'),
>>  col = 'blue',
>>  pch = 21,
>>  xlab = 'Year',
>>  ylab = 'Snowline Elevation [m]'
>> )
>>
>> Any help would be much appreciated,
>>
>> Dave
>>
>>[[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] sem package and AMOS

2009-02-02 Thread Anthony Dick

Hello-

I am using R to build my initial models, but need to use AMOS to compare 
the models of two groups (adults vs. kids). The problem is I am getting 
different results with R and AMOS for the initial models of the separate 
groups (and the R results make more sense).


The parameter estimates (path coefficients and variances) from both 
programs are nearly identical, but the model chi-squares (and 
significance estimates of the parameter estimates) are different. I am 
using Maximum Likelihood in AMOS. R I think defaults to two-stage-least 
squares estimate, and AMOS 16 does not implement 2SLS.


I am using fMRI data, so the error variances are likely correlated, and 
the data non-normal to varying degrees. Is 2SLS the better way to go for 
these kinds of data?


Is there a way to change the default method for R sem? I couldn't find 
this in the ?help. I note I have run some of the AMOS examples in R and 
have gotten identical results across platforms, so I believe the problem 
is not in specifying things incorrectly across platforms. Also, the dfs 
are identical for both analyses. I must use AMOS to do model comparison 
(and thus maximum likelihood), but would like to achieve similar results 
across platforms for the basic models before I proceed, and would like 
to track down the reason for the difference.


Thanks,

Anthony

--
Anthony Steven Dick, Ph.D.
Post-Doctoral Fellow
Human Neuroscience Laboratory
Department of Neurology
The University of Chicago
5841 S. Maryland Ave. MC-2030
Chicago, IL 60637
Phone: (773)-834-7770
Email: ad...@uchicago.edu
Web: http://home.uchicago.edu/~adick/

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


Re: [R] xyplot with lowess curves

2009-02-02 Thread Sundar Dorai-Raj
Does this do what you want? The "panel" argument has the custom pane
function I referred to before.

Col <- c("red", "green", "blue", "purple")
xyplot (
 SnowLineElevation ~ Year | Model,
 data = d,
 panel = function(x, y, col, ...) {
   Col <- Col[panel.number()]
   panel.xyplot(x, y, col = "blue", ...)
   panel.loess(x, y, col = Col)
 },
 ylim = c(0,100),
 type = c('p','smooth'),
 col = 'blue',
 pch = 21,
 xlab = 'Year',
 ylab = 'Snowline Elevation [m]'
)

On Mon, Feb 2, 2009 at 12:18 PM, Hutchinson,David [PYR]
 wrote:
> I haven't had much luck with a custom panel function; mainly because I
> don't truly understand how to embedd the functionality into the xyplot
> command.
>
> Here's a reproducible example if you can help out.
>
> Thanks,
> Dave
>
> library (lattice)
>
> d <- NULL
> models <- c('A','B','C','D')
> n = 100
> for (i in seq(along = models)){
>  d <- rbind(
>d, data.frame (
>  Model = models[i],
>  Year = seq(1960, length.out=n, by = 1),
>  SnowLineElevation = runif(n, 0, 100)
>)
>  )
> }
>
> xyplot (
>  SnowLineElevation ~ Year | Model,
>  data = d,
>  ylim = c(0,100),
>  type = c('p','smooth'),
>  col = 'blue',
>  pch = 21,
>  xlab = 'Year',
>  ylab = 'Snowline Elevation [m]'
> )
>
> -Original Message-
> From: Sundar Dorai-Raj [mailto:sdorai...@gmail.com]
> Sent: Monday, February 02, 2009 11:43 AM
> To: Hutchinson,David [PYR]
> Cc: r-help@r-project.org
> Subject: Re: [R] xyplot with lowess curves
>
> You'll need a custom panel function. It would also help if you provided
> a reproducible example:
>
> xyplot (
>  SnowLineElevation ~ Year | Model,
>  data = data,
>  panel = function(x, y, col, ...) {
>col <- ifelse(panel.number() == 1, "red", "green")
>panel.xyplot(x, y, col = "blue", ...)
>panel.loess(x, y, col = col)
>  },
>  ylim = c(0,1800),
>  pch = 21,
>  xlab = 'Year',
>  ylab = 'Snowline Elevation [m]'
> )
>
> Alternatively, you can use the group argument in conjunction with the
> panels:
>
> xyplot(SnowLineElevation ~ Year | Model, data, groups = Model, type =
> c("p", "smooth"))
>
> if you want the points and the lines to be the same color.
>
> --sundar
>
> On Mon, Feb 2, 2009 at 10:20 AM, Hutchinson,David [PYR]
>  wrote:
>> I am trying to change the attributes of the lowess lines fit to an
>> xyplot command, but have been unsuccessful in my search of the online
>> help. Right now, both the points and lowess line come out in the same
>> color (blue). I am unsure how I can change the properties of the
>> lowess line separately.
>>
>> xyplot (
>>  SnowLineElevation ~ Year | Model,
>>  data = data,
>>  ylim = c(0,1800),
>>  type = c('p','smooth'),
>>  col = 'blue',
>>  pch = 21,
>>  xlab = 'Year',
>>  ylab = 'Snowline Elevation [m]'
>> )
>>
>> Any help would be much appreciated,
>>
>> Dave
>>
>>[[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>

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


Re: [R] New to R

2009-02-02 Thread Greg Snow
It is not transposing (it just looks that way).  The first result is a vector 
which is 1 dimensional, but is neither a row or a column.  The printed version 
of it looks like a row, because that is a more compact representation.  If you 
sample enough points you will see it wrap around and be represented as several 
rows.  If it printed as a single column, then the first values would scroll off 
the screen with only a moderate number of values.

The replicate function then takes these vectors and combines them into a matrix 
and just happens to use each vector as a column of the new matrix, this is 
standard, matrices by default are filled by column, look at the output of 
as.matrix( sample( 6, 4, replace=TRUE ) ) and you will see your vector 
converted to a matrix of 1 column.  It could have been done the other way, but 
way back the decision was made to do it this way and there are probably a lot 
of things that would break if it were changed now, so we get to live with it.  
A single call to 't' is not too much effort to get what we expect.

So in short, a vector is neither a column or a row, but prints as a row for 
practical reasons, and is converted to a column by default if made into a 
matrix.  

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 Joe Hughes
> Sent: Monday, February 02, 2009 1:09 PM
> To: R help
> Subject: Re: [R] New to R
> 
> All,
> 
>   Thanks for taking the time to reply.  I understand a bit more
> about R
> and the R way then I did before.The final function looks like this:
> 
> ###
> ###
> #
> # Input:
> #   die_size - 4, 6, 8, 10, 20
> #   number_of_dice - How many dice to roll
> #   number_of_rolls - How many times to roll the dice
> #
> # Output:
> #The array holding the results of the rolls
> #
> ###
> ###
> #
> function(die_size, number_of_dice, number_of_rolls=1)
> {
>   return(t(replicate(number_of_rolls, sample(die_size,
> number_of_dice,
> replace=TRUE
> }
> 
> Before I take a look at the teaching demos, I have one question left.
> 
> Here is a sequence of commands and the output
> 
>  > sample(6, 4, replace=TRUE)
> [1] 3  4  5  4
>  > replicate(7, sample(6, 4, replace=TRUE))
>   [,1] [,2] [,3] [,4] [,5] [,6] [,7]
> [1,]3364566
> [2,]4465516
> [3,]5145656
> [4,]4631122
> 
> Why does replicate transpose the vector before assigning it to the
> array?  The way I would output it would be this
> 
>   [,1] [,2] [,3] [,4]
> [1,]3454
> [2,]3416
> [3,]6643
> [4,]4551
> [5,]5561
> [6,]6152
> [7,]6662
> 
> Thanks,
> Joe
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] R: Trellis Graph

2009-02-02 Thread Deepayan Sarkar
On Mon, Feb 2, 2009 at 11:05 AM, Greg Snow  wrote:
> ?lattice::shingle
>
> Hope that helps, if not, give more detail/example.

The example in

help(banking, package = "lattice")

should also be relevant.

-Deepayan

>
> --
> 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 K&A
>> Sent: Sunday, February 01, 2009 2:37 PM
>> To: r-help@r-project.org
>> Subject: [R] R: Trellis Graph
>>
>> I would like to plot X against Y in a trellis graph, wherein Y is the
>> conditioning variable.  Y represents time, but instead of distinct
>> categories
>> (eg, 0-10,11-20,21-30,...) I would like to use overlapping categories
>> (0-10,0-20,0-30,...).  Does anyone know how to do this, either via
>> options
>> in R graphics or by manipulating the data ?
>> Thank you.
>> Kieran Burnett
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-
>> guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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


Re: [R] xyplot with lowess curves

2009-02-02 Thread Hutchinson,David [PYR]
I haven't had much luck with a custom panel function; mainly because I
don't truly understand how to embedd the functionality into the xyplot
command.

Here's a reproducible example if you can help out.

Thanks,
Dave

library (lattice)

d <- NULL
models <- c('A','B','C','D')
n = 100
for (i in seq(along = models)){
  d <- rbind(
d, data.frame (
  Model = models[i],
  Year = seq(1960, length.out=n, by = 1),
  SnowLineElevation = runif(n, 0, 100)
)
  )
}

xyplot (
  SnowLineElevation ~ Year | Model,
  data = d,
  ylim = c(0,100),
  type = c('p','smooth'),
  col = 'blue',
  pch = 21,
  xlab = 'Year',
  ylab = 'Snowline Elevation [m]'
) 

-Original Message-
From: Sundar Dorai-Raj [mailto:sdorai...@gmail.com] 
Sent: Monday, February 02, 2009 11:43 AM
To: Hutchinson,David [PYR]
Cc: r-help@r-project.org
Subject: Re: [R] xyplot with lowess curves

You'll need a custom panel function. It would also help if you provided
a reproducible example:

xyplot (
  SnowLineElevation ~ Year | Model,
  data = data,
  panel = function(x, y, col, ...) {
col <- ifelse(panel.number() == 1, "red", "green")
panel.xyplot(x, y, col = "blue", ...)
panel.loess(x, y, col = col)
  },
  ylim = c(0,1800),
  pch = 21,
  xlab = 'Year',
  ylab = 'Snowline Elevation [m]'
)

Alternatively, you can use the group argument in conjunction with the
panels:

xyplot(SnowLineElevation ~ Year | Model, data, groups = Model, type =
c("p", "smooth"))

if you want the points and the lines to be the same color.

--sundar

On Mon, Feb 2, 2009 at 10:20 AM, Hutchinson,David [PYR]
 wrote:
> I am trying to change the attributes of the lowess lines fit to an 
> xyplot command, but have been unsuccessful in my search of the online 
> help. Right now, both the points and lowess line come out in the same 
> color (blue). I am unsure how I can change the properties of the 
> lowess line separately.
>
> xyplot (
>  SnowLineElevation ~ Year | Model,
>  data = data,
>  ylim = c(0,1800),
>  type = c('p','smooth'),
>  col = 'blue',
>  pch = 21,
>  xlab = 'Year',
>  ylab = 'Snowline Elevation [m]'
> )
>
> Any help would be much appreciated,
>
> Dave
>
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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


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

2009-02-02 Thread Stavros Macrakis
Perhaps rather than globally saying it is "utter nonsense" you would
care to refute what you think is wrong about it?

   -s

PS "Tyrants"?  Wow, we are really dramatizing life at work now

On Mon, Feb 2, 2009 at 3:14 PM, Rolf Turner  wrote:
>
> On 2/02/2009, at 4:29 PM, Murray Cooper wrote:
>
>> I was about to post a similar reply.
>> Stavros's reply was very eloquent and should be taken to heart!
>
>
> I would just like to say that in my very humble opinion Stavros's
> reply was utter nonsense.  It was the sort of excuse-making favoured
> by tyrants since time immemorial.
>
>cheers,
>
>Rolf Turner

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


Re: [R] Problems in Recommending R

2009-02-02 Thread Rolf Turner


On 2/02/2009, at 3:52 PM, Ajay ohri wrote:


Dear List,
One persistent feedback I am getting to people who are newly  
introduced to R

( especially in this cost cutting recession)  is -

1) The website looks a bit old.

While the current website does have a lot of hard work behind it,  
should n't

a world class statistics package have a better website instead.

You can check out www.knime.org which is an open source software ,  
and free,

and supports R---and notice the change in perception .


I think the R website is just fine as it is.  Effort should be put into
content and not into cosmetics.  Those (potential) users who would be  
likely to
be influenced by such trivialities as the appearance of the web page  
are unlikely

to be the sort of people who would use R anyway.

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] How do I get my IT department to "bless" R?

2009-02-02 Thread Rolf Turner


On 2/02/2009, at 4:29 PM, Murray Cooper wrote:


I was about to post a similar reply.
Stavros's reply was very eloquent and should be taken to heart!



I would just like to say that in my very humble opinion Stavros's
reply was utter nonsense.  It was the sort of excuse-making favoured
by tyrants since time immemorial.

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] New to R

2009-02-02 Thread Joe Hughes

All,

	Thanks for taking the time to reply.  I understand a bit more about R  
and the R way then I did before.The final function looks like this:


##
#
# Input:
#   die_size - 4, 6, 8, 10, 20
#   number_of_dice - How many dice to roll
#   number_of_rolls - How many times to roll the dice
#
# Output:
#The array holding the results of the rolls
#
##
#
function(die_size, number_of_dice, number_of_rolls=1)
{
	return(t(replicate(number_of_rolls, sample(die_size, number_of_dice,  
replace=TRUE

}

Before I take a look at the teaching demos, I have one question left.

Here is a sequence of commands and the output

> sample(6, 4, replace=TRUE)
[1] 3  4  5  4
> replicate(7, sample(6, 4, replace=TRUE))
 [,1] [,2] [,3] [,4] [,5] [,6] [,7]
[1,]3364566
[2,]4465516
[3,]5145656
[4,]4631122

Why does replicate transpose the vector before assigning it to the  
array?  The way I would output it would be this


 [,1] [,2] [,3] [,4]
[1,]3454
[2,]3416
[3,]6643
[4,]4551
[5,]5561
[6,]6152
[7,]6662

Thanks,
Joe

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


Re: [R] Selectively Removing objects

2009-02-02 Thread Paulo Grahl
Thanks Greg.
I did in the past looked into the details of how to create a package.
I did not seem too complicated, but it would be time consuming -- an
then when one thinks in creating a package (even for his own use)  it
always a good idea to check for wrong inputs, to have all functions
well documented, etc. The functions I've developed so far are not yet
in this stage.

But i liked the idea of using attach(). I had overlooked this point in
the attach() description.
Thanks.


Paulo Gustavo Grahl, CFA




On Mon, Feb 2, 2009 at 4:41 PM, Greg Snow  wrote:
> If you want to keep the functions, why not move them to a different 
> environment so that they don't get deleted when you delete everything else 
> (this will also work better if you want to use these same functions in other 
> R sessions).
>
> The most comprehensive way to do this is to create a package with the 
> functions (package.skeleton will get you started).
>
> One of the simplest ways to do this (if the package idea is overkill, though 
> if you expand this, the package solution may not be overkill in the long run) 
> is to use the 'save' command to save your functions into a file, delete 
> everything including the functions, then use 'attach' to attach the file you 
> saved the functions in.  Now you can still use the functions (just be careful 
> if you try to edit them), but they are not in the main environment where the 
> data is stored and when you delete 'everything' the next time, the attached 
> functions will not be affected.
>
> 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 Paulo Grahl
>> Sent: Monday, February 02, 2009 6:17 AM
>> To: r-help@r-project.org
>> Subject: [R] Selectively Removing objects
>>
>> Dear list members,
>>
>> Does anyone know how to use rm() to remove only variables but not
>> declared functions from the environment ?
>> I understand I could name all the functions with, let's say
>> "f_something", make sure that all variables do not start with "f_" and
>> then remove all BUT objects starting with "f_".
>> However, I have already defined all the functions and it would be
>> troublesome to change all of them to a new name.
>>
>> Any hint ?
>> Thanks
>>
>> Paulo Gustavo Grahl, CFA
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/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] xyplot with lowess curves

2009-02-02 Thread Sundar Dorai-Raj
You'll need a custom panel function. It would also help if you
provided a reproducible example:

xyplot (
  SnowLineElevation ~ Year | Model,
  data = data,
  panel = function(x, y, col, ...) {
col <- ifelse(panel.number() == 1, "red", "green")
panel.xyplot(x, y, col = "blue", ...)
panel.loess(x, y, col = col)
  },
  ylim = c(0,1800),
  pch = 21,
  xlab = 'Year',
  ylab = 'Snowline Elevation [m]'
)

Alternatively, you can use the group argument in conjunction with the panels:

xyplot(SnowLineElevation ~ Year | Model, data, groups = Model, type =
c("p", "smooth"))

if you want the points and the lines to be the same color.

--sundar

On Mon, Feb 2, 2009 at 10:20 AM, Hutchinson,David [PYR]
 wrote:
> I am trying to change the attributes of the lowess lines fit to an
> xyplot command, but have been unsuccessful in my search of the online
> help. Right now, both the points and lowess line come out in the same
> color (blue). I am unsure how I can change the properties of the lowess
> line separately.
>
> xyplot (
>  SnowLineElevation ~ Year | Model,
>  data = data,
>  ylim = c(0,1800),
>  type = c('p','smooth'),
>  col = 'blue',
>  pch = 21,
>  xlab = 'Year',
>  ylab = 'Snowline Elevation [m]'
> )
>
> Any help would be much appreciated,
>
> Dave
>
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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


Re: [R] sas.get under Linux

2009-02-02 Thread Frank E Harrell Jr

Adrian Dusa wrote:



Dear Frank,

I understand. Never used SAS before, so I don't have it installed anywhere.

StatTransfer is a very useful tool indeed, but maybe I don't know how to 
use it properly.


What I have is a "mydata.sas7bdat" file, along with a "formats.sas7bcat" 
file.


I specified reading SAS value labels "Read directly from a catalog 
file", but nothing appears in the output, neither in the R workspace nor 
in an intermediate SPSS file.


I also tried exporting to a SAS portable file to import directly in R, 
but there is probably something obvious that I miss because value labels 
are not there, whatever I do...


Thanks for your help,

Adrian


Stat/Transfer has a menu option to read the SAS format catalog but I 
haven't tried it.


Frank



On Saturday 31 January 2009, Frank E Harrell Jr wrote:

 > Adrian Dusa wrote:

 > > Dear all,

 > >

 > > I am trying to import a SAS file into R (in fact I only need the value

 > > labels from the formats file), using Hmisc package, but I get this 
error:


 > >

 > > my.sas <- sas.get("/home/adi/3", "fis1_sgg")

 > > sh: sas: not found

 > > Error in sas.get("/home/adi/3", "fis1_sgg") :

 > > SAS job failed with status 32512

 > >

 > > I read some past discussions and I get the impression that sas.get()

 > > needs the full path to the SAS executable, but I don't have that 
because


 > > I am using Linux.

 > >

 > > Is it possible to use sas.get() without having SAS installed?

 >

 > Since sas.get is trying to execute sas the answer is a definite no

 > unless you use the sas.get option to run SAS on another machine to

 > produce the input ASCII files needed by sas.get. Also investigate

 > sasxport.get if you have SAS version 5 transport files to import.

 > See also http://biostat.mc.vanderbilt.edu/SASexportHowto

 >

 > As SAS never got it right in allowing for full metadata to be included

 > in a SAS dataset, you often have to run PROC FORMAT CNTLOUT=... to

 > convert format libraries to SAS datasets so that programs such as

 > sasxport.get can assign value labels [if you have SAS installed, sas.get

 > runs PROC CONTENTS for you.]. SPSS and Stata have always been ahead of

 > SAS in this regard.

 >

 > Note that the excellent Stat/Transfer commercial product will convert

 > from almost any SAS dataset format to compact R binary objects,

 > including variable labels the way the Hmisc package handles them. If

 > you have another way to convert from SAS to Stata or SPSS, R is great at

 > readying those formats.

 >

 > Frank

 >

 > > Or alternatively, is there another function to import the formats 
into R?


 > >

 > > Thanks in advance for any hint,

 > > Adrian

--

Adrian Dusa

Romanian Social Data Archive

1, Schitu Magureanu Bd.

050025 Bucharest sector 5

Romania

Tel.:+40 21 3126618 \

+40 21 3120210 / int.101

Fax: +40 21 3158391




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

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


Re: [R] survfit using quantiles to group age

2009-02-02 Thread Frank E Harrell Jr

Eleni Rapsomaniki wrote:
I am using the package Design for survival analysis. I want to plot a 
simple Kaplan-Meier fit of survival vs. age, with age grouped as 
quantiles. I can do this:


survplot(survfit(Surv(time,status) ~ cut(age,3), data=veteran)

but I would like to do something like this:

survplot(survfit(Surv(time,status) ~ quantile(age,3), data=veteran) 
#will not work


ideally I would like to superimpose estimates from cph models, which 
automatically fit the 2nd to 4rth quantiles for age, so I need the age 
groups to be grouped the same.


Any help greatly appreciated!
Eleni Rapsomaniki


This will result in a poor fitting model and residual confounding (by 
only partially adjusting for a variable; you are assuming a piecewise 
flat model).  Use Surv( ) ~ strat(cut2(age,g=3)) ...

For Design it is often better to do

ageg <- cut2(age,g=3)   # Donald Rumsfeld approach to using information
f <- cph(Surv( ) ~ strat(ageg), ...)

Frank




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

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


Re: [R] Problems in Recommending R

2009-02-02 Thread Tobias Verbeke

friedrich.lei...@stat.uni-muenchen.de wrote:


On Mon, 2 Feb 2009 18:14:03 +0530,
Ajay ohri (Ao) wrote:


  > Plain HTML coding is simple enough for this list ( I think)...but aesthetic
  > designhmm

In most cases one can do more than most think using HTML and CSS: Our
universities corporate design was done by "professionals" and is backed
by a CMS:

  http://www.uni-muenchen.de

Our dpertment didn't want to use the CMS, so we emulated it using
HTML, CSS and iframes:

  http://www.stat.uni-muenchen.de/

which is *much* more convenient to maintain for us: I have a copy of
my page on my laptop, I can work on it while offline on a train, etc.

I don't want to discuss whether the above examples are aesthetic or
not (we are required to follow the coporate design, so have no
choice). The main point I want to make is: that everything is static
HTML makes life very easy for command line junkies like me ;-)


Apart from making life easy for command line junkies,
plain HTML is also very search engine friendly.

Best,
Tobias

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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-02 Thread nashjc
I won't burden the list with copies of earlier posts -- all of us have
experienced the frustration of dealing with folk who want to make their
life easier by making ours difficult. However, I have noted that a few
folk are starting to change attitudes. I was hired to give a training
session last June to a fairly large unit in the Canadian government that
realized a mix of Excel and SAS and SPSS and ... were leading to an
unmaintainable mess of small applications needed to handle the information
needed for core responsibilities. When an employee leaves a large
spreadsheet that contains the analytic and prediction model, it is
generally a VERY big job to maintain. The boss of the unit realized that
small R scripts could do a lot of the work and that dataframes and
spreadsheets are relatively easy to interchange if one avoids fancy
features. Thus it was feasible to use spreadsheets for data entry --
reducing training costs and "I don't know R" etc., though with some risks
-- and have some youngish new hires write the scripts to do the analysis
and reports that were needed every few days. If the folk involved are
reading this, I'll apologize in advance for over-simplifying.

The central theme here is "economic", in that it is making life easier for
all.

John Nash

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


Re: [R] Tunnelling X for R graphics

2009-02-02 Thread Adam D. I. Kramer


On Tue, 3 Feb 2009, Patrick Connolly wrote:


The problem, and maybe I'm just whining here, is that because the
data sets are large this takes several minutes where I'm basically just
sitting around.  This happens once every other day as the VPN software
I'm using "times out" after about 24 hours and thus the ssh session dies.


Is it possible to do anything about the VPN software?  I use tightVNC to
do something similar and it doesn't time out after 24 hours.  Even closing
the desktop machine down altogether does not lose the ssh connexion. 
Restarting the desktop a week later will still find the X session without

loss.


The VPN software is managed and maintained by the company I'm doing
statistical computing work for...out of my control. Your comments about
TightVNC are pretty impressive, though--I'm not really sure how that would
work...though if you set your ssh connection to not push any data towards
your computer, I gather the server would have no reason to believe you were
unresponsive?

In any case, this sadly doesn't help me, but many thanks!

For now, I'm just trying my hardest to remeber to dev.off() when I'm done
using graphics.

--Adam

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


Re: [R] Power analysis for MANOVA?

2009-02-02 Thread Adam D. I. Kramer

Hi Rick,

I understand the authors' point and also agree that post-hoc power
analysis is basically not telling me anything more than the p-value and
initial statistic for the test I am interested in computing power for.

Beta is a simple function of alpha, p, and the statistic.

My intention is, as I mentioned in my response to Stephan Kolassa,
to transform my p-value and statistic into a form of effect size--sample
size necessary to attain significance at alpha=.05. This will communicate no
more information, it is just a mathematical re-representation of my data in
a way I believe my readers will find more informative and useful. In other
words, there is no more information *encoded*, but there is more information
*communicated,* just like for any effect size measure.

If you have any suggestions on a more reliable effect size for
MANOVA which is *also* commonly known in the social psychology community
(e.g., a correlation or Cohen's d analogue), I'm interested--but the
multivariate nature of the beast makes these more or less impossible to
translate.

The poster I was asking for is now printed, and we reported the
multivariate R-squared using the techniques in Cohen (1988), though I'm
expecting to spend a lot of time explaining what that means to people in a
multivariate context, rather than describing the results of the study.

Cordially,
Adam D. I. Kramer

On Sun, 1 Feb 2009, Rick Bilonick wrote:


On Wed, 2009-01-28 at 21:21 +0100, Stephan Kolassa wrote:

Hi Adam,

first: I really don't know much about MANOVA, so I sadly can't help you
without learning about it an Pillai's V... which I would be glad to do,
but I really don't have the time right now. Sorry!

Second: you seem to be doing a kind of "post-hoc power analysis", "my
result isn't significant, perhaps that's due to low power? Let's look at
the power of my experiment!" My impression is that "post-hoc power
analysis" and its interpretation is, shall we say, not entirely accepted
within the statistical community, see:

Hoenig, J. M., & Heisey, D. M. (2001, February). The abuse of power: The
pervasive fallacy of power calculations for data analysis. The American
Statistician, 55 (1), 1-6

And this:
http://staff.pubhealth.ku.dk/~bxc/SDC-courses/power.pdf

However, I am sure that lots of people can discuss this more competently
than me...

Best wishes
Stephan



The point of the article was that doing a so-called "retrospective"
power analysis leads to logical contradictions with respect to the
confidence intervals and p-values from the analysis of the data. In
other words, DON'T DO IT! All the information is contained in the
confidence intervals which are based on the observed data - an after the
fact "power analysis" cannot provide any insight - it's not data
analysis.

Rick B.




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


Re: [R] Tunnelling X for R graphics

2009-02-02 Thread Adam D. I. Kramer

Indeed, I am running R in screen. That is the context in which this error
occurs.

The problem is that screen passes $DISPLAY as the $DISPLAY for the actual
terminal. So when the ssh session dies, the X11 connection is broken.

The REST of R works fine...which is why I use screen in the first place. My
data is not lost, etc., however it tells me I need to save and quit
immediately.  That is my concern.

--Adam

On Sat, 31 Jan 2009, Dylan Beaudette wrote:


Try starting your R session after starting a 'screen' session. Like this:

$> screen
$> R
# do stuff, when taking a break do CTRL-A D to disconnect
# use as normal

See the man page for screen, it is basically a terminal multiplexer
that can gracefully accommodate connection failures. If you get
disconnected, re-connect, and then re-attach the screen process:
$> screen -r

and you should be ok.

Cheers,

Dylan


On 1/31/09, Adam D. I. Kramer  wrote:

Dear colleagues,

I run R on a few different machines, and view graphs and the like by
tunnelling X through SSH to my local machine. This is useful for me because
my local machine can't easily handle some of the data sets I work with.

However, when an ssh connection dies, the tunnelled X session also
dies, which breaks R's device connection, generating this error:


Error: X11 fatal IO error: please save work and shut down R


...that's kinda scary, so I quit(save="yes") and then run R again.

The problem, and maybe I'm just whining here, is that because the
data sets are large this takes several minutes where I'm basically just
sitting around.  This happens once every other day as the VPN software I'm
using "times out" after about 24 hours and thus the ssh session dies.

I can't really guess at why a broken X session would corrupt a
running session of R so severely that it would need to be completely
restarted.  Can anyone explain this to me?  Or perhaps (hopefully) someone
has enough knowledge of the X11 device to be able to tell me that I can
ignore this message, and just use dev.off() and then X11("localhost:10") to
open a new working X11 connection?

Cordially,
Adam Kramer

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

2009-02-02 Thread Wacek Kusnierczyk
Joe Hughes wrote:
>
> #
> function(die_size, number_of_dice, number_of_rolls)
> {

you may want to replace

> rolls <- array(0, dim=c(number_of_rolls, number_of_dice))
> 
> for (i in 1:number_of_rolls)
> {
> rolls[i,] <- sample(die_size, number_of_dice, replace=TRUE)
> }

with, e.g.

rolls = t(replicate(number_of_rolls, sample(die_size, number_of_dice,
replace=TRUE)))

to have it more r-ish

> 
> return(rolls)
> }
>
> Any thoughts on this function?  

as soon as you start wrapping something like subset, lm, or the like
inside your functions, all hell breaks loose.  welcome to the r inferno,
that is. 


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] R: Trellis Graph

2009-02-02 Thread Greg Snow
?lattice::shingle

Hope that helps, if not, give more detail/example.

-- 
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 K&A
> Sent: Sunday, February 01, 2009 2:37 PM
> To: r-help@r-project.org
> Subject: [R] R: Trellis Graph
> 
> I would like to plot X against Y in a trellis graph, wherein Y is the
> conditioning variable.  Y represents time, but instead of distinct
> categories
> (eg, 0-10,11-20,21-30,...) I would like to use overlapping categories
> (0-10,0-20,0-30,...).  Does anyone know how to do this, either via
> options
> in R graphics or by manipulating the data ?
> Thank you.
> Kieran Burnett
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] New to R

2009-02-02 Thread Greg Snow
If you are interested in rolling dice with R (as opposed to using this as a 
simple test case to start writing your own programs), then you may want to look 
at the "dice" function from the TeachingDemos package.  The core line in this 
function is basically the same as Gabor's suggestion, but with the added option 
of weighting the dice (you don't like how I graded your exam? I am happy to let 
these computerized dice regrade it for you :-).  There is also an option to 
plot the results (for 6-sided dice).

There is also the plot.rgl.die and roll.rgl.die functions in the same package 
that give an animated rolling of the die (I really need to rewrite it to get a 
better animation, the coin flip works ok as is).

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 Joe Hughes
> Sent: Monday, February 02, 2009 10:40 AM
> To: R-help@r-project.org
> Subject: [R] New to R
> 
> Hello All,
> 
>   A colleague of mine started working with R and out of curiosity I
> did
> some research on the language.  Very nice.  In my opinion this is one
> of the best languages I've found for getting tasks I'm interested in
> done.  I wrote this simple die roller and was curious to know if it is
> R enough.
> 
> ###
> ###
> #
> # Input:
> #   die_size - 4, 6, 8, 10, 20
> #   number_of_dice - How many dice to roll
> #   number_of_rolls - How many times to roll the dice
> #
> # Output:
> #rolls - The array holding the values of the dice
> #
> ###
> ###
> #
> function(die_size, number_of_dice, number_of_rolls)
> {
>   rolls <- array(0, dim=c(number_of_rolls, number_of_dice))
> 
>   for (i in 1:number_of_rolls)
>   {
>   rolls[i,] <- sample(die_size, number_of_dice, replace=TRUE)
>   }
> 
>   return(rolls)
> }
> 
> Any thoughts on this function?  Is there a better way of doing it in
> R?  Can you tell I used to play AD&D?
> 
> Thanks,
> Joe
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] xyplot with lowess curves

2009-02-02 Thread Hutchinson,David [PYR]
I am trying to change the attributes of the lowess lines fit to an
xyplot command, but have been unsuccessful in my search of the online
help. Right now, both the points and lowess line come out in the same
color (blue). I am unsure how I can change the properties of the lowess
line separately.
 
xyplot (
  SnowLineElevation ~ Year | Model,
  data = data,
  ylim = c(0,1800),
  type = c('p','smooth'),
  col = 'blue',
  pch = 21,
  xlab = 'Year',
  ylab = 'Snowline Elevation [m]'
)
 
Any help would be much appreciated,
 
Dave

[[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] Tunnelling X for R graphics

2009-02-02 Thread Patrick Connolly
On Sat, 31-Jan-2009 at 03:16PM -0800, Adam D. I. Kramer wrote:

[]

>   The problem, and maybe I'm just whining here, is that because the
> data sets are large this takes several minutes where I'm basically just
> sitting around.  This happens once every other day as the VPN software I'm
> using "times out" after about 24 hours and thus the ssh session dies.

Is it possible to do anything about the VPN software?  I use tightVNC
to do something similar and it doesn't time out after 24 hours.  Even
closing the desktop machine down altogether does not lose the ssh
connexion.  Restarting the desktop a week later will still find the X
session without loss.

HTH


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

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


[R] [R-pkgs] RMySQL 0.7-3

2009-02-02 Thread Jeffrey Horner

Dear R users,

RMySQL 0.7-3 has been released. Expect it to hit the CRAN mirrors 
shortly, but in the mean time please get it here:


http://biostat.mc.vanderbilt.edu/RMySQL

From the NEWS file:

Version 0.7-3

* Added mysqlClientLibraryVersions() which returns the compiled and
  loaded client library versions as a vector.

* RMySQL will now check for MySQL minor version consistency and throw
  an error when the client and loaded library versions don't match.


Best,

Jeff
--
http://biostat.mc.vanderbilt.edu/JeffreyHorner

___
R-packages mailing list
r-packa...@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-packages

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Now - how to fix the overlap

2009-02-02 Thread Jason Rupert
Yikes.  
 
On closer inspection this causes there to be a noticeable amount of overlap of 
the various vertical bars.  Speccifically, it appears that the second overlaps 
the first, the third overlaps the second, etc.   This is much more noteable for 
a data set with a smaller x-axis. 
 
Thanks again for any feedback.  
 
--- On Mon, 2/2/09, hadley wickham  wrote:

From: hadley wickham 
Subject: Re: [R] Specifying the gap between "dodge'd" bins groups?
To: jasonkrup...@yahoo.com
Cc: Date: Monday, February 2, 2009, 11:10 AM

Hi Jason,

On Mon, Feb 2, 2009 at 9:10 AM, Jason Rupert 
wrote:
> I'm looking at ggplot-static\position_dodge.html
>
> For ggplot(diamonds, aes(x=price, fill=cut)) +
geom_bar(position="dodge") , is it possible to specify the spacing
between the dodge'd bin groupings?
>
> That is, I would like for there to be a small separation (horizontal
space) between the "Ideal" and the "Fair" bars on the plot. 
That way the reader can get a better idea of when each bin ends and the other
begins.
>
> I think this "horizontal spacing" naturally occurs for discrete
data, but for continuous data as is shown in the second figure, the bins all
seem to right beside each other.  It would be nice if a small space could be
added.

You can do something like this:

ggplot(diamonds, aes(x=price, fill=cut)) +
geom_bar(position=position_dodge(width=400), binwidth=500)

Hadley

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



  
[[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] Selectively Removing objects

2009-02-02 Thread Greg Snow
If you want to keep the functions, why not move them to a different environment 
so that they don't get deleted when you delete everything else (this will also 
work better if you want to use these same functions in other R sessions).

The most comprehensive way to do this is to create a package with the functions 
(package.skeleton will get you started).

One of the simplest ways to do this (if the package idea is overkill, though if 
you expand this, the package solution may not be overkill in the long run) is 
to use the 'save' command to save your functions into a file, delete everything 
including the functions, then use 'attach' to attach the file you saved the 
functions in.  Now you can still use the functions (just be careful if you try 
to edit them), but they are not in the main environment where the data is 
stored and when you delete 'everything' the next time, the attached functions 
will not be affected.

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 Paulo Grahl
> Sent: Monday, February 02, 2009 6:17 AM
> To: r-help@r-project.org
> Subject: [R] Selectively Removing objects
> 
> Dear list members,
> 
> Does anyone know how to use rm() to remove only variables but not
> declared functions from the environment ?
> I understand I could name all the functions with, let's say
> "f_something", make sure that all variables do not start with "f_" and
> then remove all BUT objects starting with "f_".
> However, I have already defined all the functions and it would be
> troublesome to change all of them to a new name.
> 
> Any hint ?
> Thanks
> 
> Paulo Gustavo Grahl, CFA
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] New to R

2009-02-02 Thread Gabor Grothendieck
Yes, it should be TRUE.

On Mon, Feb 2, 2009 at 1:16 PM, Joe Hughes  wrote:
> Gabor,
>
>Shouldn't the replace be TRUE instead of FALSE?  I get this error
>
> Error in sample(6, 28, replace = FALSE) :
>  cannot take a sample larger than the population when 'replace = FALSE'
>
> when I use FALSE.  I don't get the error when it is TRUE.  Examining my
> mental model of what is going on you can't remove a number from a die thus
> each sample(value of the die) when selected has to be replaced.  Or am I
> missing something?
>
> Thanks,
> Joe
>
> On Feb 2, 2009, at 1:00 PM, Gabor Grothendieck wrote:
>
>> Try this:
>>
>> matrix(sample(dsize, nrolls * ndice, replace = FALSE), nrolls, ndice)
>>
>> On Mon, Feb 2, 2009 at 12:39 PM, Joe Hughes 
>> wrote:
>>>
>>> Hello All,
>>>
>>>  A colleague of mine started working with R and out of curiosity I
>>> did
>>> some research on the language.  Very nice.  In my opinion this is one of
>>> the
>>> best languages I've found for getting tasks I'm interested in done.  I
>>> wrote
>>> this simple die roller and was curious to know if it is R enough.
>>>
>>>
>>> ##
>>> #
>>> # Input:
>>> #   die_size - 4, 6, 8, 10, 20
>>> #   number_of_dice - How many dice to roll
>>> #   number_of_rolls - How many times to roll the dice
>>> #
>>> # Output:
>>> #rolls - The array holding the values of the dice
>>> #
>>>
>>> ##
>>> #
>>> function(die_size, number_of_dice, number_of_rolls)
>>> {
>>>  rolls <- array(0, dim=c(number_of_rolls, number_of_dice))
>>>
>>>  for (i in 1:number_of_rolls)
>>>  {
>>>  rolls[i,] <- sample(die_size, number_of_dice, replace=TRUE)
>>>  }
>>>
>>>  return(rolls)
>>> }
>>>
>>> Any thoughts on this function?  Is there a better way of doing it in R?
>>>  Can
>>> you tell I used to play AD&D?
>>>
>>> Thanks,
>>> Joe
>>>
>>> __
>>> R-help@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/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 do I get my IT department to "bless" R?

2009-02-02 Thread Greg Snow
There has already been good discussion on this topic, but here are a couple of 
other things to think about:

1. is it your job to convince your IT department, or is it your job to convince 
your boss, and your boss's job to convince/dictate to the IT department 
(getting your boss on your side could be easier and very beneficial (or not 
depending on the boss)).

2. Why not do a simple cost analysis comparing what you do now using R compared 
to what it will cost if you do not use R, be honest in all the costs, but 
include how optional pieces will affect your productivity.  I would start with 
a cost for a single license of S-PLUS (most similar to R out there), then 
include the annual license fee for S-PLUS.  Do you only use R on your single 
work computer? Or do you use it at home/laptop/other computers? Include the 
cost for the additional licenses, or how your work would be impacted by only 
being able to use it when sitting at the one computer.

Next, what packages do you use in R that are not available in S-PLUS currently? 
 How often do you use them and for what?  Include this information in the cost 
analysis, because any tools not available will either limit your productivity, 
take time for you to learn an alternative, or will require time/money for 
someone to convert them to work with S-PLUS (either you estimate your time 
needed, IT (how much time would it take them to get up to speed enough to do 
the conversion), or hiring an outside programmer (cost?)).

List those things out with details, costs (needed and optional), and the 
effects of having or not having optional pieces.  Also include discussions on 
the concerns that Stavros has mentioned (and any other that your IT department 
is likely to have).  Present all of that to your boss and he/she may just 
become your advocate for blessing R (saving money can be more of a motivation 
than parts of the workflow that you see as important, but they don't 
understand).

3. Being a Microsoft shop, do they allow you to use MSExcel?, would they allow 
you to install a plug-in for Excel?  (An interface and full R implementation 
are available as a plugin, this could be a back door for installing R that does 
not need a policy change).

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 Daniel Viar
> Sent: Thursday, January 29, 2009 3:29 PM
> To: r-help@r-project.org
> Subject: [R] How do I get my IT department to "bless" R?
> 
> I currently use R at work "under the radar", but there's a chance I
> could loose that access.  I'd like to get our company to feel
> comfortable with open source and R in particular.  Does anyone have
> any experience with their company's IT department and management that
> they would be willing to share?  How does one get an all Microsoft
> shop on board with allowing users to user R?  I know about the recent
> NY Times article and recent news.  I'm afraid I may need some case
> studies or examples of what other companies have done.
> 
> Any help would be greatly appreciated.
> 
> Thanks
> Dan Viar
> Chesapeake, VA
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] New to R

2009-02-02 Thread Joe Hughes

Gabor,

Shouldn't the replace be TRUE instead of FALSE?  I get this error

Error in sample(6, 28, replace = FALSE) :
  cannot take a sample larger than the population when 'replace =  
FALSE'


when I use FALSE.  I don't get the error when it is TRUE.  Examining  
my mental model of what is going on you can't remove a number from a  
die thus each sample(value of the die) when selected has to be  
replaced.  Or am I missing something?


Thanks,
Joe

On Feb 2, 2009, at 1:00 PM, Gabor Grothendieck wrote:


Try this:

matrix(sample(dsize, nrolls * ndice, replace = FALSE), nrolls, ndice)

On Mon, Feb 2, 2009 at 12:39 PM, Joe Hughes  
 wrote:

Hello All,

  A colleague of mine started working with R and out of  
curiosity I did
some research on the language.  Very nice.  In my opinion this is  
one of the
best languages I've found for getting tasks I'm interested in  
done.  I wrote

this simple die roller and was curious to know if it is R enough.

##
#
# Input:
#   die_size - 4, 6, 8, 10, 20
#   number_of_dice - How many dice to roll
#   number_of_rolls - How many times to roll the dice
#
# Output:
#rolls - The array holding the values of the dice
#
##
#
function(die_size, number_of_dice, number_of_rolls)
{
  rolls <- array(0, dim=c(number_of_rolls, number_of_dice))

  for (i in 1:number_of_rolls)
  {
  rolls[i,] <- sample(die_size, number_of_dice,  
replace=TRUE)

  }

  return(rolls)
}

Any thoughts on this function?  Is there a better way of doing it  
in R?  Can

you tell I used to play AD&D?

Thanks,
Joe

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] survfit using quantiles to group age

2009-02-02 Thread Eleni Rapsomaniki
I am using the package Design for survival analysis. I want to plot a  
simple Kaplan-Meier fit of survival vs. age, with age grouped as  
quantiles. I can do this:


survplot(survfit(Surv(time,status) ~ cut(age,3), data=veteran)

but I would like to do something like this:

survplot(survfit(Surv(time,status) ~ quantile(age,3), data=veteran)  
#will not work


ideally I would like to superimpose estimates from cph models, which  
automatically fit the 2nd to 4rth quantiles for age, so I need the age  
groups to be grouped the same.


Any help greatly appreciated!
Eleni Rapsomaniki

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


Re: [R] New to R

2009-02-02 Thread Gabor Grothendieck
Try this:

matrix(sample(dsize, nrolls * ndice, replace = FALSE), nrolls, ndice)

On Mon, Feb 2, 2009 at 12:39 PM, Joe Hughes  wrote:
> Hello All,
>
>A colleague of mine started working with R and out of curiosity I did
> some research on the language.  Very nice.  In my opinion this is one of the
> best languages I've found for getting tasks I'm interested in done.  I wrote
> this simple die roller and was curious to know if it is R enough.
>
> ##
> #
> # Input:
> #   die_size - 4, 6, 8, 10, 20
> #   number_of_dice - How many dice to roll
> #   number_of_rolls - How many times to roll the dice
> #
> # Output:
> #rolls - The array holding the values of the dice
> #
> ##
> #
> function(die_size, number_of_dice, number_of_rolls)
> {
>rolls <- array(0, dim=c(number_of_rolls, number_of_dice))
>
>for (i in 1:number_of_rolls)
>{
>rolls[i,] <- sample(die_size, number_of_dice, replace=TRUE)
>}
>
>return(rolls)
> }
>
> Any thoughts on this function?  Is there a better way of doing it in R?  Can
> you tell I used to play AD&D?
>
> Thanks,
> Joe
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] quantiles for sorted pairs of data

2009-02-02 Thread Monica Pisica

Hi everybody,
 
Suppose I have continuous measurements of an energy waveform that is sampled 
discretely for different heights every 0.5m. Let's say I want to find out the 
height for which I have equal amount of energy above and below. 
My colleague did the following:

a. calculate the cumulative sum of the energy
b. calculate the median of the cumulative energy
c. find out what is the height for which this median corresponds.
 
My take on this is: Since the heights are already sorted from min to max, and 
the cumulative energy is by default sorted from min to max …. it does not 
matter if I calculate the median of the cumulative energy and see which height 
it belongs to when I can calculate directly the median of the height and get 
actually same result. I think the same holds if I calculate any other quantile 
if I am interested in the corresponding height of that cumulative energy 
quantile.
 
I did some simulations to see if this is true, and I have simulated the energy 
values as a random sample of a normal distribution, gamma, f distribution or 
random sample of a combination of normal and gamma distributions. My question 
is: do any of you know of any reference that proves that? Paper, math property 
of already ordered sequences, anything to prove that this is not just a 
coincidence?
 
Following is an example, with n = 15 just for convenience to see with "naked 
eye" which value should be the median (I will also use only examples from a 
normal distribution, but the results prove the same does not matter which 
distribution I use for energy)
 
### code starts
 
set.seed = 123
xn <- rnorm(15)
xn <- xn+3   #to have only positive numbers
yn <- seq(1, 8, 0.5)
zn <- cumsum(xn)
dfn <- data.frame(energy = xn, elevation = yn, cum.energ = zn)
percent <- apply(dfn,2, function(x) quantile(x, probs = c(0.1, 0.25, 0.5, 0.75, 
0.95)))
percent
dfn
f <- approxfun(yn, zn)
f(percent[1,2])
 
## code ends
 
As you can see quantiles for the cumulative energy corresponds to the 
respective quantiles of elevation, but quantiles of the energy waveform itself 
correspond to different heights than the elevation quantiles. Any help for 
references will be very much appreciated.  
 
Thanks for any help,
 
Monica
_


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


Re: [R] Tunnelling X for R graphics

2009-02-02 Thread Dylan Beaudette
On Saturday 31 January 2009, Erik Iverson wrote:
> Dylan,
>
> Can you confirm that you've done that before while tunneling R graphics
> over ssh?  I thought I'd tried and screen and failed with a similar message
> when using graphics as Adam had.  I could be wrong though.

Ack. Maybe I spoke too soon. I haven't encountered the error before and 
*expected* screen to take care of connection problems... However I cannot 
confirm that it would work for your case... Sorry!

Dylan

> Dylan Beaudette wrote:
> > Try starting your R session after starting a 'screen' session. Like this:
> >
> > $> screen
> > $> R
> > # do stuff, when taking a break do CTRL-A D to disconnect
> > # use as normal
> >
> > See the man page for screen, it is basically a terminal multiplexer
> > that can gracefully accommodate connection failures. If you get
> > disconnected, re-connect, and then re-attach the screen process:
> > $> screen -r
> >
> > and you should be ok.
> >
> > Cheers,
> >
> > Dylan
> >
> > On 1/31/09, Adam D. I. Kramer  wrote:
> >> Dear colleagues,
> >>
> >>I run R on a few different machines, and view graphs and the like by
> >> tunnelling X through SSH to my local machine. This is useful for me
> >> because my local machine can't easily handle some of the data sets I
> >> work with.
> >>
> >>However, when an ssh connection dies, the tunnelled X session also
> >>
> >> dies, which breaks R's device connection, generating this error:
> >>> Error: X11 fatal IO error: please save work and shut down R
> >>
> >> ...that's kinda scary, so I quit(save="yes") and then run R again.
> >>
> >>The problem, and maybe I'm just whining here, is that because the
> >> data sets are large this takes several minutes where I'm basically just
> >> sitting around.  This happens once every other day as the VPN software
> >> I'm using "times out" after about 24 hours and thus the ssh session
> >> dies.
> >>
> >>I can't really guess at why a broken X session would corrupt a
> >> running session of R so severely that it would need to be completely
> >> restarted.  Can anyone explain this to me?  Or perhaps (hopefully)
> >> someone has enough knowledge of the X11 device to be able to tell me
> >> that I can ignore this message, and just use dev.off() and then
> >> X11("localhost:10") to open a new working X11 connection?
> >>
> >> Cordially,
> >> Adam Kramer
> >>
> >> __
> >> R-help@r-project.org mailing list
> >> https://stat.ethz.ch/mailman/listinfo/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.



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

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


Re: [R] Specifying the gap between "dodge'd" bins groups?

2009-02-02 Thread Jason Rupert
This appears to work great. 
 
However, is there a way to programmatically to extract the bin size that ggplot 
selected in order to be able to change this for multiple data sets? 
 
Similarly, is there a way to determine the number of count in each bin that 
ggplot establish?  I wanted to change the axis a bit based on the count size, 
but I needed to do it programmatically give the large number of samples. 
 
For the example below, it would be something like the following:
ggplot(diamonds, aes(x=price, fill=cut)) +
geom_bar(position=position_dodge(width=default_ggplotbinwidth*0.75), 
binwidth=default_ggplotbinwidth) + ylim(0, ggplotmaxcount*1.1)
I would like to have access to the calculated ggplotbin and ggplotmaxcount for 
the data set.   
Thank you again for your help. 


--- On Mon, 2/2/09, hadley wickham  wrote:

From: hadley wickham 
Subject: Re: [R] Specifying the gap between "dodge'd" bins groups?
To: jasonkrup...@yahoo.com
Cc: Date: Monday, February 2, 2009, 11:10 AM

Hi Jason,

On Mon, Feb 2, 2009 at 9:10 AM, Jason Rupert 
wrote:
> I'm looking at ggplot-static\position_dodge.html
>
> For ggplot(diamonds, aes(x=price, fill=cut)) +
geom_bar(position="dodge") , is it possible to specify the spacing
between the dodge'd bin groupings?
>
> That is, I would like for there to be a small separation (horizontal
space) between the "Ideal" and the "Fair" bars on the plot. 
That way the reader can get a better idea of when each bin ends and the other
begins.
>
> I think this "horizontal spacing" naturally occurs for discrete
data, but for continuous data as is shown in the second figure, the bins all
seem to right beside each other.  It would be nice if a small space could be
added.

You can do something like this:

ggplot(diamonds, aes(x=price, fill=cut)) +
geom_bar(position=position_dodge(width=400), binwidth=500)

Hadley

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



  
[[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] New to R

2009-02-02 Thread Joe Hughes

Hello All,

	A colleague of mine started working with R and out of curiosity I did  
some research on the language.  Very nice.  In my opinion this is one  
of the best languages I've found for getting tasks I'm interested in  
done.  I wrote this simple die roller and was curious to know if it is  
R enough.


##
#
# Input:
#   die_size - 4, 6, 8, 10, 20
#   number_of_dice - How many dice to roll
#   number_of_rolls - How many times to roll the dice
#
# Output:
#rolls - The array holding the values of the dice
#
##
#
function(die_size, number_of_dice, number_of_rolls)
{
rolls <- array(0, dim=c(number_of_rolls, number_of_dice))

for (i in 1:number_of_rolls)
{
rolls[i,] <- sample(die_size, number_of_dice, replace=TRUE)
}

return(rolls)
}

Any thoughts on this function?  Is there a better way of doing it in  
R?  Can you tell I used to play AD&D?


Thanks,
Joe

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


Re: [R] Matrix

2009-02-02 Thread Gabor Grothendieck
Sorry, there was an error. Try this:

x <- matrix(1:4, 2)
y <- 10 * x
matrix(t(cbind(x, y)), nc = 2, byrow = TRUE)


On Mon, Feb 2, 2009 at 12:32 PM, Gabor Grothendieck
 wrote:
> Try this:
>
> matrix(rbind(x, y), nc = 2, byrow = TRUE)
>
>
> On Mon, Feb 2, 2009 at 10:52 AM, Shruthi Jayaram
>  wrote:
>>
>> Hi,
>>
>> I have a very basic question on merging two matrices by alternating the
>> rows. For illustration, assume two matrices -
>>
>> A looks like:
>>
>> 10 10
>> 10 10
>>
>> B looks like:
>>
>> 20 20
>> 20 20
>>
>> How do I combine them such that I get alternating rows from A and B? My
>> final result should be C which looks like:
>>
>> 10 10
>> 20 20
>> 10 10
>> 20 20
>>
>> Thanks very much, and I am sorry for such a newbie question.
>>
>> Shruthi
>> --
>> View this message in context: 
>> http://www.nabble.com/Matrix-tp21792064p21792064.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] Matrix

2009-02-02 Thread Gabor Grothendieck
Try this:

matrix(rbind(x, y), nc = 2, byrow = TRUE)


On Mon, Feb 2, 2009 at 10:52 AM, Shruthi Jayaram
 wrote:
>
> Hi,
>
> I have a very basic question on merging two matrices by alternating the
> rows. For illustration, assume two matrices -
>
> A looks like:
>
> 10 10
> 10 10
>
> B looks like:
>
> 20 20
> 20 20
>
> How do I combine them such that I get alternating rows from A and B? My
> final result should be C which looks like:
>
> 10 10
> 20 20
> 10 10
> 20 20
>
> Thanks very much, and I am sorry for such a newbie question.
>
> Shruthi
> --
> View this message in context: 
> http://www.nabble.com/Matrix-tp21792064p21792064.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] bootstrapping in regression

2009-02-02 Thread Greg Snow
Others have confirmed that you use the predicted values plus permuted residuals 
is the new y variable and also referred you to some other articles.

On the question of does this work for mixed effects models:  That is a good 
question, and it depends on what question you are trying to answer and what 
assumptions you are trying to make.  The mixed effects model is more 
complicated in that you not only have residuals that you are permuting, but 
possibly also random effects, depending on your question(s) of interest.  Then 
to further complicate things, you need to take into account any correlations 
between the different residuals/effects.

If you can work out a reduced model of interest under your null hypothesis, and 
see how to permute the other pieces in a way that preserves the correlation or 
works with assumed orthogonality.  Then it should work for you (but not be 
simple).

I would suggest that you try doing a bunch of simulations where you first 
create data sets that follow your null hypothesis (reduced model), then do the 
permutation test on them.  If everything is working correctly, then the 
p-values should follow a roughly uniform distribution (if not, then the 
permutation test is not working for your situation, your assumptions are not 
holding, or something else is messed up).  Doing the simulations will force you 
to think about all the pieces that go into the analysis and how reasonable your 
assumptions are.  If this works, then try simulating under the alternative 
(full model) to see what type of power you have to see the difference and 
compare that to other approaches.

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 Thomas Mang
> Sent: Thursday, January 29, 2009 3:52 PM
> To: r-h...@stat.math.ethz.ch
> Subject: Re: [R] bootstrapping in regression
> 
> Greg Snow wrote:
> > What you are describing is actually a permutation test rather than a
> bootstrap (related concepts but with a subtle but important
> difference).
> >
> > The way to do a permutation test with multiple x's is to fit the
> reduced model (use all x's other than x1 if you want to test x1) on the
> original data and store the fitted values and the residuals.
> >
> > Permute the residuals (randomize their order) and add them back to
> the fitted values and fit the full model (including x1 this time) to
> the permuted data set.  Do this a bunch of times and it will give you
> the sampling distribution for the slope on x1 (or whatever your set of
> interest is) when the null hypothesis that it is 0 given the other
> variables in the model is true.
> 
> Hi,
> 
> Thanks to you and Tom for the correction regarding bootstrapping vs
> permutation, and to Chuck for the cool link. Yes of course I described
> a
> permutation.
> 
> I have a question here: I am not sure if I understand your 'fit the
> full
> model ... to the permuted data set'. Am I correct to suppose that once
> the residuals of the reduced-model fit have been permuted and added
> back
> to the fitted values, the values obtained this way (fitted + permuted
> residuals) now constitute the new y-values to which the full model is
> fitted? Is that correct ?
> Do you know if this procedure is also valid for a mixed-effects model ?
> 
> thanks a lot,
> Thomas
> 
> 
> > Permuting just x1 only works if x1 is orthogonal to all the other
> predictors, otherwise the permuting destroys the relationship with the
> other predictors and does not do the test you want.
> >
> > Bootstrapping depends on sampling with replacement, not permuting,
> and is used more for confidence intervals than for tests (the reference
> by John Fox given to you in another reply can help if that is the
> approach you want to take).
> >
> > Hope this helps,
> >
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Odp: Matrix

2009-02-02 Thread baptiste auguie

Hi,

Perhaps this can help if you don't want to manually specify the  
permutation of indices,



A=matrix(10,ncol=2,nrow=2)
B <- 2*A
C <- rbind(A, B)

C[ as.vector(t(matrix(seq(1,nrow(C)),ncol=2))), ]  # trick to create  
the vector of permutations


 [,1] [,2]
[1,]   10   10
[2,]   20   20
[3,]   10   10
[4,]   20   20


The transpose operation might slow down the process on very large  
matrices, I'm not sure how to improve this.


Hope this helps,

baptiste


On 2 Feb 2009, at 17:02, Paul Smith wrote:

On Mon, Feb 2, 2009 at 4:05 PM, Petr PIKAL   
wrote:

Hi

r-help-boun...@r-project.org napsal dne 02.02.2009 16:52:06:



Hi,

I have a very basic question on merging two matrices by  
alternating the

rows. For illustration, assume two matrices -

A looks like:

10 10
10 10

B looks like:

20 20
20 20

How do I combine them such that I get alternating rows from A and  
B? My

final result should be C which looks like:

10 10
20 20
10 10
20 20


I would rbind both matrices and then indexed the resulting matrix.

x<-rep(10,4)
y<-rep(20,4)
dim(x)<-c(2,2)
dim(y)<-c(2,2)
z<-rbind(x,y)

z

   [,1] [,2]
[1,]   10   10
[2,]   10   10
[3,]   20   20
[4,]   20   20

ind<-c(seq(1,4,2), seq(2,4,2))
z[ind,]


z[ind,]

   [,1] [,2]
[1,]   10   10
[2,]   20   20
[3,]   10   10
[4,]   20   20



Another solution:

m1 <- matrix(10,4,2)
m2 <- matrix(20,2,2)
m1[seq(2,4,2),] <- m2

Paul

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


_

Baptiste Auguié

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

Phone: +44 1392 264187

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

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


Re: [R] Specifying the gap between "dodge'd" bins groups?

2009-02-02 Thread hadley wickham
Hi Jason,

On Mon, Feb 2, 2009 at 9:10 AM, Jason Rupert  wrote:
> I'm looking at ggplot-static\position_dodge.html
>
> For ggplot(diamonds, aes(x=price, fill=cut)) + geom_bar(position="dodge") , 
> is it possible to specify the spacing between the dodge'd bin groupings?
>
> That is, I would like for there to be a small separation (horizontal space) 
> between the "Ideal" and the "Fair" bars on the plot.  That way the reader can 
> get a better idea of when each bin ends and the other begins.
>
> I think this "horizontal spacing" naturally occurs for discrete data, but for 
> continuous data as is shown in the second figure, the bins all seem to right 
> beside each other.  It would be nice if a small space could be added.

You can do something like this:

ggplot(diamonds, aes(x=price, fill=cut)) +
geom_bar(position=position_dodge(width=400), binwidth=500)

Hadley

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

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


Re: [R] Odp: Matrix

2009-02-02 Thread Paul Smith
On Mon, Feb 2, 2009 at 4:05 PM, Petr PIKAL  wrote:
> Hi
>
> r-help-boun...@r-project.org napsal dne 02.02.2009 16:52:06:
>
>>
>> Hi,
>>
>> I have a very basic question on merging two matrices by alternating the
>> rows. For illustration, assume two matrices -
>>
>> A looks like:
>>
>> 10 10
>> 10 10
>>
>> B looks like:
>>
>> 20 20
>> 20 20
>>
>> How do I combine them such that I get alternating rows from A and B? My
>> final result should be C which looks like:
>>
>> 10 10
>> 20 20
>> 10 10
>> 20 20
>
> I would rbind both matrices and then indexed the resulting matrix.
>
> x<-rep(10,4)
> y<-rep(20,4)
> dim(x)<-c(2,2)
> dim(y)<-c(2,2)
> z<-rbind(x,y)
>> z
> [,1] [,2]
> [1,]   10   10
> [2,]   10   10
> [3,]   20   20
> [4,]   20   20
>
> ind<-c(seq(1,4,2), seq(2,4,2))
> z[ind,]
>
>> z[ind,]
> [,1] [,2]
> [1,]   10   10
> [2,]   20   20
> [3,]   10   10
> [4,]   20   20
>

Another solution:

m1 <- matrix(10,4,2)
m2 <- matrix(20,2,2)
m1[seq(2,4,2),] <- m2

Paul

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


Re: [R] how to generate multiple random variables that are correlated

2009-02-02 Thread Ben Bolker
eric lee  gmail.com> writes:

[snip]

> 
> Is there an R function that generates random values for my two
> variables given the correlation?  I'd like to do this for up to 5
> variables and I'm running version 2.7.2 on a windows platform.
> Thanks.

  ?MASS::mvrnrom

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Specifying the gap between "dodge'd" bins groups?

2009-02-02 Thread Jason Rupert
I'm looking at ggplot-static\position_dodge.html
 
For ggplot(diamonds, aes(x=price, fill=cut)) + geom_bar(position="dodge") , is 
it possible to specify the spacing between the dodge'd bin groupings?  
 
That is, I would like for there to be a small separation (horizontal 
space) between the "Ideal" and the "Fair" bars on the plot.  That way the 
reader can get a better idea of when each bin ends and the other begins.  
 
I think this "horizontal spacing" naturally occurs for discrete data, but for 
continuous data as is shown in the second figure, the bins all seem to right 
beside each other.  It would be nice if a small space could be added. 
 
Thank you agian for your help and feedback. 


  
[[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] Error message when executing summary() with dataset diamonds in ggplot2

2009-02-02 Thread Jim Watkins
Hi:  I am experiencing a problem with dataset diamonds in ggplot2.  When
trying execute the summary(diamonds) statement, the following error message
is displayed:
Error in summary(diamonds) :
Cannot open file
'C:/Users/James/R_Pgms/R/R-2.8.1/library/ggplot2/data/Rdata.rdb': No such
file or directory

Can you please advise me?

A complete history of commands leading up to this problem is as follows.  I
have also included in this history a set of parallel statements (involving a
different dataset, Davis, in a different package, car) for which the summary
command executed OK.  My first three commands were as follows:
> library(car)
> library(ggplot2)
> search()
The displayed results of the search command confirmed that both packages
were now in the search path.  

The next three commands were as follows:
> data(Davis)
> data(diamonds)
> ls()
The displayed results of the list command confirmed that both datasets were
in the workspace.  

Next, the following  statement provided the expected dataframe summary
> summary(Davis)
However, a similar statement for the dataframe diamonds resulted in the
error message described above.

I am running on a PC with Vista and SP1  The sessionInfo() command displayed
the following:
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] grid  stats graphics  grDevices datasets  utils methods  
[8] base 

other attached packages:
[1] ggplot2_0.8.1   reshape_0.8.2   plyr_0.1.4  proto_0.3-8
[5] car_1.2-11  rcom_2.0-4  rscproxy_1.0-12

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

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


Re: [R] how to generate multiple random variables that are correlated

2009-02-02 Thread Jorge Ivan Velez
Dear Eric,
See ?mvrnorm in the MASS package.


HTH,

Jorge



On Mon, Feb 2, 2009 at 11:15 AM, eric lee  wrote:

> Hi.
>
> I have two variables, x and y, that are each normally distributed with
> mean 0 and have known standard deviations.  The variables also have a
> known correlation, so I can represent their correlations in a matrix
> like so:
>
> a <- array(c(0.3,0.1,0.1,0.2),c(2,2))
> a
>
> Is there an R function that generates random values for my two
> variables given the correlation?  I'd like to do this for up to 5
> variables and I'm running version 2.7.2 on a windows platform.
> Thanks.
>
> eric
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


[R] how to generate multiple random variables that are correlated

2009-02-02 Thread eric lee
Hi.

I have two variables, x and y, that are each normally distributed with
mean 0 and have known standard deviations.  The variables also have a
known correlation, so I can represent their correlations in a matrix
like so:

a <- array(c(0.3,0.1,0.1,0.2),c(2,2))
a

Is there an R function that generates random values for my two
variables given the correlation?  I'd like to do this for up to 5
variables and I'm running version 2.7.2 on a windows platform.
Thanks.

eric

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


[R] Odp: Matrix

2009-02-02 Thread Petr PIKAL
Hi

r-help-boun...@r-project.org napsal dne 02.02.2009 16:52:06:

> 
> Hi,
> 
> I have a very basic question on merging two matrices by alternating the
> rows. For illustration, assume two matrices -
> 
> A looks like:
> 
> 10 10
> 10 10
> 
> B looks like:
> 
> 20 20
> 20 20 
> 
> How do I combine them such that I get alternating rows from A and B? My
> final result should be C which looks like:
> 
> 10 10 
> 20 20
> 10 10
> 20 20

I would rbind both matrices and then indexed the resulting matrix.

x<-rep(10,4)
y<-rep(20,4)
dim(x)<-c(2,2)
dim(y)<-c(2,2)
z<-rbind(x,y)
> z
 [,1] [,2]
[1,]   10   10
[2,]   10   10
[3,]   20   20
[4,]   20   20

ind<-c(seq(1,4,2), seq(2,4,2))
z[ind,]
 
> z[ind,]
 [,1] [,2]
[1,]   10   10
[2,]   20   20
[3,]   10   10
[4,]   20   20

Regards
Petr


> 
> Thanks very much, and I am sorry for such a newbie question.
> 
> Shruthi
> -- 
> View this message in context: 
http://www.nabble.com/Matrix-tp21792064p21792064.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] Defining plot colors based on a variable

2009-02-02 Thread Andrew Singleton
Hadley and Thierry, thank you ­ ggplot2 is a great package and this worked
perfectly.


On 2/2/09 10:10 AM, "hadley wickham"  wrote:

> On Mon, Feb 2, 2009 at 8:56 AM, Andrew Singleton 
> wrote:
>> > Hi, I have been trying unsuccessfully to plot data using different colors
>> > based on a variable within a subset of an imported file. The file I am
>> > reading is about 2 lines long and has a column (in the example called
>> > FILE) that contains approximately 100 unique entries. I would like to plot
a
>> > subset of the data from the file and key the color from the FILE column,
>> > This is what my file looks like :
>> >
>> > CHR  SNP BPNMISS   BETA SE R2
>> > TPREGIONFILERANDOM
>> >   1  rs17035189   10519610  135 0.3518  1.928  0.0002501
>> > 0.1824   0.8555 TCTX47303410.284627081
>> >   6   rs3763311   32484154  109  -2.05  1.6240.01467
>> > -1.262   0.2096 TCTX6706030.083147673
>> >   6   rs3892710   32790839  106 0.5695  4.743  0.0001386
>> > 0.1201   0.9047 TCTX71504030.549192815
>> >   6   rs3864300   32379785  102  9.208  6.4160.02018
>> > 1.435   0.1544 TCTX72100170.837265988
>> >   6   rs6912002   32873245   13 -1.295  5.043   0.005963
>> > -0.25690.802 TCTX27104410.170566699
>> >   5rs4024109   359553749  26.19  31.010.09245
>> > 0.8444   0.4263 TCTX26506530.298573497
>> >   6   rs3129719   32769757   16  10.35   7.44 0.1215
>> > 1.391   0.1859 TCTX29005040.378538235
>> >   6rs476885   32402690  109   -0.09378  1.552  3.411e-05
>> > -0.06041   0.9519 TCTX6706030.017970964
>> >  10   rs125707665602540  139 0.6182   6.66  6.289e-05
>> > 0.09283   0.9262 TCTX45607670.004973939
>> > etc
>> >
>> >
>> > And this is the code that I have:
>> >
>> > assoc_data <- read.table("master.out", header =TRUE)
>> > par(fig=c(0, 10, 0,  10 )/10, mar=c(10,8,2,8),xpd=NA, cex.axis=2)
>> > attach(assoc_data)
>> > curr_assoc <- assoc_data[CHR == 1 & BP > 50 & BP < 100, ] #these
>> > criteria change based on input from another file
>> >
>> > #count the number of transcripts
>> > transcripts <- length(unique(curr_assoc$FILE))
>> >
>> > #generate that number of unique ³FILE² entries in my subset of data
>> > my_colors <- rainbow(transcripts)
>> >
>> > plot(curr_assoc$BP, log10(curr_assoc$P)*-1, pch=20,
>> > col=c(my_colors)[curr_assoc$FILE], ylim=c(-15, 15),xaxs="i", xlab=NA,
>> > cex=0.7, cex.lab=2)
>> > detach(assoc_data)
> 
> You might find it easier to use ggplot2:
> 
> install.packages("ggplot2")
> library(ggplot2)
> 
> qplot(BP, P, data = curr_assoc, colour = FILE, log="y")
> 
> To ensure that you always have the same colours, you can set the
> limits for the colour scale (in analogous way to setting the limits
> for the x axis):
> 
> qplot(BP, P, data = curr_assoc, colour = FILE, log="y") +
> scale_colour_hue(limits = c(2, 7, 12, 34, 60, 64, 65, 70, 71))
> 
> Hadley
> 
> --
> http://had.co.nz/
> 

Dear Andrew,

Have a look at ggplot2

library(ggplot2)
ggplot(curr_assoc, aes(x = BP, y = P, colour = FILE)) + geom_point() +
scale_y_log10()

HTH,

Thierry



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

To call in the statistician after the experiment is done may be no more than
asking him to perform a post-mortem examination: he may be able to say what
the experiment died of.
~ Sir Ronald Aylmer Fisher

[[alternative HTML version deleted]]

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


Re: [R] Problem with foreign package

2009-02-02 Thread Kevin E. Thorpe

Prof Brian Ripley wrote:

On Mon, 2 Feb 2009, Duncan Murdoch wrote:


On 2/2/2009 8:46 AM, Kevin E. Thorpe wrote:
I tried to use write.foreign() to export to SAS this morning and got 
an error.


When I looked at the code for writeForeignSAS() I saw this line:

dfn < -df

which I think should be

dfn <- df

So, I tried to run update.packages() to see if there was an updated 
version and got the following result.


That bug was fixed a few weeks ago, but a new version has not been 
released yet.  You can get the latest source from svn:


https://svn.r-project.org/R-packages/trunk/foreign


Yes, and there is a good reason.  No less than 3 people reported 
problems in 0.8-29 without reproducible examples.  When I releaseed 
0.8-30, I asked them to test it.  Despite reminders, I am still waiting 
for any answer, and will wait another week.


It really is unhelpful to report problems and not be prepared to answer 
follow-up questions nor test solutions.




Well, I installed the new version, and my export to SAS worked.


--
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.6057

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

2009-02-02 Thread Shruthi Jayaram

Hi,

I have a very basic question on merging two matrices by alternating the
rows. For illustration, assume two matrices -

A looks like:

10 10
10 10

B looks like:

20 20
20 20 

How do I combine them such that I get alternating rows from A and B? My
final result should be C which looks like:

10 10 
20 20
10 10
20 20

Thanks very much, and I am sorry for such a newbie question.

Shruthi
-- 
View this message in context: 
http://www.nabble.com/Matrix-tp21792064p21792064.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 with foreign package

2009-02-02 Thread Prof Brian Ripley

On Mon, 2 Feb 2009, Duncan Murdoch wrote:


On 2/2/2009 8:46 AM, Kevin E. Thorpe wrote:
I tried to use write.foreign() to export to SAS this morning and got an 
error.


When I looked at the code for writeForeignSAS() I saw this line:

dfn < -df

which I think should be

dfn <- df

So, I tried to run update.packages() to see if there was an updated version 
and got the following result.


That bug was fixed a few weeks ago, but a new version has not been released 
yet.  You can get the latest source from svn:


https://svn.r-project.org/R-packages/trunk/foreign


Yes, and there is a good reason.  No less than 3 people reported 
problems in 0.8-29 without reproducible examples.  When I releaseed 
0.8-30, I asked them to test it.  Despite reminders, I am still 
waiting for any answer, and will wait another week.


It really is unhelpful to report problems and not be prepared to 
answer follow-up questions nor test solutions.


--
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] error message with roxygen

2009-02-02 Thread David Hajage
Thank you Hadley!

2009/2/2 hadley wickham 

> On Fri, Jan 30, 2009 at 3:49 AM, David Hajage  wrote:
> > Hello useRs,
> >
> > I'm trying to use the Roxygen package.
> >
> > Here my code file :
> > #' A packge to check Roxygen's sanity
> > #' @name helloRoxygen-package
> > #' @docType package
> > NA
> >
> > And my R code to generate the package :
> > library(roxygen)
> > package.skeleton("helloRoxygen", code_files = "roxy.r", force = T)
> > roxygenize("helloRoxygen", "helloRoxygen", copy.package = F,
> unlink.target =
> > F, overwrite = T)
> >
> > I obtain this error message :
> > Writing helloRoxygen-package to helloRoxygen/man/helloRoxygen-package.Rd
> > Writing namespace directives to helloRoxygen/NAMESPACE
> > Merging collate directive with helloRoxygen/DESCRIPTION to
> > helloRoxygen/DESCRIPTION
> > *Avis dans load.dependencies() :
> >  Package(s) 'helloRoxygen' wouldn't load; callgraphs might be
> incomplete.*
> >
> > I don't understand what this means. I'm doing something wrong?
>
> That's not an error - just a warning.  You can't get complete call
> graphs (if you need them) unless you've already installed your
> helloRoxygen package.  If you're not using the call graphs, don't
> worry about it.
>
> Hadley
>
> --
> http://had.co.nz/
>

[[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] error message with roxygen

2009-02-02 Thread hadley wickham
On Fri, Jan 30, 2009 at 3:49 AM, David Hajage  wrote:
> Hello useRs,
>
> I'm trying to use the Roxygen package.
>
> Here my code file :
> #' A packge to check Roxygen's sanity
> #' @name helloRoxygen-package
> #' @docType package
> NA
>
> And my R code to generate the package :
> library(roxygen)
> package.skeleton("helloRoxygen", code_files = "roxy.r", force = T)
> roxygenize("helloRoxygen", "helloRoxygen", copy.package = F, unlink.target =
> F, overwrite = T)
>
> I obtain this error message :
> Writing helloRoxygen-package to helloRoxygen/man/helloRoxygen-package.Rd
> Writing namespace directives to helloRoxygen/NAMESPACE
> Merging collate directive with helloRoxygen/DESCRIPTION to
> helloRoxygen/DESCRIPTION
> *Avis dans load.dependencies() :
>  Package(s) 'helloRoxygen' wouldn't load; callgraphs might be incomplete.*
>
> I don't understand what this means. I'm doing something wrong?

That's not an error - just a warning.  You can't get complete call
graphs (if you need them) unless you've already installed your
helloRoxygen package.  If you're not using the call graphs, don't
worry about it.

Hadley

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

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


Re: [R] Problems in Recommending R

2009-02-02 Thread hadley wickham
> We often get emails like the first in this thread that R could do with
> an update on homepage design (I fully agree) ... but actually nobody
> volunteers to do it. Hence, we still have what I did when the
> worldwide number of R users was probably less than 1000.

Well I've volunteered a couple of times but no one took me up on the offer...

I'm not sure a competition to redesign the homepage is the best way to
go.  Why not start a fund to hire a professional designer to look at
all aspects of the R website?

Hadley


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

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


[R] Outliers package function scores question

2009-02-02 Thread diego Diego
Dear R-experts,
 I'm having some doubts concernig the scores function of the "outliers"
package. I don´t understand the results when I select the p-value option on
a sample, ie, when I use scores(x,"(method)",1). The help on the function
says that the output are the p-values associatted to the sample. But for
example:

 >ser[[8]]
 Jan   Feb   Mar   Apr   May   Jun   Jul  Aug  Sep  Oct  Nov  Dec
2005
82
2006 3139 2380 1462 2897 2961 6501  686 1550 2124 2743 2652 2807
2007 2759 2974 3235 2928  606 6113 3493 2796 3607 2008 2544 3517
2008 1791 5132 3558 2898 1730 3352 2338 2462

>scores(ser[[8]],"mad",1)

Jan  Feb  Mar  Apr  May
2005
2006 0.6613307497 0.3069006015 0.0527997798 0.5487581386 0.5793236926
2007 0.4820994162 0.5854804388 0.7028297078 0.5636110196 0.0039452802
2008 0.1113882364 0.9977003225 0.8223588740 0.5492384458 0.0979746949
  Jun  Jul  Aug  Sep  Oct
2005
2006 0.965147 0.0052386075 0.0653256352 0.2074755271 0.4743676743
2007 0.713783 0.8010952047 0.50 0.8374015640 0.1695530561
2008 0.753207 0.2892402178 0.3426727125
  Nov  Dec
2005  0.0004967017
2006 0.4306622988 0.5053234242
2007 0.3799148443 0.8091190064
2008

but when I choose the significance:

> scores(ser[[8]],"mad",0.99)
  Jan   Feb   Mar  Apr May Jun  Jul
Aug   Sep   OctNov Dec
2005
 TRUE
2006 FALSE FALSE FALSE FALSE FALSE  TRUE  TRUE FALSE FALSE FALSE FALSE FALSE
2007 FALSE FALSE FALSE FALSE  TRUE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE
2008 FALSE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE



Note that the higer values get p-value-scores around 0.99 and above, but
small values like "83" get a score of  0.0004967017. So, first, which is the
null hypothesis for these calculations??, now second, why the p-values have
these values???, and third, how must I interpreter the p values returned by
this function?


Thanks

[[alternative HTML version deleted]]

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


Re: [R] Defining plot colors based on a variable

2009-02-02 Thread hadley wickham
On Mon, Feb 2, 2009 at 8:56 AM, Andrew Singleton  wrote:
> Hi, I have been trying unsuccessfully to plot data using different colors
> based on a variable within a subset of an imported file. The file I am
> reading is about 2 lines long and has a column (in the example called
> FILE) that contains approximately 100 unique entries. I would like to plot a
> subset of the data from the file and key the color from the FILE column,
> This is what my file looks like :
>
> CHR  SNP BPNMISS   BETA SE R2
> TPREGIONFILERANDOM
>   1  rs17035189   10519610  135 0.3518  1.928  0.0002501
> 0.1824   0.8555 TCTX47303410.284627081
>   6   rs3763311   32484154  109  -2.05  1.6240.01467
> -1.262   0.2096 TCTX6706030.083147673
>   6   rs3892710   32790839  106 0.5695  4.743  0.0001386
> 0.1201   0.9047 TCTX71504030.549192815
>   6   rs3864300   32379785  102  9.208  6.4160.02018
> 1.435   0.1544 TCTX72100170.837265988
>   6   rs6912002   32873245   13 -1.295  5.043   0.005963
> -0.25690.802 TCTX27104410.170566699
>   5rs4024109   359553749  26.19  31.010.09245
> 0.8444   0.4263 TCTX26506530.298573497
>   6   rs3129719   32769757   16  10.35   7.44 0.1215
> 1.391   0.1859 TCTX29005040.378538235
>   6rs476885   32402690  109   -0.09378  1.552  3.411e-05
> -0.06041   0.9519 TCTX6706030.017970964
>  10   rs125707665602540  139 0.6182   6.66  6.289e-05
> 0.09283   0.9262 TCTX45607670.004973939
> etc
>
>
> And this is the code that I have:
>
> assoc_data <- read.table("master.out", header =TRUE)
> par(fig=c(0, 10, 0,  10 )/10, mar=c(10,8,2,8),xpd=NA, cex.axis=2)
> attach(assoc_data)
> curr_assoc <- assoc_data[CHR == 1 & BP > 50 & BP < 100, ] #these
> criteria change based on input from another file
>
> #count the number of transcripts
> transcripts <- length(unique(curr_assoc$FILE))
>
> #generate that number of unique ³FILE² entries in my subset of data
> my_colors <- rainbow(transcripts)
>
> plot(curr_assoc$BP, log10(curr_assoc$P)*-1, pch=20,
> col=c(my_colors)[curr_assoc$FILE], ylim=c(-15, 15),xaxs="i", xlab=NA,
> cex=0.7, cex.lab=2)
> detach(assoc_data)

You might find it easier to use ggplot2:

install.packages("ggplot2")
library(ggplot2)

qplot(BP, P, data = curr_assoc, colour = FILE, log="y")

To ensure that you always have the same colours, you can set the
limits for the colour scale (in analogous way to setting the limits
for the x axis):

qplot(BP, P, data = curr_assoc, colour = FILE, log="y") +
scale_colour_hue(limits = c(2, 7, 12, 34, 60, 64, 65, 70, 71))

Hadley

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

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


Re: [R] Defining plot colors based on a variable

2009-02-02 Thread ONKELINX, Thierry
Dear Andrew,

Have a look at ggplot2

library(ggplot2)
ggplot(curr_assoc, aes(x = BP, y = P, colour = FILE)) + geom_point() + 
scale_y_log10()

HTH,

Thierry 



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

To call in the statistician after the experiment is done may be no more than 
asking him to perform a post-mortem examination: he may be able to say what the 
experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not ensure 
that a reasonable answer can be extracted from a given body of data.
~ John Tukey

-Oorspronkelijk bericht-
Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens 
Andrew Singleton
Verzonden: maandag 2 februari 2009 15:56
Aan: r-help@r-project.org
Onderwerp: [R] Defining plot colors based on a variable

Hi, I have been trying unsuccessfully to plot data using different colors
based on a variable within a subset of an imported file. The file I am
reading is about 2 lines long and has a column (in the example called
FILE) that contains approximately 100 unique entries. I would like to plot a
subset of the data from the file and key the color from the FILE column,
This is what my file looks like :

CHR  SNP BPNMISS   BETA SE R2
TPREGIONFILERANDOM
   1  rs17035189   10519610  135 0.3518  1.928  0.0002501
0.1824   0.8555 TCTX47303410.284627081
   6   rs3763311   32484154  109  -2.05  1.6240.01467
-1.262   0.2096 TCTX6706030.083147673
   6   rs3892710   32790839  106 0.5695  4.743  0.0001386
0.1201   0.9047 TCTX71504030.549192815
   6   rs3864300   32379785  102  9.208  6.4160.02018
1.435   0.1544 TCTX72100170.837265988
   6   rs6912002   32873245   13 -1.295  5.043   0.005963
-0.25690.802 TCTX27104410.170566699
   5rs4024109   359553749  26.19  31.010.09245
0.8444   0.4263 TCTX26506530.298573497
   6   rs3129719   32769757   16  10.35   7.44 0.1215
1.391   0.1859 TCTX29005040.378538235
   6rs476885   32402690  109   -0.09378  1.552  3.411e-05
-0.06041   0.9519 TCTX6706030.017970964
  10   rs125707665602540  139 0.6182   6.66  6.289e-05
0.09283   0.9262 TCTX45607670.004973939
etc 


And this is the code that I have:

assoc_data <- read.table("master.out", header =TRUE)
par(fig=c(0, 10, 0,  10 )/10, mar=c(10,8,2,8),xpd=NA, cex.axis=2)
attach(assoc_data)
curr_assoc <- assoc_data[CHR == 1 & BP > 50 & BP < 100, ] #these
criteria change based on input from another file

#count the number of transcripts
transcripts <- length(unique(curr_assoc$FILE))

#generate that number of unique ³FILE² entries in my subset of data
my_colors <- rainbow(transcripts)

plot(curr_assoc$BP, log10(curr_assoc$P)*-1, pch=20,
col=c(my_colors)[curr_assoc$FILE], ylim=c(-15, 15),xaxs="i", xlab=NA,
cex=0.7, cex.lab=2)
detach(assoc_data)


The problem is that when I plot this I only see (for example) 2 colors
instead of the expected 10. I believe that the problem I am having is that
the FILE column is being recoded when I read the table (as a factor?) and
that only factors within the range of my colors are being plotted (so if I
have 10 colors but there are 100 unique entries in my FILE column, and the
variables recoded 2, 7, 12, 34, 60, 64, 65, 70 and 71 are used, only 2 and 7
will be plotted). 

Many thanks for any suggestions/pointers, I have dug around in the help
archives for a couple of hours but no joy.
---
Andrew Singleton


[[alternative HTML version deleted]]


Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed 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.


Re: [R] concatenating 2 text columns in a data.frame

2009-02-02 Thread Philipp Pagel
On Mon, Feb 02, 2009 at 09:44:28AM -0500, Shaun Grannis wrote:
> I'm trying to concatenate values from two columns in a data frame. For  
> example, I have the following data.frame:
>
> C1  C2  C3  C4  C5
> A   B   *F   C*   Q
> G   H   *I   J*   T
> K   D   *R   S*   E
> P   L   *M   N*   O
>
> I'd like to concatenate text from columns C3 and C4, to yield either a  
> list or vector, like so:
>
> NewCol
>  FC
>  IJ
>  RS
>  MN

assuming your data frame is named foo:

foo$NewCol <- paste(foo$C3, foo$C4, sep='')

cu
Philipp

-- 
Dr. Philipp Pagel
Lehrstuhl für Genomorientierte Bioinformatik
Technische Universität München
Wissenschaftszentrum Weihenstephan
85350 Freising, Germany
http://mips.gsf.de/staff/pagel

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Defining plot colors based on a variable

2009-02-02 Thread Andrew Singleton
Hi, I have been trying unsuccessfully to plot data using different colors
based on a variable within a subset of an imported file. The file I am
reading is about 2 lines long and has a column (in the example called
FILE) that contains approximately 100 unique entries. I would like to plot a
subset of the data from the file and key the color from the FILE column,
This is what my file looks like :
 
CHR  SNP BPNMISS   BETA SE R2
TPREGIONFILERANDOM
   1  rs17035189   10519610  135 0.3518  1.928  0.0002501
0.1824   0.8555 TCTX47303410.284627081
   6   rs3763311   32484154  109  -2.05  1.6240.01467
-1.262   0.2096 TCTX6706030.083147673
   6   rs3892710   32790839  106 0.5695  4.743  0.0001386
0.1201   0.9047 TCTX71504030.549192815
   6   rs3864300   32379785  102  9.208  6.4160.02018
1.435   0.1544 TCTX72100170.837265988
   6   rs6912002   32873245   13 -1.295  5.043   0.005963
-0.25690.802 TCTX27104410.170566699
   5rs4024109   359553749  26.19  31.010.09245
0.8444   0.4263 TCTX26506530.298573497
   6   rs3129719   32769757   16  10.35   7.44 0.1215
1.391   0.1859 TCTX29005040.378538235
   6rs476885   32402690  109   -0.09378  1.552  3.411e-05
-0.06041   0.9519 TCTX6706030.017970964
  10   rs125707665602540  139 0.6182   6.66  6.289e-05
0.09283   0.9262 TCTX45607670.004973939
etc 


And this is the code that I have:

assoc_data <- read.table("master.out", header =TRUE)
par(fig=c(0, 10, 0,  10 )/10, mar=c(10,8,2,8),xpd=NA, cex.axis=2)
attach(assoc_data)
curr_assoc <- assoc_data[CHR == 1 & BP > 50 & BP < 100, ] #these
criteria change based on input from another file

#count the number of transcripts
transcripts <- length(unique(curr_assoc$FILE))

#generate that number of unique ³FILE² entries in my subset of data
my_colors <- rainbow(transcripts)

plot(curr_assoc$BP, log10(curr_assoc$P)*-1, pch=20,
col=c(my_colors)[curr_assoc$FILE], ylim=c(-15, 15),xaxs="i", xlab=NA,
cex=0.7, cex.lab=2)
detach(assoc_data)


The problem is that when I plot this I only see (for example) 2 colors
instead of the expected 10. I believe that the problem I am having is that
the FILE column is being recoded when I read the table (as a factor?) and
that only factors within the range of my colors are being plotted (so if I
have 10 colors but there are 100 unique entries in my FILE column, and the
variables recoded 2, 7, 12, 34, 60, 64, 65, 70 and 71 are used, only 2 and 7
will be plotted). 

Many thanks for any suggestions/pointers, I have dug around in the help
archives for a couple of hours but no joy.
---
Andrew Singleton


[[alternative HTML version deleted]]

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


Re: [R] Problems in Recommending R

2009-02-02 Thread stephen sefick
I offer my time in this particular pursuit.  Although, the website is
functional and I wonder if statisticians and other scientists care
about the aesthetics of the website.  R is incredibly useful to me,
and until this conversation I didn't even realize that the website was
a little old school, but I may be an outlier.  Because it is useful-
spartanic, I believe, was used earlier and I agree.  However, if the
group thinks it would be a useful pursuit then I will help any way
that I can.

Stephen Sefick

On Mon, Feb 2, 2009 at 8:41 AM, Ajay ohri  wrote:
> yes html and css can be pretty.
> the point is if we can do so much collective and individual  work in
> suggesting,creating,maintaining much more complex codes- how much time would
> it take to replace the html of the home page?
>
> hmm ..
>
> who decides to create the Official 2009 Website Design Contest is now open
> for entries ?
>
>
>   - submit html and css only pages by such and such date...
>
>
>   - winners choosen by vote among common publicand judges and fans and
>   media
>
>
>   - award /prize is mention and hyperlink (nofollow tag) and bragging
>   rights and free lodging and tickets to the annual R conference and  extra
>   credits for passing the dissertation exam and A in Stats 303 and sip of
>   vintage beer /wine /schnapps/vodka. and ..
>
>
> regards,
>
> Ajay
>
>
> Samuel Goldwyn  - "I had a monumental idea this morning, but I didn't like
> it."
>
> On Mon, Feb 2, 2009 at 6:45 PM, wrote:
>
>> > On Mon, 2 Feb 2009 18:14:03 +0530,
>> > Ajay ohri (Ao) wrote:
>>
>>  > Plain HTML coding is simple enough for this list ( I think)...but
>> aesthetic
>>  > designhmm
>>
>> In most cases one can do more than most think using HTML and CSS: Our
>> universities corporate design was done by "professionals" and is backed
>> by a CMS:
>>
>>  http://www.uni-muenchen.de
>>
>> Our dpertment didn't want to use the CMS, so we emulated it using
>> HTML, CSS and iframes:
>>
>>  http://www.stat.uni-muenchen.de/
>>
>> which is *much* more convenient to maintain for us: I have a copy of
>> my page on my laptop, I can work on it while offline on a train, etc.
>>
>> I don't want to discuss whether the above examples are aesthetic or
>> not (we are required to follow the coporate design, so have no
>> choice). The main point I want to make is: that everything is static
>> HTML makes life very easy for command line junkies like me ;-)
>>
>> Best,
>> Fritz
>>
>> --
>> ---
>> Prof. Dr. Friedrich Leisch
>>
>> Institut für Statistik  Tel: (+49 89) 2180 3165
>> Ludwig-Maximilians-Universität  Fax: (+49 89) 2180 5308
>> Ludwigstraße 33
>> D-80539 München http://www.statistik.lmu.de/~leisch
>> ---
>>   Journal Computational Statistics --- http://www.springer.com/180
>>  Münchner R Kurse --- http://www.statistik.lmu.de/R
>> ---
>>
>>
>
>[[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.
>
>



-- 
Stephen Sefick

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

-K. Mullis

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


  1   2   >