Re: [R] sum specific rows in a data frame

2010-04-15 Thread Jeff Newmiler
This is good news, although I have recently encountered what I consider 
excessive memory usage in the addition of key columns that don't affect the 
number of groups.  For example, grouping by Year and Month, if I add 
MonthBegin, a POSIXct column from which the Year and Month columns were 
derived, I run out of memory. 

hadley wickham  wrote:

>On Thu, Apr 15, 2010 at 1:16 AM, Chuck  wrote:
>> Depending on the size of the dataframe and the operations you are
>> trying to perform, aggregate or ddply may be better.  In the function
>> below, df has the same structure as your dataframe.
>
>Current version of plyr:
>
> agg  ddply
>X100.005  0.007
>X100   0.007  0.026
>X1000  0.086  0.248
>X1 0.577  3.136
>X1e.05 4.493 44.147
>
>Development version of plyr:
>
> agg ddply
>X100.003 0.005
>X100   0.007 0.007
>X1000  0.042 0.044
>X1 0.410 0.443
>X1e.05 4.479 4.237
>
>So there are some big speed improvements in the works.
>
>Hadley
>
>
>-- 
>Assistant Professor / Dobelman Family Junior Chair
>Department of Statistics / Rice University
>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-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 CMD REMOVE etc. query

2010-04-15 Thread Prof. John C Nash
I've been working on a fairly complex package that is a wrapper for several optimization 
routines. In this work, I've attempted to do the following:


- edit the package code   foo.R
- in a root terminal at the right directory location
R CMD REMOVE foo
R CMD INSTALL foo

However, I don't get the right code. In fact, if I just do the remove,

library(foo)

does not throw an error. If I stop my R session and restart it, I do.

Is this expected behaviour?

For information, I run scripted tests that start with
   rm(list=ls())
   library(foo)

to ensure I'm getting "new" code each time.

If desired I can provide a minimal package to show this, but I expect that it is a known 
issue for which I've missed the documentation. Perhaps there is a command to reset the

session. I did a brief search, but appropriate keywords pick up a lot of 
irrelevant material.

JN

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


Re: [R] sum specific rows in a data frame

2010-04-15 Thread hadley wickham
On Thu, Apr 15, 2010 at 1:16 AM, Chuck  wrote:
> Depending on the size of the dataframe and the operations you are
> trying to perform, aggregate or ddply may be better.  In the function
> below, df has the same structure as your dataframe.

Current version of plyr:

 agg  ddply
X100.005  0.007
X100   0.007  0.026
X1000  0.086  0.248
X1 0.577  3.136
X1e.05 4.493 44.147

Development version of plyr:

 agg ddply
X100.003 0.005
X100   0.007 0.007
X1000  0.042 0.044
X1 0.410 0.443
X1e.05 4.479 4.237

So there are some big speed improvements in the works.

Hadley


-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
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] curve

2010-04-15 Thread Duncan Murdoch

On 14/04/2010 4:59 PM, Dwayne Blind wrote:

Dear R users,

How can I use "curve" with a function of two variables ?
  


See Ben Bolker's reply if you want to plot a surface.  If you want to 
plot a curve by holding one of the two variables fixed, just set it to a 
constant value, and use "x" as the other variable, e.g.


f <- function(x, y) { x^2 + y^2 }

curve(f(x, 2), from=  )

curve(f(3, x), from=  )

or wrap the function in a one variable function if you want to follow 
some complicated path, e.g.


curve(function(t) f(t, t^2), from=)

Duncan Murdoch

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


[R] Alignment of x-axis labels

2010-04-15 Thread Steve Murray

Dear all,

I'm having trouble getting the correct spacing between x-axis labels on a 
barplot. This is the command I'm using to generate the plot:

temp <- barplot(precip, beside=TRUE, xaxt="n", las=1, xpd=FALSE, col="grey28", 
ylim=c(0, max(precip)))

Here is the structure of temp:
> str(temp)
 num [1:96, 1] 0.7 1.9 3.1 4.3 5.5 6.7 7.9 9.1 10.3 11.5 ...

And here is the structure of the data being plotted:
> str(precip)
 num [1:96] 1841 2871 9254 22335 30682 ...

> length(precip)
[1] 96

These are monthly data points for 8 years (8 * 12 = 96), but I only want to 
have labels for each year (1978 to 1985), rather than every month. So I tried 
using the following command, but this results in the labels not being far 
enough apart, and therefore they don't fill the length of the x-axis (and don't 
align properly with the corresponding first bar of every year):

axis(1, at=seq(1,96,12), 1978:1985)


This one has stumped me somewhat, so I'd be grateful to receive any suggestions 
as to how I might resolve this.

Many thanks,

Steve
  
_

We want to hear all your funny, exciting and crazy Hotmail stories. Tell us now
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Weighted Spearman Correlation with significance test

2010-04-15 Thread Антон Морковин
Hi all,
does anybody know a useful function in R to calculate Weighted Spearman 
Correlation with p-values, particularly for matrices?

Thanks,

A. Morkovin

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


Re: [R] sum() returns 0 not NA

2010-04-15 Thread David Winsemius


On Apr 15, 2010, at 8:37 AM, Wilmar Igl wrote:


Dear all,

just a stupid R question, since the results puzzle me a bit:


sum(c(NA,NA), na.rm=TRUE)

[1] 0

NA + NA

[1] NA

NA + 1

[1] NA




Why does sum(c(NA,NA), na.rm=TRUE) return 0 and not NA?



> sum(c())
[1] 0

?sum

"NB: the sum of an empty set is zero, by definition."

--
David Winsemius, MD
West Hartford, CT

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] [announce] yeroon.net/ggplot2 web application v0.2

2010-04-15 Thread Jeroen Ooms

A new version of the ggplot2 web interface has been released. Info and a demo
video are available here: http://www.stat.ucla.edu/~jeroen/ggplot2/. The new
version has a lot of new features, like advanced data import, integration
with Google docs, converting variables from numeric to factor to dates and
vice versa, and a lot of new geom's. 

For those that missed it: http://yeroon.net/ggplot2 is a web interface for
Hadley Wickham's R package ggplot2. It is used as a tool for rapid
prototyping, exploratory graphical analysis and education of statistics and
R. The interface is written completely in javascript, therefore there is no
need to install anything on the client side: a standard browser will do. All
major browsers are supported but a recent and standards-compliant browser is
highly recommended. Best performance is achieved by using Google Chrome. 

The easiest way to learn how to use the application is by taking 5 minutes
to watch the introductory demo video. 
-- 
View this message in context: 
http://n4.nabble.com/announce-yeroon-net-ggplot2-web-application-v0-2-tp1890003p1890003.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] sum() returns 0 not NA

2010-04-15 Thread Ted Harding
On 15-Apr-10 12:37:42, Wilmar Igl wrote:
> Dear all,
> 
> just a stupid R question, since the results puzzle me a bit:
> 
>> sum(c(NA,NA), na.rm=TRUE)
> [1] 0
>>  NA + NA   
> [1] NA
>> NA + 1
> [1] NA
>> 
> 
> Why does sum(c(NA,NA), na.rm=TRUE) return 0 and not NA?
> 
> Thanks in advance,
> 
> Will

For the same reason that:

  sum(logical(0))
  # [1] 0

If x is a numeric vector, possibly with NAs,

  sum(x,na.rm=TRUE)

will first remove any NAs from x, and then execute sum() on
what is left.

In the case of your example, after removing the NAs from c(NA,NA)
there is nothing left. The fact that it comes out 'logical' is
another issue:

  x <- c(NA,NA)
  x[!is.na(x)]
  # logical(0)

  c(NA,NA)[-(1:2)]
  # logical(0)

while:

  c(3,4)[-(1:2)]
  numeric(0)

The point is that the type of c(NA,NA) is "logical"

  str(c(NA,NA))
  # logi [1:2] NA NA

Ted.


E-Mail: (Ted Harding) 
Fax-to-email: +44 (0)870 094 0861
Date: 15-Apr-10   Time: 14:07:10
-- XFMail --

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


Re: [R] sum rows in a data.frame...solution

2010-04-15 Thread David Winsemius


On Apr 15, 2010, at 5:33 AM, arnaud Gaboury wrote:

Found this solution. It is maybe not the most elegant way, but it  
does the

job.


a=as.data.frame(substr(lme$DESCRIPTION,1,14))
colnames(a)=c("DESCRIPTION")
lme=as.data.frame(c(a,lme[,2:3]))



lme


DESCRIPTION CLOSING.PRICE POSITION
1  PRIMARY NICKEL   25,755.71000
2  PRIMARY NICKEL   25,760.86000
3  PRM HGH GD ALU2,415.90000
4  SPCL HIGH GRAD2,420.1000   -1
5  SPCL HIGH GRAD2,420.4100   -1
6  SPCL HIGH GRAD2,420.73001
7  SPCL HIGH GRAD2,421.05001
8  SPCL HIGH GRAD2,388.43000
9  SPCL HIGH GRAD2,389.0
10 SPCL HIGH GRAD2,389.57000
11 SPCL HIGH GRAD2,402.29000
12 SPCL HIGH GRAD2,402.6400   -2
13 SPCL HIGH GRAD2,391.86000
14 SPCL HIGH GRAD2,403.2
15 SPCL HIGH GRAD2,392.43000
16 SPCL HIGH GRAD2,393.0


