Re: [R] tcltk error compiling R 2.13.0 under Windows 7 x64

2010-12-14 Thread Uwe Ligges



On 14.12.2010 02:26, Peter Langfelder wrote:

On Mon, Dec 13, 2010 at 4:33 PM, Joshua Wileyjwiley.ps...@gmail.com  wrote:

Hi All,

I am trying to compile R 2.13.0 r53834 on 64-bit Windows 7 (home
premium) using Rtools212.exe from Duncan Murdoch's site.  I (think) I
followed the installation guide for Windows.  When installing Rtools,
made sure I was installing 64-bit tools (including tcltk), etc.  I
created a copy of MkRules.local where I selected 64 bit instead of 32
architecture.  When I run:

C:\R\R-devel\src\gnuwin32  make all recommended

I get the following error at the very end:

building package 'tcltk'
making init.d from init.c
making tcltk.d from tcltk.c
making tcltk_win.d from tcltk_win.c
x86_64-w64-mingw32-gcc -I../../../../include -I ../../../../Tcl/include -DWi


Note also that the quotes above are suspicious in
../../../../Tcl/include
...

Uwe Ligges



n32 -O2 -Wall  -std=gnu99 -c init.c -o init.o
In file included from init.c:22:0:
tcltk.h:23:17: fatal error: tcl.h: No such file or directory
compilation terminated.
make[4]: *** [init.o] Error 1
make[3]: *** [mksrc-win2] Error 1
make[2]: *** [all] Error 2
make[1]: *** [R] Error 1
make: *** [all] Error 2


Just in case no one knowledgeable answers, here's my shot in the dark
(I'm mostly a linux user)... the compiler is looking for .h files in
the directories listed in the --I options to gcc, which seems to be
Tcl, not Tcl64. The compiler also defines a macro Win32 which to my
untrained eyes seems suspicious since you are trying to produce a
64-bit executable, right (although perhaps Win32 also applies to
64-bit version, I'm not sure)? Maybe your selection of 64 bit
architecture wasn't honored - is the compiler reading the modified
copy or the original of MkRules?

Peter

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

2010-12-14 Thread Gavin Simpson
On Mon, 2010-12-13 at 01:55 -0800, jagdeesh_mn wrote:
 
 Prof Brian Ripley wrote:
snip /
 
 Thanks Mr. Brian. That kind of answers my query. 
 
 On the same note I would like to ask few other questions. Sorry if you find
 them naive, I am a novice in this subject and am trying to get a grip on
 things. 
 
 1. I am using R package using my code and the fitted object looks like this
 :
 
 The Model representation :
 n= 60 
 
 node), split, n, deviance, yval
   * denotes terminal node
 
  1) root 60 983551500 12615.670  
2) dataFrame[, 6]='Small' 13  21804710  7682.385 *
3) dataFrame[, 6]='Compact','Large','Medium','Sporty','Van' 47 557851600
 13980.190  
  6) dataFrame[, 3]='Japan/USA','Korea','USA' 29 13105 12673.030  
   12) dataFrame[, 6]='Compact','Sporty' 14  11426050 11055.570 *
   13) dataFrame[, 6]='Large','Medium','Van' 15  48812470 14182.670 *
  7) dataFrame[, 3]='France','Germany','Japan','Sweden' 18 297418200
 16086.170 * 
 
 What does the term deviance here stand for?

At this point, go an read up on the theory of classification and
regression trees. Depending on how you fitted your tree (what options
used, what type of response modelled) the deviance could be computed in
different ways. In short it is a measure of how impure each node of the
tree is.

See the References section of ?rpart

HTH

G

 2. Could you also suggest me some readings on the topic of CnR trees
 specific to R with case studies?
 
 Regards,
 Jagdeesh

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

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


Re: [R] Re : Re: descriptive statistics

2010-12-14 Thread Jim Lemon

On 12/14/2010 01:14 AM, effeesse wrote:


I am sorry, but I cannot understand how to use the summary function. Maybe,
if I describe my needs, you could sketch a line that could work.
In the data set variable V can take values 1 to 14. For the subgroup of
individuals where V takes value =1 I want the mean and variance of a
certain set of other variables (V1, V2, V3, V4, V5). And this for all the
other subgroups for values 2 to 14.
What do you suggest?


Step 1 - In a reproducible example one makes up some data and does 
something to it to show how it is or isn't working. Clearly, you don't 
know how to do that yet, so here's how.


mydataframe-data.frame(V=sample(1:14,100,TRUE),
 V1=rnorm(100),V2=runif(100),V3=sample(-3:3,100,TRUE),
 V4=sample(0:1,100,TRUE),V5=rpois(100,3))

If you run this code, you will then have a data frame that may not look 
like what you want, but it will serve as an example. In my initial post, 
I assumed that you wanted some summary statistic for each of the 
variables V1 to V5, broken down by V. That's easy:


by(mydataframe[c(V1,V2,V3,V4,V5)],
 mydataframe$V,mean)

If you run that code, you will get a big array of all of the means of 
all of the V1-V5 columns broken down by the V column as you asked. Now 
maybe you want both the mean and variance in one shot:


by_many-function(x,by,stats) {
 nfun=length(stats)
 myoutputlist-vector(list,nfun)
 for(fun in 1:nfun)
  myoutputlist[[fun]]-by(x,by,get(stats[fun]))
 names(myoutputlist)-stats
 return(myoutputlist)
}
by_many(mydataframe[c(V1,V2,V3,V4,V5)],
 mydataframe$V,stats=c(mean,var))

The first part defines a function that will call by for each statistic 
that you pass in stats, which now has to be the name of the function 
rather than the function. You will have to pick your variances out of 
the diagonal of the matrices due to the way var works.


So have a look at these and work out if they come close to doing what 
you want.


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] Saving iterative components

2010-12-14 Thread Annalaura

Thanks a lot Uwe Ligges, I've abandoned R for a few time but now I'm working
with it, so I've a question about the last problem that you solved: instead
to write 
cv_1994- idw.cv(X01_1994)
cv_1995- idw.cv(X01_1995)
cv_1996- idw.cv(X01_1996)
cv_1997- idw.cv(X01_1997)
.  
cv_2006- idw.cv(X01_2006)
cv_2007- idw.cv(X01_2007)
cv_2008- idw.cv(X01_2008)
can I use a more compact expression
Thanks


-- 
View this message in context: 
http://r.789695.n4.nabble.com/Saving-iterative-components-tp2553676p3086697.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] Drawing Maps of detailed Australian regions

2010-12-14 Thread Wang, Kevin (SYD)
Hi all,
 
I'm trying to draw a bubble plot over a map -- where the map shows local 
government areas (LGA) in Australia (or other structures under the Australian 
Standard Geographical Classification), but am not sure where I can find the 
data to plot such maps (e.g. draw the state of Northern Territory but also 
showing LGA divisions).
 
Any help will be greatly appreciated, apologies if this is a simple question -- 
this is the first time I'm trying to draw a map in R :).
 
Cheers
Kev
 
Kevin Wang 
Senior Advisor, Health and Human Services Practice 
Government Advisory Services

KPMG 
10 Shelley Street 
Sydney  NSW  2000  Australia

Tel +61 2 9335 8282 
Fax +61 2 9335 7001

kevinw...@kpmg.com.au


**

The information in this e-mail is confidential and may be legally
privileged. It is intended solely for the addressee. Access to this
e-mail by anyone else is unauthorised. If you have received this
communication in error, please notify us immediately by return
e-mail with the subject heading Received in error or telephone
+61 2 93357000, then delete the email and destroy any copies of it.
If you are not the intended recipient, any disclosure, copying,
distribution or any action taken or omitted to be taken in reliance
on it, is prohibited and may be unlawful. Any opinions or advice
contained in this e-mail are subject to the terms and conditions
expressed in the governing KPMG client engagement letter. Opinions,
conclusions and other information in this e-mail and any
attachments that do not relate to the official business of the firm
are neither given nor endorsed by it. 

KPMG cannot guarantee that e-mail communications are secure or
error-free, as information could be intercepted, corrupted,
amended, lost, destroyed, arrive late or incomplete, or contain
viruses. 

KPMG, an Australian partnership and a member firm of the KPMG
network of independent member firms affiliated with KPMG
International Cooperative (“KPMG International”), a Swiss entity. 
KPMG International provides no services to clients.  

Liability limited by a scheme approved under Professional Standards
Legislation. 

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


Re: [R] Saving iterative components

2010-12-14 Thread Liviu Andronic
On Tue, Dec 14, 2010 at 10:34 AM, Annalaura annalaura.ru...@imaa.cnr.it wrote:

 Thanks a lot Uwe Ligges, I've abandoned R for a few time but now I'm working
 with it, so I've a question about the last problem that you solved: instead
 to write
 cv_1994- idw.cv(X01_1994)
 cv_1995- idw.cv(X01_1995)
 cv_1996- idw.cv(X01_1996)
 cv_1997- idw.cv(X01_1997)
 .
 cv_2006- idw.cv(X01_2006)
 cv_2007- idw.cv(X01_2007)
 cv_2008- idw.cv(X01_2008)
 can I use a more compact expression

Yes. There are nicer ways to formulate the problem (and the solution),
but without access to the object all I can is a shot in the dark.
##obtain a vector of variable names
vars - names(Tmese[, -(1:2)])
##apply the function 'idw.cv' iteratively, each time
##using a 'vars' element as the functions first argument;
##store the results in a list
res - lapply(vars, idw.cv)
res

Regards
Liviu

PS For more on loops and the apply family check [1].
[1] http://promberger.info/files/rnews-vectorvsloops2008.pdf


 Thanks


 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Saving-iterative-components-tp2553676p3086697.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.




-- 
Do you know how to read?
http://www.alienetworks.com/srtest.cfm
http://goodies.xfce.org/projects/applications/xfce4-dict#speed-reader
Do you know how to write?
http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail

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


Re: [R] Saving iterative components

2010-12-14 Thread Ivan Calandra

Hi,

I'm trying to understand when and how to use do.call().
In this case, would it work with do.call() instead of lapply(), like this?
vars - list(names(Tmese[, -(1:2)]))
res - do.call(idw.cv, vars)

Thanks,
Ivan

Le 12/14/2010 11:48, Liviu Andronic a écrit :

On Tue, Dec 14, 2010 at 10:34 AM, Annalauraannalaura.ru...@imaa.cnr.it  wrote:

Thanks a lot Uwe Ligges, I've abandoned R for a few time but now I'm working
with it, so I've a question about the last problem that you solved: instead
to write
cv_1994- idw.cv(X01_1994)
cv_1995- idw.cv(X01_1995)
cv_1996- idw.cv(X01_1996)
cv_1997- idw.cv(X01_1997)
.
cv_2006- idw.cv(X01_2006)
cv_2007- idw.cv(X01_2007)
cv_2008- idw.cv(X01_2008)
can I use a more compact expression


Yes. There are nicer ways to formulate the problem (and the solution),
but without access to the object all I can is a shot in the dark.
##obtain a vector of variable names
vars- names(Tmese[, -(1:2)])
##apply the function 'idw.cv' iteratively, each time
##using a 'vars' element as the functions first argument;
##store the results in a list
res- lapply(vars, idw.cv)
res

Regards
Liviu

PS For more on loops and the apply family check [1].
[1] http://promberger.info/files/rnews-vectorvsloops2008.pdf



Thanks


--
View this message in context: 
http://r.789695.n4.nabble.com/Saving-iterative-components-tp2553676p3086697.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.






--
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Museum
Abt. Säugetiere
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231
ivan.calan...@uni-hamburg.de

**
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/1525_8_1.php

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


Re: [R] spatial clusters

2010-12-14 Thread Roger Bivand

SKATER is included in the spdep package, and was contributed by its original
authors.

Roger


Georg Ruß wrote:
 
 On 10/12/10 23:26:28, dorina.lazar wrote:
 I am looking for a clustering method usefull to classify the countries in
 some clusters taking account of: a) the geographical distance (in km)
 between countries  and b) of some macroeconomic indicators (gdp, life
 expectancy...).
 
 Hi Dorina,
 
 ...
 Efficient regionalization techniques for socio-economic geographical units
 using minimum spanning trees (SKATER)
 
 I haven't seen too many R implementations yet, though.
 
 You may also try the R-sig-geo mailing list, because your data look geo
 :-) https://stat.ethz.ch/mailman/listinfo/r-sig-geo
 
 Regards,
 Georg.
 --
 Research Assistant
 Otto-von-Guericke-Universität Magdeburg
 resea...@georgruss.de
 http://research.georgruss.de
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 


-
Roger Bivand
Economic Geography Section
Department of Economics
Norwegian School of Economics and Business Administration
Helleveien 30
N-5045 Bergen, Norway

-- 
View this message in context: 
http://r.789695.n4.nabble.com/spatial-clusters-tp3082728p3086903.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] Drawing Maps of detailed Australian regions

2010-12-14 Thread Barry Rowlingson
On Tue, Dec 14, 2010 at 10:45 AM, Wang, Kevin (SYD)
kevinw...@kpmg.com.au wrote:
 Hi all,

 I'm trying to draw a bubble plot over a map -- where the map shows local 
 government areas (LGA) in Australia (or other structures under the Australian 
 Standard Geographical Classification), but am not sure where I can find the 
 data to plot such maps (e.g. draw the state of Northern Territory but also 
 showing LGA divisions).

 Any help will be greatly appreciated, apologies if this is a simple question 
 -- this is the first time I'm trying to draw a map in R :).


 A second's googling leads me to an aussie gov site with downloadable
shapefiles:

http://www.abs.gov.au/AUSSTATS/a...@.nsf/DetailsPage/1259.0.30.001July%202010?OpenDocument

shapefiles can be read in R using the rgdal package. Get that, get
'sp', get 'maptools' - get mapping!

 Any other problems, head over to the r-sig-geo mailing list!

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.


Re: [R] Drawing Maps of detailed Australian regions

2010-12-14 Thread Roger Bivand

Please consider posting to R-sig-geo at 
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
https://stat.ethz.ch/mailman/listinfo/r-sig-geo , where maybe someone will
be able to point you to a data source.

Roger


Wang, Kevin (SYD) wrote:
 
 Hi all,
  
 I'm trying to draw a bubble plot over a map -- where the map shows local
 government areas (LGA) in Australia (or other structures under the
 Australian Standard Geographical Classification), but am not sure where I
 can find the data to plot such maps (e.g. draw the state of Northern
 Territory but also showing LGA divisions).
  
 Any help will be greatly appreciated, apologies if this is a simple
 question -- this is the first time I'm trying to draw a map in R :).
  
 Cheers
 Kev
  
 Kevin Wang 
 Senior Advisor, Health and Human Services Practice 
 Government Advisory Services
 
 KPMG 
 10 Shelley Street 
 Sydney  NSW  2000  Australia
 
 Tel +61 2 9335 8282 
 Fax +61 2 9335 7001
 
 kevinw...@kpmg.com.au
 
 
 **
 
 The information in this e-mail is confidential and may be legally
 privileged. It is intended solely for the addressee. Access to this
 e-mail by anyone else is unauthorised. If you have received this
 communication in error, please notify us immediately by return
 e-mail with the subject heading Received in error or telephone
 +61 2 93357000, then delete the email and destroy any copies of it.
 If you are not the intended recipient, any disclosure, copying,
 distribution or any action taken or omitted to be taken in reliance
 on it, is prohibited and may be unlawful. Any opinions or advice
 contained in this e-mail are subject to the terms and conditions
 expressed in the governing KPMG client engagement letter. Opinions,
 conclusions and other information in this e-mail and any
 attachments that do not relate to the official business of the firm
 are neither given nor endorsed by it. 
 
 KPMG cannot guarantee that e-mail communications are secure or
 error-free, as information could be intercepted, corrupted,
 amended, lost, destroyed, arrive late or incomplete, or contain
 viruses. 
 
 KPMG, an Australian partnership and a member firm of the KPMG
 network of independent member firms affiliated with KPMG
 International Cooperative (“KPMG International”), a Swiss entity. 
 KPMG International provides no services to clients.  
 
 Liability limited by a scheme approved under Professional Standards
 Legislation. 
 
 **
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 


-
Roger Bivand
Economic Geography Section
Department of Economics
Norwegian School of Economics and Business Administration
Helleveien 30
N-5045 Bergen, Norway

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Drawing-Maps-of-detailed-Australian-regions-tp3086816p3086909.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] multivariate multi regression

2010-12-14 Thread peter dalgaard

On Dec 14, 2010, at 03:21 , Bastiaan Bergman wrote:

 That doesn't work, one would get two different answers depending on the
 order of execution.
 
 The physics is: Overlay error on a Silicon wafer. One wafer has many flash
 fields, each flash field has multiple locations where the overlay error is
 measured (as: dX,dY offset). If one contemplates that the error is caused by
 a rotation of the flash field then we can say (dX,dY)=(-Y,X)*RotAngle. If in
 addition we have a scaling error: (dX,dY)=(X*XScale,Y*YScale) than the total
 model is:
 dX~X*XScale-Y*RotAngle
 dY~Y*YScale+X*RotAngle
 
 Now I want to find the values for XScale, YScale and RotAngle
 Length(dX)==length(dY)==length(X)==length(Y)==number of measured sites on a
 wafer
 
 Hope this clarifies...

Not completely, but I can see the general picture. 

I think the main thing is to rewrite the formula as

dX = XScale * X + YScale * 0 + RotAngle * (-Y) + eX
dY = XScale * 0 + YScale * Y + RotAngle * X+ eY

(where eX and eY are noise terms)

Then string together all your data pairs as

dX1
dY1
dX2
dY2
...

and the corresponding design matrix

X1  0 -Y1
0  Y1  X1
X2  0 -Y2
0  Y2  X2
...

This sets up the joint linear model that you want. (Technically, it could be 
easier to put all the dX's first, then all the dY's, though.)

The remaining question is what you assume about the eX and eY terms. If they 
can be assumed to be independent and have the same variance, you're done. If 
they are correlated and/or have different variance, then I think you need to 
look in the direction of lme() with a suitable variance function.



 
 
 -Original Message-
 From: David Winsemius [mailto:dwinsem...@comcast.net] 
 Sent: Monday, December 13, 2010 6:06 PM
 To: Bastiaan Bergman
 Cc: r-help@r-project.org
 Subject: Re: [R] multivariate multi regression
 
 
 On Dec 13, 2010, at 8:46 PM, Bastiaan Bergman wrote:
 
 Hello,
 
 
 I want to model my data with the following model:
 
 
 Y1=X1*coef1+X2*coef2
 Y2=X1*coef2+X2*coef3
 
 
 Note: coef2 appears in both lines
 
 Xi, Yi is input versus output data respectively
 
 How can I do this in R?
 
 I got this far:
 
 lm(Y1~X1+X2,mydata)
 
 now how do I add the second line of the model including the cross
 dependency?
 
 The usual way would be to extract coef2 from the object returned from  
 the first invocation of lm(...)  and use it to calculate an offset  
 term in a second model. It would not have any variance calculated  
 since you are forcing it to be what was returned in the first model.  
 Now, what is it that you are really trying to do with this procedure?
 
 -- 
 David.
 
 
 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.

-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@gmail.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] multivariate multi regression / aligning objects anything in bio or mapping?

2010-12-14 Thread Mike Marchywka






 From: pda...@gmail.com
 Date: Tue, 14 Dec 2010 13:50:27 +0100
 To: bastiaan.berg...@wdc.com
 CC: r-help@r-project.org
 Subject: Re: [R] multivariate multi regression


 On Dec 14, 2010, at 03:21 , Bastiaan Bergman wrote:

  That doesn't work, one would get two different answers depending on the
  order of execution.
 
  The physics is: Overlay error on a Silicon wafer. One wafer has many flash
  fields, each flash field has multiple locations where the overlay error is
  measured (as: dX,dY offset). If one contemplates that the error is caused by
  a rotation of the flash field then we can say (dX,dY)=(-Y,X)*RotAngle. If in
  addition we have a scaling error: (dX,dY)=(X*XScale,Y*YScale) than the total
  model is:
  dX~X*XScale-Y*RotAngle
  dY~Y*YScale+X*RotAngle
 


