Re: [R] Matrix as input to xyplot {lattice} - proper extended formula syntax

2009-09-06 Thread Gabor Grothendieck
For the example df below this also works:

library(lattice); library(zoo)
xyplot(zoo(df[1:4], df$x), type = p)

On Sun, Sep 6, 2009 at 12:51 AM, David Winsemiusdwinsem...@comcast.net wrote:
 I'm not exactly sure what structure df has. Here's my effort to duplicate
 it:

 df - data.frame(y=matrix(rnorm(24), nrow=6), x=1:6)
 df
         y.1        y.2        y.3        y.4 x
 1  0.1734636  0.2348417 -1.2375648 -1.3246439 1
 2  1.9551669 -1.1027262 -0.7307332  0.3953752 2
 3 -0.7645778  1.6297861  0.4743805 -0.4476145 3
 4 -0.5308756 -0.5246534 -0.3854609 -1.609 4
 5  0.7406525 -0.8691720 -0.8194084  1.6122059 5
 6 -0.9625619 -1.0774165  1.0760829  0.3659436 6

 And this seems to accomplish the desired task. Presumably you have assigned
 off-stage the value of title to a meaningful character string?

 p - xyplot(y.1+y.2+y.3+y.4 ~ x |1:4, data = df, main = title
 ,layout=c(1,4) )
 p




 On Sep 5, 2009, at 11:52 PM, Bryan Hanson wrote:

 Hello R Folks...

 I have a list with the following structure:

 str(df)

 List of 3
 $ y    : num [1:4, 1:1242] -0.005379 0.029874 -0.023274 0.000655 -0.004537
 ..
 $ x    : num [1:1242] 501 503 505 507 509 ...
 $ names: Factor w/ 4 levels PC Loading 1,..: 1 2 3 4

 I want to plot each row of df$y against df$x, and have each plot in it’s
 own
 panel according to the levels of df$names.  The following works in the
 sense
 that the layout is right, but the y values have clearly been recycled or
 skipped in some fashion (and an error is thrown for each panel that the
 length of x and y aren’t the same):

 p - xyplot(y ~ x | names, data = df, main = title,
       layout = c(1, dim(y)[1])

 In reviewing the extended formula interface in the Lattice Book, what I
 want
 to happen is y1 + y2 + y3 + y4 ~ x | names, outer = TRUE

 I see two options: figure out a way to create the extended formula on the
 fly (and the actual number of rows in y may vary), which seems potentially
 tricky, or create a data frame by stacking each row of y and repeating x
 and
 names to match.  This seems like a waste of memory.

 I’ve looked through the archives and haven’t come across something quite
 like this, or at least I don’t recognize it if I have!  Is there a more
 elegant way to tell xyplot I want to use each row of y repeatedly with the
 same x, in a loop-like fashion?

 TIA.  Bryan
 *
 Bryan Hanson
 Professor of Chemistry  Biochemistry
 DePauw University, Greencastle IN USA


        [[alternative HTML version deleted]]

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

 David Winsemius, MD
 Heritage Laboratories
 West Hartford, CT

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


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Matrix as input to xyplot {lattice} - proper extended formula syntax

2009-09-06 Thread Deepayan Sarkar
On Sat, Sep 5, 2009 at 10:43 PM, Bryan Hansonhan...@depauw.edu wrote:
 Thanks David, your way of constructing df is much more compact than what I
 was using, so I've incorporated it.  I also had my rows and columns
 transposed relative to how xyplot wanted them (though I had tested for that,
 other problems interfered).

 In my case, I may have varying numbers of y columns, from y.1 to y.n let's
 say.  Is there an easy way of creating the phrase y.1+y.2+...y.n to pass to
 xyplot, or even better, some sort of syntax that says take all y.n and
 plot them against x?

lm() etc does have such syntax, but not lattice unfortunately.
However, it's fairly easy (though inelegant) to create a formula from
a character string; e.g.

 as.formula(sprintf(%s ~ x, paste(y., 1:5, sep = , collapse = +)))
y.1 + y.2 + y.3 + y.4 + y.5 ~ x

-Deepayan


 Thanks, Bryan


 On 9/6/09 12:51 AM, David Winsemius dwinsem...@comcast.net wrote:

 I'm not exactly sure what structure df has. Here's my effort to
 duplicate it:

 df - data.frame(y=matrix(rnorm(24), nrow=6), x=1:6)
 df
           y.1        y.2        y.3        y.4 x
 1  0.1734636  0.2348417 -1.2375648 -1.3246439 1
 2  1.9551669 -1.1027262 -0.7307332  0.3953752 2
 3 -0.7645778  1.6297861  0.4743805 -0.4476145 3
 4 -0.5308756 -0.5246534 -0.3854609 -1.609 4
 5  0.7406525 -0.8691720 -0.8194084  1.6122059 5
 6 -0.9625619 -1.0774165  1.0760829  0.3659436 6

 And this seems to accomplish the desired task. Presumably you have
 assigned off-stage the value of title to a meaningful character string?

 p - xyplot(y.1+y.2+y.3+y.4 ~ x |1:4, data = df, main =
 title ,layout=c(1,4) )
 p




 On Sep 5, 2009, at 11:52 PM, Bryan Hanson wrote:

 Hello R Folks...

 I have a list with the following structure:

 str(df)
 List of 3
 $ y    : num [1:4, 1:1242] -0.005379 0.029874 -0.023274 0.000655
 -0.004537
 ..
 $ x    : num [1:1242] 501 503 505 507 509 ...
 $ names: Factor w/ 4 levels PC Loading 1,..: 1 2 3 4

 I want to plot each row of df$y against df$x, and have each plot in
 it¹s own
 panel according to the levels of df$names.  The following works in
 the sense
 that the layout is right, but the y values have clearly been
 recycled or
 skipped in some fashion (and an error is thrown for each panel that
 the
 length of x and y aren¹t the same):

 p - xyplot(y ~ x | names, data = df, main = title,
        layout = c(1, dim(y)[1])

 In reviewing the extended formula interface in the Lattice Book,
 what I want
 to happen is y1 + y2 + y3 + y4 ~ x | names, outer = TRUE

 I see two options: figure out a way to create the extended formula
 on the
 fly (and the actual number of rows in y may vary), which seems
 potentially
 tricky, or create a data frame by stacking each row of y and
 repeating x and
 names to match.  This seems like a waste of memory.

 I¹ve looked through the archives and haven¹t come across something
 quite
 like this, or at least I don¹t recognize it if I have!  Is there a
 more
 elegant way to tell xyplot I want to use each row of y repeatedly
 with the
 same x, in a loop-like fashion?

 TIA.  Bryan
 *
 Bryan Hanson
 Professor of Chemistry  Biochemistry
 DePauw University, Greencastle IN USA


 [[alternative HTML version deleted]]

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

 David Winsemius, MD
 Heritage Laboratories
 West Hartford, CT


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


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

2009-09-06 Thread Barry Rowlingson
On Sun, Sep 6, 2009 at 1:07 AM, spencergspencer.gra...@prodsyse.com wrote:
     What software exists for digitizing video to quantify the motion of
 specific features in the image?  I might be willing to use something that's
 NOT in R, though I'd prefer something in R (or at least with an R
 intereface).

 The 'Motion' project seems to do quite a bit:
http://www.lavrsen.dk/foswiki/bin/view/Motion/WebHome

 Specifically it will capture frames from a video device, detect
movement, and write jpeg or mpeg files when it detects movement.

 You can control it via http commands (which you can send from R) or
it can start external commands on events (such as starting to detect
motion) - these commands could trigger things in R.

 Motion is GPL licensed which means you can take the code and do stuff
with it - it might be possible to link R directly to the underlying
motion detection algorithms.

 So what's left for R to do? Or do you want to use it to develop new
motion detection algorithms?

Barry

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


[R] Concentration ellipsoid

2009-09-06 Thread RON70

Hi all,

Can anyone please guide me how to draw a Concentration ellipsoid for a
bivariate system with a bivariate normal dist. having a VCV matrix : 

Sigma - matrix(c(1,2,2,5), 2, 2)

I would like to draw in using GGPLOT. Your help will be highly appreciated.

Thanks,
-- 
View this message in context: 
http://www.nabble.com/Concentration-ellipsoid-tp25315705p25315705.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] struggling with split function

2009-09-06 Thread Dimitri Liakhovitski
I am very sorry for such a simple question, but I am struggling with split.
I have the following data frame:
x-data.frame(A=c(NA,NA,NA,NA,split,NA,NA,NA,NA,split,NA,NA,NA,NA,split,NA,NA,NA,NA),
B=c(Name1,text1,text2,text3,NA,Name2,text1,text2,text3,NA,Name3,text1,text2,text3,NA,Name4,text1,text2,text3),
C=c(NA,1,NA,3,NA,NA,4,5,6,NA,NA,7,8,9,NA,NA,3,3,3),D=c(NA,1,1,2,NA,NA,5,6,NA,NA,NA,9,8,7,NA,NA,2,2,2),
E=c(NA,3,2,1,NA,NA,6,5,4,NA,NA,7,7,8,NA,NA,1,NA,1))
print(x)

All I want to do is to split x, i.e., to create a list of data frames
that are currently separated by the word split in column A. In this
example, it would be 4 data frames, the first of them being:
A B C D E
NA Name1 NA NA NA
NA text1 1 1 3
NA text 2 NA 1 2
NA text3 3 2 1

etc.

I tried:
split(x, x$A)
split(x,x$A == 'split')
split(x,!is.na(x$A))

But nothing produces what I need.
Tanks a lot for any hint!

-- 
Dimitri Liakhovitski
Ninah.com
dimitri.liakhovit...@ninah.com

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


Re: [R] Video Analysis?

2009-09-06 Thread Bio7

In my application you can transfer images or single frames from ImageJ to R
very efficiently and easily.

http://www.uni-bielefeld.de/biologie/Oekosystembiologie/bio7app/flashtut/processavis.htm
http://www.uni-bielefeld.de/biologie/Oekosystembiologie/bio7app/flashtut/processavis.htm
 


However, there are also several plugins for  http://rsbweb.nih.gov/ij/
ImageJ  available to detect and quantify motion in images.

Another option would be to link and use the 
http://opencv.willowgarage.com/wiki/ OpenCV  library with R which embedds
algorithm to detect motion and more.


With kind regards

M. Austenfeld






-- 
View this message in context: 
http://www.nabble.com/Video-Analysis--tp25313450p25315904.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] struggling with split function

2009-09-06 Thread Dimitris Rizopoulos

one way is the following:

ind - rle(is.na(x$A))
ind - rep(seq_along(ind$lengths), ind$lengths)
na.ind - is.na(x$A)
split(x[na.ind, -1], ind[na.ind])


I hope it helps.

Best,
Dimitris


Dimitri Liakhovitski wrote:

I am very sorry for such a simple question, but I am struggling with split.
I have the following data frame:
x-data.frame(A=c(NA,NA,NA,NA,split,NA,NA,NA,NA,split,NA,NA,NA,NA,split,NA,NA,NA,NA),
B=c(Name1,text1,text2,text3,NA,Name2,text1,text2,text3,NA,Name3,text1,text2,text3,NA,Name4,text1,text2,text3),
C=c(NA,1,NA,3,NA,NA,4,5,6,NA,NA,7,8,9,NA,NA,3,3,3),D=c(NA,1,1,2,NA,NA,5,6,NA,NA,NA,9,8,7,NA,NA,2,2,2),
E=c(NA,3,2,1,NA,NA,6,5,4,NA,NA,7,7,8,NA,NA,1,NA,1))
print(x)

All I want to do is to split x, i.e., to create a list of data frames
that are currently separated by the word split in column A. In this
example, it would be 4 data frames, the first of them being:
A B C D E
NA Name1 NA NA NA
NA text1 1 1 3
NA text 2 NA 1 2
NA text3 3 2 1

etc.

I tried:
split(x, x$A)
split(x,x$A == 'split')
split(x,!is.na(x$A))

But nothing produces what I need.
Tanks a lot for any hint!



--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus University Medical Center

Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014

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

2009-09-06 Thread RON70

In the mean time, i have found one package ellipse to do the same. The
syntax is :

plot(ellipse(Sigma), type='l')

However I am still struggling on how to use qplot (in GGPLOT2) to draw
above plot. I want to get some stylish view for my presentation preparation.
Any help please?

Thanks,



RON70 wrote:
 
 Hi all,
 
 Can anyone please guide me how to draw a Concentration ellipsoid for a
 bivariate system with a bivariate normal dist. having a VCV matrix : 
 
 Sigma - matrix(c(1,2,2,5), 2, 2)
 
 I would like to draw in using GGPLOT. Your help will be highly
 appreciated.
 
 Thanks,
 

-- 
View this message in context: 
http://www.nabble.com/Concentration-ellipsoid-tp25315705p25316243.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] using histogram to find cdf

2009-09-06 Thread maram salem
Dear all,
How can I use the histogram density estimate (hist) to find the value of the 
cdf at a certain point?
Thanks
Maram



  
[[alternative HTML version deleted]]

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


Re: [R] ggplot2::qplot() -- arbitary transformations of coordinate system?

2009-09-06 Thread Michael Kubovy

Hi Stephen,

Because coord_trans() does all the work of plotting the original  
values on the tranformed scale. See ?coord_trans. To quote: The  
difference between transforming the scales and transforming the  
coordinate system is that scale transformation occurs BEFORE  
statistics, and coordinate transformation afterwards.


# After
require(ggplot2)
data(diamonds)
# Three ways of doing transformating in ggplot:
# * by transforming the data
qplot(log10(carat), log10(price), data=diamonds)
# * by transforming the scales
qplot(carat, price, data=diamonds, log=xy)
qplot(carat, price, data=diamonds) + scale_x_log10() + scale_y_log10()
# * by transforming the coordinate system:
qplot(carat, price, data=diamonds) + coord_trans(x = log10, y =  
log10)


Michael

On Sep 5, 2009, at 9:01 PM, stephen sefick wrote:


why not transform the y-data?

On Sat, Sep 5, 2009 at 8:03 PM, Michael Kubovykub...@virginia.edu  
wrote:

Hi,

Does anyone know how to do a coord_trans() in which the y-axis is  
tranformed

into (for example) -1000/y?



Stephen Sefick




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

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


[R] [Hmisc] Latex to pdf

2009-09-06 Thread Jeroen Ooms

I would like to print some tables and figures to a PDF device on a CentOS 5
vps. However, I cannot seem to get the latex function from Hmisc working. I
followed the example, and got an error: sh: xdvi: command not found. I tried
installing the 'tetex-xdvi' linux package, and now it returns: Error: Can't
open display. I guess the reason for this is that the machine is a VPS
terminal, so it has no display, however I dont understand why it does not
write to the PDF device. Some code:

 pdf(test.pdf)
 x - matrix(1:6, nrow=2, dimnames=list(c('a','b'),c('c','d','this that')))
 latex(x)   # creates x.tex in working directory
This is pdfeTeX, Version 3.141592-1.21a-2.2 (Web2C 7.5.4)
entering extended mode
(/tmp/Rtmp7bbXMN/file643c9869.tex
LaTeX2e 2003/12/01
Babel v3.8d and hyphenation patterns for american, french, german,
ngerman, b
ahasa, basque, bulgarian, catalan, croatian, czech, danish, dutch,
esperanto, e
stonian, finnish, greek, icelandic, irish, italian, latin, magyar, norsk,
polis
h, portuges, romanian, russian, serbian, slovak, slovene, spanish, swedish,
tur
kish, ukrainian, nohyphenation, loaded.
(/usr/share/texmf/tex/latex/base/report.cls
Document Class: report 2004/02/16 v1.4f Standard LaTeX document class
(/usr/share/texmf/tex/latex/base/size10.clo))
(/usr/share/texmf/tex/latex/geometry/geometry.sty
(/usr/share/texmf/tex/latex/graphics/keyval.sty)
(/usr/share/texmf/tex/latex/geometry/geometry.cfg))
No file file643c9869.aux.
[1] (./file643c9869.aux) )
Output written on file643c9869.dvi (1 page, 372 bytes).
Transcript written on file643c9869.log.
Error: Can't open display:


-
Jeroen Ooms * Dept. of Methodology and Statistics * Utrecht University 

Visit  http://www.jeroenooms.com www.jeroenooms.com  to explore some of my
current projects.





 
-- 
View this message in context: 
http://www.nabble.com/-Hmisc--Latex-to-pdf-tp25316986p25316986.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Video Analysis?

2009-09-06 Thread spencerg
Thanks to Kevin Middleton, Barry Bowlingson, M. Austenfeld: 



 The Hedrick reference is very interesting, digitizing a video of 
the flight of a moth.  This shows the state of the art AND describes 
freely available MATLAB code.  I've used Matlab before, but it would 
strain my budget right now to obtain it.  I've translated Matlab into R 
before, and I could do that again if needed.  First, however, I think I 
want to review the Motion  and OpenCV projects -- and possibly 
ImageJ. 



 I want to convert videos into functional time series, more 
complicated than the gait data set in the fda package but perhaps 
not as demanding as Hendrick's the flight of a moth.  I want to measure 
dynamic bridge deflection midspan to see how that varies between spans 
and throughout a duty cycle.  I will ultimately want to measure 
millimeters from high resolution video if possible.  For a railroad 
bridge, a duty cycle will be the passing of a train, measuring both 
maximum deflection and oscillations.  For highway bridges, I want to be 
able to measure the changes from the morning rush hour to midday to the 
late afternoon rush hour -- and preferably also the mostly unloaded 
period between 2 and 3 AM.  I might be able to place corner reflectors 
on the bridge to mark the points I want to trace, though I'd prefer to 
be able to do it without that.  In any event, I'd like to create a 
functional time series.  I may also be able to get traffic counts, so I 
could model deflection as a function of traffic. 



 Thanks again to Middleton, Bowlingson, and Austenfeld. 



 Best Wishes,
 Spencer


Barry Rowlingson wrote:

On Sun, Sep 6, 2009 at 1:07 AM, spencergspencer.gra...@prodsyse.com wrote:
  

What software exists for digitizing video to quantify the motion of
specific features in the image?  I might be willing to use something that's
NOT in R, though I'd prefer something in R (or at least with an R
intereface).



 The 'Motion' project seems to do quite a bit:
http://www.lavrsen.dk/foswiki/bin/view/Motion/WebHome

 Specifically it will capture frames from a video device, detect
movement, and write jpeg or mpeg files when it detects movement.

 You can control it via http commands (which you can send from R) or
it can start external commands on events (such as starting to detect
motion) - these commands could trigger things in R.

 Motion is GPL licensed which means you can take the code and do stuff
with it - it might be possible to link R directly to the underlying
motion detection algorithms.

 So what's left for R to do? Or do you want to use it to develop new
motion detection algorithms?

Barry

  



--
Spencer Graves, PE, PhD
President and Chief Operating Officer
Structure Inspection and Monitoring, Inc.
751 Emerson Ct.
San José, CA 95126
ph:  408-655-4567

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

2009-09-06 Thread Romain Francois

On 09/06/2009 01:51 PM, spencerg wrote:


Thanks to Kevin Middleton, Barry Bowlingson, M. Austenfeld:

The Hedrick reference is very interesting, digitizing a video of the
flight of a moth. This shows the state of the art AND describes freely
available MATLAB code. I've used Matlab before, but it would strain my
budget right now to obtain it. I've translated Matlab into R before, and
I could do that again if needed. First, however, I think I want to
review the Motion and OpenCV projects -- and possibly ImageJ.


The RImageJ R package provides some link between R and ImageJ, it is 
very simple (the package has 5 lines of R code), but might help you.


See http://tr.im/qzSl for the annoucement on my blog.


I want to convert videos into functional time series, more complicated
than the gait data set in the fda package but perhaps not as
demanding as Hendrick's the flight of a moth. I want to measure dynamic
bridge deflection midspan to see how that varies between spans and
throughout a duty cycle. I will ultimately want to measure millimeters
from high resolution video if possible. For a railroad bridge, a duty
cycle will be the passing of a train, measuring both maximum deflection
and oscillations. For highway bridges, I want to be able to measure the
changes from the morning rush hour to midday to the late afternoon rush
hour -- and preferably also the mostly unloaded period between 2 and 3
AM. I might be able to place corner reflectors on the bridge to mark the
points I want to trace, though I'd prefer to be able to do it without
that. In any event, I'd like to create a functional time series. I may
also be able to get traffic counts, so I could model deflection as a
function of traffic.

Thanks again to Middleton, Bowlingson, and Austenfeld.

Best Wishes,
Spencer


Barry Rowlingson wrote:

On Sun, Sep 6, 2009 at 1:07 AM, spencergspencer.gra...@prodsyse.com
wrote:

What software exists for digitizing video to quantify the motion of
specific features in the image? I might be willing to use something
that's
NOT in R, though I'd prefer something in R (or at least with an R
intereface).


The 'Motion' project seems to do quite a bit:
http://www.lavrsen.dk/foswiki/bin/view/Motion/WebHome

Specifically it will capture frames from a video device, detect
movement, and write jpeg or mpeg files when it detects movement.

You can control it via http commands (which you can send from R) or
it can start external commands on events (such as starting to detect
motion) - these commands could trigger things in R.

Motion is GPL licensed which means you can take the code and do stuff
with it - it might be possible to link R directly to the underlying
motion detection algorithms.

So what's left for R to do? Or do you want to use it to develop new
motion detection algorithms?

Barry







