[R] Conjoint Analysis in R??

2007-12-06 Thread faisal afzal siddiqui
Pls advise how I can use R in conjoint analysis??

regds
Faisal Afzal Siddiqui
Karachi, Pakistan


  

Looking for last minute shopping deals?

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

2007-12-06 Thread Christian Ritz
Dear Simone,

you can use the package 'drc' to fit a logistic model, that is a non-linear 
regression 
model based on the equation c+(d-c)/(1+exp(b(x-e))), to your data (below named 
'simone'):


## Fitting a 4-parameter logistic model (also called Boltzmann model)
simone.m1 - drm(size~x, data=simone, fct=B.4())

## Plotting the data together with the fitted curve
plot(simone.m1, log=)


The fit is not great due to the bend.


Christian

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


Re: [R] correlation coefficient from qq plot

2007-12-06 Thread Domenico Vistocco
You could use the qqnorm function to obtain the correlation, as:

  qqp=qqnorm(rstudent(regrname))
  cor(qqp$x,qqp$y)

If you do not want see the plot (as the qq.plot is richer):
  qqp=qqnorm(rstudent(regrname), plot.it=F)

domenico vistocco

Tom Fitzhugh wrote:
 Hi,
  
 I am trying to figure out how to get the correlation coefficient for a
 QQ plot (residual plot).  So to be more precise, I am creating the plot
 like this:
  
 qq.plot(rstudent(regrname), main = rformula, col=1) 
  
 But want to also access (or compute) the correlation coefficient for
 that plot.
  
 Thanks,  
  
 Tom

   [[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] R CMD Build feature searches or requests

2007-12-06 Thread Johannes Graumann
Hello,

I'm missing two features in R CMD build:
1) Easy building of Windows/zip packaged package version alongside the
*nix-style *.tar.gz.
Right now I'm doing a scripted version of 
R CMD build PACKAGE
R CMD INSTALL PACKAGE
mkdir tmp
cp -r /usr/local/lib/R/site-library/PACKAGE tmp/PACKAGE
cd tmp
zip -r PACKAGE_EXTRACTEDVERSION.zip PACKAGE 
mv *.zip ..
cd ..
rm -rf tmp
I was wondering whether it wouldn't be helpfull to others maintaining
packages not requiring genuine cross-compilation (only containing R code)
to deal with this via an option to R CMD build. Something
like '-zip-package' might do it ...
2) My scripted solution right now also automatically increments version
numbers and adjusts dates in PACKAGE/man/PACKAGE-package.Rd and
PACKAGE/DESCRIPTION, ensuring progressing and continuous package naming.
Would be nice to have an R CMD build-option to take care of that too ...

Please let me know what you think or where to find the functionality in case
I overlooked it.

Thanks, Joh

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


Re: [R] Using panel.densityplot with stripplot

2007-12-06 Thread Christopher Oezbek
Hi Deepayan!
   thank you! panel.violin with the following modification works as I want:

grid.polyline(x = dx.list[[i]], y = dy.list[[i]], ...

instead of

grid.polygon(x = c(dx.list[[i]], rev(dx.list[[i]])),
 y = c(dy.list[[i]], -rev(dy.list[[i]])), ...

  From examples I would have thought I would need to do...

 What examples?

The examples for writing your own panel functions. I was not aware that  
there were different expectations regarding arguments.

 panel.stripplot and panel.densityplot have entirely
 different expectations about what the y-range of the panel is going to
 be, and they cannot be mixed.

But is there a technical reason for making this distinction? It seemed to  
me that most panel functions can deal with x and y parameters and that  
panel.densityplot could make use of the same mechanisms as panel.violin to  
subdivide based on factor y.

Again many thanks for the fast response,
   Christopher

-- 
Christopher Oezbek
Arbeitsgruppe Software Engineering
Institut für Informatik
Freie Universität Berlin
Takustr. 9, 14195 Berlin, Germany
+49 30 838 75242, Raum 008
http://www.inf.fu-berlin.de/~oezbek/

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


Re: [R] Using expression in Hmisc Key()

2007-12-06 Thread Michael Kubovy
Hi Dieter,

I actually solved *my* problem:

Key(x = 0.667, y = 0.833, lev = c(expression(italic(b)),  
expression(italic(c)), expression(italic(d))),
other = list(title = expression(italic(v)), cex.title = 1))

I was able to figure this out only by looking at the code for Key(),  
because I hadn't come across the 'lev' argument in the documentation  
(in fact Key does not appear in the list of functions of Hmisc; I  
discovered its usefulness by consulting the examples for xYplot()). I  
would have expected this argument to be called 'labels' (see  
help(labels)), (or at least 'levels'):

function (x = NULL, y = NULL, lev = c(b, c, d), cex = c(0.7,  
0.7, 0.7), col = c(2, 4, 9), font = c(1, 1, 1), pch = c(1, 2, 16),  
other = NULL)
{
…
}
…

Note that the NULL setting of the parameter may be useful for  
programming, but it is not useful to anyone reading the code. How is  
one to proceed after having read help(NULL)?

At the same time, I have no grounds for complaining about the  
documentation for Key(): Frank Harrell is giving away his work. His  
examples are extensive, and his functions always work as advertised.  
Sometimes they also work as not advertised.

This is one of the cases where I wish there were a function that  
exercised all the arguments of a graphics function by visualizing  
the effect of changing  two or three levels of each argument (one by  
one, of course). This might have the side effect of allowing authors  
to shorten documentation. I have in mind adding a method to each  
graphics function, and having the author specify the two or three  
instructive levels of each argument. See the exhaustive exploration by  
J.R. Lobry, A.B. Dufour  D. Chessel of the graphical parameters  
accessible by par(), at
http://pbil.univ-lyon1.fr/R/fichestd/tdr75.pdf

On Dec 6, 2007, at 2:17 AM, Dieter Menne wrote:

 Michael Kubovy kubovy at virginia.edu writes:


 Dear r-helpers,

 How do I tell xYplot() and Key() that I want the labels in italic?

 
 Key(x = 0.667, y = 0.833, other = list(title = expression(italic(v)),
 cex.title = 1,
  labels = c(expression(italic(b)), expression(italic(c)),
 expression(italic(d)
 dev.off()

 Michael,

 I have submit a similar case last week to the Bug tracker. Maybe you  
 can raise
 that enhancement request to defect

 http://biostat.mc.vanderbilt.edu/trac/Hmisc/ticket/21

 Dieter

 ---
 The Key function generated by some plot commands should have a ...  
 parameter.
 Otherwise, the ... in rlegend is useless, and it would be nice to be  
 able to
 suppress the box, for example.

 Key = function (x = NULL, y = NULL, lev = c(No Fail, Fail), pch  
 = c(16, 1))
 { .. part omitted

rlegend(x, y, legend = lev, pch = pch, ...) invisible()

 }

_
Professor Michael Kubovy
University of Virginia
Department of Psychology
USPS: P.O.Box 400400Charlottesville, VA 22904-4400
Parcels:Room 102Gilmer Hall
 McCormick RoadCharlottesville, VA 22903
Office:B011+1-434-982-4729
Lab:B019+1-434-982-4751
Fax:+1-434-982-4766
WWW:http://www.people.virginia.edu/~mk9y/

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

2007-12-06 Thread Petr PIKAL
Dear all

I tried to make a biplot with color coded labels but I was not successful. 
Searching archives I found that it is probably not so simple.
I found
http://tolstoy.newcastle.edu.au/R/help/05/01/10661.html

which recommends eqscplot

eqscplot(fit$score[,1], fit$score[,2], pch = 20, col=c(rep(2,10), 
rep(3,40)), cex=2)

http://tolstoy.newcastle.edu.au/R/help/05/01/10661.html

or I can use plot itself, but then I was not able to find how to add 
arrows.

The closest I get is

fit-(princomp(USArrests, cor = TRUE))
biplot(fit , xlabs=rep(, 50))
points(fit$score[,1], fit$score[,2], pch = 20, col=c(rep(2,10), 
rep(3,40)), cex=2)

and use some suitable scaling before calling points. 

My question is if there is some other easier approach to get color coded 
points in biplot?

Petr Pikal
[EMAIL PROTECTED]

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


Re: [R] Segmented regression

2007-12-06 Thread vito muggeo
Dear Brendan,
I am not sure to understand your code..

It seems to me that your are interested in fitting a one-breakpoint 
segmented relationship in each level of your grouping variable

If this is the case, the correct code is below.
In order to fit a segmented relationship in each group you have to 
define the relevant variable before fitting, and to constrain the last 
slope to be zero you have to consider the `minus' variable..(I discuss 
these points in the submitted Rnews article..If you are interested, let 
me know off list).

If my code does not fix your problem, please let me know,

Best,
vito

##--define the group-specific segmented variable:
X-model.matrix(~0+factor(group),data=df)*df$tt
df$tt.KV-X[,1] #KV
df$tt.KW-X[,2]   #KW
df$tt.WC-X[,3]   #WC

##-fit the unconstrained model
olm-lm(y~group+tt.KV+tt.KW+tt.WC,data=df)
os-segmented(olm,seg.Z=~tt.KV+tt.KW+tt.WC,psi=list(tt.KV=350, 
tt.KW=500, tt.WC=350))
#have a look to results:
with(df,plot(tt,y))
with(subset(df,group==RKW),points(tt,y,col=2))
with(subset(df,group==RKV),points(tt,y,col=3))
points(df$tt[df$group==RWC],fitted(os)[df$group==RWC],pch=20)
points(df$tt[df$group==RKW],fitted(os)[df$group==RKW],pch=20,col=2)
points(df$tt[df$group==RKV],fitted(os)[df$group==RKV],pch=20,col=3)


#constrain the last slope in group KW
tt.KW.minus- -df$tt.KW
olm1-lm(y~group+tt.KV+tt.WC,data=df)
os1-segmented(olm1,seg.Z=~tt.KV+tt.KW.minus+tt.WC,psi=list(tt.KV=350, 
tt.KW.minus=-500, tt.WC=350))
#check..:-)
slope(os1)

with(df,plot(tt,y))
with(subset(df,group==RKW),points(tt,y,col=2))
with(subset(df,group==RKV),points(tt,y,col=3))
points(df$tt[df$group==RWC],fitted(os1)[df$group==RWC],pch=20)
points(df$tt[df$group==RKW],fitted(os1)[df$group==RKW],pch=20,col=2)
points(df$tt[df$group==RKV],fitted(os1)[df$group==RKV],pch=20,col=3)






Power, Brendan D (Toowoomba) ha scritto:
 Hello all,
 
 I have 3 time series (tt) that I've fitted segmented regression models
 to, with 3 breakpoints that are common to all, using code below
 (requires segmented package). However I wish to specifiy a zero
 coefficient, a priori, for the last segment of the KW series (green)
 only. Is this possible to do with segmented? If not, could someone point
 in a direction?
 
 The final goal is to compare breakpoint sets for differences from those
 derived from other data.
 
 Thanks in advance,
 
 Brendan.
 
 
 library(segmented)
 df-data.frame(y=c(0.12,0.12,0.11,0.19,0.27,0.28,0.35,0.38,0.46,0.51,0.5
 8,0.59,0.60,0.57,0.64,0.68,0.72,0.73,0.78,0.84,0.85,0.83,0.86,0.88,0.88,
 0.95,0.95,0.93,0.92,0.97,0.86,1.00,0.85,0.97,0.90,1.02,0.95,0.54,0.53,0.
 50,0.60,0.70,0.74,0.78,0.82,0.88,0.83,1.00,0.85,0.96,0.84,0.86,0.82,0.86
 ,0.84,0.84,0.84,0.77,0.69,0.61,0.67,0.73,0.65,0.55,0.58,0.56,0.60,0.50,0
 .50,0.42,0.43,0.44,0.42,0.40,0.51,0.60,0.63,0.71,0.74,0.82,0.82,0.85,0.8
 9,0.91,0.87,0.91,0.93,0.95,0.95,0.97,1.00,0.96,0.90,0.86,0.91,0.94,0.96,
 0.88,0.88,0.88,0.92,0.82,0.85),
  
 tt=c(141.6,141.6,141.6,183.2,212.8,227.0,242.4,271.5,297.4,312.3,331.4,3
 42.4,346.3,356.6,371.6,408.8,408.8,419.5,434.4,464.5,492.6,521.7,550.5,5
 50.3,565.4,588.0,602.9,623.7,639.6,647.9,672.6,680.6,709.7,709.7,750.2,7
 50.2,750.2,141.6,141.6,141.6,183.2,212.8,227.0,242.4,271.5,297.4,312.3,3
 31.4,342.4,346.3,356.6,371.6,408.8,408.8,419.5,434.4,464.5,492.6,521.7,5
 50.5,550.3,565.4,588.0,602.9,623.7,639.6,647.9,672.6,680.6,709.7,709.7,1
 41.6,141.6,141.6,183.2,212.8,227.0,242.4,271.5,297.4,312.3,331.4,342.4,3
 46.3,356.6,371.6,408.8,408.8,419.5,434.4,464.5,492.6,521.7,550.5,550.3,5
 65.4,588.0,602.9,623.7,639.6,647.9,672.6,709.7),
group=c(rep(RKW,37),rep(RWC,34),rep(RKV,32)))
 init.bp - c(297.4,639.6,680.6)
 lm.1 - lm(y~tt+group,data=df)
 seg.1 - segmented(lm.1, seg.Z=~tt, psi=list(tt=init.bp))
 
  version
_   
 platform   i386-pc-mingw32 
 arch   i386
 os mingw32 
 system i386, mingw32   
 status 
 major  2   
 minor  6.0 
 year   2007
 month  10  
 day03  
 svn rev43063   
 language   R   
 version.string R version 2.6.0 (2007-10-03)
 
 
 
 DISCLAIMER**...{{dropped:15}}
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 

Vito M.R. Muggeo
Dip.to Sc Statist e Matem `Vianelli'
Università di Palermo
viale delle Scienze, edificio 13
90128 Palermo - ITALY
tel: 091 6626240
fax: 091 485726/485612


[R] Building package - tab delimited example data issue

2007-12-06 Thread Johannes Graumann
Hello,

I'm trying to integrate example data in the shape of a tab delimited ASCII
file into my package and therefore dropped it into the data subdirectory.
The build works out just fine, but when I attempt to install I get:

** building package indices ...
Error in scan(file, what, nmax, sep, dec, quote, skip, nlines,
na.strings,  :
  line 1 did not have 500 elements
Calls: Anonymous ... Anonymous - switch - assign - read.table - scan
Execution halted
ERROR: installing package indices failed
** Removing '/usr/local/lib/R/site-library/MaxQuantUtils'
** Restoring previous '/usr/local/lib/R/site-library/MaxQuantUtils'

Accordingly the check delivers:

...
* checking whether package 'MaxQuantUtils' can be installed ... ERROR

Can anyone tell me what I'm doing wrong? build/install witout the ASCII file
works just fine.

Joh

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


Re: [R] Conjoint Analysis in R??

2007-12-06 Thread Domenico Vistocco
http://tolstoy.newcastle.edu.au/R/help/05/06/6104.html
http://tolstoy.newcastle.edu.au/R/help/05/06/6103.html

domenico

faisal afzal siddiqui wrote:
 Pls advise how I can use R in conjoint analysis??

 regds
 Faisal Afzal Siddiqui
 Karachi, Pakistan


   
 
 Looking for last minute shopping deals?

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

2007-12-06 Thread paulandpen
Faisal,

can you elaborate further on your conjoint design

there is bayesm which offers a hierarchical bayes approach to analysing 
choice data

MLogit available through zelig (see below)

http://gking.harvard.edu/zelig/docs/index.html

MNP as a standalone package for the probit model

thanks Paul


- Original Message - 
From: faisal afzal siddiqui [EMAIL PROTECTED]
To: R Help [EMAIL PROTECTED]
Sent: Thursday, December 06, 2007 6:00 PM
Subject: [R] Conjoint Analysis in R??


 Pls advise how I can use R in conjoint analysis??

 regds
 Faisal Afzal Siddiqui
 Karachi, Pakistan


 
 
 Looking for last minute shopping deals?

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Building package - tab delimited example data issue

2007-12-06 Thread Peter Dalgaard
Johannes Graumann wrote:
 Hello,

 I'm trying to integrate example data in the shape of a tab delimited ASCII
 file into my package and therefore dropped it into the data subdirectory.
 The build works out just fine, but when I attempt to install I get:

 ** building package indices ...
 Error in scan(file, what, nmax, sep, dec, quote, skip, nlines,
 na.strings,  :
   line 1 did not have 500 elements
 Calls: Anonymous ... Anonymous - switch - assign - read.table - scan
 Execution halted
 ERROR: installing package indices failed
 ** Removing '/usr/local/lib/R/site-library/MaxQuantUtils'
 ** Restoring previous '/usr/local/lib/R/site-library/MaxQuantUtils'

 Accordingly the check delivers:

 ...
 * checking whether package 'MaxQuantUtils' can be installed ... ERROR

 Can anyone tell me what I'm doing wrong? build/install witout the ASCII file
 works just fine.

 Joh

   
If you had looked at help(data), you would have found a list of which
file formats it supports and how they are read. Hint: TAB-delimited
files are not among them. *Whitespace* separated files work, using
read.table(filename, header=TRUE), but that is not a superset of
TAB-delimited data if there are empty fields.

A nice trick is to figure out how to read the data from the command line
and drop the relevant code into a mydata.R file (assuming that the
actual data file is mydata.txt). This gets executed when the data is
loaded (by data(mydata) or when building the lazyload database) because
.R files have priority over .txt.

This is quite general and allows a nice way of incorporating data
management while retaining the original data source:

more ISwR/data/stroke.R

stroke -  read.csv2(stroke.csv, na.strings=.)
names(stroke) - tolower(names(stroke))
stroke -  within(stroke,{
sex - factor(sex,levels=0:1,labels=c(Female,Male))
dgn - factor(dgn)
coma - factor(coma, levels=0:1, labels=c(No,Yes))
minf - factor(minf, levels=0:1, labels=c(No,Yes))
diab - factor(diab, levels=0:1, labels=c(No,Yes))
han - factor(han, levels=0:1, labels=c(No,Yes))
died - as.Date(died, format=%d.%m.%Y)
dstr - as.Date(dstr,format=%d.%m.%Y)
dead - !is.na(died)  died  as.Date(1996-01-01)
died[!dead] - NA
})

head ISwR/data/stroke.csv

SEX;DIED;DSTR;AGE;DGN;COMA;DIAB;MINF;HAN
1;7.01.1991;2.01.1991;76;INF;0;0;1;0
1;.;3.01.1991;58;INF;0;0;0;0
1;2.06.1991;8.01.1991;74;INF;0;0;1;1
0;13.01.1991;11.01.1991;77;ICH;0;1;0;1
0;23.01.1996;13.01.1991;76;INF;0;1;0;1
1;13.01.1991;13.01.1991;48;ICH;1;0;0;1
0;1.12.1993;14.01.1991;81;INF;0;0;0;1
1;12.12.1991;14.01.1991;53;INF;0;0;1;1
0;.;15.01.1991;73;ID;0;0;0;1



-- 
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

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


Re: [R] R function for percentrank

2007-12-06 Thread Martin Maechler
 MS == Marc Schwartz [EMAIL PROTECTED]
 on Wed, 05 Dec 2007 12:43:50 -0600 writes:

[]

MS Martin,

MS Thanks for the corrections. In hindsight, now seeing the intended use of
MS ecdf() in the fashion you describe above, it is now clear that my
MS approach in response to David's query was un-needed and over the top.
MS Yuck is quite appropriate... :-)

MS As I was going through this exercise, it did seem overly complicated,
MS given R's usual elegant philosophy about such things. I suppose if I had
MS looked at the source for plot.stepfun(), it would have been more evident
MS as to how the y values are acquired.

MS In reviewing the examples in ?ecdf, I think that an example using
MS something along the lines of the discussion here more explicitly, would
MS be helpful. It is not crystal clear from the examples, that one can use
MS ecdf() in this fashion, though the use of 12 * Fn(tt) hints at it.

MS Perhaps:

MS ##-- Simple didactical  ecdf  example:
MS x - rnorm(12)
MS Fn - ecdf(x)
MS Fn
MS Fn(x)  # returns the percentiles for x
MS ...

Thank you, Marc for the above proposal, to make the examples
more crystal clear :-) 
I've now amended the R-devel version of  help(ecdf) accordingly.

MS Thanks again Martin and no offense taken...  :-)

I'm glad. You're welcome!
Martin

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


Re: [R] Building package - tab delimited example data issue

2007-12-06 Thread Berwin A Turlach
G'day Peter,

On Thu, 06 Dec 2007 11:52:46 +0100
Peter Dalgaard [EMAIL PROTECTED] wrote:
  
 If you had looked at help(data), you would have found a list of which
 file formats it supports and how they are read. Hint: TAB-delimited
 files are not among them. [...]

On the other hand, Writing R Extensions has stated since a long time
(and still does):

The @file{data} subdirectory is for additional data files the package
makes available for loading using @code{data()}.  Currently, data files
can have one of three types as indicated by their extension: plain R
code (@file{.R} or @file{.r}), tables (@file{.tab}, @file{.txt}, or
@file{.csv}), or @code{save()} images (@file{.RData} or @file{.rda}).

Now in my book, .csv files contain comma separated values, .tab files
contain values separated by TABs and .txt files are pure text files,
presumably values separated by any kind of white space. 

Thus, I think that the expectation that TAB-delimited file formats
should work is not unreasonable; I was long time ago bitten by this
too. Then I realised that the phrase one of the three types should
probably be interpreted as implying that .tab, .txt and .csv files are
all of the same type and, apparently, should contain values separated
by whitespace.  I admit that I never tested whether .csv files would
lead to the same problems as TAB delimited .tab files. Rather, I decided
in the end that the safest option, i.e. to avoid misleading file
extensions, would be to use .rda files in the future.

Cheers,

Berwin

=== Full address =
Berwin A TurlachTel.: +65 6515 4416 (secr)
Dept of Statistics and Applied Probability+65 6515 6650 (self)
Faculty of Science  FAX : +65 6872 3919   
National University of Singapore 
6 Science Drive 2, Blk S16, Level 7  e-mail: [EMAIL PROTECTED]
Singapore 117546http://www.stat.nus.edu.sg/~statba

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

2007-12-06 Thread Domenico Vistocco
If you are using correspondence analysis you could see the plot.ca 
function in the ca library.

Petr PIKAL wrote:
 Dear all

 I tried to make a biplot with color coded labels but I was not successful. 
 Searching archives I found that it is probably not so simple.
 I found
 http://tolstoy.newcastle.edu.au/R/help/05/01/10661.html

 which recommends eqscplot

 eqscplot(fit$score[,1], fit$score[,2], pch = 20, col=c(rep(2,10), 
 rep(3,40)), cex=2)

 http://tolstoy.newcastle.edu.au/R/help/05/01/10661.html

 or I can use plot itself, but then I was not able to find how to add 
 arrows.

 The closest I get is

 fit-(princomp(USArrests, cor = TRUE))
 biplot(fit , xlabs=rep(, 50))
 points(fit$score[,1], fit$score[,2], pch = 20, col=c(rep(2,10), 
 rep(3,40)), cex=2)

 and use some suitable scaling before calling points. 

 My question is if there is some other easier approach to get color coded 
 points in biplot?

 Petr Pikal
 [EMAIL PROTECTED]

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

2007-12-06 Thread Simone Gabbriellini
Dear Christian,

it works great, and it is simple to understand, thank you very much.

just a detail, is it possible to plot just the fitted curve and not  
the data? it's because I would like to have data in black and the  
fitted curve in red.. I don't know how to pick up the single parts, if  
I simply wrote

 plot(simone.m1, log=, col=red)

everything became red..

thank in advance,
Simone


Il giorno 06/dic/07, alle ore 09:00, Christian Ritz ha scritto:

 Dear Simone,

 you can use the package 'drc' to fit a logistic model, that is a non- 
 linear regression model based on the equation c+(d-c)/(1+exp(b(x- 
 e))), to your data (below named 'simone'):


 ## Fitting a 4-parameter logistic model (also called Boltzmann model)
 simone.m1 - drm(size~x, data=simone, fct=B.4())

 ## Plotting the data together with the fitted curve
 plot(simone.m1, log=)


 The fit is not great due to the bend.


 Christian


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

2007-12-06 Thread Simone Gabbriellini
Dear Christian,

it works great, and it is simple to understand, thank you very much.

just a detail, is it possible to plot just the fitted curve and not  
the data? it's because I would like to have data in black and the  
fitted curve in red.. I don't know how to pick up the single parts, if  
I simply wrote

 plot(simone.m1, log=, col=red)

everything became red..

thank in advance,
Simone


Il giorno 06/dic/07, alle ore 09:00, Christian Ritz ha scritto:

 Dear Simone,

 you can use the package 'drc' to fit a logistic model, that is a non- 
 linear regression model based on the equation c+(d-c)/(1+exp(b(x- 
 e))), to your data (below named 'simone'):


 ## Fitting a 4-parameter logistic model (also called Boltzmann model)
 simone.m1 - drm(size~x, data=simone, fct=B.4())

 ## Plotting the data together with the fitted curve
 plot(simone.m1, log=)


 The fit is not great due to the bend.


 Christian


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] $ operator is invalid for atomic vectors, returning NULL - what is the right thing to do then?

2007-12-06 Thread Søren Højsgaard
Dear all,
Starting from a recent version of R, the $ became unusable on atomic vectors, 
e.g.
 x - c(a=1,b=2)
 x$a
NULL
Warning message:
In x$a : $ operator is invalid for atomic vectors, returning NULL
 
I can of course do
 x['a']
- but that requires more typing (5 characters rather than 2). 
 
Apologies if I've missed a an announcement regarding this, but
1) Is there an alternative to the ['a'] and
2) Why was this change made?
 
Regards
Søren
 

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Nine questions about methods and generics

2007-12-06 Thread Michael Dewey
I have a series of question about methods and generics.
The questions are interspersed in some text which explains
what I want to do, how it works now and why I do not
understand well why it works. Questions are written
Q1 and so on up to Q9 and always start a new line.

The concrete problem is this: it has become customary
after a meta-analysis to quote various statistics
to give a picture of the degree of heterogeneity.
Initially I wrote a function which calculated these given
the heterogeneity chi-squared Q and the number of studies k.
It then occurred to me that it would be convenient to
have functions which take the objects returned by
the various functions in the package rmeta (available
from CRAN) and perform the calculation on them.
So after plagiarising some ideas from rmeta
I wrote

hetero - function(x, ...) {
UseMethod(hetero)
}

Q1 - have I created a generic called hetero? If so
what is the correct idiom: created, declared, ...?
Q2 - if I go class(hetero) it returns function rather
than generic. Is that what I should expect?

I then called my original function hetero.default

hetero.default - function(Q = NULL, k = NULL, conflevel = 0.95) {
# some code left out here which computes values in the list res
class(res) - meta.hetero
res
}

Q3 was it a good idea to have it return an object of class
meta.hetero or would it have been better to call it hetero

now if I go
hetero(14.4, 24)
I get what I expected

I then provide a new function

hetero.meta.summaries - function(obj, ...) {
# some code to calculate Q and k
res - hetero.default(Q, k, ...)
res
}
which also seems to do what I wanted. There are also
similar functions hetero.meta.MH and hetero.meta.DSL
to operate on the other classes of object returned in rmeta.

The problem is that I do not really understand why it all works
and suspect it could easily stop working.

At this point I decided that if all else fails I should read the
documentation. The manual pages (the things you get
with ?UseMethod) describe what the functions do but
do not give me a series of steps to salvation.
I found S Programming (VR) much clearer now I knew where to
look but I think VR underestimate the depths of my
ignorance.

Q4 VR seems to suggest that I should have called the first
argument to hetero, hetero.default and hetero.meta.summaries
the same (possibly x or object) yet it seems to work.
Q5 Does it matter?
If it does matter which should I choose?

I also decide to look at R-extensions which seems
to suggest that I should be using NextMethod and
also has dire warnings about having different argument
lists to the various methods.
I found R-extensions much the least helpful
of the three sources I tried.

Q6 should I be using NextMethod?
Q7 if what I have created are methods which are
displayed by methods(hetero) why is it UseMethod not
usemethod? (I note that ?Methods tells me about something
different from ?methods.)
Q8 I have used a ... argument for hetero.meta.summaries
but not for hetero.default. Was that wise? R-extensions
has some stern things to say here which I do not really
understand.
Q9 is there somewhere else I could have looked
bearing in mind my comments above about the
manual pages, VR and R-extensions? Or shall
I just keep reading VR until the penny drops?

For the record:

S Programming (VR) means
@BOOK{venables00,
   author = {Venables, W N and Ripley, B D},
   year = 2000,
   title = {S programming},
   publisher = {Springer-Verlag},
   address = {New York},
   keywords = {statistics general; software}
}
The heterogeneity statistics are explained in
@ARTICLE{higgins02,
   author = {Higgins, J P T and Thompson, S G},
   year = 2002,
   title = {Quantifying heterogeneity in a meta--analysis},
   journal = {Statistics in Medicine},
   volume = 21,
   pages = {1539--1558},
   keywords = {meta-analysis, heterogeneity}
}

I am using 2.6.1 under XP Professional.
My knowledge of computer science is frozen at about 1975.



Michael Dewey
http://www.aghmed.fsnet.co.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] $ operator is invalid for atomic vectors, returning NULL - what is the right thing to do then?

2007-12-06 Thread Prof Brian Ripley

On Thu, 6 Dec 2007, Søren Højsgaard wrote:


Dear all,
Starting from a recent version of R,



From R 2.5.0, not so recent.



the $ became unusable on atomic vectors, e.g.

x - c(a=1,b=2)
x$a

NULL
Warning message:
In x$a : $ operator is invalid for atomic vectors, returning NULL
I can of course do

x['a']

- but that requires more typing (5 characters rather than 2).

Apologies if I've missed a an announcement regarding this, but
1) Is there an alternative to the ['a'] and
2) Why was this change made?


