[R] Generating valid R code using R

2006-07-16 Thread Henrik Bengtsson
Hi,

I'm trying to generate valid R code using R. Parts of the task is to
read a sequence of characters from file and escape them such that they
can be put in quotation marks to form a valid R code string.  Example:

Let the input file be (four rows containing ASCII 0-255 characters):
abcdeftabghijk\nlmno
second row\t\a\\

fourth and so on...
EOF

Now, find escapeString() such that the following piece of code
generates a second file called 'file2.txt' which is identical to
'file1.txt':

inStr - readChar(file1.txt, nchars=999)
esStr - escapeString(inStr)
rCode - sprintf('cat(file=file2.txt, %s)', esStr)
cat(file=foo.R, rCode)
source(foo.R)

For instance, quotation marks has to be escaped in order for 'rCode'
to be valid, same with newlines etc.  What's the best way to do this?
Currently I use an ad hoc sequence of gsub() substitutions to do this,
but is there a better way to create the 'rCode' string?

Thanks

Henrik

__
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] CFD Plots in R and Other Things

2006-07-16 Thread Lorenzo Isella
Dear All,

I am getting some data from fluid dynamics simulations (air mixing in
a pipe, 2D axial symmetry, geometry described by a radial coordinate r
and an axial coordinate z) which I'd like to plot and analyze with R.
Think about slicing the cylinder along its axial direction to get a
set of cross sections which are orthogonal to the z axis.
For each section, I have a set of velocity readings, i.e. the data I
would like to plot are in the form:

   v_11 v_12  v_13 . v_1n
   v_21 v_22  v_23 . v_2n
   ..
   v_m1 v_m2  v_m3 . v_mn

where v_ij is the velocity reading on the i-th position along z and
the j-th position along r.
Tipically, these sets of data are plotted in 2D with r and z as axis
and the velocity  field represented by using colours explained by a
legenda.
Can R do anything like this?
Second (and much simpler question): I have a list of data which I can
plot easily, but I would like to have the time during the day to label
the x axis (starting from 19:00 for forty hours).
How can I do that?
Many thanks

Lorenzo

__
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] dataframe computation behaviour

2006-07-16 Thread Mihai Nica
Greetings:



I have a simple issue; the (probably cumbersome) code follows:

#___

datmod=(dat)

datmod$em96gbr=ifelse(datmod$em96gbr  0, log(datmod$em96gbr),
datmod$em96gbr)

datmod$em96spbr=ifelse(datmod$em96spbr  0, log(datmod$em96spbr),
datmod$em96spbr)

datmod[,4:8]=log(datmod[,4:8])

datmod[,10:13]=log(datmod[,10:13])

datmod[,15:28]=log(datmod[,15:28])

datmod[,4:23]=datmod[,4:23]-datmod$p97

datmod[,25:26]=datmod[,25:26]-datmod$p97

#__

It works fine with the exception of datmod[,26] where the operation -
datmod$p97 is not performed. I thought this might be interesting enough to
share with the list :-)



mihai

[[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] break axis using plotrix

2006-07-16 Thread Henrik Parn
Dear all,

I am trying to plot some data with differing range in y-values with 
type=b, adding error bars and break the y-axis into two parts, one 
lower part from 12 to 20, and one upper part from 34 to 40.

I have tried to follow the basic ideas from the script provided here by 
Jim Lemon:
http://finzi.psych.upenn.edu/R/Rhelp02a/archive/56487.html


My attempt looks like this:

###
# x-values
x - 1:4

# small y-values with corresponding standard errors
meansarr - c(14.9, 18.2, 14.5, 18.3)
searr - c(0.47, 1.27, 1.22, 0.49)

# large values
meanslay - c(36.4, 39.0, 35.3, 38.6)
selay - c(0.51, 0.34, 0.57, 0.40)

library(plotrix)

# plot small values
plot(x, meansarr, ylim=c(12, 30), axes=F, type=b, xlab=, ylab=Day)
arrows(x, meansarr-searr, x, meansarr+searr, code = 3, angle = 90, 
length = 0.03)
box()

# x-axis
axis(1, tck=0.01, las=1, at=1:4,
labels=c(1998, 1999, 2002, 2003), mgp=c(3, 0.5, 0))

# y-axis
axis(2,at=c(12, 14, 16, 18, 20, 24, 26, 28, 
30),labels=c(12,14,16,18,20, 34,36,38,40))


# break axis
axis.break(2, 22, style=zigzag)

# add large values to same plot
par(new=TRUE)
plot(x, meanslay, ylim=c(30, 40), type=b, xlab=, ylab=Day, axes=F)
arrows(x, meanslay-selay, x, meanslay+selay, code = 3, angle = 90, 
length = 0.03)





As you can see, I have problems adding the larger y-values - they end up 
in the wrong place in the graph. I suppose Jim's warning 'just be 
careful that the ylim= and labels= arguments match up' is relevant here, 
but I don't manage to fix it...


Can anyone help me to plot the large y-values on the right 
placeaccording to the y-axis labeling?
I am using R 2.3.1 and WinXp.

Thanks a lot in advance!

Henrik


-- 

Henrik Pärn
Department of Biology
NTNU
7491 Trondheim
Norway

+47 735 96282 (office)
+47 909 89 255 (mobile)
+47 735 96100 (fax)

__
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] CFD Plots in R and Other Things

2006-07-16 Thread Gabor Grothendieck
Look at ?image, ?contour and in the lattice package ?contourplot,
?levelplot, ?wireframe, ?cloud and in scatterplot3d package
scatterplot3d.  Try example() on each one, e.g. example(image),
to get an idea if its what you want. Also google for the R Graph Gallery
and look through the charts there.

For the second question you can customize the x axis labels
by not drawing them in plot and drawing them yourself using axis:

tt - 19 + 0:40
plot(tt, tt, xaxt = n)
axis(1, tt, paste(tt, 00, sep = :), cex.axis = 0.5)
abline(v = tt, col = grey)  # optional



