[R] RWinEdt installation problems with Vista

2007-09-10 Thread Kevin
Hi,

I was trying to install the packageRWinEdt in my computer with Vista OS.
Once I finished the installation, R just cannot load this library at all,
reporting some error information. I reinstalled R and Winedit and reloaded
this package. RWinEdt seemed to register in the computer but never work
again. I searched some related information on internet. I did try using
administer privilege to install R and Winedit. Ans I also opened it by run
as administrator. The problem still insisted.  R always report following
results.

Error in getRegistryKeyValues(createRegistryPath(path, top, isValue =
FALSE)) :
Error in get keys: The parameter is incorrect.
Error : .onAttach failed in 'attachNamespace'
Error: package/namespace load failed for 'RWinEdt'

If anyone can help me out on this issue? Thank you in advance.

Kevin

[[alternative HTML version deleted]]

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


[R] How to auto-scale cex of y-axis labels in lattice dotplot?

2007-07-25 Thread Kevin Wright
When I create a dotplot in lattice, I frequently observe overplotting
of the labels along the vertical axis.  On my screen, this illustrates
overplotting of the letters:

windows()
reps=6
dat=data.frame(let=rep(letters,each=reps), grp=rep(1:reps, 26),
  y=runif(26*reps))
dotplot(let~y|grp, dat)

Is there a way to automatically scale the labels so that they are not
over-plotted?

I currently do something like this:
Calculate or guess the number of panel rows: NumPanelRows
cexLab - min(1, .9*par()$pin[2]/
  (nlevels(dat$let)*NumPanelRows*strheight(A,units=in)))
dotplot(..., scales=list(y=list(cex=cexLab))

Is there an easier way?

Is there a function that I can call which calculates the layout of the
panels that will be used in the dotplot?

Any tips will be appreciated.

K Wright

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] gam function time trend splines

2007-07-02 Thread Kevin Sorensen
I've been doing a simple time-series analysis looking
at the relationship between daily pneumonia
hospitalizations and daily temperature.  To mimic some
of the literature, I've been including a time-trend to
try to account for normal cyclical trends in
hospitalization.  So I've been using a function that
looks something like this:

gam(pneucount ~ temp_f +
s(day,bs=cr,k=(4*totalyears)+1),

day being the enumerated day in the analysis (1-365
for a 1 year analysis). 

This seems to work well enough.  What troubles me is
when I think about doing an analysis focusing on
winter days using more than one year of data.  If I
just delete the summer days from the dataset, the time
trend spline is trying to anneal counts from the end
of one winter with the beginning of another, which
doesn't seem right to me.  

What's the route to a statistically defensible result?
 Is it as simple as using the subset option?  Or would
I need to create indicator variables for each winter
I'm interested and work in a by statement somehow
(with an extra term for the levels of that indicator,
I assume)?  

Thanks in advance for helping a Epi student who's
being exposed to all this for the first time.

Sincerely,

Kevin Sorensen 


  

Park yourself in front of a world of choices in alternative vehicles. Visit the 
Yahoo! Auto Green Center.

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


Re: [R] Tools For Preparing Data For Analysis

2007-06-22 Thread Kevin E. Thorpe
I am posting to this thread that has been quiet for some time because I
remembered the following question.

Christophe Pallier wrote:
 Hi,
 
 Can you provide examples of data formats that are problematic to read and
 clean with R ?

Today I had a data manipulation problem that I don't know how to do in R
so I solved it with perl.  Since I'm always interested in learning more
about complex data manipulation in R I am posting my problem in the
hopes of receiving some hints for doing this in R.

If anyone has nothing better to do than play with other people's data,
I would be happy to send the row files off-list.

Background:

I have been given data that contains two measurements of left
ventricular ejection fraction.  One of the methods is echocardiogram
which sometimes gives a true quantitative value and other times a
semi-quantitative value.  The desire is to compare echo with the
other method (MUGA).  In most cases, patients had either quantitative
or semi-quantitative.  Same patients had both.  The data came
to me in excel files with, basically, no patient identifiers to link
the both with the semi-quantitative patients (the both patients
were in multiple data sets).

What I wanted to do was extract from the semi-quantitative data file
those patients with only semi-quantitative.  All I have to link with
are the semi-quantitative echo and the MUGA and these pairs of values
are not unique.

To make this more concrete, here are some portions of the raw data.

Both

ID NUM,ECHO,MUGA,Semiquant,Quant
B,12,37,10,12
D,13,13,10,13
E,13,26,10,15
F,13,31,10,13
H,15,15,10,15
I,15,21,10,15
J,15,22,10,15
K,17,22,10,17
N,17.5,4,10,17.5
P,18,25,10,18
R,19,25,10,19

Seimi-quantitative

echo,muga,quant
10,20,0  -- keep
10,20,0  -- keep
10,21,0  -- remove
10,21,0  -- keep
10,24,0  -- keep
10,25,0  -- remove
10,25,0  -- remove
10,25,0  -- keep

Here is the perl program I wrote for this.

#!/usr/bin/perl

open(BOTH, quant_qual_echo.csv) || die Can't open quant_qual_echo.csv;
# Discard first row;
$_ = BOTH;
while(BOTH) {
chomp;
($id, $e, $m, $sq, $qu) = split(/,/);
$both{$sq,$m}++;
}
close(BOTH);

open(OUT,  qual_echo_only.csv) || die Can't open qual_echo_only.csv;
print OUT pid,echo,muga,quant\n;
$pid = 2001;

open(QUAL, qual_echo.csv) || die Can't open qual_echo.csv;
# Discard first row
$_ = QUAL;
while(QUAL) {
chomp;
($echo, $muga, $quant) = split(/,/);
if ($both{$echo,$muga}  0) {
$both{$echo,$muga}--;
}
else {
print OUT $pid,$echo,$muga,$quant\n;
$pid++;
}
}
close(QUAL);
close(OUT);

open(OUT,  both_echo.csv) || die Can't open both_echo.csv;
print OUT pid,echo,muga,quant\n;
$pid = 3001;

open(BOTH, quant_qual_echo.csv) || die Can't open quant_qual_echo.csv;
# Discard first row;
$_ = BOTH;
while(BOTH) {
chomp;
($id, $e, $m, $sq, $qu) = split(/,/);
print OUT $pid,$sq,$m,0\n;
print OUT $pid,$qu,$m,1\n;
$pid++;
}
close(BOTH);
close(OUT);


-- 
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Department of Public Health Sciences
Faculty of Medicine, University of Toronto
email: [EMAIL PROTECTED]  Tel: 416.864.5776  Fax: 416.864.6057

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

2007-06-22 Thread Oden, Kevin
I  am using R 2.5.0 on windows XP and trying to fit copula.  I see the
following code works for some users, however my code crashes on the
chol.   Any suggestions?

 

  mycop - tCopula(param=0.5, dim=8, dispstr=ex, df=5) 

  x - rcopula(mycop, 1000) 

  myfit - fitCopula(x, mycop, c(0.6, 10), optim.control=list(trace=1),
method=Nelder-Mead) 

  Nelder-Mead direct search function minimizer

function value for initial parameters = -1747.582044

  Scaled convergence tolerance is 2.6041e-05

Stepsize computed as 1.00

Error in chol(x, pivot = FALSE) : the leading minor of order 2 is not
positive definite

 

Kevin D. Oden

e: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] 

 


[[alternative HTML version deleted]]

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

2007-06-22 Thread Oden, Kevin
 I  am using R 2.5.0 on windows XP and trying to fit copula.  I see the
following code works for some users, however my code crashes on the
chol.   Any suggestions?

 

  mycop - tCopula(param=0.5, dim=8, dispstr=ex, df=5) 

  x - rcopula(mycop, 1000) 

  myfit - fitCopula(x, mycop, c(0.6, 10), optim.control=list(trace=1),
method=Nelder-Mead) 

  Nelder-Mead direct search function minimizer

function value for initial parameters = -1747.582044

  Scaled convergence tolerance is 2.6041e-05

Stepsize computed as 1.00

Error in chol(x, pivot = FALSE) : the leading minor of order 2 is not
positive definite

 

Kevin D. Oden

e: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] 

 


[[alternative HTML version deleted]]

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

2007-06-20 Thread Kevin E. Thorpe
elyakhlifi mustapha wrote:
 hello,
 is it possible to merge 2 matrix or data.frame by roxnames?
 I checked details about the functino merge but I haven't fond this option.
 Can you help me please?
 thanks.

The first paragraph of the Details section says:

By default the data frames are merged on the columns with names they
both have, but separate specifications of the columns can be given by
by.x and by.y. Columns can be specified by name, number or by a logical
vector: the name row.names or the number 0 specifies the row names.


-- 
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Department of Public Health Sciences
Faculty of Medicine, University of Toronto
email: [EMAIL PROTECTED]  Tel: 416.864.5776  Fax: 416.864.6057

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Confidence interval for coefficient of variation

2007-06-14 Thread Kevin Wright
This is a function I coded a few years ago to calculate a confidence
interval for a coefficient of variation.  The code is based on a paper
by Mark Vangel in The American Statistician.  I have not used the
function much, but it could be useful for comparing cv's from
different groups.

Kevin Wright


confint.cv - function(x,alpha=.05, method=modmckay){
  # Calculate the confidence interval of the cv of the vector x
  # Author: Kevin Wright
  # See: Vangel, Mark.  Confidence Intervals for a Normal Coefficient
  # of Variation. American Statistician, Vol 15, No1, p. 21--26.
  # x - c(326,302,307,299,329)
  # confint.cv(x,.05,modmckay)

  x - na.omit(x)
  v - length(x)-1
  mu - mean(x)
  sigma - sqrt(var(x))
  k - sigma/mu
  # CV  .33 may give poor results, so warn the user
  if(k.33) warning(Confidence interval may be very approximate.)

  method - casefold(method) # In case we see McKay

  if(method==mckay){
# McKay method.  See equation 15.
t1 - qchisq(1-alpha/2,v)/v
t2 - qchisq(alpha/2,v)/v
u1 - v*t1
u2 - v*t2
lower - k/sqrt(( u1/(v+1) -1)*k*k + u1/v)
upper - k/sqrt(( u2/(v+1) -1)*k*k + u2/v)
  } else if (method==naive){
# Naive method.  See equation 17.
t1 - qchisq(1-alpha/2,v)/v
t2 - qchisq(alpha/2,v)/v
lower - k/sqrt(t1)
upper - k/sqrt(t2)
  } else {
# Modified McKay method. See equation 16.
u1 - qchisq(1-alpha/2,v)
u2 - qchisq(alpha/2,v)
lower - k/sqrt(( (u1+2)/(v+1) -1)*k*k + u1/v)
upper - k/sqrt(( (u2+2)/(v+1) -1)*k*k + u2/v)
  }
  ci - c(lower,upper)
  attr(ci,CV) - k
  attr(ci,alpha) - alpha
  return(ci)
}

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


Re: [R] Sorting dataframe by different columns

2007-06-08 Thread Kevin Wright
On the R wiki site there is a general-purpose function
(sort.data.frame) that allows you to do this:

sort(df, by=~ x-z)

See: http://wiki.r-project.org/rwiki/doku.php?id=tips:data-frames:sort

Regards,

Kevin

On 6/8/07, Gunther Höning [EMAIL PROTECTED] wrote:
 Dear list,

 I have a very short question,
 Suggest a dataframe of four columns.

 df - data.frame(w,x,y,z)

 I want this ordered the following way:
 first by :x, decreasing = FALSE
 and
 secondly by: z, decreasing =TRUE

 How can this be done ?

 Thanks

 Gunther

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

2007-06-06 Thread Kevin E. Thorpe
Yanqin Yang wrote:
 Hello,
 
 I am new in using Linux R. Would someone tell me what the best way to
 update my current R 2.3.0 to R 2.5.0? I want to keep my current
 library packages. Do I have to erase the older version and install
 the newer version? In that case, I need to re-download all the
 packages I need. Any short way to do the update?
 
 Thanks for your help!
 
 yanqin
 

Since I compile from source, I simply compile the new version and
install it to the same location as the old.  Then I run
update.packages() to update the additional packages I have
installed. Of course, I may get bit by this approach one day.

It is possible to have more than one directory for packages.
One suggestion I've seen is to collect your user installed
packages in a different directory than the base and recommended
packages.

-- 
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Department of Public Health Sciences
Faculty of Medicine, University of Toronto
email: [EMAIL PROTECTED]  Tel: 416.864.5776  Fax: 416.864.6057

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Metropolis-Hastings Markov Chain Monte Carlo in Spatstat

2007-06-06 Thread Kevin C Packard
I'm testing some different formulations of pairwise interaction point processes
in Spatstat (version 1.11-6) using R 2.5.0 on a Windows platform and I wish to
simulate them using the Metropolis-Hastings algorithm implemented with Spatstat.
Spatstat utilizes Fortran77 code with the preprocessor RatFor to do the
Metropolis-Hastings MCMC, but the Makefile is more complicated than any I have
worked with.
Any suggestions on how I could get started working with the Fortran code in
conjunction with RatFor is appreciated.

Sincerely,
Kevin

Kevin Packard
Department of Forestry, PhD student
Department of Statistics, MS student
Virginia Polytechnic Institute and State University
Blacksburg, Virginia, USA

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


Re: [R] Logrank test

2007-06-01 Thread Kevin E. Thorpe
See ?survdiff in the survival package.


Mbini wrote:
 Hi 
 
 I have a problem with computing the logrank test using R, can someone give
 me the relavent code or help me otherwise please!
 
 Thanks


-- 
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Department of Public Health Sciences
Faculty of Medicine, University of Toronto
email: [EMAIL PROTECTED]  Tel: 416.864.5776  Fax: 416.864.6057

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Competing Risks Analysis

2007-05-25 Thread Kevin E. Thorpe
I am working on a competing risks problem, specifically an analysis of
cause-specific mortality.  I am familiar with the cmprsk package and
have used it before to create cumulative incidence plots.  I also came
across an old (1998) s-news post from Dr. Terry Therneau describing
a way to use coxph to model competing risks.  I am re-producing the
post at the bottom of this message.

I would like to know if this approach is still reasonable or are there
other ways to go now.  I did an RSiteSearch with the term
competing risks and found some interesting articles but nothing as
specific as the post below.


- S-news Article Begins -
Competing risks

It's actually quite easy.

Assume a data set with n subjects and 4 types of competing events. Then
create a data set with 4n observations
First n obs: the data set you would create for an analysis of
time to event type 1, where all other event types are censored. An
extra variable etype is =1.
Second n obs: the data set you would create for time to event type 2,
with etype=2
.
.
.

Then
fit - coxph(Surv(time,status) ~  + strata(etype), 

1. Wei, Lin, and Weissfeld apply this to data sets where the competing
risks are not necessarily exclusive, i.e., time to progression and time
to death for cancer patients. JASA 1989, 1065-1073. If a given subject
can have more than one event, then you need to use the sandwich estimate
of variance, obtained by adding .. + cluster(id).. to the model
statement above, where id is variable unique to each subject.
(The method of fitting found in WLW, namely to do individual fits and
then glue the results together, is not necessary).

2. If a given subject can have at most one event, then it is not clear
that the sandwich estimate of variance is necessary. See Lunn and McNeil,
Biometrics (year?) for an example.

3. The covariates can be coded any way you like. WLW put in all of the
strata * covariate interactions for instance (the x coef is different for
each event type), but I never seem to have a big enough sample to justify
doing this. Lunn and McNeil use a certain coding of the treatment effect,
so that the betas are a contrast of interest to them; I've used similar
things
but never that particular one.

4. etype doesn't have to be 1,2,3,... of course; etype= 'paper',
'scissors', 'stone', 'pc' would work as well.

Terry M. Therneau, Ph.D.
- S-news Article Ends -

-- 
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Department of Public Health Sciences
Faculty of Medicine, University of Toronto
email: [EMAIL PROTECTED]  Tel: 416.864.5776  Fax: 416.864.6057

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Parsing data with an uneven number of delimiters

2007-05-03 Thread Kevin Burke
I have a list of data that is delimited by a / and, as long as there is an 
equal number of delimiters, I can parse the data and put it into a data frame:

 t1-c(a/a/a,b/bb/bbb,ccc/cc/c)
 t2-strsplit(t1,/)
 t3-data.frame(t2)
 t3
  c..aaa.. c..bbbbbb.. c..cccccc..
1a   b ccc
2a  bb  cc
3a bbb   c

However, if I don't have an equal number of delimiters, this technique doesn't 
work:

 l1-c(a/a/a,b/bb/bbb,cc/c)
 l2-strsplit(l1,/)
 l3-data.frame(l2)
Error in data.frame(c(a, a, a), c(b, bb, bbb), c(cc, c : 
arguments imply differing number of rows: 3, 2

Is there an easy way to get this into a data frame with NA's (or something 
else) where the missing data would be?

Thanks in advance.

Kevin Burke

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] SweaveInput and absolute paths

2007-04-27 Thread Kevin R. Coombes
The path is correct, and the file exists.  Here is a transcript of the R 
session:

-
  sessionInfo()
R version 2.4.0 (2006-10-03)
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] methods   stats graphics  grDevices utils  datasets
[7] base
  getwd()
[1] G:/Working/Fidler-Nakamura-Periphery
  dir(M:/Resources/Affymetrix)
  [1] affyExample.Rnw affyExample.tex affyplots.Rnw  chkMiame.Rnw
  [5] fnp.Rnw libLoad.Rnw readCel.Rnwrma.Rnw
  [9] rnadeg.Rnw  simpleQC.Rnw
  Sweave(affyExample.Rnw)
Writing to file affyExample.tex
Processing code chunks ...
Error in SweaveReadFile(c(ifile, file), syntax) :
 no Sweave file with name 
'./M:/Resources/Affymetrix/libLoad.Rnw' found
In addition: Warning message:
list.files: './M:/Resources/Affymetrix' is not a readable directory
-

Dieter Menne writes:
  Kevin R. Coombes krc at mdacc.tmc.edu writes:
 
  
   Is there a way to turn off the automatic inclusion of ./ at the
   beginning of a path specified in an \SweaveInput{} instruction?
  
 
  Giving a full file path name works for me (Windows, R 2.4.1)
 
  \SweaveInput{C:/tmp/MyTitle.rnw}
 
  Note the if the path does not exist, e.g
 
  \SweaveInput{C:/tmpnotexist/MyTitle.rnw},
 
  the error message refert to  ./C:/tmpnotexist/MyTitle.rnw, so it
  could be that the path you chose had been incorrectly entered.
 
  Dieter

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] SweaveInput and absolute paths