It has always returned NULL on atomic vectors: see the help page.
E.g. in R 2.0.0 from 2004:


x - c(a=1,b=2)
x$a

NULL

x['a']

a
1

The warning was added three versions of R ago: the announcement is in the 
NEWS file for 2.5.0.


USER-VISIBLE CHANGES

o   Using $ on an atomic vector now raises a warning, as does use
on an S4 class for which a method has not been defined.

I think you have exemplified the answer to your question '2)': because 
users misunderstood what it did.


In R 2.7.0 this will be an error, since package programmers did not seem 
to be heeding the warnings.


--
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] R function for percentrank

2007-12-06 Thread Gabor Grothendieck
On Dec 6, 2007 6:11 AM, Martin Maechler [EMAIL PROTECTED] wrote:
  MS == Marc Schwartz [EMAIL PROTECTED]
  on Wed, 05 Dec 2007 12:43:50 -0600 writes:

 []

MS Martin,

MS Thanks for the corrections. In hindsight, now seeing the intended use 
 of
MS ecdf() in the fashion you describe above, it is now clear that my
MS approach in response to David's query was un-needed and over the top.
MS Yuck is quite appropriate... :-)

MS As I was going through this exercise, it did seem overly complicated,
MS given R's usual elegant philosophy about such things. I suppose if I 
 had
MS looked at the source for plot.stepfun(), it would have been more 
 evident
MS as to how the y values are acquired.

MS In reviewing the examples in ?ecdf, I think that an example using
MS something along the lines of the discussion here more explicitly, would
MS be helpful. It is not crystal clear from the examples, that one can use
MS ecdf() in this fashion, though the use of 12 * Fn(tt) hints at it.

MS Perhaps:

MS ##-- Simple didactical  ecdf  example:
MS x - rnorm(12)
MS Fn - ecdf(x)
MS Fn
MS Fn(x)  # returns the percentiles for x
MS ...

 Thank you, Marc for the above proposal, to make the examples
 more crystal clear :-)
 I've now amended the R-devel version of  help(ecdf) accordingly.

Since the above does not actually reproduce percentrank in the case
of ties, the change that would facilitate this particularly would be to add
a ties = excelpercentrank to approx.  See my solution earlier in this
thread.

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


Re: [R] $ operator is invalid for atomic vectors, returning NULL

2007-12-06 Thread Ted Harding
On 06-Dec-07 12:04:56, Søren Højsgaard wrote:
 Dear all,
 Starting from a recent version of R, the $ became unusable
 on atomic vectors, e.g.
 x - c(a=1,b=2)
 x$a
 NULL
 Warning message:
 In x$a : $ operator is invalid for atomic vectors, returning NULL
  
 I can of course do
 x['a']
 - but that requires more typing (5 characters rather than 2). 
  
 Apologies if I've missed a an announcement regarding this, but
 1) Is there an alternative to the ['a'] and
 2) Why was this change made?

While Brian has answered your query from a more technical
point of view, there's an implication you should consider.

x$a always (as far as I know)[*] has been unusable, in that
it returns NULL, and not what you expected to get. The only
thing that's (relatively) new is that you now get a warning.

[*] Certainly as early as R-1.6.2 (Jan 2003), as I've just checked.

Previously, you were not getting a warning.

So, if you were using the likes of x$a in code, and getting
no warnings, possibly your code was generating results
derived from NULL values rather than from the values you
expected it to be using. Perhaps you should check back!

Best wishes,
Ted.


E-Mail: (Ted Harding) [EMAIL PROTECTED]
Fax-to-email: +44 (0)870 094 0861
Date: 06-Dec-07   Time: 12:39:49
-- XFMail --

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


Re: [R] Building package - tab delimited example data issue

2007-12-06 Thread Peter Dalgaard
Berwin A Turlach wrote:
 G'day Peter,

 On Thu, 06 Dec 2007 11:52:46 +0100
 Peter Dalgaard [EMAIL PROTECTED] wrote:
   
   
 If you had looked at help(data), you would have found a list of which
 file formats it supports and how they are read. Hint: TAB-delimited
 files are not among them. [...]
 

 On the other hand, Writing R Extensions has stated since a long time
 (and still does):

 The @file{data} subdirectory is for additional data files the package
 makes available for loading using @code{data()}.  Currently, data files
 can have one of three types as indicated by their extension: plain R
 code (@file{.R} or @file{.r}), tables (@file{.tab}, @file{.txt}, or
 @file{.csv}), or @code{save()} images (@file{.RData} or @file{.rda}).

 Now in my book, .csv files contain comma separated values, .tab files
 contain values separated by TABs and .txt files are pure text files,
 presumably values separated by any kind of white space. 

 Thus, I think that the expectation that TAB-delimited file formats
 should work is not unreasonable; I was long time ago bitten by this
 too. Then I realised that the phrase one of the three types should
 probably be interpreted as implying that .tab, .txt and .csv files are
 all of the same type and, apparently, should contain values separated
 by whitespace.  I admit that I never tested whether .csv files would
 lead to the same problems as TAB delimited .tab files. Rather, I decided
 in the end that the safest option, i.e. to avoid misleading file
 extensions, would be to use .rda files in the future.

   
Now had you lived in the Western world ... (Hey, what's that? New
address!) ... then you would have known better than to have any trust in
file extensions. At the time they apparently figured that the .CSV
standard was so good that it was even better to have two of them (double
standards are twice as good, right?), depending on whether you were in
England or in Denmark, I lost faith completely. (In this country you can
export to a text file with SAS and then NOT read it with SPSS and vice
versa on the same Windows machine).

Actually, R is a bit perverse about .csv too since it expects
_semicolon_  field separator, but not the  comma decimal separator which
usually accompanies it. The reason for this is lost in the mists of time
-- the datasets in current versions of R do not include any .csv files.
There are, however, six .tab files, three of which are not
tab-separated, but I don't actually think there was ever a standard to
the effect that they should be (.tab just means that it is a _table_).

So, you really need to read the help page for data, which does have the 
exact info. The passage you cite from the manual could do with a
rephrasing, although it probably isn't technically incorrect. As it
stands, it reminds me a bit of the old Monty Python sketch:

Our *three* weapons are fear, surprise, and ruthless efficiency...and
an almost fanatical devotion to the Pope Our *four*...no...
*Amongst* our weapons Amongst our weaponry...are such elements as
fear, surprise I'll come in again

(There really are 3 data TYPES, but 4 FORMATS and, er, diverse EXTENSIONS)



--  
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

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


[R] differences in using source() or console

2007-12-06 Thread vito muggeo
Dear all,
Is there *any* reason explaining what I describe below?
I have the following line

myfun(x)

If I type them directly in R (or copy/past), it works..

However if I type in R 2.6.1

  source(code.R) ##code.R includes the above line
Error in inherits(x, data.frame) : object d not found

namely myfun() does not work correctly.
In particular the non-working line inside myfun() is

update(eval(x$call$obj), data=d) #d is created in myfun()

My question is: why the problem occurs just via source()ing???

many thanks,
vito