First of course if you have a model it would help to get the equations right
for tanslation, scale, and rotation around an arbitrary origin. If you
can live with 3D, there may be something in the bio packages for aligning
molecules with no assumptions about their relative initial orientations.
Anyone know off hand if objection alignment exists in any bio or mapping
packages? I would imagine related tasks come up in building a coherent map
out of overlapping pieces, something which may have significant support too. 






  Now I want to find the values for XScale, YScale and RotAngle
  Length(dX)==length(dY)==length(X)==length(Y)==number of measured sites on a
  wafer
 
  Hope this clarifies...

 Not completely, but I can see the general picture.

 I think the main thing is to rewrite the formula as

 dX = XScale * X + YScale * 0 + RotAngle * (-Y) + eX
 dY = XScale * 0 + YScale * Y + RotAngle * X + eY

 (where eX and eY are noise terms)

 Then string together all your data pairs as

 dX1
 dY1
 dX2
 dY2
 ...

 and the corresponding design matrix

 X1 0 -Y1
 0 Y1 X1
 X2 0 -Y2
 0 Y2 X2
 ...

 This sets up the joint linear model that you want. (Technically, it could be 
 easier to put all the dX's first, then all the dY's, though.)

 The remaining question is what you assume about the eX and eY terms. If they 
 can be assumed to be independent and have the same variance, you're done. If 
 they are correlated and/or have different variance, then I think you need to 
 look in the direction of lme() with a suitable variance function.



 
 
  -Original Message-
  From: David Winsemius [mailto:dwinsem...@comcast.net]
  Sent: Monday, December 13, 2010 6:06 PM
  To: Bastiaan Bergman
  Cc: r-help@r-project.org
  Subject: Re: [R] multivariate multi regression
 
 
  On Dec 13, 2010, at 8:46 PM, Bastiaan Bergman wrote:
 
  Hello,
 
 
  I want to model my data with the following model:
 
 
  Y1=X1*coef1+X2*coef2
  Y2=X1*coef2+X2*coef3
 
 
  Note: coef2 appears in both lines
 
  Xi, Yi is input versus output data respectively
 
  How can I do this in R?
 
  I got this far:
 
  lm(Y1~X1+X2,mydata)
 
  now how do I add the second line of the model including the cross
  dependency?
 
  The usual way would be to extract coef2 from the object returned from
  the first invocation of lm(...) and use it to calculate an offset
  term in a second model. It would not have any variance calculated
  since you are forcing it to be what was returned in the first model.
  Now, what is it that you are really trying to do with this procedure?
 
  --
  David.
 
 
  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.

 --
 Peter Dalgaard
 Center for Statistics, Copenhagen Business School
 Solbjerg Plads 3, 2000 Frederiksberg, Denmark
 Phone: (+45)38153501
 Email: pd@cbs.dk Priv: pda...@gmail.com

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


[R] problems with lattice barchart

2010-12-14 Thread Juan Santos

   Hello everybody!
I´m trying to create figures summarizing the abundance of a given species
   (y), by its length classes (x), year (conditional factor) and a grouping
   named as fraction. I am using the lattice´s barchart but some problems
   arises:
   When  I run the function, the sizes become characters, and this is the
   starting problem for me when trying to adjust the x-axis in order to achieve
   a  good-looking. In  particular,  I  have  found  that  when  range of
   length-classes is high, the output  yield a matted looking in the x-axis,
   which in some cases is unreadable. In order to achieve a wider space between
   x-axis annotations, I was trying to reduce the number of sizes shown in the
   figure,  but so far I got a few improvements in the final results. Here you
   will find a piece of the data frame,
x[1:25,]
  Length.class year   fraction y
   1 6 2006 Fraction.a 0
   2 7 2006 Fraction.a 0
   3 8 2006 Fraction.a   191
   4 9 2006 Fraction.a   784
   510 2006 Fraction.a38
   611 2006 Fraction.a  1135
   712 2006 Fraction.a  1810
   813 2006 Fraction.a  2836
   914 2006 Fraction.a  6625
   10   15 2006 Fraction.a  6414
   11   16 2006 Fraction.a 10554
   12   17 2006 Fraction.a 12423
   13   18 2006 Fraction.a 15260
   14   19 2006 Fraction.a 11126
   15   20 2006 Fraction.a  9830
   16   21 2006 Fraction.a  8460
   17   22 2006 Fraction.a  6062
   18   23 2006 Fraction.a  4382
   19   24 2006 Fraction.a  3555
   20   25 2006 Fraction.a  1792
   21   26 2006 Fraction.a  2220
   22   27 2006 Fraction.a  1235
   23   28 2006 Fraction.a   465
   24   29 2006 Fraction.a 0
   25   30 2006 Fraction.a59
   and this is the  barchart specifications,
   plot.i-barchart(x[,4]~x[,1]|x[,2],horizontal=F,stack=TRUE,layout=paneis,
   par.settings = simpleTheme(col = c(red3,olivedrab)),groups=x[,3],
   strip = strip.custom (bg = c('transparent'),par.strip.text = list(cex =
   0.8)),auto.key=list(columns=2),
   panel=function(...,box.width,border){
   panel.grid(h=-1,v=0)
   panel.abline(v=TML,col=red,lty=2)
   panel.barchart(...,box.width = .99,border=black)},
   ,xlab=Length Size,ylab=Y)
   Can someone guide me to solve the problem?

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

2010-12-14 Thread Uwe Wolfram
Dear R-Users,

I am trying to plot an ellipsoid like function that represents some
physical threshold in its eigenvalue space. I am facing a few problems
generating a figure I need for my thesis. A small example looks as
follwos where the two contour3d plots do NOT overlay as desired so you
may try plotting the surfaces one by one to see what I mean.


# begin example

require(rgl)
require(misc3d)
require(MASS);

f - function(x, y, z){
chi0=-0.6603368
eps0=0.006590395
xi0=0.01117194
(x^2 + y^2 + z^2 - chi0*(x*y + x*z + y*z))/eps0^2 + (x + y + z)/xi0
}
ff - function(x, y, z)x + y + z