On 7/16/06, Lorenzo Isella [EMAIL PROTECTED] wrote:
 Dear All,

 I am getting some data from fluid dynamics simulations (air mixing in
 a pipe, 2D axial symmetry, geometry described by a radial coordinate r
 and an axial coordinate z) which I'd like to plot and analyze with R.
 Think about slicing the cylinder along its axial direction to get a
 set of cross sections which are orthogonal to the z axis.
 For each section, I have a set of velocity readings, i.e. the data I
 would like to plot are in the form:

   v_11 v_12  v_13 . v_1n
   v_21 v_22  v_23 . v_2n
   ..
   v_m1 v_m2  v_m3 . v_mn

 where v_ij is the velocity reading on the i-th position along z and
 the j-th position along r.
 Tipically, these sets of data are plotted in 2D with r and z as axis
 and the velocity  field represented by using colours explained by a
 legenda.
 Can R do anything like this?
 Second (and much simpler question): I have a list of data which I can
 plot easily, but I would like to have the time during the day to label
 the x axis (starting from 19:00 for forty hours).
 How can I do that?
 Many thanks

 Lorenzo

 __
 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] put R on a web server

2006-07-16 Thread Jean lobry
Has anyone put R on a web server any time, recently, please?

It depends on what you mean by recently.

R 2.3.1 and 1054 packages at http://kryton.cc.unt.edu/cgi-bin/R/Rprog
R 2.3.1 and 1046 packages at http://www.unt.edu/rss/Rinterface.htm
R 2.3.1 and 499  packages at http://pbil.univ-lyon1.fr/Rweb/
R 2.3.0 and 85   packages at http://rweb.stat.umn.edu/Rweb/
R 2.2.1 and 359  packages at http://actin.ucd.ie/Rweb/
R 2.2.0 and 25   packages at http://www.digitalhermit.com/math/Rweb.html
R 2.2.0 and 25   packages at http://r.nakama.ne.jp/Rweb-jp/
R 2.1.0 and 25   packages at http://dssm.unipa.it/R-php/
R 2.1.0 and 25   packages at 
http://homeworld.rutgers.edu/Rweb/Rweb.general.html
R 2.0.1 and 526  packages at http://www.ms.uky.edu/~statweb/
R 1.9.1 and 35   packages at http://origin.scic.ulst.ac.uk/Rweb/
R 1.9.0 and 106  packages at http://hermes.sdu.dk/cgi-bin/go/
R 1.9.0 and 48   packages at http://claree.univ-lille1.fr/Rweb/
R 1.8.1 and 30   packages at http://www.er.uqam.ca/nobel/r17165/Rweb/Rweb.html
R 1.8.1 and 30   packages at http://bayes.math.montana.edu/Rweb/
R 1.7.0 and 49   packages at http://bic.uams.edu/Rweb/
R 1.6.1 and 28   packages at 
http://user.cs.tu-berlin.de/~ulfi/cgi-bin/r-online/r-online.cgi
R 1.5.0 and 32   packages at http://www.nku.edu/~longa/Rweb/
R 1.3.0 and 11   packages at http://genome1.beatson.gla.ac.uk/Rweb/

-- 
Jean R. Lobry([EMAIL PROTECTED])
Laboratoire BBE-CNRS-UMR-5558, Univ. C. Bernard - LYON I,
43 Bd 11/11/1918, F-69622 VILLEURBANNE CEDEX, FRANCE
allo  : +33 472 43 12 87 fax: +33 472 43 13 88
http://pbil.univ-lyon1.fr/members/lobry/

__
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 with installation of older R-version

2006-07-16 Thread Christoph Clases
to whom it may concern, 

i hope that someone might help 

i do need to install an older base-package  

 R 1.6.2 (January, 2003) 

on my windows-xp computer. 

when i try to install the rw1062-1.exe file
the following error-message pops up. 

The setup files are corrupted. Please obtain 
a new copy of the program.

i downloaded the exe-file from various mirror
sites, however, unfortunately the same message
comes up again and again. 

has anyone already experiences with this problem? 

i would very much appreciate your help. 

with best regards and sunny greets, 
christoph clases