Vito M.R. Muggeo
Dip.to Sc Statist e Matem `Vianelli'
Università di Palermo
viale delle Scienze, edificio 13
90128 Palermo - ITALY
tel: 091 6626240
fax: 091 485726/485612

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] R2HTML how to pair graphic.png and table

2007-12-06 Thread Roberto Iacopetti

Dear list,
i have this problem:
how to pair a graphic.png and a table in R2HTML ?

The better showing of a mutiple analysis is sometimes to mate graphic and
table

Can anyone help me in this task ??

In the example below graphisc and table are subsequent and not pair..
 

directory=getwd()
myfile-file.path(directory,testHTML.html)
HTMLoutput=file.path(directory,testHTML.html)
graf=graf.png
png(file.path(directory,graf))
plot(c(1:12))
dev.off()
tab-as.matrix(c(1:12))
HTMLInsertGraph(graf,tab,file=HTMLoutput,caption=Esempio di grafico)
browseURL(myfile)

Thanks in advance

Roberto Iacopetti

-- 
View this message in context: 
http://www.nabble.com/R2HTML--how-to-pair-graphic.png-and-table-tf4956321.html#a14193218
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] 64-bit R question in Leopard

2007-12-06 Thread 정 태훈
Hi, All;

I've compiled and installed successfully presumably 64-bit R on  
Leopard.
But when I tried to run R, I got the following error:

/usr/bin/R: line 179: /Library/Frameworks/R.framework/Resources/etc/ 
i386/ldpaths: No such file or directory

Here is the configuration I used:

CONFIG_SHELL=/bin/bash ../R-devel/configure r_arch=x86_64 LDFLAGS=-L/ 
usr/local/lib64 -L/usr/X11R6/lib CC='gcc-4.2 -g -O3' CXX='g++-4.2 -g - 
O3' F77='gfortran -g -O3' FC='gfortran -g -O3' --with-blas='-framework  
vecLib' --with-lapack

Thanks in advance

Tae-Hoon Chung

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


Re: [R] Building package - tab delimited example data issue

2007-12-06 Thread Johannes Graumann
Johannes Graumann wrote:

 On Thursday 06 December 2007 11:52:46 Peter Dalgaard wrote:
 Johannes Graumann wrote:
  Hello,
 
  I'm trying to integrate example data in the shape of a tab delimited
  ASCII file into my package and therefore dropped it into the data
  subdirectory. The build works out just fine, but when I attempt to
  install I get:
 
  ** building package indices ...
  Error in scan(file, what, nmax, sep, dec, quote, skip, nlines,
  na.strings,  :
line 1 did not have 500 elements
  Calls: Anonymous ... Anonymous - switch - assign - read.table -
  scan Execution halted
  ERROR: installing package indices failed
  ** Removing '/usr/local/lib/R/site-library/MaxQuantUtils'
  ** Restoring previous '/usr/local/lib/R/site-library/MaxQuantUtils'
 
  Accordingly the check delivers:
 
  ...
  * checking whether package 'MaxQuantUtils' can be installed ... ERROR
 
  Can anyone tell me what I'm doing wrong? build/install witout the ASCII
  file works just fine.
 
  Joh

 If you had looked at help(data), you would have found a list of which
 file formats it supports and how they are read. Hint: TAB-delimited
 files are not among them. *Whitespace* separated files work, using
 read.table(filename, header=TRUE), but that is not a superset of
 TAB-delimited data if there are empty fields.

 A nice trick is to figure out how to read the data from the command line
 and drop the relevant code into a mydata.R file (assuming that the
 actual data file is mydata.txt). This gets executed when the data is
 loaded (by data(mydata) or when building the lazyload database) because
 .R files have priority over .txt.

 This is quite general and allows a nice way of incorporating data

 management while retaining the original data source:
 more ISwR/data/stroke.R

 stroke -  read.csv2(stroke.csv, na.strings=.)
 names(stroke) - tolower(names(stroke))
 stroke -  within(stroke,{
 sex - factor(sex,levels=0:1,labels=c(Female,Male))
 dgn - factor(dgn)
 coma - factor(coma, levels=0:1, labels=c(No,Yes))
 minf - factor(minf, levels=0:1, labels=c(No,Yes))
 diab - factor(diab, levels=0:1, labels=c(No,Yes))
 han - factor(han, levels=0:1, labels=c(No,Yes))
 died - as.Date(died, format=%d.%m.%Y)
 dstr - as.Date(dstr,format=%d.%m.%Y)
 dead - !is.na(died)  died  as.Date(1996-01-01)
 died[!dead] - NA
 })

 head ISwR/data/stroke.csv

 SEX;DIED;DSTR;AGE;DGN;COMA;DIAB;MINF;HAN
 1;7.01.1991;2.01.1991;76;INF;0;0;1;0
 1;.;3.01.1991;58;INF;0;0;0;0
 1;2.06.1991;8.01.1991;74;INF;0;0;1;1
 0;13.01.1991;11.01.1991;77;ICH;0;1;0;1
 0;23.01.1996;13.01.1991;76;INF;0;1;0;1
 1;13.01.1991;13.01.1991;48;ICH;1;0;0;1
 0;1.12.1993;14.01.1991;81;INF;0;0;0;1
 1;12.12.1991;14.01.1991;53;INF;0;0;1;1
 0;.;15.01.1991;73;ID;0;0;0;1
 
 Thanks for your help. Very insightfull and your version of RTFM was not
 to harsh either ;0)
 Part of what I want to achieve with the inclusion of the file is to be
 able to showcase a read-in function for the particular data type. Is there
 a slick way - sticking to your example - to reference the 'stroke.csv'
 directly? I'd like to put in the example of some function.Rd something
 analogous to # Use function to read in file:
 result - function(link to 'stroke.csv' in installed ISwR package)
 Without having to resort to accepting the example as No Run.

Answering to myself and staying with the same example:
system.file(data/stroke.csv,package=ISwR)
allows direct access to the example file (name).

Joh

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


Re: [R] R2HTML how to pair graphic.png and table

2007-12-06 Thread Eric Lecoutre
Hi Roberto,

here is a way that presumes you know some (basic) HTML tags:

library(R2HTML)
directory=getwd()
myfile-file.path(directory,testHTML.html)
HTMLoutput=file.path(directory,testHTML.html)
graf=graf.png
png(file.path(directory,graf))
plot(c(1:12))
dev.off()
tab-as.matrix(c(1:12))

cat(table border=0td width=50%,file=HTMLoutput, append=TRUE)
  HTMLInsertGraph(graf,file=HTMLoutput,caption=Esempio di grafico)
cat(/tdtd width=50%,file=HTMLoutput, append=TRUE)
HTML(tab,file=HTMLoutput)
cat(/td/table,file=HTMLoutput, append=TRUE)
browseURL(myfile)


I had already though I should include a function like layout for plots,
i will have a look at that when some time is available.

Best,

Eric




2007/12/6, Roberto Iacopetti [EMAIL PROTECTED]:


 Dear list,
 i have this problem:
 how to pair a graphic.png and a table in R2HTML ?

 The better showing of a mutiple analysis is sometimes to mate graphic and
 table

 Can anyone help me in this task ??

 In the example below graphisc and table are subsequent and not pair..


 directory=getwd()
 myfile-file.path(directory,testHTML.html)
 HTMLoutput=file.path(directory,testHTML.html)
 graf=graf.png
 png(file.path(directory,graf))
 plot(c(1:12))
 dev.off()
 tab-as.matrix(c(1:12))
 HTMLInsertGraph(graf,tab,file=HTMLoutput,caption=Esempio di grafico)
 browseURL(myfile)

 Thanks in advance

 Roberto Iacopetti

 --
 View this message in context:
 http://www.nabble.com/R2HTML--how-to-pair-graphic.png-and-table-tf4956321.html#a14193218
 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.




-- 
Eric Lecoutre
Consultant - Business  Decision
Business Intelligence  Customer Intelligence

[[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] $ operator is invalid for atomic vectors, returning NULL - what is the right thing to do then?

2007-12-06 Thread Duncan Murdoch
On 12/6/2007 7:04 AM, Søren Højsgaard wrote:
 Dear all,
 Starting from a recent version of R, the $ became unusable on atomic 
 vectors, e.g.
 x - c(a=1,b=2)
 x$a
 NULL
 Warning message:
 In x$a : $ operator is invalid for atomic vectors, returning NULL
  
 I can of course do
 x['a']
 - but that requires more typing (5 characters rather than 2). 
  
 Apologies if I've missed a an announcement regarding this, but
 1) Is there an alternative to the ['a'] and
 2) Why was this change made?

There's an announcement in the NEWS file for 2.6.0

DEPRECATED  DEFUNCT

 o  $ on an atomic vector now gives a warning that it is 'invalid'.
It remains deprecated, but may be removed in R = 2.7.0.

and an update in R-devel saying that in fact it has been made defunct there.

In answer to your questions:

1) I don't think so, other than x[1].
2) I don't remember the details, other than it was to avoid confusion. 
Maybe someone else can summarize the discussion?

Duncan Murdoch

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


Re: [R] hclust in heatmap.2

2007-12-06 Thread James W. MacDonald


affy snp wrote:
 Dear list,
 
 I am using heatmap.2(x) to draw a heatmap. Ideally, I want to the matrix
 x clustered only by columns and keep the original order of rows unchanged.
 Is there a way to do that in heatmap.2()?
 
 Thanks a lot! Any suggestions will be appreciated!

 From the help page:

Arguments:

x: numeric matrix of the values to be plotted.

 Rowv: determines if and how the _row_ dendrogram should be
   reordered.  By default, it is TRUE, which implies dendrogram
   is computed and reordered based on row means. If NULL or
   FALSE, then no dendrogram is computed and reordering is done.
   If a 'dendrogram', then it is used as-is, ie without any
   reordering. If a vector of integers, then dendrogram is
   computed and reordered based on the order of the vector.
 
 Best,
   Allen
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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

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


Re: [R] R2HTML how to pair graphic.png and table

2007-12-06 Thread Domenico Vistocco
You could use a table with one row and two columns:

HTML(TABLETD,file=HTMLoutput)
HTML(tab,file=HTMLoutput)
HTML(/TDTD,file=HTMLoutput)
HTMLInsertGraph(graf,file=HTMLoutput,caption=Esempio di grafico)
HTML(/TD/TABLE,file=HTMLoutput)

domenico

PS:
You could create a function if this is a common operation:

tableGraph=function(tab2Html,graph2Html,fileHtml){
HTML(TABLETD,file=fileHtml)
HTML(tab2Html,file=HTMLoutput)
HTML(/TDTD,file=HTMLoutput)
HTMLInsertGraph(graph2Html,file=fileHtml,caption=Esempio di grafico)
HTML(/TD/TABLE,file=fileHtml)
}

and then:
tableGraph(tab,graf,HTMLoutput)


Roberto Iacopetti wrote:
 Dear list,
 i have this problem:
 how to pair a graphic.png and a table in R2HTML ?

 The better showing of a mutiple analysis is sometimes to mate graphic and
 table

 Can anyone help me in this task ??

 In the example below graphisc and table are subsequent and not pair..
  

 directory=getwd()
 myfile-file.path(directory,testHTML.html)
 HTMLoutput=file.path(directory,testHTML.html)
 graf=graf.png
 png(file.path(directory,graf))
 plot(c(1:12))
 dev.off()
 tab-as.matrix(c(1:12))
 HTMLInsertGraph(graf,tab,file=HTMLoutput,caption=Esempio di grafico)
 browseURL(myfile)

 Thanks in advance

 Roberto Iacopetti



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


Re: [R] Building package - tab delimited example data issue

2007-12-06 Thread Peter Dalgaard
Johannes Graumann wrote:
 Johannes Graumann wrote:

   
 On Thursday 06 December 2007 11:52:46 Peter Dalgaard wrote:
 
 Johannes Graumann wrote:
   
 Hello,

 I'm trying to integrate example data in the shape of a tab delimited
 ASCII file into my package and therefore dropped it into the data
 subdirectory. The build works out just fine, but when I attempt to
 install I get:

 ** building package indices ...
 Error in scan(file, what, nmax, sep, dec, quote, skip, nlines,
 na.strings,  :
   line 1 did not have 500 elements
 Calls: Anonymous ... Anonymous - switch - assign - read.table -
 scan Execution halted
 ERROR: installing package indices failed
 ** Removing '/usr/local/lib/R/site-library/MaxQuantUtils'
 ** Restoring previous '/usr/local/lib/R/site-library/MaxQuantUtils'

 Accordingly the check delivers:

 ...
 * checking whether package 'MaxQuantUtils' can be installed ... ERROR

 Can anyone tell me what I'm doing wrong? build/install witout the ASCII
 file works just fine.

 Joh
 
 If you had looked at help(data), you would have found a list of which
 file formats it supports and how they are read. Hint: TAB-delimited
 files are not among them. *Whitespace* separated files work, using
 read.table(filename, header=TRUE), but that is not a superset of
 TAB-delimited data if there are empty fields.

 A nice trick is to figure out how to read the data from the command line
 and drop the relevant code into a mydata.R file (assuming that the
 actual data file is mydata.txt). This gets executed when the data is
 loaded (by data(mydata) or when building the lazyload database) because
 .R files have priority over .txt.

 This is quite general and allows a nice way of incorporating data

 management while retaining the original data source:
   
 more ISwR/data/stroke.R
 
 stroke -  read.csv2(stroke.csv, na.strings=.)
 names(stroke) - tolower(names(stroke))
 stroke -  within(stroke,{
 sex - factor(sex,levels=0:1,labels=c(Female,Male))
 dgn - factor(dgn)
 coma - factor(coma, levels=0:1, labels=c(No,Yes))
 minf - factor(minf, levels=0:1, labels=c(No,Yes))
 diab - factor(diab, levels=0:1, labels=c(No,Yes))
 han - factor(han, levels=0:1, labels=c(No,Yes))
 died - as.Date(died, format=%d.%m.%Y)
 dstr - as.Date(dstr,format=%d.%m.%Y)
 dead - !is.na(died)  died  as.Date(1996-01-01)
 died[!dead] - NA
 })

   
 head ISwR/data/stroke.csv
 
 SEX;DIED;DSTR;AGE;DGN;COMA;DIAB;MINF;HAN
 1;7.01.1991;2.01.1991;76;INF;0;0;1;0
 1;.;3.01.1991;58;INF;0;0;0;0
 1;2.06.1991;8.01.1991;74;INF;0;0;1;1
 0;13.01.1991;11.01.1991;77;ICH;0;1;0;1
 0;23.01.1996;13.01.1991;76;INF;0;1;0;1
 1;13.01.1991;13.01.1991;48;ICH;1;0;0;1
 0;1.12.1993;14.01.1991;81;INF;0;0;0;1
 1;12.12.1991;14.01.1991;53;INF;0;0;1;1
 0;.;15.01.1991;73;ID;0;0;0;1
   
 Thanks for your help. Very insightfull and your version of RTFM was not
 to harsh either ;0)
 Part of what I want to achieve with the inclusion of the file is to be
 able to showcase a read-in function for the particular data type. Is there
 a slick way - sticking to your example - to reference the 'stroke.csv'
 directly? I'd like to put in the example of some function.Rd something
 analogous to # Use function to read in file:
 result - function(link to 'stroke.csv' in installed ISwR package)
 Without having to resort to accepting the example as No Run.
 

 Answering to myself and staying with the same example:
 system.file(data/stroke.csv,package=ISwR)
 allows direct access to the example file (name).

   
Yes, but...

This works right until you turn on LazyData for your package, then you
end up with only

00Index  Rdata.rdb  Rdata.rds  Rdata.rdx

in the data directory. Use the inst source subdir for files you want
to have installed explicitly.

Also, in principle, it is

system.file(data, stroke.csv, package=ISwR)


although platforms that do not understand / as the path separator are
rare nowadays.

-- 
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

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


Re: [R] Junk or not Junk ???

2007-12-06 Thread David Hewitt


Loren Engrav wrote:
 
 Thank you
 
 As per advice from several R users I have set
 
 r-project.org, stat.math.ethz.ch,fhcrc.org, stat.ethz.ch, math.ethz.ch,
 hypatia.math.ethz.ch
 
  all to be safe domains
 
 But still some R emails go to Junk and require to be found manually
 
 I have explored the issue with Univ Wash computing to no avail
 
 Is this just how it is or have I still missed the fix to keep R emails
 out
 of junk?
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

I suspect most people that stay on this list read most posts through a news
reader... you might consider doing the same. I can't even imagine keeping up
with the daily deluge of individual emails.

http://www.nabble.com/R-help-f13820.html

http://news.gmane.org/gmane.comp.lang.r.general


-
David Hewitt
Virginia Institute of Marine Science
http://www.vims.edu/fish/students/dhewitt/
-- 
View this message in context: 
http://www.nabble.com/Junk-or-not-Junk-tf4940701.html#a14193897
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] Vertical text in a plot

2007-12-06 Thread Marcin Kozak
Hi,

Consider this simple plot:
 plot(1:25,runif(25,0,1),ylab=First Y-axis label,xaxt=n)

I want to add an additional axis as
 axis(4,at=seq(0.2,1,.2), labels=1:5)

I have no idea how to add now the title of the new axis as Second
Y-axis label. I want this text to be vertically directed from bottom
to top. I can't find the function in text() to write vertically. Any
ideas?

Thanks,
Marcin

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] 64-bit R compiling problem on Leopard

2007-12-06 Thread 정 태훈
Hi, All;

I've compiled and installed successfully presumably 64-bit R on  
Leopard.
But when I tried to run R, I got the following error:

/usr/bin/R: line 179: /Library/Frameworks/R.framework/Resources/etc/ 
i386/ldpaths: No such file or directory

Here is the configuration I used:

CONFIG_SHELL=/bin/bash ../R-devel/configure r_arch=x86_64 LDFLAGS=-L/ 
usr/local/lib64 -L/usr/X11R6/lib CC='gcc-4.2 -g -O3' CXX='g++-4.2 -g - 
O3' F77='gfortran -g -O3' FC='gfortran -g -O3' --with-blas='-framework  
vecLib' --with-lapack

Thanks in advance

Tae-Hoon Chung

Korea Centers for Disease Control  Prevention (KCDC)
Korea National Institute of Health (KNIH)
Center for Genome Sciences, Biobank for Health Sciences

194 Tongil-ro, Eunpyoung-gu, Seoul, 122-701, Korea

Tel 82-2-380-2252
Fax 82-2-354-1078
Mobile  82-10-8011-1036

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


Re: [R] Building package - tab delimited example data issue

2007-12-06 Thread Johannes Graumann
Peter Dalgaard wrote:

 Answering to myself and staying with the same example:
 system.file(data/stroke.csv,package=ISwR)
 allows direct access to the example file (name).

   
 Yes, but...
 
 This works right until you turn on LazyData for your package, then you
 end up with only
 
 00Index  Rdata.rdb  Rdata.rds  Rdata.rdx
 in the data directory. 
How would you do it in that case?


 Use the inst source subdir for files you want 
 to have installed explicitly.
Well: you provided the example ;0) - sort of ...

 
 Also, in principle, it is
 
 system.file(data, stroke.csv, package=ISwR)
 
 
 although platforms that do not understand / as the path separator are
 rare nowadays.
Thanks for that hint!

Joh

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


Re: [R] R2HTML how to pair graphic.png and table

2007-12-06 Thread Roberto Iacopetti

Eric,

your code work well for my need,
i'm not skillful in html environment, but your functions in R2HTML give
simple many
output requirements

thanks

Roberto




Eric Lecoutre wrote:
 
 Hi Roberto,
 
 here is a way that presumes you know some (basic) HTML tags:
 
 library(R2HTML)
 directory=getwd()
 myfile-file.path(directory,testHTML.html)
 HTMLoutput=file.path(directory,testHTML.html)
 graf=graf.png
 png(file.path(directory,graf))
 plot(c(1:12))
 dev.off()
 tab-as.matrix(c(1:12))
 
 cat(table border=0td width=50%,file=HTMLoutput, append=TRUE)
   HTMLInsertGraph(graf,file=HTMLoutput,caption=Esempio di grafico)
 cat(/tdtd width=50%,file=HTMLoutput, append=TRUE)
 HTML(tab,file=HTMLoutput)
 cat(/td/table,file=HTMLoutput, append=TRUE)
 browseURL(myfile)
 
 
 I had already though I should include a function like layout for plots,
 i will have a look at that when some time is available.
 
 Best,
 
 Eric
 
 
 
 
 2007/12/6, Roberto Iacopetti [EMAIL PROTECTED]:


 Dear list,
 i have this problem:
 how to pair a graphic.png and a table in R2HTML ?

 The better showing of a mutiple analysis is sometimes to mate graphic and
 table

 Can anyone help me in this task ??

 In the example below graphisc and table are subsequent and not pair..


 directory=getwd()
 myfile-file.path(directory,testHTML.html)
 HTMLoutput=file.path(directory,testHTML.html)
 graf=graf.png
 png(file.path(directory,graf))
 plot(c(1:12))
 dev.off()
 tab-as.matrix(c(1:12))
 HTMLInsertGraph(graf,tab,file=HTMLoutput,caption=Esempio di grafico)
 browseURL(myfile)

 Thanks in advance

 Roberto Iacopetti

 --
 View this message in context:
 http://www.nabble.com/R2HTML--how-to-pair-graphic.png-and-table-tf4956321.html#a14193218
 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.

 
 
 
 -- 
 Eric Lecoutre
 Consultant - Business  Decision
 Business Intelligence  Customer Intelligence
 
   [[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.
 
 

-- 
View this message in context: 
http://www.nabble.com/R2HTML--how-to-pair-graphic.png-and-table-tf4956321.html#a14194905
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] Frequency and Phase Spectrograms

2007-12-06 Thread Todd Remund

I know that there is a function, (spectro3D), that produces the Power 
Spectrogram.  Are there R functions that produce the Frequency Spectrogram and 
the Phase Spectrogram?  Thank you for your time.
[[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] hclust in heatmap.2

2007-12-06 Thread affy snp
Thanks Ashoka!

Allen

On Dec 6, 2007 12:27 AM, Ashoka Polpitiya [EMAIL PROTECTED]
wrote:

 Check the Rowv, Colv options to heatmap.2

 data(mtcars)
 x  - as.matrix(mtcars)
 heatmap.2(x, Rowv=FALSE, dendrogram=column)

 -Ashoka
 
 Scientist - Pacific Northwest National Lab

 On Dec 5, 2007 4:20 PM, affy snp [EMAIL PROTECTED] wrote:

  Dear list,
 
  I am using heatmap.2(x) to draw a heatmap. Ideally, I want to the matrix
  x clustered only by columns and keep the original order of rows
  unchanged.
  Is there a way to do that in heatmap.2()?
 
  Thanks a lot! Any suggestions will be appreciated!
 
  Best,
   Allen
 
 [[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.


Re: [R] hclust in heatmap.2

2007-12-06 Thread affy snp
Thanks James!

Allen

On Dec 6, 2007 9:21 AM, James W. MacDonald [EMAIL PROTECTED] wrote:



 affy snp wrote:
  Dear list,
 
  I am using heatmap.2(x) to draw a heatmap. Ideally, I want to the matrix
  x clustered only by columns and keep the original order of rows
 unchanged.
  Is there a way to do that in heatmap.2()?
 
  Thanks a lot! Any suggestions will be appreciated!

  From the help page:

 Arguments:

x: numeric matrix of the values to be plotted.

 Rowv: determines if and how the _row_ dendrogram should be
   reordered.  By default, it is TRUE, which implies dendrogram
   is computed and reordered based on row means. If NULL or
   FALSE, then no dendrogram is computed and reordering is done.
   If a 'dendrogram', then it is used as-is, ie without any
   reordering. If a vector of integers, then dendrogram is
   computed and reordered based on the order of the vector.
 
  Best,
Allen
 
[[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.

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


[[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] Vertical text in a plot

2007-12-06 Thread Gabor Grothendieck
There is an example in the example section of

library(zoo)
?plot.zoo

starting at:
 ## plot with left and right axes


On Dec 6, 2007 10:16 AM, Marcin Kozak [EMAIL PROTECTED] wrote:
 Hi,

 Consider this simple plot:
  plot(1:25,runif(25,0,1),ylab=First Y-axis label,xaxt=n)

 I want to add an additional axis as
  axis(4,at=seq(0.2,1,.2), labels=1:5)

 I have no idea how to add now the title of the new axis as Second
 Y-axis label. I want this text to be vertically directed from bottom
 to top. I can't find the function in text() to write vertically. Any
 ideas?

 Thanks,
 Marcin

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

2007-12-06 Thread A Friedman
An alternative solution that allows you to break it down by categories is in
the functions below.  Comments/suggestions welcome and encouraged.

Note that much thanks is due to those who responded to an earlier post of
mine on a similar topic.

To use (assuming you have a data.frame falled pathDist with columns
distances (your numeric data of interest), Capacity, Surface, and SITE
(vectors of categories)):
ops=c(quote(mean),quote(median),quote(sd),quote(length))
ops.desc=list(mean=Mean,median=Median,sd=S.D.,length=N)
pathDist.indices=list
(Surface=pathDist$Surface,Capacity=pathDist$Capacity,Site=pathDist$SITE)
pathDist.bytable=bytable(pathDist$distances,pathDist.indices,ops=ops,
ops.desc=ops.desc,na.rm=TRUE)
pathDist.table=latex.table.by(pathDist.bytable,num.by.vars=length(
pathDist.indices),caption=Path Characteristics)
print(pathDist.table,
type=latex,file=E:/xdrive/projects/Ghana_air/backpack_data/plots/pathDist.table.tex,
include.rownames = FALSE, include.colnames = TRUE, sanitize.text.function =
force, tabular.environment='longtable', floating=FALSE)





# Make a table by group
# Usage:
#   print(latex.table.by(test.df), include.rownames = FALSE,
include.colnames = TRUE, sanitize.text.function = force)
#   then add \usepackage{multirow} to the preamble of your LaTeX document
#   for longtable support, add ,tabular.environment='longtable' to the print
command (plus add in ,floating=FALSE), then \usepackage{longtable} to the
LaTeX preamble
latex.table.by = function(df,num.by.vars=1,...) {
# first num.by.vars groups must be sorted and in descending order of
priority
if(!is.numeric(num.by.vars) | length(num.by.vars)!=1) {
stop(num.by.vars must be a number)
}
# Create a by.vars vector
by.vars=1:num.by.vars

numcols=length(colnames(df))
df.original=df

# Initialize our clines variable (gives the start column of the cline
for each row)
clines = rep(num.by.vars+1,length(df[[1]]))
# - Make grouping columns multirow - #
for(b in rev(by.vars)) {

# Create a groups variable for all by.vars up to the current one
groups=rep(,length(df[[b]]))
for(by.vars.index in 1:b) {
groups = paste(groups,df.original[[by.vars.index]],sep=)
}
# Add multirow code to current column according to the groups
pattern
df[[b]] - as.character(df[[b]])
rle.lengths - rle(groups)$lengths
first - !duplicated(groups)
df[[b]][!first] - 
df[[b]][first] - paste(\\multirow{, rle.lengths, }{*}{,
df[[b]][first], })

# Store this by.var's information in the clines variable
clines[first]=b
}

# Specify horizontal lines wherever all combinations of grouping
variables change
df[[1]]-paste(\\cline{,clines,-,numcols,},df[[1]],sep=)


align.by.vars = sapply(list(rep(|c, (length(by.vars)+1)
)),paste,collapse=)
align.other.vars = sapply(list(rep(r|, (length(colnames(df))-length(
by.vars)) )),paste,collapse=)
align.df = paste(|, align.by.vars , | , align.other.vars ,sep=)

xt=xtable(df, align = align.df,...)


return(xt)

}


bytable = function(datavec,indices,ops=c(quote(mean)),ops.desc=list
(mean=Mean),na.rm=TRUE,...) {
groups=as.character()
combinations.others=c()

# indices should be a list of grouping vectors, just like you would pass
to -by-, but with sensible names for each vector
if(!is.list(indices)) {
stop(indices needs to be a list)
}
# Create a selector variable from the indices given as a list
if(length(indices)  1) {
for(indexnum in length(indices):1) {
groups=paste(groups,indices[[indexnum]],sep=)
}
}
if(length(indices)==1) {
groups=indices[[1]]
}
first=!duplicated(groups)

# Initialize data frame with grouping variables (indices)
bynames=dimnames(by(datavec,indices,function(x) x=1)) # run a dummy by
statement to get the name order out...highly inefficient...could use
indices.levels=lapply(indices,function(x) x[!duplicated(x)]) instead, as
long as we're sure the ordering is the same
for(indexnum in length(indices):1) {
# get the number of combinations of other index levels after this
one (e.g. the number of replicates we need to make of each one in this
index)
others.selector=rep(TRUE,length(indices))
others.selector[length(indices):indexnum]=FALSE
numcombinations.others = prod(unlist(subset(lapply(bynames,length),
others.selector)))
# Replicate each level of this index the number of existing
combinations of other indices
newcolumn=rep(bynames[[indexnum]],each=numcombinations.others)

if(indexnum==length(indices)) { # first run
by.df=data.frame(newcolumn)
}
if(indexnum!=length(indices)) {
# newcolumn is too short by some multiple so we have to fix that
newcolumn=rep(newcolumn, length(rownames(by.df))/length(newcolumn)
)
# now attach our 

Re: [R] Sweave problem in Windows

2007-12-06 Thread MikeHA



huang min wrote:
 
 Hi,
 
 I have searched the lists but still can not solve the problem. I am using
 a
 windows machine. After I sweave some Rnw file, I got a tex file. However,
 the tex file can not be compiled. I know the problem is in the line
 \usepackage{C:/PROGRA~1/R/R-25~1.1/share/texmf/Sweave} and I need to
 modify
 this line to
 \usepackage{Sweave}.
 
 I hope there can be some automatic way to do this instead of changing this
 line in the tex file whenever I modify something. Thank you.
 
 Huang
 
   [[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.
 
 

Simple workaround is to include the \usepackage{Sweave} in your .Rnw file,
after the \documentclass like this:

\documentclass[a4paper]{article}
\usepackage{Sweave}

Make sure you have all the .sty files you need in the same folder as your
.tex file.

cheers,  Mike

-- 
View this message in context: 
http://www.nabble.com/Sweave-problem-in-Windows-tf4527254.html#a14194509
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] Any package for deconvolution?

2007-12-06 Thread Chen, Gang (NIH/NIMH) [C]
I want to run deconvolution of a time series by an impulse or point-spread 
function through Wiener filter, regularized filter, Lucy-Richardson method, or 
any other approaches. I searched the CRAN website and the mailing list archive, 
but could not find any package for such a deconvolution analysis. Does anybody 
know an existing R function for deconvolution?
 
TIA,
Gang

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

2007-12-06 Thread Saeed Abu Nimeh
Hi,
I installed the snow package on a unix box that has multiple cores. To be
able to exploit the multiple cores (on one pc) do I still need to install
the rmpi package (or rpvm). Another question, if i run a bayesian simulation
on the multiple core after setting them up correctly (using snow), would you
think there will be a noticeable speedup gain.
Thanks,
Saeed
---

linux centos
4 dual core processors
32 gb ram
R (2.6.0)
snow 0.29

[[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] Any package for deconvolution?

2007-12-06 Thread Richard . Cotton
The RTisean package has wiener filter functions (wiener1 and wiener2).

Regards,
Richie.

Mathematical Sciences Unit
HSL




Chen, Gang (NIH/NIMH) [C] [EMAIL PROTECTED] 
Sent by: [EMAIL PROTECTED]
06/12/2007 16:20

To
r-help@r-project.org
cc

Subject
[R] Any package for deconvolution?






I want to run deconvolution of a time series by an impulse or point-spread 
function through Wiener filter, regularized filter, Lucy-Richardson 
method, or any other approaches. I searched the CRAN website and the 
mailing list archive, but could not find any package for such a 
deconvolution analysis. Does anybody know an existing R function for 
deconvolution?
 
TIA,
Gang

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




ATTENTION:

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

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


Re: [R] creating conditional means

2007-12-06 Thread Sherri Heck
hi gabor,

i was able to get your suggestion to work.  i have been going through 
the R help tools to figure out what each step actually does because i 
have something similar but hours 2,5,8,11,14,17 and 20 are missing.  i 
haven't had any luck.  each mean value that is calculated is the 
same.  i keep getting the following error:

 DF- read.table(textConnection(Lines), header = TRUE)
Error in read.table(textConnection(Lines), header = TRUE) :
duplicate 'row.names' are not allowed
aggregate(DF[2:4],
+with(DF, data.frame(Year, Qtr = (Month - 3) %/% 3 + 1, Hour)),
+mean)#skip=hour[2,5,8,11,14]
Error in data.frame(Year, Qtr = (Month - 3)%/%3 + 1, Hour) :
object Year not found


i am not clear why in aggregate(DF[#:#] that we are subsetting other 
variables besides co2.  i have been trying to just subset co2 without 
success though.
your original suggestion is below and a snippet of my data set is below 
that. if you have any ideas  or if you know of a help page that i may 
not have found yet that would be great (i've been using the aggregate 
help pages mostly.

thanks for your help-

s.heck



Lines - Year Month Hour co2 num1 num2
 2006   110 383.3709   28   28
 2006   111 383.3709   28   28
 2006   112 383.3709   28   28
 2006   113 383.3709   28   28
 2006   114 383.3709   28   28
 2006   115 383.3709   28   28
 2006   116 383.3709   28   28
 2006   117 383.3709   28   28
 2006   118 383.3709   28   28
 2006   119 383.3709   27   27
 2006   11   10 383.3709   28   28

DF - read.table(textConnection(Lines), header = TRUE)
aggregate(DF[4:6],
   with(DF, data.frame(Year, Qtr = (Month - 1) %/% 3 + 1, Hour)),
   mean)#skip=hour[2,5,8,11,14,17,20]???


 



Year Month Hour co2
200510386.1600708
200511386.823056
200513387.1335939
200514387.0681103
200516387.4750983
200517388.3398313
200519388.7545317
2005110388.0844451
2005112386.7929627
2005113385.5569521
2005115384.5523752
2005116385.0246721
2005118385.8646669
2005119386.2182493
2005121386.4820756
2005122386.6606276
200520386.6791667
200521386.6597544
200523386.5725303
200524387.0638611
200526387.9293508
200527388.3778991
200529388.3721947
2005210387.8324642
2005212386.8404892
2005213385.6770345
2005215384.4798484
2005216384.6214677
2005218384.3044105
2005219383.3018709
2005221382.5837339
2005222382.2658036

Gabor Grothendieck wrote:
 Just adjust the formula for Qtr appropriately if your quarters
 are not Jan/Feb/Mar, Apr/May/Jun, Jul/Aug/Sep, Oct/Nov/Dec
 as I assumed.

 On Dec 1, 2007 5:21 PM, Sherri Heck [EMAIL PROTECTED] wrote:
   
 Hi Gabor,

 Thank you for your help.  I think I need to clarify a bit more.  I am
 trying to say

 average all 2pms for months march + april + may (for example). I hope this 
 is clearer.

 here's a larger subset of my data set:

 year, month, hour, co2(ppm), num1,num2

 2006 1 0 384.2055 14 14
 2006 1 1 384.0304 14 14
 2006 1 2 383.9672 14 14
 2006 1 3 383.8452 14 14
 2006 1 4 383.8594 14 14
 2006 1 5 383.7318 14 14
 2006 1 6 383.6439 14 14
 2006 1 7 383.7019 14 14
 2006 1 8 383.7487 14 14
 2006 1 9 383.8376 14 14
 2006 1 10 383.8684 14 14
 2006 1 11 383.8301 14 14
 2006 1 12 383.8058 14 14
 2006 1 13 383.9419 14 14
 2006 1 14 383.7876 14 14
 2006 1 15 383.7744 14 14
 2006 1 16 383.8566 14 14
 2006 1 17 384.1014 14 14
 2006 1 18 384.1312 14 14
 2006 1 19 384.1551 14 14
 2006 1 20 384.099 14 14
 2006 1 21 384.1408 14 14
 2006 1 22 384.3637 14 14
 2006 1 23 384.1491 14 14
 2006 2 0 384.7082 27 27
 2006 2 1 384.6139 27 27
 2006 2 2 384.7453 26 26
 2006 2 3 384.9224 28 28
 2006 2 4 384.8581 28 28
 2006 2 5 384.9208 28 28
 2006 2 6 384.9086 28 28
 2006 2 7 384.837 28 28
 2006 2 8 384.6163 27 27
 2006 2 9 384.7406 28 28
 2006 2 10 384.7468 28 28
 2006 2 11 384.6992 28 28
 2006 2 12 384.6388 28 28
 2006 2 13 384.6346 28 28
 2006 2 14 384.6037 28 28
 2006 2 15 384.5295 28 28
 2006 2 16 384.5654 28 28
 2006 2 17 384.6466 28 28
 2006 2 18 384.6344 28 28
 2006 2 19 384.5911 28 28
 2006 2 20 384.6084 28 28
 2006 2 21 384.6318 28 28
 2006 2 22 384.6181 27 27
 2006 2 23 384.6087 27 27


 thanks you again for your assistance-

 s.heck



 Gabor Grothendieck wrote:
 
 Try aggregate:


 Lines - Year Month Hour co2 num1 num2
  2006   110 383.3709   28   28
  2006   111 383.3709   28   28
  2006   112 383.3709   28   28
  2006   113 383.3709   28   28
  2006   114 383.3709   28   28
  2006   115 383.3709   28   28
  2006   116 383.3709   28   28
  2006   117 383.3709   28   28
  2006   118 383.3709   28   28
  2006   119 383.3709  

Re: [R] Using panel.densityplot with stripplot

2007-12-06 Thread Deepayan Sarkar
On 12/6/07, Christopher Oezbek [EMAIL PROTECTED] wrote:

 But is there a technical reason for making this distinction? It seemed to
 me that most panel functions can deal with x and y parameters and that
 panel.densityplot could make use of the same mechanisms as panel.violin to
 subdivide based on factor y.

The technical reason is a fundamental part of the Trellis design. The
prepanel function determines a bounding box as part of the initial
calculations. Knowing this in advance allows the panel display and the
axis rendering to be completely separated.

Note that the panel.violin plot cannot easily say anything about the
actual heights of the densities, only their shape. The y-axis there
annotates the sample groups.

-Deepayan

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


[R] Help rewriting looping structure?

2007-12-06 Thread TLowe

Hey Folks,

Could somebody help me rewrite the following code?

I am looping through all records across 5 fields to calculate the cumulative
percentage of each record (relative to each individual field).

Is there a way to rewrite it so I don't have to loop through each individual
record?

# tdat is my data frame
# j is my field index
# k is my record index
# tsum is the sum of all values in field j
# tmp is a vector containing the values in field j
# tdat[k,paste(cpct,j,sep=)] creates new fields cpct1,...,cpct5 


for(j in 1:5) {
  tsum- sum(tdat[,j]);
  for(k in 1:nrow(tdat)) {
td- tdat[k,j];
tmp-tdat[,j];
# sum values = to current value and divide by the total sum
tdat[k,paste(cpct,j,sep=)]- sum(tmp[tmp = td]) / tsum;
  }
}


Thanks,
TLowe
-- 
View this message in context: 
http://www.nabble.com/Help-rewriting-looping-structure--tf4957267.html#a14196412
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] creating conditional means

2007-12-06 Thread Gabor Grothendieck
The error message says you have duplicate row names and that
is not allowed.  Make sure you have the same number of elements
on each line of data as in the header.  If you have one more on each line
than on the header then the first data item on each line will be regarded
as the row name.  See ?count.fields

The rest of your message is not clear.


On Dec 6, 2007 11:52 AM, Sherri Heck [EMAIL PROTECTED] wrote:
 hi gabor,

 i was able to get your suggestion to work.  i have been going through
 the R help tools to figure out what each step actually does because i
 have something similar but hours 2,5,8,11,14,17 and 20 are missing.  i
 haven't had any luck.  each mean value that is calculated is the
 same.  i keep getting the following error:

  DF- read.table(textConnection(Lines), header = TRUE)
 Error in read.table(textConnection(Lines), header = TRUE) :
duplicate 'row.names' are not allowed
 aggregate(DF[2:4],
 +with(DF, data.frame(Year, Qtr = (Month - 3) %/% 3 + 1, Hour)),
 +mean)#skip=hour[2,5,8,11,14]
 Error in data.frame(Year, Qtr = (Month - 3)%/%3 + 1, Hour) :
object Year not found
 

 i am not clear why in aggregate(DF[#:#] that we are subsetting other
 variables besides co2.  i have been trying to just subset co2 without
 success though.
 your original suggestion is below and a snippet of my data set is below
 that. if you have any ideas  or if you know of a help page that i may
 not have found yet that would be great (i've been using the aggregate
 help pages mostly.

 thanks for your help-

 s.heck



 Lines - Year Month Hour co2 num1 num2
  2006   110 383.3709   28   28
  2006   111 383.3709   28   28
  2006   112 383.3709   28   28
  2006   113 383.3709   28   28
  2006   114 383.3709   28   28
  2006   115 383.3709   28   28
  2006   116 383.3709   28   28
  2006   117 383.3709   28   28
  2006   118 383.3709   28   28
  2006   119 383.3709   27   27
  2006   11   10 383.3709   28   28
 
 DF - read.table(textConnection(Lines), header = TRUE)
 aggregate(DF[4:6],
   with(DF, data.frame(Year, Qtr = (Month - 1) %/% 3 + 1, Hour)),
   mean)#skip=hour[2,5,8,11,14,17,20]???






 Year Month Hour co2
 200510386.1600708
 200511386.823056
 200513387.1335939
 200514387.0681103
 200516387.4750983
 200517388.3398313
 200519388.7545317
 2005110388.0844451
 2005112386.7929627
 2005113385.5569521
 2005115384.5523752
 2005116385.0246721
 2005118385.8646669
 2005119386.2182493
 2005121386.4820756
 2005122386.6606276
 200520386.6791667
 200521386.6597544
 200523386.5725303
 200524387.0638611
 200526387.9293508
 200527388.3778991
 200529388.3721947
 2005210387.8324642
 2005212386.8404892
 2005213385.6770345
 2005215384.4798484
 2005216384.6214677
 2005218384.3044105
 2005219383.3018709
 2005221382.5837339
 2005222382.2658036


 Gabor Grothendieck wrote:
  Just adjust the formula for Qtr appropriately if your quarters
  are not Jan/Feb/Mar, Apr/May/Jun, Jul/Aug/Sep, Oct/Nov/Dec
  as I assumed.
 
  On Dec 1, 2007 5:21 PM, Sherri Heck [EMAIL PROTECTED] wrote:
 
  Hi Gabor,
 
  Thank you for your help.  I think I need to clarify a bit more.  I am
  trying to say
 
  average all 2pms for months march + april + may (for example). I hope this 
  is clearer.
 
  here's a larger subset of my data set:
 
  year, month, hour, co2(ppm), num1,num2
 
  2006 1 0 384.2055 14 14
  2006 1 1 384.0304 14 14
  2006 1 2 383.9672 14 14
  2006 1 3 383.8452 14 14
  2006 1 4 383.8594 14 14
  2006 1 5 383.7318 14 14
  2006 1 6 383.6439 14 14
  2006 1 7 383.7019 14 14
  2006 1 8 383.7487 14 14
  2006 1 9 383.8376 14 14
  2006 1 10 383.8684 14 14
  2006 1 11 383.8301 14 14
  2006 1 12 383.8058 14 14
  2006 1 13 383.9419 14 14
  2006 1 14 383.7876 14 14
  2006 1 15 383.7744 14 14
  2006 1 16 383.8566 14 14
  2006 1 17 384.1014 14 14
  2006 1 18 384.1312 14 14
  2006 1 19 384.1551 14 14
  2006 1 20 384.099 14 14
  2006 1 21 384.1408 14 14
  2006 1 22 384.3637 14 14
  2006 1 23 384.1491 14 14
  2006 2 0 384.7082 27 27
  2006 2 1 384.6139 27 27
  2006 2 2 384.7453 26 26
  2006 2 3 384.9224 28 28
  2006 2 4 384.8581 28 28
  2006 2 5 384.9208 28 28
  2006 2 6 384.9086 28 28
  2006 2 7 384.837 28 28
  2006 2 8 384.6163 27 27
  2006 2 9 384.7406 28 28
  2006 2 10 384.7468 28 28
  2006 2 11 384.6992 28 28
  2006 2 12 384.6388 28 28
  2006 2 13 384.6346 28 28
  2006 2 14 384.6037 28 28
  2006 2 15 384.5295 28 28
  2006 2 16 384.5654 28 28
  2006 2 17 384.6466 28 28
  2006 2 18 384.6344 28 28
  2006 2 19 384.5911 28 28
  2006 2 20 384.6084 28 28
  2006 2 21 384.6318 28 28
  2006 2 

Re: [R] Bootstrap Correlation Coefficient with Moving Block Bootstrap

2007-12-06 Thread Tim Hesterberg
It sounds like you should sample x and y together using the
block bootstrap.  If you have the usual situation, x and y in columns
and observations in rows, then sample blocks of rows.

Even though observations in y are independent, you would take
advantage of that only for bootstrapping statistics that depend only
on y.

The answer to your second question is the same as the first - sample
blocks of observations, keeping x and y together.

Tim Hesterberg  

Hello.

I have got two problems in bootstrapping from
dependent data sets.

Given two time-series x and y. Both consisting of n
observations with x consisting of dependent and y
consisting of independent observations over time. Also
assume, that the optimal block-length l is given.

To obtain my bootstrap sample, I have to draw
pairwise, but there is the problem of dependence of
the x-observations and so if I draw the third
observation of y, I cannot simply draw the third
observation of x (to retain the serial correlation
structure between x and y), because I devided x into
blocks of length l and I have to draw blocks, then I
draw from x.

1.
How can I compute a bootstrap sample of the
correlation coefficient between x and y with respect
to the dependence in time-series of x?

2.
How does it look like, if x and y both consist of
dependent observations?



I hope you can help me. I got really stuck with this
problem.

Sincerly
Klein.

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


Re: [R] coxme frailty model standard errors?

2007-12-06 Thread Terry Therneau
--- begin included message
I am running R 2.6.1 on windows xp
I am trying to fit a cox proportional hazard model with a shared
Gaussian frailty term using coxme My model is specified as:

nofit1-coxme(Surv(Age,cen1new)~ Sex+bo2+bo3,random=~1|isl,data=mydat)

With x1-x3 being dummy variables, and isl being the community level
variable with 4 levels.

Does anyone know if there is a way to get the standard error for the
random effect, like in nofit1$var?  I would like to know if my random
effect is worth writing home about.

-- end included message

  Computation of the se of the random effect turns out to be very hard, and 
worse it isn't worth much when you have done so.  For both these reasons coxme 
doesn't even try (and it's not on the list of things to add).
  
   First, you can do a likelihood ratio test by comparing the fit to a coxph 
model that does not have the random effect.   Make sure that the null 
loglikelihood for the two fits are the same though!  (For instance, one obs was 
missing the isl variable above, so the two fits have differnt n).  

 fit1-  coxme(Surv(Age,cen1new)~ Sex+bo2+bo3,random=~1|isl, data=mydat)  
 fit2- coxph(Surv(Age,cen1new)~ Sex+bo2+bo3, data=mydat)
 fit1$loglik[1:2] - fit2$loglik 
 
The first number printed should be 0, twice the second is distributed as a 
chisq 
on number of random effects degrees of freedom.  (Not quite.  The chisq test 
is actually conservative since the random effect is constrained to be =0.  But 
it is close, and I'll let someone else work out the details)

   Second, you can print a profile likelihood confidence interval.  You had a 
random effects variance of about .4, so make a guess that the confidence 
interval is somewhere between 0 and 2.
 vtemp - seq(0.0001, 2, length=20) 
 ltemp - 0*vtemp
 for (i in 1:length(vtemp)) {
tfit - coxme(Surv(Age,cen1new)~ Sex+bo2+bo3,random=~1|isl, data=mydat,
variance= vtemp[i])
ltemp - 2 * diff(tfit$loglik[1:2])
}
 plot(vtemp, ltemp, xlab='Variance', ylab=LR test)
 abline(h= 2*diff(fit1$loglik[1:2]) - 3.84)
 
   The sequence of fits each have a fixed value for the variance of the random 
effect; the plot shows the profile likelihood.  The profile is often very 
asymmetric (which is why the se of the random effect isn't worth much).  The 
intersection of the profile with a line 3.84 units down (chisq on 1df) is the 
profile based 95% confidence interval. 
   
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] using eval(parse(text)) , gsub(pattern, replacement, x) , to process code within a loop/custom function

2007-12-06 Thread Thomas Pujol
R-help users,
  Thanks in advance for any assistance ... I truly appreciate your expertise.  
I searched help and could not figure this out, and think you can probably offer 
some helpful tips. I apologize if I missed something, which I'm sure I probably 
did. 
   
  I have data for many samples. (e.g. 1950, 1951, 1952, etc.)

  For each sample, I have many data-frames. (e.g. temp.1952, births.1952, 
gdp.1952, etc.)

  (Because the data is rather large (and for other reasons), I have chosen to 
store the data as individual files, as opposed to a list of data frames.)
   
  I wish to write a function that enables me to run any of many custom 
functions/processes on each sample of data.

  I currently accomplish this by using a custom function that uses:
eval(parse(t=text.i2)) , and gsub(pat, rep, x) (this changes the sample 
number for each line of text I submit to eval(parse(t=text.i2)) ).

  Is there a better/preferred/more flexible way to do this?

  One issue/obstacle that I have encountered: Some of the custom functions I 
use need to take as input the value of d in the loop below. 
(Please see the sample function fn.mn.d below.)
  
#creates sample data
temp.1951 - c(11,13,15)
births.1951 - c(123, 156, 178)
temp.1952 - c(21,23,25)
births.1952 - c(223, 256, 278)
###
#function that looks for a a pattern pat.i within x, and replaces it with 
rep
recurse - function(x, pat.i,rep.i) {
f - function(x,pat,rep) if (mode(x) == character) gsub(pat, rep, x)  else x
   if (length(x) == 0) return(x)
   if (is.list(x)) for(i in seq_along(x)) x[[i]] - recurse(x[[i]], pat.i,rep.i)
   else x - f(x,pat.i,rep.i)
   x
#f - function(x) if (mode(x) == character) gsub(a, green, x)  else x
}# end recurse end
###
  ###
#function that processes code submitted as text.i for each date in dates.i
fn.dateloop - function(text.i, dates.i ) {
for(d in 1: length(dates.i) ) {
tempdate - dates.i[d]
text.i2 - recurse(text.i, pat.i='#', rep.i=tempdate)
temp0=eval(parse(t=text.i2)) 
tempname - paste(names(temp0)[1], tempdate, sep='.')
save(list='temp0', file = tempname)
} # next d
} # end fn.dateloop
###
  #
#a sample custom function that I want to run on each sample of data
fn.mn - function(x, y) {
res = x - y
names(res) = 'mn'
res
} 
#
#
#example of function that takes d as input...
#I have not been able to get this to work with the custom function 
fn.dateloop above
#I request assistance in learning how to accomplish this
fn.mn.d - function(x, y, d) {x[d] - y[d]} 
#
  #
setwd('c:/') #specifies location where sample data will be saved
getwd() #checks location
fn.mn(x=temp.1951, y=births.1951)
fn.mn(x=temp.1952, y=births.1952)
#
fn.dateloop(text.i = fn.mn(x=get('temp.#'), y=get('births.#') ) , 
dates.i=c('1951','1952') )
get(load('mn.1951'))
get(load('mn.1952'))
   
   
   

   
-

[[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] Using expression in Hmisc Key()

2007-12-06 Thread Greg Snow
 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Michael Kubovy
 Sent: Thursday, December 06, 2007 2:12 AM
 To: Dieter Menne
 Cc: [EMAIL PROTECTED]
 Subject: Re: [R] Using expression in Hmisc Key()
 
[snip]
 This is one of the cases where I wish there were a function 
 that exercised all the arguments of a graphics function by 
 visualizing the effect of changing  two or three levels of 
 each argument (one by one, of course). This might have the 
 side effect of allowing authors to shorten documentation. I 
 have in mind adding a method to each graphics function, and 
 having the author specify the two or three instructive levels 
 of each argument. See the exhaustive exploration by J.R. 
 Lobry, A.B. Dufour  D. Chessel of the graphical parameters 
 accessible by par(), at http://pbil.univ-lyon1.fr/R/fichestd/tdr75.pdf

There are some tools that already exist to help with creating these
types of visualization tools.  The playwith package appears to be one
such set of tools (I have not played with it much, so don't expect
details from me).

The tkrplot package is another one (I am more familiar with this one).
The slider function (relax and TeachingDemos package) and sliderv
function (TeachingDemos) also help here.  Try running the example for
the sliderv function and move the sliders around to see the effects.
(one of these days I am going to rewrite many of the demos in
TeachingDemos to use tkrplot)

Yes, it would be nice to have a general function that could look at the
arguments of a function, but this is not an easy task, for example, how
many arguments can you pass to the plot function?  Also which arguments
should use slider bars and which text widgets? (radio buttons are a bit
easier).  One option (that I think you are possibly suggesting above) is
to have each writer of a function include some type of metadata that a
general function could query and use to make decisions about what type
of control to use for that option including possible ranges of values.
I'll think some more about this approach.  I have plans to add some more
graphical demos to the TeachingDemos package that would do what you want
with subsets of the par arguments (there are too many to do all at once,
but one function could let you modify plotting type, cex, lwd, lty, col,
and similar options, it gets tricky when mar and mai both modify the
same thing in different ways and both take vectors rather than a single
number).

Some functions have arguments that depend on each other, making the GUI
for these cases is a bit more dificult in that you need to build in
those relationships (see the vis.gamma function in TeachingDemos for one
example, the rate and scale arguments are 2 different ways of specifying
the same thing).

One option (I would be willing to put this into TeachingDemos, or it may
want its own package at some point) is to write a general function that
takes a plotting expression/function as the first argument and a list as
the 2nd argument.  The list would include information on which type of
widget (slider, radio buttons, entry, ...) to use, what the range of
values are, and which argument to the plotting function they correspond
to.  The function would then create a gui (using tkrplot would be my
preference) that would modify those values.  Any function author that
wants users to be able to use this with their function just needs to
provide the list and possibly a not run example in the docs (and we can
create several predone lists in the package for common plotting
functions and subsets of par arguments).

I'm adding this to my list of bus projects to think about.

Any other thoughts,

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
(801) 408-8111
 
 

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


Re: [R] Any package for deconvolution?

2007-12-06 Thread Chen, Gang (NIH/NIMH) [C]
Thanks a lot for the quick pointer, Richie. I will take a close look of the 
RTisean package.
 
Gang



From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Thu 12/6/2007 11:46 AM
To: Chen, Gang (NIH/NIMH) [C]
Cc: r-help@r-project.org
Subject: Re: [R] Any package for deconvolution?



The RTisean package has wiener filter functions (wiener1 and wiener2).

Regards,
Richie.

Mathematical Sciences Unit
HSL




Chen, Gang (NIH/NIMH) [C] [EMAIL PROTECTED]
Sent by: [EMAIL PROTECTED]
06/12/2007 16:20

To
r-help@r-project.org
cc

Subject
[R] Any package for deconvolution?






I want to run deconvolution of a time series by an impulse or point-spread
function through Wiener filter, regularized filter, Lucy-Richardson
method, or any other approaches. I searched the CRAN website and the
mailing list archive, but could not find any package for such a
deconvolution analysis. Does anybody know an existing R function for
deconvolution?

TIA,
Gang

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




ATTENTION:

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

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


Re: [R] logistic regression using glm,which y is set to be 1

2007-12-06 Thread Marc Schwartz

On Wed, 2007-12-05 at 22:33 -0800, Bin Yue wrote:
 Dear all:
  By comparing glmresult$y and model.response(model.frame(glmresult)),  I
 have found out which one is 
 set to be TRUE and which FALSE.But it seems that to fit a logistic
 regression , logit (or logistic) transformation has to be done before
 regression.
  Does anybody know how to obtain the transformation result ? It is hard
 to settle down before knowing the actual process R works . I have read some
 books and the ?glm help file , but what they told me was not sufficient.
Best wishes ,
  Bin Yue

Bin,

I may be mis-interpreting your follow up query, but here goes:

You have presumably created a logistic regression model. The resultant
model object is called 'glmresult'.

If you use:

  fitted(glmresult)

it will return the fitted predicted values on a probability scale (0 -
1) for the original set of data that you used.

You can also use:

  predict(glmresult, type = response)

The advantage of using predict.glm() is that you can apply the model
against new data.


If you want the linear predicted values on a log-odds scale, you can
use:

  glmresult$linear.predictors

or more easily:

  predict(glmresult)

See ?fitted and ?predict.glm for more information.


Let's use an example from ?infert:

model1 - glm(case ~ spontaneous+induced, data=infert,family=binomial())

# Summary of fitted values on a probability scale
 summary(fitted(model1))
   Min. 1st Qu.  MedianMean 3rd Qu.Max. 
 0.1534  0.1534  0.2949  0.3347  0.3750  0.7511 


# Same
 summary(predict(model1, type = response))
   Min. 1st Qu.  MedianMean 3rd Qu.Max. 
 0.1534  0.1534  0.2949  0.3347  0.3750  0.7511 


# Get log-odds scale values
 summary(model1$linear.predictors)
   Min. 1st Qu.  MedianMean 3rd Qu.Max. 
-1.7080 -1.7080 -0.8716 -0.7781 -0.5107  1.1050


# Same
 summary(predict(model1))
   Min. 1st Qu.  MedianMean 3rd Qu.Max. 
-1.7080 -1.7080 -0.8716 -0.7781 -0.5107  1.1050


If we wanted to do the log-odds scale to probability scale transform
manually, we could do:

 summary(exp(predict(model1)) / (1 + exp(predict(model1
   Min. 1st Qu.  MedianMean 3rd Qu.Max. 
 0.1534  0.1534  0.2949  0.3347  0.3750  0.7511 

Look familiar?

I would urge you to read through An Introduction To R, which is
available with your R installation or via the R web site under
Documentation. In addition, there are various books listed on the R web
site regarding model building and related subject matter. Which you
choose can be a matter of taste, but two I recommend would be:

William N. Venables and Brian D. Ripley. Modern Applied Statistics with
S. Fourth Edition. Springer, New York, 2002. ISBN 0-387-95457-0

Frank E. Harrell. Regression Modeling Strategies, with Applications to
Linear Models, Survival Analysis and Logistic Regression. Springer,
2001. ISBN 0-387-95232-2

HTH,

Marc Schwartz

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


Re: [R] Help rewriting looping structure?

2007-12-06 Thread Erik Iverson
How about this example?

## sample data frame with two columns
df - data.frame(x = abs(rnorm(20)), y=abs(rnorm(20,2)))

## create new variables in df with an lapply call
df[c(cpctx,cptcty)] - lapply(df, function(x) cumsum(x)/sum(x))

A possible improvement would be to construct the new column names in
the data frame automatically.

Best,
Erik
TLowe wrote:
 Hey Folks,
 
 Could somebody help me rewrite the following code?
 
 I am looping through all records across 5 fields to calculate the cumulative
 percentage of each record (relative to each individual field).
 
 Is there a way to rewrite it so I don't have to loop through each individual
 record?
 
 # tdat is my data frame
 # j is my field index
 # k is my record index
 # tsum is the sum of all values in field j
 # tmp is a vector containing the values in field j
 # tdat[k,paste(cpct,j,sep=)] creates new fields cpct1,...,cpct5 
 
 
 for(j in 1:5) {
   tsum- sum(tdat[,j]);
   for(k in 1:nrow(tdat)) {
 td- tdat[k,j];
 tmp-tdat[,j];
 # sum values = to current value and divide by the total sum
 tdat[k,paste(cpct,j,sep=)]- sum(tmp[tmp = td]) / tsum;
   }
 }
 
 
 Thanks,
 TLowe

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


Re: [R] Help rewriting looping structure?

2007-12-06 Thread jim holtman
Is this basically what you want to do? (Please include commented,
minimal, self-contained, reproducible code so we don't have to guess
at what you want)

 x - data.frame(a=runif(10), b=runif(10))
# do for one column
 cumsum(x$a)/sum(x$a)
 [1] 0.05892073 0.08129611 0.11067218 0.28640268 0.28969826 0.44477544
0.55195101 0.76500220 0.85234025
[10] 1.


If this is the case, you can extend it.

On Dec 6, 2007 9:02 AM, TLowe [EMAIL PROTECTED] wrote:

 Hey Folks,

 Could somebody help me rewrite the following code?

 I am looping through all records across 5 fields to calculate the cumulative
 percentage of each record (relative to each individual field).

 Is there a way to rewrite it so I don't have to loop through each individual
 record?

 # tdat is my data frame
 # j is my field index
 # k is my record index
 # tsum is the sum of all values in field j
 # tmp is a vector containing the values in field j
 # tdat[k,paste(cpct,j,sep=)] creates new fields cpct1,...,cpct5


 for(j in 1:5) {
  tsum- sum(tdat[,j]);
  for(k in 1:nrow(tdat)) {
td- tdat[k,j];
tmp-tdat[,j];
 # sum values = to current value and divide by the total sum
tdat[k,paste(cpct,j,sep=)]- sum(tmp[tmp = td]) / tsum;
  }
 }


 Thanks,
 TLowe
 --
 View this message in context: 
 http://www.nabble.com/Help-rewriting-looping-structure--tf4957267.html#a14196412
 Sent from the R help mailing list archive at Nabble.com.

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




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

What is the problem you are trying to solve?

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


Re: [R] Help rewriting looping structure?

2007-12-06 Thread TLowe

Thank you all.  That's exactly what I was looking for.



TLowe wrote:
 
 Hey Folks,
 
 Could somebody help me rewrite the following code?
 
 I am looping through all records across 5 fields to calculate the
 cumulative
 percentage of each record (relative to each individual field).
 
 Is there a way to rewrite it so I don't have to loop through each
 individual
 record?
 
 # tdat is my data frame
 # j is my field index
 # k is my record index
 # tsum is the sum of all values in field j
 # tmp is a vector containing the values in field j
 # tdat[k,paste(cpct,j,sep=)] creates new fields cpct1,...,cpct5 
 
 
 for(j in 1:5) {
   tsum- sum(tdat[,j]);
   for(k in 1:nrow(tdat)) {
 td- tdat[k,j];
 tmp-tdat[,j];
 # sum values = to current value and divide by the total sum
 tdat[k,paste(cpct,j,sep=)]- sum(tmp[tmp = td]) / tsum;
   }
 }
 
 
 Thanks,
 TLowe
 

-- 
View this message in context: 
http://www.nabble.com/Help-rewriting-looping-structure--tf4957267.html#a14198294
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] a question on stepAIC

2007-12-06 Thread Minya Pu
 Hi,
 I am trying to use stepAIC to do forward stepwise selection for a logistic
model.
I did

 hi  - glm(melanoma ~ ., family = binomial, data=data)

lo  - glm(melanoma ~ 1, family = binomial, data=data)

 stepAIC(lo, scope=list(upper = hi , lower = lo), direction = forward )

But the full model hi did not converge since I have many many candidate
covariates:

Warning message:

algorithm did not converge in: glm.fit(x = X, y = Y, weights = weights,
start = start, etastart = etastart,…

 Question: Can I do the forward selection without specifying a maximal model
hi?


Thanks,

Minya Pu

[[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] Displaying numerics to full double precision

2007-12-06 Thread Jeff Delmerico

Thanks Ben, that fixed the display within R.  However, even after changing
the display settings, the matrix elements still appear to be exported in
single precision.  The matrix object is being passed into my C routines as
an SEXP Numeric type, and somewhere along the way, some of the digits are
getting lost.  
Here's the relevant bit of my C code:

SEXP
divideMatrix(SEXP matrix_in, SEXP sub_height, SEXP sub_width, SEXP fileS)
...
if ( isMatrix(matrix_in)  isNumeric(matrix_in) )
{
/* Use R macros to convert from SEXP to C types */
matrix = REAL(matrix_in);
height = INTEGER(GET_DIM(matrix_in))[0];
width = INTEGER(GET_DIM(matrix_in))[1];
subW = INTEGER_VALUE(sub_width);
subH = INTEGER_VALUE(sub_height);
...
}

Am I using the wrong macro to convert into a double in C?  Any ideas?

Thanks,
Jeff Delmerico


Ben Bolker wrote:
 
 
 
 Jeff Delmerico wrote:
 
 I'm working on a shared library of C functions for use with R, and I want
 to create a matrix in R and pass it to the C routines.  I know R computes
 and supposedly stores numerics in double precision, but when I create a
 matrix of random numerics using rnorm(), the values are displayed in
 single precision, and also exported in single precision when I pass them
 out to my C routines.  An example is below:
 
 a - matrix(rnorm(16, mean=10, sd=4), nrow=4)
 a
   [,1]  [,2]  [,3]  [,4]
 [1,] 14.907606 17.572872 19.708977  9.809943
 [2,]  9.322041 13.624452  7.745254  7.596176
 [3,] 10.642408  6.151546  9.937434  6.913875
 [4,] 14.617647  5.577073  8.217559 12.115465
 storage.mode(a)
 [1] double
 
 Does anyone know if there is a way to change the display or storage
 settings so that the values will be displayed to their full precision?  
 Or does rnorm only produce values to single precision? 
 
 Any assistance would be greatly appreciated.
 
 Thanks,
 Jeff Delmerico
 
 
 options(digits) # 7
 options(digits=x)
 
   I may be mistaken, but I think the values are indeed exported
 as double precision -- the issue here is just a display setting.
 
   Ben Bolker
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Displaying-numerics-to-full-double-precision-tf4950807.html#a14179534
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] Frequency and Phase Spectrograms

2007-12-06 Thread Dieter Menne
Todd Remund tkremund98 at hotmail.com writes:

 I know that there is a function, (spectro3D), that produces the Power
Spectrogram.  Are there R functions
 that produce the Frequency Spectrogram and the Phase Spectrogram?  Thank you
for your time.

fft in stats gives you all you need, possibly combined with some time window in
package signal, which also has some higher level stuff. Do you really want to
interpret the frequency spectrum (whatever it is) with real, imaginary part
and signs?

The docs of spectro3D gives makes me cringe:

Following Heisenberg uncertainty principle, the short-term Fourier transform
cannot be precised in both time and frequency. 

I know that's written in quite a few books, but that upside-down thinking has
been a source of confusion for generations of students and professors (of
biology, to say).

Dieter

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


[R] relationship between two factors

2007-12-06 Thread christopher snow
I have a dataset with two variables that are factors:

1) Decision Making Satisfaction (DMS), values = A - Completely, B - 
Mostly, C - Partly, D - Not at all
2) IT Satisfaction values (ITS), values = A - Completely, B - Mostly, C 
- Partly, D - Not at all

I would like to produce a table (matrix) and a chart of the factors, 
with counts at the cross sections:

 A   B   C   D
A   
B   counts
C
D

How can I do this in R?

Many thanks,

Chris

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] generalized linear model with mixed effects

2007-12-06 Thread Samuel Oman
Hi,

I need to fit a general generalized linear model, for observations 
on a response Y which is Gamma-distributed and observed in clusters.  So, if

E(Y) = mu,

then for a suitable link function f, f(mu) is a (linear) function of 
both fixed and random effects.  Are there R packages or functions which 
fit these models, using either MLE or estimating-equation approaches?

Many thanks,
Sam

-- 
Professor Samuel D. Oman
Department of Statistics
Hebrew University
Mount Scopus
Jerusalem
91905 Israel

tel:+ 972 2 5883 442
fax:+ 972 2 5883 549

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


Re: [R] Help rewriting looping structure?

2007-12-06 Thread Law, Jason
This will give you the percents in the same order as your original data (as
this is what your original code did)

apply(tdat, 2,
function(x) {
o - order(x)
oldo - order(o)
prc - cumsum(x[o]) / sum(x)
prc[oldo]
})

Jason Law
Statistician
City of Portland, Bureau of Environmental Services
Water Pollution Control Laboratory
6543 N Burlington Avenue
Portland, OR 97203 -5452
[EMAIL PROTECTED]



-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of TLowe
Sent: Thursday, December 06, 2007 10:28 AM
To: r-help@r-project.org
Subject: Re: [R] Help rewriting looping structure?



Thank you all.  That's exactly what I was looking for.



TLowe wrote:
 
 Hey Folks,
 
 Could somebody help me rewrite the following code?
 
 I am looping through all records across 5 fields to calculate the
 cumulative
 percentage of each record (relative to each individual field).
 
 Is there a way to rewrite it so I don't have to loop through each
 individual
 record?
 
 # tdat is my data frame
 # j is my field index
 # k is my record index
 # tsum is the sum of all values in field j
 # tmp is a vector containing the values in field j
 # tdat[k,paste(cpct,j,sep=)] creates new fields cpct1,...,cpct5

 
 
 for(j in 1:5) {
   tsum- sum(tdat[,j]);
   for(k in 1:nrow(tdat)) {
 td- tdat[k,j];
 tmp-tdat[,j];
 # sum values = to current value and divide by the total sum
 tdat[k,paste(cpct,j,sep=)]- sum(tmp[tmp = td]) / tsum;
   }
 }
 
 
 Thanks,
 TLowe
 

-- 
View this message in context:
http://www.nabble.com/Help-rewriting-looping-structure--tf4957267.html#a1419
8294
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] Fitting large titles in a plot

2007-12-06 Thread Greg Snow
Try inserting \n into the title where you would like it to start on a
new line, e.g.:

plot(A,main=This is my really long title\nand it's so long\nthat I can
see just about half of it.)

You may need to give yourself more room in the margin for multi-line
titles (see ?par and the mar entry) and using the title function (rather
than in the plot) will let you specify the position of the title (line
argument).

Hope this helps,


-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
(801) 408-8111
 
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Svempa
 Sent: Thursday, December 06, 2007 8:16 AM
 To: r-help@r-project.org
 Subject: [R] Fitting large titles in a plot
 
 
 I want to fit a fairly long main title for a plot, supposedly 
 by changing row after a while. As for now it starts way 
 outside the picture margin at the left and continues way out 
 right passed the right margins.
 
 plot(A,main=This is my really long title and it's so long 
 that I can 
 see
 just about half of it.)
 
 Any suggestions? Shouldn't be that hard.
 
 --
 View this message in context: 
 http://www.nabble.com/Fitting-large-titles-in-a-plot-tf4956510
 .html#a14193900
 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] Fitting large titles in a plot

2007-12-06 Thread Marc Schwartz

On Thu, 2007-12-06 at 07:16 -0800, Svempa wrote:
 I want to fit a fairly long main title for a plot, supposedly by changing row
 after a while. As for now it starts way outside the picture margin at the
 left and continues way out right passed the right margins.
 
 plot(A,main=This is my really long title and it's so long that I can see
 just about half of it.)
 
 Any suggestions? Shouldn't be that hard.

You can insert newline characters ('\n') in the title:


plot(A, main = This is my really long title\nand it's so long that I
can see\njust about half of it.)


The likelihood is that you will need to alter the vertical position of
the title to accommodate the line wrapping.

To do that, you can either use mtext() in lieu of the 'main' argument,
or consider adjusting par(mgp), the first value of which is the
position of the plot title. See ?mtext and ?par.

You might also want to look at ?strwrap for a more general way of
wrapping long lines of text.

HTH,

Marc Schwartz

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


Re: [R] differences in using source() or console

2007-12-06 Thread Duncan Murdoch
On 12/6/2007 8:01 AM, vito muggeo wrote:
 Dear all,
 Is there *any* reason explaining what I describe below?

Probably, but you're unlikely to get a correct explanation if you don't 
give us code to reproduce the problem.

 From the look of things, your real example is quite complex, which is 
probably why you didn't post it.  But the very act of simplifying it to 
something that is reasonable to post is quite likely to reveal to you 
what the problem is.

Duncan Murdoch

 I have the following line
 
 myfun(x)
 
 If I type them directly in R (or copy/past), it works..
 
 However if I type in R 2.6.1
 
   source(code.R) ##code.R includes the above line
 Error in inherits(x, data.frame) : object d not found
 
 namely myfun() does not work correctly.
 In particular the non-working line inside myfun() is
 
 update(eval(x$call$obj), data=d) #d is created in myfun()
 
 My question is: why the problem occurs just via source()ing???
 
 many thanks,
 vito
 
 
 
 Vito M.R. Muggeo
 Dip.to Sc Statist e Matem `Vianelli'
 Università di Palermo
 viale delle Scienze, edificio 13
 90128 Palermo - ITALY
 tel: 091 6626240
 fax: 091 485726/485612
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Fitting large titles in a plot