2007-04-26 Thread Kevin R. Coombes
Hi,

Is there a way to turn off the automatic inclusion of ./ at the 
beginning of a path specified in an \SweaveInput{} instruction?

I'd like to create some reusable template modules of Sweave code and 
put them in a standard directory like
/Resources/Affymetrix
Then the corresponding file that uses one of these would include a 
command like

\SweaveInput{/Resources/Affymetrix/libload.Rnw}

If I try that (in R 2.4.0 on either Windows or UNIX), however, I get an 
error message to the following effect:

Writing to file affyExample.tex
Processing code chunks ...
Error in SweaveReadFile(c(ifile, file), syntax) :
no Sweave file with name './/Resources/Affymetrix/libload.Rnw' found
In addition: Warning message:
list.files: './/Resources/Affymetrix' is not a readable directory

Of course it cannot find the files if it insists on looking in the wrong 
place

On a related note, where is SweaveInput documented besides in the R help 
archives?

Thanks,
Kevin

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


Re: [R] sorting data in R

2007-04-20 Thread Kevin Wright
Now that sort is a generic function, I have modified my original
sort.data.frame function to be s 'data.frame' method to sort.  (You
now have to specify the formula as the 'by' argument).

See the R Wiki:
http://wiki.r-project.org/rwiki/doku.php?id=tips:data-frames:sorts=sort%20data

There are also some other tips on that page for sorting.

Kevin Wright


On 4/20/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

 Hi

 Best function for sorting which i have used and many in the community :-)
 HTH Cheers

 sort.data.frame(Oats, ~ -nitro + Variety)

 Feedback and improvements are welcome.

 sort.data.frame - function(form,dat){
   # Author: Kevin Wright
   # Some ideas from Andy Liaw
   #   http://tolstoy.newcastle.edu.au/R/help/04/07/1076.html

   # Use + for ascending, - for decending.
   # Sorting is left to right in the formula

   # Useage is either of the following:
   # library(nlme); data(Oats)
   # sort.data.frame(~-Variety+Block,Oats) # Note: levels(Oats$Block)
   # sort.data.frame(Oats,~nitro-Variety)

   # If dat is the formula, then switch form and dat
   if(inherits(dat,formula)){
 f=dat
 dat=form
 form=f
   }
   if(form[[1]] != ~)
 stop(Formula must be one-sided.)

   # Make the formula into character and remove spaces
   formc - as.character(form[2])
   formc - gsub( ,,formc)
   # If the first character is not + or -, add +
   if(!is.element(substring(formc,1,1),c(+,-)))
 formc - paste(+,formc,sep=)

   # Extract the variables from the formula
   if(exists(is.R)  is.R()){
 vars - unlist(strsplit(formc, [\\+\\-]))
   }
   else{
 vars - unlist(lapply(unpaste(formc,-),unpaste,+))
   }
   vars - vars[vars!=] # Remove spurious  terms

   # Build a list of arguments to pass to order function
   calllist - list()
   pos=1 # Position of + or -
   for(i in 1:length(vars)){
 varsign - substring(formc,pos,pos)
 pos - pos+1+nchar(vars[i])
 if(is.factor(dat[,vars[i]])){
   if(varsign==-)
 calllist[[i]] - -rank(dat[,vars[i]])
   else
 calllist[[i]] - rank(dat[,vars[i]])
 }
 else {
   if(varsign==-)
 calllist[[i]] - -dat[,vars[i]]
   else
 calllist[[i]] - dat[,vars[i]]
 }
   }
   dat[do.call(order,calllist),]

 }










 elyakhlifi mustapha [EMAIL PROTECTED]
 Sent by: [EMAIL PROTECTED]
 20-04-07 03:30 PM

 To
 R-help@stat.math.ethz.ch
 cc

 Subject
 [R] sorting data in R






 hello,
 I'd  like  know how to sort a data frame in R for example how I should do
 to sort by Catholic with swiss data frame like below
 thanks

  Fertility Agriculture Examination Education Catholic
 Infant.Mortality
 Courtelary80.217.0  1512 9.9622.2
 Delemont  83.145.1   6 984.8422.2
 Franches-Mnt  92.539.7   5 593.4020.2
 Moutier   85.836.5  12 733.7720.3
 Neuveville76.943.5  1715 5.1620.6
 Porrentruy76.135.3   9 790.5726.6
 Broye 83.870.2  16 792.8523.6
 Glane 92.467.8  14 897.1624.9
 Gruyere   82.453.3  12 797.6721.0
 Sarine82.945.2  161391.3824.4
 Veveyse   87.164.5  14 698.6124.5
 Aigle 64.162.0  2112 8.5216.5
 Aubonne   66.967.5  14 7 2.2719.1
 Avenches  68.960.7  1912 4.4322.7
 Cossonay  61.769.3  22 5 2.8218.7
 Echallens 68.372.6  18 224.2021.2
 Grandson  71.734.0  17 8 3.3020.0
 Lausanne  55.719.4  262812.1120.2
 La Vallee 54.315.2  3120 2.1510.8
 Lavaux65.173.0  19 9 2.8420.0
 Morges65.559.8  2210 5.2318.0
 Moudon65.055.1  14 3 4.5222.4
 Nyone 56.650.9  221215.1416.7
 Orbe  57.454.1  20 6 4.2015.3
 Oron  72.571.2  12 1 2.4021.0
 Payerne   74.258.1  14 8 5.2323.8
 Paysd'enhaut  72.063.5   6 3 2.5618.0
 Rolle 60.560.8  1610 7.7216.3
 Vevey 58.326.8  251918.4620.9
 Yverdon   65.449.5  15 8 6.1022.5
 Conthey   75.585.9   3 299.7115.1
 Entremont 69.3

[R] Problem saving xYplot graph to file

2007-04-13 Thread Kevin E. Thorpe
Hello.

I am having a problem directing the results of xYplot in the Hmisc
package to a file.  First I'll give you my sessionInfo and then my
data and code, afterwhich I'll describe my problem.

 sessionInfo()
R version 2.4.1 Patched (2007-02-26 r40806)
i686-pc-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_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C

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

other attached packages:
  lattice Hmisc   acepack
0.14-16   3.3-1 1.3-2.2

`pcs.means.sd` -
structure(list(group = structure(as.integer(c(1, 2, 1, 2, 1,
2, 1, 2)), .Label = c(Strength, Aerobic), class = factor),
vis = c(0, 0, 2, 2, 6, 6, 18, 18), pcs = c(39.0334828308696,
36.9953199347826, 41.8490848139535, 39.0470522655814, 44.9146868080952,
41.04989196775, 46.4435591345946, 39.928985488), sd = c(8.6865669448865,
8.133546159086, 8.73403314236636, 8.34564558942182, 9.95941054193798,
10.7706814575657, 8.88934684511587, 10.9269199038043)), .Names =
c(group,
vis, pcs, sd), row.names = c(1, 2, 3, 4, 5, 6,
7, 8), class = data.frame)

Ylim - c(pcs.means.sd$pcs-pcs.means.sd$sd-1,
pcs.means.sd$pcs+pcs.means.sd$sd+1)
trellis.device(postscript,color=FALSE,file=pcs.ps)
xYplot(Cbind(pcs,pcs-sd,pcs+sd)~vis,data=pcs.means.sd,groups=group,type='b',
method=bands,scales=list(x=list(at=c(0,2,6,18))),
ylim=Ylim,xlab=Months,ylab=PCS)
dev.off()

Now, when I call xYplot without the trellis.device() and dev.off() the
graph I want displays on the screen.  When I try this with the
trellis.device() the plot is only partially created.  The axes are drawn
but the actual plot area is empty except for the curve labels,
although these are plotted on to of each other in the wrong place.

I also tried putting my xYplot() inside a print() which gave the same
results.

-- 
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Department of Public Health Sciences
Faculty of Medicine, University of Toronto
email: [EMAIL PROTECTED]  Tel: 416.864.5776  Fax: 416.864.6057

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 alpha transparency for lines in levelplot - SUMMARY

2007-03-29 Thread Kevin Wright
I reported a similar issue with Adobe Reader in a thread starting here:
http://tolstoy.newcastle.edu.au/R/e2/devel/06/10/0706.html

K Wright



On 3/27/07, Michael Sumner [EMAIL PROTECTED] wrote:
 Hello, thanks to Deepayan Sarkar for sorting me out on this one.

 The problem with transparent lines affecting region colour in lattice
 plot appears
 when using Adobe Reader (v 8 in my case). I've only viewed the file on
 Windows XP.

 I've tried using Foxit Reader to view the file and there's no problem.

 Cheers, Mike.

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Implementing trees in R

2007-03-16 Thread Yuk Lap Yip (Kevin)
Hi all,

I am rather new to R. Recently I have been trying to implement some 
tree algorithms in R. I used lists to model tree nodes. I thought 
something like this would work:

parent - list();
child - list();
parent$child1 - child;
child$parent - parent;

When I tried to check whether a node is its parent's first child 
using if (node$parent$child1 == node), it always returned false. Then 
I realized that it does not really work because parent$child1 - child 
actually makes a copy of child instead of referencing it. I think one 
possible fix is to keep a list of node objects, and make references 
using the positions in the list. For example, I think the following 
would work:

parent - list();
child - list();
nodes - list(parent, child);
parent$child1 - 2;
child$parent - 1;

Then the first child test can be rewritten as if 
(nodes[[nodes[[nodeId]]$parent]]$child1 == nodeId). However, I would 
prefer not to implement trees in this way, as it requires the 
inconvenient and error-prone manipulations of node IDs.

May I know if there is a way to make object references to lists? Or 
are there other ways to implement tree data structures in R?

BTW, I checked how hclust was implemented, and noticed that it calls 
an external Fortran program. I would want a solution not involving any 
external programs.

Thanks.

-- 


God bless.

Kevin

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


Re: [R] Implementing trees in R

2007-03-16 Thread Yuk Lap Yip (Kevin)
Hi Gabor,

Thanks for the suggestions. I tried to look for the proto vignette 
document but could not find it, could you tell me how to reach it?

Besides, is it possible to define my own node object type with a 
default behavior for the - operator of its member variables being 
referencing rather than copying? Any good reference material/ similar 
code examples?

Thanks.

Gabor Grothendieck wrote:
 Lists are not good for this.  There is an example in section 3.3 of
 the proto vignette of using proto objects for this.  That section
 also references an S4 example although its pretty messy with S4.

 You might want to look at the graph, RBGL and graphviz packages
 in Bioconductor and the dynamicgraph, mathgraph and sna packages
 on CRAN.

 On 3/16/07, Yuk Lap Yip (Kevin) [EMAIL PROTECTED] wrote:
 Hi all,

I am rather new to R. Recently I have been trying to implement some
 tree algorithms in R. I used lists to model tree nodes. I thought
 something like this would work:

parent - list();
child - list();
parent$child1 - child;
child$parent - parent;

When I tried to check whether a node is its parent's first child
 using if (node$parent$child1 == node), it always returned false. Then
 I realized that it does not really work because parent$child1 - child
 actually makes a copy of child instead of referencing it. I think one
 possible fix is to keep a list of node objects, and make references
 using the positions in the list. For example, I think the following
 would work:

parent - list();
child - list();
nodes - list(parent, child);
parent$child1 - 2;
child$parent - 1;

Then the first child test can be rewritten as if
 (nodes[[nodes[[nodeId]]$parent]]$child1 == nodeId). However, I would
 prefer not to implement trees in this way, as it requires the
 inconvenient and error-prone manipulations of node IDs.

May I know if there is a way to make object references to lists? Or
 are there other ways to implement tree data structures in R?

BTW, I checked how hclust was implemented, and noticed that it calls
 an external Fortran program. I would want a solution not involving any
 external programs.

Thanks.

 -- 


God bless.

Kevin

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


-- 


God bless.

Kevin

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


Re: [R] Implementing trees in R

2007-03-16 Thread Yuk Lap Yip (Kevin)
Gabor,

Thanks. That helps a lot.

Gabor Grothendieck wrote:
 On 3/16/07, Gabor Grothendieck [EMAIL PROTECTED] wrote:
 1. Here is your example redone using proto:

 library(proto)

 parent - proto()
 child - proto(a = 1)
 parent$child1 - child
 child$parent.env - parent

 This last line should have been:

 parent.env(child) - parent



 # also just for illustration lets change a

 parent$child1$a # 1
 child$a - 2
 parent$child1$a # 2

 2. To redefine $- use S3 or S4 but it can be done
 in conjunction with proto like this:

 # constructor
 node - function(. = parent.frame(), ...)
   structure(proto(...), class = c(node, proto))

 $-.node - function(this, s, value) {
if (s == .super)
parent.env(this) - value
if (is.function(value))
environment(value) - this
if (inherits(value, node))
parent.env(value) - this
this[[as.character(substitute(s))]] - value
this
 }


 p - node(a = 1)
 p$child - node(b = 2)
 p$child$parent.env()
 p # same



 On 3/16/07, Yuk Lap Yip (Kevin) [EMAIL PROTECTED] wrote:
  Hi Gabor,
 
 Thanks for the suggestions. I tried to look for the proto vignette
  document but could not find it, could you tell me how to reach it?
 
 Besides, is it possible to define my own node object type with a
  default behavior for the - operator of its member variables being
  referencing rather than copying? Any good reference material/ similar
  code examples?
 
 Thanks.
 
  Gabor Grothendieck wrote:
   Lists are not good for this.  There is an example in section 3.3 of
   the proto vignette of using proto objects for this.  That section
   also references an S4 example although its pretty messy with S4.
  
   You might want to look at the graph, RBGL and graphviz packages
   in Bioconductor and the dynamicgraph, mathgraph and sna packages
   on CRAN.
  
   On 3/16/07, Yuk Lap Yip (Kevin) [EMAIL PROTECTED] wrote:
   Hi all,
  
  I am rather new to R. Recently I have been trying to 
 implement some
   tree algorithms in R. I used lists to model tree nodes. I thought
   something like this would work:
  
  parent - list();
  child - list();
  parent$child1 - child;
  child$parent - parent;
  
  When I tried to check whether a node is its parent's first child
   using if (node$parent$child1 == node), it always returned 
 false. Then
   I realized that it does not really work because parent$child1 
 - child
   actually makes a copy of child instead of referencing it. I 
 think one
   possible fix is to keep a list of node objects, and make references
   using the positions in the list. For example, I think the following
   would work:
  
  parent - list();
  child - list();
  nodes - list(parent, child);
  parent$child1 - 2;
  child$parent - 1;
  
  Then the first child test can be rewritten as if
   (nodes[[nodes[[nodeId]]$parent]]$child1 == nodeId). However, I 
 would
   prefer not to implement trees in this way, as it requires the
   inconvenient and error-prone manipulations of node IDs.
  
  May I know if there is a way to make object references to 
 lists? Or
   are there other ways to implement tree data structures in R?
  
  BTW, I checked how hclust was implemented, and noticed that 
 it calls
   an external Fortran program. I would want a solution not 
 involving any
   external programs.
  
  Thanks.
  
   --
  
  
  God bless.
  
  Kevin
  
   __
   R-help@stat.math.ethz.ch mailing list
   https://stat.ethz.ch/mailman/listinfo/r-help
   PLEASE do read the posting guide
   http://www.R-project.org/posting-guide.html
   and provide commented, minimal, self-contained, reproducible code.
  
 
  --
 
 
 God bless.
 
 Kevin
 
 


-- 


God bless.

Kevin

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


Re: [R] Sweave question: prevent expansion of unevaluated reused code chunk

2007-03-14 Thread Kevin R. Coombes
Hi,

I don't know of a standard way to indicate this; I would have suggested

combined,expand=FALSE

(with expand=TRUE the default), except for the fact that Seth Falcon 
already suggested the same notation in his response...so I can only 
second the motion.

Kevin

Duncan Murdoch wrote:
 On 3/13/2007 7:02 PM, Kevin R. Coombes wrote:
 Hi,

 Consider the following (much simplified) Sweave example:

 --

 First, we set the value of $x$:
 chunk1,eval=FALSE=
 x - 1
 @

 Then we set the value of $y$:
 chunk2,eval=FALSE=
 y - 2
 @

 Thus, the overall algorithm has this structure:
 combined,eval=FALSE=
 chunk1
 chunk2
 @

 justDoIt,echo=FALSE=
 combined
 @

 ---

 I'd like to be able to do something like this, where the combined 
 chunk prints out in the final LaTeX document essentially verbatim.  In 
 particular, I want to see the chunk1 unexpanded in that block, 
 since this gives me a nice conceptual overview of the algorithm. (Of 
 courser, this is more useful when chunk1 and chunk2 are much longer 
 than they are in this example)

 Is there an option that allows me to get this behavior?
 
 As others have said, the answer is currently no, but in R 2.5.0 this 
 should be a relatively easy modification (because it has the ability to 
 echo your input, rather than a deparsed version of it).  In the other 
 platforms you've used, is there a standard syntax to indicate whether or 
 not you want the chunks expanded?  I can see either behaviour as being 
 desirable in different circumstances.  Sometimes you want the reader to 
 know about your chunk names, and sometimes you don't.
 
 Duncan Murdoch

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


[R] Sweave question: prevent expansion of unevaluated reused code chunk

2007-03-13 Thread Kevin R. Coombes
Hi,

Consider the following (much simplified) Sweave example:

--

First, we set the value of $x$:
chunk1,eval=FALSE=
x - 1
@

Then we set the value of $y$:
chunk2,eval=FALSE=
y - 2
@

Thus, the overall algorithm has this structure:
combined,eval=FALSE=
chunk1
chunk2
@

justDoIt,echo=FALSE=
combined
@

---

I'd like to be able to do something like this, where the combined 
chunk prints out in the final LaTeX document essentially verbatim.  In 
particular, I want to see the chunk1 unexpanded in that block, 
since this gives me a nice conceptual overview of the algorithm. (Of 
courser, this is more useful when chunk1 and chunk2 are much longer than 
they are in this example)

Is there an option that allows me to get this behavior?

Thanks,
Kevin

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


Re: [R] Sweave question: prevent expansion of unevaluated reused code chunk

2007-03-13 Thread Kevin R. Coombes
[1] In the example I presented, you're right; I can just use a verbatim 
environment. In the following more complicated example

combined,eval=FALSE
if (some.condition) {
chunk1
} else {
chunk2
}
@