If someone has a better idea, it is welcomed.


-Original Message-
From: arnaud Gaboury [mailto:arnaud.gabo...@gmail.com]
Sent: Thursday, April 15, 2010 9:50 AM
To: 'r-help@r-project.org'
Subject: sum rows in a data.frame

Dear group,

Here is a data.frame, "lme":


lme

 DESCRIPTION CLOSING.PRICE POSITION
4PRIMARY NICKEL USD 04/06/1025,755.71000
5PRIMARY NICKEL USD 10/06/1025,760.86000
6  PRM HGH GD ALUMINIUM USD 09/07/10 2,415.90000
8  SPCL HIGH GRADE ZINC USD 06/07/10 2,420.1000   -1
9  SPCL HIGH GRADE ZINC USD 07/07/10 2,420.4100   -1
10 SPCL HIGH GRADE ZINC USD 08/07/10 2,420.73001
11 SPCL HIGH GRADE ZINC USD 09/07/10 2,421.05001
12 SPCL HIGH GRADE ZINC USD 13/04/10 2,388.43000
13 SPCL HIGH GRADE ZINC USD 14/04/10 2,389.0
14 SPCL HIGH GRADE ZINC USD 15/04/10 2,389.57000
15 SPCL HIGH GRADE ZINC USD 17/05/10 2,402.29000
16 SPCL HIGH GRADE ZINC USD 18/05/10 2,402.6400   -2

DESCRIPTION and CLOSING.PRICE are factors, POSITION is numeric.

I want to sum POSITION by products, i.e. PRIMARY NICKEL, PRM HGH GD
ALUMINIUM and SPCL HIGH GRADE ZINC. The problem is that, as you can  
see,
there is a different date as a part of each product description. Can  
anyone
tell me how to get rid of these dates so I can sum the position  
column? The

number of rows is not fixed and will change every day.


See earlier post for one approach to the sum within description  
problem. But I did use mean instead of sum.




TY.

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


David Winsemius, MD
West Hartford, CT

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


Re: [R] sum rows in a data.frame

2010-04-15 Thread David Winsemius


On Apr 15, 2010, at 3:50 AM, arnaud Gaboury wrote:


Dear group,

Here is a data.frame, "lme":


lme

 DESCRIPTION CLOSING.PRICE POSITION
4PRIMARY NICKEL USD 04/06/1025,755.71000
5PRIMARY NICKEL USD 10/06/1025,760.86000
6  PRM HGH GD ALUMINIUM USD 09/07/10 2,415.90000
8  SPCL HIGH GRADE ZINC USD 06/07/10 2,420.1000   -1
9  SPCL HIGH GRADE ZINC USD 07/07/10 2,420.4100   -1
10 SPCL HIGH GRADE ZINC USD 08/07/10 2,420.73001
11 SPCL HIGH GRADE ZINC USD 09/07/10 2,421.05001
12 SPCL HIGH GRADE ZINC USD 13/04/10 2,388.43000
13 SPCL HIGH GRADE ZINC USD 14/04/10 2,389.0
14 SPCL HIGH GRADE ZINC USD 15/04/10 2,389.57000
15 SPCL HIGH GRADE ZINC USD 17/05/10 2,402.29000
16 SPCL HIGH GRADE ZINC USD 18/05/10 2,402.6400   -2

DESCRIPTION and CLOSING.PRICE are factors, POSITION is numeric.



Lacking a reproducible example   ... that is one that can be readily  
pasted into a console session ... this code remains untested and  
probably full of bugs so it is more a pseudo-code approach to the  
problem than a solution:


DESCRIPgrep <- sub(".{13}$","",  lme$DESCRIPTION, perl=TRUE)
with( lme, tapply(as.numeric(as.character(CLOSING.PRICE),   
DESCRIPgrep, mean)


Please reread the Posting Guide and submit data examples constructed  
with dput or dump so that responders can work on representative data.  
It would be a real pain to reconstruct that data example but you could  
have trivially offered it for testing.




I want to sum POSITION by products, i.e. PRIMARY NICKEL, PRM HGH GD
ALUMINIUM and SPCL HIGH GRADE ZINC. The problem is that, as you can  
see,
there is a different date as a part of each product description. Can  
anyone
tell me how to get rid of these dates so I can sum the position  
column? The

number of rows is not fixed and will change every day.

TY.

--

David Winsemius, MD
West Hartford, CT

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


Re: [R] Exporting an rgl graph

2010-04-15 Thread Ted Harding
On 15-Apr-10 12:33:11, baptiste auguie wrote:
> I have seen pdf files with 3D objects embedded in it, using the U3D
> format,
> http://en.wikipedia.org/wiki/Universal_3D

At the bottom of that page is a link to a very nice example:

  http://meshlab.sourceforge.net/wiki/images/c/cc/Laurana.pdf

"Embedding interactive 3D object in a PDF using MeshLab and U3D,
 Visual Computing Group. ISTI CNR. Example of an embedded U3D in a pdf."

Nice to play with! (With the mouse cursor over her, hold down the
button, and move around). According to the caption at the bottom:

  "This pdf was produced with open source tools. The object
   was converted in the pdf-ready U3D format with MeshLab
   ( http://meshlab.sourceforge.net ) and assembled in a pdf
   with pdfLATEX and the movie15 package."

I think there may be some scope here!
Ted.


> but I don't think there's a device for this in R; in fact there may
> not even exist a third-party post-processing route available at this
> time to bridge the gap between rgl and this format. It sure would be
> nice, though.
> 
> Best,
> 
> baptiste
> 
> 
> 
> On 15 April 2010 14:12, Barry Rowlingson 
> wrote:
>> On Thu, Apr 15, 2010 at 1:01 PM, _ wrote:
>>> Thanks for you answer. Let me precise my question.
>>>
>>> In fact, I do not want to "capture" a screen, I want to save an
>>> object that
>>> can be seen in 3D. With rgl, using my mouse, I can make the object
>>> move.
>>> This is what I want to export: an real 3D object that my collaborator
>>> will
>>> have the possibility to see in 3D.
>>>
>>
>> _You mean without them having to install R and rgl and run the code
>> that produces your graphic?
>>
>> _I guess you could somehow export a VRML or some other 3d file:
>>
>> _http://en.wikipedia.org/wiki/VRML
>>
>> _but I suspect of all the billions of people on the planet only Duncan
>> Murdoch knows enough about rgl to figure that one out...
>>
>> _The person at the other end would still need a VRML viewer. Just get
>> them to install R.
>>
>> Barry
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/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.


E-Mail: (Ted Harding) 
Fax-to-email: +44 (0)870 094 0861
Date: 15-Apr-10   Time: 13:54:02
-- XFMail --

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] sum() returns 0 not NA

2010-04-15 Thread Wilmar Igl
Dear all,

just a stupid R question, since the results puzzle me a bit:

> sum(c(NA,NA), na.rm=TRUE)
[1] 0
>  NA + NA   
[1] NA
> NA + 1
[1] NA
> 

Why does sum(c(NA,NA), na.rm=TRUE) return 0 and not NA?

Thanks in advance,

Will

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


Re: [R] Exporting an rgl graph

2010-04-15 Thread baptiste auguie
I have seen pdf files with 3D objects embedded in it, using the U3D format,
http://en.wikipedia.org/wiki/Universal_3D

but I don't think there's a device for this in R; in fact there may
not even exist a third-party post-processing route available at this
time to bridge the gap between rgl and this format. It sure would be
nice, though.

Best,

baptiste



On 15 April 2010 14:12, Barry Rowlingson  wrote:
> On Thu, Apr 15, 2010 at 1:01 PM,   wrote:
>> Thanks for you answer. Let me precise my question.
>>
>> In fact, I do not want to "capture" a screen, I want to save an object that
>> can be seen in 3D. With rgl, using my mouse, I can make the object move.
>> This is what I want to export: an real 3D object that my collaborator will
>> have the possibility to see in 3D.
>>
>
>  You mean without them having to install R and rgl and run the code
> that produces your graphic?
>
>  I guess you could somehow export a VRML or some other 3d file:
>
>  http://en.wikipedia.org/wiki/VRML
>
>  but I suspect of all the billions of people on the planet only Duncan
> Murdoch knows enough about rgl to figure that one out...
>
>  The person at the other end would still need a VRML viewer. Just get
> them to install R.
>
> Barry
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] sequence clustering and assembly

2010-04-15 Thread Martin Morgan
Hi Bogdan --

On 04/14/2010 08:19 PM, Bogdan Tanasa wrote:
> Dear all,
> 
> please could you suggest any R functions or packages (or external
> programs), that
likely you'll have more luck on the Bioconductor mailing list,

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

but...

> a. take as input a large number (> 10 000) of short 20-30 nt
> sequences, and do sequence assembly, to reconstruct larger (extended)
> 30-50 sequences ?

I don't know of any sequence assemblers in R; velvet would be a first
stop third party tool but it sounds like you have some fairly specific
requirements

> b. take as input a larger number of sequences (100 000 - 1 mil) and
> cluster these sequences in distinct classes based on the sequence
> similarity  ?

The Biostrings package has various functions to calculate edit distance,
which might form the input to familiar R clustering algorithms. See
installation instructions at

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

This thread

https://stat.ethz.ch/pipermail/bioconductor/2010-March/032580.html

might suggest some directions.

Martin

> 
> thanks a lot,
> 
> bogdan
> 
> [[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.


-- 
Martin Morgan
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109

Location: Arnold Building M1 B861
Phone: (206) 667-2793

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


Re: [R] Regression w/ interactions

2010-04-15 Thread Frank E Harrell Jr

Michael Dykes wrote:

I have a project due in my Linear Regression class re: regression on a data
set & my professor gave us a hint that there were *exactly *2 sig
interactions. The data set is attached. We have to find which predictors are
significant, & which 2 interactions are sig. Also, I nedd some guidance for
this & selecting the best model. I tried the `full' model, that being:
z=lm(y~x1+x2+x3+x4+x1*x2+x2*x3...+x3*x4). I then ran an anova(z), &
summary(z). My R^2 & R^2_a were *really* low. I am not sure how to do PRESS,
AIC & Cp in R yet though. Any help would be appreciated.




Michael this is not really the place for help on homework other than 
perhaps on technical roadblocks.  Note that the strategy you are being 
told to follow is one whose statistical properties have been severely 
criticized in the statistical literature.  Only with a very high signal 
to noise ratio (e.g., high true R^2) can torturing data lead to a 
confession to something other than what the analyst wants to hear.  I 
suppose that in simulated data there is a "true" model out there waiting 
to be found, but beware of using this approach with real data with low 
signal to noise ratios.


Frank


--
Frank E Harrell Jr   Professor and ChairmanSchool 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] sequence clustering and assembly

2010-04-15 Thread David Winsemius


On Apr 14, 2010, at 11:19 PM, Bogdan Tanasa wrote:


Dear all,

please could you suggest any R functions or packages (or external  
programs),

that

a. take as input a large number (> 10 000) of short 20-30 nt  
sequences, and

do
sequence assembly, to reconstruct larger (extended) 30-50 sequences ?

b. take as input a larger number of sequences (100 000 - 1 mil) and  
cluster

these
sequences in distinct classes based on the sequence similarity  ?


Most of the discussion about genetics/omics applications occurs on the  
BioConductor mailing list. You should definitely seek it out, get the  
base installed and review their available online resources (before  
sending your next message to the correct mailing list.


http://www.bioconductor.org/docs

--

David Winsemius, MD
West Hartford, CT

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


Re: [R] predict.lm with NAs

2010-04-15 Thread Walmes Zeviani

You can use predict() by specifying a complete data.frame() for prediction to
the argument newdata=. Look:

da <- expand.grid(x1=LETTERS[1:4], x2=1:9)
da$y <- rnorm(da$x1)
da$y[sample(length(da$y), 5)] <- NA

m0 <- lm(y~x1+x2, data=da)
predict(m0) # NA not predicted
predict(m0, newdata=da) # NA predicted

Sincerely.
Walmes.

-
..ooo0
...
..()... 0ooo...  Walmes Zeviani
...\..(.(.)... Master in Statistics and Agricultural
Experimentation
\_). )../   walmeszevi...@hotmail.com, Lavras - MG, Brasil

(_/
-- 
View this message in context: 
http://n4.nabble.com/predict-lm-with-NAs-tp1840661p1886457.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] Non-parametric Tests for location in R

2010-04-15 Thread David Winsemius


On Apr 14, 2010, at 7:19 PM, maithili davda wrote:

How do I do the sign test and the sign rank test that SAS gives as  
an output

in proc univariate in R?

sign.test
and
wilcox.test

do not give the same output.


No data, no specifics, no code. Rather difficult to determine whether  
you made an error or   what?


Also how do you pick what output you want displayed in R?
like if I want only the test statistic and p value displayed and  
nothing

else how do I do that.


Most such functions return lists. One can look at the names of the  
components of such lists with str and extract the desired components.  
In the case of wilcox.test you do not need str because you can just go  
to the Value section of the help page and it's all laid out for you  
(as it should be.) You could assign the results to say, wres, and then :


wres$statistic
wres$p.value

--
David Winsemius, MD
West Hartford, CT

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


Re: [R] Exporting an rgl graph

2010-04-15 Thread Barry Rowlingson
On Thu, Apr 15, 2010 at 1:01 PM,   wrote:
> Thanks for you answer. Let me precise my question.
>
> In fact, I do not want to "capture" a screen, I want to save an object that
> can be seen in 3D. With rgl, using my mouse, I can make the object move.
> This is what I want to export: an real 3D object that my collaborator will
> have the possibility to see in 3D.
>

 You mean without them having to install R and rgl and run the code
that produces your graphic?

 I guess you could somehow export a VRML or some other 3d file:

 http://en.wikipedia.org/wiki/VRML

 but I suspect of all the billions of people on the planet only Duncan
Murdoch knows enough about rgl to figure that one out...

 The person at the other end would still need a VRML viewer. Just get
them to install R.

Barry

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

2010-04-15 Thread baxy77

hi, i have a problem installing any type of GUI interface on my debian lenny
64x OS, can anybody spare some time to help me?. so i have installed the R
by apt-get and then in R used command : 


baxy:~#  update-alternatives --config java

There are 3 alternatives which provide `java'.

  SelectionAlternative
---
  1/usr/bin/gij-4.3
  2/usr/lib/jvm/java-gcj/jre/bin/java
*+3/usr/lib/jvm/java-6-openjdk/jre/bin/java

Press enter to keep the default[*], or type selection number: 
baxy:~#  R CMD javareconf 
Java interpreter : /usr/bin/java
Java version : 1.6.0_0
Java home path   : /usr/lib/jvm/java-6-openjdk/jre
Java compiler: /usr/bin/javac
Java headers gen.: /usr/bin/javah
Java archive tool: /usr/bin/jar
Java library path:
$(JAVA_HOME)/lib/amd64/server:$(JAVA_HOME)/lib/amd64:$(JAVA_HOME)/../lib/amd64::/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib:/usr/lib/jni
JNI linker flags : -L$(JAVA_HOME)/lib/amd64/server -L$(JAVA_HOME)/lib/amd64
-L$(JAVA_HOME)/../lib/amd64 -L -L/usr/java/packages/lib/amd64 -L/usr/lib64
-L/lib64 -L/lib -L/usr/lib -L/usr/lib/jni -ljvm
JNI cpp flags: -I$(JAVA_HOME)/../include

Updating Java configuration in /etc/R
Done.

baxy:~# R

R version 2.7.1 (2008-06-23)
Copyright (C) 2008 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

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

  Natural language support but running in an English locale

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

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

[Previously saved workspace restored]

>  install.packages('JGR', dep=TRUE) 
Warning in install.packages("JGR", dep = TRUE) :
  argument 'lib' is missing: using '/root/R/x86_64-pc-linux-gnu-library/2.7'
--- Please select a CRAN mirror for use in this session ---
CRAN mirror 


...




  to install GUI but the message that i'm geting is 

Warning message:
In install.packages("JGR", dep = TRUE) : package ‘JGR’ is not available

so is there any other package so i can just plot my graphs  i'm seeking
for just minimal tools so i can plot my images distributions and stuff ...

thank you 


baxy

-- 
View this message in context: 
http://n4.nabble.com/debian-lenny-R-GUI-instalation-problems-tp1880797p1880797.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] Exporting an rgl graph

2010-04-15 Thread cgenolin

Thanks for you answer. Let me precise my question.

In fact, I do not want to "capture" a screen, I want to save an object 
that can be seen in 3D. With rgl, using my mouse, I can make the object 
move. This is what I want to export: an real 3D object that my 
collaborator will have the possibility to see in 3D.


Christophe



On 15-Apr-10 10:10:54, Barry Rowlingson wrote:

On Thu, Apr 15, 2010 at 10:24 AM,   wrote:

Hi the list,

I use rgl to produce a 3D graph. I would like to "show" this graph
to some collaborator. Is there a way to save it and send it to
someone else?


See ?rgl.postscript and ?rgl.snapshot

 Or use some kind of screen capture system - on Windows the 'Print
Screen' key can copy the screen to the clipboard, paste into Photoshop
or other graphics program.

 On Linux, I use 'scrot' from the command line - type 'scrot -s',
click on a window, and it makes a PNG file of it.


Again on Linux, since ImageMagick is installed, I use the 'import'
programme from that suite. When you start that, it produces a
"+"-shaped mouse cursor which you can use (selecting a top-left-hand
corner to start with, and holding down the left mouse button) to
drag out a bounding frame for the part of the screen you want to
save. Then, when you release the button, an image of that portion
of the screen is saved to a file of your choice, in any graphics
format of your choice that is supported by ImageMagick (including
PS and EPS, as well as all the common butmap formats).

See 'man import' for pointers to more information.

I have this set up as an icon on my "launch" panel, so it is just
a matter of clicking on that, and then doing the above. The command
behind the icon is

 /usr/local/bin/mkscreengrab

and my script file 'mkscreengrab' contains:

 #! /bin/bash
 export ScrGrbTmp=`mktemp /home/ted/Screengrabs/screengrab`
 import $ScrGrbTmp.jpg
 rm $ScrGrbTmp

so this makes JPEGs (I could have chosen somthing else, but that's
the default I mostly want for that activity). This produces a file
with a name like "screengrab4913.jpg" which will be unique in that
directory, and it can later be renamed to your taste.

If I wanted a different file format, I would use 'import' from
the command line, with appropriate filenam extension (e.g. ".png",
".ps", ".eps", ... ).

I hadn't heard of scrot before, but now I've looked it up it
seems that its output format is limited to PNG.

I've now also located more info about various ways of taking
screenshots in Linux:

http://tips.webdesign10.com/how-to-take-a-screenshot-on-ubuntu-linux

Ted.


E-Mail: (Ted Harding) 
Fax-to-email: +44 (0)870 094 0861
Date: 15-Apr-10   Time: 12:18:25
-- XFMail --



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

2010-04-15 Thread Sébastien Bihorel
Thanks David,

After a bit of research, I believe that I've found the post you are
referring to:

http://tolstoy.newcastle.edu.au/R/e9/help/10/03/8779.html

I will look into the proposed solutions.

Sebastien

On Wed, Apr 14, 2010 at 6:01 PM, David Scott  wrote:

> Sébastien Bihorel wrote:
>
>> Thanks Tobias,
>>
>> If there is no automated way to combine both documents, I will stack them
>> manually... that will likely cause some problems with page numbering
>> tough.
>>
>> Sebastien
>>
>>
> There was a thread a while back (this year) about someone who wanted to
> incorporate his package manual in his thesis. A solution was offered to this
> as I recall and it seems like the same problem to me.
>
> What you need is the LaTeX that comes out of the package check. Just add it
> to your vignette LaTeX and that should do the trick.
>
> David
>
> _
> David Scott Department of Statistics
>The University of Auckland, PB 92019
>Auckland 1142,NEW ZEALAND
> Phone: +64 9 923 5055, or +64 9 373 7599 ext 85055
> Email:  d.sc...@auckland.ac.nz,  Fax: +64 9 373 7018
>
> Director of Consulting, Department of Statistics
>
>

[[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] Consistent behaviour of for-loop

2010-04-15 Thread Petr PIKAL
Hi

r-help-boun...@r-project.org napsal dne 15.04.2010 13:00:57:

> Peter Ehlers wrote:
> > You are mixing 'traditional' graphics (par(...)) and
> > 'lattice' graphics.
> > That won't work. In lattice, you use the 'layout' argument to
> > select the number of columns/rows. This is easiest if you set
> > up a conditioning variable:
> >
> >   cond <- gl(12, 20, labels = letters[1:12])
> >   x <- rnorm(12*20)
> >   qqmath(~x | cond, layout = c(4, 3))
> >
> > Note that layout = c(columns, rows), not c(rows, columns).
> >
> > Since you're new to R, let me also recommend very strongly
> > that you learn to use the str() function (not needed for
> > this problem, but undoubtedly indispensible in your further
> > adventures in R-land).
> > 
> Nice example, and good recommendation!
> 
> (It is difficult to satisfy me:)
> How can one know/see, what is traditional graphics, and what is lattice 

I would prefer to name it base and grid graphics. 

Base is in graphics and grDevices packages and grid graphics is in grid 
package. Only some packages use grid graphics (lattice, ggplot2, nlme for 
some) many more packages use base graphics. You can not simply mix 
functions from one with another, however if you dig deeper you can find 
that it is possible.

Basically if you do not intend to develop graphic package you probably 
will use what others developed for you and you will use base graphics most 
of the time.

Fro lattice help page

 Lattice is built upon the Grid graphics engine and requires the
 ‘grid’ add-on package.  It is not (readily) compatible with
 traditional R graphics tools. 

Regards
Petr


> graphics? Or is it try-and-fail-and-use-the-alternative?
> 
> Thanks,
> 
> Uwe
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] graphic question

2010-04-15 Thread Tighiouart, Hocine
Thanks Peter. This worked fine. I guess my problem was that when I
maximize the graph window everything seems to expand, this is why I was
having trouble with it.


-Original Message-
From: Peter Ehlers [mailto:ehl...@ucalgary.ca] 
Sent: Thursday, April 15, 2010 4:54 AM
To: Tighiouart, Hocine
Cc: r-help@r-project.org
Subject: Re: [R] graphic question

On 2010-04-14 19:57, Tighiouart, Hocine wrote:
> Hello,
>
> I have a simple question that I could not really figure out. I am
plotting labels within a graph using the text function. I first plot the
first label by specifying the x and y coordinates on the graph. Then to
plot the second label next to it, I am using te strwidth function to get
the width of the previous label in user coordinate then add the maximum
width to the x value. However, this is not working:
>
> Here is an example:
>
> lab1<-c("Hocine&  Ruba 2000", "Yasmine 2004","Ziad was born in 2006")
> lab2<-c(20,22,45)
> lab3<-c(54677,10900,200)
> plot(-10:5,1:6)
> text(par("usr")[1],2:4,lab1,adj=c(0,0.5))
> text(par("usr")[1]+max(strwidth(lab1)),2:4,lab1,adj=c(0,0.5))
>
> However, this is not working OK. I would like to get the max width of
lab1 as it appears in the figure then add that amount to plot lab2 and
so forth. I would like to leave only one blank column between successive
labels.

Does this give you what you have in mind:

  text(par("usr")[1] + max(strwidth(paste(lab1, ""))),
   2:4,lab1,adj=c(0,0.5))

  -Peter Ehlers

>
> Thanks!
>
> Hocine
>
>
>
>
>   [[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.
>
>

-- 
Peter Ehlers
University of Calgary

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


Re: [R] Exporting an rgl graph

2010-04-15 Thread Ted Harding
On 15-Apr-10 10:10:54, Barry Rowlingson wrote:
> On Thu, Apr 15, 2010 at 10:24 AM,   wrote:
>> Hi the list,
>>
>> I use rgl to produce a 3D graph. I would like to "show" this graph
>> to some collaborator. Is there a way to save it and send it to
>> someone else?
> 
> See ?rgl.postscript and ?rgl.snapshot
> 
>  Or use some kind of screen capture system - on Windows the 'Print
> Screen' key can copy the screen to the clipboard, paste into Photoshop
> or other graphics program.
> 
>  On Linux, I use 'scrot' from the command line - type 'scrot -s',
> click on a window, and it makes a PNG file of it.

Again on Linux, since ImageMagick is installed, I use the 'import'
programme from that suite. When you start that, it produces a
"+"-shaped mouse cursor which you can use (selecting a top-left-hand
corner to start with, and holding down the left mouse button) to
drag out a bounding frame for the part of the screen you want to
save. Then, when you release the button, an image of that portion
of the screen is saved to a file of your choice, in any graphics
format of your choice that is supported by ImageMagick (including
PS and EPS, as well as all the common butmap formats).

See 'man import' for pointers to more information.

I have this set up as an icon on my "launch" panel, so it is just
a matter of clicking on that, and then doing the above. The command
behind the icon is

  /usr/local/bin/mkscreengrab

and my script file 'mkscreengrab' contains:

  #! /bin/bash
  export ScrGrbTmp=`mktemp /home/ted/Screengrabs/screengrab`
  import $ScrGrbTmp.jpg
  rm $ScrGrbTmp

so this makes JPEGs (I could have chosen somthing else, but that's
the default I mostly want for that activity). This produces a file
with a name like "screengrab4913.jpg" which will be unique in that
directory, and it can later be renamed to your taste.

If I wanted a different file format, I would use 'import' from
the command line, with appropriate filenam extension (e.g. ".png",
".ps", ".eps", ... ).

I hadn't heard of scrot before, but now I've looked it up it
seems that its output format is limited to PNG.

I've now also located more info about various ways of taking
screenshots in Linux:

http://tips.webdesign10.com/how-to-take-a-screenshot-on-ubuntu-linux

Ted.


E-Mail: (Ted Harding) 
Fax-to-email: +44 (0)870 094 0861
Date: 15-Apr-10   Time: 12:18:25
-- XFMail --

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


Re: [R] Consistent behaviour of for-loop

2010-04-15 Thread Peter Ehlers

On 2010-04-15 5:00, Uwe Dippel wrote:

Peter Ehlers wrote:

You are mixing 'traditional' graphics (par(...)) and
'lattice' graphics.
That won't work. In lattice, you use the 'layout' argument to
select the number of columns/rows. This is easiest if you set
up a conditioning variable:

cond <- gl(12, 20, labels = letters[1:12])
x <- rnorm(12*20)
qqmath(~x | cond, layout = c(4, 3))

Note that layout = c(columns, rows), not c(rows, columns).

Since you're new to R, let me also recommend very strongly
that you learn to use the str() function (not needed for
this problem, but undoubtedly indispensible in your further
adventures in R-land).

Nice example, and good recommendation!

(It is difficult to satisfy me:)
How can one know/see, what is traditional graphics, and what is lattice
graphics? Or is it try-and-fail-and-use-the-alternative?


You have to do a fair amount of reading. There's a whole chapter
on base graphics in the Intro to R, which also (briefly) mentions
lattice graphics. And then there's the ggplot2 package ...

Beginners should definitely work through the Intro to R.

It takes time and patience.

 -Peter Ehlers



Thanks,

Uwe




--
Peter Ehlers
University of Calgary

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


Re: [R] classes and functions for qqnorm and stem

2010-04-15 Thread Peter Ehlers

On 2010-04-14 21:20, Uwe Dippel wrote:

Referring to "Using R for Data Analysis and Graphics" by J H Maindonald,
and available from the R site, I found the example on p.30 non-working:
 > stem(qqnorm(possum$hdlngth))
Error in stem(qqnorm(possum$hdlngth)) : 'x' must be numeric
Since qqnorm(possum$hdlngth) plots, and
 > class(possum$hdlngth)
[1] "numeric"
, the problem must be here:
 > class(qqnorm(possum$hdlngth))
[1] "list"
Does 'stem' require numerical input? The help says so.
But how to render it numeric?:
 > class(as.numeric(qqnorm(possum$hdlngth)))
Error: (list) object cannot be coerced to type 'double'

Can someone please enlighten me about what goes wrong/has changed here?


This is a perfect time to learn about str().
If you check

 str(qqnorm(possum$hdlngth))

You will see that it is a list of two numeric vectors. But
stem() expects just one vector. The stem() call is an
error; it should be just stem(possum$hdlngth).

 -Peter Ehlers



Uwe

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




--
Peter Ehlers
University of Calgary

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


Re: [R] Consistent behaviour of for-loop

2010-04-15 Thread Uwe Dippel

Peter Ehlers wrote:

You are mixing 'traditional' graphics (par(...)) and
'lattice' graphics.
That won't work. In lattice, you use the 'layout' argument to
select the number of columns/rows. This is easiest if you set
up a conditioning variable:

  cond <- gl(12, 20, labels = letters[1:12])
  x <- rnorm(12*20)
  qqmath(~x | cond, layout = c(4, 3))

Note that layout = c(columns, rows), not c(rows, columns).

Since you're new to R, let me also recommend very strongly
that you learn to use the str() function (not needed for
this problem, but undoubtedly indispensible in your further
adventures in R-land).
  

Nice example, and good recommendation!

(It is difficult to satisfy me:)
How can one know/see, what is traditional graphics, and what is lattice 
graphics? Or is it try-and-fail-and-use-the-alternative?


Thanks,

Uwe

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


Re: [R] Consistent behaviour of for-loop

2010-04-15 Thread Peter Ehlers

On 2010-04-15 4:03, Uwe Dippel wrote:

Peter Ehlers wrote:

> par(mfrow=c(1,1))
> qqnorm(rnorm(20))
> qqmath(rnorm(20))
> par(mfrow=c(3,4))
> for(i in 1:12)qqnorm(rnorm(20))
Until here everything works as expected, and the last line prints 12
samples of qqnorm. However,
> for(i in 1:12)qqmath(rnorm(20))
is doing nothing at all.


You should always tell us what contributed packages you are using.
Here, the qqmath function is from pkg:lattice.
Now check FAQ 7.22.

Thanks, Peter!
(And to the offline-reply as well!)
The question is not completely answered in FAQ 7.22, though:
 > par(mfrow=c(3,4))
 > for(i in 1:12)print(qqmath(rnorm(20)))
prints 12 after another; not in (3,4)

Why, and how to print 12 samples on a single sheet?


You are mixing 'traditional' graphics (par(...)) and
'lattice' graphics.
That won't work. In lattice, you use the 'layout' argument to
select the number of columns/rows. This is easiest if you set
up a conditioning variable:

 cond <- gl(12, 20, labels = letters[1:12])
 x <- rnorm(12*20)
 qqmath(~x | cond, layout = c(4, 3))

Note that layout = c(columns, rows), not c(rows, columns).

Since you're new to R, let me also recommend very strongly
that you learn to use the str() function (not needed for
this problem, but undoubtedly indispensible in your further
adventures in R-land).

 -Peter Ehlers



Uwe




--
Peter Ehlers
University of Calgary

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


Re: [R] histogram

2010-04-15 Thread Peter Ehlers

On 2010-04-15 3:35, Santosh wrote:

Thanks for your email... yes, I had tried that "bw" thing.. for some reason
it does not seem to work.. could not figure out where I am wrong...

Below is an example for your convenience.. you might notice that the density
plots appear to be a curve of connected segments. Changing breaks, nint or
bw didn't seem to help.


library(reshape)
set.seed(13454)
aa<-
data.frame(a1=rnorm(500),b1=rnorm(500,0.8),c1=rnorm(500,0.5),cat1=rep(1:5,each=100))
ab<- melt(aa,measure.vars=c("a1","b1","c1"))
histogram(~
value|variable,ab,breaks=NULL,nint=10,type="density",layout=c(2,2),as.table=T,scales=list(relation='free'),
 panel=function(x,lqp=c(0.05,0.975),...) {
 panel.histogram(x,col='lightblue',...)
 panel.densityplot(x,col.line='blue',lwd=1.75,bw=2,...)
 panel.abline(v=c(quantile(as.vector(x),prob=lqp,na.rm = T)),
 col="dark green",lwd=2,lty=2)
 },
 strip=strip.custom( strip.names=F,
 strip.levels=T,
 par.strip.text=list(cex=0.75)),
)




You need to supply a *list* 'darg' to panel.densityplot; see
the help page.

 panel.densityplot(x, darg = list(bw = "nrd", adjust = 1.2), ...)

(I would use one of the built-in bandwidth selectors with a
suitable 'adjust' value.)

 -Peter Ehlers



Thanks again,
Santosh
On Thu, Apr 15, 2010 at 12:41 AM, Paul Hiemstrawrote:


Santosh wrote:


Dear R gurus...

How do I control "smoothing" of a density plot in panel.densityplot when
using histogram?

Thanks much,
Santosh

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



Hi,

 From ?panel.densityplot, argument darg, I was referred to ?density. I think
the 'bw' argument is what you need. Pass it to panel.densityplot in the darg
argument.

cheers,
Paul


--
Drs. Paul Hiemstra
Department of Physical Geography
Faculty of Geosciences
University of Utrecht
Heidelberglaan 2
P.O. Box 80.115
3508 TC Utrecht
Phone:  +3130 274 3113 Mon-Tue
Phone:  +3130 253 5773 Wed-Fri
http://intamap.geo.uu.nl/~paul
http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770




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




--
Peter Ehlers
University of Calgary

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


Re: [R] histogram

2010-04-15 Thread Paul Hiemstra

Santosh wrote:
Thanks for your email... yes, I had tried that "bw" thing.. for some 
reason it does not seem to work.. could not figure out where I am wrong...


Below is an example for your convenience.. you might notice that the 
density plots appear to be a curve of connected segments. Changing 
breaks, nint or bw didn't seem to help.



library(reshape)
set.seed(13454)
aa <- 
data.frame(a1=rnorm(500),b1=rnorm(500,0.8),c1=rnorm(500,0.5),cat1=rep(1:5,each=100))

ab <- melt(aa,measure.vars=c("a1","b1","c1"))
histogram(~ 
value|variable,ab,breaks=NULL,nint=10,type="density",layout=c(2,2),as.table=T,scales=list(relation='free'),

panel=function(x,lqp=c(0.05,0.975),...) {
panel.histogram(x,col='lightblue',...)
panel.densityplot(x,col.line='blue',lwd=1.75,bw=2,...)
replace bw = 2 by darg = list(bw = 2), then it works for me. Read the 
documentation of panel.densityplot carefully, it says that you need to 
use darg = list().


cheers,
Paul

panel.abline(v=c(quantile(as.vector(x),prob=lqp,na.rm = T)),
col="dark green",lwd=2,lty=2)
},
strip=strip.custom( strip.names=F,
strip.levels=T,
par.strip.text=list(cex=0.75)),
)



Thanks again,
Santosh
On Thu, Apr 15, 2010 at 12:41 AM, Paul Hiemstra > wrote:


Santosh wrote:

Dear R gurus...

How do I control "smoothing" of a density plot in
panel.densityplot when
using histogram?

Thanks much,
Santosh

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


Hi,

From ?panel.densityplot, argument darg, I was referred to
?density. I think the 'bw' argument is what you need. Pass it to
panel.densityplot in the darg argument.

cheers,
Paul


-- 
Drs. Paul Hiemstra

Department of Physical Geography
Faculty of Geosciences
University of Utrecht
Heidelberglaan 2
P.O. Box 80.115
3508 TC Utrecht
Phone:  +3130 274 3113 Mon-Tue
Phone:  +3130 253 5773 Wed-Fri
http://intamap.geo.uu.nl/~paul 
http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770





--
Drs. Paul Hiemstra
Department of Physical Geography
Faculty of Geosciences
University of Utrecht
Heidelberglaan 2
P.O. Box 80.115
3508 TC Utrecht
Phone:  +3130 274 3113 Mon-Tue
Phone:  +3130 253 5773 Wed-Fri
http://intamap.geo.uu.nl/~paul
http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770

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


Re: [R] Consistent behaviour of for-loop

2010-04-15 Thread Uwe Dippel

Peter Ehlers wrote:

 > par(mfrow=c(1,1))
 > qqnorm(rnorm(20))
 > qqmath(rnorm(20))
 > par(mfrow=c(3,4))
 > for(i in 1:12)qqnorm(rnorm(20))
Until here everything works as expected, and the last line prints 12
samples of qqnorm. However,
 > for(i in 1:12)qqmath(rnorm(20))
is doing nothing at all.



You should always tell us what contributed packages you are using.
Here, the qqmath function is from pkg:lattice.
Now check FAQ 7.22.
  

Thanks, Peter!
(And to the offline-reply as well!)
The question is not completely answered in FAQ 7.22, though:
> par(mfrow=c(3,4))
> for(i in 1:12)print(qqmath(rnorm(20)))
prints 12 after another; not in (3,4)

Why, and how to print 12 samples on a single sheet?

Uwe

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


Re: [R] Exporting an rgl graph

2010-04-15 Thread Barry Rowlingson
On Thu, Apr 15, 2010 at 10:24 AM,   wrote:
> Hi the list,
>
> I use rgl to produce a 3D graph. I would like to "show" this graph to some
> collaborator. Is there a way to save it and send it to someone else?

See ?rgl.postscript and ?rgl.snapshot

 Or use some kind of screen capture system - on Windows the 'Print
Screen' key can copy the screen to the clipboard, paste into Photoshop
or other graphics program.

 On Linux, I use 'scrot' from the command line - type 'scrot -s',
click on a window, and it makes a PNG file of it.

-- 
blog: http://geospaced.blogspot.com/
web: http://www.maths.lancs.ac.uk/~rowlings
web: http://www.rowlingson.com/
twitter: http://twitter.com/geospacedman
pics: http://www.flickr.com/photos/spacedman

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

2010-04-15 Thread Jim Lemon

On 04/15/2010 12:36 AM, senne wrote:

hi R gurus

I saw some graphs with vertical band like this one:

http://pragcap.com/wp-content/uploads/2010/04/GS.png

how to draw the blue band in R, can't find any clue to do this,any ideas?


Hi senne,
The rect function in base graphics can do the job. First do the plot 
with type="n" (i.e. no plotting), then display your rectangles:


xylim<-par("usr")
rect.left<-as.Date(seq(paste(rep(c("Dec","Mar","Jun","Sep"),length.out=10),
 c("07","08","08","08","08","09","09","09","09","10"),sep="-")))
rect.right<-rect.left+10
rect(rect.left,xylim[3],rect.right,xylim[4],col="lightblue",border="lightblue")

then draw the line and text labels.

Warning - untested

Jim

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


Re: [R] Consistent behaviour of for-loop

2010-04-15 Thread Peter Ehlers

On 2010-04-15 2:10, Uwe Dippel wrote:

First my excuses if I keep bugging everyone in this list, but I am a
newbie, and tend to find some behaviour that looks unexpected to me; and
I would really appreciate to be pointed to some location that allows me
to understand more about this software. Here is my next question:
 > par(mfrow=c(1,1))
 > qqnorm(rnorm(20))
 > qqmath(rnorm(20))
 > par(mfrow=c(3,4))
 > for(i in 1:12)qqnorm(rnorm(20))
Until here everything works as expected, and the last line prints 12
samples of qqnorm. However,
 > for(i in 1:12)qqmath(rnorm(20))
is doing nothing at all.


You should always tell us what contributed packages you are using.
Here, the qqmath function is from pkg:lattice.
Now check FAQ 7.22.

 -Peter Ehlers



As I wrote, I'd really appreciate the understand where this behaviour
comes from.

Thanks in advance,

Uwe

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




--
Peter Ehlers
University of Calgary

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


Re: [R] histogram

2010-04-15 Thread Santosh
Thanks for your email... yes, I had tried that "bw" thing.. for some reason
it does not seem to work.. could not figure out where I am wrong...

Below is an example for your convenience.. you might notice that the density
plots appear to be a curve of connected segments. Changing breaks, nint or
bw didn't seem to help.


library(reshape)
set.seed(13454)
aa <-
data.frame(a1=rnorm(500),b1=rnorm(500,0.8),c1=rnorm(500,0.5),cat1=rep(1:5,each=100))
ab <- melt(aa,measure.vars=c("a1","b1","c1"))
histogram(~
value|variable,ab,breaks=NULL,nint=10,type="density",layout=c(2,2),as.table=T,scales=list(relation='free'),
panel=function(x,lqp=c(0.05,0.975),...) {
panel.histogram(x,col='lightblue',...)
panel.densityplot(x,col.line='blue',lwd=1.75,bw=2,...)
panel.abline(v=c(quantile(as.vector(x),prob=lqp,na.rm = T)),
col="dark green",lwd=2,lty=2)
},
strip=strip.custom( strip.names=F,
strip.levels=T,
par.strip.text=list(cex=0.75)),
)



Thanks again,
Santosh
On Thu, Apr 15, 2010 at 12:41 AM, Paul Hiemstra wrote:

> Santosh wrote:
>
>> Dear R gurus...
>>
>> How do I control "smoothing" of a density plot in panel.densityplot when
>> using histogram?
>>
>> Thanks much,
>> Santosh
>>
>>[[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.
>>
>>
> Hi,
>
> From ?panel.densityplot, argument darg, I was referred to ?density. I think
> the 'bw' argument is what you need. Pass it to panel.densityplot in the darg
> argument.
>
> cheers,
> Paul
>
>
> --
> Drs. Paul Hiemstra
> Department of Physical Geography
> Faculty of Geosciences
> University of Utrecht
> Heidelberglaan 2
> P.O. Box 80.115
> 3508 TC Utrecht
> Phone:  +3130 274 3113 Mon-Tue
> Phone:  +3130 253 5773 Wed-Fri
> http://intamap.geo.uu.nl/~paul 
> http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770
>
>

[[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] sum rows in a data.frame...solution

2010-04-15 Thread arnaud Gaboury
Found this solution. It is maybe not the most elegant way, but it does the
job.

  > a=as.data.frame(substr(lme$DESCRIPTION,1,14))
  > colnames(a)=c("DESCRIPTION")
  > lme=as.data.frame(c(a,lme[,2:3]))

  > lme

 DESCRIPTION CLOSING.PRICE POSITION
1  PRIMARY NICKEL   25,755.71000
2  PRIMARY NICKEL   25,760.86000
3  PRM HGH GD ALU2,415.90000
4  SPCL HIGH GRAD2,420.1000   -1
5  SPCL HIGH GRAD2,420.4100   -1
6  SPCL HIGH GRAD2,420.73001
7  SPCL HIGH GRAD2,421.05001
8  SPCL HIGH GRAD2,388.43000
9  SPCL HIGH GRAD2,389.0
10 SPCL HIGH GRAD2,389.57000
11 SPCL HIGH GRAD2,402.29000
12 SPCL HIGH GRAD2,402.6400   -2
13 SPCL HIGH GRAD2,391.86000
14 SPCL HIGH GRAD2,403.2
15 SPCL HIGH GRAD2,392.43000
16 SPCL HIGH GRAD2,393.0


If someone has a better idea, it is welcomed.


-Original Message-
From: arnaud Gaboury [mailto:arnaud.gabo...@gmail.com] 
Sent: Thursday, April 15, 2010 9:50 AM
To: 'r-help@r-project.org'
Subject: sum rows in a data.frame

Dear group,

Here is a data.frame, "lme":

> lme
  DESCRIPTION CLOSING.PRICE POSITION
4PRIMARY NICKEL USD 04/06/1025,755.71000
5PRIMARY NICKEL USD 10/06/1025,760.86000
6  PRM HGH GD ALUMINIUM USD 09/07/10 2,415.90000
8  SPCL HIGH GRADE ZINC USD 06/07/10 2,420.1000   -1
9  SPCL HIGH GRADE ZINC USD 07/07/10 2,420.4100   -1
10 SPCL HIGH GRADE ZINC USD 08/07/10 2,420.73001
11 SPCL HIGH GRADE ZINC USD 09/07/10 2,421.05001
12 SPCL HIGH GRADE ZINC USD 13/04/10 2,388.43000
13 SPCL HIGH GRADE ZINC USD 14/04/10 2,389.0
14 SPCL HIGH GRADE ZINC USD 15/04/10 2,389.57000
15 SPCL HIGH GRADE ZINC USD 17/05/10 2,402.29000
16 SPCL HIGH GRADE ZINC USD 18/05/10 2,402.6400   -2

DESCRIPTION and CLOSING.PRICE are factors, POSITION is numeric.

I want to sum POSITION by products, i.e. PRIMARY NICKEL, PRM HGH GD
ALUMINIUM and SPCL HIGH GRADE ZINC. The problem is that, as you can see,
there is a different date as a part of each product description. Can anyone
tell me how to get rid of these dates so I can sum the position column? The
number of rows is not fixed and will change every day.

TY.

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

2010-04-15 Thread cgenolin

Hi the list,

I use rgl to produce a 3D graph. I would like to "show" this graph to 
some collaborator. Is there a way to save it and send it to someone 
else?


Christophe Genolini

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

2010-04-15 Thread Vehbi Sinan Tunalioglu
Dear All,

Is there any GARCH-M implementation in R? I checked tseries and fGarch
packages and could not find yet.

Thanks in advance and Kind Regards,
Vehbi Sinan



signature.asc
Description: OpenPGP digital 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] env() for lme4

2010-04-15 Thread pnouvellet

Thanks a lot Rob!

sorry, yesterday, i misunderstood your post...

the call to 'profile(fm...@env)'  worked perfectly!

it is really nice to see it working smoothly!!

pierre
-- 
View this message in context: 
http://n4.nabble.com/env-for-lme4-tp1565045p1871149.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] graphic question

2010-04-15 Thread Peter Ehlers

On 2010-04-14 19:57, Tighiouart, Hocine wrote:

Hello,

I have a simple question that I could not really figure out. I am plotting 
labels within a graph using the text function. I first plot the first label by 
specifying the x and y coordinates on the graph. Then to plot the second label 
next to it, I am using te strwidth function to get the width of the previous 
label in user coordinate then add the maximum width to the x value. However, 
this is not working:

Here is an example:

lab1<-c("Hocine&  Ruba 2000", "Yasmine 2004","Ziad was born in 2006")
lab2<-c(20,22,45)
lab3<-c(54677,10900,200)
plot(-10:5,1:6)
text(par("usr")[1],2:4,lab1,adj=c(0,0.5))
text(par("usr")[1]+max(strwidth(lab1)),2:4,lab1,adj=c(0,0.5))

However, this is not working OK. I would like to get the max width of lab1 as 
it appears in the figure then add that amount to plot lab2 and so forth. I 
would like to leave only one blank column between successive labels.


Does this give you what you have in mind:

 text(par("usr")[1] + max(strwidth(paste(lab1, ""))),
  2:4,lab1,adj=c(0,0.5))

 -Peter Ehlers



Thanks!

Hocine




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




--
Peter Ehlers
University of Calgary

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


Re: [R] GAMM : how to use a smoother for some levels of a variable, and a linear effect for other levels?

2010-04-15 Thread JANSEN, Ivy

I was not sure whether using the smoother as presented would give
exactly the same result as using two linear terms and 2 smoothers, and
wanted to check this.

Regards,
Ivy

-Oorspronkelijk bericht-
Van: Gavin Simpson [mailto:gavin.simp...@ucl.ac.uk] 
Verzonden: woensdag 14 april 2010 21:33
Aan: JANSEN, Ivy
CC: r-help@r-project.org
Onderwerp: Re: [R] GAMM : how to use a smoother for some levels of a
variable, and a linear effect for other levels?

On Wed, 2010-04-14 at 10:03 +0200, JANSEN, Ivy wrote:
> Hi,
>  
> I was reading the book on "Mixed Effects Models and Extensions in 
> Ecology with R" by Zuur et al.
> In Section 6.2, an example is discussed where a gamm-model is fitted, 
> with a smoother for time, which differs for each value of ID (4 
> different bird species). In earlier versions of R, the following code 
> was used
>  
> BM2<-gamm(Birds~Rain+ID+
>s(Time,by=as.numeric(ID=="Stilt.Oahu"))+
>s(Time,by=as.numeric(ID=="Stilt.Maui"))+
>s(Time,by=as.numeric(ID=="Coot.Oahu"))+
>s(Time,by=as.numeric(ID=="Coot.Maui")),
>  correlation=corAR1(form=~Time |ID ),
>  weights=varIdent(form=~1|ID))
>  
> However, in the current version of R, this does not work anymore, and 
> should be changed into
>  
> BM2<-gamm(Birds~Rain+ID+
>s(Time,by=ID),
>  correlation=corAR1(form=~Time |ID ),
>  weights=varIdent(form=~1|ID))
>  
> It turns out that 2 of the 4 smoothers have estimated degrees of 
> freedom of 1, so a linear effect would be sufficient.
> Now my question is how I need to change the code in order to have a 
> time smoother for ID=Coot.Oahu and ID=Coot.Maui, and a linear time 
> effect for ID=Stilt.Oahu and ID=Stilt.Maui. With the "old" R-code, 
> this seems trivial, but I don't have any idea how to do it in the 
> newest R-version (interactions with a dummy variable do not work in
gamm).

Isn't a smooth that uses 1 df == to a linear function? So doesn't the
current model already do what you want? You don't need to refit it with
two smooths and two linear parametric terms as the two models should be
effectively equivalent anyway.

Or have I misunderstood your question?

HTH

G

>  
> Thanks,
> Ivy
> 
> Druk dit bericht a.u.b. niet onnodig af.
> Please do not print this message unnecessarily.
> 
> 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.

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


Druk dit bericht a.u.b. niet onnodig af.
Please do not print this message unnecessarily.

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] envelope in spatstat

2010-04-15 Thread Adrian Baddeley

Tom Richardson wrote:


This query is regarding the use of the 'envelope' function in Spatstat.


For queries about a contributed package, please contact the package author.


My data can be represented as a point process with CONTINUOUS marks:

points <- ppp(x=x,y=y, marks=m, window= wind)

However the marks are alignments (lines), and so have to be treated
differently to normal scalar marks. Hence to create a mcf object with the
appropriate test function for alignment marks, I input 'func' (below)
suggested by Stoyan & Penttinen (1989):

func <- function(m1,m2) { sin(abs(m1-m2))^2}
mcf <- markcorr(points, func, normalise = TRUE, method="density")

So far, so good. 


I presume the "alignment" values 'm' are numerical values that represent 
angles (in radians). Otherwise the code above would be incorrect, 
because sin() works on angles in radians.



Using 'envelope' and 'rlabel' I would like to
check if the pattern in the data is  lost when randomly relabeling the mark
for each point. If the test function, 'func' were the usual G(m1,m2)=m1*m2,
then the following would work:

E <- envelope(points,  markcorr, nsim=20, simulate=expression(rlabel(points)))

However, in the above 'markcorr' calculates  G(m1,m2)=m1*m2  by default. So
need to specify the test function to be G(m1,m2)= sin(abs(m1-m2))^2.

[ ]

>

So how do I tell 'envelope' that I want to specify the mark correlation
test function ??


First look at help(markcorr). It says that the test function for the 
mark correlation is specified by the second argument to markcorr(), 
which has the formal name 'f'. So you want 'f' to be 'func'.


Now look at help(envelope). It says that the arguments "..." will be 
passed through to the function that is evaluated for each point pattern. 
So call envelope(points, markcorr, f=func) and the argument f=func will 
be passed to markcorr.


Thus:
   E <- envelope(points,  markcorr, nsim=20, f=func,
 simulate=expression(rlabel(points)))


Two other comments:
   (1) for efficiency you can replace sin(abs(m1-m2))^2
by  sin(m1-m2)^2.

   (2) if you take nsim=20 then the significance level is
   1/21 = 4.8% (one-sided) or 2/21 = 9.5% (two-sided).
   If you want a significance level of 5%, you need either
   nsim=19 (one-sided) or nsim=39 (two-sided).

Adrian Baddeley

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


Re: [R] Ranking correlation with R

2010-04-15 Thread Peter Ehlers

On 2010-04-14 16:04, David Nemer wrote:

Hello Guys, thank you all very much for the help!

Sorry for my total lack of knowledge in R... so I did the correlation.. and
got these results:


cor(A, C, method = "spearman")
[1] 0.4922165
cor(B, C, method = "spearman")
[1] 0.1922412
cor(A, B, method = "spearman")
[1] -0.00889328


I don't know how to interpret them... so the correlation is good when it is
really close to 1 or to 0? What about negative correlation??


Your questions suggest that it's time to do some studying.
Crack open a stats book (or at least check Wikipedia). There is
no such thing as a 'good' or 'bad' correlation. Everything
depends on context. You shouldn't use a statistic if you don't
understand it.

 -Peter Ehlers



Cheers,
--
David Nemer


On Sat, Apr 10, 2010 at 2:58 PM, Gabor Grothendieck
wrote:



Try this:


A<- c("file1.java", "file3.java", "file2.java")
B<- c("file2.java", "file4.java", "file1.java")
cor(A, B, method = "spearman")

[1] 0.5


On Fri, Apr 9, 2010 at 11:22 AM, David Nemer  wrote:

Hey Everyone,

Im fresh new in R, and Im supposed to write a code to give me a

correlation

between two rankings. So I have two ranking lists, which contain file

names,

e.g.:

Ranking list 1:
file1.java
file3.java
file2.java

Ranking list 2:
fiile2.java
file4.java
file1.java

I need to see how much are these two ranking lists are alike, get a
correlation between them. I dont even know where to start. Can anyone

bring

me some light or tips? Thank you in advance.

Cheers,
--
David Nemer

[[alternative HTML version deleted]]

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

http://www.R-project.org/posting-guide.html

and provide commented, minimal, self-contained, reproducible code.





[[alternative HTML version deleted]]

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




--
Peter Ehlers
University of Calgary

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


Re: [R] Question about R mode

2010-04-15 Thread Patrick Burns

On 15/04/2010 08:52, Paul Hiemstra wrote:

djack...@miners.utep.edu wrote:

Hello all,

I am using R to perform certain calculations on huge amounts of data.
In short I need a function that does the mode function, ie returns the
most common element. I looked at the mode function in R but it seems
to return the type of the data element you give it. Does such a method
exist? I have tried googling this to no avail as all the results lead
me back to the mode function I do not want.

I googled for "R calculate mode", the first hit was this result:

http://www.mail-archive.com/r-help@r-project.org/msg30197.html


But be careful: creating your own function
called 'mode' will mask the standard 'mode'
function.

If you desire to remain sane, name it something
else.

Pat



this is probably what you want.

cheers,
Paul

Thanks,

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




--
Patrick Burns
pbu...@pburns.seanet.com
http://www.burns-stat.com
(home of 'Some hints for the R beginner'
and 'The R Inferno')

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

2010-04-15 Thread Uwe Dippel
First my excuses if I keep bugging everyone in this list, but I am a 
newbie, and tend to find some behaviour that looks unexpected to me; and 
I would really appreciate to be pointed to some location that allows me 
to understand more about this software. Here is my next question:

> par(mfrow=c(1,1))
> qqnorm(rnorm(20))
> qqmath(rnorm(20))
> par(mfrow=c(3,4))
> for(i in 1:12)qqnorm(rnorm(20))
Until here everything works as expected, and the last line prints 12 
samples of qqnorm. However,

> for(i in 1:12)qqmath(rnorm(20))
is doing nothing at all.

As I wrote, I'd really appreciate the understand where this behaviour 
comes from.


Thanks in advance,

Uwe

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


Re: [R] Question about R mode

2010-04-15 Thread Paul Hiemstra

djack...@miners.utep.edu wrote:

Hello all,

I am using R to perform certain calculations on huge amounts of data.  In short 
I need a function that does the mode function, ie returns the most common 
element.  I looked at the mode function in R but it seems to return the type of 
the data element you give it.  Does such a method exist?  I have tried googling 
this to no avail as all the results lead me back to the mode function I do not 
want.
  

I googled for "R calculate mode", the first hit was this result:

http://www.mail-archive.com/r-help@r-project.org/msg30197.html

this is probably what you want.

cheers,
Paul

Thanks,

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


--
Drs. Paul Hiemstra
Department of Physical Geography
Faculty of Geosciences
University of Utrecht
Heidelberglaan 2
P.O. Box 80.115
3508 TC Utrecht
Phone:  +3130 274 3113 Mon-Tue
Phone:  +3130 253 5773 Wed-Fri
http://intamap.geo.uu.nl/~paul
http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770

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

2010-04-15 Thread arnaud Gaboury
Dear group,

Here is a data.frame, "lme":

> lme
  DESCRIPTION CLOSING.PRICE POSITION
4PRIMARY NICKEL USD 04/06/1025,755.71000
5PRIMARY NICKEL USD 10/06/1025,760.86000
6  PRM HGH GD ALUMINIUM USD 09/07/10 2,415.90000
8  SPCL HIGH GRADE ZINC USD 06/07/10 2,420.1000   -1
9  SPCL HIGH GRADE ZINC USD 07/07/10 2,420.4100   -1
10 SPCL HIGH GRADE ZINC USD 08/07/10 2,420.73001
11 SPCL HIGH GRADE ZINC USD 09/07/10 2,421.05001
12 SPCL HIGH GRADE ZINC USD 13/04/10 2,388.43000
13 SPCL HIGH GRADE ZINC USD 14/04/10 2,389.0
14 SPCL HIGH GRADE ZINC USD 15/04/10 2,389.57000
15 SPCL HIGH GRADE ZINC USD 17/05/10 2,402.29000
16 SPCL HIGH GRADE ZINC USD 18/05/10 2,402.6400   -2

DESCRIPTION and CLOSING.PRICE are factors, POSITION is numeric.

I want to sum POSITION by products, i.e. PRIMARY NICKEL, PRM HGH GD
ALUMINIUM and SPCL HIGH GRADE ZINC. The problem is that, as you can see,
there is a different date as a part of each product description. Can anyone
tell me how to get rid of these dates so I can sum the position column? The
number of rows is not fixed and will change every day.

TY.

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

2010-04-15 Thread Paul Hiemstra

余舟 wrote:

Huhu,

Thank you for all you guys. readline works.

I hope R can be more and more powerful to deal with strings.
  

Strings and power come from regular expressions, check out ?regexpr.

cheers,
Paul

Thank you so much;
Zhou

2010/4/14 Erik Iverson 

  

David Scott wrote:



Erik Iverson wrote:

  

?? wrote:



Thank you for your reply.

My objective is simple. Assume  I have a constant vector, say Vector. in
C++ code, I want to do:


int index;
cout<<"Please enter the index of the element you want to look at Vector
:";
cin>>index
cout<  

Isn't that what the file argument of ?scan says?  I think?

file: the name of a file to read data values from.  If the
  specified file is ‘""’, then input is taken from the keyboard
  (or whatever ‘stdin()’ reads if input is redirected or R is
  embedded).




I think the required function is readline which prompts for user input.

?readline


  

Great, didn't know that one.  The example in ?readline is hilarious.




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



--
Drs. Paul Hiemstra
Department of Physical Geography
Faculty of Geosciences
University of Utrecht
Heidelberglaan 2
P.O. Box 80.115
3508 TC Utrecht
Phone:  +3130 274 3113 Mon-Tue
Phone:  +3130 253 5773 Wed-Fri
http://intamap.geo.uu.nl/~paul
http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770

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


Re: [R] histogram

2010-04-15 Thread Paul Hiemstra

Santosh wrote:

Dear R gurus...

How do I control "smoothing" of a density plot in panel.densityplot when
using histogram?

Thanks much,
Santosh

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

Hi,

From ?panel.densityplot, argument darg, I was referred to ?density. I 
think the 'bw' argument is what you need. Pass it to panel.densityplot 
in the darg argument.


cheers,
Paul

--
Drs. Paul Hiemstra
Department of Physical Geography
Faculty of Geosciences
University of Utrecht
Heidelberglaan 2
P.O. Box 80.115
3508 TC Utrecht
Phone:  +3130 274 3113 Mon-Tue
Phone:  +3130 253 5773 Wed-Fri
http://intamap.geo.uu.nl/~paul
http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Automating searching text for key words

2010-04-15 Thread LCOG1

Hello all, 
Im doing some content analysis of news stories and i am looking for a
way to sort through different text lists searching for specified words then
storing the results, at this point just the count.  Heres what i have so
far:

#Load data frame of wed address to load ->Creates raw word data

#Create web addresses to where text data is located
WebAdds<-c("
http://anitasdailyshowpage.tripod.com/transcripts/2002bushisms.htm","http://anitasdailyshowpage.tripod.com/transcripts/2002wasntcorrspondent.htm";)
#Create text data by accessing website and putting all text from page into a
list where each element
#is represents by a word 


#Loop through and load  text from  all website addresses
WordData_<-list()
for(i in 1:length(WebAdds)){
AddToUse<-WebAdds[i]
Select.WebAdd<-AddToUse
Select.WebAdd<-as.character(Select.WebAdd)
#Remove blanks from address to it can be read
Select.WebAdd<-sub("[[:blank:]]", "", Select.WebAdd) 
WordData_[[i]]<- scan(url(Select.WebAdd), what = "character") 
  }
  #Define words to look for
 SearchWords_ <-c("Bush","actor")

#Create lists to store retunred values WordDataResults_<-list()
 AllWordDataResults_<-list()
 WordDataResults_<-list()

 for(i in 1:length(WordData_)){
   
for(j in 1:length(SearchWords_)){
#Loop through all transcripts searching for each of the words in the
search list
 WordData.X <- sub(paste("",  SearchWords_[j], ").*", sep=""),
"\\1",WordData_[[i]] )
# check if no match in original string; replace with 'other'
 match <- grep(SearchWords_[j], WordData.X)
WordDataResults_[[j]]<-WordData.X[match]
 AllWordDataResults_[[i]]<- WordDataResults_[[j]]
}

}

AllWordDataResults_

which returns 
[[1]]
character(0)

[[2]]
[1] "actor."

This result basically shows that the word actor was found in the 2nd web
page searched.  It should show a "Bush" , with a number of
varietiest(e.g."Bush-isms""Bush-ism" "Bush","  "Bush"." 
"Bush?"," ,"Bush" "Bush"  AND and "Actor" .

So what happens above is i load to web pages in for sample content to search
through then each word is compared to each of the web pages.  Any insight in
to how to make the basic operation of above would be appreciated as well,
but this is the best i could come up with at this point.  Thanks for any
help.

Cheers, 
JR

-- 
View this message in context: 
http://n4.nabble.com/Automating-searching-text-for-key-words-tp1856444p1856444.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] Efficient algorithm to get a solution path for ridge regression?

2010-04-15 Thread Kenneth Lo
With the use of the LARS algorithm, a path of solutions corresponding  
to a sequence of the regularization parameter can be obtained for  
LASSO (or even the elastic net, a hybrid between LASSO and ridge) at  
the cost of one linear regression. In terms of computational speed  
LASSO seems to have beaten ridge regression, the solution of which  
needs to be computed individually, at the cost of one linear  
regression, for each regularization parameter. Is there any efficient  
method to compute a path of solutions for ridge regression  
corresponding to a sequence of the regularization parameter? Thanks.


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


[R] Question about R mode

2010-04-15 Thread djackson

Hello all,

I am using R to perform certain calculations on huge amounts of data.  In short 
I need a function that does the mode function, ie returns the most common 
element.  I looked at the mode function in R but it seems to return the type of 
the data element you give it.  Does such a method exist?  I have tried googling 
this to no avail as all the results lead me back to the mode function I do not 
want.

Thanks,

Don
  
[[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] grofit

2010-04-15 Thread alexander russell
Hello,
I would like to ask about the statistic used for initial values for models
built with grofit. Is the mean (of the experiments or cases) at t1 used?
Also at the other time points?
regards,
Russell

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


<    1   2