2007-12-06 Thread jim holtman
try this:


plot(0, main=paste(strwrap(This is my really long title and it's so
long that I can see just about half of it., width=50),
collapse=\n))

On Dec 6, 2007 7:16 AM, Svempa [EMAIL PROTECTED] wrote:

 I want to fit a fairly long main title for a plot, supposedly by changing row
 after a while. As for now it starts way outside the picture margin at the
 left and continues way out right passed the right margins.

 plot(A,main=This is my really long title and it's so long that I can see
 just about half of it.)

 Any suggestions? Shouldn't be that hard.

 --
 View this message in context: 
 http://www.nabble.com/Fitting-large-titles-in-a-plot-tf4956510.html#a14193900
 Sent from the R help mailing list archive at Nabble.com.

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




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

What is the problem you are trying to solve?

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


Re: [R] merge in function

2007-12-06 Thread Marc Schwartz

On Thu, 2007-12-06 at 09:27 -0800, qian z wrote:
 I used merge() in a function, but it doesn't return correct data frame. 

   add.name - function(data, x)

   {

   ...
   ...

   newfile - merge(data, resid, by =0, all.x=TRUE, all.y= FALSE)
   newfile


   }

You are going to need to give us more information. 

It is not clear what you mean by not returning the correct data frame.
Why is it not correct? 