[[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] ts and stl functions - still a problem

2006-07-16 Thread Spencer Graves
  The 'ts' function retains the 'dim' attribute of 'tkr'.  When 'stl' 
finds this 'dim' attribute, it thinks 'tstkr' is a multivariate time 
series.  This causes it to stop with the error, only univariate series 
allowed.

  Consider the following modification of an example from the 'stl' help 
file:

  not.1 - stl(nottem, per)
  Nottem - ts(array(nottem, dim=c(240, 1)))
  Not.1 - stl(Nottem)
Error in stl(Nottem) : only univariate series are allowed

  Solution:

tstkr - ts(as.numeric(tkr), deltat=1/12)

  After converting tkr and tstkr from a matrix to a vector like this, 
please try 'stl(tstkr)'.  If it doesn't work, please submit another post.

  Hope this helps.
  Spencer Graves
p.s.  Your example was not quite self-contained, because I didn't know 
for sure the format, class, and attributes of your 'tkr' object.  The 
absence of these details made it harder for me (and, I believe, anyone 
else) to reply.  You might get better replies quicker with greater 
attention to such details.

Daniel sutcliffe wrote:
 Hi

   I am still having problems with using the stl 
function, when I read the csv file into R into a
file called tkr and use dim(tkr) the result is 132 x 1
which is fine.

   When coerce it into a trime series using ts either:


   tstkr - ts(t(tkr), deltat=1/12) or

   tstkr - ts(c(tkr), deltat=1/12) 

   and use the stl function I get the following error:

   Error in stl(tstkr) : only univariate series are allowed

   id just use the tkr file I get the same error..does anyibe have an idea 
 what to do next, here is my data...it's not sensitive so if anyone wants to 
 try then you are very welcome!
   Rate184.0222180.517222.5792173.5066192.7852 
198.0429182.2696189.28178.7644206.8059236.6
 155.9807231.7314249.2868222.9537198.3761201.8872
 208.9094242.2646221.1982228.2203245.7757244.0202
 194.865239.3664234.0862251.6867235.8463197.1253
 237.6063267.5271228.8061241.1264249.9267256.9669
 188.325258.8788239.5069214.8518234.2237211.3296
 234.2237237.7458156.7361239.5069225.4183257.1177
 170.8248230.1611265.3001296.9253193.265233.675
 240.7028249.4876205.5637237.1889237.1889289.8975
 245.9736283.1755316.3875372.3234234.2316263.9476
 314.6395286.6715272.6875323.3795295.4115300.6555
 174.7997227.184277.4767317.364234.121286.1478279.2109 
280.9452235.8552319.0982   
  296.5532303.4901173.4229302.6072312.8651389.7991
 223.9635254.7371329.9615288.93317.994312.8651381.2509 
333.3808194.8996285.5743304.0526335.9698307.4123
 346.0489288.934335.9698243.5781384.6854359.4876
 357.8078221.74336.3712344.6562389.3952286.6611
 338.0282407.6222356.2552241.9221347.9702400.9942
 381.1102304.8882383.9077418.5089476.1774331.1822
 378.9647375.6694339.4206364.1357420.1565446.5193
 410.2705296.5811

   Cheers and thanks to everyone who offered suggestions before.

   Daniel



   
 
 SAULEAU Erik-André [EMAIL PROTECTED] wrote:
   Perhaps ts(t(tkr))?
 
 -Message d'origine-
 De : Daniel sutcliffe [mailto:[EMAIL PROTECTED] 
 Envoyé : mercredi 12 juillet 2006 15:53
 À : r-help@stat.math.ethz.ch
 Objet : [R] ts and stl functions


 Hi, 

 I have imported a csv file into R which contains one column 
 (the rate er 100,000 population of a disease, by month over 
 11 years) I coerced into a time series using the following function, 

 tstkr-ts(tkr,deltat=1/12) 

 This seems to work fine, and when I check for the class of 
 the object using class(tstkr) I get ts as the response. 

 When I try to use the stl function in stats I get the error message: 

 Error in stl(tstkr)only univariate series are allowed 

 I then tried this: 

 tstkr - ts(c(tkr), deltat=1/12) 

 however this made no difference...I still get an error - does 
 anybody know what is wrong? 

 Regards, 

 Daniel 


 -

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


 **
 
 Afin d'eviter toute propagation de virus informatique, et en 
 complement 
 des dispositifs en place, ce message (et ses pieces jointes 
 s'il y en a) 
 a ete automatiquement analyse par un antivirus de messagerie. 
 

[R] Trailing on r-help messages

2006-07-16 Thread Gabor Grothendieck
I would like to propose that we change the trailer on r-help
messages which is currently:

   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

to add the following 4th line:

   and provide minimal, self-contained, reproducible code.

The posting guide is so long that I suspect few people really read
it so at least this way the most important part of the message about
posting would be readily visible without further user action.

Of course minimal refers to cutting the code down to remove
anything not related to the question at hand while self-contained
and reproducible refer to being able to copy the code from
the post and paste it into an R session to reproduce the
problem.

__
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] Trailing on r-help messages

2006-07-16 Thread Spencer Graves
Hi, Gabor:

  Sounds great.  May I suggest a minor modification something like the 
following;

 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE include in your post minimal, self-contained, reproducible 
code as suggested in posting guide, 
www.R-project.org/posting-guide.html.  Posts more consistent with this 
standard tend to get quicker, more useful replies.

  I'd also suggest adding something like this to the Special Interest 
Group posts as well.  I also reply to questions on R-sig-finance, and I 
find myself going to R-help to copy the PLEASE do read the posting 
guide comment for r-sig-finance.

  Thanks for suggesting this.
  Spencer Graves

Gabor Grothendieck wrote:
 I would like to propose that we change the trailer on r-help
 messages which is currently:
 
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
 
 to add the following 4th line:
 
and provide minimal, self-contained, reproducible code.
 
 The posting guide is so long that I suspect few people really read
 it so at least this way the most important part of the message about
 posting would be readily visible without further user action.
 
 Of course minimal refers to cutting the code down to remove
 anything not related to the question at hand while self-contained
 and reproducible refer to being able to copy the code from
 the post and paste it into an R session to reproduce the
 problem.
 
 __
 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] Trailing on r-help messages

2006-07-16 Thread hadley wickham
Personally, I doubt anyone actually reads the bottom of the emails,
and generally it is too late anyway, as they have already sent the
message.  Much like the opening text in R, details in footer tend to
trigger legalese neurons and are largely ignored.

I think it would be more useful to radically redesign the signup page
so that pertinent information is highlighted and the page made easily
scannable.  As it is, the eye tends to skip to the action part and
fill out name and email address without reading the rest of the page.

Hadley

On 7/16/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
 I would like to propose that we change the trailer on r-help
 messages which is currently:

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

 to add the following 4th line:

and provide minimal, self-contained, reproducible code.

 The posting guide is so long that I suspect few people really read
 it so at least this way the most important part of the message about
 posting would be readily visible without further user action.

 Of course minimal refers to cutting the code down to remove
 anything not related to the question at hand while self-contained
 and reproducible refer to being able to copy the code from
 the post and paste it into an R session to reproduce the
 problem.

 __
 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] Trailing on r-help messages

2006-07-16 Thread Mihai Nica
Or just reminding the rules to the list now and then (as it was done today). I, 
for one, am happy I got reminded, and appologise for my previous posting. 
Trying to provide reproductible code forced me to find my own mistake!

mihai

hadley wickham [EMAIL PROTECTED] wrote: Personally, I doubt anyone actually 
reads the bottom of the emails,
and generally it is too late anyway, as they have already sent the
message.  Much like the opening text in R, details in footer tend to
trigger legalese neurons and are largely ignored.