--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://tr.im/xMdt : update on the ant package
|- http://tr.im/xHLs : R capable version of ant
`- http://tr.im/xHiZ : Tip: get java home from R with rJava

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

2009-09-06 Thread Schalk Heunis
Jeroen

This seems to work for (1):
anova(myModels[[1]], force(myModels[[2]]))
OR
anova(myModels[[1]], (myModels[[2]]))
I suspect this is about lazy-evaluation, looking at the source code
for anova for mer objects: selectMethod(anova,mer), something goes
wrong with the sapply to get the names, I think sapply(...,toString)
would work better for this particular case.

For (2), the best solution I could come up with is:

myParameters = lapply(1:length(myModels),function(x){ if(x==1)
paste(myModels[[,x,]],sep = ) else
paste(force(myModels[[,x,]]),sep = )})
myParStr = toString(paste( myParameters  ))
eval(parse(text = paste(anova(,myParStr,

I would have expected do.call(anova, myModels) to work


Hope this helps

Schalk Heunis


On Sat, Sep 5, 2009 at 10:43 PM, Jeroen Oomsj.c.l.o...@uu.nl wrote:
 2009/9/5 Henrique Dallazuanna www...@gmail.com

 Try this:
 anova(myModels[[1]],myModels[[2]])

 do.call(anova, myModels)

 Does this work for you? Both functions are failing here:

 anova(myModels[[1]],myModels[[2]])
 Error in names(mods) - sapply(as.list(mCall)[c(FALSE, TRUE, modp)],
 as.character) :
   'names' attribute [6] must be the same length as the vector [2]
 do.call(anova, myModels)
 Error in as.character.default(X[[1L]], ...) :
   no method for coercing this S4 class to a vector

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


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


[R] Simulation of population dynamics in R?

2009-09-06 Thread Oliver Bandel
Hello,

are there simulation packages to simulate population dynamics,
for example for epidemiology?

Or are there (open source) tools that can do that task and can be
used from within R (or at least can read the resulting data files)?


Oliver

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

2009-09-06 Thread Dimitri Liakhovitski
Thanks a lot, Dimitris.
It totally works on my example data frame.
I know, it's probably hard to address, but when I try to apply it to
the real huge data frame I have, after the last line I get:
Error in `[.default`(x$A, na.ind, -1) :  incorrect number of dimensions.
I know it's impossible to answer this question without seeing the
data, but still: what do you think might be wrong?

Do you think it could be because my first column contains something
else but the split? No, I've just run the table on A and it is:
split NA
204 6356

I also checked the first dimension of x and the length(na.ind) - the
are the same length: 6560.

No idea where the error might lye...


Thanks a lot!
Dimitri

On Sun, Sep 6, 2009 at 5:43 AM, Dimitris
Rizopoulosd.rizopou...@erasmusmc.nl wrote:
 one way is the following:

 ind - rle(is.na(x$A))
 ind - rep(seq_along(ind$lengths), ind$lengths)
 na.ind - is.na(x$A)
 split(x[na.ind, -1], ind[na.ind])


 I hope it helps.

 Best,
 Dimitris


 Dimitri Liakhovitski wrote:

 I am very sorry for such a simple question, but I am struggling with
 split.
 I have the following data frame:

 x-data.frame(A=c(NA,NA,NA,NA,split,NA,NA,NA,NA,split,NA,NA,NA,NA,split,NA,NA,NA,NA),

 B=c(Name1,text1,text2,text3,NA,Name2,text1,text2,text3,NA,Name3,text1,text2,text3,NA,Name4,text1,text2,text3),

 C=c(NA,1,NA,3,NA,NA,4,5,6,NA,NA,7,8,9,NA,NA,3,3,3),D=c(NA,1,1,2,NA,NA,5,6,NA,NA,NA,9,8,7,NA,NA,2,2,2),
 E=c(NA,3,2,1,NA,NA,6,5,4,NA,NA,7,7,8,NA,NA,1,NA,1))
 print(x)

 All I want to do is to split x, i.e., to create a list of data frames
 that are currently separated by the word split in column A. In this
 example, it would be 4 data frames, the first of them being:
 A B C D E
 NA Name1 NA NA NA
 NA text1 1 1 3
 NA text 2 NA 1 2
 NA text3 3 2 1

 etc.

 I tried:
 split(x, x$A)
 split(x,x$A == 'split')
 split(x,!is.na(x$A))

 But nothing produces what I need.
 Tanks a lot for any hint!


 --
 Dimitris Rizopoulos
 Assistant Professor
 Department of Biostatistics
 Erasmus University Medical Center

 Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
 Tel: +31/(0)10/7043478
 Fax: +31/(0)10/7043014




-- 
Dimitri Liakhovitski
Ninah.com
dimitri.liakhovit...@ninah.com

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


Re: [R] DOE in R?

2009-09-06 Thread Carlos J. Gil Bellosta
Hello,

This is your starting point:

http://cran.r-project.org/web/views/ExperimentalDesign.html

Best regards,

Carlos J. Gil Bellosta
http://www.datanalytics.com


On Thu, 2009-09-03 at 17:38 -0700, B_miner wrote:
 Hello!
 
 
 This is not a topic I am well versed in but required to become well versed
 in...I welcome any assistance!
 
 Using R, I want to create an optimal design for an experiment. I'll be
 analyzing the results with logistic regression or some generalized linear
 model. I am thinking that the algdesign package can help (but no idea where
 to start?).
 
 I'm presenting an example here that I have seen the answer to (in SAS) in
 order to make sure I would have gotten it *right*.
 
 There are 5 factors: 4 are quantitative with three levels each and 1 is
 qualitative with two levels.
 
 Factor and levels:
 
 Intro: 0, 1.99, 2.99
 Duration: 6, 9 ,12
 GOTO: 3.99, 4.99, 5.99
 Fee: 0, 15, 45
 Color: Red, White
 
 
 In order to screen these factors, I would want to get a design where I could
 evaluate all main effects, all first order interactions and the squared
 terms of Intro, Duration, GOTO and FEE (for example Intro*Intro).
 
 Looking for the D-optimal design.
 
 Is this something that  R can provide?
 
 
 These are, according to the SAS paper I read the following:
 Obs intro duration goto fee color
 1 0.00 6 3.99 0 WHITE
 2 0.00 6 3.99 45 RED
 3 0.00 6 5.99 0 RED
 4 0.00 6 5.99 45 WHITE
 5 0.00 9 3.99 45 RED
 6 0.00 9 4.99 15 WHITE
 7 0.00 9 5.99 0 RED
 8 0.00 12 3.99 0 RED
 9 0.00 12 3.99 45 WHITE
 10 0.00 12 5.99 0 WHITE
 11 0.00 12 5.99 45 RED
 12 0.00 12 5.99 45 WHITE
 13 1.99 6 3.99 15 RED
 14 1.99 6 4.99 45 WHITE
 15 1.99 6 5.99 0 WHITE
 16 1.99 9 5.99 45 RED
 17 1.99 12 3.99 0 WHITE
 18 1.99 12 5.99 15 RED
 19 2.99 6 3.99 0 WHITE
 20 2.99 6 3.99 45 WHITE
 21 2.99 6 4.99 0 RED
 22 2.99 6 5.99 15 WHITE
 23 2.99 6 5.99 45 RED
 24 2.99 9 3.99 0 RED
 25 2.99 12 3.99 15 WHITE
 26 2.99 12 3.99 45 RED
 27 2.99 12 4.99 0 WHITE
 28 2.99 12 4.99 45 RED
 29 2.99 12 5.99 0 RED
 30 2.99 12 5.99 45 WHITE
 


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

2009-09-06 Thread Steve Lianoglou
Hi Dan,

On Sat, Sep 5, 2009 at 4:40 PM, dan.z...@uni-ulm.de wrote:
 Hello,

 I am working on getting optimal lags by using BIC, But I don't know how to
 calculate BIC. Is there any code or useful function for it?

The second formula listed on the wikipedia page for BIC seems pretty
straightforward to calculate:

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

BIC = n * ln(RSS/n) + k * ln(n)

n = number of datapoints in your data
RSS = residual sum of squares
k = number of free params in your model

Otherwise, there is a BIC function in the nlme package and maybe
others since I just ran ??bic to find it.

Hope that helps,
-steve

-- 
Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] ggplot2::qplot() -- arbitary transformations of coordinate system?

2009-09-06 Thread hadley wickham
Hi Michael,

You could use aes(y = 1000 * myyvar) and coord_trans(trans_y = inverse)

Hadley

On Sun, Sep 6, 2009 at 6:30 AM, Michael Kubovykub...@virginia.edu wrote:
 Hi Stephen,

 Because coord_trans() does all the work of plotting the original values on
 the tranformed scale. See ?coord_trans. To quote: The difference between
 transforming the scales and transforming the coordinate system is that scale
 transformation occurs BEFORE statistics, and coordinate transformation
 afterwards.

 # After
 require(ggplot2)
 data(diamonds)
 # Three ways of doing transformating in ggplot:
 # * by transforming the data
 qplot(log10(carat), log10(price), data=diamonds)
 # * by transforming the scales
 qplot(carat, price, data=diamonds, log=xy)
 qplot(carat, price, data=diamonds) + scale_x_log10() + scale_y_log10()
 # * by transforming the coordinate system:
 qplot(carat, price, data=diamonds) + coord_trans(x = log10, y = log10)

 Michael

 On Sep 5, 2009, at 9:01 PM, stephen sefick wrote:

 why not transform the y-data?

 On Sat, Sep 5, 2009 at 8:03 PM, Michael Kubovykub...@virginia.edu wrote:

 Hi,

 Does anyone know how to do a coord_trans() in which the y-axis is
 tranformed
 into (for example) -1000/y?

 Stephen Sefick



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

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




-- 
http://had.co.nz/

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


Re: [R] Concentration ellipsoid

2009-09-06 Thread Duncan Murdoch

On 06/09/2009 6:08 AM, RON70 wrote:

In the mean time, i have found one package ellipse to do the same. The
syntax is :

plot(ellipse(Sigma), type='l')

However I am still struggling on how to use qplot (in GGPLOT2) to draw
above plot. I want to get some stylish view for my presentation preparation.
Any help please?


Unlike plot(), qplot() doesn't appear to use xy.coords to extract x and 
y from a single argument.  So you need to do it:


e - ellipse(Sigma)
x - e[,x]
y - e[,y]
qplot(x,y,geom=path)

Duncan Murdoch

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


Re: [R] using histogram to find cdf

2009-09-06 Thread Steve Lianoglou
Hi,

On Sun, Sep 6, 2009 at 7:03 AM, maram salemmarammagdysa...@yahoo.com wrote:
 Dear all,
 How can I use the histogram density estimate (hist) to find the value of the 
 cdf at a certain point?

Can you just use the ecdf function on your original data?

-steve

-- 
Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

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

2009-09-06 Thread Steve Lianoglou
Hi,

On Sat, Sep 5, 2009 at 7:06 AM, FMHkagba2...@yahoo.com wrote:
 Dear All,

 I was looking for the color index in image function, such as from 
 topo.colors(n) and etc. but still never found it. For instance, from the help 
 menu.

The answer is in the code:

 ###
 # Volcano data visualized as matrix. Need to transpose and flip
 # matrix horizontally.
 image(t(volcano)[ncol(volcano):1,])

 # A prettier display of the volcano
 x - 10*(1:nrow(volcano))
 y - 10*(1:ncol(volcano))
 image(x, y, volcano, col = terrain.colors(100), axes = FALSE)

Right here:

R terrrain.colors(100)

[1] #00A600FF #03A700FF #07A800FF #0AAA00FF #0EAB00FF ...

Is that what you mean?
-steve

-- 
Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

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

2009-09-06 Thread Henrique Dallazuanna
The AIC function calculate the BIC.

See ?AIC

On Sat, Sep 5, 2009 at 5:40 PM, dan.z...@uni-ulm.de wrote:

 Hello,

 I am working on getting optimal lags by using BIC, But I don't know how to
 calculate BIC. Is there any code or useful function for it?

 Thanks and regards,
 Dan Zhao

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




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

[[alternative HTML version deleted]]

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


Re: [R] how do I draw this surface -- hand drawn in the attachemtn

2009-09-06 Thread Steve Lianoglou
Hi,

On Sat, Sep 5, 2009 at 5:16 AM, gallon ligallon...@gmail.com wrote:
 Basially I have the observation for x, y, and z

 for each fixed z, the value of y moves from 0 to y0 as x moves from 0 to x0.
 I then move the curve for z from 0 to z0 and form a continuous surface. want
 to know if there is a way that R can replace my handdrawing.

Do the examples in ?persp help?

How about this example from the r graph gallery:

http://addictedtor.free.fr/graphiques/graphcode.php?graph=42

I think lattice graphics also has functions to help plotting in 3d,
but I've never used it. I've only seen it in actio in the lattics vs.
ggplot series of posts on the learnr.wordpress.com blog (very
helpful).

-steve
-- 
Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

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


Re: [R] saving large matrices with decimal numbers

2009-09-06 Thread Uwe Ligges



Moreno Ignazio Coco wrote:



Please tell us what you did exactly when you got the empty file:
PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html

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


well, that's exactly the point, I didn't do anything fancy or special, 
just save the matrix I gave you before (1024 X 768) either in format txt.



That's strange, because

 image - matrix(0.1, 1024, 768)
 write.table(image, ~/data.txt, col.names=FALSE, row.names=FALSE)
 file.show(~/data.txt)

works fine for me.
Hence I suspect you did something very different, but since you have 
still not provided any piece of reproducible code, we cannot help.


Uwe Ligges







write.table(image, ~/mydata/blablabla/data.txt, col.names=F, row.names=F)

or csv:

write.csv (image, ~/mydata/blablabla/data.csv)


both cases the output is an empty file. Do you know what can be the 
problem?


Thanks a lot,

Moreno

 write.csv (image,  
/afs/inf.ed.ac.uk/user/s07/s0788806/R/r_data/ProdEyeTrack/DataFrame/Clustered/Clut/Cluster1/Cl1Verb-tr.csv.1) 





Quoting Uwe Ligges lig...@statistik.tu-dortmund.de:


Moreno Ignazio Coco wrote:

Hi everybody,

I am struggling to save txt. or csv. large sparse matrices (1024 X  
768 image size), initialized at 0.1.


image1[0:10,0:10]
 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,]  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1   0.1
[2,]  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1   0.1
[3,]  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1   0.1
[4,]  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1   0.1
[5,]  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1   0.1
[6,]  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1   0.1
[7,]  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1   0.1
[8,]  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1   0.1
[9,]  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1   0.1
[10,]  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1   0.1

with small distributions located at different points of matrix.
If I try the same matrix but initialized at 0, it can save it.

It seems that R manages to save up around 800 X 600 decimal  matrices 
but for bigger sizes the output is an empty file. Does  anyone know 
whether there is a limit in saving such matrices and  how can I work 
around this problem?


Please tell us what you did exactly when you got the empty file:
PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html

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

Best wishes,
Uwe Ligges





Thanks a lot,

Regards,

Moreno









__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Matrix as input to xyplot {lattice} - proper extended formula syntax

2009-09-06 Thread David Winsemius


On Sep 6, 2009, at 12:51 AM, David Winsemius wrote:

I'm not exactly sure what structure df has. Here's my effort to  
duplicate it:


df - data.frame(y=matrix(rnorm(24), nrow=6), x=1:6)
 df
y.1y.2y.3y.4 x
1  0.1734636  0.2348417 -1.2375648 -1.3246439 1
2  1.9551669 -1.1027262 -0.7307332  0.3953752 2
3 -0.7645778  1.6297861  0.4743805 -0.4476145 3
4 -0.5308756 -0.5246534 -0.3854609 -1.609 4
5  0.7406525 -0.8691720 -0.8194084  1.6122059 5
6 -0.9625619 -1.0774165  1.0760829  0.3659436 6

And this seems to accomplish the desired task. Presumably you have  
assigned off-stage the value of title to a meaningful character  
string?


 p - xyplot(y.1+y.2+y.3+y.4 ~ x |1:4, data = df, main =  
title ,layout=c(1,4) )

 p

For the record, the xyplot call above does not give the desired output  
but Gabor's method does. I'm glad that construction of a sample df was  
useful, even is my efforts a driving xyplot with a surrogate grouping  
sequence was not.


--
David.




On Sep 5, 2009, at 11:52 PM, Bryan Hanson wrote:


Hello R Folks...

I have a list with the following structure:


str(df)

List of 3
$ y: num [1:4, 1:1242] -0.005379 0.029874 -0.023274 0.000655  
-0.004537

..
$ x: num [1:1242] 501 503 505 507 509 ...
$ names: Factor w/ 4 levels PC Loading 1,..: 1 2 3 4

I want to plot each row of df$y against df$x, and have each plot in  
it’s own
panel according to the levels of df$names.  The following works in  
the sense
that the layout is right, but the y values have clearly been  
recycled or
skipped in some fashion (and an error is thrown for each panel that  
the

length of x and y aren’t the same):

p - xyplot(y ~ x | names, data = df, main = title,
  layout = c(1, dim(y)[1])

In reviewing the extended formula interface in the Lattice Book,  
what I want

to happen is y1 + y2 + y3 + y4 ~ x | names, outer = TRUE

I see two options: figure out a way to create the extended formula  
on the
fly (and the actual number of rows in y may vary), which seems  
potentially
tricky, or create a data frame by stacking each row of y and  
repeating x and

names to match.  This seems like a waste of memory.

I’ve looked through the archives and haven’t come across something  
quite
like this, or at least I don’t recognize it if I have!  Is there a  
more
elegant way to tell xyplot I want to use each row of y repeatedly  
with the

same x, in a loop-like fashion?

TIA.  Bryan
*
Bryan Hanson
Professor of Chemistry  Biochemistry
DePauw University, Greencastle IN USA


[[alternative HTML version deleted]]

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


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


Re: [R] ggplot2::qplot() -- arbitary transformations of coordinate system?

2009-09-06 Thread David Winsemius
Is there a place to find a list of the legal values for the  
coord_trans parameters. I spent a bunch of time searching the ggplot2  
docs and r-help for same without success. I also made an attempt at  
looking at the code in R which also failed.


--
David.

On Sep 6, 2009, at 10:12 AM, hadley wickham wrote:


Hi Michael,

You could use aes(y = 1000 * myyvar) and coord_trans(trans_y =  
inverse)


Hadley

On Sun, Sep 6, 2009 at 6:30 AM, Michael Kubovykub...@virginia.edu  
wrote:

Hi Stephen,

Because coord_trans() does all the work of plotting the original  
values on
the tranformed scale. See ?coord_trans. To quote: The difference  
between
transforming the scales and transforming the coordinate system is  
that scale
transformation occurs BEFORE statistics, and coordinate  
transformation

afterwards.

# After
require(ggplot2)
data(diamonds)
# Three ways of doing transformating in ggplot:
# * by transforming the data
qplot(log10(carat), log10(price), data=diamonds)
# * by transforming the scales
qplot(carat, price, data=diamonds, log=xy)
qplot(carat, price, data=diamonds) + scale_x_log10() +  
scale_y_log10()

# * by transforming the coordinate system:
qplot(carat, price, data=diamonds) + coord_trans(x = log10, y =  
log10)


Michael

On Sep 5, 2009, at 9:01 PM, stephen sefick wrote:


why not transform the y-data?

On Sat, Sep 5, 2009 at 8:03 PM, Michael  
Kubovykub...@virginia.edu wrote:


Hi,

Does anyone know how to do a coord_trans() in which the y-axis is
tranformed
into (for example) -1000/y?



Stephen Sefick




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

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





--
http://had.co.nz/

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


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


Re: [R] Color index in image function

2009-09-06 Thread FMH
Hi,

Thank you for your response. I'm looking for the names of the colors denoted by 
these  codes and what do these colors represent for. 
For instance, if we use topo.colors(5) in the image function, five different 
colors will be used in which its codes are denoted as: 

[1] #4C00 #004C #00E5 #00FF4DFF #00FF

So, my first question is what type of color do these codes represent for? Are 
they white, red,...?

My second question is, if we use this topo.colors(5) in image function to 
denote the temperature values for intance, what are these colors represent 
for? Does the first color, #4C00 represent the lower/medium/higher 
temperature?

I do hope you could advice me on this matter?

Thank you
Fir




- Original Message 
From: FMH kagba2...@yahoo.com
To: Steve Lianoglou mailinglist.honey...@gmail.com
Sent: Sunday, September 6, 2009 3:41:02 PM
Subject: Re: [R] Color index in image function

Hi,

Thank you for your response. I'm looking for the name of the colors denoted by 
this  code and what are these colors representing for. 

For instance, if we use topo.colors(5) in the image function, five different 
colors will be used in which its codes are denoted as: 

[1] #4C00 #004C #00E5 #00FF4DFF #00FF

So, my first question is what type of color does these codes represent for? Are 
they white, red,...?

My second question is, if we use this topo.colors(5) in image function to 
denote the temperature values for intance, what are these colors represent 
for? Does the first color, #4C00 represent the lower/medium/higher 
temperature?

I do hope you could advice me on this matter?

Thank you
Fir







- Original Message 
From: Steve Lianoglou mailinglist.honey...@gmail.com
To: FMH kagba2...@yahoo.com
Cc: r-help@r-project.org
Sent: Sunday, September 6, 2009 3:20:25 PM
Subject: Re: [R] Color index in image function

Hi,

On Sat, Sep 5, 2009 at 7:06 AM, FMHkagba2...@yahoo.com wrote:
 Dear All,

 I was looking for the color index in image function, such as from 
 topo.colors(n) and etc. but still never found it. For instance, from the help 
 menu.

The answer is in the code:

 ###
 # Volcano data visualized as matrix. Need to transpose and flip
 # matrix horizontally.
 image(t(volcano)[ncol(volcano):1,])

 # A prettier display of the volcano
 x - 10*(1:nrow(volcano))
 y - 10*(1:ncol(volcano))
 image(x, y, volcano, col = terrain.colors(100), axes = FALSE)

Right here:

R terrrain.colors(100)

[1] #00A600FF #03A700FF #07A800FF #0AAA00FF #0EAB00FF ...

Is that what you mean?
-steve

-- 
Steve Lianoglou
Graduate Student: Computational Systems Biology
| Memorial Sloan-Kettering Cancer Center
| Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact




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


[R] selecting columns based on values of two variables

2009-09-06 Thread Thomas Jensen
Dear R-list,

I am having troubles selecting rows from a very large data-set  
containing distances between capitals.

The structure of the data-set looks like this:

numaida numbidb kmdist  midist
12  USA 20  CAN 731 456
22  USA 31  BHM 16231012
32  USA 40  CUB 18131130


I want to select a subset of these dyads, and have tried the following  
code:

subset(capdist,ida == c(DEN,SWD,FIN)  idb ==  
c(DEN,SWD,FIN))

This should ideally give me the dyads involving only Denmark, Sweden  
and Finland, however i get the error message:

[1] numa   idanumb   idbkmdist midist
0 rows (or 0-length row.names)
Warning messages:
1: In is.na(e1) | is.na(e2) :
   longer object length is not a multiple of shorter object length
2: In `==.default`(ida, c(DEN, SWD, FIN)) :
   longer object length is not a multiple of shorter object length
3: In is.na(e1) | is.na(e2) :
   longer object length is not a multiple of shorter object length
4: In `==.default`(idb, c(DEN, SWD, FIN)) :
   longer object length is not a multiple of shorter object length

Any help would be greatly appreciated,

Best, Thomas Jensen
[[alternative HTML version deleted]]

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


Re: [R] selecting columns based on values of two variables

2009-09-06 Thread Dimitris Rizopoulos

probably you're looking for

subset(capdist, ida %in% c(DEN,SWD,FIN)  idb %in% 
c(DEN,SWD,FIN))



I hope it helps.

Best,
Dimitris


Thomas Jensen wrote:

Dear R-list,

I am having troubles selecting rows from a very large data-set  
containing distances between capitals.


The structure of the data-set looks like this:

numaida numbidb kmdist  midist
12  USA 20  CAN 731 456
22  USA 31  BHM 16231012
32  USA 40  CUB 18131130


I want to select a subset of these dyads, and have tried the following  
code:


subset(capdist,ida == c(DEN,SWD,FIN)  idb ==  
c(DEN,SWD,FIN))


This should ideally give me the dyads involving only Denmark, Sweden  
and Finland, however i get the error message:


[1] numa   idanumb   idbkmdist midist
0 rows (or 0-length row.names)
Warning messages:
1: In is.na(e1) | is.na(e2) :
   longer object length is not a multiple of shorter object length
2: In `==.default`(ida, c(DEN, SWD, FIN)) :
   longer object length is not a multiple of shorter object length
3: In is.na(e1) | is.na(e2) :
   longer object length is not a multiple of shorter object length
4: In `==.default`(idb, c(DEN, SWD, FIN)) :
   longer object length is not a multiple of shorter object length

Any help would be greatly appreciated,

Best, Thomas Jensen
[[alternative HTML version deleted]]

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



--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus University Medical Center

Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014

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

2009-09-06 Thread Henrique Dallazuanna
Try this to see which colors the codes are:

Color - function(color){
z - matrix(1:length(color), ncol = length(color))
image(y = seq(1, length(color)),
z, col = color, axes = FALSE)
text(0, y = z, labels = color, pos = 1, offset = 0, cex = 0.7)
}

Color(topo.colors(5))
Color(terrain.colors(10))

You can use levelplot from lattice package too.

On Sun, Sep 6, 2009 at 11:50 AM, FMH kagba2...@yahoo.com wrote:

 Hi,

 Thank you for your response. I'm looking for the names of the
 colors denoted by these  codes and what do these colors represent for.
 For instance, if we use topo.colors(5) in the image function, five
 different colors will be used in which its codes are denoted as:

 [1] #4C00 #004C #00E5 #00FF4DFF #00FF

 So, my first question is what type of color do these codes represent
 for? Are they white, red,...?

 My second question is, if we use this topo.colors(5) in image function to
 denote the temperature values for intance, what are these colors represent
 for? Does the first color, #4C00 represent the lower/medium/higher
 temperature?

 I do hope you could advice me on this matter?

 Thank you
 Fir




 - Original Message 
 From: FMH kagba2...@yahoo.com
 To: Steve Lianoglou mailinglist.honey...@gmail.com
 Sent: Sunday, September 6, 2009 3:41:02 PM
 Subject: Re: [R] Color index in image function

 Hi,

 Thank you for your response. I'm looking for the name of the colors denoted
 by this  code and what are these colors representing for.

 For instance, if we use topo.colors(5) in the image function, five
 different colors will be used in which its codes are denoted as:

 [1] #4C00 #004C #00E5 #00FF4DFF #00FF

 So, my first question is what type of color does these codes represent
 for? Are they white, red,...?

 My second question is, if we use this topo.colors(5) in image function to
 denote the temperature values for intance, what are these colors represent
 for? Does the first color, #4C00 represent the lower/medium/higher
 temperature?

 I do hope you could advice me on this matter?

 Thank you
 Fir







 - Original Message 
 From: Steve Lianoglou mailinglist.honey...@gmail.com
 To: FMH kagba2...@yahoo.com
 Cc: r-help@r-project.org
 Sent: Sunday, September 6, 2009 3:20:25 PM
 Subject: Re: [R] Color index in image function

 Hi,

 On Sat, Sep 5, 2009 at 7:06 AM, FMHkagba2...@yahoo.com wrote:
  Dear All,
 
  I was looking for the color index in image function, such as from
 topo.colors(n) and etc. but still never found it. For instance, from the
 help menu.

 The answer is in the code:

  ###
  # Volcano data visualized as matrix. Need to transpose and flip
  # matrix horizontally.
  image(t(volcano)[ncol(volcano):1,])
 
  # A prettier display of the volcano
  x - 10*(1:nrow(volcano))
  y - 10*(1:ncol(volcano))
  image(x, y, volcano, col = terrain.colors(100), axes = FALSE)

 Right here:

 R terrrain.colors(100)

 [1] #00A600FF #03A700FF #07A800FF #0AAA00FF #0EAB00FF ...

 Is that what you mean?
 -steve

 --
 Steve Lianoglou
 Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
 Contact Info: 
 http://cbio.mskcc.org/~lianos/contacthttp://cbio.mskcc.org/%7Elianos/contact




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




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

[[alternative HTML version deleted]]

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


Re: [R] How can I appoint a small part of the whole data

2009-09-06 Thread Yichih Hsieh
Dear baptiste,

many thanks for your suggestions !


best,
yichih


2009/9/5, baptiste auguie baptiste.aug...@googlemail.com:

 Hi,

 you have two problems in your first scenario,

 1- Wrong operator precedence. For example,

  1 == 2 | 3
 [1] TRUE

 where 1==2 is tested as FALSE, but 1 is not tested against 3 for equality
 as it would be using,

  1 == 2 | 1 == 3
 [1] FALSE

 or using %in% 2:3

 Instead, R evaluates FALSE | 3, and

 2- it so happens that non-zero integers are treated as TRUE, according to
 ?|

  as.logical(1)
 [1] TRUE
  as.logical(0)
 [1] FALSE


 HTH,

 baptiste

  2009/9/5 Yichih Hsieh yichih.hs...@gmail.com

 Dear all,

 I got another problem:

 if education have five levels

 edu=1
 edu=2
 edu=3
 edu=4
 edu=5

 If I want to appoint y=edu2~4 in 1990
 which programs is correct?
 I tried this two programs, they both work, but two results is different.

 1.
 fig2b-reldist(y=mu1990$wage[mu1990$edu==2|3|4],..)


 2.
 fig2b-reldist(y=mu1990$wage[mu1990$edu%in%2:4],..)

 which one is correct?
 and why they have different results?


 All help high appreciated.


 best,
 Yichih

 2009/9/5 Yichih Hsieh yichih.hs...@gmail.com

 
  Dear Petr,
 
  your suggestion is useful
 
  many thanks for your help !
 
 
  best,
  Yichih
 
  2009/9/3 Petr PIKAL petr.pi...@precheza.cz
 
  Hi
 
  use any of suitable selection ways that are in R.
 
  E.g.
 
  data[data$gender==1, ]
 
  selects only female values
 
  data$wage[(data$gender==1)   (data$race=1)] selects black female
 wages.
 
  and see also ?subset
 
  Regards
  Petr
 
  r-help-boun...@r-project.org napsal dne 03.09.2009 10:51:59:
 
   Dear all,
  
   I have 1980~1990 eleven datas,
   every year have three variables,
   wage
   gender(1=female, 2=male)
   race(1=black, 2=white)
  
   My original commands is:
  
   fig2b-reldist(y=mu1990$wage,yo=mu1980$wage,...)
  
   I have three questions:
   1. If I want to appoint y=women's wage in 1990
   yo=women's wage in 1980
   2. If I want to appoint y=women's wage in 1990
   yo=men's wage in 1990
   3. If I want to appoint y=black women's wage in 1990
   yo=white women's wage in 1990
  
   How can I modify the commands?
  
   All help highly appreciated.
  
   Best,
   Yichih
  
  
   --
   Yichih Hsieh
  
   e-mail : yichih.hs...@gmail.com
  
  [[alternative HTML version deleted]]
  
   __
   R-help@r-project.org mailing list
   https://stat.ethz.ch/mailman/listinfo/r-help
   PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html
 http://www.r-project.org/posting-guide.html
   and provide commented, minimal, self-contained, reproducible code.
 
 
 
 
  --
  Yichih Hsieh
 
  e-mail : yichih.hs...@gmail.com
 



 --
 Yichih Hsieh

 e-mail : yichih.hs...@gmail.com

[[alternative HTML version deleted]]

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




 --
 _

 Baptiste Auguié

 School of Physics
 University of Exeter
 Stocker Road,
 Exeter, Devon,
 EX4 4QL, UK

 http://newton.ex.ac.uk/research/emag
 __




-- 
Yichih Hsieh

e-mail : yichih.hs...@gmail.com

[[alternative HTML version deleted]]

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


Re: [R] How can I appoint a small part of the whole data

2009-09-06 Thread Yichih Hsieh
Dear Mark,

many thanks for your suggestions !


best,
yichih


-- 
Yichih Hsieh

e-mail : yichih.hs...@gmail.com

[[alternative HTML version deleted]]

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


Re: [R] [Hmisc] Latex to pdf

2009-09-06 Thread Oliver Bandel
Jeroen Ooms j.c.l.ooms at uu.nl writes:

[...]
 Output written on file643c9869.dvi (1 page, 372 bytes).
 Transcript written on file643c9869.log.
 Error: Can't open display:

The can't open display-error rather looks like an X11-problem.

Are you reglar user on that system ?


Try to look at the dvi with your dvi-viewer.

xdvi, kdvi or something like that.



Ciao,
   Oliver

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

2009-09-06 Thread Schalk Heunis
By default the z-values are split into equal ranges to match the
number of colors.  The first color is then for first interval from
min(z) etc.  Look at the code for image.default for clarity - there
seems to be some influence from the oldstyle parameter.  If you want
to be 100% sure about which colors match which range, consider
specifying the ranges in breaks.

Schalk Heunis



On Sun, Sep 6, 2009 at 4:50 PM, FMHkagba2...@yahoo.com wrote:
 Hi,

 Thank you for your response. I'm looking for the names of the colors denoted 
 by these  codes and what do these colors represent for.
 For instance, if we use topo.colors(5) in the image function, five different 
 colors will be used in which its codes are denoted as:

 [1] #4C00 #004C #00E5 #00FF4DFF #00FF

 So, my first question is what type of color do these codes represent for? Are 
 they white, red,...?

 My second question is, if we use this topo.colors(5) in image function to 
 denote the temperature values for intance, what are these colors represent 
 for? Does the first color, #4C00 represent the lower/medium/higher 
 temperature?

 I do hope you could advice me on this matter?

 Thank you
 Fir




 - Original Message 
 From: FMH kagba2...@yahoo.com
 To: Steve Lianoglou mailinglist.honey...@gmail.com
 Sent: Sunday, September 6, 2009 3:41:02 PM
 Subject: Re: [R] Color index in image function

 Hi,

 Thank you for your response. I'm looking for the name of the colors denoted 
 by this  code and what are these colors representing for.

 For instance, if we use topo.colors(5) in the image function, five different 
 colors will be used in which its codes are denoted as:

 [1] #4C00 #004C #00E5 #00FF4DFF #00FF

 So, my first question is what type of color does these codes represent 
 for? Are they white, red,...?

 My second question is, if we use this topo.colors(5) in image function to 
 denote the temperature values for intance, what are these colors represent 
 for? Does the first color, #4C00 represent the lower/medium/higher 
 temperature?

 I do hope you could advice me on this matter?

 Thank you
 Fir







 - Original Message 
 From: Steve Lianoglou mailinglist.honey...@gmail.com
 To: FMH kagba2...@yahoo.com
 Cc: r-help@r-project.org
 Sent: Sunday, September 6, 2009 3:20:25 PM
 Subject: Re: [R] Color index in image function

 Hi,

 On Sat, Sep 5, 2009 at 7:06 AM, FMHkagba2...@yahoo.com wrote:
 Dear All,

 I was looking for the color index in image function, such as from 
 topo.colors(n) and etc. but still never found it. For instance, from the 
 help menu.

 The answer is in the code:

 ###
 # Volcano data visualized as matrix. Need to transpose and flip
 # matrix horizontally.
 image(t(volcano)[ncol(volcano):1,])

 # A prettier display of the volcano
 x - 10*(1:nrow(volcano))
 y - 10*(1:ncol(volcano))
 image(x, y, volcano, col = terrain.colors(100), axes = FALSE)

 Right here:

 R terrrain.colors(100)

 [1] #00A600FF #03A700FF #07A800FF #0AAA00FF #0EAB00FF ...

 Is that what you mean?
 -steve

 --
 Steve Lianoglou
 Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
 Contact Info: http://cbio.mskcc.org/~lianos/contact




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


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


[R] linear mixed model question

2009-09-06 Thread Wen Huang

Hello,

I wanted to fit a linear mixed model to a data that is similar in  
terms of design to the 'Machines' data in 'nlme' package except that  
each worker (with triplicates) only operates one machine. I created a  
subset of observations from 'Machines' data such that it looks the  
same as the data I wanted to fit the model with (see code below).


I fitted a model in which 'Machine' was a fixed effect and 'Worker'  
was random (intercept), which ran perfectly. Then I decided to  
complicate the model a little bit by fitting 'Worker' within  
'Machine', which was saying variation among workers was nested within  
each machine. The model could be fitted by 'lme', but when I tried to  
get

confidence intervals by 'intervals(fm2)' it gave me an error:

Error in intervals.lme(fm2) :
  Cannot get confidence intervals on var-cov components: Non-positive  
definite approximate variance-covariance


I am wondering if this is because it is impossible to fit a model like  
'fm2' or there is some other reasons?


Thanks a lot!

Wen

#

library(nlme)
data(Machines)
new.data = Machines[c(1:6, 25:30, 49:54), ]
fm1 = lme(score ~ Machine, random = ~1|Worker, data = new.data)
fm1
fm2 = lme(score ~ Machine, random = ~Machine-1|Worker, data = new.data)
fm2
intervals(fm2)

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

2009-09-06 Thread Peng Yu
Hi,

I want to know what is there returned values of 'lm'. 'class' and 'lm'
does not show that the returned value has the variable coefficients,
etc. I am wondering what is the command to show the detailed
information. If possible, I aslo want the lower level information. For
example, I want to show that 'coefficients' is a named list and it has
2 elements.

Regards,
Peng

 x=1:10
 y=1:10
 r=lm(x~y)
 class(r)
[1] lm
 mode(r)
[1] list
 r

Call:
lm(formula = x ~ y)

Coefficients:
(Intercept)y
  1.123e-151.000e+00

 r$coefficients[1]
 (Intercept)
1.123467e-15
 r$coefficients[[1]]
[1] 1.123467e-15
 r$coefficients[2]
y
1
 r$coefficients[[2]]
[1] 1


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


Re: [R] How to figure the type of a variable?

2009-09-06 Thread Duncan Murdoch

On 06/09/2009 12:33 PM, Peng Yu wrote:

Hi,

I want to know what is there returned values of 'lm'. 'class' and 'lm'
does not show that the returned value has the variable coefficients,
etc. I am wondering what is the command to show the detailed
information. If possible, I aslo want the lower level information. For
example, I want to show that 'coefficients' is a named list and it has
2 elements.


Try the str() function, it shows a summary of the structure of an object.

Duncan Murdoch




Regards,
Peng


x=1:10
y=1:10
r=lm(x~y)
class(r)

[1] lm

mode(r)

[1] list

r


Call:
lm(formula = x ~ y)

Coefficients:
(Intercept)y
  1.123e-151.000e+00


r$coefficients[1]

 (Intercept)
1.123467e-15

r$coefficients[[1]]

[1] 1.123467e-15

r$coefficients[2]

y
1

r$coefficients[[2]]

[1] 1

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


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

2009-09-06 Thread Jorge Ivan Velez
Dear Peng,
Perhaps

str(r)

is what you are looking for.

HTH,
Jorge


On Sun, Sep 6, 2009 at 12:33 PM, Peng Yu pengyu...@gmail.com wrote:

 Hi,

 I want to know what is there returned values of 'lm'. 'class' and 'lm'
 does not show that the returned value has the variable coefficients,
 etc. I am wondering what is the command to show the detailed
 information. If possible, I aslo want the lower level information. For
 example, I want to show that 'coefficients' is a named list and it has
 2 elements.

 Regards,
 Peng

  x=1:10
  y=1:10
  r=lm(x~y)
  class(r)
 [1] lm
  mode(r)
 [1] list
  r

 Call:
 lm(formula = x ~ y)

 Coefficients:
 (Intercept)y
  1.123e-151.000e+00

  r$coefficients[1]
  (Intercept)
 1.123467e-15
  r$coefficients[[1]]
 [1] 1.123467e-15
  r$coefficients[2]
 y
 1
  r$coefficients[[2]]
 [1] 1
 

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


[[alternative HTML version deleted]]

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


Re: [R] How to pop up the graphics window from Rscript?

2009-09-06 Thread Peng Yu
I get the following error.

$ Rscript plot.R
 x=1:10
 y=1:10
 windows()
Error: could not find function windows
Execution halted


On Sun, Sep 6, 2009 at 11:59 AM, RIOS,ALFREDO ARTUROar...@ufl.edu wrote:
 maybe

 windows()


 On Sun Sep 06 12:53:14 EDT 2009, Peng Yu pengyu...@gmail.com wrote:

 Hi,

 I am wondering how to pop up the graphics window from Rscript. I run
 the following code, but I don't see the graphics window, even
 transiently.

 Regards,
 Peng

 $ Rscript plot.R

 x=1:10
 y=1:10
 plot(x,y)


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





 --
 RIOS,ALFREDO ARTURO



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 refer the element in a named list?

2009-09-06 Thread Duncan Murdoch

On 06/09/2009 1:04 PM, Peng Yu wrote:

Hi,

I thought that 'coefficients' is a named list, but I can not refer to
its element by something like r$coefficients$y. I used str() to check
r. It says the following. Can somebody let me know what it means?


The line that matters is the one

 $ coefficients : Named num [1:2] 1.12e-15 1.00

It says that coefficients is a numeric (num) vector, not a list.  So 
r$coefficients[y] will extract the y coefficient.


Duncan Murdoch



  ..- attr(*, names)= chr [1:2] (Intercept) y

$ Rscript lm.R

x=1:10
y=1:10
r=lm(x~y)
class(r)

[1] lm

mode(r)

[1] list

r


Call:
lm(formula = x ~ y)

Coefficients:
(Intercept)y
  1.123e-151.000e+00


r$coefficients[1]

 (Intercept)
1.123467e-15

r$coefficients[[1]]

[1] 1.123467e-15

r$coefficients[2]

y
1

r$coefficients[[2]]

[1] 1



str(r)

List of 12
 $ coefficients : Named num [1:2] 1.12e-15 1.00
  ..- attr(*, names)= chr [1:2] (Intercept) y

Regards,
Peng

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


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


Re: [R] How to pop up the graphics window from Rscript?

2009-09-06 Thread David Winsemius
Perhaps you should read the Posting Guide (again?) and then adopt a  
consistent practice of including system information in your questions  
to r-help. Not everyone keeps a mental list of what OS you are using.  
Graphics commands are highly OS specific.


capabilities() # at an interactive R prompt anyway, will return a list  
of devices for your system.


You may want X11() since you are on a Linux box, but my experience on  
Linux is virtually nil, so that's a guess based on reading prior  
postings.


--
David.

On Sep 6, 2009, at 1:07 PM, Peng Yu wrote:


I get the following error.

$ Rscript plot.R

x=1:10
y=1:10
windows()

Error: could not find function windows
Execution halted


On Sun, Sep 6, 2009 at 11:59 AM, RIOS,ALFREDO ARTUROar...@ufl.edu  
wrote:

maybe

windows()


On Sun Sep 06 12:53:14 EDT 2009, Peng Yu pengyu...@gmail.com wrote:


Hi,

I am wondering how to pop up the graphics window from Rscript. I run
the following code, but I don't see the graphics window, even
transiently.

Regards,
Peng

$ Rscript plot.R


x=1:10
y=1:10
plot(x,y)



__


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


Re: [R] How to pop up the graphics window from Rscript?

2009-09-06 Thread Gabor Grothendieck
Try this (contents of plot.R):

png(mygraphic.png)
plot(1:10)
dev.off()
browseURL(mygraphic.png)

It will pop up the graphic in a browser window.


On Sun, Sep 6, 2009 at 12:53 PM, Peng Yupengyu...@gmail.com wrote:
 Hi,

 I am wondering how to pop up the graphics window from Rscript. I run
 the following code, but I don't see the graphics window, even
 transiently.

 Regards,
 Peng

 $ Rscript plot.R
 x=1:10
 y=1:10
 plot(x,y)


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


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


Re: [R] How to refer the element in a named list?

2009-09-06 Thread David Winsemius


On Sep 6, 2009, at 1:35 PM, Duncan Murdoch wrote:


On 06/09/2009 1:04 PM, Peng Yu wrote:

Hi,
I thought that 'coefficients' is a named list, but I can not refer to
its element by something like r$coefficients$y. I used str() to check
r. It says the following. Can somebody let me know what it means?


The line that matters is the one

$ coefficients : Named num [1:2] 1.12e-15 1.00

It says that coefficients is a numeric (num) vector, not a list.   
So r$coefficients[y] will extract the y coefficient.




And r$coefficients[`(Intercept)`] # note back-quote, should get you  
the intercept


?coef

Generally coef(fit) will extract model coefficients across a wider  
range of R model objects.




Duncan Murdoch



 ..- attr(*, names)= chr [1:2] (Intercept) y
$ Rscript lm.R

x=1:10
y=1:10
r=lm(x~y)
class(r)

[1] lm

mode(r)

[1] list

r

Call:
lm(formula = x ~ y)
Coefficients:
(Intercept)y
 1.123e-151.000e+00

r$coefficients[1]

(Intercept)
1.123467e-15

r$coefficients[[1]]

[1] 1.123467e-15

r$coefficients[2]

y
1

r$coefficients[[2]]

[1] 1

str(r)

List of 12
$ coefficients : Named num [1:2] 1.12e-15 1.00
 ..- attr(*, names)= chr [1:2] (Intercept) y
Regards,
Peng
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


Re: [R] [Hmisc] Latex to pdf

2009-09-06 Thread Liviu Andronic
On 9/6/09, Jeroen Ooms j.c.l.o...@uu.nl wrote:
  I would like to print some tables and figures to a PDF device on a CentOS 5
  vps. However, I cannot seem to get the latex function from Hmisc working. I

There is also xtable() for transferring tables to LaTeX.
Liviu

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 wait for a user response in Rscript?

2009-09-06 Thread RIOS,ALFREDO ARTURO

Hi Peng

I think this is what you are looking for

par(ask=T)

Alfredo


On Sun Sep 06 12:52:31 EDT 2009, Peng Yu pengyu...@gmail.com 
wrote:



Hi,

In 'example(barplot)' running in R, I see 'Hit Return to see 
next
plot:', then R waits for my input. I am wondering how to wait for 
a

user response in Rscript.

Regards,
Peng

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







--
RIOS,ALFREDO ARTURO

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 wait for a user response in Rscript?

2009-09-06 Thread Peng Yu
Hi,

In 'example(barplot)' running in R, I see 'Hit Return to see next
plot:', then R waits for my input. I am wondering how to wait for a
user response in Rscript.

Regards,
Peng

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 pop up the graphics window from Rscript?

2009-09-06 Thread RIOS,ALFREDO ARTURO

maybe

windows()


On Sun Sep 06 12:53:14 EDT 2009, Peng Yu pengyu...@gmail.com 
wrote:



Hi,

I am wondering how to pop up the graphics window from Rscript. I 
run

the following code, but I don't see the graphics window, even
transiently.

Regards,
Peng

$ Rscript plot.R

x=1:10
y=1:10
plot(x,y)



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







--
RIOS,ALFREDO ARTURO

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 refer the element in a named list?

2009-09-06 Thread Peng Yu
Hi,

I thought that 'coefficients' is a named list, but I can not refer to
its element by something like r$coefficients$y. I used str() to check
r. It says the following. Can somebody let me know what it means?
  ..- attr(*, names)= chr [1:2] (Intercept) y

$ Rscript lm.R
 x=1:10
 y=1:10
 r=lm(x~y)
 class(r)
[1] lm
 mode(r)
[1] list
 r

Call:
lm(formula = x ~ y)

Coefficients:
(Intercept)y
  1.123e-151.000e+00

 r$coefficients[1]
 (Intercept)
1.123467e-15
 r$coefficients[[1]]
[1] 1.123467e-15
 r$coefficients[2]
y
1
 r$coefficients[[2]]
[1] 1



 str(r)
List of 12
 $ coefficients : Named num [1:2] 1.12e-15 1.00
  ..- attr(*, names)= chr [1:2] (Intercept) y

Regards,
Peng

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 wait for a user response in Rscript?

2009-09-06 Thread Duncan Murdoch

On 06/09/2009 12:52 PM, Peng Yu wrote:

Hi,

In 'example(barplot)' running in R, I see 'Hit Return to see next
plot:', then R waits for my input. I am wondering how to wait for a
user response in Rscript.


Rscript doesn't run R interactively, so I doubt if there's a way to do 
this.  Rterm has the --ess option that asserts interactive use when 
reading piped input, so you might be able to do something like


Rterm --ess script.R

but that's not the intended use, so you may find other problems.

If you want interactive use but don't want the full Rterm or Rgui, you 
really should be writing your own front-end.  It's not trivial, but it's 
not impossible either, and there are samples included with the R sources.


Duncan Murdoch

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


[R] How to pop up the graphics window from Rscript?

2009-09-06 Thread Peng Yu
Hi,

I am wondering how to pop up the graphics window from Rscript. I run
the following code, but I don't see the graphics window, even
transiently.

Regards,
Peng

$ Rscript plot.R
 x=1:10
 y=1:10
 plot(x,y)


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 pop up the graphics window from Rscript?

2009-09-06 Thread David Winsemius


On Sep 6, 2009, at 1:42 PM, Gabor Grothendieck wrote:


Try this (contents of plot.R):

png(mygraphic.png)
plot(1:10)
dev.off()
browseURL(mygraphic.png)

It will pop up the graphic in a browser window.


On a Mac that shows up in a Preview window. The X11() device does open  
a plot on a Mac when this file is submitted:


x=1:10
y=1:10
X11()
plot(x,y)
dev.off()

I was under the impression that no surrounding box was displayed since  
the points were visible for several seconds before the window  
disappeared. But testing from a GUI session, I see that the X11 device  
takes a long time to draw the axes, which has a side-effect in the  
Rscript session of displaying the points for several seconds and the  
axes for only milliseconds.


--
David.

Mac OS 10.5.7/R 2.9.1 Patched (2009-07-04 r48897)




On Sun, Sep 6, 2009 at 12:53 PM, Peng Yupengyu...@gmail.com wrote:

Hi,

I am wondering how to pop up the graphics window from Rscript. I run
the following code, but I don't see the graphics window, even
transiently.

Regards,
Peng

$ Rscript plot.R

x=1:10
y=1:10
plot(x,y)



David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


Re: [R] Creating mixed line and point graphs with xyplot

2009-09-06 Thread John Kane
I think you have a couple of typos.

Should it not be
par(new=True) 
points(x,b)



--- On Sat, 9/5/09, jim holtman jholt...@gmail.com wrote:

 From: jim holtman jholt...@gmail.com
 Subject: Re: [R] Creating mixed line and point graphs with xyplot
 To: Paul Sweeting m...@paulsweeting.co.uk
 Cc: r-help@r-project.org
 Received: Saturday, September 5, 2009, 6:37 PM
 I would use the base plot routine
 
 plot(x,c, type='l', ylim=range(a,c))
 points(x,a)
 park(new=TRUE)
 plot(x,d,type='l', ylim=range(b,d), axes=FALSE,ylab='',
 xlab='')
 pints(x,b)
 axis(4)
 
 On Fri, Sep 4, 2009 at 11:28 AM, Paul Sweetingm...@paulsweeting.co.uk
 wrote:
  Hi
 
  Well, I think the title says it all!  I've looked
 through the documentation but I can't find a way of doing
 this.  The situation is that I have 4 series, say a, b, c
 and d.  Series a and c are plotted on the lh y axis, series
 b and d are plotted on the rh (secondary) y axis.  I've
 worked out how to do this.
 
  However, I need to plot series a and b a points
 (symbols only, no line), whislt c and d need plotting as
 lines (with no symbols).  What is the easiest way to do
 this in xyplot?  Or should I be using something else?
 
  Thanks!
 
  Paul
 
  __
  R-help@r-project.org
 mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained,
 reproducible code.
 
 
 
 
 -- 
 Jim Holtman
 Cincinnati, OH
 +1 513 646 9390
 
 What is the problem that you are trying to solve?
 
 __
 R-help@r-project.org
 mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained,
 reproducible code.
 


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

http://www.flickr.com/gift/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 mixed line and point graphs with xyplot

2009-09-06 Thread David Winsemius


On Sep 6, 2009, at 3:03 PM, John Kane wrote:


I think you have a couple of typos.

Should it not be
par(new=True)
points(x,b)


Probably not True





--- On Sat, 9/5/09, jim holtman jholt...@gmail.com wrote:


From: jim holtman jholt...@gmail.com
Subject: Re: [R] Creating mixed line and point graphs with xyplot
To: Paul Sweeting m...@paulsweeting.co.uk
Cc: r-help@r-project.org
Received: Saturday, September 5, 2009, 6:37 PM
I would use the base plot routine

plot(x,c, type='l', ylim=range(a,c))
points(x,a)
park(new=TRUE)
plot(x,d,type='l', ylim=range(b,d), axes=FALSE,ylab='',
xlab='')
pints(x,b)
axis(4)

On Fri, Sep 4, 2009 at 11:28 AM, Paul Sweetingm...@paulsweeting.co.uk 


wrote:

Hi

Well, I think the title says it all!  I've looked

through the documentation but I can't find a way of doing
this.  The situation is that I have 4 series, say a, b, c
and d.  Series a and c are plotted on the lh y axis, series
b and d are plotted on the rh (secondary) y axis.  I've
worked out how to do this.


However, I need to plot series a and b a points

(symbols only, no line), whislt c and d need plotting as
lines (with no symbols).  What is the easiest way to do
this in xyplot?  Or should I be using something else?


Thanks!

Paul

__
R-help@r-project.org

mailing list

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

reproducible code.






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

What is the problem that you are trying to solve?

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




  
__

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

http://www.flickr.com/gift/

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


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


Re: [R] eps file with embedded font

2009-09-06 Thread Ted Harding
I am going back to Simone's original query (though this will
split the thread) because subsequent replies did not include
his original. Some comments interspersed below; the main
response at the end.

I have had some private correspondence with Simone, who sent me
two of his files that exhibit the problem, and this has enabled
me to form an idea of where the trouble may lie. It would seem
that either there is something seriously wrong with the function
embedFonts(), or with ghostscript when executing the command
generated by embedFonts(), or with both. I shal descibe the results
of my esperminets, in the hope that some expert in embedFonts(),
or in ghostscript, or in both, can make a useful suggestion.

On 04-Sep-09 14:01:44, Simone Gabbriellini wrote:
 Dear list,
 I am trying to make eps file with embedded font.
 I use:
 
 postscript(ranking-exp-all.eps, horizontal=TRUE, onefile=FALSE,
paper=special, height=8, width=12, family=Helvetica)
 # plot stuff
 dev.off()
 
 since R does not embed font, I then use:
 
 embedFonts(file=indegdistr.eps, outfile=indegdistrEMB.eps,
fontpaths=System/Library/Fonts)

I think Simone intended to use a different filename here, probably

  embedFonts(file=ranking-exp-all.eps,
 outfile=ranking-exp-all-EMB.eps,
 fontpaths=System/Library/Fonts)

in line with his previous command above. This is not important here.

 the problem is that the second file, with font embedded, is cutted
 near the end, and the very last part of the plots and the border are
 off the page...

In fact the bottom of the graphic is slightly clipped when viewed
in ghostview, and the righthand side is severely clipped.

 I use R 2.8.1 on a Mac OSX
 any help more than welcome,
 regards,
 Simone

Ths problem Simone encountered can be reproduced in a simple way
as follows.

  postscript(file=test1.eps,family=Times,horizontal=FALSE,
 paper=special,width=10,height=5)
  plot(c(0,1,2),c(0,1,4),main=Test Plot,xlab=X,ylab=Y)
  dev.off()

If I view this file test1.eps in ghostsript (using 'gv', on Linux),
I see it fine. There is a nice clearance all round (about 24 points
above the Test Plot title, about 6 points to the left of the
Y y-axis label, about 30 points below the X x-axis label,
and about 30 points to the right of the plot frame.

The BoundingBox line in test1.eps is
  %%BoundingBox: 0 0 720 360
so it is indeed 10 inches wide and 5 inches high, as requested.
So far, so good.

Now I do the equivalent of Simone's embedFonts() command:

  embedFonts(file=test1.eps,format=pswrite,
 outfile=test1-EMB.eps)

and view the result of this in 'gv'. The left, top and bottom of
the plot just fit in (there is a miniscule space left around them),
but the right-hand side of the plot is severely cropped. Instead
of seeing the x-axis out to 2.0, with the right-hand side of the
frame, and a little bit of space, it is truncated around x = 1.75

The BoundingBox in test1-EMB.eps is specified in the lines:
  %%BoundingBox: 4 18 595 336
  %%HiResBoundingBox: 4.60 18.70 595.00 335.30
so the BBox 0 0 720 360 from test1.eps has been slightly trimmed
on the left, substantially (18 points) from below and (14 points)
from above, and hugely (125 points = 1.74 inches) from the right.

The lesser trimmings on the left, bottom and top can be put down,
perhaps, to ghostscript putting the BoundingBox just outside the
marks on the page; but *not* the bad cropping of the right-hand
side, since marks which ought to be included are way outside it.

Next I tried editing a copy test1B-EMB.eps of test1-EMB.eps, to
change the BoundingBox to what it ought to be (0 0 720,360).
The ghostscript window now encloises the full BoundingBox, but
the righthand part is blank (only what can be seen in test1-EMB.eps
is shown, i.e. up to x = 1.75 approx, with what should be seen
beyond this being totally blank).

It follows that, despite the BoundingBox now being the correct
one (and of course the BBox is a clipping-path for display in gv),
there is additional clipping being done in the PostScript generate
by ghostscript as a result of embedFonts().

Looking into the PostScript in test1-EMB.eps (or test1B-EMB.eps),
there are several occurrenfces of clip therein. However, the
additional PostScript generated by ghostscript is very obscure,
and I cannot decipher what is going on.

It next occurred to me that one may be able to add ghostsctript
options to the call to embedFonts(), to try to ensure that it
would respect the original BoundingBox. The command generated by
  embedFonts(file=test1.eps,format=pswrite,
 outfile=test1-EMB.eps)
is:

  gs -dNOPAUSE -dBATCH -q -dAutoRotatePages=/None -sDEVICE=pswrite \
  -sOutputFile=/tmp/RtmplPWs8l/Rembed24b931bd -sFONTPATH=  test1.eps

A quick study of the ghostscript documentation revealed the existence
of some EPS Parameters, of which the only one that seemed relevant
was:

  -dEPSCrop
  Crop an EPS file to the bounding box. 

Re: [R] Combining expressions.

2009-09-06 Thread Rolf Turner


Many thanks to Gabor Grothendieck and William Dunlap who both
solved my problem for me, right rapidly!

cheers,

Rolf Turner

##
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}

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

2009-09-06 Thread Grzes

Hi!
I want to use one method combinations from gtools package but in my code
I must use also dprep method where is method combinations too. Mayby I
show you result my help function:

Help on topic 'combinations' was found in the following packages: 

  Package   Library 
  dprep /usr/lib64/R/library 
  gtools/usr/lib64/R/library 

Choose one 

1: Constructing distinct permutations {dprep} 
2: Enumerate the Combinations or Permutations of the Elements of a Vector
{gtools} 


If I want to use combination method I use error:

 combinations(3,2,letters[1:3]) 
Error in combinations(3, 2, letters[1:3]) : 
  unused argument(s) (2, letters[1:3])

Do you have any idea?
I try code similar to C++   gtools::combinations but in my opinion it's
wrong way.

If my explanation is't clear to you let me show my all attempts:


 library(gtools) 
 combinations(3,2,letters[1:3]) 
 [,1] [,2] 
[1,] a  b 
[2,] a  c 
[3,] b  c 
 library(dprep) 
Loading required package: MASS 
Loading required package: nnet 
Loading required package: lattice 
Loading required package: class 

Attaching package: 'dprep' 


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

combinations 

 combinations(3,2,letters[1:3]) 
Error in combinations(3, 2, letters[1:3]) : 
  unused argument(s) (2, letters[1:3]) 

 gtools::combinations  
function (n, r, v = 1:n, set = TRUE, repeats.allowed = FALSE) 
{ 
if (mode(n) != numeric || length(n) != 1 || n  1 || (n%%1) != 
0) 
stop(bad value of n) 
if (mode(r) != numeric || length(r) != 1 || r  1 || (r%%1) != 
0) 
stop(bad value of r) 
if (!is.atomic(v) || length(v)  n) 
stop(v is either non-atomic or too short) 
if ((r  n)  repeats.allowed == FALSE) 
stop(r  n and repeats.allowed=FALSE) 
if (set) { 
v - unique(sort(v)) 
if (length(v)  n) 
stop(too few different elements) 
} 
v0 - vector(mode(v), 0) 
if (repeats.allowed) 
sub - function(n, r, v) { 
if (r == 0) 
v0 
else if (r == 1) 
matrix(v, n, 1) 
else if (n == 1) 
matrix(v, 1, r) 
else rbind(cbind(v[1], Recall(n, r - 1, v)), Recall(n - 
1, r, v[-1])) 
} 
else sub - function(n, r, v) { 
if (r == 0) 
v0 
else if (r == 1) 
matrix(v, n, 1) 
else if (r == n) 
matrix(v, 1, n) 
else rbind(cbind(v[1], Recall(n - 1, r - 1, v[-1])), 
Recall(n - 1, r, v[-1])) 
} 
sub(n, r, v[1:n]) 
} 
environment: namespace:gtools 

 combinations(3,2,letters[1:3])  ### what I should do to 
 start working combinations?
Error in combinations(3, 2, letters[1:3]) : 
  unused argument(s) (2, letters[1:3]) 
-- 
View this message in context: 
http://www.nabble.com/Two-packages-in-one-method-tp25319739p25319739.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] avoid NA in list

2009-09-06 Thread Grzes

Hi!
I Have list, for example:
...
[[22]]
[1]  27  51  69 107 119

[[23]]
[1] NA

[[24]]
[1] 54 57 62

And I would like to avoid NA value. Similar way like I may do it in vector
using na.value() function.
Do you have any idea?
-- 
View this message in context: 
http://www.nabble.com/avoid-NA-in-list-tp25321020p25321020.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] Creating adjacency matrix from a data frame

2009-09-06 Thread Thomas Jensen

Dear R-list,

Sorry for spamming the list, but I am just learning how to manipulate  
data in R, so  if this is a trivial question I am sorry.


I have the following data which list the distance between capitals:

ida idb kmdist
7108UK  BEL  313
7110UK  FRN  365
7116UK  POR 1618

I would like to convert this into an a valued adjacency matrix that  
looks like this:


BEL FRN POR
UK  313 365 1618

The full data set has all possible pairings between countries, so the  
end goal should be a symmetric adjacency matrix.


Thank you,

Thomas Jensen

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

2009-09-06 Thread Henrique Dallazuanna
Try this:

 xtabs(kmdist ~ ida + idb, data = x)

On Sun, Sep 6, 2009 at 5:12 PM, Thomas Jensen 
thomas.jen...@eup.gess.ethz.ch wrote:

 Dear R-list,

 Sorry for spamming the list, but I am just learning how to manipulate data
 in R, so  if this is a trivial question I am sorry.

 I have the following data which list the distance between capitals:

ida idb kmdist
 7108UKBEL313
 7110UKFRN365
 7116UKPOR   1618

 I would like to convert this into an a valued adjacency matrix that looks
 like this:

BEL FRN POR
 UK  313 365 1618

 The full data set has all possible pairings between countries, so the end
 goal should be a symmetric adjacency matrix.

 Thank you,

 Thomas Jensen

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




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

[[alternative HTML version deleted]]

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


[R] How many attributes are there of a variable?

2009-09-06 Thread Peng Yu
Hi,

According to the example below this email, attr(x,names) is the same
as names(x). I am wondering how many attributes there are of a given
variable. How to find out what they are? Can I always use
some_attribute(x) instead of attr(x, some_attribute)?

Regards,
Peng

 x=c(1,2,3)
 attr(x,names)=c(a,b,c)
 x
a b c
1 2 3

 y=c(1,2,3)
 names(y)=c(a,b,c)
 y
a b c
1 2 3

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 refer the element in a named list?

2009-09-06 Thread Duncan Murdoch

On 06/09/2009 1:45 PM, David Winsemius wrote:

On Sep 6, 2009, at 1:35 PM, Duncan Murdoch wrote:


On 06/09/2009 1:04 PM, Peng Yu wrote:

Hi,
I thought that 'coefficients' is a named list, but I can not refer to
its element by something like r$coefficients$y. I used str() to check
r. It says the following. Can somebody let me know what it means?

The line that matters is the one

$ coefficients : Named num [1:2] 1.12e-15 1.00

It says that coefficients is a numeric (num) vector, not a list.   
So r$coefficients[y] will extract the y coefficient.




And r$coefficients[`(Intercept)`] # note back-quote, should get you  
the intercept


No, that says to get the element of the coefficients whose index is 
stored in a variable named `(Intercept)`.  (Chances are that variable 
doesn't exist, unless you made an effort to create it.  And if you 
perversely stored y in it you'd get the same coefficient as before!)


You want regular (single or double, R doesn't care) quotes to say that 
you are giving the index directly:


r$coefficients[(Intercept)]

Duncan Murdoch


?coef

Generally coef(fit) will extract model coefficients across a wider  
range of R model objects.




Duncan Murdoch



 ..- attr(*, names)= chr [1:2] (Intercept) y
$ Rscript lm.R

x=1:10
y=1:10
r=lm(x~y)
class(r)

[1] lm

mode(r)

[1] list

r

Call:
lm(formula = x ~ y)
Coefficients:
(Intercept)y
 1.123e-151.000e+00

r$coefficients[1]

(Intercept)
1.123467e-15

r$coefficients[[1]]

[1] 1.123467e-15

r$coefficients[2]

y
1

r$coefficients[[2]]

[1] 1

str(r)

List of 12
$ coefficients : Named num [1:2] 1.12e-15 1.00
 ..- attr(*, names)= chr [1:2] (Intercept) y
Regards,
Peng
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

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


David Winsemius, MD
Heritage Laboratories
West Hartford, CT


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


Re: [R] Two packages ane one method

2009-09-06 Thread Henrique Dallazuanna
You have tried

gtools::combinations(3,2,letters[1:3])

?

On Sun, Sep 6, 2009 at 2:10 PM, Grzes gregori...@gmail.com wrote:


 Hi!
 I want to use one method combinations from gtools package but in my
 code
 I must use also dprep method where is method combinations too. Mayby I
 show you result of help function:

 Help on topic 'combinations' was found in the following packages:

  Package   Library
  dprep /usr/lib64/R/library
  gtools/usr/lib64/R/library

 Choose one

 1: Constructing distinct permutations {dprep}
 2: Enumerate the Combinations or Permutations of the Elements of a Vector
 {gtools}


 If I want to use combination method I use error:

  combinations(3,2,letters[1:3])
 Error in combinations(3, 2, letters[1:3]) :
  unused argument(s) (2, letters[1:3])

 Do you have any idea?
 I try code similar to C++   gtools::combinations but in my opinion it's
 wrong way.

 If my explanation is't clear to you let me show my all attempts:


  library(gtools)
  combinations(3,2,letters[1:3])
 [,1] [,2]
 [1,] a  b
 [2,] a  c
 [3,] b  c
  library(dprep)
 Loading required package: MASS
 Loading required package: nnet
 Loading required package: lattice
 Loading required package: class

 Attaching package: 'dprep'


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

combinations

  combinations(3,2,letters[1:3])
 Error in combinations(3, 2, letters[1:3]) :
  unused argument(s) (2, letters[1:3])

  gtools::combinations
 function (n, r, v = 1:n, set = TRUE, repeats.allowed = FALSE)
 {
if (mode(n) != numeric || length(n) != 1 || n  1 || (n%%1) !=
0)
stop(bad value of n)
if (mode(r) != numeric || length(r) != 1 || r  1 || (r%%1) !=
0)
stop(bad value of r)
if (!is.atomic(v) || length(v)  n)
stop(v is either non-atomic or too short)
if ((r  n)  repeats.allowed == FALSE)
stop(r  n and repeats.allowed=FALSE)
if (set) {
v - unique(sort(v))
if (length(v)  n)
stop(too few different elements)
}
v0 - vector(mode(v), 0)
if (repeats.allowed)
sub - function(n, r, v) {
if (r == 0)
v0
else if (r == 1)
matrix(v, n, 1)
else if (n == 1)
matrix(v, 1, r)
else rbind(cbind(v[1], Recall(n, r - 1, v)), Recall(n -
1, r, v[-1]))
}
else sub - function(n, r, v) {
if (r == 0)
v0
else if (r == 1)
matrix(v, n, 1)
else if (r == n)
matrix(v, 1, n)
else rbind(cbind(v[1], Recall(n - 1, r - 1, v[-1])),
Recall(n - 1, r, v[-1]))
}
sub(n, r, v[1:n])
 }
 environment: namespace:gtools

  combinations(3,2,letters[1:3])  ### what I should do to
  start working combinations?
 Error in combinations(3, 2, letters[1:3]) :
  unused argument(s) (2, letters[1:3])
 --
 View this message in context:
 http://www.nabble.com/Two-packages-ane-one-method-tp25319739p25319739.html
 Sent from the R help mailing list archive at Nabble.com.

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




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

[[alternative HTML version deleted]]

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


Re: [R] avoid NA in list

2009-09-06 Thread Henrique Dallazuanna
Try this:

your_list[!is.na(your_list)]

On Sun, Sep 6, 2009 at 4:32 PM, Grzes gregori...@gmail.com wrote:


 Hi!
 I Have list, for example:
 ...
 [[22]]
 [1]  27  51  69 107 119

 [[23]]
 [1] NA

 [[24]]
 [1] 54 57 62

 And I would like to avoid NA value. Similar way like I may do it in vector
 using na.value() function.
 Do you have any idea?
 --
 View this message in context:
 http://www.nabble.com/avoid-NA-in-list-tp25321020p25321020.html
 Sent from the R help mailing list archive at Nabble.com.

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




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

[[alternative HTML version deleted]]

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


Re: [R] How to refer the element in a named list?

2009-09-06 Thread Peng Yu
On Sun, Sep 6, 2009 at 12:45 PM, David Winsemiusdwinsem...@comcast.net wrote:

 On Sep 6, 2009, at 1:35 PM, Duncan Murdoch wrote:

 On 06/09/2009 1:04 PM, Peng Yu wrote:

 Hi,
 I thought that 'coefficients' is a named list, but I can not refer to
 its element by something like r$coefficients$y. I used str() to check
 r. It says the following. Can somebody let me know what it means?

 The line that matters is the one

 $ coefficients : Named num [1:2] 1.12e-15 1.00

 It says that coefficients is a numeric (num) vector, not a list.  So
 r$coefficients[y] will extract the y coefficient.


 And r$coefficients[`(Intercept)`] # note back-quote, should get you the
 intercept

Back-quotes do not work.

 r$coefficients[`(Intercept)`]
Error: object '(Intercept)' not found
 r$coefficients[(Intercept)]
 (Intercept)
1.123467e-15


 ?coef

 Generally coef(fit) will extract model coefficients across a wider range of
 R model objects.


 Duncan Murdoch


  ..- attr(*, names)= chr [1:2] (Intercept) y
 $ Rscript lm.R

 x=1:10
 y=1:10
 r=lm(x~y)
 class(r)

 [1] lm

 mode(r)

 [1] list

 r

 Call:
 lm(formula = x ~ y)
 Coefficients:
 (Intercept)            y
  1.123e-15    1.000e+00

 r$coefficients[1]

 (Intercept)
 1.123467e-15

 r$coefficients[[1]]

 [1] 1.123467e-15

 r$coefficients[2]

 y
 1

 r$coefficients[[2]]

 [1] 1

 str(r)

 List of 12
 $ coefficients : Named num [1:2] 1.12e-15 1.00
  ..- attr(*, names)= chr [1:2] (Intercept) y
 Regards,
 Peng
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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

 David Winsemius, MD
 Heritage Laboratories
 West Hartford, CT



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


Re: [R] How many attributes are there of a variable?

2009-09-06 Thread Frank E Harrell Jr

Peng,

You can create all the attributes you want, with one headache: R does 
not keep attributes across subsetting operations so you need to write 
classes and [.something methods when attributions need to be kept or 
adjusted upon subsetting rows.


The Hmisc package uses attributes such as label, units, imputed.  You 
might look at the code to see how it did that.  For example, label(x) 
will use attr(x, 'label') to fetch the 'label' attribute.  There are 
attribute-setting functions there too.


Frank


Peng Yu wrote:

Hi,

According to the example below this email, attr(x,names) is the same
as names(x). I am wondering how many attributes there are of a given
variable. How to find out what they are? Can I always use
some_attribute(x) instead of attr(x, some_attribute)?

Regards,
Peng


x=c(1,2,3)
attr(x,names)=c(a,b,c)
x

a b c
1 2 3

y=c(1,2,3)
names(y)=c(a,b,c)
y

a b c
1 2 3

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




--
Frank E Harrell Jr   Professor and Chair   School of Medicine
 Department of Biostatistics   Vanderbilt University

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


Re: [R] How to wait for a user response in Rscript?

2009-09-06 Thread Peng Yu
Hi,

The following script will run without asking me anything.

$ Rscript plot.R
 x=1:10
 y=1:10
 X11()
 plot(x,y)
 par(ask=T)


Regards,
Peng

On Sun, Sep 6, 2009 at 11:55 AM, RIOS,ALFREDO ARTUROar...@ufl.edu wrote:
 Hi Peng

 I think this is what you are looking for

 par(ask=T)

 Alfredo


 On Sun Sep 06 12:52:31 EDT 2009, Peng Yu pengyu...@gmail.com wrote:

 Hi,

 In 'example(barplot)' running in R, I see 'Hit Return to see next
 plot:', then R waits for my input. I am wondering how to wait for a
 user response in Rscript.

 Regards,
 Peng

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





 --
 RIOS,ALFREDO ARTURO



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

2009-09-06 Thread Peter Alspach
Tena koe

Alternatively, for instances where you have a list element which is a vector of 
all NA:

 grzes - list(a=1:4, b=NA, c=letters[1:5], d=c(1,NA,10), e=rep(NA,5))
 grzes
$a
[1] 1 2 3 4

$b
[1] NA

$c
[1] a b c d e

$d
[1]  1 NA 10

$e
[1] NA NA NA NA NA

 grzes[sapply(grzes, function(x) !all(is.na(x)))]
$a
[1] 1 2 3 4

$c
[1] a b c d e

$d
[1]  1 NA 10

 grzes[!is.na(grzes)]
$a
[1] 1 2 3 4

$c
[1] a b c d e

$d
[1]  1 NA 10

$e
[1] NA NA NA NA NA


HTH ...

Peter Alspach
 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of Henrique 
 Dallazuanna
 Sent: Monday, 7 September 2009 8:37 a.m.
 To: Grzes
 Cc: r-help@r-project.org
 Subject: Re: [R] avoid NA in list
 
 Try this:
 
 your_list[!is.na(your_list)]
 
 On Sun, Sep 6, 2009 at 4:32 PM, Grzes gregori...@gmail.com wrote:
 
 
  Hi!
  I Have list, for example:
  ...
  [[22]]
  [1]  27  51  69 107 119
 
  [[23]]
  [1] NA
 
  [[24]]
  [1] 54 57 62
 
  And I would like to avoid NA value. Similar way like I may do it in 
  vector using na.value() function.
  Do you have any idea?
  --
  View this message in context:
  http://www.nabble.com/avoid-NA-in-list-tp25321020p25321020.html
  Sent from the R help mailing list archive at Nabble.com.
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
 
 
 --
 Henrique Dallazuanna
 Curitiba-Paraná-Brasil
 25° 25' 40 S 49° 16' 22 O
 
   [[alternative HTML version deleted]]
 
 

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


Re: [R] How to wait for a user response in Rscript?

2009-09-06 Thread Joshua Wiley
Hello Peng Yu,

Invert the order of plot and par.  See below:

x=1:10
y=1:10
X11()

par(ask=T)
plot(x,y)

That should wait for some user input.

I hope that helps,

Joshua

On Sun, Sep 6, 2009 at 2:23 PM, Peng Yu pengyu...@gmail.com wrote:

 Hi,

 The following script will run without asking me anything.

 $ Rscript plot.R
  x=1:10
  y=1:10
  X11()
  plot(x,y)
  par(ask=T)
 

 Regards,
 Peng

 On Sun, Sep 6, 2009 at 11:55 AM, RIOS,ALFREDO ARTUROar...@ufl.edu wrote:
  Hi Peng
 
  I think this is what you are looking for
 
  par(ask=T)
 
  Alfredo
 
 
  On Sun Sep 06 12:52:31 EDT 2009, Peng Yu pengyu...@gmail.com wrote:
 
  Hi,
 
  In 'example(barplot)' running in R, I see 'Hit Return to see next
  plot:', then R waits for my input. I am wondering how to wait for a
  user response in Rscript.
 
  Regards,
  Peng
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
 
 
 
  --
  RIOS,ALFREDO ARTURO
 
 

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




-- 
Joshua Wiley
Senior in Psychology
University of California, Riverside
http://www.joshuawiley.com/

[[alternative HTML version deleted]]

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


Re: [R] How to wait for a user response in Rscript?

2009-09-06 Thread Alfredo
Sorry, did not realize that it was for Rscript

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Peng Yu
Sent: Sunday, September 06, 2009 5:24 PM
To: r-h...@stat.math.ethz.ch
Subject: Re: [R] How to wait for a user response in Rscript?

Hi,

The following script will run without asking me anything.

$ Rscript plot.R
 x=1:10
 y=1:10
 X11()
 plot(x,y)
 par(ask=T)


Regards,
Peng

On Sun, Sep 6, 2009 at 11:55 AM, RIOS,ALFREDO ARTUROar...@ufl.edu wrote:
 Hi Peng

 I think this is what you are looking for

 par(ask=T)

 Alfredo


 On Sun Sep 06 12:52:31 EDT 2009, Peng Yu pengyu...@gmail.com wrote:

 Hi,

 In 'example(barplot)' running in R, I see 'Hit Return to see next
 plot:', then R waits for my input. I am wondering how to wait for a
 user response in Rscript.

 Regards,
 Peng

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





 --
 RIOS,ALFREDO ARTURO



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

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


Re: [R] Nested Fixed Effects - basic questions

2009-09-06 Thread Daniel Malter
You will have to talk to your local statistician/econometrician. Given that
you say you will have three observations per student, your description of
the data is incomplete. Therefore, it is impossible to tell what the right
approach would be. Assumed that all observations are independent, you would
fit fix3 as one dummy/factor variable (not fix1 or fix2), and then you would
test linear hypotheses for sums of certain coefficients against sums of
other coefficients in your case. Nested effects are what you can specify as
random effects, afaik; you don't fit them in fixed-effects analyses (rather
you would take the outlined linear-hypothesis approach).
 
As far as I can tell from your post, your understanding of the subject
matter is limited. As I said, you will have to get yourself an overview of
the topic and search for materials that explain a.) nested effects and b.)
the application of nested effects in R (e.g. with the nlme and lme4
libraries). So go ahead and put in the effort.
 
Daniel
 
ps: on a more general note, the R-help list is to help with the
implementation in R rather than statistical/econometric questions,
especially if these problems are extensive.
 
-
cuncta stricte discussurus
-
 

  _  

Von: Jojo Ziggy [mailto:jojo.zi...@yahoo.com] 
Gesendet: Saturday, September 05, 2009 2:14 PM
An: Daniel Malter
Betreff: Re: AW: [R] Nested Fixed Effects - basic questions


Nesting would imply something like students nested
in class nested in school, where each student is only member of one class
and each class only member of one school.

Yes, I think this is actually what I have going on - I guess I did not
represent that correctly in the data table.

So... I gather my data shown properly as nested effects should actually look
more like:

fix1fix2fix3response
00016.596
00016.564
00122.665
00122.801
01216.000
01215.930
01321.739
01321.628
12416.260
12416.128
12522.969
12523.245
13614.687
13614.635
13722.954
13723.345

In this case, how do I tell R that the effects are nested, as opposed to
unnested?  And how do I specify that they are fixed and not random effects?
Will it somehow know automatically?  

I will in the end have 3 observations for each student - so 24 datapoints
in this example.  Certainly nothing close to 160, however.

Thanks,
jojo


  _  

From: Daniel Malter dan...@umd.edu
To: Jojo Ziggy jojo.zi...@yahoo.com; r-help@r-project.org
Sent: Friday, September 4, 2009 4:37:14 PM
Subject: AW: [R] Nested Fixed Effects - basic questions

In R and experimental or mixed-model terminology, your lm model specifies
fixed effects. As long as each data row represents a unique subject, you are
fine with lm. If not, you have to account for the repeated measurement of
subjects and will need other methods (potentially involving random effects).
In your model, you perform a dummy variable OLS (ordinary least squares)
regression. Mixed-effects models that allow for a combination of fixed and
random effects or random-effects-only analyses are most prominently done
with Doug Bates's nlme or lme4 libraries (though, there are more libraries
that allow for mixed-effects modeling). Google for some manuals.

Further, your effects are not nested. If each row stands for a different
unit of observation (e.g., subject), and if subjects are randomized into
treatments fix1, fix2, and fix3, then you have a completely randomized
factorial design (CRF). Nesting would imply something like students nested
in class nested in school, where each student is only member of one class
and each class only member of one school. Then your fix columns should look
like (with 8 students nested in 4 classes nested in 2 schools):

fix1 fix2 fix3
111
211
321
421
532
632
742
842

Thus, your effects are really not nested (at least not for what you show us
as the data). What you can do to figure out whether not only fix1 and fix2
have an independent effect, but also whether fix1 and fix2 interact in their
effect on your response, you can include interaction effects. However, if
the data you provided is your entire dataset, you will likely overfit the
model and inflate the standard errors if you include all possible
interactions (eats up 4 degrees of freedom) along with the direct effects
and intercept (also 4 degrees of freedom), given that your provided data has
only 16 observations.

Example:
#Simulate data
fix1=rep(0:1,each=8)
fix2=rep(c(0,0,1,1),4)
fix3=rep(0:1,8)
e=rnorm(16)

#Dependent variable
y=-1*fix1+2*fix2+1*fix3-0.75*fix1*fix2+0.9*fix1*fix3-2*fix2*fix3+1.5*fix1*fi
x2*fix3+e

#Run regression and show output
reg0=lm(y~(fix1+fix2+fix3)^3) #all interactions up to three-way
summary(reg0) 
#note that this is not very 

[R] CRAN (and crantastic) updates this week

2009-09-06 Thread Crantastic
CRAN (and crantastic) updates this week

New packages


* AICcmodavg (1.01)
  Marc J. Mazerolle
  http://crantastic.org/packages/AICcmodavg

  This package includes functions to create model selection tables based
  on Akaike's information criterion (AIC) and the second-order AIC
  (AICc), as well as their quasi-likelihood counterparts (QAIC,
  QAICc).  Tables are printed with delta AIC and Akaike weights.  The
  package also includes functions to conduct model averaging
  (multimodel inference) for a given parameter of interest or
  predicted values.  Other handy functions enable the computation of
  relative variable importance, evidence ratios, and confidence sets
  for the best model. The present version works with lm, glm, and lme
  object classes.

* amer (0.5)
  Fabian Scheipl
  http://crantastic.org/packages/amer

  Fitting generalized additive mixed models based on the mixed model
  algorithm of lme4

* frbf (0.9)
  Fernando Martins
  http://crantastic.org/packages/frbf

  Flexible kernerl for radial basis function network implementation.

* GGMselect (0.1-0)
  Annie Bouvier
  http://crantastic.org/packages/GGMselect

  GGMselect is a package dedicated to graph estimation in Gaussian
  Graphical Models. The main functions return the adjacency matrix of
  an undirected graph estimated from a data matrix.

* lemma (1.2-1)
  Haim Bar
  http://crantastic.org/packages/lemma

  LEMMA is used to detect nonnull genes - genes for which the average
  response in treatment group 1 is significantly different from the
  average response in group 2, in normalized microarray data. LEMMA is
  an implementation of an approximate EM algorithm to estimate the
  parameters in the assumed linear model in Bar, Booth, Schifano,
  Wells (2009).


Updated packages


AICcmodavg (1.01), betareg (2.0-0), BioIDMapper (1.2), boolean
(2.0-1), boolean (2.0-0), boot (1.2-39), cem (1.0.111), clue (0.3-30),
DAKS (2.0-0), dcemri (0.10.5), dplR (1.1.9.1), drc (1.7-7), epicalc
(2.9.2.0), etm (0.4-6), exams (1.0-2), feature (1.2.4), GenABEL
(1.4-4), gnumeric (0.5-2), gputools (0.1-3), hash (0.40), Hmisc
(3.7-0), Iso (0.0-7), ISOcodes (0.2-5), KernSmooth (2.23-3),
longitudinalData (0.6), mapReduce (1.02), MCMCglmm (1.11), meta
(1.0-6), mhsmm (0.3.0), multmod (0.5), nleqslv (1.5), nlme (3.1-94),
OAIHarvester (0.0-5), orientlib (0.9.3), phmm (0.6), R.matlab (1.2.5),
rainbow (1.4), Rcplex (0.2-3), relations (0.5-4), rgdal (0.6-17),
Rmpfr (0.1-6), RWeka (0.3-21), sdef (1.2), SigWinR (1.0.1), simecol
(0.6-9), simFrame (0.1.1), skmeans (0.1-1), Snowball (0.0-7), spgrass6
(0.6-8), spgrass6 (0.6-9), SubpathwayMiner (2.0), tau (0.0-3), tau
(0.0-2), TeachingSampling (1.0.2), tsDyn (0.7-1), tseries (0.10-19),
ttrTests (1.1), YourCast (1.1-2)


New reviews
---

* wavethresh, by cranktastic
  http://crantastic.org/reviews/27



This email provided as a service for the R community by
http://crantastic.org.

Like it?  Hate it?  Please let us know: crana...@gmail.com.

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


[R] Is there a package for generating standardized R script command line options?

2009-09-06 Thread Peng Yu
Hi,

In python, there is a package that helps generating command line
options. I am wondering if there is such a package in R that helps
generating the command options for a R script?

http://docs.python.org/library/optparse.html

Regards,
Peng

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Is there a package for generating standardized R script command line options?

2009-09-06 Thread Gabor Grothendieck
Check out the getopt package on CRAN.

On Sun, Sep 6, 2009 at 8:28 PM, Peng Yupengyu...@gmail.com wrote:
 Hi,

 In python, there is a package that helps generating command line
 options. I am wondering if there is such a package in R that helps
 generating the command options for a R script?

 http://docs.python.org/library/optparse.html

 Regards,
 Peng

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


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


[R] Why tempdir() always give me the same results in the same session?

2009-09-06 Thread Peng Yu
Hi,

tempdir() always gives me the same result. Should it give a different
result each time I call it?

 tempdir()
[1] /tmp/RtmppB72wH
 tempdir()
[1] /tmp/RtmppB72wH

Regards,
Peng

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Why this statement does not print anything in an if-statement that includes 'q()'?

2009-09-06 Thread Peng Yu
Hi,

I run the following script. I don't understand why the second
'length(args)' does not show anything but the first one shows '0'. Is
it because the command 'q()' affects anything in the if-statement.

However, if I change the second 'length(args)' to
'print(length(args))', the script will print the length of 'args'. Can
somebody let me know what is the difference between the 'print(x)'
statement and the 'x' statement where 'x' is a variable?

Regards,
Peng

$ Rscript not_print_in_if_block.R
 args=commandArgs(T)
 length(args)
[1] 0

 if(length(args)!=3){
+   length(args)
+   q()
+ }

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Why tempdir() always give me the same results in the same session?

2009-09-06 Thread cls59


Peng Yu wrote:
 
 
 tempdir() always gives me the same result. Should it give a different
 result each time I call it?
 
 

The help page for tempdir() contains the following explanation of the return
value:

?tempdir

...
For tempdir, the path of the per-session temporary directory. 


I would interpret that to mean that each time you start R a temporary
directory is assigned which retains a static value until you close R and
then open it again later. 

-Charlie


-
Charlie Sharpsteen
Undergraduate
Environmental Resources Engineering
Humboldt State University
-- 
View this message in context: 
http://www.nabble.com/Why-tempdir%28%29-always-give-me-the-same-results-in-the-same-session--tp25323681p25323805.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Why this statement does not print anything in an if-statement that includes 'q()'?

2009-09-06 Thread jim holtman
You need to explicitly 'print' the second 'length' function call.
Only at the top level of the interactive session is the value of an
object printed out if you just reference the object.

On Sun, Sep 6, 2009 at 9:13 PM, Peng Yupengyu...@gmail.com wrote:
 Hi,

 I run the following script. I don't understand why the second
 'length(args)' does not show anything but the first one shows '0'. Is
 it because the command 'q()' affects anything in the if-statement.

 However, if I change the second 'length(args)' to
 'print(length(args))', the script will print the length of 'args'. Can
 somebody let me know what is the difference between the 'print(x)'
 statement and the 'x' statement where 'x' is a variable?

 Regards,
 Peng

 $ Rscript not_print_in_if_block.R
 args=commandArgs(T)
 length(args)
 [1] 0

 if(length(args)!=3){
 +   length(args)
 +   q()
 + }

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




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

What is the problem that you are trying to solve?

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


Re: [R] struggling with split function

2009-09-06 Thread Dimitri Liakhovitski
Found a mistake - it was mine!
Thanks a lot for your help!

On Sun, Sep 6, 2009 at 8:43 AM, Dimitri Liakhovitskild7...@gmail.com wrote:
 Thanks a lot, Dimitris.
 It totally works on my example data frame.
 I know, it's probably hard to address, but when I try to apply it to
 the real huge data frame I have, after the last line I get:
 Error in `[.default`(x$A, na.ind, -1) :  incorrect number of dimensions.
 I know it's impossible to answer this question without seeing the
 data, but still: what do you think might be wrong?

 Do you think it could be because my first column contains something
 else but the split? No, I've just run the table on A and it is:
 split NA
 204 6356

 I also checked the first dimension of x and the length(na.ind) - the
 are the same length: 6560.

 No idea where the error might lye...


 Thanks a lot!
 Dimitri

 On Sun, Sep 6, 2009 at 5:43 AM, Dimitris
 Rizopoulosd.rizopou...@erasmusmc.nl wrote:
 one way is the following:

 ind - rle(is.na(x$A))
 ind - rep(seq_along(ind$lengths), ind$lengths)
 na.ind - is.na(x$A)
 split(x[na.ind, -1], ind[na.ind])


 I hope it helps.

 Best,
 Dimitris


 Dimitri Liakhovitski wrote:

 I am very sorry for such a simple question, but I am struggling with
 split.
 I have the following data frame:

 x-data.frame(A=c(NA,NA,NA,NA,split,NA,NA,NA,NA,split,NA,NA,NA,NA,split,NA,NA,NA,NA),

 B=c(Name1,text1,text2,text3,NA,Name2,text1,text2,text3,NA,Name3,text1,text2,text3,NA,Name4,text1,text2,text3),

 C=c(NA,1,NA,3,NA,NA,4,5,6,NA,NA,7,8,9,NA,NA,3,3,3),D=c(NA,1,1,2,NA,NA,5,6,NA,NA,NA,9,8,7,NA,NA,2,2,2),
 E=c(NA,3,2,1,NA,NA,6,5,4,NA,NA,7,7,8,NA,NA,1,NA,1))
 print(x)

 All I want to do is to split x, i.e., to create a list of data frames
 that are currently separated by the word split in column A. In this
 example, it would be 4 data frames, the first of them being:
 A B C D E
 NA Name1 NA NA NA
 NA text1 1 1 3
 NA text 2 NA 1 2
 NA text3 3 2 1

 etc.

 I tried:
 split(x, x$A)
 split(x,x$A == 'split')
 split(x,!is.na(x$A))

 But nothing produces what I need.
 Tanks a lot for any hint!


 --
 Dimitris Rizopoulos
 Assistant Professor
 Department of Biostatistics
 Erasmus University Medical Center

 Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
 Tel: +31/(0)10/7043478
 Fax: +31/(0)10/7043014




 --
 Dimitri Liakhovitski
 Ninah.com
 dimitri.liakhovit...@ninah.com




-- 
Dimitri Liakhovitski
Ninah.com
dimitri.liakhovit...@ninah.com

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


[R] Plot 2 ecdf in one graph

2009-09-06 Thread Roslina Zakaria
Hi r-users,
 
I would like to compare the cdf between historical and predicted. My x.obs and 
x.pre are the frequency data in classes of 0-300.
I tried:

plot(ecdf(x.obs),ecdf(x.pre),type=l,col=red)
 
and it gives me:

Error in plot.stepfun(x, ..., ylab = ylab, verticals = verticals, pch = pch) : 
  argument 4 matches multiple formal arguments
 
Thank you so much for any help given.


  
[[alternative HTML version deleted]]

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


Re: [R] Plot 2 ecdf in one graph

2009-09-06 Thread Rolf Turner


Two things:

(1) type=l won't work; plot.ecdf() calls plot.stepfun() and it  
doesn't have a ``type'' argument.


(2) Giving plot two separate objects to plot makes no sense at all.

(3) If you've got ***frequency*** data then ecdf() is probably not  
the right thing to do

in the first place.

(4) I can't count.

To get the ***plots** you want, do something like:

plot(ecdf(x.pre),do.points=FALSE,col=red,xlim=range(x.pre,x.obs))
plot(ecdf(x.obs),do.points=FALSE,col=blue,add=TRUE)

But as I said if x.obs and x.pre are counts, rather than the raw  
data, this
does not appear to make any sense.  You are getting the ecdf-s of the  
counts
rather than of the raw data which is a toadally different story.  And  
toadally

misleading.  Re-think.

cheers,

Rolf Turner

On 7/09/2009, at 1:52 PM, Roslina Zakaria wrote:


Hi r-users,

I would like to compare the cdf between historical and predicted.  
My x.obs and x.pre are the frequency data in classes of 0-300.

I tried:

plot(ecdf(x.obs),ecdf(x.pre),type=l,col=red)

and it gives me:

Error in plot.stepfun(x, ..., ylab = ylab, verticals = verticals,  
pch = pch) :

  argument 4 matches multiple formal arguments

Thank you so much for any help given.


##
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}

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

2009-09-06 Thread b miner

I attempted to use the package algdesign. I used the following code. However, 
the results were very much not matching the reference I noted (which is located 
at http://www2.sas.com/proceedings/sugi31/196-31.pdf). Instead of 30 design 
points, I received 25 and those that were returned, only half or so matched the 
reference. I am inexperienced with optimal designs so I dont know if I am doing 
something wrong, the package is not the correct one for the task or a 
combination. Here is the code in case anyone has any input:

#CODE:

runif(1) #for a bug in program (assumes random seed object exists)

dat-gen.factorial(c(3,3,3,3,2),varNames=c(Intro,Duration,GOTO,Fee,Color))
dat #show design plan

desD-optFederov(~Intro+Duration+GOTO+Fee+Color+quad(Intro)+quad(Duration)+quad(GOTO)+quad(Fee)+Intro*Duration+Intro*GOTO+Intro*Fee+Intro*Color+Duration*GOTO+Duration*Fee+Duration*Color+GOTO*Fee+GOTO*Color+Fee*Color,dat,crit=D,maxIteration=1000,eval=TRUE)

#D
desD$D

#design
desD$design
design-desD$design




 Subject: Re: [R]  DOE in R?
 From: c...@datanalytics.com
 To: b_mi...@live.com
 CC: r-help@r-project.org
 Date: Sun, 6 Sep 2009 14:57:36 +0200
 
 Hello,
 
 This is your starting point:
 
 http://cran.r-project.org/web/views/ExperimentalDesign.html
 
 Best regards,
 
 Carlos J. Gil Bellosta
 http://www.datanalytics.com
 
 
 On Thu, 2009-09-03 at 17:38 -0700, B_miner wrote:
  Hello!
  
  
  This is not a topic I am well versed in but required to become well versed
  in...I welcome any assistance!
  
  Using R, I want to create an optimal design for an experiment. I'll be
  analyzing the results with logistic regression or some generalized linear
  model. I am thinking that the algdesign package can help (but no idea where
  to start?).
  
  I'm presenting an example here that I have seen the answer to (in SAS) in
  order to make sure I would have gotten it *right*.
  
  There are 5 factors: 4 are quantitative with three levels each and 1 is
  qualitative with two levels.
  
  Factor and levels:
  
  Intro: 0, 1.99, 2.99
  Duration: 6, 9 ,12
  GOTO: 3.99, 4.99, 5.99
  Fee: 0, 15, 45
  Color: Red, White
  
  
  In order to screen these factors, I would want to get a design where I could
  evaluate all main effects, all first order interactions and the squared
  terms of Intro, Duration, GOTO and FEE (for example Intro*Intro).
  
  Looking for the D-optimal design.
  
  Is this something that  R can provide?
  
  
  These are, according to the SAS paper I read the following:
  Obs intro duration goto fee color
  1 0.00 6 3.99 0 WHITE
  2 0.00 6 3.99 45 RED
  3 0.00 6 5.99 0 RED
  4 0.00 6 5.99 45 WHITE
  5 0.00 9 3.99 45 RED
  6 0.00 9 4.99 15 WHITE
  7 0.00 9 5.99 0 RED
  8 0.00 12 3.99 0 RED
  9 0.00 12 3.99 45 WHITE
  10 0.00 12 5.99 0 WHITE
  11 0.00 12 5.99 45 RED
  12 0.00 12 5.99 45 WHITE
  13 1.99 6 3.99 15 RED
  14 1.99 6 4.99 45 WHITE
  15 1.99 6 5.99 0 WHITE
  16 1.99 9 5.99 45 RED
  17 1.99 12 3.99 0 WHITE
  18 1.99 12 5.99 15 RED
  19 2.99 6 3.99 0 WHITE
  20 2.99 6 3.99 45 WHITE
  21 2.99 6 4.99 0 RED
  22 2.99 6 5.99 15 WHITE
  23 2.99 6 5.99 45 RED
  24 2.99 9 3.99 0 RED
  25 2.99 12 3.99 15 WHITE
  26 2.99 12 3.99 45 RED
  27 2.99 12 4.99 0 WHITE
  28 2.99 12 4.99 45 RED
  29 2.99 12 5.99 0 RED
  30 2.99 12 5.99 45 WHITE
  
  
 
 
 
 

_
Windows Live: Make it easier for your friends to see what you’re up to on 
Facebook.
http://windowslive.com/Campaign/SocialNetworking?ocid=PID23285::T:WLMTAGL:ON:WL:en-US:SI_SB_facebook:082009
[[alternative HTML version deleted]]

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


[R] get the command line

2009-09-06 Thread Peng Yu
Hi,

commandArgs gives me the arguments. I am wondering what command can
give the whole command line.

Regards,
Peng

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

2009-09-06 Thread Steve Lianoglou
Hi,

On Sun, Sep 6, 2009 at 11:25 PM, Peng Yupengyu...@gmail.com wrote:
 Hi,

 commandArgs gives me the arguments. I am wondering what command can
 give the whole command line.

What does the whole command line mean? Are you looking for the
command args in one string?

paste(commandArgs(), collapse= )

Can you give an example of what you're trying to get?

-steve

-- 
Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

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

2009-09-06 Thread Peng Yu
On Sun, Sep 6, 2009 at 10:50 PM, Steve
Lianogloumailinglist.honey...@gmail.com wrote:
 Hi,

 On Sun, Sep 6, 2009 at 11:25 PM, Peng Yupengyu...@gmail.com wrote:
 Hi,

 commandArgs gives me the arguments. I am wondering what command can
 give the whole command line.

 What does the whole command line mean? Are you looking for the
 command args in one string?

 paste(commandArgs(), collapse= )

 Can you give an example of what you're trying to get?

For example, I run the following command in bash.

Rscript some_script.R a b c

I want to get the string Rscript some_script.R a b c in the script
some_script.R.

Regards,
Peng

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

2009-09-06 Thread Steve Lianoglou
On Mon, Sep 7, 2009 at 12:00 AM, Peng Yupengyu...@gmail.com wrote:
 On Sun, Sep 6, 2009 at 10:50 PM, Steve
 Lianogloumailinglist.honey...@gmail.com wrote:
 Hi,

 On Sun, Sep 6, 2009 at 11:25 PM, Peng Yupengyu...@gmail.com wrote:
 Hi,

 commandArgs gives me the arguments. I am wondering what command can
 give the whole command line.

 What does the whole command line mean? Are you looking for the
 command args in one string?

 paste(commandArgs(), collapse= )

 Can you give an example of what you're trying to get?

 For example, I run the following command in bash.

 Rscript some_script.R a b c

 I want to get the string Rscript some_script.R a b c in the script
 some_script.R.

If I print each arg in commandArgs() on its own line, when I call:

Rscript test.R a b c

I get:

/Library/Frameworks/R.framework/Resources/bin/exec/i386/R
--slave
--no-restore
--file=test.R
--args
a
b
c

From that you can reconstruct the command line pretty easily, except
for the missing Rscript part ...  is that what's concerning you? I'm
not sure how you would go about getting the Rscript, if that's what
you're after ...

-steve

-- 
Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

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

2009-09-06 Thread Roslina Zakaria
Hi r-users,
 
I would like to know how to put all the data that is greater than certain value 
in certain cell for my histogram.  For example, since maximum value of p1 is 
588 it doesn't fit in the breaks that we specified.  Can we write breaks 300? 
 
max(p1[,2])
pre.hist - hist(p1[,2],breaks = c(0,50,100,150,200,250,300),right=FALSE)
 
 max(p1)
[1] 587.2761
 pre.hist - hist(p1[,2],breaks = c(0,50,100,150,200,250,300),right=FALSE)
Error in hist.default(p1[, 2], breaks = c(0, 50, 100, 150, 200, 250, 300),  : 
  some 'x' not counted; maybe 'breaks' do not span range of 'x'
 max(p1[,2])
[1] 587.2761

Thank you.




  
[[alternative HTML version deleted]]

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


Re: [R] (no subject)

2009-09-06 Thread milton ruser
Hi Roslina,

x-runif(1000,min=0, max=600)
hist(x)

x2-ifelse(x=300,x,300)
summary(x2)
hist(x2, ,breaks = c(0,50,100,150,200,250,300))
 good luck

milton

On Mon, Sep 7, 2009 at 12:51 AM, Roslina Zakaria zrosl...@yahoo.com wrote:

 Hi r-users,

 I would like to know how to put all the data that is greater than certain
 value in certain cell for my histogram.  For example, since maximum value of
 p1 is 588 it doesn't fit in the breaks that we specified.  Can we write
 breaks 300?

 max(p1[,2])
 pre.hist - hist(p1[,2],breaks = c(0,50,100,150,200,250,300),right=FALSE)

  max(p1)
 [1] 587.2761
  pre.hist - hist(p1[,2],breaks = c(0,50,100,150,200,250,300),right=FALSE)
 Error in hist.default(p1[, 2], breaks = c(0, 50, 100, 150, 200, 250, 300),
 :
   some 'x' not counted; maybe 'breaks' do not span range of 'x'
  max(p1[,2])
 [1] 587.2761

 Thank you.





[[alternative HTML version deleted]]


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



[[alternative HTML version deleted]]

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


Re: [R] (no subject)

2009-09-06 Thread milton ruser
May be you also want:

x-runif(1000,min=0, max=600)

 x3-x[x=300]
summary(x3)
 hist(x3, ,breaks = c(0,50,100,150,200,250,300))

bests

milton

On Mon, Sep 7, 2009 at 1:01 AM, milton ruser milton.ru...@gmail.com wrote:

 Hi Roslina,

 x-runif(1000,min=0, max=600)
 hist(x)

 x2-ifelse(x=300,x,300)
 summary(x2)
 hist(x2, ,breaks = c(0,50,100,150,200,250,300))
  good luck

 milton

   On Mon, Sep 7, 2009 at 12:51 AM, Roslina Zakaria zrosl...@yahoo.comwrote:

  Hi r-users,

 I would like to know how to put all the data that is greater than certain
 value in certain cell for my histogram.  For example, since maximum value of
 p1 is 588 it doesn't fit in the breaks that we specified.  Can we write
 breaks 300?

 max(p1[,2])
 pre.hist - hist(p1[,2],breaks = c(0,50,100,150,200,250,300),right=FALSE)

  max(p1)
 [1] 587.2761
  pre.hist - hist(p1[,2],breaks =
 c(0,50,100,150,200,250,300),right=FALSE)
 Error in hist.default(p1[, 2], breaks = c(0, 50, 100, 150, 200, 250,
 300),  :
   some 'x' not counted; maybe 'breaks' do not span range of 'x'
  max(p1[,2])
 [1] 587.2761

 Thank you.





[[alternative HTML version deleted]]


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




[[alternative HTML version deleted]]

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