Where and what is 'resid'?  

What is 'x' and how is it used in the function?  

What is 'by = 0'? The 'by' argument values need to be quoted.

Please provide a small reproducible example as per the Posting Guide.

HTH,

Marc Schwartz

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


Re: [R] Fitting large titles in a plot

2007-12-06 Thread Jim Price

I wrote a little utility function for exactly this reason, which I use with
long titles. You may want to add calls to par to adjust the upper margin if
you are using raw graphical functionality (plot et al) - but lattice adjusts
the upper margin automatically so you wouldn't need to add anything else.


PrettyString - function(theString, maxLength, collapse = \n)
{
words - unlist(strsplit(theString,  ))
wordLengths - unlist(lapply(strsplit(words, ), length))

if(max(wordLengths)  maxLength) 
stop(maxChar must be increased due to string length)

count = wordLengths[1]
results = vector()
currentLine = words[1]

for(i in 2:length(words))
{
if((count + wordLengths[i] + 1)  maxLength)
{
results = c(results, currentLine)
currentLine = words[i]
count = wordLengths[i]
}
else
{
currentLine = paste(currentLine, words[i])
count = count + wordLengths[i] + 1
}
}
if(length(currentLine))
results - c(results, currentLine)

paste(results, collapse = collapse)
}


Knowing the R list, someone can probably reduce this function to 2 lines of
code.
Jim