I think it would be more useful to radically redesign the signup page
so that pertinent information is highlighted and the page made easily
scannable.  As it is, the eye tends to skip to the action part and
fill out name and email address without reading the rest of the page.

Hadley

On 7/16/06, Gabor Grothendieck  wrote:
 I would like to propose that we change the trailer on r-help
 messages which is currently:

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

 to add the following 4th line:

and provide minimal, self-contained, reproducible code.

 The posting guide is so long that I suspect few people really read
 it so at least this way the most important part of the message about
 posting would be readily visible without further user action.

 Of course minimal refers to cutting the code down to remove
 anything not related to the question at hand while self-contained
 and reproducible refer to being able to copy the code from
 the post and paste it into an R session to reproduce the
 problem.

 __
 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



Mihai Nica
ITT Tech instructor
Jackson State University
170 East Griffith St. G5
Jackson, MS 39201
601-914-0361

-

[[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] Trailing on r-help messages

2006-07-16 Thread Gabor Grothendieck
On 7/16/06, hadley wickham [EMAIL PROTECTED] wrote:
 Personally, I doubt anyone actually reads the bottom of the emails,
 and generally it is too late anyway, as they have already sent the
 message.  Much like the opening text in R, details in footer tend to
 trigger legalese neurons and are largely ignored.

They might read it when reading other people's messages since
it would be at the bottom of every single one.

 I think it would be more useful to radically redesign the signup page
 so that pertinent information is highlighted and the page made easily
 scannable.  As it is, the eye tends to skip to the action part and
 fill out name and email address without reading the rest of the page.

Good idea.   Of course these are not mutually exclusive.


 Hadley

 On 7/16/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
  I would like to propose that we change the trailer on r-help
  messages which is currently:
 
 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
 
  to add the following 4th line:
 
 and provide minimal, self-contained, reproducible code.
 
  The posting guide is so long that I suspect few people really read
  it so at least this way the most important part of the message about
  posting would be readily visible without further user action.
 
  Of course minimal refers to cutting the code down to remove
  anything not related to the question at hand while self-contained
  and reproducible refer to being able to copy the code from
  the post and paste it into an R session to reproduce the
  problem.
 
  __
  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] Trailing on r-help messages

2006-07-16 Thread Gabor Grothendieck
I was trying to keep it to 4 lines making it more likely read
than a longer description.

On 7/16/06, Spencer Graves [EMAIL PROTECTED] wrote:
 Hi, Gabor:

  Sounds great.  May I suggest a minor modification something like the
 following;

  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE include in your post minimal, self-contained, reproducible
 code as suggested in posting guide,
 www.R-project.org/posting-guide.html.  Posts more consistent with this
 standard tend to get quicker, more useful replies.

  I'd also suggest adding something like this to the Special Interest
 Group posts as well.  I also reply to questions on R-sig-finance, and I
 find myself going to R-help to copy the PLEASE do read the posting
 guide comment for r-sig-finance.

  Thanks for suggesting this.
  Spencer Graves

 Gabor Grothendieck wrote:
  I would like to propose that we change the trailer on r-help
  messages which is currently:
 
 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
 
  to add the following 4th line:
 
 and provide minimal, self-contained, reproducible code.
 
  The posting guide is so long that I suspect few people really read
  it so at least this way the most important part of the message about
  posting would be readily visible without further user action.
 
  Of course minimal refers to cutting the code down to remove
  anything not related to the question at hand while self-contained
  and reproducible refer to being able to copy the code from
  the post and paste it into an R session to reproduce the
  problem.
 
  __
  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] rbind, array

2006-07-16 Thread Robert Mcfadden
Hello,

I'm looping something like rbind for array. More precisely: if I define  

y-array(c(1:27),dim=c(3,3,3)) and I take 3 matrix: y[,,1], y[,,2], y[,,3]
and write rbind(y[,,1], y[,,2], y[,,3]) I get what I want. But what if I
have hundreds such matrix. How to do it.

Robert  

 


[[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] rbind, array

2006-07-16 Thread Richard M. Heiberger
download library(abind).

__
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] rbind, array

2006-07-16 Thread Gabor Grothendieck
Try this:

y - array(1:27, c(3, 3, 3))   # test array
rbind(y[,,1], y[,,2], y[,,3])
apply(y, 2, I)

# verify that last two lines give same result
identical(apply(y, 2, I), rbind(y[,,1], y[,,2], y[,,3]))  # TRUE

On 7/16/06, Robert Mcfadden [EMAIL PROTECTED] wrote:
 Hello,

 I'm looping something like rbind for array. More precisely: if I define

 y-array(c(1:27),dim=c(3,3,3)) and I take 3 matrix: y[,,1], y[,,2], y[,,3]
 and write rbind(y[,,1], y[,,2], y[,,3]) I get what I want. But what if I
 have hundreds such matrix. How to do it.

 Robert




[[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-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] Trailing on r-help messages

2006-07-16 Thread Spencer Graves
Hi, Gabor:  Yes.  Saying more often communicates less.  Spencer Graves

Gabor Grothendieck wrote:
 I was trying to keep it to 4 lines making it more likely read
 than a longer description.
 
 On 7/16/06, Spencer Graves [EMAIL PROTECTED] wrote:
 Hi, Gabor:

  Sounds great.  May I suggest a minor modification something like the
 following;

  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE include in your post minimal, self-contained, reproducible
 code as suggested in posting guide,
 www.R-project.org/posting-guide.html.  Posts more consistent with this
 standard tend to get quicker, more useful replies.

  I'd also suggest adding something like this to the Special Interest
 Group posts as well.  I also reply to questions on R-sig-finance, and I
 find myself going to R-help to copy the PLEASE do read the posting
 guide comment for r-sig-finance.

  Thanks for suggesting this.
  Spencer Graves

 Gabor Grothendieck wrote:
 I would like to propose that we change the trailer on r-help
 messages which is currently:

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

 to add the following 4th line:

and provide minimal, self-contained, reproducible code.

 The posting guide is so long that I suspect few people really read
 it so at least this way the most important part of the message about
 posting would be readily visible without further user action.

 Of course minimal refers to cutting the code down to remove
 anything not related to the question at hand while self-contained
 and reproducible refer to being able to copy the code from
 the post and paste it into an R session to reproduce the
 problem.

 __
 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] Trailing on r-help messages