I would still want to be able to see the outline of what is going on, 
and a verbatim environment wouldn't work.

[2] You are also correct that there is no advantage if I just call them 
chunk1 and chunk2. But if I call them something more interesting, 
like perform.quantile.normalization or truncate.and.log.transform,
then I can use this structure to explain the algorithm at a higher 
level.  If you go back to Knuth's original literate programming 
examples, this is exactly how he presents his examples. For instance, on 
page 104 of the Literate Programming book, he has

Program to print the first thousand prime numbers 2 =
program print_primes(output);
   const m = 1000; other constants of the program 5
   var Variables of the program 4
 begin Print the first m prime numbers 3;
 end.

Of course, he's writing pascal instead of R. But the stuff between  
are the program chunks, and he is displaying them without expanding the 
chunks. And, as a result, You get to see a high-level picture of the 
algorithm, keeping the details somewhere else.

Since I'm looking at the results of weave in Knuth's example, I don't 
know if he is using a verbatim environment or is automatically 
generating this using his implementation of weave for teX and pascal

But that's the idea.

Kevin

Seth Falcon wrote:
 Kevin R. Coombes [EMAIL PROTECTED] writes:
 
 Hi,

 Consider the following (much simplified) Sweave example:

 --

 First, we set the value of $x$:
 chunk1,eval=FALSE=
 x - 1
 @

 Then we set the value of $y$:
 chunk2,eval=FALSE=
 y - 2
 @

 Thus, the overall algorithm has this structure:
 combined,eval=FALSE=
 chunk1
 chunk2
 @

 justDoIt,echo=FALSE=
 combined
 @

 ---

 I'd like to be able to do something like this, where the combined 
 chunk prints out in the final LaTeX document essentially verbatim.  In 
 particular, I want to see the chunk1 unexpanded in that block, 
 since this gives me a nice conceptual overview of the algorithm. (Of 
 courser, this is more useful when chunk1 and chunk2 are much longer than 
 they are in this example)

 Is there an option that allows me to get this behavior?
 
 Maybe I'm not understanding what it is you want, but why not:
 
 \begin{verbatim}
 chunk1
 chunk2
 \end{verbatim}
 
 What does putting this in an unevaluated chunk buy you?  The
 chunkName markers are an internal detail of the document and so
 must of the time these never appear in the rendered output.  Even in
 your example, won't it be confusing that chunk1 and chunk2
 won't have appeared in labels earlier in the rendered document?
 
 + seth


__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Another newbie book recommandation question

2007-03-01 Thread Zembower, Kevin
I hope this question is sufficiently different from the other requests
for book recommendations that it's not repetitious. If not, I apologize
in advance.

I'm curious what standard reference books working statisticians, or
biostatisticians, have within easy reach of their desk. I'm a computer
systems administrator, and have a two-foot bookshelf directory under my
monitor that contains 13 paperback manuals that I refer to frequently,
some once or twice a day. Are there standard reference works for
statisticians that are used the same way? From reading this list, I'm
guessing that one might be W. N. Venables and B. D. Ripley (2002),
Modern Applied Statistics with S. Fourth Edition, Springer, ISBN
0-387-95457-0. However, I'm not limiting this to books pertaining to R.

On the other hand, maybe Google and other on-line sources, as well as
interactive programs like R that can spit out numbers previously looked
up in tables, have completely replaced the need for reference books. Is
this the case today?

I'm particularly interested in reference books that may be helpful in my
organization's work. We typically deal with datasets from international
Demographic and Health Surveys (DHS) similar to those available at
http://www.measuredhs.com/aboutsurveys/search/search_survey_main.cfm?Srv
yTp=typelisttypes=1. These typically contain 10,000+ respondents and
can have up to 800 fields. We currently analyze these datasets using
Stata.

Thanks for taking the time to think about and respond to this question.
I'll summarize the answers in a later post for the archive.

-Kevin

Kevin Zembower
Internet Services Group manager
Center for Communication Programs
Bloomberg School of Public Health
Johns Hopkins University
111 Market Place, Suite 310
Baltimore, Maryland  21202
410-659-6139

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 using Sweave with wireframe or cloud

2007-02-22 Thread Kevin E. Thorpe
Matthieu Cornec wrote:
 Hi,
 
 
 I used the sweave package to get a 3D plot
 
 echo=F,fig=F=
 wireframe(volcano, shade = TRUE,
   aspect = c(61/87, 0.4),
   light.source = c(10,0,10))
 @
 
 but it gives an error message for the pdf file of this picture.
 
 Any one could help ?
 

Try this.

echo=FALSE,fig=TRUE=
library(lattice)
print(wireframe(volcano, shade = TRUE, aspect = c(61/87, 0.4),
light.source = c(10,0,10)))
@


 Thanks in advance,
 
 Matthieu
 


-- 
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Department of Public Health Sciences
Faculty of Medicine, University of Toronto
email: [EMAIL PROTECTED]  Tel: 416.864.5776  Fax: 416.864.6057

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] NEWBIE: @BOOK help?

2007-02-08 Thread Zembower, Kevin
In Henric's recent post, he included this output:

@BOOK{R:Harrell:2001,
  AUTHOR = {Frank E. Harrell},
  TITLE = {Regression Modeling Strategies, with Applications to
  Linear Models, Survival Analysis and Logistic
  Regression},
  PUBLISHER = {Springer},
  YEAR = 2001,
  NOTE = {ISBN 0-387-95232-2},
  URL = {http://biostat.mc.vanderbilt.edu/twiki/bin/view/Main/RmS}
}

Can someone tell me how this is generated? I've noticed this in a few
recent posts. I attempted:

RSiteSearch(@BOOK)
?BOOK
?book

but it didn't return anything useful.

Thanks.

-Kevin

Kevin Zembower
Internet Services Group manager
Center for Communication Programs
Bloomberg School of Public Health
Johns Hopkins University
111 Market Place, Suite 310
Baltimore, Maryland  21202
410-659-6139

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


Re: [R] Sweave, Xfig, pdflatex and \setkeys

2006-12-12 Thread Kevin E. Thorpe
David Lindelöf wrote:
 Dear useRs,
 
 How does one include graphics created with Xfig with LaTeX fonts into
 Sweave?
 
 If I create a graphic with Xfig with some Computer Modern fonts, I
 choose to export it as combined PDF and LaTeX. So I get two files, one
 foo.pdf with the drawings without the text and foo.pdftex with some
 LaTeX code that ensures the text lands in the right place together with
 the drawing. I'm supposed to \input{} this file in my LaTeX document.
 
 Trouble is that Sweave defines (with \setkeys) the default width of
 \includegraphics to be 0.8 times the \textwidth. The result is that the
 graphic is scaled, but not the text.
 
 I was looking for a way to temporarily undefine the default width of
 included graphics, but without success. Does anyone know how to undo a
 definition that has been set with \setkeys?
 
 Or does anyone has another workaround for including xfig graphics with
 LaTeX text in Sweave?
 
 Looking forward to your help,

If you knew what setting you needed, you could try

\setkeys{Gin}{width=whatever}

before your include, and set it back to the default afterward with

\setkeys{Gin}{width=0.8\textwidth}

I have run into this myself, but since I was also using beamer, it
wasn't at all obvious what I should try for the setting, so I don't
know if this will work.  I have used this to rescale the imported
graphics from R.  Fortunately, the graphic I created in xfig could
be completely specified in LaTeX, and so I exported it in that format
and imported it with \scalebox{0.5}{\input{xfigfile.latex}}

-- 
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Department of Public Health Sciences
Faculty of Medicine, University of Toronto
email: [EMAIL PROTECTED]  Tel: 416.864.5776  Fax: 416.864.6057

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

2006-12-09 Thread Ko-Kang Kevin Wang
Hi David,

You can export the graphs in (encapsulated) postscript format, or in 
PDF/PNG/JPEG format.  The following functions may be helpful:
   postscript()
   png()
   pdf()

You may also want to check out Sweave 
(http://www.ci.tuwien.ac.at/~leisch/Sweave/), it allows you to integrate 
LaTeX and R neatly.

Cheers,

Kevin

David Kaplan wrote:
 Hi all,
 
 I have started using LaTeX for writing papers and I have heard that R 
 works well with LaTeX.  I'm specifically interested in how I can have 
 LaTeX read in R generated graphics - for example graphs formed by 
 matplot, or other such  processes.  Does anyone out there use LaTeX and 
 can point me in the right direction?
 
 Thanks
 
 David
 
 
 


-- 
Ko-Kang Kevin Wang
Ph (H): +61-2-612 57471
Ph (M): +61-40-4518301
http://wwwmaths.anu.edu.au/~wangk/personal/

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] cat not evaluated before file.choose

2006-11-25 Thread Kevin Middleton
As part of a larger function I have code similar to the reduced  
example below. The user is instructed to choose a file, which gets  
read using read.csv. In this example, I just have the name of the  
file print out.

When I call this function with choosefile(), the file dialog box  
appears before the first cat line is printed. After I choose a file,  
both cat lines are printed.

choosefile - function (){
cat(Choose the data file.\n)
filename - file.choose(new = FALSE)
cat(You chose: , filename, sep = )
}

Is there a way to force the first cat line to print before the call  
to file.choose? I'm using R 2.4.0 Patched (2006-11-24 r39989) on OS  
X. Session info below.

Any suggestions would be greatly appreciated.

Kevin Middleton

---

  sessionInfo()
R version 2.4.0 Patched (2006-11-24 r39989)
powerpc-apple-darwin8.8.0

locale:
en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

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


Re: [R] confige error:X11 headres/libs

2006-11-14 Thread Kevin E. Thorpe
Prof Brian Ripley wrote:
 Please do as the file INSTALL asks and read the R-admin.html file.
 It says
 
 Remember that some package management systems (such as RPM and deb) make a 
 distinction between the user version of a package and the development 
 version. The latter usually has the same name but with the extension 
 `-devel' or `-dev': you need both versions installed.
 
 Unless you do not want to view graphs on-screen you need `X11' installed, 
 including its headers and client libraries. (On Fedora Core Linux this 
 means the `xorg-x11-devel' and `xorg-x11-libs' RPMs, for example. Older 
 Linuxen used `XFree86-'. Some Debian derivatives apparently also require 
 `libxt-dev'.) If you really do not want these you will need to explicitly 
 configure R without X11, using --with-x=no.
 

They have the same names on my SuSE 9.2 installation as Prof. Ripley
indicated for a Fedora Core system.

On SuSE, you need to install these packages with YaST (assuming that's
what you are using for system admin).

 
 
 On Tue, 14 Nov 2006, thomas phillipson wrote:
 
 Can someone who uses SuSe Linux (I currently use 9.3) please tell me what I
 need toto to avoid the
 message

 configure: error: --with-x=yes (default) and X11 headers/libs are not
 available

 without setting --with-x=no

 currently my /usr/lib/X11 directory looks like this

 ls /usr/lib/X11
 app-defaults  fvwm2  nlstwm  XErrorDB   Xmodmap
 Cards getconfig  Optionswmmount  xinit  Xmodmap.remote
 etc   icons  proxymngr  x11perfcomp  xkbXresources
 fonts lbxproxy   rgb.txtxdm  XKeysymDB  xserver
 fslocale rstart xeditxman.help  xsm


 thanks
 tom


-- 
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Department of Public Health Sciences
Faculty of Medicine, University of Toronto
email: [EMAIL PROTECTED]  Tel: 416.946.8081  Fax: 416.946.3297

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Next useR conference date/location

2006-11-14 Thread Kevin Wright
Are there any tentative plans for the next useR conference?

I ask because I will soon need to develop an expense budget for 2007
and wondered if the conference is switching to an annual meeting or
will continue every two years.

Thanks for any information

K Wright

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Unexpected behavior of predict and interval=confidence

2006-10-29 Thread Kevin Middleton

Based on some recent r-help discussions, I have been trying out  
plotting confidence intervals using predict and matplot. Matplot  
appeared to not be plotting the linear regression when using the  
default column names generated by read.table (V1, V2, etc). On  
further inspection, the error seemed to be with predict and vector  
names (V1, V2) rather than with matplot. I was using some textbook  
data sets that were read with read.table, so my data.frame columns  
were named by default. The problem seems to be related to the name of  
the vector only (though I may be wrong).

The example below, based on that in ?predict.lm, better describes the  
problem. Using predict with V2~V1  y~x produces identical output  
(when x-V1 and y-V2). However, using predict with  
interval=confidence results in different output from the same data.  
That with y~x is correct, and V2~V1 is incorrect.

This may be related to a previous post on r-help:
http://finzi.psych.upenn.edu/R/Rhelp02a/archive/56982.html

I can't figure out why there would be a difference in predict when  
only the vector name seemingly changes. Granted, I could just read  
the data.frame is as x and y.

Thanks
Kevin

##

set.seed(10)

# For example purposes, plot side by side
par(mfrow=c(1,2))

V1 - rnorm(15)
V2 - V1 + rnorm(15)

new - data.frame(x = seq(min(V1), max(V1), length.out = length(V1)))

pred.w.clim - predict(lm(V2 ~ V1), new, interval=confidence)
matplot(new$x, pred.w.clim,
 lty=c(1,2,2), type=l,
 col=c(black, red, red),
 ylab=predicted y)
points(V1,V2)


# Create x  y equal to V1  V2
x - V1
y - V2

pred.w.clim2 - predict(lm(y ~ x), new, interval=confidence)
matplot(new$x, pred.w.clim2,
 lty=c(1,2,2), type=l,
 col=c(black, red, red),
 ylab=predicted y)
points(x,y)

# Test if V1=x, V2=y
all.equal(x,V1)
all.equal(y,V2)

# Same output with predict
predict(lm(V2 ~ V1))
predict(lm(y ~ x))
all.equal(predict(lm(V2 ~ V1)), predict(lm(y ~ x)))

# Different output with interval=confidence
pred.w.clim
pred.w.clim2
all.equal(pred.w.clim, pred.w.clim2)

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Newbie: Better way to do compound conditionals in subset?

2006-10-26 Thread Zembower, Kevin
There must be a better way to select the rows after 22-Apr-2004 and
before 01-Sep-2004 with a temperature below 65 than this:

 before2sw1 - subset(energy.data, as.Date(start, format=%d-%b-%y) 
as.Date(01-Sep-04, format = %d-%b-%y))
 before2sw2 - subset(before2sw1, as.Date(start, format=%d-%b-%y) =
as.Date(22-Apr-04, format = %d-%b-%y), select=c(therms,temp,days))
 before2sw - subset(before2sw2, temp  65)

Is it also possible to combine in this step:

attach(before2sw)
before2sw.HDD - therms / (65 - temp) * days

My data looks like this:
 head(energy.data)
  start therms   gas KWHs elect temp days
1 10-Jun-98  9 16.84  613 63.80   75   40
2 20-Jul-98  6 15.29  721 74.21   76   29
3 18-Aug-98  7 15.73  597 62.22   76   29
4 16-Sep-98 42 35.81  460 43.98   70   33
5 19-Oct-98105 77.28  314 31.45   57   29
6 17-Nov-98106 77.01  342 33.86   48   30


Thanks for your suggestions and advice. I'm continuing to enjoy learning
R.

-Kevin

Kevin Zembower
Internet Services Group manager
Center for Communication Programs
Bloomberg School of Public Health
Johns Hopkins University
111 Market Place, Suite 310
Baltimore, Maryland  21202
410-659-6139

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


Re: [R] Dataset on Baltimore home energy costs

2006-10-21 Thread Zembower, Kevin
Sorry, dumb typo. Should be 18-Dec-2005. -Kevin



From: Richard M. Heiberger [mailto:[EMAIL PROTECTED]
Sent: Fri 10/20/2006 5:43 PM
To: Zembower, Kevin
Subject: Re: [R] Dataset on Baltimore home energy costs



Thanks for the data.  Can you clarify the date here.

18-Dec-2006: Brought home son; spouse and son home during the day,
setback thermostat no longer used. Interesting question: What's the
cost of adding a child?


It's still October, so I am not at all sure which year this should be.

Rich



[[alternative HTML version deleted]]

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


Re: [R] I really don't understand functions in R :-)

2006-10-20 Thread Kevin E. Thorpe
Is this what you want?

 f - function(x,n=3) x^n
 f(2)
[1] 8
 n - 2
 f(2)
[1] 8
 f(2,2)
[1] 4


Alberto Monteiro wrote:
 An example:
 
 n - 3
 f - function(x) x^n
 f(2)
 # [1] 8
 n - 2
 f(2)
 # [1] 4
 f
 # function(x) x^n
 
 Ok, I know this is trivial, because function f is foverer bound 
 to the variable n. But how can I _fix_ n when I define _f_, so 
 that changing _n_ won't change the function f?
 
 Alberto Monteiro


-- 
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Department of Public Health Sciences
Faculty of Medicine, University of Toronto
email: [EMAIL PROTECTED]  Tel: 416.946.8081  Fax: 416.946.3297

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Dataset on Baltimore home energy costs

2006-10-20 Thread Zembower, Kevin
I received a private request for my complete dataset from my previous
questions. In gratitude to the developers of R, and especially to the
helpful members of r-help, I'm happy to attach it. Anyone is free to use
this dataset in any manner they wish, including published books.
Attribution is not required, or even desired.

Explanatory notes on dataset:
This data is collected from monthly utility bills for my 80 year old
house in northern Baltimore City, Maryland, USA. The fields are:
start: date of start of billing period
therms: integer number of therms used in this billing period
gas: Total cost of gas (including delivery and commodity charges) for
natural gas
KWHs: integer number of KWH used in this billing period
elect: Total cost of electricity (including delivery and commodity
charges)
temp: average daily outdoor temperature in degrees Fahrenheit, as
printed on the bill
days: number of days in billing period.

Heating system is a 10-15 year old natural gas steam boiler supplying
iron radiators. Hot water heater, clothes dryer and stove and oven are
also natural gas. Air conditioning is by various numbers of window
units. If surface area of house is desired, I can add this at a later
time.

Some interesting points in time:
22-Apr-04: Date when I upgraded 2 failed, older storm windows to more
modern ones. 
1-Sep-04: Date when I upgraded 4 failed, older storm windows to more
modern ones. Interesting question: Did upgrading the windows
significantly change the heat loss?
last week of July 1999: Spouse moved in; both adults absent during the
work day, setback thermostat used. Interesting question: Is there a
discernable difference in the energy costs for heating between a single
person and a couple? What's the heating cost of adding a spouse or
roommate?
18-Dec-2006: Brought home son; spouse and son home during the day,
setback thermostat no longer used. Interesting question: What's the
cost of adding a child?

If I could supply any more information that would make this dataset more
useful or interesting, please let me know. I'm having fun 'playing' with
these data; I hope you and your students do, too.

-Kevin
start   therms  gas KWHselect   tempdays
10-Jun-98   9   16.84   613 63.80   75  40
20-Jul-98   6   15.29   721 74.21   76  29
18-Aug-98   7   15.73   597 62.22   76  29
16-Sep-98   42  35.81   460 43.98   70  33
19-Oct-98   105 77.28   314 31.45   57  29
17-Nov-98   106 77.01   342 33.86   48  30
17-Dec-98   200 136.66  298 30.08   40  33
19-Jan-99   144 107.28  278 28.37   37  30
18-Feb-99   179 122.80  253 26.21   39  29
16-Apr-99   57  49.81   315 31.56   54  32
18-May-99   8   17.11   373 40.57   64  30
17-Jun-99   6   15.77   596 62.12   73  33
20-Jul-99   6   15.88   723 74.41   77  29
18-Aug-99   7   16.69   532 55.94   76  30
17-Sep-99   45  42.20   551 50.81   66  32
19-Oct-99   107 82.87   367 36.00   55  29
16-Dec-99   245 166.94  490 46.56   42  33
18-Jan-00   267 183.35  395 38.40   33  30
17-Feb-00   147 99.77   448 42.95   38  32
20-Mar-00   94  72.39   395 38.40   49  29
18-Apr-00   50  46.87   363 35.65   56  29
17-May-00   25  28.63   457 48.68   64  33
19-Jun-00   5   16.53   525 55.26   70  31
20-Jul-00   7   18.23   511 51.64   74  28
17-Aug-00   8   19.22   538 53.95   72  33
19-Sep-00   51  60.78   390 34.98   65  30
19-Oct-00   91  94.72   364 33.18   56  28
16-Nov-00   241 226.93  465 40.19   44  33
19-Dec-00   289 287.52  423 37.28   33  31
19-Jan-01   174 197.69  348 32.07   33  28
16-Feb-01   145 163.59  338 31.38   39  32
20-Mar-01   121 122.53  346 31.93   45  29
18-Apr-01   47  50.94   370 33.60   55  29
17-May-01   16  23.99   460 48.11   65  34
20-Jun-01   7   17.25   447 46.98   71  29
19-Jul-01   6   15.81   589 59.40   75  32
20-Aug-01   6   15.66   433 45.76   74  29
18-Sep-01   44  39.27   419 36.24   66  31
19-Oct-01   97  74.58   356 31.98   56  27
15-Nov-01   120 91.27   484 40.65   51  33
18-Dec-01   183 154.37  393 34.45   43  30
17-Jan-02   170 134.35  394 34.52   38  33
19-Feb-02   142 120.94  331 30.27   43  28
19-Mar-02   88  71.53   393 34.45   48  30
18-Apr-02   47  48.19   389 34.18   57  29
20-Jun-02   5   15.92   625 61.40   78  32
22-Jul-02   5   15.90   656 64.04   80  25
19-Aug-02   6

Re: [R] binom.test

2006-10-19 Thread Kevin E. Thorpe
See also the binconf function in the Hmisc package.

Ethan Johnsons wrote:
 R-experts:
 
 A quick question, please.
 
From a lab exp, I got 12 positives out of 50.
 To get 90% CI for this , I think binom.test might be the one to be used.
 Is there a better way or function to calculate this?
 
 binom.test(x=12, n=50, p=12/50, conf.level = 0.90)
 
 Exact binomial test
 
 data:  12 and 50
 number of successes = 12, number of trials = 50, p-value = 1
 alternative hypothesis: true probability of success is not equal to 0.24
 90 percent confidence interval:
  0.1447182 0.3596557
 sample estimates:
 probability of success
   0.24
 
 thx much
 
 ej
 


-- 
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Department of Public Health Sciences
Faculty of Medicine, University of Toronto
email: [EMAIL PROTECTED]  Tel: 416.946.8081  Fax: 416.946.3297

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Newbie: Selecting data

2006-10-19 Thread Zembower, Kevin
I've been working with R for all of about 8 hours, so anyone with more
experience than this should be able to help me. General comments about
my methods of work are also welcomed.

I have a table that I've imported thusly:
 w - read.table(woodford.data, header=T)
 w
   start thermsgas KWHs  elect temp days
1  10-Jun-98  9  16.84  613  63.80   75   40
2  20-Jul-98  6  15.29  721  74.21   76   29
3  18-Aug-98  7  15.73  597  62.22   76   29
4  16-Sep-98 42  35.81  460  43.98   70   33
5  19-Oct-98105  77.28  314  31.45   57   29
6  17-Nov-98106  77.01  342  33.86   48   30
snip

[This is real data on my house.] 'days' is number of days in bill,
'temp' is average temperature in Fahrenheit. I'd like to see if there is
a relationship between the gas burned (therms) and the number of heating
degree days.

I compute therms per day and heating degree days like this:
 thermsperday - w[,2]/w[,7]
 hdd - (w[,6] -65)*w[,7]

However, I only want the data for the months in which the average
temperature is less than 65 (otherwise, it's a cooling degree day). I
tried ifelse, but couldn't get it to work. What simple technique am I
overlooking?

Thanks so much for your help and suggestions, especially for your
patience with a newbie.

-Kevin

Kevin Zembower
Internet Services Group manager
Center for Communication Programs
Bloomberg School of Public Health
Johns Hopkins University
111 Market Place, Suite 310
Baltimore, Maryland  21202
410-659-6139

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Book recommendation for newbie to stats and R?

2006-10-17 Thread Zembower, Kevin
I'm trying to learn statistics and R at the same time. I have an
undergraduate science degree and one year of calculus (30 years ago),
but never took a stats course. I hope to take some stats courses in the
next year, but thought I would start to see how much I could teach
myself.

I work for an organization that analyses behavior change communication
programs regarding HIV/AIDS and reproductive health. A typical question
we're trying to answer is, Watching which television programs in South
Africa is related to an increased use of condoms? All of our work is in
the social sciences, I'd say. I'd like to help analyze our data using R.

I found these titles that may teach me both stats and R:
--Data Analysis and Graphics Using R by John Maindonald, John Braun
--Introductory Statistics with R by Peter Dalgaard
--Statistics: An Introduction using R by Michael J. Crawley
--Using R for Introductory Statistics by John Verzani

I recognize some of the authors by their postings here.

Can anyone recommend any of these books over the others? I'm interested
in a book that I can learn statistics by reading the chapters and
working out the exercises and problems, therefore having access to many
or all of the problem solutions is important.

Do you have any other recommendations for me in learning both R and
stats? Is it an impossible quest to learn enough stats by myself to be
useful in analyzing real data sets?

Thanks so much for your advice and suggestions.

Kevin Zembower
Center for Communication Programs
Bloomberg School of Public Health
Johns Hopkins University
www.jhuccp.org

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

2006-08-11 Thread Kevin E. Thorpe
Bill Knebel wrote:
 Is there any package in R to create a SAS transport file?  I checked the 
 help archive and did not find any references to creating SAS transport 
 files in R, only reading them.
 
 Bill
 

I have used write.foreign in the foreign package.  This
produces a text data file and a SAS program to read the
data into SAS.

It has worked well for my uses.  As for exporting to a
transport file directly, I do not know.

-- 
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Department of Public Health Sciences
Faculty of Medicine, University of Toronto
email: [EMAIL PROTECTED]  Tel: 416.946.8081  Fax: 416.946.3297

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] lme4 and lmeSplines

2006-08-02 Thread Kevin Wright
I'm trying to use the lmeSplines package together with lme4.

Below is (1) an example of lmeSplines together with nlme (2) an
attempt to use lmeSplines with lme4 (3) then a comparison of the
random effects from the two different methods.

(1)

require(lmeSplines)
data(smSplineEx1)
dat - smSplineEx1
dat.lo - loess(y~time, data=dat)
plot(dat.lo)
dat$all - rep(1,nrow(dat))
times20 - seq(1,100,length=20)
Zt20 - smspline(times20)
dat$Zt20 - approx.Z(Zt20, times20, dat$time)
fit1.20 - lme(y~time, data=dat, random=list(all=pdIdent(~Zt20-1)))
# Loess model
dat.lo - loess(y~time, data=dat)
plot(dat.lo)
# Spline model
with(dat, lines(fitted(fit1.20)~time, col=red))
# Save random effects for later
ranef.nlme - unlist(ranef(fit1.20))

(2) Now an attempt to use lme4:

library(lmeSplines)
detach(package:nlme)
library(lme4)
data(smSplineEx1)
# Use 20 spline in lme4
dat - smSplineEx1
times20 - seq(1,100,length=20)
Zt20 - smspline(times20)
dat - cbind(dat, approx.Z(Zt20, times20, dat$time))
names(dat)[4:21] - paste(Zt,names(dat)[4:21],sep=)
dat$all - rep(1, nrow(dat))
fit1.20 - lmer(y~time
 
+(-1+Zt1|all)+(-1+Zt2|all)+(-1+Zt3|all)+(-1+Zt4|all)+(-1+Zt5|all)+(-1+Zt6|all)
 
+(-1+Zt7|all)+(-1+Zt8|all)+(-1+Zt9|all)+(-1+Zt10|all)+(-1+Zt11|all)+(-1+Zt12|all)
 
+(-1+Zt13|all)+(-1+Zt14|all)+(-1+Zt15|all)+(-1+Zt16|all)+(-1+Zt17|all)+(-1+Zt18|all),
 data=dat)
#summary(fit1)
# Plot the data and loess fit
dat.lo - loess(y~time, data=dat)
plot(dat.lo)
# Fitting with splines
with(dat, lines(fitted(fit1.20)~time, col=red))
ranef.lme4 - unlist(ranef(fit1.20))

(3) Compare nlme lme4 random effects

plot(ranef.nlme~ranef.lme4)

The plot of fitted values from lme4 is visually appealing, but the
random effects from lme4 are peculiar--three are non-zero and the rest
are essentially zero.

Any help in getting lme4 + lmeSplines working would be appreciated.
It is not unlikely that I have the lmer syntax wrong.

Kevin Wright

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] grouping by consecutive integers

2006-07-24 Thread Kevin J Emerson
Hello R-helpers!

I have a question concerning extracting sequence information from a
vector.  I have a vector (representing the bins of a time series where
the frequency of occurrences is greater than some threshold) where I
would like to extract the min, median and max of each group of
consecutive numbers.

For Example:

tmp - c(24,25,29,35,36,37,38,39,40,41,42,43,44,45,46,47,68,69,70,71)

I would like to have the max,min,median of the following groups:

24,25
29
35,36,37,38,39,40,41,42,43,44,45,46,47,
68,69,70,71

I would like to be able to perform this for many time series so an
automated process would be nice.  I am hoping to use this as a peak
detection protocol.

Any advice would be greatly appreciated,
Kevin

-
-
Kevin J Emerson
Center for Ecology and Evolutionary Biology
1210 University of Oregon
Eugene, OR 97403
USA
[EMAIL PROTECTED]

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


Re: [R] grouping by consecutive integers

2006-07-24 Thread Kevin J Emerson
Let me clarify one thing that I dont think I made clear in my posting.
I am looking for the max, min and median of the indicies, not of the
time series frequency counts.  I am looking to find the max, min, and
median time of peaks in a time series, so i am looking for the
information concerning that. 

so mostly my question is how to extract the information of max, min, and
median of sequential numbers in a vector.  I will reword my original
posting below.

  Hello R-helpers!
 
  I have a question concerning extracting sequence information from a
  vector.  I have a vector (representing the bins of a time series where
  the frequency of occurrences is greater than some threshold) where I
  would like to extract the min, median and max of each group of
  consecutive numbers in the index vector..
 
  For Example:
 
  tmp - c(24,25,29,35,36,37,38,39,40,41,42,43,44,45,46,47,68,69,70,71)
 
  I would like to have the max,min,median of the following groups:
 
  24,25 - max = 25, min = 24 median = 24.5
  29 max=min=median = 29
  35,36,37,38,39,40,41,42,43,44,45,46,47, max = 45 min = 35 etc...
  68,69,70,71
 
  I would like to be able to perform this for many time series so an
  automated process would be nice.  I am hoping to use this as a peak
  detection protocol.
 
  Any advice would be greatly appreciated,
  Kevin
 
  -
  -
  Kevin J Emerson
  Center for Ecology and Evolutionary Biology
  1210 University of Oregon
  Eugene, OR 97403
  USA
  [EMAIL PROTECTED]
 
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] throwaway() function