Svempa wrote:
 
 I want to fit a fairly long main title for a plot, supposedly by changing
 row after a while. As for now it starts way outside the picture margin at
 the left and continues way out right passed the right margins.
 
plot(A,main=This is my really long title and it's so long that I can see
just about half of it.)
 
 Any suggestions? Shouldn't be that hard.
 
 

-- 
View this message in context: 
http://www.nabble.com/Fitting-large-titles-in-a-plot-tf4956510.html#a14196971
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] Randomizing one column in the dataMatrix

2007-12-06 Thread mogra

I have huge data file, and I would like randomize just one column at a time ,
is there any easy way?

Thanks a lot.
-- 
View this message in context: 
http://www.nabble.com/Randomizing-one-column-in-the-dataMatrix-tf4957535.html#a14197423
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] Using expression in Hmisc Key()

2007-12-06 Thread Dieter Menne
Michael Kubovy kubovy at virginia.edu writes:

 
 This is one of the cases where I wish there were a function that  
 exercised all the arguments of a graphics function by visualizing  
 the effect of changing  two or three levels of each argument (one by  
 one, of course). This might have the side effect of allowing authors  
 to shorten documentation. I have in mind adding a method to each  
 graphics function, and having the author specify the two or three  
 instructive levels of each argument. See the exhaustive exploration by  
 J.R. Lobry, A.B. Dufour  D. Chessel of the graphical parameters  
 accessible by par(), at


 http://pbil.univ-lyon1.fr/R/fichestd/tdr75.pdf