2006-07-16 Thread hadley wickham
 They might read it when reading other people's messages since
 it would be at the bottom of every single one.

Perhaps, it might also trigger same-blindness: seeing the same thing
again and again makes it less and less likely to really percieve it.

Hadley

__
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] Trailing on r-help messages

2006-07-16 Thread Gabor Grothendieck
On 7/16/06, hadley wickham [EMAIL PROTECTED] wrote:
  They might read it when reading other people's messages since
  it would be at the bottom of every single one.

 Perhaps, it might also trigger same-blindness: seeing the same thing
 again and again makes it less and less likely to really percieve it.

 Hadley


I think that is likely true but it would at least mean that they had
seen it repeatedly and there would really be no excuse for not following it
(unlike the current situation where one needs to take action to follow
the posting guide link and then read a lengthy page).

__
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] install.packages for local zip files

2006-07-16 Thread Daniel Gatti
O/S: Linux
R version : 2.2.1

The R server doesn't have http internet access.  And the sys admins will 
not install the R libraries that I requested.  So I have downloaded the 
packages that I want to intall and have moved them into my home 
directory on the server.  These are a series of *.tar.gz files.  I want 
to install the R libraries in my home directory, but I can't get it to 
work.  According to the install.packages documentation :

install.packages(pkgs, lib, repos = getOption(repos),  contriburl = 
contrib.url(repos, type), method, available = NULL, destdir = NULL, 
installWithVers = FALSE, dependencies = FALSE, type = getOption(pkgType))

repos: character vector, the base URL(s) of the repositories to use,
   i.e.,  Can be 'NULL' to install from local '.tar.gz' files.

contriburl: URL(s) of the contrib section of the repositories. ..
   Can be 'NULL' to install from local '.tar.gz' files.


 pkgs: character vector of the short names of packages/bundles whose
  current versions should be downloaded from the repositories.
  If 'repos = NULL', a character vector of file paths of
  '.tar.gz' files.  These can be source archives or binary
  package/bundle archive files (as created by 'R CMD build
  --binary'). ..

 lib: character vector giving the library directories where to install 
the packages.  Recycled as needed.

So I have issued a command like this:

  install.packages(pkgs=~/Rdownloads/hgug4112a_1.12.0.tar.gz, lib = 
~/Rlib, repos=NULL, contriburl=NULL)

Warning in download.packages(pkgs, destdir = tmpd, available = 
available,  :
 no package '~/Rdownloads/hgug4112a_1.12.0.tar.gz' at the 
repositories

As far as I can tell, I've given it the full path to the zip file, the 
directory in which to install the library and I've set the repository 
path to 'NULL' to indicate that I'm installing from an already 
downloaded zip file.  But I'm missing something.  Any ideas?

Thanks,
Dan

__
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] Manipulation involving arrays

2006-07-16 Thread RAVI VARADHAN
Hi,

I have the following piece of code that is part of a larger function.  This 
piece is the most time consuming part of the function, and I would like to make 
this a bit more efficient.  Could anyone suggest a way to do this faster?  

In particular, I would like to replace the nested for loop with a faster 
construct.  I tried things like kronecker and outer combined with apply, 
but couldn't get it to work.


Here is a sample code:

 ##
 n - 120
 sigerr - 5
 covmat - diag(c(8,6,3.5))
 mu - c(105,12,10)
 mcsamp - 1
 
 Tbar - array(0, dim=c(3,3,n))
 
 # theta is a mcsamp x 3 matrix
 theta - mvrnorm(mcsamp, mu = mu, Sigma = covmat)
 
 wt - matrix(runif(n*mcsamp),n,mcsamp) 
 wti - apply(wt,1,sum)
 
 tarray - array(apply(theta,1,function(x)outer(x,x)),dim=c(3,3,mcsamp))
 
 for (i in 1:n) {
 for (k in 1:mcsamp) {
 Tbar[,,i] - Tbar[,,i] + wt[i,k] * tarray[,,k]
 } 
 Tbar[,,i] - Tbar[,,i] / wti[i]
 }

###

Thanks very much,
Ravi.

__
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] Hmisc xYplot

2006-07-16 Thread Erin Berryman

Dear R community,

I am having trouble with a particular plot that I am trying to produce 
using Hmisc's xYplot function. I've been using primarily lattice and 
Hmisc packages for my plotting needs for the past few years, with great 
success.
However, what I want to do now with xYplot is plot more than one data 
trend in the same panel, much as I would use xyplot from package 
lattice in conjunction with superpose, with type=b. My problem is I 
can't get the error bars to plot when I use xYplot this way. I've 
attached my data set for reference.


Here are my inputs:

p1sum-read.csv(file=p1sum.csv, header=T)
library(Hmisc)
xYplot(Cbind(DRP, SE) + Cbind(Fe, FeSE) ~ Day | Group + Port,  p1sum, 
type='b')


The plotted result is two lines per panel, one labeled Cbind(DRP, SE) 
and the other labeled Cbind(Fe, FeSE). However, the error bars are not 
plotted at all (I want the error bars to be DRP +/- SE, and Fe +/- 
FeSE). Any advice on this is greatly appreciated.


Thank you,

Erin





Erin Berryman
***PLEASE- NOTE NEW EMAIL [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] Manipulation involving arrays

2006-07-16 Thread Gabor Grothendieck
The double loop is the same as:

 Tbar[] - matrix(tarray, 9) %*% t(wt) / rep(wti, each = 9)