2006-07-20 Thread Kevin E. Thorpe
John Wiedenhoeft wrote:
 Dear all,
 
 I apologize if this is a FAQ (seems a bit like one, but I didn't find
 anything).
 
 I'm looking for an easy way to cut one value out of a vector and shorten
 the vector accordingly. Something like:
 
 x - c(1, 1, 0, 6, 2)
 throwaway(x[3])
 
 which will return x = 1 1 6 2, with length(x) = 4. I know one could do
 this by hand, but then one would have to create a second vector y in a
 loop which has to be 1 shorter then x and then assign x - y, as there
 is no anti-c() function which shortens a vector (at least to my
 knowledge).
 
 Is there some kind of a throwaway() function in R?
 
 Best regards,
 John

x[-3] works.


-- 
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Department of Public Health Sciences
Faculty of Medicine, University of Toronto
email: [EMAIL PROTECTED]  Tel: 416.946.8081  Fax: 416.946.3297

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Getting rid of for loops

2006-07-16 Thread Kevin J Emerson
Hello R-users!

I have a style question.  I know that for loops are somewhat frowned upon in
R, and I was trying to figure out a nice way to do something without using
loops, but figured that i could get it done quickly using them.  I am now
looking to see what kind of tricks I can use to make this code a bit more
aesthetically appealing to other R users (and learn something about R along
the way...).

Here's the problem.  I have a data.frame with 4 columns of dependent
variables and then ~35 columns of predictor variables (factors) [for those
interested, it is a qtl problem, where the predictors are genotypes at DNA
markers and the dependent variable is a biological trait].  I want to go
through all pairwise combinations of predictor variables and perform an
anova with two predictors and their interaction on a given dependent
variable.  I then want to store the p.value of the interaction term, along
with the predictor variable information.  So I want to end up with a
dataframe at the end with the two variable names and the interaction p value
in each row, for all pairwise combinations of predictors.  I used the
following code:

# qtl is the original data.frame, and my dependent var in this case is
# qtl$CPP.

marker1 - NULL
marker2 - NULL
p.interaction - NULL
for ( i in 5:40) {   # cols 5 - 41 are the predictor factors
for (j in (i+1):41) {
marker1 - rbind(marker1,names(qtl)[i])
marker2 - rbind(marker2,names(qtl)[j])
tmp2 - summary(aov(tmp$CPP ~ tmp[,i] * tmp[,j]))[[1]]
p.interaction - rbind(p.interaction, tmp2$Pr(F)[3])
}
}

I have two questions:
(1) is there a nicer way to do this without having to invoke for loops?
(2) my other dependent variables are categorical in nature.  I need
basically the same information - I am looking for information regarding the
interaction of predictors on a categorical variable.  Any ideas on what
tests to use? (I am new to analysis of all-categorical data).

Thanks in advance!
Kevin

--
--
Kevin Emerson
Center for Ecology and Evolutionary Biology
1210 University of Oregon
Eugene, OR 97403
USA
[EMAIL PROTECTED]

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


[R] Mixing grid and base graphics--need help understanding this quirk

2006-06-27 Thread Kevin Wright
My setup: Windows 2000, R 2.3.1

When I start a brand new session of R and paste the code below into R,
the graphic device shows Some text in the lower left corner.  If I
paste the code into the command window again, then Some text does
not appear in the lower left corner.  Why is this?

require(grid)
par(mfrow=c(1,2))
plot(1:10)
plot(-10:1)
par(mfrow=c(1,1))
pushViewport(viewport(.04, .04, width=stringWidth(Some text),
height=unit(2,lines),
  name=pagenum, gp=gpar(fontsize=10)))
grid.text(Some text, gp=gpar(col=gray30),
  just=c(left,bottom))
popViewport()


Kevin Wright

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


Re: [R] modeling logit(y/n) using lrm

2006-06-16 Thread Kevin E. Thorpe
Hamilton, Cody wrote:
 I have a dataset at a hospital level (as opposed to the patient level)
 that contains number of patients experiencing events (call this number
 y), and the number of patients eligible for such events (call this
 number n).  I am trying to model logit(y/n) = XBeta.  In SAS this can be
 done in PROC LOGISTIC or GENMOD with a model statement such as: model
 y/n = predictors;.  Can this be done using lrm from the Hmisc library
 without restructuring the dataset so that for each hospital there is one
 row with y = 1 and one row with y = 0 and then using the weight option
 in lrm to weight these two responses by the number of 'successes' and
 'failures' for that hospital, respectively?  I would like to avoid the
 restructuring, and I understand that the use of the weight function is
 not compatible with a lot of the validation functions available in Hmisc
 (validate, bootcov, etc.).

I don't know about lrm, but for glm you can do
glm(cbind(y,m)~ ...) where y is number of successes and
m is the number of failures.

So, you might try that.

 Cody Hamilton, Ph.D
 
 Institute for Health Care Research and Improvement
 
 Baylor Health Care System
 
 (214) 265-3618
 


-- 
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Department of Public Health Sciences
Faculty of Medicine, University of Toronto
email: [EMAIL PROTECTED]  Tel: 416.946.8081  Fax: 416.946.3297

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


Re: [R] xyplot problem

2006-06-15 Thread Kevin E. Thorpe
Marc Bernard wrote:
 Dear all,

   I have created  the following data (that you can run) in order to  explain 
 my problem:

   y - rep(c(1,2), 8)
   id - rep(1:8,each=2)
 x1 - rep(c(-a,+a), each = 8)
 x2 - rep(c(-b,+b), each = 2, times = 4)
 x3 - rep(c(-c, +c), each = 4,2)
 df - data.frame(cbind(id,y,x1,x2,x3))

   If I do:

   xyplot(y~ x3|x1*x2,data=df,groups=id,type = b)

   then my id's  are joined by lines which is what I want. However when I 
 wanted to add an horizontal line for each panel by using panel.abline the 
 lines disapears, i.e.

   xyplot(y~ x3|x1*x2,data=df,groups=id,type = b,panel=function(x,y)
 {
 panel.xyplot(x,y)
 panel.abline(h=1.5)
 }
 ) 


   I would be grateful if someone can tell me how can I correct the second 
 statement in order to have horizontal lines for each panel and each id are 
 joined  by lines.

   Thank you,

   Bernard,