That looks like a nice source for classical graphics, but I fear that it will
have a limited readience because of the language (Disclaimer: I am not working
for Time Magazine, my French is acceptable, and we drink their wine. ).

Even reading such stuff in German is difficult for me, because of the required 
switching between computer terms and translation.

For lattice, show.settings() is a good starter. Too bad it's miles from showing
the complete set of options. No student around looking for the first steps to 
fame?

Dieter

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


Re: [R] Vertical text in a plot

2007-12-06 Thread John Kane
op - par(mar=(c(5, 4, 4, 4) + 0.1)) 
plot(1:25,runif(25,0,1),ylab=First Y-axis
label,xaxt=n)
axis(4,at=seq(0.2,1,.2), labels=1:5)
mtext(Second  Y-axis label,side=4, line=2)
par(op) 
--- Marcin Kozak [EMAIL PROTECTED] wrote:

 Hi,
 
 Consider this simple plot:
  plot(1:25,runif(25,0,1),ylab=First Y-axis
 label,xaxt=n)
 
 I want to add an additional axis as
  axis(4,at=seq(0.2,1,.2), labels=1:5)
 
 I have no idea how to add now the title of the new
 axis as Second
 Y-axis label. I want this text to be vertically
 directed from bottom
 to top. I can't find the function in text() to write
 vertically. Any
 ideas?
 
 Thanks,
 Marcin
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] relationship between two factors

2007-12-06 Thread Henrique Dallazuanna
Try this:

df - data.frame(DMS=factor(rep(LETTERS[1:4], 10)),
ITS=factor(rep(LETTERS[1:4], 10)))
table(df)
plot(table(df))

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


On 06/12/2007, christopher snow [EMAIL PROTECTED] wrote:
 I have a dataset with two variables that are factors:

 1) Decision Making Satisfaction (DMS), values = A - Completely, B -
 Mostly, C - Partly, D - Not at all
 2) IT Satisfaction values (ITS), values = A - Completely, B - Mostly, C
 - Partly, D - Not at all

 I would like to produce a table (matrix) and a chart of the factors,
 with counts at the cross sections:

  A   B   C   D
 A
 B   counts
 C
 D

 How can I do this in R?

 Many thanks,

 Chris

 --
 This message has been scanned for viruses and
 dangerous content by MailScanner, and is
 believed to be clean.

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] finding most highly transcribed genes - ranking, sorting and subsets?

2007-12-06 Thread alison waller
Hello,

 

I am not only interested in finding out which genes are the most highly up-
or down-regulated (which I have done using the linear models and Bayesian
statistics in Limma), but I also want to know which genes are consistently
highly transcribed (ie. they have a high intensity in the channel of
interest eg. Cy5 or Cy3 across the set of experiments).  I might have missed
a straight forward way to do this, or a valuable function, but I've been
using my own methods and going around in circles.

 

So far I've normalized within and between arrays, then returned the RG
values using RG-RG.MA, then I ranked each R and G values for each array as
below.

rankRG-RG

rankRG$R[,1]-rank(rankRG$R[,1])

rankRG$R[,2]-rank(rankRG$R[,2]) .. and so on for 6 columns(ie. arrays, as
well as the G's)

 

then I thought I could pull out a subset of rankRG using something like;

topRG-rankRG

topRG$R-subset(topRG$R,topRG$R[,1]500topRG$R[,2]500topRG$R[,5]500)

 

However, this just returned me a matrix with one row of $R (the ranks were
500 for columns 1,2, and 5 and greater than 500 for 3,4,and 6).  However, I
can't believe that there is only one gene that is in the top 500 for R
intensitiy among those three arrays.

 

Am I doing something wrong?  Can someone think of a better way of doing
this?

 

Thanks

 

Alison

 

 

**
Alison S. Waller  M.A.Sc.
Doctoral Candidate
[EMAIL PROTECTED]
416-978-4222 (lab)
Department of Chemical Engineering
Wallberg Building
200 College st.
Toronto, ON
M5S 3E5

  

 


[[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] Fitting large titles in a plot

2007-12-06 Thread Bert Gunter

Try This:

plot(A,main=paste(This is my really long title and,\n,it's so long that
I can see
just about half of it., sep =  ))

-- Bert Gunter
Genentech

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

2007-12-06 Thread Gerard Tromp
Greetings!

Recently when I tried to use lm.influence I get the following error:
Error in .Fortran(lminfl, model$qr$qr, n, n, k, as.integer(do.coef),  :
  Fortran symbol name lminfl not in DLL for package base

This occurs on both Linux and Windows platforms (details below).

Searching the mail lists and other sources indicates that the fortran code
for lminfluence (lminfl.f) was moved in the source code tree suggesting it
should be found in package stats. Not clear to me why the hardcoded path
is package base.
The offending line in the R code for lm.influence is:
res - .Fortran(lminfl, model$qr$qr, n, n, k, as.integer(do.coef),

There were no other messages from people experiencing errors with
lm.influence on the mailing list.

Can someone else confirm that they are experiencing the same problem?

Also, as a workaround, is there a way of forcing R to look in stats for the
fortran symbol (similar to using the double and triple colon for addressing
specific namespaces)?


On Linux platform:
=
sessionInfo()
R version 2.6.1 (2007-11-26)
x86_64-redhat-linux-gnu

locale:
LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8
;LC_MONETARY=en_US.UTF-8;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAM
E=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION
=C

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

other attached packages:
[1] SMPracticals_1.1-1 ellipse_0.3-5

loaded via a namespace (and not attached):
[1] rcompgen_0.1-17 tools_2.6.1

On Windows platform:
===
R version 2.6.1 (2007-11-26)
i386-pc-mingw32

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

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

other attached packages:
[1] SMPracticals_1.1-1 ellipse_0.3-5

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



Gerard
%
Gerard Tromp, Ph.D
Center for Molecular Medicine and Genetics  Vox: 313.577.8773
Department of Neurologyfax: 313.577.5218
Wayne State University School of Medicine
3309 Scott Hall
540 East Canfield Ave.
Detroit, MI 48201

e-mail: [EMAIL PROTECTED]
   web: http://www.genetics.wayne.edu/gtromp/gtromp-home.html

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


Re: [R] relationship between two factors

2007-12-06 Thread Greg Snow
The 'table' function will give you the simple counts.  Plotting a table
with the 'plot' function gives common charts for this.  The 'CrossTable'
function in the gmodels package creates the table along with additional
information.  There are a lot of other functions for creating/working
with tables depending on what you are trying to do.

Hope this helps, 

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
(801) 408-8111
 
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of christopher snow
 Sent: Thursday, December 06, 2007 5:51 AM
 To: r-help@r-project.org
 Subject: [R] relationship between two factors
 
 I have a dataset with two variables that are factors:
 
 1) Decision Making Satisfaction (DMS), values = A - 
 Completely, B - Mostly, C - Partly, D - Not at all
 2) IT Satisfaction values (ITS), values = A - Completely, B - 
 Mostly, C
 - Partly, D - Not at all
 
 I would like to produce a table (matrix) and a chart of the 
 factors, with counts at the cross sections:
 
  A   B   C   D
 A   
 B   counts
 C
 D
 
 How can I do this in R?
 
 Many thanks,
 
 Chris
 
 --
 This message has been scanned for viruses and dangerous 
 content by MailScanner, and is believed to be clean.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] S3 and S4 clash

2007-12-06 Thread Spencer Graves
Hello: 

  How can I work around the conflict between the S3 and S4 
illustrated in the example below?  I'm developing a package that 
requires a function in 'stats4', but when 'stats4' is attached, it 
breaks my AIC function.  I could give my AIC function another name so it 
no longer uses the generic dispatch, but I wonder if there is another way. 

  Thanks,
  Spencer Graves

bar.tmp - structure(1, class = bar)
AIC.bar - function(object, ..., k=2) {
  3
}

  AIC(bar.tmp)
[1] 3
  library(stats4)
  AIC(bar.tmp)
Error in UseMethod(logLik) : no applicable method for logLik
  detach(package:stats4)
  AIC(bar.tmp)
[1] 3
  objects()
[1] AIC.bar bar.tmp
  sessionInfo()
R version 2.6.1 (2007-11-26)
i386-pc-mingw32

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

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

loaded via a namespace (and not attached):
[1] stats4_2.6.1

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


Re: [R] relationship between two factors

2007-12-06 Thread Marc Schwartz

On Thu, 2007-12-06 at 12:51 +, christopher snow wrote:
 I have a dataset with two variables that are factors:
 
 1) Decision Making Satisfaction (DMS), values = A - Completely, B - 
 Mostly, C - Partly, D - Not at all
 2) IT Satisfaction values (ITS), values = A - Completely, B - Mostly, C 
 - Partly, D - Not at all
 
 I would like to produce a table (matrix) and a chart of the factors, 
 with counts at the cross sections:
 
  A   B   C   D
 A   
 B   counts
 C
 D
 
 How can I do this in R?
 
 Many thanks,
 
 Chris


See ?table, for example:

  table(DMS, ITS)

You did not indicate the type of chart you want to create, but some
possibilities, using base graphics, would be barplot(), dotchart() and
mosaicplot(). The latter is in the vcd package on CRAN.

HTH,

Marc Schwartz

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


Re: [R] Java parser for R data file?

2007-12-06 Thread David Coppit

On 12/5/07 12:15 PM, Prof Brian Ripley [EMAIL PROTECTED] wrote:

On Wed, 5 Dec 2007, David Coppit wrote:

 Or, given that I'm dealing with just a single array, would it be better to
 roll my own I/O using write.table or write.matrix from the MASS package?

It would be much easier.  The save() format is far more complex than you
need.  However, I would use writeBin() to write a binary file and read
that in in Java, avoiding the binary - ASCII - binary conversion.

Thanks for the suggestion-writeBin works quite well. For posterity, here's what 
I did:

On the R side:

# Assumes that there are no special values in the tofList, such as NA_REAL,
# R_PosInf, R_NegInf, ISNAN, R_FINITE. See the R Data Import/Export manual.
saveListAsBinary - function( tofList, filename )
{
  outConn - file( filename, wb );

  for (m in 1:length(tofList)) {
writeBin(names(tofList)[[m]], outConn);
writeBin(length(tofList[[m]]), outConn, size = 4, endian = big);
writeBin(tofList[[m]], outConn, size = 4, endian = big);
  }

  close(outConn);
}

saveListAsBinary(myList, outfile.RDat);

On the Java side:

  public static void read_R_Output(String filename, ArrayListString names,
  ArrayListArrayListFloat data)
  {
try {
  DataInputStream dataInputStream = new DataInputStream(
new BufferedInputStream(new FileInputStream(filename)));

  boolean endOfFile = false;

  while (!endOfFile) {
try {
  StringBuffer sb = new StringBuffer();

  byte c;
  while ((c = dataInputStream.readByte()) != 0)
sb.append((char)c);

  names.add(new String(sb));

  int cols = dataInputStream.readInt();

  ArrayListFloat row = new ArrayListFloat(cols);

  for (int i = 0; i  cols; i++)
row.add(dataInputStream.readFloat());

  data.add(row);
} catch (EOFException e) {
  endOfFile = true;
}
  }

  dataInputStream.close();
} catch (Exception e) {
  e.printStackTrace();
}
  }

Regards,
David

[[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] simple problems

2007-12-06 Thread marciarr

Hello R users,
I have been looking through Help files and Nabble list for the answers for
these simple questions, but it seems to be fruitless.
1- in a data frame with two columns, x and y, how do I get the corresponding
value of x to, let's say, the minimum value of the y column (min (data$y)) ?
2- how do I solve a simple equation? Considering the equation y= exp(-x)^12,
I would like to find the values of x for,  for example, y=0.01, so
exp(-x)^12=0.01. How do I do that using R?
I know those a probably very, very simple questions, but for which I do not
seem to find the answer.
Thank you very much,
Marcia
-- 
View this message in context: 
http://www.nabble.com/simple-problems-tf4958407.html#a14200401
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] relationship between two factors

2007-12-06 Thread John Kane
?table should work 

table (DMS, ITS)

I am not clear on what kind of chart you want.

will 
plot(DMS, ITS) do what you want?


--- christopher snow [EMAIL PROTECTED] wrote:

 I have a dataset with two variables that are
 factors:
 
 1) Decision Making Satisfaction (DMS), values = A -
 Completely, B - 
 Mostly, C - Partly, D - Not at all
 2) IT Satisfaction values (ITS), values = A -
 Completely, B - Mostly, C 
 - Partly, D - Not at all
 
 I would like to produce a table (matrix) and a chart
 of the factors, 
 with counts at the cross sections:
 
  A   B   C   D
 A   
 B   counts
 C
 D
 
 How can I do this in R?
 
 Many thanks,
 
 Chris



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

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


Re: [R] Fitting large titles in a plot

2007-12-06 Thread Marc Schwartz

On Thu, 2007-12-06 at 09:28 -0800, Jim Price wrote:
 I wrote a little utility function for exactly this reason, which I use with
 long titles. You may want to add calls to par to adjust the upper margin if
 you are using raw graphical functionality (plot et al) - but lattice adjusts
 the upper margin automatically so you wouldn't need to add anything else.
 
 
 PrettyString - function(theString, maxLength, collapse = \n)
 {
   words - unlist(strsplit(theString,  ))
   wordLengths - unlist(lapply(strsplit(words, ), length))
 
   if(max(wordLengths)  maxLength) 
   stop(maxChar must be increased due to string length)
 
   count = wordLengths[1]
   results = vector()
   currentLine = words[1]
 
   for(i in 2:length(words))
   {
   if((count + wordLengths[i] + 1)  maxLength)
   {
   results = c(results, currentLine)
   currentLine = words[i]
   count = wordLengths[i]
   }
   else
   {
   currentLine = paste(currentLine, words[i])
   count = count + wordLengths[i] + 1
   }
   }
   if(length(currentLine))
   results - c(results, currentLine)
 
   paste(results, collapse = collapse)
 }
 
 
 Knowing the R list, someone can probably reduce this function to 2 lines of
 code.
 Jim

Would you believe one line?

  paste(strwrap(theString, width = maxLength), collapse = \n)

;-)

See ?strwrap as I noted previously.

HTH,

Marc Schwartz

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


Re: [R] lm.influence under R2.6.1

2007-12-06 Thread Marc Schwartz

On Thu, 2007-12-06 at 14:00 -0500, Gerard Tromp wrote:
 Greetings!
 
 Recently when I tried to use lm.influence I get the following error:
 Error in .Fortran(lminfl, model$qr$qr, n, n, k, as.integer(do.coef),  :
   Fortran symbol name lminfl not in DLL for package base
 
 This occurs on both Linux and Windows platforms (details below).

I presume that the Linux message does not refer to DLLs? :-)

 Searching the mail lists and other sources indicates that the fortran code
 for lminfluence (lminfl.f) was moved in the source code tree suggesting it
 should be found in package stats. Not clear to me why the hardcoded path
 is package base.
 The offending line in the R code for lm.influence is:
 res - .Fortran(lminfl, model$qr$qr, n, n, k, as.integer(do.coef),
 
 There were no other messages from people experiencing errors with
 lm.influence on the mailing list.
 
 Can someone else confirm that they are experiencing the same problem?
 
 Also, as a workaround, is there a way of forcing R to look in stats for the
 fortran symbol (similar to using the double and triple colon for addressing
 specific namespaces)?

snip

I can run example(lm.influence) and example(influence.measures) without
issue on:

  R version 2.6.1 Patched (2007-11-26 r43541)

on an F8 Linux system.

I don't see anything immediately obvious in the NEWS file for 2.6.1
patched to suggest that something has changed here.

Can you provide a reproducible example here and/or try to upgrade to
patched?

I would also try to run:

  R --vanilla

from the command line to provide a clean environment to be sure that
none of the other packages that you are loading are causing conflicts.

HTH,

Marc Schwartz

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


[R] Course***January 2008 *** San Francisco New York City *** R/S-Plus Advanced Programming by XLSolutions Corp

2007-12-06 Thread [EMAIL PROTECTED]
Happy Holidays Folks!

XLSolutions Corporation has scheduled 2 great R/Splus Advanced
programming courses. More course can be viewed on our website.


R/Splus Advanced Programming*  San Francisco    January 21-22,
2008
R/Splus Advanced Programming*  New York City    January 24-25,
2008


Please email for earlybird rates: Payments due after the class.


R/Splus Advanced Programming  Course Outline:

Day 1 

 - Overview of R/S fundamentals: Syntax and Semantics  
 - Class and Inheritance  
 - Concepts, Construction and good use of Language Objects  
 - Coercion and Efficiency  
 - Object-oriented Programming in R and S-Plus  
 - Taking advantage of fast objects and fast functions  
 - Advanced Manipulation tools: Parse, Deparse, Substitute, etc.  
 - How to fully take advantage of Vectorization  
 - Generic and Method Functions; S4 (S-Plus 6), etc.  
 - Search path, Databases and Frames Visibility (S-plus)  

Day 2 

 - Working with Large Objects  
 - Handling Properly Recursion and Iterative Calculations  
 - Managing loops; For (S-Plus) and for() loops  
 - Consequences of Lazy Evaluation  
 - Efficient Code Practices for Large Computations  
 - Memory Management and Resource Monitoring  
 - Writing R and S-plus Functions to call Compiled Code  
 - Writing and Debugging Compiled Code for S-plus and R system  
 - Connecting R to External Data Sources  
 - Macros in R  
 - Understanding the Structure of Model fitting Functions in R and
S-plus  
 - Designing and Packaging Efficiently a new model Function  

Payment due AFTER the class
Email us for group discounts.
Email Sue Turner: [EMAIL PROTECTED]
Phone: 206-686-1578
Visit us: www.xlsolutions-corp.com/courselist.htm
Please let us know if you and your colleagues are interested in this
class to take advantage of group discount. 

Register now to secure your seat!

Cheers,
Elvis Miller, PhD
Manager Training.
XLSolutions Corporation
206 686 1578
www.xlsolutions-corp.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] Fitting large titles in a plot