On 7/16/06, RAVI VARADHAN [EMAIL PROTECTED] wrote:
 Hi,

 I have the following piece of code that is part of a larger function.  This 
 piece is the most time consuming part of the function, and I would like to 
 make this a bit more efficient.  Could anyone suggest a way to do this faster?

 In particular, I would like to replace the nested for loop with a faster 
 construct.  I tried things like kronecker and outer combined with apply, 
 but couldn't get it to work.


 Here is a sample code:

  ##
  n - 120
  sigerr - 5
  covmat - diag(c(8,6,3.5))
  mu - c(105,12,10)
  mcsamp - 1

  Tbar - array(0, dim=c(3,3,n))

  # theta is a mcsamp x 3 matrix
  theta - mvrnorm(mcsamp, mu = mu, Sigma = covmat)

  wt - matrix(runif(n*mcsamp),n,mcsamp)
  wti - apply(wt,1,sum)

  tarray - array(apply(theta,1,function(x)outer(x,x)),dim=c(3,3,mcsamp))

  for (i in 1:n) {
  for (k in 1:mcsamp) {
  Tbar[,,i] - Tbar[,,i] + wt[i,k] * tarray[,,k]
  }
  Tbar[,,i] - Tbar[,,i] / wti[i]
  }


__
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] sem question

2006-07-16 Thread Spencer Graves


MODEL UNDERIDENTIFIED?

  I've looked at 'sem' for many years but never found that application 
that seemed to me to require that machinery.  However, I know that it's 
very easy to get models that are underidentified.  One of the simplest 
cases is the classical errors in x regression problem:

Observe:
  X = xi + e.x, e.x~N(0, s2.x)
  Y = eta + e.y, e.y~N(0, s2.y)
Model:
  eta = a+b*xi

  If I'm not mistaken, I believe that it is theoretically impossible to 
estimate a, b, s2.x, and s2.y without additional information, like for 
example the ratio between s2.x and s2.y.


LAGS IN BOTH TIME AND SPACE?

  I've copied John Fox, the 'sem' package author and maintainer, on 
this reply.  He might educate us both on how to include lags in both 
time and space into an 'sem' model.

  Failing that, are you familiar with Pinheiro and Bates (2000) 
Mixed-Effects Models in S and S-Plus (Springer).  This book and the 
companion 'nlme' packages include facilities for linear and nonlinear 
models in both space and time.  The follow-on 'lme4' package and 
accompanying 'lmer' function will also handle non-normal response 
distributions.  I'm a firm believer in trying the simple things first, 
and I think the mixed-effects models are simpler than 'sem', though 
Prof. Fox may wish to disabuse me of my ignorance on that point.


MORE HELP?

  If you would like more from this listserve than just this, please 
submit another post.  When you do, however, please include a simple, 
self contained example to illustrate briefly what you want, what you 
tried, and the deficiencies with what you tried, as suggested in the 
posting guide! www.R-project.org/posting-guide.html.

  Hope this helps.
  Spencer Graves