open3d()
clear3d(all)
bg3d(color=#88)
light3d()

x - seq(-.02,.02,len=20)

# plot ellipsoid
contour3d(f,1,x,x,x,color=#FF,alpha=0.5)

# plot plane
contour3d(ff,1,x,x,x,color=#FF,alpha=0.5)

# plot data points
spheres3d(c(-0.009379952, 0.007899338), c(-0.00879318, 0.00700924),
c(-0.009009740, 0.007656409),radius=0.0005,color=#FF)

# plot hydrostatic pressure line 
lines3d(c(-0.012, 0.012), c(-0.012, 0.012), c(-0.012, 0.012),
col=#A8A8A8, lwd=4)

# end example


I have three questions regarding this problem and I hope you could help
me.

 1. How can I overlay the plan plotted using contours3d(ff, ...) and
the ellipsoid plotted with contours3d(f, ...)
 2. Instead of using spheres3d(...) I would love to use plot3d to
obtain proper x, y and z coordinate axes. Is there a possibility
to overly the contour3d() and line3d() commands with pot3d?
Otherwise is there a possibility to plot proper coordinate axes
with tics and such as usual R plots?
 3. How can I save the scene to an image? pdf(...) ... dev.off()
seems not to work on my machine. I am using Ubuntu on a 32 Bit
Laptop.

Thanks a  million for your help!

Uwe


Am Montag, den 13.12.2010, 10:20 -0500 schrieb Duncan Murdoch:
 On 13/12/2010 10:13 AM, Uwe Wolfram wrote:
  
 
  I am currently trying to fit a tensorial function in its principal
  coorinate system. The function is given by:
 
  1~(x1^2 + x2^2 + x3^2 - chi0*(x1*x2 + x1*x3 + x2*x3))/eps0^2 + (x1 + x2
  + x3)/xi0
 
  Where eps0 = 0.0066, chi0 = -0.66 and xi0 = 0.011 are obtained from
  experimental data using nls().I am able to plot the experimental points
  that delivered the parameters of the function. For my thesis, however, I
  need to overlay the fitted surface. So far I am using the following code
  which wonderfully plots the experimental points in 3D:
 
  ===
  # from demo(bivar)
  require(rgl)
  require(misc3d)
  require(MASS);
 
  # New window
  open3d()
  # clear scene:
  clear3d(all)
  # setup env. That is, background, light and so on:
  bg3d(color=#88)
  light3d()
  # spheres at points in principal strain space
  #spheres3d(e1,e2,e3,radius=0.00025,color=#FF)
  # draws points alternatively
  plot3d(e1,e2,e3, col=#FF)
  ===
 
  According to the examples on http://rgl.neoscientists.org/gallery.shtml
  I tried to overlay the point plot using surface3d. However, these were
  only functions of type y ~f(x1, x2). I think that the surface could be
  plotted if I could provide the gridpoints correctly. Using
  xyz.coords(1~(x1^2 + x2^2 + x3^2 - chi0*(x1*x2 + x1*x3 + x2*x3))/eps0^2
  + (x1 + x2 + x3)/xi0, y = NULL, z = NULL) did unfortunately not solve
  the problem.
 
  Is there any function that can generate the surface for the given
  function such as ContourPlot3D in Mathematica.
 
 See ?misc3d::contour3d


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

2010-12-14 Thread Duncan Murdoch

On 14/12/2010 8:45 AM, Uwe Wolfram wrote:

Dear R-Users,

I am trying to plot an ellipsoid like function that represents some
physical threshold in its eigenvalue space. I am facing a few problems
generating a figure I need for my thesis. A small example looks as
follwos where the two contour3d plots do NOT overlay as desired so you
may try plotting the surfaces one by one to see what I mean.


# begin example

require(rgl)
require(misc3d)
require(MASS);

f- function(x, y, z){
 chi0=-0.6603368
 eps0=0.006590395
 xi0=0.01117194
 (x^2 + y^2 + z^2 - chi0*(x*y + x*z + y*z))/eps0^2 + (x + y + z)/xi0
}
ff- function(x, y, z)x + y + z

open3d()
clear3d(all)
bg3d(color=#88)
light3d()

x- seq(-.02,.02,len=20)

# plot ellipsoid
contour3d(f,1,x,x,x,color=#FF,alpha=0.5)

# plot plane
contour3d(ff,1,x,x,x,color=#FF,alpha=0.5)

# plot data points
spheres3d(c(-0.009379952, 0.007899338), c(-0.00879318, 0.00700924),
c(-0.009009740, 0.007656409),radius=0.0005,color=#FF)

# plot hydrostatic pressure line
lines3d(c(-0.012, 0.012), c(-0.012, 0.012), c(-0.012, 0.012),
col=#A8A8A8, lwd=4)

# end example


I have three questions regarding this problem and I hope you could help
me.

  1. How can I overlay the plan plotted using contours3d(ff, ...) and
 the ellipsoid plotted with contours3d(f, ...)


Use add=TRUE in the second call to contour3d.  However, the level you 
chose (i.e. 1) never occurs in the range of your x,y,z data, so you 
won't see anything unless you change it.



  2. Instead of using spheres3d(...) I would love to use plot3d to
 obtain proper x, y and z coordinate axes. Is there a possibility
 to overly the contour3d() and line3d() commands with pot3d?
 Otherwise is there a possibility to plot proper coordinate axes
 with tics and such as usual R plots?


Use decorate3d() to add the axes etc, or axes3d() for just axes.

  3. How can I save the scene to an image? pdf(...) ... dev.off()
 seems not to work on my machine. I am using Ubuntu on a 32 Bit
 Laptop.


That's harder, but you can try rgl.snapshot() (for a bitmap copy in PNG 
format) or rgl.postscript() (for vector graphics in
ps, eps, tex, pdf, svg, or pgf, but with incomplete rendering of some 
scenes).


Duncan Murdoch


Thanks a  million for your help!

Uwe


Am Montag, den 13.12.2010, 10:20 -0500 schrieb Duncan Murdoch:
  On 13/12/2010 10:13 AM, Uwe Wolfram wrote:
  
  
I am currently trying to fit a tensorial function in its principal
coorinate system. The function is given by:
  
1~(x1^2 + x2^2 + x3^2 - chi0*(x1*x2 + x1*x3 + x2*x3))/eps0^2 + (x1 + x2
+ x3)/xi0
  
Where eps0 = 0.0066, chi0 = -0.66 and xi0 = 0.011 are obtained from
experimental data using nls().I am able to plot the experimental points
that delivered the parameters of the function. For my thesis, however, I
need to overlay the fitted surface. So far I am using the following code
which wonderfully plots the experimental points in 3D:
  
===
# from demo(bivar)
require(rgl)
require(misc3d)
require(MASS);
  
# New window
open3d()
# clear scene:
clear3d(all)
# setup env. That is, background, light and so on:
bg3d(color=#88)
light3d()
# spheres at points in principal strain space
#spheres3d(e1,e2,e3,radius=0.00025,color=#FF)
# draws points alternatively
plot3d(e1,e2,e3, col=#FF)
===
  
According to the examples on http://rgl.neoscientists.org/gallery.shtml
I tried to overlay the point plot using surface3d. However, these were
only functions of type y ~f(x1, x2). I think that the surface could be
plotted if I could provide the gridpoints correctly. Using
xyz.coords(1~(x1^2 + x2^2 + x3^2 - chi0*(x1*x2 + x1*x3 + x2*x3))/eps0^2
+ (x1 + x2 + x3)/xi0, y = NULL, z = NULL) did unfortunately not solve
the problem.
  
Is there any function that can generate the surface for the given
function such as ContourPlot3D in Mathematica.

  See ?misc3d::contour3d


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

2010-12-14 Thread Terry Therneau
 On Sun, 12 Dec 2010, jagdeesh_mn wrote:
 
 Hi,

 Suppose i have generated an object using the following :
 fit - rpart(Kyphosis ~ Age + Number + Start, data=kyphosis)

 And when i print fit, i get the following :

 n= 81

 node), split, n, loss, yval, (yprob)
  * denotes terminal node

 1) root 81 17 absent (0.7901235 0.2098765)
   2) Start=8.5 62  6 absent (0.9032258 0.0967742)
 4) Start=14.5 29  0 absent (1.000 0.000) *
 5) Start 14.5 33  6 absent (0.8181818 0.1818182)
  10) Age 55 12  0 absent (1.000 0.000) *
  11) Age=55 21  6 absent (0.7142857 0.2857143)
22) Age=111 14  2 absent (0.8571429 0.1428571) *
23) Age 111 7  3 present (0.4285714 0.5714286) *
   3) Start 8.5 19  8 present (0.4210526 0.5789474) *

 Is it possible to extract the splits alone as a matrix using
 rpart.object?
 If so, how?
 
 
 Regards,
 Jagdeesh

The best description of the rpart object is obtained with
help(rpart.object).  Each row of $frame describes one primary split.
More detailed descriptions of the (1 + ncompete + nprimary) split
variables for the node are found in the $splits and $csplits component.
You would need to look at summary.rpart to see how that is all indexed.
I would suggest grabbing a copy of the source code, since that contains
comments, which are stripped out when you print the R internal version.

Terry Therneau

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] rpart - how to estimate the “meaningful” predictors for an outcome (in classification t rees)

2010-12-14 Thread Tal Galili
Hi dear R-help memebers,

When building a CART model (specifically classification tree) using rpart,
it is sometimes obvious that there are variables (X's) that are meaningful
for predicting some of the outcome (y) variables - while other predictors
are relevant for other outcome variables (y's only).

*How can it be estimated, which explanatory variable is used for which of
the predicted value in the outcome variable?*

Here is an example code in which x2 is the only important variable for
predicting b (one of the y outcomes). There is no predicting variable for
c, and x1 is a predictor for a, assuming that x2 permits it.

How can this situation be shown using the an rpart fitted model?

N - 200
set.seed(5123)

x1 - runif(N)

x2 - runif(N)

x3 - runif(N)

y - sample(letters[1:3], N, T)

y[x1 .5] - a

y[x2 .1] - b

fit - rpart(y ~ x1+x2)

fit2 - prune(fit, cp= 0.07)

plot(fit2)

text(fit2, use.n=TRUE)

Thanks,

Tal



Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--

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

2010-12-14 Thread Sarah Goslee
Val,

Here's the complete console output. The graph produced is at:
http://www.functionaldiversity.org/temp/curve.png

R version 2.12.0 (2010-10-15)
Copyright (C) 2010 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: x86_64-redhat-linux-gnu (64-bit)

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.

 ls()
character(0)

 test- rnorm(5000,1000,100)
 test1 - subset(test, subset=(test  1100))
 d - density(test)

 png(curve.png)
 plot(d, main=Density of production, xlab=)

 xarea - c(1100, d$x[d$x  1100], c(max(test)))
 yarea - c(0, d$y[d$x  1100], 0)


 polygon(xarea, yarea, col=blue)

 curveheight - d$y[abs((d$x - mean(test1))) == min(abs((d$x - mean(test1]
 segments(x0=mean(test1), y0=0, x1=mean(test1), y1=curveheight, col=red, 
 lwd=2)
 dev.off()
null device
  1


Sarah


On Tue, Dec 14, 2010 at 8:59 AM, Val valkr...@gmail.com wrote:
 Hi Sara,

 Could you please send me your output as an attached file if it is possible?

 Thanks


  1. to shade or color (blue) the curve using the criterion that any
  values
  greater than 11,000
 
  I think I was not clear in the above point. I want shade not the line
  but
  the area under the curve,

 Here's an example of how to do that using polygon:
 http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=7

  and
  Your last line of code,
  segments(x0=mean(test1), y0=0, y1=curveheight)
 
  gave me the  following error message
 
  Error in segments(x0 = mean(test1), y0 = 0, y1 = curveheight) :
   element 3 is empty;
    the part of the args list of '.Internal' being evaluated was:
    (x0, y0, x1, y1, col = col, lty = lty, lwd = lwd, ...)
 
  could you check it please

 I checked it before I sent it to you. The code I provided works correctly
 on my computer.  (R 2.12.0, Linux).

 You could try this statement instead:
 segments(x0 = mean(test1), y0 = 0, x1=mean(test1), y1 = curveheight)

 Sarah

 --



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

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


Re: [R] Browsing through a dataframe page by page (like with shell command more)

2010-12-14 Thread Alexandre CESARI
Thank you all for your input.

View is quite nice, despite the fact that you need to be in a X session and
it seems(?) difficult to copy paste data out of the view.

page(my_var) works great and is most similar to what I had in mind.

TkListView seems interesting but quite slow for large list or frames.


Alexandre

On Mon, Dec 13, 2010 at 7:48 PM, Greg Snow greg.s...@imail.org wrote:

 For data frames the best is probably the View function (note capitol V)
 which opens the data frame in a spreadsheet like window that you can scroll
 through.

 For more complicated, list or list-like objects, look at TkListView in the
 TeachingDemos package.

 For more general investigation of data objects look at ?page and ?options
 specifically the pager section.

 --
 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 Alexandre CESARI
  Sent: Monday, December 13, 2010 3:49 AM
  To: r-help@r-project.org
  Subject: [R] Browsing through a dataframe page by page (like with shell
  command more)
 
  Hello,
 
  I'm looking for an easy way to display a data.frame (or other
  variables)
  page by page, similarly to what is possible on a file using the more
  command
  in a standard UNIX shell. Any help would be greatly appreciated.
 
  Thanks
 
  Alexandre
 
[[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.


[R] Question about cut()

2010-12-14 Thread Tianchan Niu
Dear all,
I would like to use cut() to make numerics to factors, the sample codes are as 
follows. However, the result is not what I want, since r[3] = 9 should be in 
the interval of 8-10% rather than 2-4%. Maybe cut() is not the right 
function to use for my situation. Please help.  r - c(1,1,9,1,1,1)
 col_no - as.factor(as.numeric(cut(r,c(0,2,4,6,8,10,100
 levels(col_no) - c(2%,2-4%,4-6%,6-8%,8-10%,10%)
 col_no
[1] 2%  2%  2-4% 2%  2%  2% 
Levels: 2% 2-4% 4-6% 6-8% 8-10% 10%Thanks,
Tianchan__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] lines and points without margin

2010-12-14 Thread Andrew Collier
hi,

i am sure that this is a trivial question but i have not been able to
find an answer by searching the mailing lists. i want to plot points on
a graph, joined by lines. the command that i am using is

points(x, y, type = b, pch = 21)

this plots nice open circles at the data points and draws lines between
them. however, the lines do not come all the way up to the edge of the
circles but stop some small distance away so that there is an empty
margin around the circles. is there a way to get rid of this margin?
my first guess was that there would be an option to par() but i did not
find anything there. any suggestions would be appreciated.

thanks!

best regards,
andrew.

-- 
Andrew B. Collier

Physicist
Waves and Space Plasmas Group
Hermanus Magnetic Observatory

Honorary Senior Lecturer tel: +27 31 2601157
Space Physics Research Institute fax: +27 31 2607795
University of KwaZulu-Natal, Durban, South Africagsm: +27 83 3813655

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] labelling of axis in plot.ca

2010-12-14 Thread Manderscheid Katharina
hi all,

how can i get correspondence analysis plots (package ca, plot.ca()) with the 
inertia on the two dimensions of the map?

thanks,
kat




[[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] lines and points without margin

2010-12-14 Thread baptiste auguie
Hi,

Try the following,

plot(1:10,rnorm(10),t=o)

## fill the points in white
plot(1:10,rnorm(10),t=o,pch=21,bg=white)

You could also try this with Grid graphics,

library(gridExtra)
# like type=o
grid.barbed(space=0)
# like type=b
grid.barbed(space=1)
# like the example above, but without filling the dots
grid.barbed(space=0.5)

(I may be wrong but don't recall that this parameter is tunable with
base graphics)

HTH,

baptiste

On 14 December 2010 16:33, Andrew Collier collie...@gmail.com wrote:
 hi,

 i am sure that this is a trivial question but i have not been able to
 find an answer by searching the mailing lists. i want to plot points on
 a graph, joined by lines. the command that i am using is

 points(x, y, type = b, pch = 21)

 this plots nice open circles at the data points and draws lines between
 them. however, the lines do not come all the way up to the edge of the
 circles but stop some small distance away so that there is an empty
 margin around the circles. is there a way to get rid of this margin?
 my first guess was that there would be an option to par() but i did not
 find anything there. any suggestions would be appreciated.

 thanks!

 best regards,
 andrew.

 --
 Andrew B. Collier

 Physicist
 Waves and Space Plasmas Group
 Hermanus Magnetic Observatory

 Honorary Senior Lecturer                             tel: +27 31 2601157
 Space Physics Research Institute                     fax: +27 31 2607795
 University of KwaZulu-Natal, Durban, South Africa    gsm: +27 83 3813655

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

2010-12-14 Thread effeesse

Thanks! I got the results! Now I would like to put them in a nice and
readable plot to see if there are outlier means or variances. Using
plot(by_many$mean) I got Error in by_many$mean : object of type 'closure'
is not subsettable.

Another question: I have done the principal components analysis on the same
group of variables (V1--V5) I used before. I'd like to get a similar
descriptive analysis of these principal components by variable V. Correct me
if I am wrong; should I run it on the scores of the 2 or 3 principal
components I obtained in the PCA?
-- 
View this message in context: 
http://r.789695.n4.nabble.com/descriptive-statistics-tp3085197p3086849.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] Question

2010-12-14 Thread Matthew Rosett

How do I determine if my data deviate from the normal distribution?
The sample size is 1000 (weights of people).

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Selecting non-empty elements after strsplit of string

2010-12-14 Thread Scott Chamberlain
Hello, 

I am attempting to manipulate strings in which there are differing amounts of 
whitespace before and after each element taht I want to keep (any word, letter, 
or number). However, after strsplit and unlist, I know how to select specific 
elements with [ ], but I want to select instead all elements that are not 
missing. That is, do not select any elements that are simply . 

output - c(a b     6)

gsub( ,,unlist(strsplit(output,  ,fixed=TRUE)))
[1] a b   6   

Thanks! Scott Chamberlain
[[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] Selecting non-empty elements after strsplit of string

2010-12-14 Thread Scott Chamberlain
Hello,

I am attempting to manipulate strings in which there are differing amounts
of whitespace before and after each element taht I want to keep (any word,
letter, or number). However, after strsplit and unlist, I know how to select
specific elements with [ ], but I want to select instead all elements that
are not missing. That is, do not select any elements that are simply .

output - c(a b     6)

gsub( ,,unlist(strsplit(output,  ,fixed=TRUE)))
[1] a b   6

Thanks! Scott Chamberlain

[[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] lines and points without margin

2010-12-14 Thread Ben Bolker
Andrew Collier collierab at gmail.com writes:

 i am sure that this is a trivial question but i have not been able to
 find an answer by searching the mailing lists. i want to plot points on
 a graph, joined by lines. the command that i am using is
 
 points(x, y, type = b, pch = 21)
 
 this plots nice open circles at the data points and draws lines between
 them. however, the lines do not come all the way up to the edge of the
 circles but stop some small distance away so that there is an empty
 margin around the circles. is there a way to get rid of this margin?
 my first guess was that there would be an option to par() but i did not
 find anything there. any suggestions would be appreciated.

  Does type=o do what you want?  (See ?plot )
  However, this actually overplots (which would be OK with filled
point types, or if you don't care if you have lines running across
your open points) -- it doesn't draw the line up to the edge of
the point.

  It looks like the size of the spacing is hard-coded at a fairly
deep level: in plot.c, within the do_plot_xy function, there is
a spacing factor which seems to be encoded as half the width of
standard character in the current plotting coordinates.

  Ben Bolker

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


Re: [R] writing sample values in to a file

2010-12-14 Thread Dieter Menne


chandu wrote:
 
   I am relatively new to R. I would like to know how can we write the
 realizations (for example generated through rnorm or runif) in to a data
 file. It would be very inefficient to first generate values and then write
 them in to file using write function. Instead, is there a way to
 generate 1 value at a time and append them in to the file.
 

It would be very inefficient. Sounds like you tried it.

n = 3
system.time(for (i in 1:n){
cat(rnorm(1),file=a.txt,append=TRUE)
 }
)
system.time(write.table(rnorm(n),file=b.txt))
 )
  
 user  system elapsed 
   3.988.66   16.11 

 system.time(write.table(rnorm(n),file=b.txt))
   user  system elapsed 
   0.590.010.61 

So the inefficient method is about 25 times faster.

Dieter



-- 
View this message in context: 
http://r.789695.n4.nabble.com/writing-sample-values-in-to-a-file-tp3086286p3087354.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] Question about cut()

2010-12-14 Thread Gavin Simpson
On Tue, 2010-12-14 at 15:40 +, Tianchan Niu wrote:
 Dear all,
 I would like to use cut() to make numerics to factors, the sample codes are 
 as follows. However, the result is not what I want, since r[3] = 9 should be 
 in the interval of 8-10% rather than 2-4%. Maybe cut() is not the right 
 function to use for my situation. Please help.  r - c(1,1,9,1,1,1)
  col_no - as.factor(as.numeric(cut(r,c(0,2,4,6,8,10,100
  levels(col_no) - c(2%,2-4%,4-6%,6-8%,8-10%,10%)
  col_no
 [1] 2%  2%  2-4% 2%  2%  2% 
 Levels: 2% 2-4% 4-6% 6-8% 8-10% 10%Thanks,
 Tianchan

It would really help if you looked at the intermediary steps of your
calculations to see what went wrong.

The problem is here:

 as.factor(as.numeric(cut(r,c(0,2,4,6,8,10,100
[1] 1 1 5 1 1 1
Levels: 1 5

There are 2 levels in the data passed to as.factor, 1 and 5.
levels(...)[1] is 1, and levels(...)[2] is 5. You then assign the values
2% 2-4% to these two levels. Hence the result

One option is to use factor and specify the levels as 1:6:

 factor(as.numeric(cut(r,c(0,2,4,6,8,10,100))), levels = 1:6)
[1] 1 1 5 1 1 1
Levels: 1 2 3 4 5 6

Using this we have:

 col_no - factor(as.numeric(cut(r,c(0,2,4,6,8,10,100))), levels = 1:6)
 levels(col_no) - c(2%,2-4%,4-6%,6-8%,8-10%,10%)
 col_no
[1] 2%   2%   8-10% 2%   2%   2%  
Levels: 2% 2-4% 4-6% 6-8% 8-10% 10%

I'm sure there are other, possibly better, ways of doing this, but that
is one.

HTH

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

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


Re: [R] writing sample values in to a file

2010-12-14 Thread Dennis Murphy
Hi:

On Mon, Dec 13, 2010 at 4:28 PM, chandu chandrasekhar.kar...@gmail.comwrote:


 Dear all,

  I am relatively new to R. I would like to know how can we write the
 realizations (for example generated through rnorm or runif) in to a data
 file. It would be very inefficient to first generate values and then write
 them in to file using write function. Instead, is there a way to generate
 1 value at a time and append them in to the file.


On the contrary, it is very inefficient in R to generate one value at a time
and then append it to a file. R can do vectorized calculations, so for
generating random data, it takes one line of code; e.g.,

rnorm(100, 0, 5)

generates a vector of 100 random numbers from a normal distribution with
mean 0 and standard deviation 5. To generate the code and write it to a file
can also take one line:

write.csv(rnorm(100, 0, 5), file = 'myRandomNumbers.csv'), row.names =
FALSE, quote = FALSE)

 On my system, it took 4.24 seconds to write 100 random numbers to a
file (its size is 18.6 Mb).

Now, let's try your for loop approach, without writing to a file:

# Pre-allocate space for the vector:
u - vector('numeric', 100)
system.time(for(i in seq_along(u)) u[i] - rnorm(1, 0, 5))
   user  system elapsed
   6.860.006.88

# Initialize an empty object and populate it one element at a time:
u - NULL
 system.time(for(i in 1:100) u - c(u, rnorm(1, 0, 5)))

The reason the second one is so inefficient is because of two important
features in R that generally don't arise in most programming languages:
fixed memory for workspaces and lazy evaluation. Because you are repeatedly
appending to a object that grows and grows (this is where the lazy
evaluation come into play), R has to work harder to find new memory after a
while and so it slows down precipitously as it expends more and more effort
finding memory. I got impatient with waiting, so

Timing stopped at: 571.83 9.08 585.53

 system.time(for(i in 1:1000) u - c(u, rnorm(1, 0, 5)))
   user  system elapsed
   2.640.082.74
 system.time(for(i in 1:1) u - c(u, rnorm(1, 0, 5)))
   user  system elapsed
  27.470.50   28.08

Multiply the last one (total time is on the far right) by 100 to get a
probable lower bound for how long this takes. There are more efficient ways
to do this (use of the function force(), for example), but the point is that
one thing you definitely do NOT want to do in R is to append to an object
one value at a time. It wouldn't be much different if you were writing to an
external file.

The question might be trivial to many experts. I appreciate your help.


The question is far from trivial, and many people have put in great amounts
of effort to make R efficient.  If possible, vectorized operations are a
good way to go because they are generally fast. Having said that, there are
occasions where it is more efficient to perform loops, but for novices who
are used to Fortran/C/Java looping constructs, it is usually the case that
there are very fast ways to do the same thing in R without a loop using
vectorized operations.


HTH,
Dennis


 Thank you
 --
 View this message in context:
 http://r.789695.n4.nabble.com/writing-sample-values-in-to-a-file-tp3086286p3086286.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.


Re: [R] Question about cut()

2010-12-14 Thread Ben Bolker
Tianchan Niu niu at isis.georgetown.edu writes:

 
 Dear all,
 I would like to use cut() to make numerics to factors, the sample codes are as
follows. However, the result is
 not what I want, since r[3] = 9 should be in the interval of 8-10% rather
than 2-4%. Maybe cut() is not
 the right function to use for my situation. Please help.  r - c(1,1,9,1,1,1)
  col_no - as.factor(as.numeric(cut(r,c(0,2,4,6,8,10,100
  levels(col_no) - c(2%,2-4%,4-6%,6-8%,8-10%,10%)
  col_no
 [1] 2%  2%  2-4% 2%  2%  2% 
 Levels: 2% 2-4% 4-6% 6-8% 8-10% 10%Thanks,
 Tianchan

  I think you're making the problem a little harder than it needs to be ...

r - c(1,1,9,1,1,1)
col_no - cut(r,c(0,2,4,6,8,10,100),
  labels = c(2%,2-4%,4-6%,6-8%,8-10%,10%))


[1] 2%   2%   8-10% 2%   2%   2%  
Levels: 2% 2-4% 4-6% 6-8% 8-10% 10%

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


Re: [R] Selecting non-empty elements after strsplit of string

2010-12-14 Thread Ivan Calandra

Hi,

I have just recently started to use regular expression, so I'm not sure 
that my solution would be valid in every case. But it works in yours:

 unlist(strsplit(output, split= +))
[1] ab 6

It would split them whatever the number of spaces between them is 
(because of the + in the pattern of splitting).


HTH,
Ivan

Le 12/14/2010 14:32, Scott Chamberlain a écrit :

Hello,

I am attempting to manipulate strings in which there are differing amounts
of whitespace before and after each element taht I want to keep (any word,
letter, or number). However, after strsplit and unlist, I know how to select
specific elements with [ ], but I want to select instead all elements that
are not missing. That is, do not select any elements that are simply .

output- c(a b     6)

gsub( ,,unlist(strsplit(output,  ,fixed=TRUE)))
[1] a b   6

Thanks! Scott Chamberlain

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



--
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Museum
Abt. Säugetiere
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231
ivan.calan...@uni-hamburg.de

**
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/1525_8_1.php

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


Re: [R] Selecting non-empty elements after strsplit of string

2010-12-14 Thread Jinyan Huang
unlist(strsplit(output, +))


On Tue, Dec 14, 2010 at 2:09 PM, Scott Chamberlain
myrmecocys...@gmail.com wrote:
 Hello,

 I am attempting to manipulate strings in which there are differing amounts of 
 whitespace before and after each element taht I want to keep (any word, 
 letter, or number). However, after strsplit and unlist, I know how to select 
 specific elements with [ ], but I want to select instead all elements that 
 are not missing. That is, do not select any elements that are simply .

 output - c(a     b         6)

 gsub( ,,unlist(strsplit(output,  ,fixed=TRUE)))
 [1] a         b               6

 Thanks! Scott Chamberlain
        [[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] Question about cut()

2010-12-14 Thread Gerrit Eichner

Tianchan, why aren't you just using


col_no - cut(r,c(0,2,4,6,8,10,100))
levels(col_no) - c(2%,2-4%,4-6%,6-8%,8-10%,10%)


?

Your use of as.numeric() is nonsensical; check step by step what is
happening with that.

Hth,

Gerrit

On Tue, 14 Dec 2010, Tianchan Niu wrote:


Dear all,
I would like to use cut() to make numerics to factors, the sample codes are as follows. However, the 
result is not what I want, since r[3] = 9 should be in the interval of 8-10% rather than 
2-4%. Maybe cut() is not the right function to use for my situation. Please help.  r 
- c(1,1,9,1,1,1)

col_no - as.factor(as.numeric(cut(r,c(0,2,4,6,8,10,100
levels(col_no) - c(2%,2-4%,4-6%,6-8%,8-10%,10%)
col_no

[1] 2%  2%  2-4% 2%  2%  2%
Levels: 2% 2-4% 4-6% 6-8% 8-10% 10%Thanks,
Tianchan


 Best regards  --  Gerrit
 Best regards  --  Gerrit Eichner
 Viele Grüße  --  Gerrit
 Viele Grüße  --  Gerrit Eichner
 Viele Grüße  --  GE
 Freundliche Grüße  --  Gerrit Eichner
 Freundliche Grüße  --  GE
 Grüße  --  Gerrit
 Grüße  --  Gerrit Eichner
 Grüße  --  GE
 Gruß  --  G

-
AOR Dr. Gerrit Eichner   Mathematical Institute, Room 212
gerrit.eich...@math.uni-giessen.de   Justus-Liebig-University Giessen
Tel: +49-(0)641-99-32104  Arndtstr. 2, 35392 Giessen, Germany
Fax: +49-(0)641-99-32109http://www.uni-giessen.de/cms/eichner
-__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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

2010-12-14 Thread Gerrit Eichner

On Tue, 14 Dec 2010, Matthew Rosett wrote:


How do I determine if my data deviate from the normal distribution?
The sample size is 1000 (weights of people).


See

?qqnorm

and/or

?shapiro.test

and/or

a text book on applied statistics

and/or

google for testing normality.


Hth,

Gerrit

PS: With n = 1000 your data will almost inevitably deviate from the normal 
distribution.


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

2010-12-14 Thread Jing Shi
Hello everyone,

I have been doing a binary classification using random forest from the
library randomForest. One of the predictors is a factor variable, which is
known to be highly related to the binary response I am trying to predict.
Other 80 predictors are numeric. Totally I have 44 subjects. However, the
random forest returns the factor variable as the least important one based
on the decreased accuracy measurement.  I specified the classification in
the way below:

myrf - randomForest (disease ~ ., data = mydata, ntree = 500,  importance =
T, do.trace = F, keep.forest = T)

disease is factor of cases and controls. Are there any specific things I
need to do differently when a factor predictor is included?

Thank you very much,

Jing

[[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] Date variable error

2010-12-14 Thread Ben Bolker
 Kurt_Helf at nps.gov writes:

 
 Greetings
  In attempting to create a date variable based on month (e.g.,
 February, April, etc.) and year (e.g., 2006) data, wherein I converted
 Month to a factor with Jan=1...Dec=12, I used the following command:
 
 data$Date-mdy.date(month=data$Month,day=15,year=data$Year)
 
 however, I get a message Error: trunc not meaningful for factors

  Have you tried

data$Date-mdy.date(month=as.numeric(data$Month),day=15,year=data$Year)

 (I like with() or transform() for making these cleaner:

data - transform(data,Date=mdy.date(month=as.numeric(Month),day=15,year=Year))

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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-12-14 Thread Sarah Goslee
You are most likely to get reasonable help if you provide at a minimum
your OS, the version of R you're using, and the error message you get.

And also if you send your replies to the R-help list, not just me.

Sarah

On Tue, Dec 14, 2010 at 10:58 AM, Val valkr...@gmail.com wrote:
 Thank you Sarah,


 It worked in my Linux machine as well  but not in Windows.





 On Tue, Dec 14, 2010 at 9:37 AM, Sarah Goslee sarah.gos...@gmail.com
 wrote:

 Val,

 Here's the complete console output. The graph produced is at:
 http://www.functionaldiversity.org/temp/curve.png

 R version 2.12.0 (2010-10-15)
 Copyright (C) 2010 The R Foundation for Statistical Computing
 ISBN 3-900051-07-0
 Platform: x86_64-redhat-linux-gnu (64-bit)

 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.

  ls()
 character(0)
 
  test- rnorm(5000,1000,100)
  test1 - subset(test, subset=(test  1100))
  d - density(test)
 
  png(curve.png)
  plot(d, main=Density of production, xlab=)
 
  xarea - c(1100, d$x[d$x  1100], c(max(test)))
  yarea - c(0, d$y[d$x  1100], 0)
 
 
  polygon(xarea, yarea, col=blue)
 
  curveheight - d$y[abs((d$x - mean(test1))) == min(abs((d$x -
  mean(test1]
  segments(x0=mean(test1), y0=0, x1=mean(test1), y1=curveheight,
  col=red, lwd=2)
  dev.off()
 null device
          1
 

 Sarah


 On Tue, Dec 14, 2010 at 8:59 AM, Val valkr...@gmail.com wrote:
  Hi Sara,
 
  Could you please send me your output as an attached file if it is
  possible?
 
  Thanks
 
 
   1. to shade or color (blue) the curve using the criterion that any
   values
   greater than 11,000
  
   I think I was not clear in the above point. I want shade not the line
   but
   the area under the curve,
 
  Here's an example of how to do that using polygon:
  http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=7
 
   and
   Your last line of code,
   segments(x0=mean(test1), y0=0, y1=curveheight)
  
   gave me the  following error message
  
   Error in segments(x0 = mean(test1), y0 = 0, y1 = curveheight) :
    element 3 is empty;
     the part of the args list of '.Internal' being evaluated was:
     (x0, y0, x1, y1, col = col, lty = lty, lwd = lwd, ...)
  
   could you check it please
 
  I checked it before I sent it to you. The code I provided works
  correctly
  on my computer.  (R 2.12.0, Linux).
 
  You could try this statement instead:
  segments(x0 = mean(test1), y0 = 0, x1=mean(test1), y1 = curveheight)
 
  Sarah
 
  --



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





-- 
Sarah Goslee
http://www.stringpage.com
http://www.astronomicum.com
http://www.functionaldiversity.org

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


Re: [R] stepAIC: plot predicted versus observed

2010-12-14 Thread sergeetienneparent

I figured out how to call coefficients and R² from the summary.

-
fit-lm(...) #multiple regression function
stepComp - stepAIC(fit, direction=both)
summary(stepComp)$coef[1,1] #call first coefficient
summary(stepComp)$coef[1,2] #call Std. Error of first coefficient
summary(stepComp)$coef[2,1] #call second coefficient
#... so on...
#And the R² can be called by
summary(stepComp)$adj.r.squared #call adjusted R²
summary(stepComp)$r.squared #call multiple R²
-- 
View this message in context: 
http://r.789695.n4.nabble.com/stepAIC-plot-predicted-versus-observed-tp3085991p3087345.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] Installing R-packages in Windows

2010-12-14 Thread Erik Lukac

Hi there,
I have the following problem and I hope somebody might help me.

First of all: I am using WinXP SP3 (english and/or german) with R in 
Version 2.10.0.


Now I am trying to install some packages but unfortunately I am getting 
a weird error. No matter which package I am trying to install - I nearly 
get the same error.


It looks like this:
-
C:\Program Files\R\R-2.10.0\binR CMD INSTALL 
%SystemDrive%\rPAcsTemp\car_2.0-2.

zip
Warning in rawToChar(block[seq_len(ns)]) :
  truncating string with embedded nul: 
'PK\003\004\n\0\0\0\0\01áG=\0\0\0\0\0\0\0

\0\0\0\0\0\004\0\0\0car/PK\003\004\n\0\0\0\0\0-áG=\0\0\0\0\0\0\0\0\0\0\0\0\t\0\0
\0car/data/PK\003\004\024\0\002\0\b\0-áG=+2ô[\t\003\0¥-\003\0\022'
Warning in rawToChar(block[101:107]) :
  truncating string with embedded nul: '\0\0\0car/'
Error in switch(rawToChar(z), ` ` = { : invalid octal digit
-


I am trying to install with a batch-script that looks like this:
-
SET rVersion=2.10.0
SET RPfad=%ProgramFiles%\R\R-%rVersion%\bin\
set RPacPfad=software\R_packages
REM #
REM  copyying to a folder without spaces
REM #
cd %windir%
cd ..
mkdir rPAcsTemp
cd %OrdnerDIR%\%RPACPFAD%
copy *.zip %SystemDrive%\rPAcsTemp


cd %RPFAD%
R CMD INSTALL %SystemDrive%\rPAcsTemp\car*.zip
R CMD INSTALL %SystemDrive%\rPAcsTemp\dbi*.zip
R CMD INSTALL %SystemDrive%\rPAcsTemp\zipfR*.zip
R CMD INSTALL %SystemDrive%\rPAcsTemp\lme4*.zip
R CMD INSTALL %SystemDrive%\rPAcsTemp\coda*.zip
R CMD INSTALL %SystemDrive%\rPAcsTemp\languageR*.zip
R CMD INSTALL %SystemDrive%\rPAcsTemp\lattice_*.zip
R CMD INSTALL %SystemDrive%\rPAcsTemp\mvtnorm_*.zip
R CMD INSTALL %SystemDrive%\rPAcsTemp\multcomp_*.zip
R CMD INSTALL %SystemDrive%\rPAcsTemp\R.oo_*.zip
R CMD INSTALL %SystemDrive%\rPAcsTemp\R.methodsS3_*.zip
R CMD INSTALL %SystemDrive%\rPAcsTemp\R.matlab_*.zip
R CMD INSTALL %SystemDrive%\rPAcsTemp\RPostgreSQL_*.zip
R CMD INSTALL %SystemDrive%\rPAcsTemp\tree_*.zip
R CMD INSTALL %SystemDrive%\rPAcsTemp\xtable_*.zip
R CMD INSTALL %SystemDrive%\rPAcsTemp\emu*.tar.gz
cd %Back-to-Normal%
-


Does anybody have an idea why I am recieving these error-messages? I 
thought about buggy files but after downloading the files (from 
http://cran.r-project.org/bin/windows/contrib/2.10/ ) again I could 
reproduce the messages.


By the way: Is there a better method installing packages? I tried within R 
install.packages from online and local repository but that only works 
for the user I am installing with.


Thanks in advance for the replies

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


Re: [R] peak detection

2010-12-14 Thread Joe Stuart
Thank you. I will look at that also.

On Mon, Dec 13, 2010 at 9:49 PM, Michael Bedward
michael.bedw...@gmail.com wrote:
 Hi Joe,

 Just for info, I've done this in the past by applying lowess followed
 by diff to a vector, then identifying points with change of sign in
 the diffs.

 Michael

 On 14 December 2010 14:22, Joe Stuart joe.stu...@gmail.com wrote:
 Never mind. I did find this package, which seems to do the trick. Thanks

 http://rgm2.lab.nig.ac.jp/RGM2/R_man-2.9.0/library/msProcess/man/msExtrema.html

 On Mon, Dec 13, 2010 at 9:05 PM, Joe Stuart joe.stu...@gmail.com wrote:
 Hi,
 I was wondering if anyone knows of a package that contains the ability
 for peak/valley detection. Here is an example of what I'm looking for,
 only problem is that it's written in Matlab.

 http://www.billauer.co.il/peakdet.html

 Thanks for any help in advance.

 -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] survreg vs. aftreg (eha) - the relationship between fitted coefficients?

2010-12-14 Thread Göran Broström
On Fri, Dec 10, 2010 at 5:21 PM, Eleni Rapsomaniki
er...@medschl.cam.ac.uk wrote:
 Dear R-users,

 I need to use the aftreg function in package 'eha' to estimate failure times 
 for left truncated survival data.

Be careful! This is only possible under strong assumptions about the
(unobserved) covariate vector. This is not (yet) reflected on the help
page for aftreg, but has been discussed here earlier.

 Apparently, survreg still cannot fit such models. Both functions
should be fitting the accelerated failure time (Weibull) model.
However, as Göran Broström points out in the help file for aftreg, the
parameterisation is different giving rise to different coefficients.
The betas for adjusted covariates are opposite in sign but otherwise
identical, whereas the intercept is quite different in a non-obvious
way. The log-likelihoods are similar also, but not identical. I would
like to find out how I can convert one set of coefficients to the
other so as to obtain the same linear predictors using either model.
Any ideas???

Yes. Since you work with Weibull data, try 'phreg' instead. You will
have to change sign of estimated coefficients, and divide them by
estimated shape, see the help page for 'weibreg', to compare to
parameters from survreg, but they are directly comparable with those
from coxph and coxreg.

Göran



 #the example below uses right-censored data for simplicity (the principle 
 should be the same with left truncation I hope)
 library(survival)
 library(eha)

 #  COMPARE coefs between survreg ('survival' pkg) and aftreg ('eha' pkg)
 #Fitting NULL models (no covariates) results in (approximately) the same 
 coefs (which is good!)

 m1_NULL=survreg(Surv(futime/365, status==1) ~ 1, data=pbcseq)
 m2_NULL=aftreg(Surv(futime/365, status==1) ~ 1, data=pbcseq)

 c(m1_NULL$coef, 1/m1_NULL$scale) #-- intercept= 3.878656  ,  shape = 1.478177
 c(m2_NULL$coef[1], exp(m2_NULL$coef[2])) #-- intercept= 3.878859 ,  
 shape=1.478150


 # NOW I adjust for covariates

 m1=survreg(Surv(futime/365, status==1) ~ chol+stage, data=pbcseq)
 m2= aftreg(Surv(futime/365, status==1) ~ chol+stage, data=pbcseq)

 ###      m2  ###
 #Coefficients:
 # (Intercept)         chol        stage
 # 5.944641913 -0.001692574 -0.470861324

 #Scale= 0.6416744

 #Loglik(model)= -483.9   Loglik(intercept only)= -506.8
 #        Chisq= 45.91 on 2 degrees of freedom, p= 1.1e-10
 #n=1124 (821 observations deleted due to missingness)

 ###      m2  ###

 #Covariate          W.mean      Coef Exp(Coef)  se(Coef)    Wald p
 #chol              303.777     0.002     1.002     0.000     0.000
 #stage               3.298     0.460     1.584     0.119     0.000
 #
 #log(scale)                    5.029   152.807     0.477     0.000
 #log(shape)                    0.467     1.595     0.095     0.000
 #
 #Events                    92
 #Total time at risk          9017
 #Max. log. likelihood      -484.31
 #LR test statistic         45.0
 #Degrees of freedom        2
 #Overall p-value           1.64669e-10

 Many thanks for any help you may be able to provide.

 Eleni Rapsomaniki
 Research Associate
 University of Cambridge
 Institute of Primary and Public Health

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




-- 
Göran Broström

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

2010-12-14 Thread Bert Gunter
... (in addition to the very useful suggestion to plot your data):

(Sounds like a homework question... ?).

Sigh. [mount soapbox]

1. Data never deviate from normality. They only provide provide
evidence to challenge (test is the formal term) the assumption that
the population from which the data were sampled (how? -- see below)
can be modeled as normal (e.g. whether the data provide strong
evidence against this assumption). This is a philosophical brain
twister, I know; but understanding what it means is actually very
important for how one uses evidence (data) to inform science. It took
me about 20 years after grad school to (partially, anyway) figure it
out. Bear of little brain and all that..

2. Define: Deviate from normality. With a sample of 1000, normality
tests at conventional significance levels will typically come out
statistically significant/contradict normality (which is why a whole
school of statistics, the gang of Bayesians, do not think that
statistical significance and evidence in the data have much to do
with one another). But that's not the real question, is it?

3. The real question is: Does whatever I do to analyze the data and
draw scientific conclusions depend crucially on the assumption of
normality of the underlying population from which the data are
sampled? Of course, it depends on exactly what you do, but, by and
large,  basic statistical texts continue to teach that the answer is
yes. Unfortunately, that is mostly (not always -- and it depends on
what's at issue) a lie, as we have known for about 50 years. The
crucial matter in practice is not normality but how the sampled data
were obtained: the study design and, especially, the issue of
independence. Unfortunately, that is rather complicated to deal
with, so the Intro Stats texts prefer to ignore it and teach hogwash.

[dismount soapbox]

Thoughtful nasty rejoinders welcome. Please send your thought-less
nasty ones to me privately to spare our colleagues.

Cheers,
Bert


Bert Gunter
Genentech Nonclinical Biostatistics

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


Re: [R] Installing R-packages in Windows

2010-12-14 Thread Mike Marchywka










( hotmail just randomly decides not to prefix original text, my comments below) 



Date: Tue, 14 Dec 2010 17:36:11 +0100
From: er...@phonetik.uni-muenchen.de
To: r-help@r-project.org



Hi there,
I have the following problem and I hope somebody might help me.

First of all: I am using WinXP SP3 (english and/or german) with R in
Version 2.10.0.

Now I am trying to install some packages but unfortunately I am getting
a weird error. No matter which package I am trying to install - I nearly
get the same error.

It looks like this:
-
C:\Program Files\R\R-2.10.0\binR CMD INSTALL
%SystemDrive%\rPAcsTemp\car_2.0-2.
zip
Warning in rawToChar(block[seq_len(ns)]) :
   truncating string with embedded nul:

M::


I used to build all from source then that stopped working and I have
seen others here complain about installation failures. I have had  good
luck with what others have suggested, and use install.packages()

It goes into a script ok, for example, ( note that myR is my 
script that invokes R but you can change etc). This points to ucla
mirror, writes a script into $tf to install $pkf,  installs $pkf by
running the gerated script, and then shows you the results and deletes junk
( normally you want to check error codes before deling junk however) 

tf=$$_temp
cat -  DUMMTY   $tf
options(repos=c(http://cran.stat.ucla.edu;))
install.packages(c($pkf),dep=TRUE)
DUMMTY
echo executing
cat $tf
myR -run $tf

echo removing $tf
rm $tf
echo removing R output
cat $tf.Rout
rm $tf.Rout









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


Re: [R] Installing R-packages in Windows

2010-12-14 Thread Uwe Ligges

Or in short, type

 install.packages(car)

within R.

Note that you won't get new versions of car for the outdated version of 
R. Note also that your zip file might not fit to the R version you are 
using.


Hence recommendation is to upgrade to R-2.12.0 patched (or 2.12.1 which 
will be released this Thursday) and run install.packages() after the 
upgrade.


Uwe Ligges



On 14.12.2010 18:17, Mike Marchywka wrote:











( hotmail just randomly decides not to prefix original text, my comments below)



Date: Tue, 14 Dec 2010 17:36:11 +0100
From: er...@phonetik.uni-muenchen.de
To: r-help@r-project.org



Hi there,
I have the following problem and I hope somebody might help me.

First of all: I am using WinXP SP3 (english and/or german) with R in
Version 2.10.0.

Now I am trying to install some packages but unfortunately I am getting
a weird error. No matter which package I am trying to install - I nearly
get the same error.

It looks like this:
-
C:\Program Files\R\R-2.10.0\binR CMD INSTALL
%SystemDrive%\rPAcsTemp\car_2.0-2.
zip
Warning in rawToChar(block[seq_len(ns)]) :
truncating string with embedded nul:

M::


I used to build all from source then that stopped working and I have
seen others here complain about installation failures. I have had  good
luck with what others have suggested, and use install.packages()

It goes into a script ok, for example, ( note that myR is my
script that invokes R but you can change etc). This points to ucla
mirror, writes a script into $tf to install $pkf,  installs $pkf by
running the gerated script, and then shows you the results and deletes junk
( normally you want to check error codes before deling junk however)

tf=$$_temp
cat -  DUMMTY  $tf
options(repos=c(http://cran.stat.ucla.edu;))
install.packages(c($pkf),dep=TRUE)
DUMMTY
echo executing
cat $tf
myR -run $tf

echo removing $tf
rm $tf
echo removing R output
cat $tf.Rout
rm $tf.Rout










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

2010-12-14 Thread Greg Snow
What about thoughtless un-nasty comments?

I would suggest the original poster (and others thinking that they want to do 
normality testing) read the help page for SnowsPenultimateNormalityTest in the 
TeachingDemos package, which I think agrees mostly with what Bert wrote below 
(though it goes more with the idea that data always deviates from normality, 
but that may be differences in interpreting the language rather than the 
theory).

-- 
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 Bert Gunter
 Sent: Tuesday, December 14, 2010 10:12 AM
 To: Gerrit Eichner
 Cc: r-help@r-project.org; Matthew Rosett
 Subject: Re: [R] Question
 
 ... (in addition to the very useful suggestion to plot your data):
 
 (Sounds like a homework question... ?).
 
 Sigh. [mount soapbox]
 
 1. Data never deviate from normality. They only provide provide
 evidence to challenge (test is the formal term) the assumption that
 the population from which the data were sampled (how? -- see below)
 can be modeled as normal (e.g. whether the data provide strong
 evidence against this assumption). This is a philosophical brain
 twister, I know; but understanding what it means is actually very
 important for how one uses evidence (data) to inform science. It took
 me about 20 years after grad school to (partially, anyway) figure it
 out. Bear of little brain and all that..
 
 2. Define: Deviate from normality. With a sample of 1000, normality
 tests at conventional significance levels will typically come out
 statistically significant/contradict normality (which is why a whole
 school of statistics, the gang of Bayesians, do not think that
 statistical significance and evidence in the data have much to do
 with one another). But that's not the real question, is it?
 
 3. The real question is: Does whatever I do to analyze the data and
 draw scientific conclusions depend crucially on the assumption of
 normality of the underlying population from which the data are
 sampled? Of course, it depends on exactly what you do, but, by and
 large,  basic statistical texts continue to teach that the answer is
 yes. Unfortunately, that is mostly (not always -- and it depends on
 what's at issue) a lie, as we have known for about 50 years. The
 crucial matter in practice is not normality but how the sampled data
 were obtained: the study design and, especially, the issue of
 independence. Unfortunately, that is rather complicated to deal
 with, so the Intro Stats texts prefer to ignore it and teach hogwash.
 
 [dismount soapbox]
 
 Thoughtful nasty rejoinders welcome. Please send your thought-less
 nasty ones to me privately to spare our colleagues.
 
 Cheers,
 Bert
 
 
 Bert Gunter
 Genentech Nonclinical Biostatistics
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] colour-plot of point intensities?

2010-12-14 Thread Matthew Vernon
Hi,

I've spent a while scrabbling around at this problem, to no avail. I'm
sure there /should/ be a simple answer...

I have a large (14 million rows) data set, with two columns. Each row
contains the number of times an individual moved, and the distance
that individual moved in total. I would like a figure where the colour
indicates the density of points, rather like this one my colleague
produced in Matlab (with an older version of the data):

http://www.warwick.ac.uk/~lssgah/warwick1.pdf

Sadly, my colleague is away at the moment, so I can't find out what
they did in Matlab. How should I be approaching this problem?
[ideally, I'd like a colour-scale like that, too, but]

My current approach, based on a bit in the back of Crawley's R book,
was to create a new data file where I rounded distance off, and
counted the number of similar rows to give a third column (a count). I
then did:

library(akima)
obs - read.table(numvsdistscount.dat)
zz - with(obs,interp(V1,V2,V3))
filled.contour(zz,col=heat.colors(12))

But:
i) I think doing a rounding step to create the third column (separate
from the plot generation) is unwise
ii) This results in a shaded area less than the full area of the plot
iii) The colour comes out almost uniform

I'd be grateful for any pointers.

Thanks,

Matthew

-- 
Matthew Vernon, Research Fellow
Ecology and Epidemiology Group,
University of Warwick
http://blogs.warwick.ac.uk/mcvernon

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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-12-14 Thread Peter Ehlers

On 2010-12-14 08:43, Sarah Goslee wrote:

You are most likely to get reasonable help if you provide at a minimum
your OS, the version of R you're using, and the error message you get.

And also if you send your replies to the R-help list, not just me.

Sarah


Sarah's code works perfectly well on Windows Vista.
Is Val using Windows 95?

Peter Ehlers



On Tue, Dec 14, 2010 at 10:58 AM, Valvalkr...@gmail.com  wrote:

Thank you Sarah,


It worked in my Linux machine as well  but not in Windows.


[...snip...]

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


Re: [R] colour-plot of point intensities?

2010-12-14 Thread Greg Snow
Look at the hexbin package (bioconductor).

-- 
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 Matthew Vernon
 Sent: Tuesday, December 14, 2010 9:48 AM
 To: r-h...@stat.math.ethz.ch
 Subject: [R] colour-plot of point intensities?
 
 Hi,
 
 I've spent a while scrabbling around at this problem, to no avail. I'm
 sure there /should/ be a simple answer...
 
 I have a large (14 million rows) data set, with two columns. Each row
 contains the number of times an individual moved, and the distance
 that individual moved in total. I would like a figure where the colour
 indicates the density of points, rather like this one my colleague
 produced in Matlab (with an older version of the data):
 
 http://www.warwick.ac.uk/~lssgah/warwick1.pdf
 
 Sadly, my colleague is away at the moment, so I can't find out what
 they did in Matlab. How should I be approaching this problem?
 [ideally, I'd like a colour-scale like that, too, but]
 
 My current approach, based on a bit in the back of Crawley's R book,
 was to create a new data file where I rounded distance off, and
 counted the number of similar rows to give a third column (a count). I
 then did:
 
 library(akima)
 obs - read.table(numvsdistscount.dat)
 zz - with(obs,interp(V1,V2,V3))
 filled.contour(zz,col=heat.colors(12))
 
 But:
 i) I think doing a rounding step to create the third column (separate
 from the plot generation) is unwise
 ii) This results in a shaded area less than the full area of the plot
 iii) The colour comes out almost uniform
 
 I'd be grateful for any pointers.
 
 Thanks,
 
 Matthew
 
 --
 Matthew Vernon, Research Fellow
 Ecology and Epidemiology Group,
 University of Warwick
 http://blogs.warwick.ac.uk/mcvernon
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] 300 dpi and eps:

2010-12-14 Thread Aldi Kraja

Hi,

I have a run of 5 graphs that I want to place them under the same page.
Everything works fine to place them in a pdf file , or eps file, but 
when it comes to have a high quality of
300 dpi these graphs are not good. For example I open the eps file with 
Adobe Illustrator (AI) and it shows that it is a 72dpi graph. If I start 
with a 72dpi graph AI cannot improve this to 300 dpi. Q: HOW CAN A GRAPH 
IN R DIRECTLY SAVED AS 300dpi? What options do I need to add to the 
postscript function to have a 1 page graph that has these 5 plots and is 
a 300 dpi graph? Thank you in advance, Aldi


Here is what I am using right now:
 
postscript(file='./plotST.eps',paper='special',width=10,height=10,horizontal=FALSE)

 par(mfrow=c(5 ,1))
 plot(sortord , X1 , cex=0.5 ,pch=21 , ylim=c(1.02 , 8.08771 ), 
xlab='ST: 1-5 position (unit)',ylab='ylabel',font.lab = 1, cex.lab = 
1,cex.main=0.5 +0.4, col=chrom )

 text(midpointsbyc+minadj+5,0-5,chnum ,cex=0.5 +0.2 ,col=chnum+1 )
 abline(h = -1*log10(9.7e-08 ), lty = 2,col = 'gray' )
 # Draw the legend
 legend('topright',legend=c('X1'))
 plot(sortord , X2

 # Put a box around the plot
 box(lwd = 1)
 dev.off()

--

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 left or right truncate a character string?

2010-12-14 Thread Mark Na
Hi R-helpers,

I have a character string, for example:

lm(y ~ X2 + X3 + X4)

from which I would like to strip off the leading and trailing
quotation marks resulting in this:

lm(y ~ X2 + X3 + X4)


I have tried using gsub() but I can't figure out how to specify the
quotation mark using a regular expression.

Alternatively, I would like a function that lets me delete the leading
(or trailing) X characters, and in this case X=1 (but it could be used
more flexibly to delete several leading or trailing characters).

I would appreciate help with either of these potential solutions (gsub
and regex, or delete leading/trailing characters).

Many thanks!

Mark

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 left or right truncate a character string?

2010-12-14 Thread Henrique Dallazuanna
Try this:

noquote(lm(y ~ X2 + X3 + X4))

To remove X characters:

gsub(^.|.$, , lm(y ~ X2 + X3 + X4))


On Tue, Dec 14, 2010 at 6:27 PM, Mark Na mtb...@gmail.com wrote:

 Hi R-helpers,

 I have a character string, for example:

 lm(y ~ X2 + X3 + X4)

 from which I would like to strip off the leading and trailing
 quotation marks resulting in this:

 lm(y ~ X2 + X3 + X4)


 I have tried using gsub() but I can't figure out how to specify the
 quotation mark using a regular expression.

 Alternatively, I would like a function that lets me delete the leading
 (or trailing) X characters, and in this case X=1 (but it could be used
 more flexibly to delete several leading or trailing characters).

 I would appreciate help with either of these potential solutions (gsub
 and regex, or delete leading/trailing characters).

 Many thanks!

 Mark

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




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

[[alternative HTML version deleted]]

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


[R] Discriminant Correspondence Analysis

2010-12-14 Thread Wayne Sawtell
Hello everyone,

I am totally new to the R program. I have had a look at some pdf documents
that I downloaded and that explain how to do many things in R; however, I
still cannot figure out how to do what I want to do, which is to perform
Discriminant Correspondence Analysis on a rectangular matrix of data that I
have in an Excel file. I know R users frown upon Excel and recommend
converting Excel files to .csv format, which I have done, no problem. That
is not an issue.
There are several parts to my problem.
1) When I try the read.table command, even if I include the directory name
in the filename, R still cannot read the file, even if it is in .csv format
2) I was able to copy my file and then read the clipboard contents into R
but then I do not know to assign a name to the data frame in order to
conduct any operations on it
3) I need the ADE4 program in order to perform Discriminant Correspondence
Analysis, so I used the install.packages command to install it. It
installed no problem but I do not know how to access the ADE4 program in R.
I am unable to open it directly, either.
4) I thought that using the ADE4 GUI (called ade4TkGUI) would be easier
because I do not know many of the R commands; but, again, I downloaded it
but cannot open or access it.

The following is the suggested coding that I found through the R website,
but when I try to use this code, I don't know how to assign a name for the
df, or what to put for fac, and what is worse, I get an error message
saying that the program cannot find the discrimin.coa command.


Usage

discrimin.coa(df, fac, scannf = TRUE, nf = 2)

Arguments

df a data frame containing positive or null values

fac a factor defining the classes of discriminant analysis

scannf a logical value indicating whether the eigenvalues bar plot should be
displayed

nf if scannf FALSE, an integer indicating the number of kept axes

Examples

data(perthi02)

plot(discrimin.coa(perthi02$tab, perthi02$cla, scan = FALSE))
For clarification, my data consists of measurements of morphological
characters of an assemblage of biological specimens. I have already
performed Principal Co-ordinates Analysis, Principal Compionents Analysis
and Cluster Analysis in another program (PAST) in order to see if the data
fall into distinct groupings that might represent different morphological
species. I now want to test the groupings that I found on my test data set
using Discriminant Correspondence Analysis.There are both continuous and
categorical characters, which is the reason why I need to perform
Discriminant Correspondence Analysis, instead of Linear Discriminant
Analysis, which is only valid for continuous measurements. R seems to be the
only program in which I can perform Discriminant Correspondence Analysis.

Thanks for any help offered on any of these points.
Wayne

[[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] Discriminant Correspondence Analysis

2010-12-14 Thread Bastiaan Bergman
Read files, if you're on windows remember to include the path like this:
C:\\Documents and Settings\\USER\\My Documents\\MyFile.csv

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Wayne Sawtell
Sent: Tuesday, December 14, 2010 12:36 PM
To: r-help@r-project.org
Subject: [R] Discriminant Correspondence Analysis

Hello everyone,

I am totally new to the R program. I have had a look at some pdf documents
that I downloaded and that explain how to do many things in R; however, I
still cannot figure out how to do what I want to do, which is to perform
Discriminant Correspondence Analysis on a rectangular matrix of data that I
have in an Excel file. I know R users frown upon Excel and recommend
converting Excel files to .csv format, which I have done, no problem. That
is not an issue.
There are several parts to my problem.
1) When I try the read.table command, even if I include the directory name
in the filename, R still cannot read the file, even if it is in .csv format
2) I was able to copy my file and then read the clipboard contents into R
but then I do not know to assign a name to the data frame in order to
conduct any operations on it
3) I need the ADE4 program in order to perform Discriminant Correspondence
Analysis, so I used the install.packages command to install it. It
installed no problem but I do not know how to access the ADE4 program in R.
I am unable to open it directly, either.
4) I thought that using the ADE4 GUI (called ade4TkGUI) would be easier
because I do not know many of the R commands; but, again, I downloaded it
but cannot open or access it.

The following is the suggested coding that I found through the R website,
but when I try to use this code, I don't know how to assign a name for the
df, or what to put for fac, and what is worse, I get an error message
saying that the program cannot find the discrimin.coa command.


Usage

discrimin.coa(df, fac, scannf = TRUE, nf = 2)

Arguments

df a data frame containing positive or null values

fac a factor defining the classes of discriminant analysis

scannf a logical value indicating whether the eigenvalues bar plot should be
displayed

nf if scannf FALSE, an integer indicating the number of kept axes

Examples

data(perthi02)

plot(discrimin.coa(perthi02$tab, perthi02$cla, scan = FALSE))
For clarification, my data consists of measurements of morphological
characters of an assemblage of biological specimens. I have already
performed Principal Co-ordinates Analysis, Principal Compionents Analysis
and Cluster Analysis in another program (PAST) in order to see if the data
fall into distinct groupings that might represent different morphological
species. I now want to test the groupings that I found on my test data set
using Discriminant Correspondence Analysis.There are both continuous and
categorical characters, which is the reason why I need to perform
Discriminant Correspondence Analysis, instead of Linear Discriminant
Analysis, which is only valid for continuous measurements. R seems to be the
only program in which I can perform Discriminant Correspondence Analysis.

Thanks for any help offered on any of these points.
Wayne

[[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 to left or right truncate a character string?

2010-12-14 Thread Phil Spector

Mark -
   Since regular expressions in R are just character
strings, it's pretty easy to assemble a regular expression
to delete leading or trailing characters.  For example:


delchars = function(str,n,lead=TRUE){

+dots = paste(rep('.',n),collapse='')
+pat = if(lead)paste('^',dots,sep='') else paste(dots,'$',sep='')
+sub(pat,'',str)
+ }

str = this is a test
delchars(str,4)

[1]  is a test

delchars(str,4,lead=FALSE)

[1] this is a 


- Phil Spector
 Statistical Computing Facility
 Department of Statistics
 UC Berkeley
 spec...@stat.berkeley.edu



On Tue, 14 Dec 2010, Mark Na wrote:


Hi R-helpers,

I have a character string, for example:

lm(y ~ X2 + X3 + X4)

from which I would like to strip off the leading and trailing
quotation marks resulting in this:

lm(y ~ X2 + X3 + X4)


I have tried using gsub() but I can't figure out how to specify the
quotation mark using a regular expression.

Alternatively, I would like a function that lets me delete the leading
(or trailing) X characters, and in this case X=1 (but it could be used
more flexibly to delete several leading or trailing characters).

I would appreciate help with either of these potential solutions (gsub
and regex, or delete leading/trailing characters).

Many thanks!

Mark

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



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


[R] How to bind models into a list of models?

2010-12-14 Thread Mark Na
Hi R-helpers,

I have a character object called dd that has 32 elements each of which
is a model formula contained within quotation marks. Here's what it
looks like:

 dd
 [1] lm(y ~ 1,data=Cement) lm(y ~
X,data=Cement) lm(y ~ X1,data=Cement)
 [4] lm(y ~ X2,data=Cement)lm(y ~
X3,data=Cement)lm(y ~ X4,data=Cement)
 [7] lm(y ~ X + X1,data=Cement)lm(y ~ X +
X2,data=Cement)lm(y ~ X + X3,data=Cement)
[10] lm(y ~ X + X4,data=Cement)lm(y ~ X1 +
X2,data=Cement)   lm(y ~ X1 + X3,data=Cement)
[13] lm(y ~ X1 + X4,data=Cement)   lm(y ~ X2 +
X3,data=Cement)   lm(y ~ X2 + X4,data=Cement)
[16] lm(y ~ X3 + X4,data=Cement)   lm(y ~ X + X1 +
X2,data=Cement)   lm(y ~ X + X1 + X3,data=Cement)
[19] lm(y ~ X + X1 + X4,data=Cement)   lm(y ~ X + X2 +
X3,data=Cement)   lm(y ~ X + X2 + X4,data=Cement)
[22] lm(y ~ X + X3 + X4,data=Cement)   lm(y ~ X1 + X2 +
X3,data=Cement)  lm(y ~ X1 + X2 + X4,data=Cement)
[25] lm(y ~ X1 + X3 + X4,data=Cement)  lm(y ~ X2 + X3 +
X4,data=Cement)  lm(y ~ X + X1 + X2 + X3,data=Cement)
[28] lm(y ~ X + X1 + X2 + X4,data=Cement)  lm(y ~ X + X1 + X3 +
X4,data=Cement)  lm(y ~ X + X2 + X3 + X4,data=Cement)
[31] lm(y ~ X1 + X2 + X3 + X4,data=Cement) lm(y ~ X + X1 + X2 +
X3 + X4,data=Cement)

I would like to convert this object into a list called Cand.models
with 32 list elements each of which would contain one of the above
model formulae. When I print the list, the models should run, so the
first few elements of the list would look like this (see below output
from a list I created by hand).

Many thanks for any help you can provide!

Mark




Cand.models

[[1]]

Call:
lm(formula = y ~ 1, data = Cement)

Coefficients:
(Intercept)
  95.42


[[2]]

Call:
lm(formula = y ~ X, data = Cement)

Coefficients:
(Intercept)X
 82.3081.874


[[3]]

Call:
lm(formula = y ~ X1, data = Cement)

Coefficients:
(Intercept)   X1
 81.4791.869

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

2010-12-14 Thread Jinyan Huang
Try
step()
?

On Tue, Dec 14, 2010 at 10:05 PM, Mark Na mtb...@gmail.com wrote:
 Hi R-helpers,

 I have a character object called dd that has 32 elements each of which
 is a model formula contained within quotation marks. Here's what it
 looks like:

 dd
  [1] lm(y ~ 1,data=Cement)                     lm(y ~
 X,data=Cement)                     lm(y ~ X1,data=Cement)
  [4] lm(y ~ X2,data=Cement)                    lm(y ~
 X3,data=Cement)                    lm(y ~ X4,data=Cement)
  [7] lm(y ~ X + X1,data=Cement)                lm(y ~ X +
 X2,data=Cement)                lm(y ~ X + X3,data=Cement)
 [10] lm(y ~ X + X4,data=Cement)                lm(y ~ X1 +
 X2,data=Cement)               lm(y ~ X1 + X3,data=Cement)
 [13] lm(y ~ X1 + X4,data=Cement)               lm(y ~ X2 +
 X3,data=Cement)               lm(y ~ X2 + X4,data=Cement)
 [16] lm(y ~ X3 + X4,data=Cement)               lm(y ~ X + X1 +
 X2,data=Cement)           lm(y ~ X + X1 + X3,data=Cement)
 [19] lm(y ~ X + X1 + X4,data=Cement)           lm(y ~ X + X2 +
 X3,data=Cement)           lm(y ~ X + X2 + X4,data=Cement)
 [22] lm(y ~ X + X3 + X4,data=Cement)           lm(y ~ X1 + X2 +
 X3,data=Cement)          lm(y ~ X1 + X2 + X4,data=Cement)
 [25] lm(y ~ X1 + X3 + X4,data=Cement)          lm(y ~ X2 + X3 +
 X4,data=Cement)          lm(y ~ X + X1 + X2 + X3,data=Cement)
 [28] lm(y ~ X + X1 + X2 + X4,data=Cement)      lm(y ~ X + X1 + X3 +
 X4,data=Cement)      lm(y ~ X + X2 + X3 + X4,data=Cement)
 [31] lm(y ~ X1 + X2 + X3 + X4,data=Cement)     lm(y ~ X + X1 + X2 +
 X3 + X4,data=Cement)

 I would like to convert this object into a list called Cand.models
 with 32 list elements each of which would contain one of the above
 model formulae. When I print the list, the models should run, so the
 first few elements of the list would look like this (see below output
 from a list I created by hand).

 Many thanks for any help you can provide!

 Mark




Cand.models

 [[1]]

 Call:
 lm(formula = y ~ 1, data = Cement)

 Coefficients:
 (Intercept)
      95.42


 [[2]]

 Call:
 lm(formula = y ~ X, data = Cement)

 Coefficients:
 (Intercept)            X
     82.308        1.874


 [[3]]

 Call:
 lm(formula = y ~ X1, data = Cement)

 Coefficients:
 (Intercept)           X1
     81.479        1.869

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

2010-12-14 Thread Aldi Kraja

Hi,

I have a run of 5 graphs that I want to place them under the same page.
Everything works fine to place them in a pdf file , or eps file, but 
when it comes to have a high quality of
300 dpi these graphs are not good. For example I open the eps file with 
Adobe Illustrator (AI) and it shows that it is a 72dpi graph. If I start 
with a 72dpi graph AI cannot improve this to 300 dpi. Q: HOW CAN A GRAPH 
IN R DIRECTLY SAVED AS 300dpi? What options do I need to add to the 
postscript function to have a 1 page graph that has these 5 plots and is 
a 300 dpi graph? Thank you in advance, Aldi


Here is what I am using right now:
 
postscript(file='./plotST.eps',paper='special',width=10,height=10,horizontal=FALSE)

 par(mfrow=c(5 ,1))
 plot(sortord , X1 , cex=0.5 ,pch=21 , ylim=c(1.02 , 8.08771 ), 
xlab='ST: 1-5 position (unit)',ylab='ylabel',font.lab = 1, cex.lab = 
1,cex.main=0.5 +0.4, col=chrom )

 text(midpointsbyc+minadj+5,0-5,chnum ,cex=0.5 +0.2 ,col=chnum+1 )
 abline(h = -1*log10(9.7e-08 ), lty = 2,col = 'gray' )
 # Draw the legend
 legend('topright',legend=c('X1'))
 plot(sortord , X2

 # Put a box around the plot
 box(lwd = 1)
 dev.off()

--

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

2010-12-14 Thread JESSICA

I have a table like this:

Date TIME  Q

A a1
A b2
A c3  
B a4
B b5
B c6
C a7
C b8
C c9

I want use R language to turn it to a matrix like :
a  b  c 
A  1  2  3
B  4  5  6
C  7  8  9


I am new to R , anyone can help? Thanks in advance! have a table like this:

Date TIME  Q

A a1
A b2
A c3  
B a4
B b5
B c6

-- 
View this message in context: 
http://r.789695.n4.nabble.com/from-table-to-matrix-tp3087972p3087972.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] How to bind models into a list of models?

2010-12-14 Thread Phil Spector

Mark -
   I believe

 lapply(dd,function(m)eval(parse(text=m)))

will do what you want.
- Phil Spector
 Statistical Computing Facility
 Department of Statistics
 UC Berkeley
 spec...@stat.berkeley.edu


On Tue, 14 Dec 2010, Mark Na wrote:


Hi R-helpers,

I have a character object called dd that has 32 elements each of which
is a model formula contained within quotation marks. Here's what it
looks like:


dd

[1] lm(y ~ 1,data=Cement) lm(y ~
X,data=Cement) lm(y ~ X1,data=Cement)
[4] lm(y ~ X2,data=Cement)lm(y ~
X3,data=Cement)lm(y ~ X4,data=Cement)
[7] lm(y ~ X + X1,data=Cement)lm(y ~ X +
X2,data=Cement)lm(y ~ X + X3,data=Cement)
[10] lm(y ~ X + X4,data=Cement)lm(y ~ X1 +
X2,data=Cement)   lm(y ~ X1 + X3,data=Cement)
[13] lm(y ~ X1 + X4,data=Cement)   lm(y ~ X2 +
X3,data=Cement)   lm(y ~ X2 + X4,data=Cement)
[16] lm(y ~ X3 + X4,data=Cement)   lm(y ~ X + X1 +
X2,data=Cement)   lm(y ~ X + X1 + X3,data=Cement)
[19] lm(y ~ X + X1 + X4,data=Cement)   lm(y ~ X + X2 +
X3,data=Cement)   lm(y ~ X + X2 + X4,data=Cement)
[22] lm(y ~ X + X3 + X4,data=Cement)   lm(y ~ X1 + X2 +
X3,data=Cement)  lm(y ~ X1 + X2 + X4,data=Cement)
[25] lm(y ~ X1 + X3 + X4,data=Cement)  lm(y ~ X2 + X3 +
X4,data=Cement)  lm(y ~ X + X1 + X2 + X3,data=Cement)
[28] lm(y ~ X + X1 + X2 + X4,data=Cement)  lm(y ~ X + X1 + X3 +
X4,data=Cement)  lm(y ~ X + X2 + X3 + X4,data=Cement)
[31] lm(y ~ X1 + X2 + X3 + X4,data=Cement) lm(y ~ X + X1 + X2 +
X3 + X4,data=Cement)

I would like to convert this object into a list called Cand.models
with 32 list elements each of which would contain one of the above
model formulae. When I print the list, the models should run, so the
first few elements of the list would look like this (see below output
from a list I created by hand).

Many thanks for any help you can provide!

Mark





Cand.models


[[1]]

Call:
lm(formula = y ~ 1, data = Cement)

Coefficients:
(Intercept)
 95.42


[[2]]

Call:
lm(formula = y ~ X, data = Cement)

Coefficients:
(Intercept)X
82.3081.874


[[3]]

Call:
lm(formula = y ~ X1, data = Cement)

Coefficients:
(Intercept)   X1
81.4791.869

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

2010-12-14 Thread Phil Spector

Here's one way:


df = data.frame(Date=rep(LETTERS[1:3],each=3),TIME=rep(letters[1:3],3),Q=1:9)
df

  Date TIME Q
1Aa 1
2Ab 2
3Ac 3
4Ba 4
5Bb 5
6Bc 6
7Ca 7
8Cb 8
9Cc 9

mat = matrix(0,3,3,dimnames=list(LETTERS[1:3],letters[1:3]))
mat[as.matrix(df[,1:2])] = df[,3]
mat

  a b c
A 1 2 3
B 4 5 6
C 7 8 9

- Phil Spector
 Statistical Computing Facility
 Department of Statistics
 UC Berkeley
 spec...@stat.berkeley.edu

On Tue, 14 Dec 2010, JESSICA [via R] wrote:



I have a table like this:

Date TIME  Q

A a1
A b2
A c3
B a4
B b5
B c6
C a7
C b8
C c9

I want use R language to turn it to a matrix like :
   a  b  c
A  1  2  3
B  4  5  6
C  7  8  9


I am new to R , anyone can help? Thanks in advance! have a table like this:

Date TIME  Q

A a1
A b2
A c3
B a4
B b5
B c6


__
This email was sent by JESSICA (via Nabble)
Your replies will appear at 
http://r.789695.n4.nabble.com/from-table-to-matrix-tp3087972p3087972.html
To receive all replies by email, subscribe to this discussion: 
http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=subscribe_by_codenode=3087972code=ci1oZWxwQHItcHJvamVjdC5vcmd8MzA4Nzk3MnwtNzg0MjM1NTA4

[[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 to bind models into a list of models?

2010-12-14 Thread Mark Na
Many thanks Phil. This is perfect. I usually forget about lapply and
try something more complicated. Your solution works really well.

Best, Mark


On Tue, Dec 14, 2010 at 3:45 PM, Phil Spector spec...@stat.berkeley.edu wrote:
 Mark -
   I believe

  lapply(dd,function(m)eval(parse(text=m)))

 will do what you want.
                                        - Phil Spector
                                         Statistical Computing Facility
                                         Department of Statistics
                                         UC Berkeley
                                         spec...@stat.berkeley.edu


 On Tue, 14 Dec 2010, Mark Na wrote:

 Hi R-helpers,

 I have a character object called dd that has 32 elements each of which
 is a model formula contained within quotation marks. Here's what it
 looks like:

 dd

 [1] lm(y ~ 1,data=Cement)                     lm(y ~
 X,data=Cement)                     lm(y ~ X1,data=Cement)
 [4] lm(y ~ X2,data=Cement)                    lm(y ~
 X3,data=Cement)                    lm(y ~ X4,data=Cement)
 [7] lm(y ~ X + X1,data=Cement)                lm(y ~ X +
 X2,data=Cement)                lm(y ~ X + X3,data=Cement)
 [10] lm(y ~ X + X4,data=Cement)                lm(y ~ X1 +
 X2,data=Cement)               lm(y ~ X1 + X3,data=Cement)
 [13] lm(y ~ X1 + X4,data=Cement)               lm(y ~ X2 +
 X3,data=Cement)               lm(y ~ X2 + X4,data=Cement)
 [16] lm(y ~ X3 + X4,data=Cement)               lm(y ~ X + X1 +
 X2,data=Cement)           lm(y ~ X + X1 + X3,data=Cement)
 [19] lm(y ~ X + X1 + X4,data=Cement)           lm(y ~ X + X2 +
 X3,data=Cement)           lm(y ~ X + X2 + X4,data=Cement)
 [22] lm(y ~ X + X3 + X4,data=Cement)           lm(y ~ X1 + X2 +
 X3,data=Cement)          lm(y ~ X1 + X2 + X4,data=Cement)
 [25] lm(y ~ X1 + X3 + X4,data=Cement)          lm(y ~ X2 + X3 +
 X4,data=Cement)          lm(y ~ X + X1 + X2 + X3,data=Cement)
 [28] lm(y ~ X + X1 + X2 + X4,data=Cement)      lm(y ~ X + X1 + X3 +
 X4,data=Cement)      lm(y ~ X + X2 + X3 + X4,data=Cement)
 [31] lm(y ~ X1 + X2 + X3 + X4,data=Cement)     lm(y ~ X + X1 + X2 +
 X3 + X4,data=Cement)

 I would like to convert this object into a list called Cand.models
 with 32 list elements each of which would contain one of the above
 model formulae. When I print the list, the models should run, so the
 first few elements of the list would look like this (see below output
 from a list I created by hand).

 Many thanks for any help you can provide!

 Mark




 Cand.models

 [[1]]

 Call:
 lm(formula = y ~ 1, data = Cement)

 Coefficients:
 (Intercept)
     95.42


 [[2]]

 Call:
 lm(formula = y ~ X, data = Cement)

 Coefficients:
 (Intercept)            X
    82.308        1.874


 [[3]]

 Call:
 lm(formula = y ~ X1, data = Cement)

 Coefficients:
 (Intercept)           X1
    81.479        1.869

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] defining contrasts in lm() - is there a simpler way?

2010-12-14 Thread Mark Heckmann
Dear R users,

I am looking for a simple way to define a contrast in a linear model. 
I have a data frame with two factors (f1, f2) and a dependent y.

x - data.frame(y =rnorm(30), f1=gl(2, 15), f2=gl(3, 5, 30))

Now I want to specify the following contrast:   f1= 1 or 2 and f2=1 vs. f1= 
1 or 2 and f2=3 
The best I can come up with is the following:

x$new[x$f1==1  x$f2==1] - 1
x$new[x$f1==1  x$f2==2] - 2
x$new[x$f1==1  x$f2==3] - 3
x$new[x$f1==2  x$f2==1] - 4
x$new[x$f1==2  x$f2==2] - 5
x$new[x$f1==2  x$f2==3] - 6
x$new - as.factor(x$new)
contrasts(x$new) - cbind( my constrast = c( .5, -.5,  0, .5, 0, -.5))
summary(lm(y ~ new, x))

I have two questions concerning this: 

1) if I take a look at the constrast matrix derived from the one
contrast I specified, I assume that R automatically adds the missing constrasts 
so they are orthogonal.

   round(cor(attributes(x$new)$contrast), 1)

Is that always the case?

2) Can I get this in a simpler way? I find it a bit tedious to define the 
constrast like above. 
Is there something simpler, like:

   lm(y ~ f1:f2, + user defined contrast definition inside lm that is 
equivalent to the above)

Thanks in advance,
Mark
–––
Mark Heckmann
Blog: www.markheckmann.de
R-Blog: http://ryouready.wordpress.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] Discriminant Correspondence Analysis

2010-12-14 Thread Mark Difford

Wayne,

 I don't know how to assign a name for the df, or what to put for fac,
 and what is worse, 
 I get an error message saying that the program cannot find the
 discrimin.coa command.

Before you can use a package you have downloaded you need to activate it.
There are different ways of doing this. Simplest is to type library(ade4).

##
library(ade4)
?discrimin.coa

Follow Bastiaan and read in your file as follows (single forward slashes
also work):

## See ?read.csv as you may need to change some switches
MyFile - read.csv(C:\\Documents and Settings\\USER\\My
Documents\\MyFile.csv)
str(MyFile)

Without data it is difficult to help you further, but your general call to
discrimin.coa is

## This may or may not work; depends what's in MyFile
T.discrimin - discrimin.coa(MyFile, fac = someFacInMyFile, scann=F, nf=4)
T.discrimin
plot(T.discrimin)

Regards, Mark.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Discriminant-Correspondence-Analysis-tp3087929p3088091.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] from table to matrix

2010-12-14 Thread jonathan

That's so weird, I just signed up on here to ask exactly the same question!

However, I think my issue is like Jessica's who says that her data is like
that, not actually that...

So the issue is not in generating that data on-the-fly but in transforming
it from a data frame to a matrix.

As a more concrete example, I have read the following data in from a file
(around 300,000 rows):

xy z
00687
0164
0271
0355
0452
0551
0638
0738
0854
0949
.
.
.
3049792829771
35137715479801
38383517405411
41813360247101
42154910285721
47131417518361
57960218173931
71351555243851 


So what I want to do is transform this into a matrix where at position (x,y)
in the matrix I have value z. I am doing this so that I can then do a
filled.contour plot on the data.

I think this is the same as what Jessica is asking...

Regards and many thanks,

Jonathan
UCL Computer Science
-- 
View this message in context: 
http://r.789695.n4.nabble.com/from-table-to-matrix-tp3087972p3088096.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] survival: ridge log-likelihood workaround

2010-12-14 Thread Damjan Krstajic

I would like to clarify statistics that ridge coxph returns. Here is my 
understanding and please correct me where I am wrong.

1) In his paper Gray [JASA 1992] suggests a Wald-type statistics with the 
formula for degree of freedom. The summary function for ridge coxph returns the 
degree of freedom and Wald test which are equivalent to what Gray wrote.
2) Summary for ridge coxph prints a likelihood ratio test which is not, if I 
may say, a proper likelihood ratio test. First it is based on unpenalized 
log-likelihoods and the above defined degree of freedom is used. I accept that 
there is nothing which suggests that one should use penalized log-likelihoods. 
However, there is also nothing published which suggests that unpenalized 
log-likelihoods should be used with the above defined degree of freedom. I have 
found that TherneauGrambsch in their excellent book discuss this in a 
paragraph and mention that the p-value thus returned is somewhat conservative 
(p too large). Therefore, the likelihood ratio test that ridge coxph returns is 
not a true one and the statistics returned (i.e. 2*(loglik(beta)-loglik(0)))  
has the distribution which is somewhat more compact than the chi-square. I like 
conservative p-values and like to be on a safe side. However, in my work Wald 
test p-values for ridge regression are much higher than the l!
 ikelihood ratio test's p-value and I don't get impression that they are 
conservative.
3) There is no efficient score test for ridge regression, as there is no 
penalized efficient score test. That is OK.
4) Rsquare and max possible are returned and I have so far failed to find 
exact references for them.

I would like to add a note here that the coxph algorithm works really fast with 
high-dimensional covariates and all compliments to people who developed it.  
There was evidently a lot of effort put to make it all work fast and correctly 
and, in my opinion, it is a shame that the last bit - summary for ridge coxph - 
is a bit, if I may say, shaky. In my opinion, only Wald test and degree of 
freedom as defined by Gray deserve to be part of summary for ridge coxph and I 
look forward to be corrected. On my behalf I am prepared in my spare time to 
write the code so that the summary for ridge coxph does not return NULL and 
that the statistics printed in summary for ridge coxph are based on published 
papers.

Damjan Krstajic


 Subject: Re: [R] survival: ridge log-likelihood workaround
 From: thern...@mayo.edu
 To: r-help@r-project.org; dkrsta...@hotmail.com
 Date: Fri, 10 Dec 2010 09:07:42 -0600
 
 -- begin inclusion -
 Dear all,
 
 I need to calculate likelihood ratio test for ridge regression. In
 February I have reported a bug where coxph returns unpenalized
 log-likelihood for final beta estimates for ridge coxph regression. In
 high-dimensional settings ridge regression models usually fail for lower
 values of lambda. As the result of it, in such settings the ridge
 regressions have higher values of lambda (e.g. over 100) which means
 that the difference between unpenalized log-likelihood and penalized
 log-likelihood is not insignificant. I would be grateful if someone can
 confirm that the below code is correct workaround.
 
 --- end included message 
 
 First, the bug you report is not a bug.  The log partial likelihood
 from a Cox model LPL(beta) is well defined for any vector of
 coefficients beta, whether they are result of a maximization or taken
 from your daily horoscope.  The loglik component of coxph is the LPL for
 the reported coefficients.
 
 For a ridge regression the coxph function maximizes LPL(beta) -
 penalty(beta) = penalized partial likelihood = PPL(beta).  You have
 correctly recreated the PPL.
 
 Second: how do you do formal tests on such a model?  This is hard.  The
 difference LPL1- LPL2 is a chi-square when each is the result of
 maximizing the Cox LPL over a set of coefficients; when using a PPL we
 are maximizing over something else.  The distribution of the difference
 of constrained LPL values can be argued to be a weighed sum of squared
 normals where the weights are in (0,1), which is something more complex
 than a chisq distribution.  In a world with infinite free time I'd have
 pursued this, worked it all out, and added appropriate code to coxph.
 
 What about the difference in PPL values, which is the test you propose?
 I'm not aware of any theory showing that these have any relation to a
 chi-square distribution.  (Said theory may well exist, and I'd be happy
 for pointers.)
 
 Terry Therneau
 
  
[[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] GLM with different factors

2010-12-14 Thread Rafael Xavier de Camargo
Hi R-Helpers,

I am stuck with my analysis. I wonder if anybody could have with this.

My data set looks like:

  Squares

Hours

SppRichness

Feeding_guild

natprop

1

10

1

aq inverts

0.118697

2

25

2

aq inverts

0.605874

3

35

2

fish

0.61255

4

20

4

fish

0.764418

5

40

3

insects

0.810646

6

20

2

insects

0.832063

7

20

2

Omnivores

0.838509

n

20

3

Omnivores

0.839228


My interest is to run a GLM model between the response variable y =
SppRichness (species richness) and y = natprop )Proportion of Natural Area
considering each Feeding Guild (factor) separately. In other words I want to
run with one single code the richness within guild as a function of natural
proportion area.

Is there a way to write a code to run all the correlations for each guild at
once? And then to keep the coefficients? And plot the correlations in
separately files?

Thanks in advance.

Rafael


-- 
**
RAFAEL CAMARGO
Postgraduate Student
Biology Department of University of Ottawa
30 Marie Currie, room # 251
Ottawa, ON, CANADA
Tel: +1 (613) 562-5800 ext. 6366
Cel: +1 (613) 869-3772
e-mail: rcama...@uottawa.ca
rafael.x.cama...@gmail.com

[[alternative HTML version deleted]]

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


Re: [R] from table to matrix

2010-12-14 Thread Greg Snow
If the goal is to produce a filled contour plot, then look at the levelplot 
function in the trellis package, it takes the data in the form that you already 
have it, no need to transform.

-- 
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 jonathan
 Sent: Tuesday, December 14, 2010 3:14 PM
 To: r-help@r-project.org
 Subject: Re: [R] from table to matrix
 
 
 That's so weird, I just signed up on here to ask exactly the same
 question!
 
 However, I think my issue is like Jessica's who says that her data is
 like
 that, not actually that...
 
 So the issue is not in generating that data on-the-fly but in
 transforming
 it from a data frame to a matrix.
 
 As a more concrete example, I have read the following data in from a
 file
 (around 300,000 rows):
 
 xy z
 00687
 0164
 0271
 0355
 0452
 0551
 0638
 0738
 0854
 0949
 .
 .
 .
 3049792829771
 35137715479801
 38383517405411
 41813360247101
 42154910285721
 47131417518361
 57960218173931
 71351555243851
 
 
 So what I want to do is transform this into a matrix where at position
 (x,y)
 in the matrix I have value z. I am doing this so that I can then do a
 filled.contour plot on the data.
 
 I think this is the same as what Jessica is asking...
 
 Regards and many thanks,
 
 Jonathan
 UCL Computer Science
 --
 View this message in context: http://r.789695.n4.nabble.com/from-table-
 to-matrix-tp3087972p3088096.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] from table to matrix

2010-12-14 Thread Sarah Goslee
There are many ways to do this in R. For very simple problems, this
one is convenient:

library(ecodist)
newdata - crosstab(mydata$x, mydata$y, mydata$z)

For more complicated problems, reshape is very powerful.

Sarah

On Tue, Dec 14, 2010 at 5:13 PM, jonathan j...@than.biz wrote:

 That's so weird, I just signed up on here to ask exactly the same question!

 However, I think my issue is like Jessica's who says that her data is like
 that, not actually that...

 So the issue is not in generating that data on-the-fly but in transforming
 it from a data frame to a matrix.

 As a more concrete example, I have read the following data in from a file
 (around 300,000 rows):

 x    y     z
 0    0    687
 0    1    64
 0    2    71
 0    3    55
 0    4    52
 0    5    51
 0    6    38
 0    7    38
 0    8    54
 0    9    49
 .
 .
 .
 304979    282977    1
 351377    1547980    1
 383835    1740541    1
 418133    6024710    1
 421549    1028572    1
 471314    1751836    1
 579602    1817393    1
 713515    5524385    1


 So what I want to do is transform this into a matrix where at position (x,y)
 in the matrix I have value z. I am doing this so that I can then do a
 filled.contour plot on the data.

 I think this is the same as what Jessica is asking...

 Regards and many thanks,

 Jonathan
 UCL Computer Science


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

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


Re: [R] from table to matrix

2010-12-14 Thread Phil Spector

Jonathan -
   Same problem, same solution:

Suppose your data frame is called df:


thematrix = matrix(NA,max(df$x),max(df$y))
thematrix[as.matrix(df[,1:2])] = df[,3]


- Phil Spector
 Statistical Computing Facility
 Department of Statistics
 UC Berkeley
 spec...@stat.berkeley.edu

On Tue, 14 Dec 2010, jonathan wrote:



That's so weird, I just signed up on here to ask exactly the same question!

However, I think my issue is like Jessica's who says that her data is like
that, not actually that...

So the issue is not in generating that data on-the-fly but in transforming
it from a data frame to a matrix.

As a more concrete example, I have read the following data in from a file
(around 300,000 rows):

xy z
00687
0164
0271
0355
0452
0551
0638
0738
0854
0949
.
.
.
3049792829771
35137715479801
38383517405411
41813360247101
42154910285721
47131417518361
57960218173931
71351555243851


So what I want to do is transform this into a matrix where at position (x,y)
in the matrix I have value z. I am doing this so that I can then do a
filled.contour plot on the data.

I think this is the same as what Jessica is asking...

Regards and many thanks,

Jonathan
UCL Computer Science
--
View this message in context: 
http://r.789695.n4.nabble.com/from-table-to-matrix-tp3087972p3088096.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] peak detection

2010-12-14 Thread Carl Witthoft
	THere's the peaks package which will do some peak detection, or 'peaks' 
in the simecol package.  Or msc.peaks.find in caMassClass,



I'm madly trying to remember what spectral package I found which has a 
tool similar to msextrema but returns a couple more useful lists 
describing the data and the results...



Carl



***


From: Michael Bedward michael.bedward_at_gmail.com
Date: Tue, 14 Dec 2010 14:49:04 +1100

Hi Joe,

Just for info, I've done this in the past by applying lowess followed by 
diff to a vector, then identifying points with change of sign in the diffs.


Michael

On 14 December 2010 14:22, Joe Stuart joe.stuart_at_gmail.com wrote:
 Never mind. I did find this package, which seems to do the trick. Thanks

 
http://rgm2.lab.nig.ac.jp/RGM2/R_man-2.9.0/library/msProcess/man/msExtrema.html


 On Mon, Dec 13, 2010 at 9:05 PM, Joe Stuart joe.stuart_at_gmail.com 
wrote:

 Hi,
 I was wondering if anyone knows of a package that contains the ability
 for peak/valley detection. Here is an example of what I'm looking for,
 only problem is that it's written in Matlab.

 http://www.billauer.co.il/peakdet.html

 Thanks for any help in advance.

 -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] Use generalised additive model to plot curve

2010-12-14 Thread e-letter
Readers,

I have been reading 'the r book' by Crawley and think that the
generalised additive model is appropriate for this problem. The
package 'gam' was installed using the command (as root)

install.package(gam)
...
library(gam)

 library(gam)
Loading required package: splines
Loading required package: akima
 library(mgcv)
This is mgcv 1.3-25

Attaching package: 'mgcv'


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

 gam,
 gam.control,
 gam.fit,
 plot.gam,
 predict.gam,
 s,
 summary.gam

 x-c(30,50,80,90,100)
 y-c(160,180,250,450,300)
 model-gam(y~s(x))
Error in smooth.construct.tp.smooth.spec(object, data, knots) :
A term has fewer unique covariate combinations than specified
maximum degrees of freedom

The objective is to plot y against x, finally to produce a graph with
a smooth curve (and then remove the data points). What is my mistake
please?

yours,

r251
gnu/linux mandriva2008

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


Re: [R] from table to matrix

2010-12-14 Thread Carl Witthoft
For contour plots,  some of the contour functions in graphics packages 
(lattice for one IIRC) are pretty good at understanding that columns in 
a matrix correspond to x,y, and z values already.








There are many ways to do this in R. For very simple problems, this one 
is convenient:


library(ecodist)
newdata - crosstab(mydata$x, mydata$y, mydata$z)

For more complicated problems, reshape is very powerful.

Sarah

On Tue, Dec 14, 2010 at 5:13 PM, jonathan jon_at_than.biz wrote:

 That's so weird, I just signed up on here to ask exactly the same 
question!


 However, I think my issue is like Jessica's who says that her data is 
like

 that, not actually that...

 So the issue is not in generating that data on-the-fly but in 
transforming

 it from a data frame to a matrix.

 As a more concrete example, I have read the following data in from a file
 (around 300,000 rows):

 xy z
 00687
 0164
 0271
 0355
 0452
 0551
 0638
 0738
 0854
 0949
 .
 .
 .
 3049792829771
 35137715479801
 38383517405411
 41813360247101
 42154910285721
 47131417518361
 57960218173931
 71351555243851


 So what I want to do is transform this into a matrix where at 
position (x,y)

 in the matrix I have value z. I am doing this so that I can then do a
 filled.contour plot on the data.

 I think this is the same as what Jessica is asking...

 Regards and many thanks,

 Jonathan
 UCL Computer Science

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


Re: [R] Use generalised additive model to plot curve

2010-12-14 Thread Bill.Venables
Dear Lurker,

If all you art trying to do is to plot something, isn't all you need something 
like the following?

x - c( 30,  50,  80,  90, 100)
y - c(160, 180, 250, 450, 300)
sp - spline(x, y, n = 500)
plot(sp, type = l, xlab = x, ylab = y, 
 las = 1, main = A Spline Interpolation)
points(x, y, pch = 3, col = red, lwd = 2) 

Bill Venables.

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of e-letter
Sent: Wednesday, 15 December 2010 8:37 AM
To: r-help@r-project.org
Subject: [R] Use generalised additive model to plot curve

Readers,

I have been reading 'the r book' by Crawley and think that the
generalised additive model is appropriate for this problem. The
package 'gam' was installed using the command (as root)

install.package(gam)
...
library(gam)

 library(gam)
Loading required package: splines
Loading required package: akima
 library(mgcv)
This is mgcv 1.3-25

Attaching package: 'mgcv'


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

 gam,
 gam.control,
 gam.fit,
 plot.gam,
 predict.gam,
 s,
 summary.gam

 x-c(30,50,80,90,100)
 y-c(160,180,250,450,300)
 model-gam(y~s(x))
Error in smooth.construct.tp.smooth.spec(object, data, knots) :
A term has fewer unique covariate combinations than specified
maximum degrees of freedom

The objective is to plot y against x, finally to produce a graph with
a smooth curve (and then remove the data points). What is my mistake
please?

yours,

r251
gnu/linux mandriva2008

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

2010-12-14 Thread Gavin Simpson
On Tue, 2010-12-14 at 22:36 +, e-letter wrote:
 Readers,
 
 I have been reading 'the r book' by Crawley and think that the
 generalised additive model is appropriate for this problem. The
 package 'gam' was installed using the command (as root)
 
 install.package(gam)
 ...
 library(gam)
 
  library(gam)
 Loading required package: splines
 Loading required package: akima
  library(mgcv)
 This is mgcv 1.3-25

Why do you want to use both gam:::gam and mgcv:::gam at the same time?
Use one or the other package; not both.

 Attaching package: 'mgcv'
 
 
 The following object(s) are masked from package:gam :
 
  gam,
  gam.control,
  gam.fit,
  plot.gam,
  predict.gam,
  s,
  summary.gam

These warnings/messages are because you loaded two packages that both
provide a gam() and other similarly named functions.

  x-c(30,50,80,90,100)
  y-c(160,180,250,450,300)
  model-gam(y~s(x))
 Error in smooth.construct.tp.smooth.spec(object, data, knots) :
 A term has fewer unique covariate combinations than specified
 maximum degrees of freedom

You are trying to fit a thin-plate spline that is of greater complexity
than the available data. You need to reduce the complexity of the fitted
spline whilst fitting the model. For these data the maximum complexity
is 5:

 mod - gam(y ~ s(x, k = 5))

HTH

G

 The objective is to plot y against x, finally to produce a graph with
 a smooth curve (and then remove the data points). What is my mistake
 please?
 
 yours,
 
 r251
 gnu/linux mandriva2008
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

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


Re: [R] from table to matrix

2010-12-14 Thread jonathan

OK well I don't mean to hijack Jessica's thread with a tangent on graphics
and plots, but I'm still having some trouble. I'm a total newbie here so if
the correct etiquette would be for me to start a new thread at this point
then please do advise me!!

The code I'm now trying to run is:

library(lattice)
df - read.table(data, sep=\t, header=TRUE)

levelplot(df$z ~ df$x * df$y)

It seems to run OK but I don't seem to be getting any output... I'm running
the latest R on OS X. All the normal plotting functions, e.g. standard
plot() seem to work fine and display in a Quartz window, but when I run this
I'm not getting anything =/

Any tips?

Jonathan
-- 
View this message in context: 
http://r.789695.n4.nabble.com/from-table-to-matrix-tp3087972p3088161.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] rpart - how to estimate the “meaningful” predictors for an outcome (in classification t rees)

2010-12-14 Thread Xiaogang Su
Hi, Tal,

Here is a quick way of getting around. First create two responses via
dummy variables

y1 - ifelse(y==a, 1, 0)
y2 - ifelse(y==b, 1, 0)

and then built two separate tree models for y1 and y2 separately.

Hope it helps.
Xiaogang


On Tue, Dec 14, 2010 at 8:33 AM, Tal Galili tal.gal...@gmail.com wrote:
 Hi dear R-help memebers,

 When building a CART model (specifically classification tree) using rpart,
 it is sometimes obvious that there are variables (X's) that are meaningful
 for predicting some of the outcome (y) variables - while other predictors
 are relevant for other outcome variables (y's only).

 *How can it be estimated, which explanatory variable is used for which of
 the predicted value in the outcome variable?*

 Here is an example code in which x2 is the only important variable for
 predicting b (one of the y outcomes). There is no predicting variable for
 c, and x1 is a predictor for a, assuming that x2 permits it.

 How can this situation be shown using the an rpart fitted model?

 N - 200
 set.seed(5123)

 x1 - runif(N)

 x2 - runif(N)

 x3 - runif(N)

 y - sample(letters[1:3], N, T)

 y[x1 .5] - a

 y[x2 .1] - b

 fit - rpart(y ~ x1+x2)

 fit2 - prune(fit, cp= 0.07)

 plot(fit2)

 text(fit2, use.n=TRUE)

 Thanks,

 Tal



 Contact
 Details:---
 Contact me: tal.gal...@gmail.com |  972-52-7275845
 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
 www.r-statistics.com (English)
 --

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




-- 
==
Xiaogang Su, Ph.D.
Associate Professor, Statistician
School of Nursing, University of Alabama
Birmingham, AL 35294-1210
(205) 934-2355 [Office]
x...@uab.edu
xiaogan...@gmail.com
http://homepage.uab.edu/xgsu/

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


Re: [R] from table to matrix

2010-12-14 Thread jonathan

Maybe I can help here:

In OS X at least you can open the R Package Installer from the Packages 
Data menu, select a mirror, etc, then type ecodist into the search bar and
then Install Selected... this will install the ecodist package on your
machine.

Not exactly sure how it would be done under other operating systems but
that's the basic idea.

Jonathan
-- 
View this message in context: 
http://r.789695.n4.nabble.com/from-table-to-matrix-tp3087972p3088187.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] Modifying values outside a function using apply.

2010-12-14 Thread Worik R
I am sure this si a simple problem but the solution is evading me.

I have a list of matrices all with the same number of columns but different
number of rows.  The first two columns label the row.  The labels are
allways the same for the same row numbers, just some matricies have more
rows.

For example using 3 column matrices...

 q.1 - function(r){return(cbind(seq(0, 10, by=1)[1:r], seq(10, 30,
by=2)[1:r], runif(r)))}
 sapply(q, q.1)
[[1]]
 [,1] [,2]  [,3]
[1,]0   10 0.5399220
[2,]1   12 0.1551015
[3,]2   14 0.9664470

[[2]]
 [,1] [,2]   [,3]
[1,]0   10 0.09678172
[2,]1   12 0.75177116
[3,]2   14 0.59927159
[4,]3   16 0.18472215

[[3]]
 [,1] [,2]  [,3]
[1,]0   10 0.6343689
[2,]1   12 0.8121039

Given such a list I would like to create a matrix:

0 10 mean(ThisCol for this row)
1 12 mean(ThisCol for this row)
2 14 mean(ThisCol for this row)
3 16 mean(ThisCol for this row)

I can loop using a for loop but I would like to use apply but I have no idea
how to get it to work.  If I could pass arguments by reference to a function
it would be easy but as far as I can tell there is only pass by value.


 cheers
Worik

[[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] Installing R-packages in Windows

2010-12-14 Thread Mike Marchywka





 Date: Tue, 14 Dec 2010 23:48:20 +0100
 From: er...@phonetik.uni-muenchen.de
 To: marchy...@hotmail.com
 CC: r-help@r-project.org; lig...@statistik.tu-dortmund.de


 Hi Mike, Hi Uwe,

 thanks for your reply.
 The main thing is that we have mixed OSs. On the one hand we have Linux,
 on the other WinXP. I need the same version of packages and R on both
 systems. Otherwise I cant explain my colleagues why error messages are
 reproduceable on only one system.
 Installing by compiling the .tar.gz-files does work on Linux, but not on
 Win because make is not avaivable :( I already tried.

If you want to do anything on 'dohs where you want to use
the computer to automate data processing, get something
like cygwin- that was probably where my make came from. 
You can put that on all the relevant computers
and disto a script or something, that should be allowable. 
Machine specific failures I would think would be quite common
in most settings in any case. 


 The disadvantage of install.packages is (if I am not right tell me
 please), that the package is only installed for the local user (and its
 home-Directory ) who is using R at the moment. In my case I need to
 install for all local users. Is there a way to do that automated with
 install.packages ?

Well, without actually knowing myself I would again just
suggest giving people a script or if it is just one
machine that you use install multiple times/copies even
if it is a bit of a waste and could create inconsistencies.

In any case, however, you should be able to pick a library
directory for R. I've never tried to point mine
but presumably all the installs could point to the same
one. Permissions may need to be modified but usually these
things are read-execute world so it may not be a factor. 



 I might think about Uwe's proposal to install the latest R with the
 latest packages. But there's still that problem with installing for ALL
 users :S
 I am unable to do that - even if I can use a local repo.

 Any ideas?

 Thanks in advance

 Erik

 On 12/14/2010 06:17 PM, Mike Marchywka wrote:
 
 
 
 
 
 
 
 
 
  ( hotmail just randomly decides not to prefix original text, my comments 
  below)
 
 
  
  Date: Tue, 14 Dec 2010 17:36:11 +0100
  From: er...@phonetik.uni-muenchen.de
  To: r-help@r-project.org

 
 
  Hi there,
  I have the following problem and I hope somebody might help me.
 
  First of all: I am using WinXP SP3 (english and/or german) with R in
  Version 2.10.0.
 
  Now I am trying to install some packages but unfortunately I am getting
  a weird error. No matter which package I am trying to install - I nearly
  get the same error.
 
  It looks like this:
  -
  C:\Program Files\R\R-2.10.0\binR CMD INSTALL
  %SystemDrive%\rPAcsTemp\car_2.0-2.
  zip
  Warning in rawToChar(block[seq_len(ns)]) :
  truncating string with embedded nul:
 
  M::
 
 
  I used to build all from source then that stopped working and I have
  seen others here complain about installation failures. I have had good
  luck with what others have suggested, and use install.packages()
 
  It goes into a script ok, for example, ( note that myR is my
  script that invokes R but you can change etc). This points to ucla
  mirror, writes a script into $tf to install $pkf, installs $pkf by
  running the gerated script, and then shows you the results and deletes junk
  ( normally you want to check error codes before deling junk however)
 
  tf=$$_temp
  cat - DUMMTY $tf
  options(repos=c(http://cran.stat.ucla.edu;))
  install.packages(c($pkf),dep=TRUE)
  DUMMTY
  echo executing
  cat $tf
  myR -run $tf
 
  echo removing $tf
  rm $tf
  echo removing R output
  cat $tf.Rout
  rm $tf.Rout
 
 
 
 
 
 
 
 
 
 


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


Re: [R] Discriminant Correspondence Analysis

2010-12-14 Thread Peter Ehlers

Wayne,

So far, no one has said the obvious:
Please do work your way through (or at least
skim) An Introduction to R which you'll
find right there on your computer under
Help/Manuals. Your questions indicate that
you have not yet done so. Do it, it really
will pay off.

Peter Ehlers

On 2010-12-14 12:36, Wayne Sawtell wrote:

Hello everyone,

I am totally new to the R program. I have had a look at some pdf documents
that I downloaded and that explain how to do many things in R; however, I
still cannot figure out how to do what I want to do, which is to perform
Discriminant Correspondence Analysis on a rectangular matrix of data that I
have in an Excel file. I know R users frown upon Excel and recommend
converting Excel files to .csv format, which I have done, no problem. That
is not an issue.
There are several parts to my problem.
1) When I try the read.table command, even if I include the directory name
in the filename, R still cannot read the file, even if it is in .csv format
2) I was able to copy my file and then read the clipboard contents into R
but then I do not know to assign a name to the data frame in order to
conduct any operations on it
3) I need the ADE4 program in order to perform Discriminant Correspondence
Analysis, so I used the install.packages command to install it. It
installed no problem but I do not know how to access the ADE4 program in R.
I am unable to open it directly, either.
4) I thought that using the ADE4 GUI (called ade4TkGUI) would be easier
because I do not know many of the R commands; but, again, I downloaded it
but cannot open or access it.

The following is the suggested coding that I found through the R website,
but when I try to use this code, I don't know how to assign a name for the
df, or what to put for fac, and what is worse, I get an error message
saying that the program cannot find the discrimin.coa command.


Usage

discrimin.coa(df, fac, scannf = TRUE, nf = 2)

Arguments

df a data frame containing positive or null values

fac a factor defining the classes of discriminant analysis

scannf a logical value indicating whether the eigenvalues bar plot should be
displayed

nf if scannf FALSE, an integer indicating the number of kept axes

Examples

data(perthi02)

plot(discrimin.coa(perthi02$tab, perthi02$cla, scan = FALSE))
For clarification, my data consists of measurements of morphological
characters of an assemblage of biological specimens. I have already
performed Principal Co-ordinates Analysis, Principal Compionents Analysis
and Cluster Analysis in another program (PAST) in order to see if the data
fall into distinct groupings that might represent different morphological
species. I now want to test the groupings that I found on my test data set
using Discriminant Correspondence Analysis.There are both continuous and
categorical characters, which is the reason why I need to perform
Discriminant Correspondence Analysis, instead of Linear Discriminant
Analysis, which is only valid for continuous measurements. R seems to be the
only program in which I can perform Discriminant Correspondence Analysis.

Thanks for any help offered on any of these points.
Wayne

[[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] lattice fun: multiple themes in panels with spplot()

2010-12-14 Thread nbest937

I have some geospatial data where two layers are thematic and the third is a
percentage, so the maps need to have different themes.  

thumbDf - as( stack( thumb), SpatialGridDataFrame)
names(thum...@data) - c(pri, sec, pct)
thum...@data$pri - factor(thum...@data$pri, levels=c(0:8), labels= names(
peelClasses))
thum...@data$sec - factor(thum...@data$sec, levels=c(0:8), labels= names(
peelClasses))

stack() comes from library(raster), which does not do lattice natively and
doesn't plot thematic maps particularly well, AFAIK.  Coercing the data to
something that spplot() can handle and changing the thematic data to factors
results in a very satisfactory legend for that theme.  I would like the
third map to have the same size so that they more closely resemble a set of
panels even though they have different themes.

I have experimented with three approaches:


thumbDfPlot - 
  spplot(thumbDf, c(pri, sec), 
 names.attr=c(Primary cover, Secondary cover), 
 between= list( x=0.5))


trellis.par.set( peelTheme)
plot( thumbDfPlot, split= c(1,1,2,1), more=TRUE)
trellis.par.set(sp.theme())
plot( spplot(thumbDf, pct), split= c(2,1,2,1))

The second plot (showing the third panel) is taller because it's legend is
narrower and together they have half of the page to work with.  Also, it
does not have a panel title showing it's name (pct unless I give it
something else, which I cannot figure out how to do for a plot of one panel.

trellis.par.set( peelTheme)
plot( spplot( thumbDf, pri), split= c(1,1,3,1), more=TRUE)
plot( spplot( thumbDf, sec), split= c(2,1,3,1), more=TRUE)
trellis.par.set(sp.theme())
plot( spplot(thumbDf, pct), split= c(3,1,3,1), position= c(0,0.25,1,0.75))

Doing it this way, each of the first two gets its own legend, which is not
what I want either, but at least none of them has a panel title, so I could
give them each a plot title.  The size is close, but not quite right.  I
could probably get it pretty close changing the position vector itertively,
but that is not very satisfying.

trellis.par.set( peelTheme)
plot( thumbDfPlot, position= c(0,0,0.625,1), more=TRUE)
trellis.par.set(sp.theme())
plot( spplot(thumbDf, pct, names.attr=Confidence), position=c(
0.625,0,1,1))

Sizing is closer than the first, but the same basic issues are still in
play, plus names.attr has no effect.  There must be a way to link the panel
sizes from one plot to the next in case something else changes.

Is there a way to turn off the legend and plot it separately, extracting it
from the original spplot() object?

Is it possible to specify the theme panel by panel?

I could post some images somewhere if it's helpful.  Any suggestions on a
free, public tool for doing that?

Thanks for taking a look at this.


Climbing the lattice learning curve,

Neil

-- 
View this message in context: 
http://r.789695.n4.nabble.com/lattice-fun-multiple-themes-in-panels-with-spplot-tp3088225p3088225.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] survfit

2010-12-14 Thread Angel Russo
Hello R helpers:

*My first message didn't pass trough filter so here it's again*

I would like to obtain probability of an event for one single patient as a
function of time (from survfit.coxph) object, as I want to find what is the
probability of an event say at 1 month and what is the probability of an
event at 80 months and compare. So I tried the following but it fails
miserably. I looked at some old posts but could not figure out the solution.
Here's what I did where for one single patient, the answer is NULL. Could
anyone help me with the problem?

R.app GUI 1.34 (5589 Leopard build 32-bit)

 library(glmpath)
* dataall - list(x=lung.data$x[1:130,], time=lung.data$time[1:130],
status=lung.data$status[1:130])*
*

 fit.a - coxpath(dataall)

 testall - list(x=lung.data$x[131:137,], time=lung.data$time[131:137],
status=lung.data$status[131:137])

 testpred - predict(fit.a, testall, s=0.99, type='coxph',
mode='lambda.fraction')


 testpred

Call:

coxph(formula = Surv(time, status) ~ x, method = object$method)

  coef exp(coef) se(coef)  zp

karno -0.00756 0.992   0.0364 -0.208 0.84

Likelihood ratio test=0.89  on 1 df, p=0.344  n= 7

 newd1 - list(testall$x[1,])

 survtest - survfit(testpred,newdata=newd1,individual=T)

 survtest

Call: survfit(formula = testpred, newdata = newd1, individual = T)


records   n.max n.start  events  median 0.95LCL 0.95UCL

  7   0   0   0   0   0   0

 summary(survtest)

Call: survfit(formula = testpred, newdata = newd1, individual = T)

time n.risk n.event survival std.err lower 95% CI upper 95% CI

 survtest$survival




NULL


***

[[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] from table to matrix

2010-12-14 Thread jonathan

I actually got it to work now using levelplot, and I also worked out how to
get the graph I wanted to display, I had to assign the graph to a reference
and then print it -- yes, that simple!

Now I just need to work out why my levelplot doesn't look quite right, even
though the data is in there... and I should be good to go!

Hope that you got your stuff to work Jessica, and thanks to everyone for
your help :-) I'm sure I will be posting here again very soon!

Jonathan
-- 
View this message in context: 
http://r.789695.n4.nabble.com/from-table-to-matrix-tp3087972p3088230.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] survival: ridge log-likelihood workaround

2010-12-14 Thread Therneau, Terry M., Ph.D.
You ask some good questions. 
 
 I would like to clarify statistics that ridge coxph returns. Here is
 my understanding and please correct me where I am wrong.
 
 1) In his paper Gray [JASA 1992] suggests a Wald-type statistics with
 the formula for degree of freedom. The summary function for ridge
 coxph returns the degree of freedom and Wald test which are
 equivalent to what Gray wrote.
 
Not quite.  The printout contains se and se2.  The first is the
suggestion
of Verwiej and Van Houwlingen and the second is the suggestion of Gray.
The first error estimate is always larger although usually very close to
the
second.  However, I have seen several data sets where the second
collapses and
produces a tiny variance estimate.  Thus the Wald statistic is based on 
the Verweij estimate.
 
 2) Summary for ridge coxph prints a likelihood ratio test which is
  not, if I may say, a proper likelihood ratio test. First it is
  based on unpenalized log-likelihoods and the above defined degree
  of freedom is used. I accept that there is nothing which suggests
  that one should use penalized log-likelihoods. However, there is
  also nothing published which suggests that unpenalized
  log-likelihoods should be used with the above defined degree of
  freedom. I have found that TherneauGrambsch in their excellent
  book discuss this in a paragraph and mention that the p-value thus
  returned is somewhat conservative (p too large). Therefore, the
  likelihood ratio test that ridge coxph returns is not a true one
  and the statistics returned (i.e. 2*(loglik(beta)-loglik(0))) has
  the distribution which is somewhat more compact than the
  chi-square. I like conservative p-values and like to be on a safe
  side. However, in my work Wald test p-values for ridge regression
  are much higher than the likelihood ratio test's p-value and I
  don't get impression that they are conservative.
 
There is literature, but it's been 10 years and I don't remember the
references.  One key issue, not documented I admit, is that for the
difference in LR between two models to be valid at all, they have to
have
the same penalty parameter.  I have almost never compared two penalized
LR to each other, likely because I rarely use ridge().  More often I am
comparing the LR of a penalized model to one without the penalty term, 
for which the issue does not arise.
  The same type of issue will arise, I believe, if one were to fit two
mixed effects models that differed only in the fixed effects, and then
used an LR test.  Comparisons are only valid if two have the same
variance
values, or else the models are not nested.
 
 3) There is no efficient score test for ridge regression, as there is
no 
 penalized efficient score test. That is OK.
 

 4) Rsquare and max possible are returned and I have so far failed
to 
 find exact references for them.
  I was sure that was somewhere, but I can't find it either.  The manual
page
summary.coxph.object fell off my list somewhere.
  The R^2 value is that of Nagelkirke.  At the time I wrote that code it
was
a simple estimate of R^2.  There have since been several other
proposals, and
a recent review by Schemper suggests that the Nagelkirke method may be
nearly
the worst of the bunch.  Replacing this is another item on my to-do
list. 
 
 I would like to add a note here that the coxph algorithm works really
 fast with high-dimensional covariates and all compliments to people
 who developed it.  There was evidently a lot of effort put to make it
 all work fast and correctly and, in my opinion, it is a shame that the
 last bit - summary for ridge coxph - is a bit, if I may say, shaky. In
 my opinion, only Wald test and degree of freedom as defined by Gray
 deserve to be part of summary for ridge coxph and I look forward to be
 corrected. On my behalf I am prepared in my spare time to write the
 code so that the summary for ridge coxph does not return NULL and that
 the statistics printed in summary for ridge coxph are based on
 published papers.
 
This is the hard issue.  The penalized methods addition to coxph was 
designed so that a new method could be added without any changes at all
to the coxph (or survreg) code.  The primary reason was to allow users
to
add arbitrary methods.  It turned out that no one ever has done so, at
least
none that I have ever heard of, so that particular design goal now looks
silly.
  A consequnce of the design is that the basic printouts for the model
consist of a constant piece + an addition bit supplied by the inserted
method.  There are others: the user has to know whether a particular
penalty plug in is appropriate for survreg, coxph, or both.  This is
true
for pspline and ridge, but most of the parameter combinations for
frailty
only work with coxph.  It is in the documentation for fraily, but has
nevertheless caused many a user to stumble.  
  I think that it should be rewritten, but this is a formidable task.
Note: the people who developed the survival package is --- me, and

Re: [R] lattice fun: multiple themes in panels with spplot()

2010-12-14 Thread nbest937

I figured out how to toggle the legend for the second scenario, but now I
have three different map sizes!

trellis.par.set( peelTheme)
plot( spplot( thumbDf, pri, 
 colorkey= list( space= left)), 
 split= c( 1, 1, 3, 1), more= TRUE)
plot( spplot( thumbDf, sec,
 colorkey= FALSE), 
 split= c( 2, 1, 3, 1), more= TRUE)
trellis.par.set( seqTheme)
plot( spplot( thumbDf, pct,
 at= seq( 0, 100, by= 5), 
 split= c( 3, 1, 3, 1), 
 position= c( 0, 0.25, 1, 0.75))
-- 
View this message in context: 
http://r.789695.n4.nabble.com/lattice-fun-multiple-themes-in-panels-with-spplot-tp3088225p3088244.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] Urgent help requested using survfit(individual=T):

2010-12-14 Thread Angel Russo
Hello:

I would like to obtain probability of an event for one single patient as a
function of time (from survfit.coxph) object, as I want to find what is the
probability of an event say at 1 month and what is the probability of an
event at 80 months and compare. So I tried the following but it fails
miserably. I looked at some old posts but could not figure out the solution.
Here's what I did where for one single patient, the answer is NULL. Could
anyone help me with the problem?

R.app GUI 1.34 (5589 Leopard build 32-bit)

 library(glmpath)
* dataall - list(x=lung.data$x[1:130,], time=lung.data$time[1:130],
status=lung.data$status[1:130])*
*

 fit.a - coxpath(dataall)

 testall - list(x=lung.data$x[131:137,], time=lung.data$time[131:137],
status=lung.data$status[131:137])

 testpred - predict(fit.a, testall, s=0.99, type='coxph',
mode='lambda.fraction')


 testpred

Call:

coxph(formula = Surv(time, status) ~ x, method = object$method)

  coef exp(coef) se(coef)  zp

karno -0.00756 0.992   0.0364 -0.208 0.84

Likelihood ratio test=0.89  on 1 df, p=0.344  n= 7

 newd1 - list(testall$x[1,])

 survtest - survfit(testpred,newdata=newd1,individual=T)

 survtest

Call: survfit(formula = testpred, newdata = newd1, individual = T)


records   n.max n.start  events  median 0.95LCL 0.95UCL

  7   0   0   0   0   0   0

 summary(survtest)

Call: survfit(formula = testpred, newdata = newd1, individual = T)

  time n.risk n.event survival std.err lower 95% CI upper 95% CI

   survtest$survival



NULL


*

[[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] Multivariate binary response analysis

2010-12-14 Thread Emmanuel Charpentier
Dear Derek, dear list,

A couple suggestions (and more) :

0) check that your problem can't be expressed in terms of what glmer() 
(lme4(a|b)? package(s)) can solve. I use this often, and am quite 
impressed with its abilities.

1) Why not modeling that directly in BUGS ? That might not be easy, will 
almost certainly not be fast to converge and will require lots of post-
convergence analysis but offers a direct solution.

Current BUGS implementations (OpenBUGS 3.1.x, JAGS 2.x) are well-
interfaced to R. My current favorite is JAGS + rjags, but this preference 
might come from years of frustration about (Win|Open)BUG on Wine on 
Linux, and the current offering of OpenBUGS + BRugs, currently in beta on 
the Community page of the OpenBUGS website, seems quite decent. Memory 
use might have been a  problem in the (not so) good old days, but in a 
era of multigigabyte netbooks, I doubt this is still relevant. 
Computation time is more of a concern : although Lunn  al. (2009)(1) 
allude to a parallelized version of WinBUGS(2), I am not aware of any 
publicly-accessible parallelized BUGS interpreter, which is a shame in 
times where even said netbooks get multicore CPUs ...).

2) The nice MCMCglmm package is able to run a large subclass of DAG 
Bayesian models expressible as generalizations of (possibly 
multidependent) multivaried mixed-model GLMs, *way* faster than current 
BUGS implementations (the author claims an acceleration factor of about 
30 on his test problem, and my (limited) experience does not disprove 
him).

It seems (to me) that your problem *might* be expressible in terms 
palatable to MCMCglm(). Be aware, however, that using this package will 
*require* some serious understanding of the author's notation used in his 
(excellent) documentation. Furthermore, if you're interested in the 
random effects values, you're SOL : I have not (yet) been able to 
retrieve traces of their distributions in the resultant object. But 
again, my understanding of this package is limited.

My personal bias goes to BUGS, as you might have guessed, but the public 
health warning that the Spiegelhalter gang put in front of the WinBUGS 
manual still apply : MCMC sampling can be dangerous. To which I add 
model checking, convergence assessment and validation might eat more 
time than modeling itself.

HTH,

Emmanuel Charpentier

--

1. David Lunn et al., “Rejoinder to commentaries on ‘The BUGS project: 
Evolution, critique and future directions’,” Statistics in Medicine 28, 
no. 25 (11, 2009): 3081-3082.
2. http://www.page-meeting.org/pdf_assets/6232-PARALLEL%
20Girgis_POSTER_final.pdf. Accessed on Dec, 14, 2010.

On Mon, 13 Dec 2010 15:31:53 -0800, Janszen, Derek B wrote :

 Greetings ~
 
 I need some assistance determining an appropriate approach to analyzing
 multivariate binary response data, and how to do it in R.
 
 The setting: Data from an assay, wherein 6-hours-post-fertilization
 zebrafish embryos (n=20, say) are exposed in a vial to a chemical
 (replicated 3 times, say), and 5 days later observed for the
 presence/absence (1/0) of defects in several organ systems (yolk sac,
 jaw, snout, body axis, pericardial edema, etc.) for each fish. The assay
 can be used as a screen (in which case a single response 'any' is first
 analyzed) as well as for comparing the responses of different classes of
 chemicals (a MANOVA-type analysis). Interest is focused on where
 response(s) are occurring, any associations among responses, and
 ultimately on possible biological mechanisms (the fish are tested for
 behavioral activity prior to this assay, and then ground up to provide
 RNA for microarray assays. A-lotta-data!).
 
 What I *wish* I could do is something like glm(response.matrix ~
 treat/vial, family=binomial(logit), data=zf.dat) but I know this can't
 be done. I came across the baymvb (Bayesian analysis of multivariate
 binary data) package in the R contributed packages archives, but it is
 no longer supported and the author is incommunicado. In the baymvb
 function the model is specified as single.stacked.response ~
 structure.factor + linear.model.terms. Huh? This looks suspiciously
 similar to analyzing repeated measures data in SAS as a univariate
 response with a split-plot structure (which forces the response
 covariance matrix to have a compound symmetric structure). If this is
 what's happening with this function it is definitely not appropriate.
 How about a GEE approach (I'm not familiar with the liter
  ature, or with any of the R packages that implement it)? Any other
  recommendations? (NB: just discovered the bayesm package. Don't know if
  this will work for me or not.)
 
 Any help would be greatly appreciated. Derek Janszen, PhD
 Sr Research Biostatistician
 Computational Biology  Bioinformatics Pacific Northwest National
 Laboratory Richland, WA  99352 USA
 derek.jans...@pnl.gov
 
 
 
   [[alternative HTML version deleted]]


[R] Significance Help

2010-12-14 Thread Samaire Holden

I have a set of results where I have the eyesight power of both left and right 
eyes for each participant (e.g. 0.75, 0.5). Each participant then had to throw 
basketballs into a hoop and the number of successful throws was recorded.
 
I would like to do two things:
1. Test whether the eyesight power of the left and right eyes are significantly 
different from each other.
2. Test whether the number of successful throws is significantly affected by 
eyesight power (i.e. is there a difference between those people who have 
similar powers in left and right eyesight, to those who have significantly 
different powers?)
 
I know that I may not have explained this particularly well, but I'm totally 
stumped as to where to start! I have only had basic lessons with R and now have 
to do this report! 
 
Many thanks, Samaire  
[[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] Installing R-packages in Windows

2010-12-14 Thread Erik Lukac

Hi Mike, Hi Uwe,

thanks for your reply.
The main thing is that we have mixed OSs. On the one hand we have Linux, 
on the other WinXP. I need the same version of packages and R on both 
systems. Otherwise I cant explain my colleagues why error messages are 
reproduceable on only one system.
Installing by compiling the .tar.gz-files does work on Linux, but not on 
Win because make is not avaivable :( I already tried.


The disadvantage of install.packages is (if I am not right tell me 
please), that the package is only installed for the local user (and its 
home-Directory ) who is using R at the moment. In my case I need to 
install for all local users. Is there a way to do that automated with 
install.packages ?


I might think about Uwe's proposal to install the latest R with the 
latest packages.  But there's still that problem with installing for ALL 
users :S

I am unable to do that - even if I can use a local repo.

Any ideas?

Thanks in advance

Erik

On 12/14/2010 06:17 PM, Mike Marchywka wrote:










( hotmail just randomly decides not to prefix original text, my comments below)



Date: Tue, 14 Dec 2010 17:36:11 +0100
From: er...@phonetik.uni-muenchen.de
To: r-help@r-project.org
Subject: [R] Installing R-packages in Windows


Hi there,
I have the following problem and I hope somebody might help me.

First of all: I am using WinXP SP3 (english and/or german) with R in
Version 2.10.0.

Now I am trying to install some packages but unfortunately I am getting
a weird error. No matter which package I am trying to install - I nearly
get the same error.

It looks like this:
-
C:\Program Files\R\R-2.10.0\binR CMD INSTALL
%SystemDrive%\rPAcsTemp\car_2.0-2.
zip
Warning in rawToChar(block[seq_len(ns)]) :
truncating string with embedded nul:

M::


I used to build all from source then that stopped working and I have
seen others here complain about installation failures. I have had  good
luck with what others have suggested, and use install.packages()

It goes into a script ok, for example, ( note that myR is my
script that invokes R but you can change etc). This points to ucla
mirror, writes a script into $tf to install $pkf,  installs $pkf by
running the gerated script, and then shows you the results and deletes junk
( normally you want to check error codes before deling junk however)

tf=$$_temp
cat -  DUMMTY  $tf
options(repos=c(http://cran.stat.ucla.edu;))
install.packages(c($pkf),dep=TRUE)
DUMMTY
echo executing
cat $tf
myR -run $tf

echo removing $tf
rm $tf
echo removing R output
cat $tf.Rout
rm $tf.Rout













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


Re: [R] from table to matrix

2010-12-14 Thread JESSICA [via R]


Thank you guys I learnt a lot .

But when I tried to run the library(ecodist) function,  R says there is no 
package called ecodist.
why? 
__
View message @ 
http://r.789695.n4.nabble.com/from-table-to-matrix-tp3087972p3088184.html

To unsubscribe from from table to matrix, visit 
http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=3087972code=ci1oZWxwQHItcHJvamVjdC5vcmd8MzA4Nzk3MnwtNzg0MjM1NTA4
[[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] from table to matrix

2010-12-14 Thread JESSICA [via R]


Hi Jonathan,thanks a lot! Mine is windows operating system so I will 
try other ways . 
About your question, do you want to get a matrix like this:
   0 1  2  3 ...1817393  5524385 

0687 
0  64 
0  71
0   55
...
579602  1 
713515 1 


Are you intending to get a matrix like above, eg. only the diagonal position 
are filled?


__
View message @ 
http://r.789695.n4.nabble.com/from-table-to-matrix-tp3087972p3088223.html

To unsubscribe from from table to matrix, visit 
http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=3087972code=ci1oZWxwQHItcHJvamVjdC5vcmd8MzA4Nzk3MnwtNzg0MjM1NTA4
[[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] Modifying values outside a function using apply.

2010-12-14 Thread Henrique Dallazuanna
Try this:

l - sapply(c(4, 3, 2), q.1)
aggregate(V3 ~ V1 + V2, as.data.frame(do.call(rbind, l)), mean)

On Tue, Dec 14, 2010 at 9:19 PM, Worik R wor...@gmail.com wrote:

 I am sure this si a simple problem but the solution is evading me.

 I have a list of matrices all with the same number of columns but different
 number of rows.  The first two columns label the row.  The labels are
 allways the same for the same row numbers, just some matricies have more
 rows.

 For example using 3 column matrices...

  q.1 - function(r){return(cbind(seq(0, 10, by=1)[1:r], seq(10, 30,
 by=2)[1:r], runif(r)))}
  sapply(q, q.1)
 [[1]]
 [,1] [,2]  [,3]
 [1,]0   10 0.5399220
 [2,]1   12 0.1551015
 [3,]2   14 0.9664470

 [[2]]
 [,1] [,2]   [,3]
 [1,]0   10 0.09678172
 [2,]1   12 0.75177116
 [3,]2   14 0.59927159
 [4,]3   16 0.18472215

 [[3]]
 [,1] [,2]  [,3]
 [1,]0   10 0.6343689
 [2,]1   12 0.8121039

 Given such a list I would like to create a matrix:

 0 10 mean(ThisCol for this row)
 1 12 mean(ThisCol for this row)
 2 14 mean(ThisCol for this row)
 3 16 mean(ThisCol for this row)

 I can loop using a for loop but I would like to use apply but I have no
 idea
 how to get it to work.  If I could pass arguments by reference to a
 function
 it would be easy but as far as I can tell there is only pass by value.


  cheers
 Worik

[[alternative HTML version deleted]]

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




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

[[alternative HTML version deleted]]

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


[R] [R-pkgs] googleVis 0.2.2 - Using the Google Visualisation API with R

2010-12-14 Thread Markus Gesmann
Hi all,

Version 0.2.2 of the googVis package has been released on CRAN and 
will be available from your local CRAN mirror in due course. 

googleVis provides an interface between R and the Google Visualisation
API. The functions of the package allow users to visualise data
stored in R with the Google Visualisation API without 
uploading their data to Google. 

We presented our initial ideas on motion charts at LondonR in early
October. Since then we have developed the package further to include
also interfaces to Google Maps, Geo Maps, Tables, Tree Maps and
Annotated Time Lines. 

Combining R with the Google Visualisation API enables users to
create powerful analysis tools which are easily accessible also to
non-data analysts. 

The Statistics Relating to Lloyd's site (http://www.lloyds.com/stats)
is an example which used the functions of the googleVis package to
create a data visualisation page. 
The page shows how interactive charts can be used to engage with users, 
allowing them to identify trends and insights over time.

For more information and examples visit the project web site:
http://code.google.com/p/google-motion-charts-with-r/

Please feel free to send us an email rvisualisat...@gmail.com
if you would like to be kept informed of new versions,
or if you have any feedback, ideas, suggestions or would
like to collaborate.

Markus Gesmann, Diego de Castillo

And now the NEWS:

Version 0.2.2 [2010-12-12]
==

Changes

   o Fixed typos in documentation

NEW FEATURES

  o New function:
- createGoogleGadget which allows users to create Google Gadgets XML output 


Version 0.2.1 [2010-11-30]
==

Changes

   o First version to be released on CRAN

NEW FEATURES

  o New function:
- gvisAnnotatedTimeLine to generate interactive annotated time line charts

Version 0.2.0 [2010-11-14]
==

Changes

  o The package has been renamed from GoogleMotionChart to googleVis to reflect 
a new more flexible implementation.
  o More functions of the Google Visualisation API are now available.

USER-VISIBLE CHANGES

  o New interfaces, all visualisation functions start with 'gvis'.
  o Output is now of class 'gvis' with generic print and plot
functions.
  o 'gvis' objects are list of lists, which allow the user to extract
the various parts of the visualisation output, e.g. the chart object.  

NEW FEATURES

  o New functions:
- gvisMotionChart to generate motion charts
- gvisGeoMap to generate geographical maps
- gvisMap to generate maps
- gvisTreeMap to generate tree maps
- gvisTable to generate table output
- print.gvis: generic function to print 'gvis' objects
- plot.gvis: generic function to display 'gvis' objects in a browser via 
the R.rsp package. 


[[alternative HTML version deleted]]

___
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] frestimate functionality

2010-12-14 Thread Jason Rupert
By any chance is there an R package that may contain functionality similar to 
the frestimate in Matlab/Simulink. 


Here is the URL for a description of the frestimate functionality:
http://www.mathworks.com/help/toolbox/slcontrol/ug/frestimate.html


Thank you again for any feedback.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 apitalize leading letters else of personal names?

2010-12-14 Thread RockO

Dear R world,

Do you know about a function that would capitalize in the correct manner
first and family names?
I found in the cwhmisc only the CapLeading function, but it just does not do
the job, taking care only to capitalize the first letter of a word.

I am looking for a function that would recognize  |'|Mc|- and capitalize
the first letter following these characters.

An example:
names-c(jean-francois st-john,helene o'donnel, joe mcintyre)

Desired result:

Jean-Francois St-John Helene O'Donnel Joe McIntyre

Thanks,

Rock


-- 
View this message in context: 
http://r.789695.n4.nabble.com/How-to-apitalize-leading-letters-else-of-personal-names-tp3088336p3088336.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] frestimate functionality

2010-12-14 Thread stephen sefick
Have you done a google search, looked on CRAN, searched the archives,
or looked at the task views?  I can't be of any help, but maybe one of
those places could be.
HTH,

Stephen

On Tue, Dec 14, 2010 at 7:57 PM, Jason Rupert jasonkrup...@yahoo.com wrote:
 By any chance is there an R package that may contain functionality similar to
 the frestimate in Matlab/Simulink.


 Here is the URL for a description of the frestimate functionality:
 http://www.mathworks.com/help/toolbox/slcontrol/ug/frestimate.html


 Thank you again for any feedback.

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

| Auburn University                                   |
| Department of Biological Sciences           |
| 331 Funchess Hall                                  |
| Auburn, Alabama                                   |
| 36849                                                    |
|___|
| sas0...@auburn.edu                             |
| http://www.auburn.edu/~sas0025             |
|___|

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

A big computer, a complex algorithm and a long time does not equal science.

                              -Robert Gentleman

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


Re: [R] Significance Help

2010-12-14 Thread Michael Bedward
Hello Samaire,

I don't know much about eyesight measurements (other than that my own
would probably be 0.1, 0.2) but I'll attempt some suggestions...

For objective (1) you will have to define what you mean by
significantly different. If you had data on left/right values from a
larger population to use as a standard you could then compare each
subject's left - right difference to the population.

For objective (2), it would be better if you had forced them to throw
the ball more than 3 times !

Anyway, something like this to start with...

glm( hoops ~ lr.diff, family=binomial )

where hoops is a two column matrix with number of successful throws in
col 1 and number of misses in col 2; lr.diff is absolute value of left
- right value.

Hope this helps.

Michael

On 15 December 2010 08:21, Samaire Holden samair...@hotmail.co.uk wrote:

 I have a set of results where I have the eyesight power of both left and 
 right eyes for each participant (e.g. 0.75, 0.5). Each participant then had 
 to throw basketballs into a hoop and the number of successful throws was 
 recorded.

 I would like to do two things:
 1. Test whether the eyesight power of the left and right eyes are 
 significantly different from each other.
 2. Test whether the number of successful throws is significantly affected by 
 eyesight power (i.e. is there a difference between those people who have 
 similar powers in left and right eyesight, to those who have significantly 
 different powers?)

 I know that I may not have explained this particularly well, but I'm totally 
 stumped as to where to start! I have only had basic lessons with R and now 
 have to do this report!

 Many thanks, Samaire
        [[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] selecting certain rows from data frame

2010-12-14 Thread Hrithik R
Hi, 
if I have a dataframe such that 

ID Time  Earn
1        1        10
1        2        50
1        3        68
2    1    40
2    2    78
24   88
3    1    50
3    2    60
3    3    98
4    1    33
4    2    48
44   58
.

.

Now if I have to select the all the rows from the data frame which does not 
include rows with certain IDs, say for example (prime) ID == 2  3, how do I do 
it 


Thanks

Rith


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