2007-12-06 Thread Jim Price

I have learned something new - thanks for the strwrap info.

The problem with posting from Nabble is that by the time your post actually
gets to the list (2 hours after you posted it in this case) and you've
written some line like Knowing the R list, someone can probably reduce this
function to 2 lines of code half a dozen people have already shown exactly
how you can do that, making me look totally incompetent.

Ah well, such is life :)

Jim.


Marc Schwartz wrote:
 
 
 On Thu, 2007-12-06 at 09:28 -0800, Jim Price wrote:
 I wrote a little utility function for exactly this reason, which I use
 with
 long titles. You may want to add calls to par to adjust the upper margin
 if
 you are using raw graphical functionality (plot et al) - but lattice
 adjusts
 the upper margin automatically so you wouldn't need to add anything else.
 
 
 PrettyString - function(theString, maxLength, collapse = \n)
 {
  words - unlist(strsplit(theString,  ))
  wordLengths - unlist(lapply(strsplit(words, ), length))
 
  if(max(wordLengths)  maxLength) 
  stop(maxChar must be increased due to string length)
 
  count = wordLengths[1]
  results = vector()
  currentLine = words[1]
 
  for(i in 2:length(words))
  {
  if((count + wordLengths[i] + 1)  maxLength)
  {
  results = c(results, currentLine)
  currentLine = words[i]
  count = wordLengths[i]
  }
  else
  {
  currentLine = paste(currentLine, words[i])
  count = count + wordLengths[i] + 1
  }
  }
  if(length(currentLine))
  results - c(results, currentLine)
 
  paste(results, collapse = collapse)
 }
 
 
 Knowing the R list, someone can probably reduce this function to 2 lines
 of
 code.
 Jim
 
 Would you believe one line?
 
   paste(strwrap(theString, width = maxLength), collapse = \n)
 
 ;-)
 
 See ?strwrap as I noted previously.
 
 HTH,
 
 Marc Schwartz
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/Fitting-large-titles-in-a-plot-tf4956510.html#a14201050
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] S3 and S4 clash

2007-12-06 Thread Prof Brian Ripley
I'd say that was pretty clearly a bug in stats4 (which as I recall was 
needed to get around the scoping awkwardnesses of S4).

But could you not write a logLik method for your class?  E.g.

 logLik.bar - function(object, ...) structure(pi, class=logLik, df=1)
 AIC(bar.tmp)
[1] -4.283185
 library(stats4)
 AIC(bar.tmp)
[1] -4.283185


On Thu, 6 Dec 2007, Spencer Graves wrote:

 Hello:

  How can I work around the conflict between the S3 and S4
 illustrated in the example below?  I'm developing a package that
 requires a function in 'stats4', but when 'stats4' is attached, it
 breaks my AIC function.  I could give my AIC function another name so it
 no longer uses the generic dispatch, but I wonder if there is another way.

  Thanks,
  Spencer Graves
 
 bar.tmp - structure(1, class = bar)
 AIC.bar - function(object, ..., k=2) {
  3
 }

  AIC(bar.tmp)
 [1] 3
  library(stats4)
  AIC(bar.tmp)
 Error in UseMethod(logLik) : no applicable method for logLik
  detach(package:stats4)
  AIC(bar.tmp)
 [1] 3
  objects()
 [1] AIC.bar bar.tmp
  sessionInfo()
 R version 2.6.1 (2007-11-26)
 i386-pc-mingw32

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

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

 loaded via a namespace (and not attached):
 [1] stats4_2.6.1

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


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

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


Re: [R] Java parser for R data file?

2007-12-06 Thread kchine
Dear David,

You may also consider using the biocep project' tools and frameworks. they
provide an advanced  bridge that allow you to exchange between R and Java
any standard R Object and any mapped S4 object.
the object extracted to Java (an RList for you data) can be serialized to
a file (saved as a java object). you can then read the serialized object
very easily from java and this is obviously  much faster than parsing and
more elegant than a proprietary serialization/deserialization .

the easiest way to achieve this is to create the Serialized RList via the
Virtual R Workbench (Universal IDE for R).
you can run the R workbench on any kind of OS via the biocep sources:
http://www.ebi.ac.uk/microarray-srv/frontendapp/BIOCEP_README.txt

or just use this link to get the software installed on your machine if you
are using Mac OS or windows
http://www.ebi.ac.uk/microarray-srv/frontendapp/rworkbench.jnlp

create your data via the workbench R Console (you may also use the script
editor or just read your list from a file)
go to the menu Java, choose Save R/Java Object to local file
select the name you've given to your list and choose a file name.

to retrieve your list in java, all you need is to add the RJB.jar to your
class path and use this simple code:

RList l=(RList)new ObjectInputStream(new
FileInputStream(J:/list.ser)).readObject();

and that's it.
this works for much more complex R objects (ExpressionSet..)

best wishes,

Karim



 On 12/5/07 12:15 PM, Prof Brian Ripley [EMAIL PROTECTED] wrote:

 On Wed, 5 Dec 2007, David Coppit wrote:

 Or, given that I'm dealing with just a single array, would it be better
 to
 roll my own I/O using write.table or write.matrix from the MASS package?

 It would be much easier.  The save() format is far more complex than you
 need.  However, I would use writeBin() to write a binary file and read
 that in in Java, avoiding the binary - ASCII - binary conversion.

 Thanks for the suggestion-writeBin works quite well. For posterity, here's
 what I did:

 On the R side:

 # Assumes that there are no special values in the tofList, such as
 NA_REAL,
 # R_PosInf, R_NegInf, ISNAN, R_FINITE. See the R Data Import/Export
 manual.
 saveListAsBinary - function( tofList, filename )
 {
   outConn - file( filename, wb );

   for (m in 1:length(tofList)) {
 writeBin(names(tofList)[[m]], outConn);
 writeBin(length(tofList[[m]]), outConn, size = 4, endian = big);
 writeBin(tofList[[m]], outConn, size = 4, endian = big);
   }

   close(outConn);
 }

 saveListAsBinary(myList, outfile.RDat);

 On the Java side:

   public static void read_R_Output(String filename, ArrayListString
 names,
   ArrayListArrayListFloat data)
   {
 try {
   DataInputStream dataInputStream = new DataInputStream(
 new BufferedInputStream(new FileInputStream(filename)));

   boolean endOfFile = false;

   while (!endOfFile) {
 try {
   StringBuffer sb = new StringBuffer();

   byte c;
   while ((c = dataInputStream.readByte()) != 0)
 sb.append((char)c);

   names.add(new String(sb));

   int cols = dataInputStream.readInt();

   ArrayListFloat row = new ArrayListFloat(cols);

   for (int i = 0; i  cols; i++)
 row.add(dataInputStream.readFloat());

   data.add(row);
 } catch (EOFException e) {
   endOfFile = true;
 }
   }

   dataInputStream.close();
 } catch (Exception e) {
   e.printStackTrace();
 }
   }

 Regards,
 David

   [[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] Integral implicit function

2007-12-06 Thread Eddy H. G. Bekkers
Hi,

Could somebody help me with the following. I want to calculate the integral 
over an implicit function. I thought to integrate over a function depending on 
uniroot. In previous topics I found a thread about finding the root of an 
integral. And that works. But the other way around, does not work. Does R 
support this?

I included the following example. The function in the example is very easy and 
can be solved explicitly, but when it does not work for such an easy function 
it will certainly not work for a more difficult function. First the root of an 
integral (which works) and then the integral of a function dependent on uniroot:

# Calculating the root of an integral

a- function(x,y)
{x-y}

b- function(y)
{integrate(a,lower=1,upper=2,y=y)$value}

d- uniroot(b,c(0,10))$root

print(d)

# Calculating the integral of a function dependent on uniroot

e- function(u,v)
{u-v}

f- function(v)
{uniroot(e,c(0,10),v=v)$root}

g- integrate(f,lower=1,upper=2)$value

print(g)

Does anyone have suggestions how to proceed? By the way, the implicit function 
I am targeting does have a unique solution, it is only not explicitly solvable, 
i.e. in the example above, you cannot solve u as a function of v explicitly, so 
as to substitute it in the integrand. 


Thanks a lot in advance for your help,

Best regards,

Eddy Bekkers
Department of Economics
Erasmus University Rotterdam

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] coxme() random effect syntax

2007-12-06 Thread Justin Montemarano
Hello:

I would like to run a Cox proportional hazards regression on crayfish 
dislodgement at different water velocities by crayfish size class and 
substrate (rock) type. Additionally, there is a covariate variable, rock 
movement that may be influencing crayfish dislodgment. So...

I have crayfish size class (CFSZCL) and substrate type (SUBSZ) as fixed 
factors influencing the dislodgment of crayfish at different water 
velocities (SLIPVEL). Thus, I am currently using the call:

coxph(Surv(SLIPVEL, FREEDOM) ~ CFSZCL + SUBSZ + CFSZCL:SUBSZ, data = 
data.table)

However, I would like to add rock movement (BEDLOAD) as a random 
co-variate, which is not possible with the coxph() function. Is it 
possible to do so with coxme() in the kinship package? If so, what is 
the proper syntax?

Thanks for any help.

Justin Montemarano

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


Re: [R] simple problems

2007-12-06 Thread Domenico Vistocco
marciarr wrote:
 Hello R users,
 I have been looking through Help files and Nabble list for the answers for
 these simple questions, but it seems to be fruitless.
 1- in a data frame with two columns, x and y, how do I get the corresponding
 value of x to, let's say, the minimum value of the y column (min (data$y)) ?
   
data$x2[data$x1==min(data$x1)]
 2- how do I solve a simple equation? Considering the equation y= exp(-x)^12,
 I would like to find the values of x for,  for example, y=0.01, so
 exp(-x)^12=0.01. How do I do that using R?
   
I know there is solve for linear equations, but I do not know if there is
a generic solver for other equations.
You could implement it using a numerical approach (perhaps it is yet in some
package).

domenico

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] row lables in heatmap.2()

2007-12-06 Thread affy snp
Dear list,

I am wondering if there are any parameters in heatmap.2
to be able to adjust the size of row labels. Or the size
of the plot can be made smaller. The plot I got is big
and cannot see the full row labels completely.

And what is the maximum of rows which could allow row
labels visible in the plot? Last time, I tried a matrix
of 2900 rows, but apparently the row labels are too
dense to see it clearly.

Any suggestions?

Allen

[[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] Testing Two Categorical Variable

2007-12-06 Thread ramin . 1981
The chi-square does not need your two categorical variables to have equal 
levels, nor limitation for the number of levels.

The Chi-square procedure is as follow:
χ^2=∑_(All Cells)▒〖(Observed-Expected)〗^2/Expected

Expected Cell= E_ij=n((i^th RowTotal)/n)((j^th RowTotal)/n)

Degree of Freedom=df= (row-1)(Col-1)

This way should not give you any errors if your calculations are all correct. I 
usually use SAS for calculations like this. Below is a sample code I wrote to 
test whether US_State and Blood type are independent. You can modify it for 
your data and should give you no error.

data bloodtype;
input bloodtype$ state$ count@@;
datalines;
A FL 122 B FL 117
AB FL 19 O FL 244
A IA 1781 B IA 351
AB IA 289 O IA 3301
A MO 353 B MO 269
AB MO 60 O MO 713
;
proc freq data=bloodtype;
tables bloodtype*state
/ cellchi2 chisq expected norow nocol nopercent;
weight count;
quit;


Best
Ramin

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

2007-12-06 Thread ramin . 1981
The chi-square does not need your two categorical variables to have equal 
levels, nor limitation for the number of levels.

The Chi-square procedure is as follow:
χ^2=∑_(All Cells)▒〖(Observed-Expected)〗^2/Expected

Expected Cell= E_ij=n((i^th RowTotal)/n)((j^th RowTotal)/n)

Degree of Freedom=df= (row-1)(Col-1)

This way should not give you any errors if your calculations are all correct. I 
usually use SAS for calculations like this. Below is a sample code I wrote to 
test whether US_State and Blood type are independent. You can modify it for 
your data and should give you no error.

data bloodtype;
input bloodtype$ state$ count@@;
datalines;
A FL 122 B FL 117
AB FL 19 O FL 244
A IA 1781 B IA 351
AB IA 289 O IA 3301
A MO 353 B MO 269
AB MO 60 O MO 713
;
proc freq data=bloodtype;
tables bloodtype*state
/ cellchi2 chisq expected norow nocol nopercent;
weight count;
quit;


Best
Ramin

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

2007-12-06 Thread Tao Shi

Hi list,

Sorry for the vague title, but here is the scenario.  

I’m writing an R package, let’s say, ‘pkg1’, which contains 3 functions: f1, 
f2, f3.  f2 and f3 are helper functions for f1, i.e. f1 calls f2 which in turn 
calls f3.

f1 - function(…) {
….
f2()
…
}

f2 - function(…){
…
f3(…)
…
}

f3 - function(...){
   
}

Then, I wrote a new version of f3 and I want to test it.  With the old version 
of ‘pkg1’ already loaded into my R session, I tried just copy-and-paste the new 
‘f3’ to R console and hope f1 will pick the new ‘f3’ up.  It obviously didn’t 
work.  I know it’s b/c the new f3 and old f3 are in different environments and 
when f1 is called, only old f3 is used.  Then I tried to change the environment 
of new f3 to the same as the old f3's by calling:

environment(f3) - environment(pkg1:::f3)

but it wasn't working either.

So,  
1)  Could somebody help me to put all these into perspectives?
2)  Is there an easier way to update f3 without rebuilding the package? (by 
that I mean, writing the new version of f3 in a way that I only need to 
copy-and-paste to R console and I’m good to go.  I know it’s kind of stupid but 
I’m curious to know) 

I'm using R-2.5.1, on WinXP.

Many thanks,

…Tao


_


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


Re: [R] simple problems

2007-12-06 Thread Gabor Grothendieck
On Dec 6, 2007 3:26 PM, marciarr [EMAIL PROTECTED] wrote:

 Hello R users,
 I have been looking through Help files and Nabble list for the answers for
 these simple questions, but it seems to be fruitless.
 1- in a data frame with two columns, x and y, how do I get the corresponding
 value of x to, let's say, the minimum value of the y column (min (data$y)) ?

In the builtin Formaldehyde data frame find the value of carb (first column)
which corresponds to the least value of optden (second column):

with(Formaldehyde, carb[which.min(optden)])

 2- how do I solve a simple equation? Considering the equation y= exp(-x)^12,
 I would like to find the values of x for,  for example, y=0.01, so
 exp(-x)^12=0.01. How do I do that using R?
 I know those a probably very, very simple questions, but for which I do not
 seem to find the answer.

Search between 0 and 1 for the root of the indicated function:

uniroot(function(x) 0.1 - exp(-x)^12, 0:1)

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


Re: [R] updating a helper function in a R package

2007-12-06 Thread Gabor Grothendieck
If you are using namespaces see:

?assignInNamespace

On Dec 6, 2007 5:38 PM, Tao Shi [EMAIL PROTECTED] wrote:

 Hi list,

 Sorry for the vague title, but here is the scenario.

 I'm writing an R package, let's say, 'pkg1', which contains 3 functions: f1, 
 f2, f3.  f2 and f3 are helper functions for f1, i.e. f1 calls f2 which in 
 turn calls f3.

 f1 - function(…) {
….
f2()
…
 }

 f2 - function(…){
…
f3(…)
…
 }

 f3 - function(...){
   
 }

 Then, I wrote a new version of f3 and I want to test it.  With the old 
 version of 'pkg1' already loaded into my R session, I tried just 
 copy-and-paste the new 'f3' to R console and hope f1 will pick the new 'f3' 
 up.  It obviously didn't work.  I know it's b/c the new f3 and old f3 are in 
 different environments and when f1 is called, only old f3 is used.  Then I 
 tried to change the environment of new f3 to the same as the old f3's by 
 calling:

 environment(f3) - environment(pkg1:::f3)

 but it wasn't working either.

 So,
 1)  Could somebody help me to put all these into perspectives?
 2)  Is there an easier way to update f3 without rebuilding the package? 
 (by that I mean, writing the new version of f3 in a way that I only need to 
 copy-and-paste to R console and I'm good to go.  I know it's kind of stupid 
 but I'm curious to know)

 I'm using R-2.5.1, on WinXP.

 Many thanks,

 …Tao


 _


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

2007-12-06 Thread David Rees
Hi,

I am having trouble plotting the graph I need given the follow kind of data

 xxx - data.frame(
   x=c(1,2,3,4,5),
   y1=c(2,4,3,5,6),
   y2=c(3,4,6,3,1),
   y3=c(1,3,5,7,3),
   z1=c(1,NA,3,5,NA),
   z2=c(2,NA,4,6,NA) )
 xxx
  x y1 y2 y3 z1 z2
1 1  2  3  1  1  2
2 2  4  4  3 NA NA
3 3  3  6  5  3  4
4 4  5  3  7  5  6
5 5  6  1  3 NA NA

What I need is the following

- One graph 
- y1, y2, y3 plotted as seperate lines vs x
- z1, z2 give the range of the value of z, and need to be plotted as error bars 
or confidence intervals vs x

Many thanks for any help,
Regards,
David

   
-

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