Denis Fomchenko wrote:
 Dear all,
 
 I am trying to estimate simultaneous equation model concerning growth in 
 russian regions.
 I run the analysis by means of FIML in R sem package.
 I am not familiar with SEM yet, but I've just got several suitable estimated 
 specifications.
 Nevertheless, sometimes R gives the following warning message:
 
 Warning message:
 Negative parameter variances.
 Model is probably underidentified.
  in: sem.default(ram = ram, S = S, N = N, param.names = pars, var.names = 
 vars,  
 
 I check for rank condition - all three equations in the system are turned out 
 to be exact...
 
 Does anybody know what it means? and how to handle with that problem?
 
 P.S.
 Do you know any examples of models estimated in SEM by means of FIML, 
 incorporating spatial lag on endogenous variable?
 
 Thanks, in advance
 
 Denis Fomchenko
 research fellow
 Department for Economic Development Problems
 Institute for the Economy in Transition
 5, Gazetny lane, Moscow 125993, Russia
 e-mail: [EMAIL PROTECTED]
 http://www.iet.ru
  
 
   [[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-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] MLE and QR classes

2006-07-16 Thread Spencer Graves
  I don't understand your question.  First, I'm not familiar with the 
'wls' package;  I found no such package by that name via 
www.r-project.org - CRAN - (select a local mirror) - Packages.

  The 'qr' function in the 'quandreg' package looks straightforward to 
me.  Have you worked through the examples in the 'qr' help page?  The 
look to me like they follow the standard syntax of 'lm'.  If you don't 
understand the 'lm' syntax, I encourage you to spend some quality time 
with appropriate sections of Venables and Ripley (2003) Modern Applied 
Statistics with S, 4th ed. (Springer).

  If you'd like more help from this listserve, please submit another 
question.  However, please include a simple, self-contained example of 
something you tried to help illustrate your question (as suggested in 
the posting guide! www.R-project.org/posting-guide.html).

  Hope this helps.
  Spencer Graves

[EMAIL PROTECTED] wrote:
 Hi,
 
 I load my data set and separate it as folowing:
 
 presu - read.table(C:/_Ricardo/Paty/qtdata_f.txt, header=TRUE, sep=\t,
 na.strings=NA, dec=., strip.white=TRUE)
 dep-presu[,3];
 exo-presu[,4:92];
 
 Now, I want to use it using the wls and quantreg packages. How I change the
 data classes for mle and rq objects?
 
 Thanks a lot,
 
 Ricardo Gonçalves Silva, M. Sc.
 Apoio aos Processos de Modelagem Matemática
 Econometria  Inadimplência
 Serasa S.A.
 (11) - 6847-8889
 [EMAIL PROTECTED]
 
 **
 
 As informações contidas nesta mensagem e no(s) arquivo(s) anexo(s) são
 endereçadas exclusivamente à(s) pessoa(s) e/ou instituição(ões) acima
 indicada(s), podendo conter dados confidenciais, os quais não podem, sob
 qualquer forma ou pretexto, ser utilizados, divulgados, alterados,
 impressos ou copiados, total ou parcialmente, por pessoas não autorizadas.
 Caso não seja o destinatário, favor providenciar sua exclusão e notificar o
 remetente imediatamente.  O uso impróprio será tratado conforme as normas
 da empresa e da legislação em vigor.
 Esta mensagem expressa o posicionamento pessoal do subscritor e não reflete
 necessariamente a opinião da Serasa.
 
 __
 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] sem question

2006-07-16 Thread John Fox
Dear Spencer and Denis,

I've been traveling for a while and away from r-help, so I didn't see
Denis's question until now.

I'm not familiar with applications of SEMs that have lags in time and space.
As to the identification status of Denis's model, it's hard to know about
that in the abstract. What's the model? 

Regards,
 John


John Fox
Department of Sociology
McMaster University
Hamilton, Ontario
Canada L8S 4M4
905-525-9140x23604
http://socserv.mcmaster.ca/jfox 
 

 -Original Message-
 From: Spencer Graves [mailto:[EMAIL PROTECTED] 
 Sent: Sunday, July 16, 2006 7:29 PM
 To: Denis Fomchenko
 Cc: r-help@stat.math.ethz.ch; John Fox
 Subject: Re: [R] sem question
 
 
 
 MODEL UNDERIDENTIFIED?
 
 I've looked at 'sem' for many years but never found 
 that application that seemed to me to require that machinery. 
  However, I know that it's very easy to get models that are 
 underidentified.  One of the simplest cases is the 
 classical errors in x regression problem:
 
 Observe:
 X = xi + e.x, e.x~N(0, s2.x)
 Y = eta + e.y, e.y~N(0, s2.y)
 Model:
 eta = a+b*xi
 
 If I'm not mistaken, I believe that it is 
 theoretically impossible to estimate a, b, s2.x, and s2.y 
 without additional information, like for example the ratio 
 between s2.x and s2.y.
 
 
 LAGS IN BOTH TIME AND SPACE?
 
 I've copied John Fox, the 'sem' package author and 
 maintainer, on this reply.  He might educate us both on how 
 to include lags in both time and space into an 'sem' model.
 
 Failing that, are you familiar with Pinheiro and 
 Bates (2000) Mixed-Effects Models in S and S-Plus (Springer). 
  This book and the companion 'nlme' packages include 
 facilities for linear and nonlinear models in both space and 
 time.  The follow-on 'lme4' package and accompanying 'lmer' 
 function will also handle non-normal response distributions.  
 I'm a firm believer in trying the simple things first, and I 
 think the mixed-effects models are simpler than 'sem', though 
 Prof. Fox may wish to disabuse me of my ignorance on that point.
 
 
 MORE HELP?
 
 If you would like more from this listserve than just 
 this, please submit another post.  When you do, however, 
 please include a simple, self contained example to illustrate 
 briefly what you want, what you tried, and the deficiencies 
 with what you tried, as suggested in the posting guide! 
 www.R-project.org/posting-guide.html.
 
 Hope this helps.
 Spencer Graves
 
 Denis Fomchenko wrote:
  Dear all,
  
  I am trying to estimate simultaneous equation model 
 concerning growth in russian regions.
  I run the analysis by means of FIML in R sem package.
  I am not familiar with SEM yet, but I've just got several 
 suitable estimated specifications.
  Nevertheless, sometimes R gives the following warning message:
  
  Warning message:
  Negative parameter variances.
  Model is probably underidentified.
   in: sem.default(ram = ram, S = S, N = N, param.names = pars, 
  var.names = vars,
  
  I check for rank condition - all three equations in the 
 system are turned out to be exact...
  
  Does anybody know what it means? and how to handle with 
 that problem?
  
  P.S.
  Do you know any examples of models estimated in SEM by 
 means of FIML, incorporating spatial lag on endogenous variable?
  
  Thanks, in advance
  
  Denis Fomchenko
  research fellow
  Department for Economic Development Problems Institute for 
 the Economy 
  in Transition 5, Gazetny lane, Moscow 125993, Russia
  e-mail: [EMAIL PROTECTED]
  http://www.iet.ru
   
  
  [[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-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] 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] a question about data combination

2006-07-16 Thread XinMeng
Hello sir: 

Here's the data: a b c d 1 2 3 4 

I wanna know how to get: 
ab ac ad bc bd cd 
12 13 14 23 24 34 

Thanks a lot! My best  
 




--
***
Xin Meng 
Capitalbio Corporation
National Engineering Research Center 
for Beijing Biochip Technology 
BioPharma-informatics  Software Dept. 
Research Engineer
Tel: +86-10-80715888/80726868-6438
Fax: +86-10-80726790
[EMAIL PROTECTED] 
Address:18 Life Science Parkway, 
Changping District, Beijing 102206, China

__
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] ols/gls or systemfit (OLS, WLS, SUR) give identical results

2006-07-16 Thread Spencer Graves
  I can't say without more information.  If the system were saturated 
(i.e., has as many equations as unknowns), you should get the same 
answer from all the different methods.  However, I just tried a 
saturated model in 'systemfit', with the following results:

  DF2 - data.frame(y=1:2, x=3:4)
  lm(y~x, DF2)
Call:
lm(formula = y ~ x, data = DF2)

Coefficients:
(Intercept)x
  -21
  library(systemfit)
  systemfit(OLS, list(eqn=y~x), data=DF2)
Error in solve.default(sigma, tol = solvetol) :
system is computationally singular: reciprocal condition number = 0
 
  If you'd like more help from this listserve, please supply a simple, 
self-contained example to illustrate your question (as suggested in the 
posting guide! www.R-project.org/posting-guide.html).

  Hope this helps.
  Spencer Graves

Mihai Nica wrote:
I might be sorry for asking this question :-)
 
 I have two equations and I tried to estimate 
them individually with lm and gls, and then in a
system (using systemfit)  with OLS, WLS and SUR.
Quite surprisingly (for myself at least) the results
are identical to the last digit.
 
 Could someone (please!) give a hint as to what 
am I doing wrong?
 
 Thanks,
 
 mihai
   
 -
 
 
   [[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-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] Correlation Mapping

2006-07-16 Thread justin rapp
On the cover of Zivot and Wang's Modeling Financial Time Series with S
Plus, there is a correlation plot that seems to indicate the strength
of correlation with color-coded squares, so that more highly
correlated stocks appear darker red.  If anybody out there is familiar
with the book or understands what I am talking about, I am curious as
to whether or not there is a similar function in R and how I can call
it up.
Thank you.

jdr

__
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] planned comparisons for ANOVA

2006-07-16 Thread Darren Weber
Hi,

we need some help to define planned comparisons.  I've based my
understanding of the problem on reading Tabachnick and Fidell (2006),
ie:

http://www.ablongman.com/catalog/academic/product/0,1144,0205459382,00.html

I don't understand how to specify planned comparisons in R.  I've not
found explanations for this in MASS or elsewhere.  There is only
discussion of the contrast option to ANOVA in general terms, there are
no examples for the analysis of planned comparisons.

I have an ANOVA design, described as a factorial design, with both
between-subjects and within-subjects factors.  There are 2 subject
groups.  Although there are matched individuals across groups (matched
for extraneous demographic variables), we consider them a
between-subject factor with 2 categorical levels (controls, patients).
 The dependent variable is a multivariate recording from 124
electrodes on the scalp, to measure electric potential from the scalp
surface.  These recordings are summarised into regional activity for
the left and right hemisphere.   So hemisphere is a within-subjects
factor that has 2 levels (left and right).  The last factor is an
experimental manipulation, a visual task contains three types of
events.  This is a  within-subjects factor with three levels (S1, S2,
S3).

Our planned comparisons are:

1. test the group mean difference for S1 vs S2 (in the absence of S3)
2. test the group mean difference for S2 vs S3 (in the absence of S1)

This is the current form of the ANOVA specification for R:

aov( Y ~ (Task*Hemisphere*Group) +
Error( Subject/(Task*Hemisphere) )

How can we add planned comparisons to this specification?  Can we add
just one planned comparison matrix, with rows for 1  2 above, or do
we need to run the model twice, once for each planned comparison?
Alternatively, is there a function  to compute the planned comparisons
after running the full ANOVA model?

Thanks, Darren

PS, I was trained well on using SPSS, but I am trying to make a switch
to R.  You help with this would be really appreciated.  We need to get
our results revised and published soon.

__
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] Handshake exception in Rserve

2006-07-16 Thread jaydeep chovatia
Hello,

 

We are facing some problem while calling a Rserve API from our Java client.
The details are as below:

 

1) We have installed Rserve on linux machine Nagarajan(Port: 6311) and
related modules.

 