This appears to work for me.

xyplot(y~ x3|x1*x2,data=df,groups=id,type = b,
   panel=function(x,y,groups,...) {
 panel.superpose(x,y,groups,...)
 panel.abline(h=1.5)})


-- 
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Department of Public Health Sciences
Faculty of Medicine, University of Toronto
email: [EMAIL PROTECTED]  Tel: 416.946.8081  Fax: 416.946.3297

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


[R] DSC 2005 proceedings?

2006-06-13 Thread Kevin Wright
This page:
http://depts.washington.edu/dsc2005/
says the proceedings for DSC 2005 will be published online and that
the papers were due in final form by September 2005.

Anyone know if the proceedings have been published yet or when (if?)
they will be published?

Thanks.

Kevin Wright

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


Re: [R] text plots?

2006-05-12 Thread Kevin E. Thorpe
This may not help, but if you have S-Plus on the machine you're
connecting to, it has a printer() device for this sort of thing.

Robert Citek wrote:
 Is there a way to do text plots in R?
 
 I'd like to do some simple XY plots in R with the output in text  
 (ascii).  For example, with gnuplot I can do the following:
 
 echo 'set terminal dumb ; plot sin(x)' | gnuplot
 
 To generate a simple sin wave.  Since I connect to a remote Linux  
 machine using SSH, being able to generate a rough idea of what a plot  
 will look like in text would be of benefit.  I've looked at ?plot, ? 
 par, and ?plot.default but didn't see anything obvious.
 
 Regards,
 - Robert


-- 
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Department of Public Health Sciences
Faculty of Medicine, University of Toronto
email: [EMAIL PROTECTED]  Tel: 416.946.8081  Fax: 416.946.3297

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


Re: [R] text plots?

2006-05-12 Thread Kevin E. Thorpe
François Pinard wrote:
 [Robert Citek]
 
 Is there a way to do text plots in R?  I'd like to do some simple XY 
 plots in R with the output in text  (ascii).  Since I connect to 
 a remote Linux machine using SSH, being able to generate a rough idea 
 of what a plot will look like in text would be of benefit.
 
 Note that it is easy with SSH to open a graphics connection, you may use 
 ssh -X to force it.  Than, R will show you nice graphics even if run 
 remotely.
 