2) We have started the Rserve in daemon mode perfectly by executing the
comman  R CMD Rserve on the linux machine.

 

But when the Java client executes the statement: Rconnection c = new
Rconnection (Nagrajan, 6311), we are getting an exception: handshake
exception:  expected  32 bytes received -1 byte.

 

It would be really great if you could help us out to resolve the issue or
provide a probable root cause of the problem.

 

Thank you,

Jaydeep

 


DISCLAIMER\ ==\ This e-mail may contain privileged a...{{dropped}}

__
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] planned comparisons for ANOVA

2006-07-16 Thread Simon Blomberg
Darren Weber wrote:

[snip]
 Our planned comparisons are:

 1. test the group mean difference for S1 vs S2 (in the absence of S3)
 2. test the group mean difference for S2 vs S3 (in the absence of S1)

 This is the current form of the ANOVA specification for R:

 aov( Y ~ (Task*Hemisphere*Group) +
 Error( Subject/(Task*Hemisphere) )
   
 How can we add planned comparisons to this specification?  Can we add
 just one planned comparison matrix, with rows for 1  2 above, or do
 we need to run the model twice, once for each planned comparison?
   
There are a couple of ways to do this in R. Perhaps the easiest is to 
use make.contrasts in the gmodels package.

cmat - rbind(S1 v S2 = c(1, -1, 0),
  S2 v S3 = c(0, 1, -1))
library(gmodels)
fit - aov( Y ~ Task*Hemisphere*Group + Error( 
Subject/(Task*Hemisphere), contrasts=list(Task=make.contrasts(cmat )))
summary(fit)

 Alternatively, is there a function  to compute the planned comparisons
 after running the full ANOVA model?
   
see ?fit.contrast in gmodels  for this.

HTH,

Simon.
 Thanks, Darren

 PS, I was trained well on using SPSS, but I am trying to make a switch
 to R.  You help with this would be really appreciated.  We need to get
 our results revised and published soon.

 __
 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

   


-- 
Simon Blomberg, B.Sc.(Hons.), Ph.D, M.App.Stat.
Centre for Resource and Environmental Studies
The Australian National University
Canberra ACT 0200
Australia
T: +61 2 6125 7800 email: Simon.Blomberg_at_anu.edu.au
F: +61 2 6125 0757
CRICOS Provider # 00120C

__
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] Correlation Mapping

2006-07-16 Thread Gabor Grothendieck
I have not seen that book cover but I assume the
question is how to plot the cells of a correlation
matrix in different colors.  Try heatmap or the gplot
package function heatmap.2 .  For example, we create a
correlation matrix, K, from the first 4 columns of
the iris data set and create a heatmap using the
bluered color scheme:

# heatmap.2
library(gplots)
K - cor(iris[,1:4])
heatmap.2(K, col = bluered(16), cexRow = .7, cexCol = .7, symm = TRUE,
dend = row, trace = none, main = Iris Data)

balloonplot, also in the gplots package, and image in graphics (i.e. core R)
might be other functions to look at.

On 7/16/06, justin rapp [EMAIL PROTECTED] wrote:
 On the cover of Zivot and Wang's Modeling Financial Time Series with S
 Plus, there is a correlation plot that seems to indicate the strength
 of correlation with color-coded squares, so that more highly
 correlated stocks appear darker red.  If anybody out there is familiar
 with the book or understands what I am talking about, I am curious as
 to whether or not there is a similar function in R and how I can call
 it up.
 Thank you.

 jdr

 __
 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