I had forgotton about that.  I just did a quick test.  I SSHd into my
home PC from my office (it's a 455 MHz PII), started the X11() device
and ran example(xyplot).  I was suprised by the speed.  It was faster
than I expected it to be.

-- 
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Department of Public Health Sciences
Faculty of Medicine, University of Toronto
email: [EMAIL PROTECTED]  Tel: 416.946.8081  Fax: 416.946.3297

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


Re: [R] there is no xls reader in R?

2006-04-20 Thread Ko-Kang Kevin Wang
Have a look at the read.xls() in gdata package.

HTH,

Kevin

Michael wrote:
 Currently I have to convert all my xls into csv before I can read it in
 and process the excel data in R...
 
 Is there a way to directly read in xls data?
 
 Thanks a lot!
 
   [[alternative HTML version deleted]]
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

-- 
Ko-Kang Kevin Wang
Homepage: http://wwwmaths.anu.edu.au/~wangk/
Ph (W): +61-2-6125-2431
Ph (H): +61-2-6125-7471
Ph (M): +61-40-451-8301

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


Re: [R] Why is transform=km the default for cox.zph?

2006-04-17 Thread Kevin E. Thorpe
At the suggestion of Thomas Lumley, I posted this to s-news.
Dr. Therneau replied and I have posted (with permission) his
answer below the original question.

Kevin E. Thorpe wrote:
 To enhance my understanding, and that of my students, I have a question
 about cox.zph in the survival package.
 
 If I have correctly gleaned the high-level point from the 1994
 Biometrika paper of Grambsch and Therneau, it looks to me like
 cox.zph provides a mechanism to test for a simple trend in plots
 of a function of time, g(t) versus the scaled schoenfeld
 residuals and it also provides some built-in ones and the capability
 to provide your own.  It also appears to me that different forms look
 at different departures from proportionality.
 
 So, my question is what are the advantages and disadvantages of the
 default transform=km compared to say, identity or log?
 
 Thank you.
 
 Kevin
 

=== Begin Dr. Therneau's Reply ===

There are 2 reasons for making the KM the default:

  1. Safety:  The test for PH is essentially a least-squares fit of
 line to a plot of f(time) vs residual.  If the plot contains an
 extreme oulier in x, then the test is basically worthless.  This
 sometimes happens with transform= identity or transform =log.
 It doesn't with transform='KM'.

 As a default value for naive users, I chose the safe course.

  2. A secondary reason is efficiency.  In DY Lin, JASA 1991
 Dan-Yu argues that this is a good test statistic under various
 assumptions about censoring. (His measure has the same score
 statistics as the KM option).

But #1 is the big one.

 Terry T.

=== End Dr. Therneau's Reply ===


-- 
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Department of Public Health Sciences
Faculty of Medicine, University of Toronto
email: [EMAIL PROTECTED]  Tel: 416.946.8081  Fax: 416.946.3297

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


[R] Why is transform=km the default for cox.zph?

2006-04-07 Thread Kevin E. Thorpe
To enhance my understanding, and that of my students, I have a question
about cox.zph in the survival package.

If I have correctly gleaned the high-level point from the 1994
Biometrika paper of Grambsch and Therneau, it looks to me like
cox.zph provides a mechanism to test for a simple trend in plots
of a function of time, g(t) versus the scaled schoenfeld
residuals and it also provides some built-in ones and the capability
to provide your own.  It also appears to me that different forms look
at different departures from proportionality.

So, my question is what are the advantages and disadvantages of the
default transform=km compared to say, identity or log?

Thank you.

Kevin

-- 
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Department of Public Health Sciences
Faculty of Medicine, University of Toronto
email: [EMAIL PROTECTED]  Tel: 416.946.8081  Fax: 416.946.3297

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


[R] Problem compiling R-Patched

2006-03-15 Thread Kevin E. Thorpe
I downloaded R-Patched today (to see if another problem I want to
ask about is still present or if its just me - as per the posting
guide).  I ran tools/rsync-recommended successfully.  I then ran
configure --enable-R-shlib successfully.  Then make stops with the
following error.

gcc -shared -L/usr/local/lib -o tools.so text.o init.o Rmd5.o md5.o 
-L../../../../lib -lR
mkdir -p -- ../../../../library/tools/libs
make[5]: Leaving directory `/home/src/R-patched/src/library/tools/src'
make[4]: Leaving directory `/home/src/R-patched/src/library/tools/src'
Error in file(datafile, wb) : unable to open connection
In addition: Warning message:
cannot open file '/usr/local/lib/R/library/tools/R/tools.rdb', reason 
'Permission denied'
Execution halted
make[3]: *** [all] Error 1
make[3]: Leaving directory `/home/src/R-patched/src/library/tools'
make[2]: *** [R] Error 1
make[2]: Leaving directory `/home/src/R-patched/src/library'
make[1]: *** [R] Error 1
make[1]: Leaving directory `/home/src/R-patched/src'
make: *** [R] Error 1

The tools.rdb file is on my system from a previous build

-rw-r--r--  1 root root 90486 2005-08-04 18:54 /usr/local/.../tools.rdb

As you can see from the output above, I am not trying to build in 
/usr/local/... at all so I am puzzled as to why anything is being done
in /usr/local/ before the make install.  Can anyone suggest what I 
should try?  I am compiling on SuSE Linux version 9.2.

Thank you.

Kevin

-- 
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Department of Public Health Sciences
Faculty of Medicine, University of Toronto
email: [EMAIL PROTECTED]  Tel: 416.946.8081  Fax: 416.946.3297

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


Re: [R] Problem compiling R-Patched

2006-03-15 Thread Kevin E. Thorpe
Liaw, Andy wrote:
 Could it be that you have the environment variable R_HOME (or something like
 that) defined somewhere?  Just a wild guess...

No, R_HOME is not defined in the shell I was compiling in, but R_LIBS
was!  Brilliant wild guess.

Thanks,

Kevin

 Andy
 
 From: Kevin E. Thorpe
 
I downloaded R-Patched today (to see if another problem I 
want to ask about is still present or if its just me - as per 
the posting guide).  I ran tools/rsync-recommended 
successfully.  I then ran configure --enable-R-shlib 
successfully.  Then make stops with the following error.

gcc -shared -L/usr/local/lib -o tools.so text.o init.o Rmd5.o md5.o 
-L../../../../lib -lR
mkdir -p -- ../../../../library/tools/libs
make[5]: Leaving directory `/home/src/R-patched/src/library/tools/src'
make[4]: Leaving directory `/home/src/R-patched/src/library/tools/src'
Error in file(datafile, wb) : unable to open connection
In addition: Warning message:
cannot open file '/usr/local/lib/R/library/tools/R/tools.rdb', reason 
'Permission denied'
Execution halted
make[3]: *** [all] Error 1
make[3]: Leaving directory `/home/src/R-patched/src/library/tools'
make[2]: *** [R] Error 1
make[2]: Leaving directory `/home/src/R-patched/src/library'
make[1]: *** [R] Error 1
make[1]: Leaving directory `/home/src/R-patched/src'
make: *** [R] Error 1

The tools.rdb file is on my system from a previous build

-rw-r--r--  1 root root 90486 2005-08-04 18:54 
/usr/local/.../tools.rdb

As you can see from the output above, I am not trying to build in 
/usr/local/... at all so I am puzzled as to why anything is 
being done in /usr/local/ before the make install.  Can 
anyone suggest what I 
should try?  I am compiling on SuSE Linux version 9.2.

Thank you.

Kevin


-- 
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Department of Public Health Sciences
Faculty of Medicine, University of Toronto
email: [EMAIL PROTECTED]  Tel: 416.946.8081  Fax: 416.946.3297

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


[R] Having trouble with plot.survfit and fun=cloglog

2006-03-15 Thread Kevin E. Thorpe
I'm having trouble getting fun=cloglog to work with plot on
a survfit object.  Here are the data I used for the commands
that follow.

days status
2 0
2 0
5 1
9 0
14 1
16 0
16 0
17 0
29 1
30 0
37 1
37 0
39 1
44 0
44 0
58 0
60 1
67 1
68 1
82 1
82 1
86 0
86 0
89 1
93 0
97 1
100 0
100 0
100 0


  library(survival)
Loading required package: splines
  eg1.km - survfit(Surv(days,status),data=eg1)
  plot(eg1.km,mark.time=FALSE,conf.int=FALSE)  # Works
  plot(eg1.km,mark.time=FALSE,conf.int=FALSE,fun=cumhaz)  # Works
  plot(eg1.km,mark.time=FALSE,conf.int=FALSE,fun=cloglog)  # Error
Error in rep.default(2, n2 - 1) : invalid number of copies in rep()
In addition: Warning message:
2 x values = 0 omitted from logarithmic plot in: xy.coords(x, y, 
xlabel, ylabel
, log)

The axes are set and drawn up but nothing else is plotted.

  plot(eg1.km,mark.time=FALSE,conf.int=FALSE,fun=cumhaz,log=xy) # OK
Warning messages:
1: 2 x values = 0 omitted from logarithmic plot in: xy.coords(x, y, 
xlabel, yla
bel, log)
2: 1 y value = 0 omitted from logarithmic plot in: xy.coords(x, y, 
xlabel, ylab
el, log)

This does display the right plot but I am confused about how the xaxis
is computed.  The first tick mark is labeled with 100, the next with
200 right up to 600, but the entire plot is drawn between 0 and 100.

Please elighten me as to what I'm not understanding about fun=cloglog
and log scales.

  R.version
  _
platform i686-pc-linux-gnu
arch i686
os   linux-gnu
system   i686, linux-gnu
status   Patched
major2
minor2.1
year 2006
month03
day  13
svn rev  37540
language R

The survival package is version 2.21

Thank you,

Kevin

-- 
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Department of Public Health Sciences
Faculty of Medicine, University of Toronto
email: [EMAIL PROTECTED]  Tel: 416.946.8081  Fax: 416.946.3297

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


Re: [R] ESS, transcripts, and such

2006-03-13 Thread Kevin E. Thorpe
A.J. Rossini wrote:
SNIP

 One nice thing about ESS/Emacs is that it will cean a transcript
 buffer.  So if you are working in the inferior process buffer (where
 you shouldn't be, but that's for another day), then you can write it
 to disk as a transcript file, and clean it into a script.

Okay, I'll bite.  Could you ellaborate a bit on your parenthetical
comment?

 best,
 -tony

Thanks,

Kevin

-- 
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Department of Public Health Sciences
Faculty of Medicine, University of Toronto
email: [EMAIL PROTECTED]  Tel: 416.946.8081  Fax: 416.946.3297

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


Re: [R] ESS, transcripts, and such

2006-03-13 Thread Kevin E. Thorpe
A.J. Rossini wrote:
 Work in an inferior R session
 
 M-x write-buffer to TonyIsSilly.Rt
 
 So now your buffer is associated with a file, TonyIsSilly.Rt
 
 M-x R-transcript-mode
 
 M-x ess-transcript-clean-buffer
 
 and you should be left with a script file, not a transcript file.
 
 Enjoy.   I'll be talking about such things at useR if enough people
 show up for the tutorial...

Those are useful to know.  I was more interested in why you advise
not working directly in the inferior process buffer.  Sorry for not
being more clear.

Kevin

 On 3/13/06, Kevin E. Thorpe [EMAIL PROTECTED] wrote:
 
A.J. Rossini wrote:
SNIP

One nice thing about ESS/Emacs is that it will cean a transcript
buffer.  So if you are working in the inferior process buffer (where
you shouldn't be, but that's for another day), then you can write it
to disk as a transcript file, and clean it into a script.

Okay, I'll bite.  Could you ellaborate a bit on your parenthetical
comment?


-- 
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Department of Public Health Sciences
Faculty of Medicine, University of Toronto
email: [EMAIL PROTECTED]  Tel: 416.946.8081  Fax: 416.946.3297

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


[R] To improve my understanding of workspaces

2006-03-10 Thread Kevin E. Thorpe
Hello.

I have grown accustomed to the .Data directory in S-Plus and so when
I came to R I continued that behaviour by saving my workspaces at
the end of each R session.  So, I have saved workspaces in various
directories where I have used R just as I would have had various
.Data directories where I had used S-Plus.

I have seen comments on the list, most recently from Prof. Ripley
that they don't routinely save their workspaces in this way.
So my questions are:

   1. What do people do instead to manage projects?
   2. Is there an official recommendation?

 From my reading I have learned that you can save data frames
(and other objects?) to disk and then attach them.  Does this
save memory?  If I have read correctly, I understand that
everything in the workspace is in memory, but haven't been able
to determine if objects in the search path are as well.

Kind Regards,

Kevin

-- 
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Department of Public Health Sciences
Faculty of Medicine, University of Toronto
email: [EMAIL PROTECTED]  Tel: 416.946.8081  Fax: 416.946.3297

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


Re: [R] To improve my understanding of workspaces

2006-03-10 Thread Kevin E. Thorpe
Thanks Adai.  A couple questions/comments about this.

Adaikalavan Ramasamy wrote:
 I use emacs and ESS to develop the scripts. The new releases of R has
 the script function already in built.

I use emacs and ESS too (in Linux).  I do not know about the script
function you mention.  It's not in my version (2.1.1) and I couldn't
find it in an RSiteSearch either.

 Typically I keep all the data and scripts related to a project in its
 own folder, so I have minimal worry about paths.

I do the same.

 To save large and associated objects, I use 
save(x, y, z, file=lala.rda, compress=TRUE) 
 and then to load x, y, z in another session or workspace I use
load(lala.rda) 
 
 To save small dataframes and matrices, I use 
write.table(mat, file=lala.txt, sep=\t) 
 and to read it back I use
mat - read.delim(file=lala.txt, row.names=1)

Am I correct that load() or read.whatever() or even data() will
bring the objects into the current workspace while attach() can
attach a save() data frame to the search path?  Is one approach
better than the other in general?

 
 The problem with .RData (via quit or save.image), is that it keeps all
 intermediate objects which can be unnecessarily bloated and confusing.
 Further you will have difficulty distinguishing one .RData from the
 other by looking at the filename alone.

If you don't save the workspace on q(), do you also lose the history for
that session (although when working in emacs, this is rarely a problem)?

 Regards, Adai

Thanks again,

Kevin

 
 
 On Fri, 2006-03-10 at 06:58 -0500, Kevin E. Thorpe wrote:
 
Hello.

I have grown accustomed to the .Data directory in S-Plus and so when
I came to R I continued that behaviour by saving my workspaces at
the end of each R session.  So, I have saved workspaces in various
directories where I have used R just as I would have had various
.Data directories where I had used S-Plus.

I have seen comments on the list, most recently from Prof. Ripley
that they don't routinely save their workspaces in this way.
So my questions are:

   1. What do people do instead to manage projects?
   2. Is there an official recommendation?

 From my reading I have learned that you can save data frames
(and other objects?) to disk and then attach them.  Does this
save memory?  If I have read correctly, I understand that
everything in the workspace is in memory, but haven't been able
to determine if objects in the search path are as well.

Kind Regards,

Kevin

 
 
 


-- 
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Department of Public Health Sciences
Faculty of Medicine, University of Toronto
email: [EMAIL PROTECTED]  Tel: 416.946.8081  Fax: 416.946.3297

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


Re: [R] To improve my understanding of workspaces

2006-03-10 Thread Kevin E. Thorpe
Sean Davis wrote:
 
 On 3/10/06 8:33 AM, Duncan Murdoch [EMAIL PROTECTED] wrote:
 
 
Other than Emacs, I use the same work habits as Adai.  An advantage of
this workflow is that almost everything is stored in text format, so it
is easy to compare different versions to see what has changed, and it
works very well with version control (I use Subversion).

The only thing I'd add to his recommendation is that you be sure to save
the scripts that produced the objects in the binary images (his
lala.rda), so that they can be reconstructed if necessary.  As long as
the reconstruction isn't too difficult, this means I don't need to
bother to save them in Subversion.

Version control sounds like a good idea Duncan, but I've always been a
bit intimidated by it.  How cumbersome is Subversion and what are the
advantages of version control?

 
 I would add a bit of detail here that I do.  ESS/xemacs allows one to create
 a transcript file that you can then step through, executing each command as
 it was originally executed.  I make one of these transcript files for each
 project and save it with the data and any scripts that I have for the
 project.  So, in the end, I have a set of Rda files, one or more transcript
 files, and a Src directory that contains any function code (and ESS supports
 saving scripts to this directory automatically).

Do you save your functions in Rda files to be loaded/attached or are
they sourced every time?  How do you tell ESS/emacs to save in ./src or
is that only possible with xemacs (I can use emacs to do what I need to
but don't know lisp so the config files and terminology are a bit
cryptic to me)?

Kevin

-- 
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Department of Public Health Sciences
Faculty of Medicine, University of Toronto
email: [EMAIL PROTECTED]  Tel: 416.946.8081  Fax: 416.946.3297

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


Re: [R] Read SAS .sd2 file into R?

2006-02-27 Thread Kevin Viel


Peter Dalgaard wrote:
 mtb954 mtb954 [EMAIL PROTECTED] writes:
 
 
Does anyone know how to import a SAS .sd2 file into R? I can't see
anything in library(foreign).
 
 
 The SAS dataset file formats are not publicly available. You need
 either SAS itself (on a Windows machine) or a specialized tool like
 DBMS/Copy to converti it.


Peter,

   There may be another way, though I have yet to explore it.

The SAS System Viewer is free and you may distribute it royalty free:

http://www.sas.com/apps/demosdownloads/sassysview_PROD_8.2_sysdep.jsp?packageID=000176


Files Supported by the SAS System Viewer
The SAS System Viewer lets you view the following types of SAS files:
Read Only
* 7.00 Data Sets created under the windows environment (sas7bdat, sd7, 
sd2, ssd,
ssd0x, saseb$data)
* 6.06 - 6.12 Catalogs - Directory Information Only (sc2, sct, sct0x,
saseb$catalog)
* 3.2.2 JMP(r) Data Sets - Macintosh and Windows (jmp)
* 6.12 MDDB - Multi-dimensional Data Base Files (sm2)
* SAS Transport Files (stx, xpt)
* SAS Log Files (log)
* SAS List Files (lst)

Read and Write Enabled
* Comma Delimited Files (csv)
* Space Delimited Files (prn)
* Text Based Files (sas, dat, cfg, html)

Whether you can copy and paste will be key.

Regards,

Kevin

--
Kevin Viel
Department of Genetics  e-mail: [EMAIL PROTECTED]
Southwest Foundationphone:  (210)258-9884
P.O. Box 760549 fax:(210)258-9444
San Antonio, TX 78245-0549

Kevin Viel
PhD Candidate
Department of Epidemiology
Rollins School of Public Health
Emory University
Atlanta, GA 30322

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


Re: [R] OT Futility Analysis

2006-02-22 Thread Kevin E. Thorpe
Thank you Spencer and Steve for your helpful comments.  If I may, I
would like to elaborate on some of the points you raise.

Stephen A Roberts wrote:
 I would take the line that if they hadn't pre-specified any stopping
 rules, the only reason to stop is safety or new external data. I
 would be very suspicious of requests from the steering committee to
 stop for futility - they should be blinded so why are they thinking
 futility unless results have leaked? I would argue that they are
 obliged to finish the trial once they start.

In general I agree with this.  In this case the request for a futility
analysis came from the sponsor (a drug company).  It is a classic case
of company B buys company A and wnats to stop RD on company A's drugs.
Therefore the company was looking for a reason to stop.  Now that they
will stop producing the drug used in the trial, recruitment will end
before reaching its target.  Now the Steering Committee's point of
view is that if there is any reasonable hope, they would find some
other way to continue recruitment.  I am confident that results have
not leaked.  I am well aquainted with the data management and blinding
procedures in place for the trial.

 This is an example of the need to sort out these things in advance -
 look up the stuff from the UK DAMOCLES project. The recent book
 edited by DeMets et al (Data Monitoring in Clinical Trials: A Case
 Studies Approach) is a good read on these sorts of issues and I think
 there is a more statistical book from the same group of authors.

Thanks for the reference.  My library has it, so will give it a look.

 As far as software is concerned, futility analysis and conditional
 power are simply standard analyses with made up data and more-or-less
 justifiable assumptions.

I am also interested if there are good alternatives to conditional
power for this type of scenario.

 Steve.
 
 
 
 
 What does this particular Steering Committee think a futility 
 analysis is?  Do they have any particular reference(s)?  What do
 you find in your own literature review?
 
 If it were my problem, I think I'd start with questions like that. 
 Your comments suggested to me a confounding of technical and
 political problems.  The politics suggests the language you need to
 use in your response.  Beyond that, I've never heard before of a
 futility analysis, but I think I could do one by just trying to
 be clear about the options the Steering Committee might consider
 plausible and then comparing them with appropriate simulations --
 summarized as confidence intervals, as you suggest.

I did ask REPEATEDLY for guidelines from the steering committee, but
none came or are likely to come.  In fact, they wanted me to come up
with the recommendation, which I find entirely inappropriate, but here
I am.  So, I don't think I'm confounded between techincal and political.

Basically, they want to stop if there is a low chance of rejecting the
null hypothesis.  This is often referred to as conditional power or
stochastic curtailment.  I recently saw a paper by Scott Emerson
pointing out some problems (interpretation, relation to unconditional
power).

As far as references, I have used a book by Jennisen and Turnbull in
the past, but, as I recall, with the exception of stochastic
curtailment, it assumes the trial was designed with group sequential
methods.  I have also just found a 1988 Biometrics paper by Lan and
Wittes on the B-value which I will read.

 And I hope that someone else will enlighten us both if there are 
 better options available.
 
 Best Wishes, spencer graves p.s.  For any attorneys who may read
 these comments, the suggestions are obviously warranteed up to the
 amount you paid for it, which is nothing. If you follow them and
 they turn out to be inappropriate, you will pay the price.  I
 encourage you to share the problems with me, so I can learn from
 the experience.  However, the limits of my liability are as already
 stated.
 
 Kevin E. Thorpe wrote:
 
 
 I beg your pardon if this is too off topic.  I am posting here 
 since I hope to find an R solution to my problem.  Please indulge
  me while I give a little background about what I'm trying to do.
 
 
 I'm on a DSMB for a clinical trial.  The Steering Committee for
 the trial has asked us to perform a futility analysis on their
 primary outcome which is a time-to-event endpoint.  The trial was
 not designed with group sequential methods, nor was any futility
 analysis spelled out in the protocol.  Another thing which may be
 relevant is that due to circumstances beyond the investigators'
 control, the trial will stop recruitment prematurely unless there
 is some compelling reason for them to find a way to continue the
 trial.  Lastly, the trial has accrued not quite half of the
 planned sample size.
 
 Admittedly, I don't have a vast amount of experience implementing
  stopping rules.  In other protocols I have seen where futility 
 analyses have been planned but a group sequential

[R] Using string vectors as for loop arguments

2006-02-03 Thread Kevin Middleton
Is there a mechanism to interate through a vector of strings? Say I  
have a data frame of 50 variables (VAR1 to VAR50), each with 100  
measurements along with some coding factors (EXP and DOSE). I want to  
calculate the mean of a subset of each of VAR1 to VAR 50 (selecting  
by EXP and DOSE). Rather than just copy/pasting the same code 50  
times, I thought of using a for loop to go through a vector of VAR1  
to VAR50 (VAR.LIST below). Each iteration would be the variable name  
for which the mean would be calculated.

Trying this, I get an error that the argument is not numeric or  
logical. So I assume that for loops with vectors of strings are  
disallowed. What I am wondering is whether there a way to mimic this  
sort of procedure?

The code looked something like this:

VAR.LIST-paste(c(VAR), 1:50, sep=)

for (i in VAR.LIST){
mean(i[EXP==1  DOSE==1], na.rm=T)
}



Thanks
Kevin Middleton

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


Re: [R] installation of R on Linux

2006-01-28 Thread Kevin E. Thorpe
Daniel Nordlund wrote:
-Original Message-
From: Prof Brian Ripley [mailto:[EMAIL PROTECTED]
Sent: Friday, January 27, 2006 11:49 PM
To: Daniel Nordlund
Cc: r-help@stat.math.ethz.ch
Subject: Re: [R] installation of R on Linux

On Fri, 27 Jan 2006, Daniel Nordlund wrote:


R-users,

I am new user of Linux (have been using Win XP Pro) and wanted to
install R.  Since I am just beginning to learn Linux I was wondering,
where in the directory structure do users of Linux usually install R?
Most of the instructions I have read simply say to untar the tarball
where you want to install the program.  Any suggestions would be welcome
as to an appropriate place.  I know I could get an rpm, but wanted to
use this as a learning process for a variety of skills.  Currently
working with SuSE 9.1

There is a definitive set of instructions, in the file INSTALL in
the tarball and at

https://svn.r-project.org/R/trunk/INSTALL

Unpacking and installing are separate operations.  There is more
information in the R-admin manual (which you already have in a Windows
version of R, and is also in the tarball).

What most of us do is to untar in any convenient place (I use ~/R), use
configure, make, and then use 'make install' to install R.  This
installs in /usr/local in the conventional subdirectories (and
conventionally needs su to access).  Having installed, you can wipe out
the unpacked version of the tarball.

So, in my example

cd ~/R
tar zxf R-2.2.1.tar.gz
cd R-2.2.1
configure
make
make info pdf
su
make install install-info install-pdf
[leave su shell]
cd ..
rm -rf R-2.2.1

Rehash and start R.

--
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
 
 
 Prof. Ripley,
 
 Thanks for the example and the pointers to various locations for 
 documentation.  As a new user of Linux (with minimal experience in using 
 Unix-like systems), I am somewhat uncomfortable putting programs just 
 anywhere since there seem to be default locations for where many system 
 programs reside.  Your concrete example is very helpful.
 
 Thanks again,
 
 Daniel Nordlund
 Bothell, WA  USA
 

One additional point.  I have often found it preferable to
run configure and make as a regular user and only run
'make install' as root.


-- 
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Department of Public Health Sciences
Faculty of Medicine, University of Toronto
email: [EMAIL PROTECTED]  Tel: 416.946.8081  Fax: 416.946.3297

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


Re: [R] R Commenting Style

2006-01-19 Thread Kevin E. Thorpe
I don't know if this is what you're referring to, but in ESS the number 
of octothorpes (#) affects the indentation in the emacs buffer. If I 
remember right, ### puts it at the beginning of the line, ## the current 
indentation level (eg. in a function) and # further right.

Paul Roebuck wrote:

I seem to remember reading somewhere about some style
guide regarding R the number of comment characters (#)
prior to the comment meaning something.

Anyone know to what I'm referring? Where?



-- 
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Department of Public Health Sciences
Faculty of Medicine, University of Toronto
email: [EMAIL PROTECTED]  Tel: 416.946.8081  Fax: 416.946.3297

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


Re: [R] Wikis etc.

2006-01-08 Thread Kevin Gamble
Kris over at Wiki That! has a post today about what makes for a good  
wiki: http://www.wikithat.com/wiki_that/2006/01/wiki_of_the_wee_1.html

 Most wikis I’ve looked at are in danger of facing the same fate as  
 most websites and CMS - death by boredom. They are focused on  
 content that is used as reference for some off-line activity OR as  
 the end-result of an off-line activity.

 Collaboration and participation is more than just sharing  
 information and making it accessible. It’s all about the PROCESS of  
 planning and executing events, projects, tasks, and deliverables.  
 Content is boring - action is engaging. Make your wiki activity- 
 centric, not just data-centric (content).

If the wiki is a place where people just go to look things up --  
we're toast. It needs to be made into an active learning environment,  
a place where experts and beginners alike come to interact. Some to  
share their knowledge, and others to learn from the masters. It's the  
same dynamic  that makes the mailing list so active, and yet also  
what exposes its weakness (i.e. it doesn't scale well).

Kevin



Kevin J. Gamble. Ph.D.
Associate Director eXtension Initiative
Box 7647 NCSU
Raleigh, NC 27694-7641
v: 919.515.8447
c: 919.605.5815
AIM: k1v1n
Web: intranet.extension.org

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


Re: [R] Wikis etc.

2006-01-05 Thread Kevin E. Thorpe
Frank makes an intersting point.  For those interested, A site I spend
quite a bit of time on for Linux related stuff is IMHO really well done.
There are fora for many different linux distrubtions.  There is a wiki,
a collection of tutorials, etc.  If you want to take a look, the url is
http://www.linuxquestions.org/

Kevin

Frank E Harrell Jr wrote:
 I feel that as long as people continue to provide help on r-help wikis 
 will not be successful.  I think we need to move to a central wiki or 
 discussion board and to move away from e-mail.  People are extremely 
 helpful but e-mail seems to be to always be memory-less and messages get 
 too long without factorization of old text.  R-help is now too active 
 and too many new users are asking questions asked dozens of times for 
 e-mail to be effective.
 
 The wiki also needs to collect and organize example code, especially for 
 data manipulation.  I think that new users would profit immensely from a 
 compendium of examples.
 
 Just my .02 Euros
 
 Frank


-- 
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Department of Public Health Sciences
Faculty of Medicine, University of Toronto
email: [EMAIL PROTECTED]  Tel: 416.946.8081  Fax: 416.946.3297

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


Re: [R] Maintaining factors when copying from one data frame to another

2005-12-07 Thread Kevin E. Thorpe
Does newDF - oldDF[,c(A,C,D)] work?

Kurt Wollenberg wrote:

Greetings all:

OK, this is bugging the @[EMAIL PROTECTED] out of me. I know the answer is 
simple
and straightforward but for the life of me I cannot find it in the
documentation, in the archives, or in my notes (because I know I've
encountered this in the past). My problem is:

I have a data frame with columns A, B, C, D, and E. A, B, and E are
factors and C and D are numeric. I need a new data frame with just A,
C, and D. When I copy these columns to a new data frame

  

newDF - data.frame(cbind(oldDF$A, oldDF$C, oldDF$D))



all the factor data comes out as levels rather than the original
factors. How do I preserve the factors when I copy from one data frame
to another?


Thanks vary much,
Kurt Wollenberg, Ph.D.
Tufts Center for Vision Research
Tufts-New England Medical Center
750 Washington St #450
Boston, MA 02111
Office: 617-636-9028
Fax: 617-636-8945
email: kurt.wollenberg at gmail dot com

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

  



-- 
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Department of Public Health Sciences
Faculty of Medicine, University of Toronto
email: [EMAIL PROTECTED]  Tel: 416.946.8081  Fax: 416.946.3297

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


Re: [R] Really supress output from Sweave

2005-11-23 Thread Kevin E. Thorpe
Fredrik Karlsson wrote:
 Hi,
 
 I am using Sweave for chapters in my thesis that contain results.
 In the beginning of each chapter, I use this to load libraries I need.
 
 init,echo=FALSE,quiet=TRUE=

Have you tried init,echo=FALSE,quiet=TRUE,results=hide=

 library(gplots)
 library(Hmisc)
 library(e1071)
 
 @
 
 
 What I want is, of course, to supress messages written by this code,
 but what I get in the end is X-init.tex with this the contents below.
 How do I really supress it?
 
 /Fredrik
 
 Type library(help='Hmisc'), ?Overview, or ?Hmisc.Overview')
 to see overall documentation.
 
 NOTE:Hmisc no longer redefines [.factor to drop unused levels when
 subsetting.  To get the old behavior of Hmisc type dropUnusedLevels().
 
 Attaching package: 'Hmisc'
 
 
 The following object(s) are masked from package:gdata :
 
  reorder.factor
 
 
 The following object(s) are masked from package:car :
 
  recode
 
 
 The following object(s) are masked from package:stats :
 
  ecdf
 \end{Soutput}
 \begin{Soutput}
 Loading required package: class
 
 Attaching package: 'e1071'
 
 
 The following object(s) are masked from package:Hmisc :
 
  impute
 
 
 The following object(s) are masked from package:gtools :
 
  permutations
 
 
 The following object(s) are masked from package:foreign :
 
  read.octave
 \end{Soutput}
 \begin{Soutput}
 Attaching package: 'xtable'
 
 
 The following object(s) are masked _by_ .GlobalEnv :
 
  digits
 
 
 The following object(s) are masked from package:Hmisc :
 
  label label-
 \end{Soutput}
 \end{Schunk}
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
 


-- 
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Department of Public Health Sciences
Faculty of Medicine, University of Toronto
email: [EMAIL PROTECTED]  Tel: 416.946.8081  Fax: 416.946.3297

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


[R] new article on R at oreillynet.com

2005-11-19 Thread Kevin Farnham
An article I wrote that provides a basic introduction to R has
been published on Oreillynet.com. The article is titled
Analyzing Statistics with GNU/R. Here is the link:

http://www.onlamp.com/pub/a/onlamp/2005/11/17/r_for_statistics.html

Please feel free to post comments or interesting basic R scripts
at the end of the article. 

Kevin Farnham

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


Re: [R] RODBC and Excel: Wrong Data Type Assumed on Import

2005-11-03 Thread Kevin Wright
From my experience (somewhat of a guess):

1.

Excel uses the first 16 rows of data to determine if a column is numeric or
character. The data type which is most common in the first 16 rows will then
be used for the whole column. If you sort the data so that at least the
first 9 rows have character data, you may find this allows the data to be
interpreted as character. There is supposedly a registy setting that can
control how many lines to use (instead of 16), but I have not had success
with the setting. I suspect that ODBC uses JET4, which may be the real
source of the problem. See more here:
http://www.dicks-blog.com/archives/2004/06/03/external-data-mixed-data-types/

2.

The gregmisc bundle has a different read.xls function that uses a Perl
script (xls2csv) and seems to be safer with mixed-type columns.
Requires a working version of Perl.

Best,

Kevin Wright



The first column in my Excel sheet has mostly numbers but I need to treat it
as character data:

 library(RODBC)
http://tolstoy.newcastle.edu.au/R/help/05/09/11324.html#14938qlink1
* channel - odbcConnectExcel(U:/efg/lab/R/Plasmid/construct list.xls) *
* plasmid - sqlFetch(channel,Sheet1, as.is=TRUE) *
* odbcClose(channel) *

 names(plasmid)

[1] Plasmid Number Plasmid Concentration Comments Lost

# How is the type decided? I need a character type.
 class(plasmid$Plasmid Number)

[1] numeric
 typeof(plasmid$Plasmid Number)

[1] double

 plasmid$Plasmid Number[273:276]

[1] 274 NA NA 276

The two NAs are supposed to be 275a and 275b. I tried the as.is=TRUE but
that didn't help.

I consulted Section 4, Relational databases, in the R Data Import/Export
document (for Version 2.2.0).

Section 4.2.2, Data types, was not helpful. In particular, this did not seem
helpful: The more comprehensive of the R interface packages hide the type
conversion issues from the user.

Section 4.3.2, Package RODBC, provided a simple example of using ODBC ..
with a(sic) Excel spreadsheet but is silent on how to control the data type
on import. Could the documentation be expanded to address this issue?

I really need to show Plasmid 275a and Plasmid 275b instead of Plasmid
NA.

Thanks for any help with this.

efg

--
Earl F. Glynn
Scientific Programmer
Bioinformatics Department

[[alternative HTML version deleted]]

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


[R] How to create a new data.frame with all possible observations

2005-10-24 Thread Kevin Wright
I would like to use something like expand.grid to get a data.frame with all
possible combinations of model terms from a formula. For example:

R dat=data.frame(y=rnorm(8),
+ trt=rep(c(A,B),4),
+ state=c(rep(c('IA','NE'),each=4)),
+ county=c('P','P','S','S','J','J','N','N'))
R dat=dat[-1,]
R dat
y trt state county
2 0.36 B IA P
3 0.44 A IA S
4 2.26 B IA S
5 -0.12 A NE J
6 0.84 B NE J
7 -2.11 A NE N
8 -0.69 B NE N

If my model is
model=formula(y~trt+state + county%in%state)

Then I would like to create a data.frame that includes the missing
observation for
A + IA + P %in IA (trt + state + county %in% state)

I currently use expand.grid to get all possible combinations of variables,
then delete impossible combinations like J %in IA. This works, but is a
bit clumsy and I wonder if there is a more general solution.

Ideas welcome.

Kevin Wright

[[alternative HTML version deleted]]

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


Re: [R] simple question

2005-10-22 Thread Ko-Kang Kevin Wang
Hi,

Korbinian von Blanckenburg wrote:
 Its just a simple question I guess:
 
 I have a vector with missing information like 
 x-c(0,1,31,131,NA,133,NA,310,NA,112,3,1,2,93)
 
 How can I make a vector like this no missing in it. I used the x[x0] 
 commabd and tried some more, with no success.

Try na.omit()

HTH,

Kevin

-- 
Ko-Kang Kevin Wang
PhD Student
Centre for Bioinformation Science
Building 27, Room 1004
Mathematical Sciences Institute (MSI)
Australian National University
Canberra, ACT 2601
Australia

Homepage: http://wwwmaths.anu.edu.au/~wangk/
Ph (W): +61-2-6125-2431
Ph (H): +61-2-6125-7488
Ph (M): +61-40-451-8301

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


Re: [R] Problem whit a piece of program

2005-10-13 Thread Kevin E. Thorpe
Arturo Coral Alamo wrote:
 Hi friends, I'm beginning in R and I have simple question.
 
 I have this piece of my program and how you see, that's ok (whit  num-
 0.002)
 
 num-0.002 # ok, but not when I change whit num-0... ?
 factor1-1;
 while(1)
 {
 if (num*factor11)
 factor1-factor1*10
 else
 {
 print(out ok!!);
 break;
 }
 }
 
 [1] out ok!!
 
 
 but when I change (whit  num-0) R show this:

Since num==0, num*factor1 is always 0 and so the loop never terminates 
and factor1 grows without bound becoming Inf.

 Error in if (num * factor1  1) factor1 - factor1 * 10 else { :
 missing value where TRUE/FALSE needed
 
 
 I can't understand that error, can somebody help me, please
 thanks in advance
  Jac


-- 
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Department of Public Health Sciences
Faculty of Medicine, University of Toronto
email: [EMAIL PROTECTED]  Tel: 416.946.8081  Fax: 416.946.3297

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


Re: [R] Binary Logit Regression with R

2005-09-29 Thread Ko-Kang Kevin Wang
Hi,

Johann Park wrote:

 Let say, my Y is war occurence (occur=1, otherwise 0). And my independent 
 variables (Xs) are trade, democracy, military poweretc. 

Take a look at ?glm.

HTH,

Kev

-- 
Ko-Kang Kevin Wang
PhD Student
Centre for Bioinformation Science
Building 27, Room 1004
Mathematical Sciences Institute (MSI)
Australian National University
Canberra, ACT 2601
Australia

Homepage: http://wwwmaths.anu.edu.au/~wangk/
Ph (W): +61-2-6125-2431
Ph (H): +61-2-6125-7488
Ph (M): +61-40-451-8301

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


Re: [R] graphics guide?

2005-09-27 Thread Ko-Kang Kevin Wang
Hi,

Karin Lagesen wrote:
 I am trying to create some graphs with R and it seems to be able to do
 what I need. However, I have so far not been able to find any sort of
 explanation of how the graphics system works. I am for instance trying
 to create a multiple figure, and I seem to have to call plot.new()
 before every new plot command, I have however not found any

Do you mean several graphs in the same window?

If so, you want something like, e.g.:
   par(mfrow = c(2, 2))

Take a look at ?par and the mfrow or mfcol options.

Cheers and HTH,

Kev

-- 
Ko-Kang Kevin Wang
PhD Student
Centre for Bioinformation Science
Building 27, Room 1004
Mathematical Sciences Institute (MSI)
Australian National University
Canberra, ACT 2601
Australia

Homepage: http://wwwmaths.anu.edu.au/~wangk/
Ph (W): +61-2-6125-2431
Ph (H): +61-2-6125-7488
Ph (M): +61-40-451-8301

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


Re: [R] Transform variable number of rows per subject to column variables?

2005-09-20 Thread Kevin Bartz
Hey Bing,

Reshape's the ticker -- ?reshape.

For example, reshape(myFrame, idvar = ID, timevar = TEST.A) should
do most of the trick.

Kevin

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Bing Ho
Sent: Monday, September 19, 2005 10:04 PM
To: r-help@stat.math.ethz.ch
Subject: [R] Transform variable number of rows per subject to column
variables?

Hello,

I am very new to R, but I am having trouble with my dataset.

I have a data frame where a subject has a variable number of multiple 
observations for each row, which I wish the transform these 
observations to column variables.

An example of the data frame
ID  TEST.A  TEST.B
1   10  1
1   13  2
1   11  1
2   15  2
2   17  3

And I wish to transform it to the following:
ID  TEST.A1 TEST.A2 TEST.A3 TEST.B1 TEST.B2 TEST.B3
1   10  13  11  1
2   1
2   15  17  NA  2
3   NA

In other words, for the variable number of repeated follow up 
studies, a new column variable for each subject, but they are grouped 
by the original test.

Thank you for any help - I'm realizing that I am a terrible programmer!

Bing Ho

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

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


[R] pairwise comparisons among treatments

2005-09-19 Thread kevin Lin
Hello R listing,

I did two-way anova on lm. Further question the investigator 
interested in is what two treatments are different?

I am looking for a command which could do pairwise comparison for 
every treatment.

Could anyone help me out?

Thanks a bunch

Kevin

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


Re: [R] pairwise comparisons among treatments

2005-09-19 Thread kevin Lin
Hello Bert,

Thanks for your response. I don't know why I am getting following 
error messages. I use version of R version 2.1.1, 2005-06-20, 
powerpc-apple-darwin7.9.0  in Mac OS X version 10.3.8.
I did try to load following packages before, but it failed.

help.search(pairwise comparison)
Error in help.search(pairwise comparison) :
could not find package 'arrayQuality.1'
In addition: Warning messages:
1: no Rd contents for package 'R2HTML' in 
'/Library/Frameworks/R.framework/Resources/library' in: 
help.search(pairwise comparison)
2: no Rd contents for package 'affylmGUI' in 
'/Library/Frameworks/R.framework/Resources/library' in: 
help.search(pairwise comparison)

Thanks.

Kevin

help.search('pairwise comparison')

-- Bert Gunter
Genentech Non-Clinical Statistics
South San Francisco, CA

The business of the statistician is to catalyze the scientific learning
process.  - George E. P. Box




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


Re: [R] [handling] Missing [values in randomForest]

2005-09-12 Thread Kevin Bartz
Hi Jan-Paul,

You definitely want to be careful with na.omit in randomForest -- that
wipes out any row with even one NA. If NAs are sprawled throughout your
dataset, na.omit might end up killing a lot of rows. Here's my usual MO
for missing values:

1) impute in Hmisc fills in gaps with the mean, median, most common
value, etc.
2) rfImpute: fits a forest on the rows available and uses it to predict
the missing values.
3) aregImpute: similar to rfImpute, but using a linear model.
4) You may want to consider using a single tree (rpart package) in
this case instead of a forest. Single trees deal with missing values
cleanly through surrogate splits.

Good luck!

Kevin

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Uwe Ligges
Sent: Sunday, September 11, 2005 3:44 AM
To: Jan-Paul Roodbol
Cc: r-help@stat.math.ethz.ch
Subject: Re: [R] [handling] Missing [values in randomForest]

Jan-Paul Roodbol wrote:

 Does anyone know if randomForest in R can handle
 dataset with missings?

See ?randomForest, you can omit observations including NAs by specifying

na.action=na.omit

Please do not cross-post!
Please specify a sensible subject!

Uwe Ligges


 Thank you
 
 Kind regards
 
 Jan-Paul
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html

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

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


Re: [R] TeX distribution on Windows

2005-09-05 Thread Ko-Kang Kevin Wang
Hi,

Göran Broström wrote:

 So, what is suggested? TUG (tug.org) recommends something called proTeXt,
 which is said to be based on MiKTeX, for Windows users. Since MikTeX 
 could be used with  R, that sounds like a good alternative.
 
 Any comments to that?

I've been using MikTeX on Windows for years and have never had any 
problems.  Its Update Wizard also has a nice and intuitive user 
interface.  I've never had any problems using it with R.

Cheers,

Kev


-- 
Ko-Kang Kevin Wang
PhD Student
Centre for Bioinformation Science
Building 27, Room 1004
Mathematical Sciences Institute (MSI)
Australian National University
Canberra, ACT 2601
Australia

Homepage: http://wwwmaths.anu.edu.au/~wangk/
Ph (W): +61-2-6125-2431
Ph (H): +61-2-6125-7488
Ph (M): +61-40-451-8301

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


Re: [R] TeX distribution on Windows

2005-09-05 Thread Ko-Kang Kevin Wang
Thomas Petzoldt wrote:


 
 Miktex can be used with WinEDT, Emacs, Texniccenter and others as editor.

Slightly off topic, if you want to get MikTeX working with Emacs and 
ESS, the  Claus Dethlefsen has a wonderful web site (in fact, best 
website on this topic IMHO) http://www.math.auc.dk/~dethlef/Tips/

Cheers,

Kev

-- 
Ko-Kang Kevin Wang
PhD Student
Centre for Bioinformation Science
Building 27, Room 1004
Mathematical Sciences Institute (MSI)
Australian National University
Canberra, ACT 2601
Australia

Homepage: http://wwwmaths.anu.edu.au/~wangk/
Ph (W): +61-2-6125-2431
Ph (H): +61-2-6125-7488
Ph (M): +61-40-451-8301

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


Re: [R] preprocessing data

2005-08-16 Thread Kevin E. Thorpe
Some time ago, Doug Bates wrote a useful paper called Data
manipulatation in perl.  It is a very concise intoduction and
introduces the unpack function which is one way to deal with fixed
format data.  Just google for

   data manipulation in perl bates

and you should be able to find a copy.

Jean Eid wrote:
 Dear all,
 
 My question is concerning the line
 This is adequate for small files, but for anything more complicated we
 recommend using the facilities   of a language like perl to pre-process
 the file.
 
 in the import/export manual.
 
 I have a large fixed-width file that I would like to preprocess in Perl or
 awk. The problem is that I do not know where to start. Does anyone have a
 simple example on how to turn a fixed-width file in any of these
 facilities into csv or tab delimited file. I guess I am looking for
 somewhat a perl for dummies or awk for dummies that does this. any
 pointers for website will be greatly appreciated
 
 Thank you
 
 
 Jean Eid
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
 


-- 
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Department of Public Health Sciences
Faculty of Medicine, University of Toronto
email: [EMAIL PROTECTED]  Tel: 416.946.8081  Fax: 416.971.2462

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


Re: [R] Problem configuring R-patched

2005-08-05 Thread Kevin E. Thorpe
Martin Maechler wrote:
 Duncan I believe there are two kinds of tar files.  The daily
 Duncan snapshots don't include the recommended packages, the
 Duncan releases do.
 
 eeehm, no: The daily snapshots do contain the recommended packages,
 and have for quite a while now.
 
 Duncan Or perhaps the test is a recent addition.
 
 only for a pretty generous definition of recent.
 
 To be honest, I don't know what Kevin's problem could be.
 
 The daily snapshots are really produced here at ETH Zurich and
 daily mirrored from here to CRAN. I can see that the 
R-patched_2005-08-04.tar.gz
 does contain the recommended packages.
 
 Maybe your download wasn't completed; your disk full; or you
 have a gnome in your computer who occasionally deletes some of
 your files?  I've had similar feelings a few times in the
 past...
 
 Kevin Both versions were R-patched.tar.gz as opposed to the
 Kevin devel sets which looks like it's actually a link to
 Kevin the most recent.  Maybe I incorrectly assumed that
 
 Kevin Maybe I incorrectly assumed that the patched tarballs
 Kevin contained the recommended packages.
 
 actually that was a correct assumption.
 
 Martin Maechler, ETH Zurich

I still don't know why it didn't work observe (sorry for the wrapping):

[EMAIL PROTECTED]:/home/src tar tvzf R-patched.tar.gz | grep Recommended
drwxr-xr-x local/local   0 2005-08-03 20:45:50 
R-patched/src/library/Recommended/
-rw-r--r-- local/local2394 2005-04-18 08:51:32 
R-patched/src/library/Recommended/Makefile.in
-rw-r--r-- local/local  20 2005-04-18 08:51:32 
R-patched/src/library/Recommended/.cvsignore
-rw-r--r-- local/local   25656 2005-04-18 08:58:17 
R-patched/src/library/Recommended/KernSmooth_2.22-15.tar.gz
-rw-r--r-- local/local  465529 2005-07-28 11:45:14 
R-patched/src/library/Recommended/VR_7.2-17.tar.gz
-rw-r--r-- local/local  179895 2005-07-28 11:45:14 
R-patched/src/library/Recommended/boot_1.2-23.tar.gz
-rw-r--r-- local/local  190975 2005-07-03 11:45:11 
R-patched/src/library/Recommended/cluster_1.10.1.tar.gz
-rw-r--r-- local/local  273520 2005-07-14 11:45:08 
R-patched/src/library/Recommended/foreign_0.8-9.tar.gz
-rw-r--r-- local/local  205131 2005-07-27 11:45:14 
R-patched/src/library/Recommended/lattice_0.12-1.tar.gz
-rw-r--r-- local/local  240276 2005-07-12 11:46:13 
R-patched/src/library/Recommended/mgcv_1.3-4.tar.gz
-rw-r--r-- local/local  662143 2005-07-26 11:45:13 
R-patched/src/library/Recommended/nlme_3.1-62.tar.gz
-rw-r--r-- local/local  110072 2005-04-19 11:45:20 
R-patched/src/library/Recommended/rpart_3.1-23.tar.gz
-rw-r--r-- local/local  846737 2005-06-10 11:45:23 
R-patched/src/library/Recommended/survival_2.18.tar.gz
lrwxrwxrwx local/local   0 2005-08-03 20:45:50 
R-patched/src/library/Recommended/VR.tgz - VR_7.2-17.tar.gz
lrwxrwxrwx local/local   0 2005-08-03 20:45:50 
R-patched/src/library/Recommended/boot.tgz - boot_1.2-23.tar.gz
lrwxrwxrwx local/local   0 2005-08-03 20:45:50 
R-patched/src/library/Recommended/cluster.tgz - cluster_1.10.1.tar.gz
lrwxrwxrwx local/local   0 2005-08-03 20:45:50 
R-patched/src/library/Recommended/foreign.tgz - foreign_0.8-9.tar.gz
lrwxrwxrwx local/local   0 2005-08-03 20:45:50 
R-patched/src/library/Recommended/KernSmooth.tgz - 
KernSmooth_2.22-15.tar.gz
lrwxrwxrwx local/local   0 2005-08-03 20:45:50 
R-patched/src/library/Recommended/lattice.tgz - lattice_0.12-1.tar.gz
lrwxrwxrwx local/local   0 2005-08-03 20:45:50 
R-patched/src/library/Recommended/nlme.tgz - nlme_3.1-62.tar.gz
lrwxrwxrwx local/local   0 2005-08-03 20:45:50 
R-patched/src/library/Recommended/mgcv.tgz - mgcv_1.3-4.tar.gz
lrwxrwxrwx local/local   0 2005-08-03 20:45:50 
R-patched/src/library/Recommended/rpart.tgz - rpart_3.1-23.tar.gz
lrwxrwxrwx local/local   0 2005-08-03 20:45:50 
R-patched/src/library/Recommended/survival.tgz - survival_2.18.tar.gz


It appears to me that the recommended packages were in the tarball.

I suppose it is largely immaterial now given I have successfully
re-built R.

Thanks your help.

-- 
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Department of Public Health Sciences
Faculty of Medicine, University of Toronto
email: [EMAIL PROTECTED]  Tel: 416.946.8081  Fax: 416.971.2462

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


[R] Problem configuring R-patched

2005-08-04 Thread Kevin E. Thorpe
I downloaded R-patched (2005-08-04) from CRAN today.
I ran ./configure --enable-R-shlib

I received the error message:

checking for recommended packages... no
configure: error: Some of the recommended packages are missing
   Use --without-recommended-packages if this was intentional

I built a previous version of R-patched successfully on my system
which is running the SuSE 9,2 Pro Linux distribution.  I untarred the
tar ball into the same directory I did my last build on in case that's
important.

The only other differences between this attempt and my successful build
are:

1. I did not use --enable-R-shlib last time.
2. I found and installed the blas libraries for this build.

Have I messed up or made an erroneous assumption along the way?

Thanks

-- 
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Department of Public Health Sciences
Faculty of Medicine, University of Toronto
email: [EMAIL PROTECTED]  Tel: 416.946.8081  Fax: 416.971.2462

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


Re: [R] Problem configuring R-patched

2005-08-04 Thread Kevin E. Thorpe
Gavin Simpson wrote:
 On Thu, 2005-08-04 at 14:57 -0400, Kevin E. Thorpe wrote:
 
I downloaded R-patched (2005-08-04) from CRAN today.
I ran ./configure --enable-R-shlib

I received the error message:

checking for recommended packages... no
configure: error: Some of the recommended packages are missing
   Use --without-recommended-packages if this was intentional
 
  ^^
 So was this intentional?

No, it wasn't.

 
I built a previous version of R-patched successfully on my system
which is running the SuSE 9,2 Pro Linux distribution.  I untarred the
tar ball into the same directory I did my last build on in case that's
important.

The only other differences between this attempt and my successful build
are:

1. I did not use --enable-R-shlib last time.
2. I found and installed the blas libraries for this build.

Have I messed up or made an erroneous assumption along the way?
 
 
 Yes and No. You obviously haven't compiled R recently. If you haven't
 got the recommended packages in the source you are compiling, configure
 now gives an error, which quite clearly states (and you've quoted it in
 your email!) that it cannot find (some of) the recommended packages.

Actually, I compiled it about a week ago.  Here is my current version.

  version
  _
platform i686-pc-linux-gnu
arch i686
os   linux-gnu
system   i686, linux-gnu
status   Patched
major2
minor1.1
year 2005
month07
day  28
language R

When I compiled that version, I did my tar xzf to a clean directory
and did not receive that error.

 A solution - again given by the error message you quote! - is:
 
 ./configure --enable-R-shlib --without-recommended-packages
   ^
 
 That should clear things up.

I realise that would clear it up.  I was puzzled why I got this message
in the first place, given I didn't get it last week.

 Other wise you need to cd to the R directory (where you have the source
 code), and then execute ./tools/rsync-recommended and then run your
 configure command.
 
 HTH
 
 G

Thanks for the rsync tip.

-- 
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Department of Public Health Sciences
Faculty of Medicine, University of Toronto
email: [EMAIL PROTECTED]  Tel: 416.946.8081  Fax: 416.971.2462

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


Re: [R] Problem configuring R-patched

2005-08-04 Thread Kevin E. Thorpe
Duncan Murdoch wrote:
 Kevin E. Thorpe wrote:
 
 Gavin Simpson wrote:

 On Thu, 2005-08-04 at 14:57 -0400, Kevin E. Thorpe wrote:


 I downloaded R-patched (2005-08-04) from CRAN today.
 I ran ./configure --enable-R-shlib

 I received the error message:

 checking for recommended packages... no
 configure: error: Some of the recommended packages are missing
  Use --without-recommended-packages if this was intentional


 ^^
 So was this intentional?



 No, it wasn't.


 I built a previous version of R-patched successfully on my system
 which is running the SuSE 9,2 Pro Linux distribution.  I untarred the
 tar ball into the same directory I did my last build on in case that's
 important.

 The only other differences between this attempt and my successful build
 are:

 1. I did not use --enable-R-shlib last time.
 2. I found and installed the blas libraries for this build.

 Have I messed up or made an erroneous assumption along the way?



 Yes and No. You obviously haven't compiled R recently. If you haven't
 got the recommended packages in the source you are compiling, configure
 now gives an error, which quite clearly states (and you've quoted it in
 your email!) that it cannot find (some of) the recommended packages.



 Actually, I compiled it about a week ago.  Here is my current version.

   version
   _
 platform i686-pc-linux-gnu
 arch i686
 os   linux-gnu
 system   i686, linux-gnu
 status   Patched
 major2
 minor1.1
 year 2005
 month07
 day  28
 language R

 When I compiled that version, I did my tar xzf to a clean directory
 and did not receive that error.


 A solution - again given by the error message you quote! - is:

 ./configure --enable-R-shlib --without-recommended-packages
  ^

 That should clear things up.



 I realise that would clear it up.  I was puzzled why I got this message
 in the first place, given I didn't get it last week.
 
 
 I believe there are two kinds of tar files.  The daily snapshots don't 
 include the recommended packages, the releases do.
 
 Or perhaps the test is a recent addition.

Both versions were R-patched.tar.gz as opposed to the devel sets which
looks like it's actually a link to the most recent.  Maybe I incorrectly
assumed that the patched tarballs contained the recommended packages.

 Duncan Murdoch
 


 Other wise you need to cd to the R directory (where you have the source
 code), and then execute ./tools/rsync-recommended and then run your
 configure command.

 HTH

 G



 Thanks for the rsync tip.

Anyway, running rsync-recommended did the trick.

Thanks

-- 
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Department of Public Health Sciences
Faculty of Medicine, University of Toronto
email: [EMAIL PROTECTED]  Tel: 416.946.8081  Fax: 416.971.2462

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


Re: [R] R: regression data set

2005-08-02 Thread Kevin Wang
Clark Allan wrote:

 i would like to give the class a practical assignment as well. could you
 suggest a good problem and the location of the data set/s?
 
 it would be good if the data set has been analysed by a number of other
 people so that students can see the different ways of tackling a
 regression problem. 

If you want some textbook examples I'd recommend
Ripley and Venables's  Modern Applied Statistics With S (VR bundle);

Maindonald and Braun's Data Analysis and Graphics using R (DAAG package)

Cheers,

Kev

-- 
Ko-Kang Kevin Wang
PhD Student
Centre for Bioinformation Science
Building 27, Room 1004
Mathematical Sciences Institute (MSI)
Australian National University
Canberra, ACT 2601
Australia

Homepage: http://wwwmaths.anu.edu.au/~wangk/
Ph (W): +61-2-6125-2431
Ph (H): +61-2-6125-7407
Ph (M): +61-40-451-8301

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


Re: [R] error with scan

2005-07-26 Thread Kevin Bartz
Can you show us the first line of the file?

The error means that in one of the values you specified as numeric (first, 
second, third, fourth, fifth, seventh, eighth, ninth), it found the character 
value it displayed.

Otherwise, this looks like a good use of scan.

Kevin

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jean-Pierre 
Gattuso
Sent: Tuesday, July 26, 2005 11:52 AM
To: r-help@stat.math.ethz.ch
Cc: Jean-Pierre Gattuso
Subject: [R] error with scan

Hi:

I am trying to read a large (50+ lines) with scan() as read.table  
is unable to read it.

I get a strange error (below) which says that 'a real' was expected  
and '5' was read. Can someone help?

Thanks,
jp

  type=list(a=0,b=0,c=0,d=0,e=0,f=,g=0,h=0,i=0)
  tmp2 - scan(file=tmp2.txt, what=type, sep=,, quote=\,  
dec=., skip=1, nmax=541502)
Erreur dans scan(file = tmp2.txt, what = type, sep = ,, quote =  
\,  :
 scan() attendait 'a real' et a reçu '5
'

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

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


Re: [R] Cannot update some packages after upgrade to 2.1.1

2005-07-22 Thread Kevin E. Thorpe
Prof Brian Ripley wrote:

 On Wed, 20 Jul 2005, Kevin E. Thorpe wrote:

 Thank you for the information. I have contacted the RPM maintainer 
 and am awaiting a response.

 It occurs to me that my problem could also be fixed by putting 
 ATLAS on my system. Are there advantages to doing that or any reasons 
 not to?


 It is a good idea unless you share R systems between different 
 architectures (even down to the vintage of P4 or Xeon chips). We do 
 and so tend to avoid ATLAS (which gets statically compiled in by 
 default).

After following the discussion between you and Uwe, and thinking a bit, 
I've decided to give it a try. My system is basically stand-alone so 
different architectures are not an issue.

Now my question (recognising this may be the wrong list). I successfully 
compiled ATLAS, but it isn't clear to me from the install instructions 
that came with it how to make the libraries seen by gcc and g77 and 
therefore, presumably by the configure script with the R source. How do 
I make the libraries available? I've looked at the ATLAS project page 
and done a couple RSiteSearch's but have not yet recognised the answer 
to my question.


 Prof Brian Ripley wrote:

 -lf77blas is part of ATLAS, so I do suspect the RPM builder had 
 ATLAS installed.

 lme4 needs a compatible Matrix installed.

 I do think installing from the sources would solve this, but 
 probably you need to discuss this with the RPM maintainer as a 
 dependency appears to be missing.

 On Fri, 15 Jul 2005, Kevin E. Thorpe wrote:

 I just upgraded to version 2.1.1 (from 2.0.1) today.

  R.version
 _
 platform i686-pc-linux-gnu
 arch i686
 os linux-gnu
 system i686, linux-gnu
 status
 major 2
 minor 1.1
 year 2005
 month 06
 day 20
 language R

 I am using SuSE 9.2 and did the upgrade using rpm -U with the RPM
 available on CRAN. After upgrading r-base, I ran update.packages().
 Four previously installed packages failed to update:

 Matrix (0.95-5 to 0.97-4)
 gam (0.93 to 0.94)
 lme4 (0.95-3 to 0.96-1)
 mgcv (1.3-1 to 1.3-4)

 In the case of Matrix, gam and mgcv I get the message:

 [long path]/ld: cannot find -lf77blas

 In the case of lme4 the messages are:

 ** preparing package for lazy loading
 Error in setMethod(coef, signature(object = lmList), 
 function(object, :
 no existing definition for function 'coef'
 Error: unable to load R code in package 'lme4'
 Execution halted
 ERROR: lazy loading failed for package 'lme4'

 I have searched the SuSE repository for any package that provides
 f77blas but came up empty.

 I also could not identify any relevant messages in the mailing list
 archives.

 Is R looking for that library because it was present on the machine
 the RPM was built on? Would building R myself solve the missing 
 library
 problem or did I do something wrong?


-- 
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Department of Public Health Sciences
Faculty of Medicine, University of Toronto
email: [EMAIL PROTECTED]  Tel: 416.946.8081  Fax: 416.971.2462

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


Re: [R] Cannot update some packages after upgrade to 2.1.1

2005-07-20 Thread Kevin E. Thorpe
Thank you for the information. I have contacted the RPM maintainer and 
am awaiting a response.

It occurs to me that my problem could also be fixed by putting ATLAS 
on my system. Are there advantages to doing that or any reasons not to?

Prof Brian Ripley wrote:

 -lf77blas is part of ATLAS, so I do suspect the RPM builder had ATLAS 
 installed.

 lme4 needs a compatible Matrix installed.

 I do think installing from the sources would solve this, but probably 
 you need to discuss this with the RPM maintainer as a dependency 
 appears to be missing.

 On Fri, 15 Jul 2005, Kevin E. Thorpe wrote:

 I just upgraded to version 2.1.1 (from 2.0.1) today.

  R.version
 _
 platform i686-pc-linux-gnu
 arch i686
 os linux-gnu
 system i686, linux-gnu
 status
 major 2
 minor 1.1
 year 2005
 month 06
 day 20
 language R

 I am using SuSE 9.2 and did the upgrade using rpm -U with the RPM
 available on CRAN. After upgrading r-base, I ran update.packages().
 Four previously installed packages failed to update:

 Matrix (0.95-5 to 0.97-4)
 gam (0.93 to 0.94)
 lme4 (0.95-3 to 0.96-1)
 mgcv (1.3-1 to 1.3-4)

 In the case of Matrix, gam and mgcv I get the message:

 [long path]/ld: cannot find -lf77blas

 In the case of lme4 the messages are:

 ** preparing package for lazy loading
 Error in setMethod(coef, signature(object = lmList), 
 function(object, :
 no existing definition for function 'coef'
 Error: unable to load R code in package 'lme4'
 Execution halted
 ERROR: lazy loading failed for package 'lme4'

 I have searched the SuSE repository for any package that provides
 f77blas but came up empty.

 I also could not identify any relevant messages in the mailing list
 archives.

 Is R looking for that library because it was present on the machine
 the RPM was built on? Would building R myself solve the missing library
 problem or did I do something wrong?



-- 
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Department of Public Health Sciences
Faculty of Medicine, University of Toronto
email: [EMAIL PROTECTED]  Tel: 416.946.8081  Fax: 416.971.2462

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


[R] Cannot update some packages after upgrade to 2.1.1

2005-07-15 Thread Kevin E. Thorpe
I just upgraded to version 2.1.1 (from 2.0.1) today.

  R.version
  _
platform i686-pc-linux-gnu
arch i686
os   linux-gnu
system   i686, linux-gnu
status
major2
minor1.1
year 2005
month06
day  20
language R

I am using SuSE 9.2 and did the upgrade using rpm -U with the RPM
available on CRAN.  After upgrading r-base, I ran update.packages().
Four previously installed packages failed to update:

Matrix (0.95-5 to 0.97-4)
gam (0.93 to 0.94)
lme4 (0.95-3 to 0.96-1)
mgcv (1.3-1 to 1.3-4)

In the case of Matrix, gam and mgcv I get the message:

[long path]/ld: cannot find -lf77blas

In the case of lme4 the messages are:

** preparing package for lazy loading
Error in setMethod(coef, signature(object = lmList), function(object,  :
 no existing definition for function 'coef'
Error: unable to load R code in package 'lme4'
Execution halted
ERROR: lazy loading failed for package 'lme4'

I have searched the SuSE repository for any package that provides
f77blas but came up empty.

I also could not identify any relevant messages in the mailing list
archives.

Is R looking for that library because it was present on the machine
the RPM was built on?  Would building R myself solve the missing library
problem or did I do something wrong?

-- 
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Department of Public Health Sciences
Faculty of Medicine, University of Toronto
email: [EMAIL PROTECTED]  Tel: 416.946.8081  Fax: 416.971.2462

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


[R] logistic regression asymptote problem

2005-07-05 Thread Kevin J Emerson
R-helpers,

I have a question about logistic regressions.

Consider a case where you have binary data that reaches an asymptote
that is not 1, maybe its 0.5.  Can I still use a logistic regression to
fit a curve to this data?  If so, how can I do this in R.  As far as I
can figure out, using a logit link function assumes that the asymptote
is at y = 1.

An example.  Consider the following data:

tmp -
structure(list(x = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 
14), yes = c(0, 0, 0, 2, 1, 14, 24, 15, 23, 18, 22, 20, 14, 17
), no = c(94, 101, 95, 80, 81, 63, 51, 56, 30, 38, 31, 18, 21, 
20)), .Names = c(x, yes, no), row.names = c(1, 2, 3, 
4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14), class =
data.frame)

where x is the independent variable, and yes and no are counts of
events.  plotting the data you can see that the data seem to reach an
asymptote at around y=0.5.  using glm to fit a logistic regression it is
easily seen that it does not fit well.

tmp.glm - glm(cbind(yes,no) ~ x, data = tmp, family = binomial(link =
logit))
plot(tmp.glm$fitted, type = l, ylim = c(0,1))
par(new=T)
plot(tmp$yes / (tmp$yes + tmp$no), ylim = c(0,1))

Any suggestions would be greatly appreciated.

Cheers,
Kevin

-- 


Kevin J Emerson
Center for Ecology and Evolutionary Biology
1210 University of Oregon
University of Oregon
Eugene, OR 97403
[EMAIL PROTECTED]

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


Re: [R] Finding out collinearity in regression

2005-06-29 Thread Kevin Wang
Hi,

Young Cho wrote:

 fit - aov( Y ~ . , data = dat)
 Error in contrasts-(`*tmp*`, value =
 contr.treatment) :
 contrasts can be applied only to factors with
 2 or more levels
 
 I think there is a dependency in explanatory
 variables. So, I wanted to use alias to find out a
 dependency in design matrix but I can't because I
 cannot create fit in the first place.

The error message actually looks like you have got (at least) a variable 
that only has 1 level, e.g. a factor with only one level.

Cheers,

Kev

-- 
Ko-Kang Kevin Wang
PhD Student
Centre for Bioinformation Science
Building 27, Room 1004
Mathematical Sciences Institute (MSI)
Australian National University
Canberra, ACT 2601
Australia

Homepage: http://wwwmaths.anu.edu.au/~wangk/
Ph (W): +61-2-6125-2431
Ph (H): +61-2-6125-7407
Ph (M): +61-40-451-8301

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


[R] frequency tables

2005-06-20 Thread Kevin J Emerson
R-masters,

I have a problem that I have been working on for a while and it seems
that there may be a simple solution that I have yet to figure out, so I
thought that I would venture to post to the help list.

Let's say there was a data.frame with three vectors, two that are
factors identifying the data, and one that holds the frequency of
occurrence (the events are binary, yes or no).  I would like to perform
logistic regression on this data, and it seems that I need a vector of
0s and 1s for input into lrm.  How might I convert between a frequency
table and a vector of binary data while still maintaining all identifier
information?

I have thought about using the rep command over and over again and
basically building the data.frame by hand but that seems long and
tedious.  Is there a quick and dirty way of doing this?

Thanks in advance!
Kevin
-- 


Kevin J Emerson
Center for Ecology and Evolutionary Biology
1210 University of Oregon
University of Oregon
Eugene, OR 97403
[EMAIL PROTECTED]

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


Re: [R] vectorization

2005-06-17 Thread Kevin Bartz
These two lines worked for me:

rst - tapply(mydata$income, mydata$education, median)
mydata$md - rst[mydata$education]

Here's my cheesy example:

 mydata - data.frame(income= round(rnorm(3, 55000, 1)),
+  education = letters[rbinom(3, 4, 1/2)+1])
 rst - tapply(mydata$income, mydata$education, median)
 mydata$md - rst[mydata$education]
 head(mydata)
  income education  md
1  66223 e 55094.5
2  56830 c 54966.0
3  58035 b 54937.5
4  74045 a 55213.5
5  61327 b 54937.5
6  64150 b 54937.5

Is this what you wanted?

Kevin

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Dimitri Joe
Sent: Friday, June 17, 2005 10:01 AM
To: R-Help
Subject: [R] vectorization

Hi there,

I have a data frame (mydata) with 1 numeric variable (income) and 1
factor (education). I want a new column in this data with the median
income for each education level. A obviously inneficient way to do this
is

for ( k in 1: nrow(mydata) ){
l - mydata$education[k]
mydata$md[k] - median(mydata$income[mydata$education==l],na.rm=T)
}

Since mydata has nearly 30.000 rows, this will be done not untill the
end of this month. I thus need some help for vectorizing this, please.

Thanks,

Dimitri

[[alternative HTML version deleted]]






___ 

Instale o discador agora! http://br.acesso.yahoo.com/

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

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


  1   2   3   >