[R] Extracting R plots from MS Word

2006-06-29 Thread maj
Hi,

I am revising a paper that I am a co-author of. The figures are plots
generated from R but at the moment I do not have the R code that generates
them.

As this is time critical I would like to slightly abuse the list by asking
whether anyone knows how to extract from MS Word into a stand-alone
graphics file a plot that was pasted into Word from R (probably as a
Windows Metafile, but possibly as a bitmap).

I would be very grateful for help with this.

Regards,  Murray Jorgensen

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


[R] Problem with package sem

2006-06-29 Thread Gang Chen
Hi experts,

I just started to learn R today, and tried to work with an add-on  
package sem. I have a version of 2.3.1 on MacOS X 10.4.6 with sem put  
under /Library/Frameworks/R.framework/Versions/2.3/Resources/library

However when I typed

library(sem)

the following error showed up:

Error in library(sem) : 'sem' is not a valid package -- installed   
2.0.0?

Why is this?

Thank you,
Gang Chen


[[alternative HTML version deleted]]

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


[R] Address of FactoMineR package author

2006-06-29 Thread Patrick Connolly
I've tried to contact the author of part of the FactoMineR package
which was given as:  [EMAIL PROTECTED]

However, the cedilla is not liked by any mail system I have access to,
so that address is a non-starter.  I tried using a simple letter 'c'
which didn't cause a syntax error, but achieved nothing else.  

Could it just be that the address was correct and it's the season in
France for people to be away and so not answering email?  Or is there
something I should know about such characters in email addresses?

TIA

-- 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
   ___Patrick Connolly   
 {~._.~} Great minds discuss ideas
 _( Y )_Middle minds discuss events 
(:_~*~_:)Small minds discuss people  
 (_)-(_)   . Anon
  
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

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


Re: [R] Problem with package sem

2006-06-29 Thread Uwe Ligges
Gang Chen wrote:
 Hi experts,
 
 I just started to learn R today, and tried to work with an add-on  
 package sem. I have a version of 2.3.1 on MacOS X 10.4.6 with sem put  
 under /Library/Frameworks/R.framework/Versions/2.3/Resources/library
 
 However when I typed
 
 library(sem)
 
 the following error showed up:
 
 Error in library(sem) : 'sem' is not a valid package -- installed   
 2.0.0?


Please read the R Installation and Administration manual on how to 
install packages (e.g. with R CMD INTALL in the OS' console or 
install.packages() in R)

Uwe Ligges


 Why is this?
 
 Thank you,
 Gang Chen
 
 
   [[alternative HTML version deleted]]
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

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


Re: [R] R project question (SEM)

2006-06-29 Thread Uwe Ligges
Patrick Bedard wrote:
 Hi there, 
 
 I just saw your question on the help list and tough you could help me with
 some start-up info
 
 I just downloaded the R project software to try running SEM analysis and I
 also downloaded the SEM package. But it just sits there on the desktop and R
 does not know where it is...I can¹t figure out how to organize the
 files...When I type ?sem in R it says object sem not found...I can¹t seem to
 find help on the web on how to set-up the packages


Same answer:
There is the R Installation and Administration manual.

Uwe Ligges

 Well, thanks in advance
 
 __ 
 Patrick Bedard Ph.D.
 Dept. of Neuroscience
 Brown University
 
 
 
   [[alternative HTML version deleted]]
 
 
 
 
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

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


[R] re-direct to more or less

2006-06-29 Thread Mike Wolfgang
Dear list,

sometimes my function generates too much data and shows them on screen, i
cannot view first several lines until program ends and I have to scroll my
mouse up to get them. Is there any re-direction function in R to pipeline
outputs to more or less type functions?
Thanks

mike

[[alternative HTML version deleted]]

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


[R] Question on memory allocation loop

2006-06-29 Thread Manoj
Hello All,
  I am trying to work on writing the following piece of (pseudo)
code in an optimal fashion:


# Two data frames with some data

a = data.frame(somedata)
b = data.frame(somedata)

for(i in 1:nrow(dt) {
  # Merge dates for a given date into a new data frame
   c = merge(a[a$dt==dt[i],),b[b$dt == dt[i],], by=c(some column));
}



Now, my understanding is that the data frame c in the above code is
malloc'ed in every count of the loop.  Is that assumption correct?

Is the following attempt a better way of doing things?


a = data.frame(somedata)
b = data.frame(somedata)

# Pre-allocate data frame c

c = data.frame(for some size);

for(i in 1:nrow(dt) {
  # Merge dates for a given date into a new data frame
   # and copy the result into c

  copy(c, merge(a[a$dt==dt[i],),b[b$dt == dt[i],], by=c(some column));

}


Now the question is, How can I copy the merged data into my
pre-allocated data frame c ? I tried rbind/cbind but they are pretty
fuzzy about having the right names and dimension hence it fails.

Any help would be greatly appreciated!

Thanks.

Manoj

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


Re: [R] Problem with package sem

2006-06-29 Thread John Fox
Dear Gang Chen,

I expect that either you didn't install the package properly (see
?install.packages) or installed a version of the package for an earlier
version of R.

I hope this helps,
 John

On Wed, 28 Jun 2006 17:14:10 -0400
 Gang Chen [EMAIL PROTECTED] wrote:
 Hi experts,
 
 I just started to learn R today, and tried to work with an add-on  
 package sem. I have a version of 2.3.1 on MacOS X 10.4.6 with sem put
  
 under /Library/Frameworks/R.framework/Versions/2.3/Resources/library
 
 However when I typed
 
 library(sem)
 
 the following error showed up:
 
 Error in library(sem) : 'sem' is not a valid package -- installed   
 2.0.0?
 
 Why is this?
 
 Thank you,
 Gang Chen
 
 
   [[alternative HTML version deleted]]
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html


John Fox
Department of Sociology
McMaster University
Hamilton, Ontario, Canada
http://socserv.mcmaster.ca/jfox/

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


[R] Building R: use the current version! {was Running R}

2006-06-29 Thread Martin Maechler
I'm not really answering your question, but if you install from
the sources -- always a useful experience in finding out if your
computer is well equipped with software -- 
*PLEASE* use the latest aka current version of R.
Currently, that's 2.3.1 and not 2.3.0.

A very reasonable alternative is also to work with R-patched
(i.e. 'R 2.3.1 patched' at the moment), since we (aim to) ensure
that R-patched only contains simple well tested bug fixes in
addition to the respective released version.

(Contrary to R-devel which always contains the current R
 development version with all potential new features and which
 is hence also designated 'unstable'.)

Martin Maechler, 
ETH Zurich (and R-core)


 Pramod == Pramod Anugu [EMAIL PROTECTED]
 on Wed, 28 Jun 2006 15:18:10 -0500 writes:

Pramod [EMAIL PROTECTED] R-2.3.0]# ./configure

  .
  .

Pramod 1. tar -zxvf R-2.3.0.tar.gz
Pramod 2. changed the directory to the newly created directory R-2.3.0

   .
   .

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


Re: [R] re-direct to more or less

2006-06-29 Thread Dimitris Rizopoulos
maybe ?sink() or ?capture.output() could be useful, in this case.


Best,
Dimitris


Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
 http://www.student.kuleuven.be/~m0390867/dimitris.htm


- Original Message - 
From: Mike Wolfgang [EMAIL PROTECTED]
To: R-help list r-help@stat.math.ethz.ch
Sent: Thursday, June 29, 2006 4:28 AM
Subject: [R] re-direct to more or less


 Dear list,

 sometimes my function generates too much data and shows them on 
 screen, i
 cannot view first several lines until program ends and I have to 
 scroll my
 mouse up to get them. Is there any re-direction function in R to 
 pipeline
 outputs to more or less type functions?
 Thanks

 mike

 [[alternative HTML version deleted]]

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


Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm

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


[R] Help needed understanding eval,quote,expression

2006-06-29 Thread toby_marks
I am trying to build up a quoted or character expression representing a 
component in a list  in order to reference it indirectly. 
For instance, I have a list that has data I want to pull, and another list 
that has character vectors and/or lists of characters containing the names 
of the components in the first list.


It seems that the way to do this is as evaluating expressions, but I seem 
to be missing something.  The concept should be similar to the snippet 
below:


For instance:

$x = list(y=list(y1=hello,y2=world),z=list(z1=foo,z2=bar))
$y = quote(x$y$y1)
$eval(y)
[1] hello


but, I'm trying to accomplish this by building up y as a character and 
then evaluating it, and having no success. 

$y1=paste(x$y$,y1,sep=)
$y1
[1] x$y$y1


How can I evaluate y1 as I did with y previously?  or can I? 


Much Thanks !









CONFIDENTIALITY NOTICE: This electronic mail transmission (i...{{dropped}}

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


Re: [R] Question on memory allocation loop

2006-06-29 Thread Prof Brian Ripley
On Thu, 29 Jun 2006, Manoj wrote:

 Hello All,
  I am trying to work on writing the following piece of (pseudo)
 code in an optimal fashion:

 
 # Two data frames with some data

 a = data.frame(somedata)
 b = data.frame(somedata)

 for(i in 1:nrow(dt) {
  # Merge dates for a given date into a new data frame
   c = merge(a[a$dt==dt[i],),b[b$dt == dt[i],], by=c(some column));
 }

Note that only the last iteration of that loop is actually needed.

What are you really trying to do, and why are you worrying about memory? 
E.g. merge() in R-devel is a lot more efficient for some operations, 
including perhaps your example.

 


 Now, my understanding is that the data frame c in the above code is
 malloc'ed in every count of the loop.  Is that assumption correct?

No.  Here 'c' is just a symbol, and assignment (please use - in public 
code, it is easier to read) binds the symbol to the data frame returned by 
merge().  So the allocation (not 'malloc' necessarily) is going on inside 
merge(). Also, 'c' is a system object, so you are confusing people by 
using its name for your own object.

When you assign to 'c' you change the binding to a different already 
allocated object.  Eventually garbage collection will recover (to R) the 
memory allocated to objects which are no longer bound to symbols.

I am not aware of any account which describes in detail how R works at 
this level, and end users do not need to know it.  (It is also the case 
that R maintains a number of illusions and internally may not do what it 
appears to do.)


 Is the following attempt a better way of doing things?

 
 a = data.frame(somedata)
 b = data.frame(somedata)

 # Pre-allocate data frame c

 c = data.frame(for some size);

 for(i in 1:nrow(dt) {
  # Merge dates for a given date into a new data frame
   # and copy the result into c

  copy(c, merge(a[a$dt==dt[i],),b[b$dt == dt[i],], by=c(some column));

 }
 

 Now the question is, How can I copy the merged data into my
 pre-allocated data frame c ? I tried rbind/cbind but they are pretty
 fuzzy about having the right names and dimension hence it fails.

 Any help would be greatly appreciated!

 Thanks.

 Manoj

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


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

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


Re: [R] re-direct to more or less

2006-06-29 Thread Søren Højsgaard
Something like

less - function(a){
  fn - paste(tempdir(),\\dataframe.txt,sep='',collapse='')
  write.table(a, quote=F, file=fn)
  system(paste(less ,fn))
}

could perhaps help you (assuming that you have less on your computer). I agree 
that it would be very nice to have a built-in version...
Regards
Søren

 

 -Oprindelig meddelelse-
 Fra: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] På vegne af Mike Wolfgang
 Sendt: 29. juni 2006 04:29
 Til: R-help list
 Emne: [R] re-direct to more or less
 
 Dear list,
 
 sometimes my function generates too much data and shows them 
 on screen, i cannot view first several lines until program 
 ends and I have to scroll my mouse up to get them. Is there 
 any re-direction function in R to pipeline outputs to more 
 or less type functions?
 Thanks
 
 mike
 
   [[alternative HTML version deleted]]
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! 
 http://www.R-project.org/posting-guide.html


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


Re: [R] Error: evaluation nested too deeply: infinite recursion / options(expressions=)?

2006-06-29 Thread Uwe Ligges
Aarti Dahiya wrote:
 I am getting this error:- Error: evaluation nested too deeply: infinite 
 recursion / options(expressions=)? The reason is probbaly because I am 
 calling methods within methods.

Maybe at some point you get an infinite recursion because you forgot to 
unclass something?


 I read related posts.  It said the solution is to set  options(expressions = 
 1000). I wanted to know where in my code or system to set 
 options(expressions = 1000)?


Bewore you start the problematic code, but probably you really have 
infinite recursion 

Uwe Ligges


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

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


Re: [R] Help needed understanding eval,quote,expression

2006-06-29 Thread Prof Brian Ripley
You are missing eval(parse(text=)). E.g.

 x - list(y=list(y1=hello,y2=world),z=list(z1=foo,z2=bar))
(what do you mean by the $ at the start of these lines?)
 eval(parse(text=x$y$y1))
[1] hello

However, bear in mind

 fortune(parse)

If the answer is parse() you should usually rethink the question.
-- Thomas Lumley
   R-help (February 2005)

In your indicated example you could probably use substitute() as 
effectively.


On Wed, 28 Jun 2006, [EMAIL PROTECTED] wrote:

 I am trying to build up a quoted or character expression representing a
 component in a list  in order to reference it indirectly.
 For instance, I have a list that has data I want to pull, and another list
 that has character vectors and/or lists of characters containing the names
 of the components in the first list.


 It seems that the way to do this is as evaluating expressions, but I seem
 to be missing something.  The concept should be similar to the snippet
 below:


 For instance:

 $x = list(y=list(y1=hello,y2=world),z=list(z1=foo,z2=bar))
 $y = quote(x$y$y1)
 $eval(y)
 [1] hello


 but, I'm trying to accomplish this by building up y as a character and
 then evaluating it, and having no success.

 $y1=paste(x$y$,y1,sep=)
 $y1
 [1] x$y$y1


 How can I evaluate y1 as I did with y previously?  or can I?


 Much Thanks !








 
 CONFIDENTIALITY NOTICE: This electronic mail transmission (i...{{dropped}}

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


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

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


Re: [R] Problem running one of the rgl demo scripts...

2006-06-29 Thread Brian Lunergan
Duncan Murdoch wrote:
 Brian Lunergan wrote:
 Afternoon folks:

 I'm getting a program crash when I try to run demo(rgl). The following 
 error details result:

 RGUI caused a stack fault in module NVOPENGL.DLL at 017f:695280f0.
 Registers:
 EAX=0002 CS=017f EIP=695280f0 EFLGS=00010246
 EBX=0001 SS=0187 ESP=00572000 EBP=004d1208
 ECX=042f1f01 DS=0187 ESI=004d1208 FS=5d1f
 EDX=00442d84 ES=0187 EDI=042f1f3c GS=5d0e
 Bytes at CS:EIP:
 53 56 8b 5c 24 0c 57 83 bb 9c 39 00 00 02 0f 84
 Stack dump:
 69541be5 004d1208 004d1208 0001 69541bef 0001 004d1208 
 0001 69541bef 0001 004d1208 0001 69541bef 0001 
 004d1208 0001

 Setup details are:

 R version: 2.2.1
 OS: win98se
 RGL file name: rgl_0.66.zip

 It appears to be gagging on an Nvidia opengl driver file, NVIDIA 
 Compatible OpenGL ICD, version 4.12.01.0631. The video card is 
 recorded as:

 3DForce2 MX Series,NVIDIA GeForce2 MX (Ver 4.12.01.0631 ,9/20/2000)

 I also tried this with version 2.3.1 of R with the same results.

 Anyone have any thoughts or ideas on the subject? Has it occurred any 
 place else? Is there a workaround or solution, or should I perhaps 
 turf the package and forgo its abilities since it appears my system as 
 it stands may not be able to support it?
 You could try a newer build, available on my web page 
 (http://www.stats.uwo.ca/faculty/murdoch/software).  If it dies the same 
 way, you could perhaps try to diagnose what is going wrong and send a 
 patch if it's an rgl bug.  Given the age of your video driver 
 (9/20/2000), you might be able to update it and fix a bug there.

Just downloaded and installed a new video driver (file the demo originally 
reporting choking on now showing v4.14.10.8198, December 10, 2005 03:06:00) 
and things seemed to have settled down. The demo now runs through fully 
without complaint.

-- 
Brian Lunergan
Nepean, Ontario
Canada


---
avast! Antivirus: Outbound message clean.
Virus Database (VPS): 0626-2, 2006-06-28
Tested on: 2006-06-28 19:20:04
avast! is copyright (c) 2000-2006 ALWIL Software.
http://www.avast.com

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


Re: [R] Extracting R plots from MS Word

2006-06-29 Thread Johannes Ranke
Hi,

I would also like to know how to do this with MS products alone.

However, a nice tool to do this is wmf2eps (http://www.wmf2eps.de.vu/).
You can paste windows vector graphics into wmf2eps, and it first saves
it as EMF (enhanced metafile), before it creates EPS, which is what I
use it for.

Maybe your publisher will be even more happy if you supply EPS.

Best regards,

Johannes Ranke


* [EMAIL PROTECTED] [EMAIL PROTECTED] [060629 08:30]:
 Hi,
 
 I am revising a paper that I am a co-author of. The figures are plots
 generated from R but at the moment I do not have the R code that generates
 them.
 
 As this is time critical I would like to slightly abuse the list by asking
 whether anyone knows how to extract from MS Word into a stand-alone
 graphics file a plot that was pasted into Word from R (probably as a
 Windows Metafile, but possibly as a bitmap).
 
 I would be very grateful for help with this.
 
 Regards,  Murray Jorgensen
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

-- 
Dr. Johannes Ranke [EMAIL PROTECTED]
UFT Bremen, Leobenerstr. 1 +49 421 218 8971 
D-28359 Bremen http://www.uft.uni-bremen.de/chemie/ranke

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


Re: [R] re-direct to more or less

2006-06-29 Thread Peter Dalgaard
Søren Højsgaard [EMAIL PROTECTED] writes:

 Something like
 
 less - function(a){
   fn - paste(tempdir(),\\dataframe.txt,sep='',collapse='')
   write.table(a, quote=F, file=fn)
   system(paste(less ,fn))
 }
 
 could perhaps help you (assuming that you have less on your computer). I 
 agree that it would be very nice to have a built-in version...


Like page(), you mean... ?

:-)

(This goes via file.show, so Windows GUI users get a separate window,
I suppose.) 

 Regards
 Søren
 
  
 
  -Oprindelig meddelelse-
  Fra: [EMAIL PROTECTED] 
  [mailto:[EMAIL PROTECTED] På vegne af Mike Wolfgang
  Sendt: 29. juni 2006 04:29
  Til: R-help list
  Emne: [R] re-direct to more or less
  
  Dear list,
  
  sometimes my function generates too much data and shows them 
  on screen, i cannot view first several lines until program 
  ends and I have to scroll my mouse up to get them. Is there 
  any re-direction function in R to pipeline outputs to more 
  or less type functions?
  Thanks
  
  mike
  
  [[alternative HTML version deleted]]
  
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide! 
  http://www.R-project.org/posting-guide.html
 
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
 

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

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


Re: [R] re-direct to more or less

2006-06-29 Thread Søren Højsgaard
No - not like page(). Page (on windows) gives

structure(list(Sepal.Length = c(5.1, 4.9, 4.7, 4.6, 5, 5.4, 4.6, 
5, 4.4, 4.9, 5.4, 4.8, 4.8, 4.3, 5.8, 5.7, 5.4, 5.1, 5.7, 5.1, 
5.4, 5.1, 4.6, 5.1, 4.8, 5, 5, 5.2, 5.2, 4.7, 4.8, 5.4, 5.2, .

while the less() function below gives

Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1 5.1 3.5 1.4 0.2 setosa
2 4.9 3 1.4 0.2 setosa
3 4.7 3.2 1.3 0.2 setosa
4 4.6 3.1 1.5 0.2 setosa


Regards
Søren


 

 -Oprindelig meddelelse-
 Fra: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] På vegne 
 af Peter Dalgaard
 Sendt: 29. juni 2006 10:31
 Til: Søren Højsgaard
 Cc: Mike Wolfgang; R-help list
 Emne: Re: [R] re-direct to more or less
 
 Søren Højsgaard [EMAIL PROTECTED] writes:
 
  Something like
  
  less - function(a){
fn - paste(tempdir(),\\dataframe.txt,sep='',collapse='')
write.table(a, quote=F, file=fn)
system(paste(less ,fn))
  }
  
  could perhaps help you (assuming that you have less on your 
 computer). I agree that it would be very nice to have a 
 built-in version...
 
 
 Like page(), you mean... ?
 
 :-)
 
 (This goes via file.show, so Windows GUI users get a separate 
 window, I suppose.) 
 
  Regards
  Søren
  
   
  
   -Oprindelig meddelelse-
   Fra: [EMAIL PROTECTED] 
   [mailto:[EMAIL PROTECTED] På vegne af 
 Mike Wolfgang
   Sendt: 29. juni 2006 04:29
   Til: R-help list
   Emne: [R] re-direct to more or less
   
   Dear list,
   
   sometimes my function generates too much data and shows them on 
   screen, i cannot view first several lines until program 
 ends and I 
   have to scroll my mouse up to get them. Is there any re-direction 
   function in R to pipeline outputs to more
   or less type functions?
   Thanks
   
   mike
   
 [[alternative HTML version deleted]]
   
   __
   R-help@stat.math.ethz.ch mailing list 
   https://stat.ethz.ch/mailman/listinfo/r-help
   PLEASE do read the posting guide! 
   http://www.R-project.org/posting-guide.html
  
  
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide! 
  http://www.R-project.org/posting-guide.html
  
 
 -- 
O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
   c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
  (*) \(*) -- University of Copenhagen   Denmark  Ph:  
 (+45) 35327918
 ~~ - ([EMAIL PROTECTED])  FAX: 
 (+45) 35327907


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


Re: [R] Help needed understanding eval,quote,expression

2006-06-29 Thread Joerg van den Hoff
Prof Brian Ripley wrote:
 You are missing eval(parse(text=)). E.g.
 
 x - list(y=list(y1=hello,y2=world),z=list(z1=foo,z2=bar))
 (what do you mean by the $ at the start of these lines?)
 eval(parse(text=x$y$y1))
 [1] hello
 
 However, bear in mind
 
 fortune(parse)
 
 If the answer is parse() you should usually rethink the question.
 -- Thomas Lumley
R-help (February 2005)
 
 In your indicated example you could probably use substitute() as 
 effectively.
 
 
 On Wed, 28 Jun 2006, [EMAIL PROTECTED] wrote:
 
 I am trying to build up a quoted or character expression representing a
 component in a list  in order to reference it indirectly.
 For instance, I have a list that has data I want to pull, and another list
 that has character vectors and/or lists of characters containing the names
 of the components in the first list.


 It seems that the way to do this is as evaluating expressions, but I seem
 to be missing something.  The concept should be similar to the snippet
 below:


 For instance:

 $x = list(y=list(y1=hello,y2=world),z=list(z1=foo,z2=bar))
 $y = quote(x$y$y1)
 $eval(y)
 [1] hello


 but, I'm trying to accomplish this by building up y as a character and
 then evaluating it, and having no success.

 $y1=paste(x$y$,y1,sep=)
 $y1
 [1] x$y$y1


 How can I evaluate y1 as I did with y previously?  or can I?


 Much Thanks !



if I understand you correctly you can achieve your goal much easier than 
with eval, parse, substitute and the like:

x - list(y=list(y1=hello,y2=world),z=list(z1=foo,z2=bar))

s1 - 'y'
s2 - 'y1'

x[[s1]][[s2]]

i.e. using `[[' instead of `$' for list component extraction allows to 
use characters for indexing (in other words: x$y == x[['y']])

joerg

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


Re: [R] re-direct to more or less

2006-06-29 Thread Peter Dalgaard
Søren Højsgaard [EMAIL PROTECTED] writes:

 No - not like page(). Page (on windows) gives
 
 structure(list(Sepal.Length = c(5.1, 4.9, 4.7, 4.6, 5, 5.4, 4.6, 
 5, 4.4, 4.9, 5.4, 4.8, 4.8, 4.3, 5.8, 5.7, 5.4, 5.1, 5.7, 5.1, 
 5.4, 5.1, 4.6, 5.1, 4.8, 5, 5, 5.2, 5.2, 4.7, 4.8, 5.4, 5.2, .
 
 while the less() function below gives
 
 Sepal.Length Sepal.Width Petal.Length Petal.Width Species
 1 5.1 3.5 1.4 0.2 setosa
 2 4.9 3 1.4 0.2 setosa
 3 4.7 3.2 1.3 0.2 setosa
 4 4.6 3.1 1.5 0.2 setosa
 


If all else fails, read the manual...: page() has a method= argument.
(It might not be a bad idea to switch the default, though).

  -Oprindelig meddelelse-
  Fra: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] På vegne 
  af Peter Dalgaard
  Sendt: 29. juni 2006 10:31
  Til: Søren Højsgaard
  Cc: Mike Wolfgang; R-help list
  Emne: Re: [R] re-direct to more or less
  
  Søren Højsgaard [EMAIL PROTECTED] writes:
  
   Something like
   
   less - function(a){
 fn - paste(tempdir(),\\dataframe.txt,sep='',collapse='')
 write.table(a, quote=F, file=fn)
 system(paste(less ,fn))
   }
   
   could perhaps help you (assuming that you have less on your 
  computer). I agree that it would be very nice to have a 
  built-in version...
  
  
  Like page(), you mean... ?
  
  :-)
  
  (This goes via file.show, so Windows GUI users get a separate 
  window, I suppose.) 
  
   Regards
   Søren
   

   
-Oprindelig meddelelse-
Fra: [EMAIL PROTECTED] 
[mailto:[EMAIL PROTECTED] På vegne af 
  Mike Wolfgang
Sendt: 29. juni 2006 04:29
Til: R-help list
Emne: [R] re-direct to more or less

Dear list,

sometimes my function generates too much data and shows them on 
screen, i cannot view first several lines until program 
  ends and I 
have to scroll my mouse up to get them. Is there any re-direction 
function in R to pipeline outputs to more
or less type functions?
Thanks

mike

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list 
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! 
http://www.R-project.org/posting-guide.html
   
   
   __
   R-help@stat.math.ethz.ch mailing list
   https://stat.ethz.ch/mailman/listinfo/r-help
   PLEASE do read the posting guide! 
   http://www.R-project.org/posting-guide.html
   
  
  -- 
 O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
   (*) \(*) -- University of Copenhagen   Denmark  Ph:  
  (+45) 35327918
  ~~ - ([EMAIL PROTECTED])  FAX: 
  (+45) 35327907
  
 

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

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


Re: [R] Help needed understanding eval,quote,expression

2006-06-29 Thread Prof Brian Ripley
On Thu, 29 Jun 2006, Joerg van den Hoff wrote:

 Prof Brian Ripley wrote:
 You are missing eval(parse(text=)). E.g.
 
 x - list(y=list(y1=hello,y2=world),z=list(z1=foo,z2=bar))
 (what do you mean by the $ at the start of these lines?)
 eval(parse(text=x$y$y1))
 [1] hello
 
 However, bear in mind
 
 fortune(parse)
 
 If the answer is parse() you should usually rethink the question.
 -- Thomas Lumley
R-help (February 2005)
 
 In your indicated example you could probably use substitute() as 
 effectively.
 
 
 On Wed, 28 Jun 2006, [EMAIL PROTECTED] wrote:
 
 I am trying to build up a quoted or character expression representing a
 component in a list  in order to reference it indirectly.
 For instance, I have a list that has data I want to pull, and another list
 that has character vectors and/or lists of characters containing the names
 of the components in the first list.
 
 It seems that the way to do this is as evaluating expressions, but I seem
 to be missing something.  The concept should be similar to the snippet
 below:
 
 
 For instance:
 
 $x = list(y=list(y1=hello,y2=world),z=list(z1=foo,z2=bar))
 $y = quote(x$y$y1)
 $eval(y)
 [1] hello
 
 
 but, I'm trying to accomplish this by building up y as a character and
 then evaluating it, and having no success.
 
 $y1=paste(x$y$,y1,sep=)
 $y1
 [1] x$y$y1
 
 
 How can I evaluate y1 as I did with y previously?  or can I?
 
 
 Much Thanks !
 
 

 if I understand you correctly you can achieve your goal much easier than with 
 eval, parse, substitute and the like:

 x - list(y=list(y1=hello,y2=world),z=list(z1=foo,z2=bar))

 s1 - 'y'
 s2 - 'y1'

 x[[s1]][[s2]]

 i.e. using `[[' instead of `$' for list component extraction allows to use 
 characters for indexing (in other words: x$y == x[['y']])


But what he actually asked for was

 I am trying to build up a quoted or character expression representing a
 component in a list  in order to reference it indirectly.

You just typed in x[[s1]][[s2]], not 'built [it] up'.  Suppose the 
specification had been

r - x
s - c(y, y1)

and s was of variable length?  Then you need to construct a call similar 
to x[[y]][[y1]] from r and s.

[There was another reason for sticking with $ rather than using [[: the 
latter makes unnecessary copies in released versions of R.]


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

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


Re: [R] re-direct to more or less

2006-06-29 Thread Prof Brian Ripley

Please read the help before replying ...


page(iris, method=print)


does exactly what I understand was asked for.

On Thu, 29 Jun 2006, Søren Højsgaard wrote:


No - not like page(). Page (on windows) gives

structure(list(Sepal.Length = c(5.1, 4.9, 4.7, 4.6, 5, 5.4, 4.6,
5, 4.4, 4.9, 5.4, 4.8, 4.8, 4.3, 5.8, 5.7, 5.4, 5.1, 5.7, 5.1,
5.4, 5.1, 4.6, 5.1, 4.8, 5, 5, 5.2, 5.2, 4.7, 4.8, 5.4, 5.2, .

while the less() function below gives

Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1 5.1 3.5 1.4 0.2 setosa
2 4.9 3 1.4 0.2 setosa
3 4.7 3.2 1.3 0.2 setosa
4 4.6 3.1 1.5 0.2 setosa


Regards
Søren





-Oprindelig meddelelse-
Fra: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] På vegne
af Peter Dalgaard
Sendt: 29. juni 2006 10:31
Til: Søren Højsgaard
Cc: Mike Wolfgang; R-help list
Emne: Re: [R] re-direct to more or less

Søren Højsgaard [EMAIL PROTECTED] writes:


Something like

less - function(a){
  fn - paste(tempdir(),\\dataframe.txt,sep='',collapse='')
  write.table(a, quote=F, file=fn)
  system(paste(less ,fn))
}

could perhaps help you (assuming that you have less on your

computer). I agree that it would be very nice to have a
built-in version...


Like page(), you mean... ?

:-)

(This goes via file.show, so Windows GUI users get a separate
window, I suppose.)


Regards
Søren




-Oprindelig meddelelse-
Fra: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] På vegne af

Mike Wolfgang

Sendt: 29. juni 2006 04:29
Til: R-help list
Emne: [R] re-direct to more or less

Dear list,

sometimes my function generates too much data and shows them on
screen, i cannot view first several lines until program

ends and I

have to scroll my mouse up to get them. Is there any re-direction
function in R to pipeline outputs to more
or less type functions?
Thanks

mike

[[alternative HTML version deleted]]

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



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



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



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



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

Re: [R] Running R [Broadcast]

2006-06-29 Thread Liaw, Andy
You have two choices (AFAIK): 
 
1.  Tell configure exactly where to find the readline header files (by
something like --with-readline=/where/the/files/are, check configure
--help).
 
2.  Compile R without readline; i.e., configure --with-readline=no.
 
Andy

  _  

From: [EMAIL PROTECTED] on behalf of Pramod Anugu
Sent: Wed 6/28/2006 4:18 PM
To: r-help@stat.math.ethz.ch
Subject: Re: [R] Running R [Broadcast]



[EMAIL PROTECTED] R-2.3.0]# ./configure 
checking build system type... x86_64-unknown-linux-gnu 
checking host system type... x86_64-unknown-linux-gnu 
loading site script './config.site' 
loading build specific script './config.site' 
checking for pwd... /bin/pwd 
checking whether builddir is srcdir... yes 
checking for working aclocal... found 
checking for working autoconf... found 
checking for working automake... found 
checking for working autoheader... found 
checking for working makeinfo... found 
checking for gawk... gawk 
checking for egrep... grep -E 
checking whether ln -s works... yes 
checking for ranlib... ranlib 
checking for bison... no 
checking for byacc... no 
checking for ar... ar 
checking for a BSD-compatible install... /usr/bin/install -c 
checking for sed... /bin/sed 
checking for less... /usr/bin/less 
checking for perl... /usr/bin/perl 
checking whether perl version is at least 5.004... yes 
checking for dvips... /usr/bin/dvips 
checking for tex... /usr/bin/tex 
checking for latex... /usr/bin/latex 
checking for makeindex... /usr/bin/makeindex 
checking for pdftex... /usr/bin/pdftex 
checking for pdflatex... /usr/bin/pdflatex 
checking for makeinfo... /usr/bin/makeinfo 
checking for unzip... /usr/bin/unzip 
checking for zip... /usr/bin/zip 
checking for gzip... /bin/gzip 
checking for firefox... /usr/bin/firefox 
using default browser ... /usr/bin/firefox 
checking for acroread... no 
checking for acroread4... no 
checking for xpdf... no 
checking for gv... no 
checking for gnome-gv... no 
checking for ggv... /usr/bin/ggv 
checking for gcc... gcc 
checking for C compiler default output file name... a.out 
checking whether the C compiler works... yes 
checking whether we are cross compiling... no 
checking for suffix of executables... 
checking for suffix of object files... o 
checking whether we are using the GNU C compiler... yes 
checking whether gcc accepts -g... yes 
checking for gcc option to accept ANSI C... none needed 
checking how to run the C preprocessor... gcc -E 
checking whether gcc needs -traditional... no 
checking how to run the C preprocessor... gcc -E 
checking for g77... g77 
checking whether we are using the GNU Fortran 77 compiler... yes 
checking whether g77 accepts -g... yes 
checking for g++... g++ 
checking whether we are using the GNU C++ compiler... yes 
checking whether g++ accepts -g... yes 
checking how to run the C++ preprocessor... g++ -E 
checking whether __attribute__((visibility())) is supported... yes 
checking whether gcc accepts -fvisibility... yes 
checking whether g77 accepts -fvisibility... yes 
checking for a sed that does not truncate output... /bin/sed 
checking for ld used by gcc... /usr/bin/ld 
checking if the linker (/usr/bin/ld) is GNU ld... yes 
checking for /usr/bin/ld option to reload object files... -r 
checking for BSD-compatible nm... /usr/bin/nm -B 
checking how to recognise dependent libraries... pass_all 
checking for ANSI C header files... yes 
checking for sys/types.h... yes 
checking for sys/stat.h... yes 
checking for stdlib.h... yes 
checking for string.h... yes 
checking for memory.h... yes 
checking for strings.h... yes 
checking for inttypes.h... yes 
checking for stdint.h... yes 
checking for unistd.h... yes 
checking dlfcn.h usability... yes 
checking dlfcn.h presence... yes 
checking for dlfcn.h... yes 
checking the maximum length of command line arguments... 32768 
checking command to parse /usr/bin/nm -B output from gcc object... ok 
checking for objdir... .libs 
checking for ranlib... (cached) ranlib 
checking for strip... strip 
checking if gcc static flag  works... yes 
checking if gcc supports -fno-rtti -fno-exceptions... no 
checking for gcc option to produce PIC... -fPIC 
checking if gcc PIC flag -fPIC works... yes 
checking if gcc supports -c -o file.o... yes 
checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared 
libraries... yes 
checking whether -lc should be explicitly linked in... no 
checking dynamic linker characteristics... GNU/Linux ld.so 
checking how to hardcode library paths into programs... immediate 
checking whether stripping libraries is possible... yes 
checking if libtool supports shared libraries... yes 
checking whether to build shared libraries... yes 
checking whether to build static libraries... no 
configure: creating libtool 
appending configuration tag CXX to libtool 
checking for ld used by g++... /usr/bin/ld -m elf_x86_64 
checking if the linker (/usr/bin/ld -m elf_x86_64) is GNU ld... yes 
checking whether the g++ linker (/usr/bin/ld -m 

[R] kmeans clustering

2006-06-29 Thread richard mendes
Hello R list members,

I'm a bio informatics student from the Leiden university
(netherlands). We were asked to make a program with different
clustering methods. The problem we are experiencing is the following.

we have a matrix with data like the following

 research1research2research3enz
sample1  0.5 0.2  0.4

sample2  0.4 0.4  0.3

sample3  0.7 0.2  0.8

enz


now if we use kmeans(matrix,3,20) the clustering method will cluster
only on rows by using the columns values as multiple variables. The
output from this syntax is for example

sample1 = 1
sample2 = 2
sample3 = 3
enz

Is there a method that will use the rows and columns as seperate
values so that every variable in the matrix will be assigned to a
cluster instead of a row.

the output then could be interperted as a heatmap.

thank you in advance for your time,

Richard Mendes

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


Re: [R] kmeans clustering

2006-06-29 Thread Andrej Kastrin
richard mendes wrote:
 Hello R list members,

 I'm a bio informatics student from the Leiden university
 (netherlands). We were asked to make a program with different
 clustering methods. The problem we are experiencing is the following.

 we have a matrix with data like the following

  research1research2research3enz
 sample1  0.5 0.2  0.4

 sample2  0.4 0.4  0.3

 sample3  0.7 0.2  0.8

 enz


 now if we use kmeans(matrix,3,20) the clustering method will cluster
 only on rows by using the columns values as multiple variables. The
 output from this syntax is for example

 sample1 = 1
 sample2 = 2
 sample3 = 3
 enz

 Is there a method that will use the rows and columns as seperate
 values so that every variable in the matrix will be assigned to a
 cluster instead of a row.

 the output then could be interperted as a heatmap.

 thank you in advance for your time,

 Richard Mendes

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

   
You mean something like:?
kmeans(dataMatrix,5) ## clustering by rows
kmeans(t(dataMatrix),5) ## clustering by attribute

HTH, Andrej

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


Re: [R] Very slow read.table on Linux, compared to Win2000 [Broad cast]

2006-06-29 Thread Patrick Connolly
On Wed, 28-Jun-2006 at 04:43PM -0700, Alberto Murta wrote:

| I have a pentium 4 pc with 256 MB of RAM, so I made a text file, tab 
| separated, with column names and 15000 x 483 integers:
| 
|  system(ls -l teste.txt)
| -rw-r--r--  1 amurta  amurta  16998702 Jun 28 16:08 teste.txt
| 
| the time it took to import it was around 15 secs:
| 
|  system.time(teste - read.delim(teste.txt))
| [1] 15.349  0.244 16.597  0.000  0.000
| 
| so I think lack of RAM must not be the main problem.
| Cheers
| 
| Alberto
| 
| 
|  version
|_
| platform   i386-unknown-freebsd6.1
| arch   i386
| os freebsd6.1
| system i386, freebsd6.1
| status
| major  2
| minor  3.1
| year   2006
| month  06
| day01
| svn rev38247
| language   R
| version.string Version 2.3.1 (2006-06-01)

Doesn't tell us about your window manager.  I'd suspect you're using a
light one.



-- 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
   ___Patrick Connolly   
 {~._.~} Great minds discuss ideas
 _( Y )_Middle minds discuss events 
(:_~*~_:)Small minds discuss people  
 (_)-(_)   . Anon
  
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

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


[R] zero.print in print.table after adding margins

2006-06-29 Thread BXC (Bendix Carstensen)
The function addmargins() adds margins to a table, but returns a matrix.
But even after converted to a table the print.zero=. option of
print.table() does not work:

 x - sample( 1:7, 20, replace=T )
 y - sample( 1:7, 20, replace=T )
 tt - table( x, y )
 tx - as.table( addmargins( table( x, y ) ) )
 print( tt, zero.print=. )
   y
x   1 2 3 4 5 6 7
  1 1 2 2 . . 1 .
  2 1 . . 1 . . .
  3 . . . . . . 2
  4 1 . . . . 1 .
  5 1 . 1 . . 1 .
  6 . 1 . 1 . . .
  7 . . 1 . 1 1 .
 print( tx, zero.print=. )
 y
x  1  2  3  4  5  6  7 Sum
  11  2  2  0  0  1  0   6
  21  0  0  1  0  0  0   2
  30  0  0  0  0  0  2   2
  41  0  0  0  0  1  0   2
  51  0  1  0  0  1  0   3
  60  1  0  1  0  0  0   2
  70  0  1  0  1  1  0   3
  Sum  4  3  4  2  1  4  2  20

Is this a facility of print.table?
The attributes() of tt and tx have identical stucture. 

Best,
Bendix
--
Bendix Carstensen
Senior Statistician
Steno Diabetes Center
Niels Steensens Vej 2
DK-2820 Gentofte
Denmark
tel: +45 44 43 87 38
mob: +45 30 75 87 38
fax: +45 44 43 07 06
[EMAIL PROTECTED]
www.biostat.ku.dk/~bxc

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


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

2006-06-29 Thread Paul Murrell
Hi


Kevin Wright wrote:
 My setup: Windows 2000, R 2.3.1
 
 When I start a brand new session of R and paste the code below into R,
 the graphic device shows Some text in the lower left corner.  If I
 paste the code into the command window again, then Some text does
 not appear in the lower left corner.  Why is this?
 
 require(grid)
 par(mfrow=c(1,2))
 plot(1:10)
 plot(-10:1)
 par(mfrow=c(1,1))
 pushViewport(viewport(.04, .04, width=stringWidth(Some text),
 height=unit(2,lines),
   name=pagenum, gp=gpar(fontsize=10)))
 grid.text(Some text, gp=gpar(col=gray30),
   just=c(left,bottom))
 popViewport()


Good question! :)

Short answer:
Traditional and grid graphics are fighting each other for control of the
clipping region.

Simple fix/workaround:
Explicitly set the clipping region for the grid output, like this ...

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

Long answer:
The first time you run the code, the pushViewport() call is the first
grid operation on the graphics device, so some initial grid set up
occurs, *including setting the clipping region to the whole device*.
The second time you run the code, the pushViewport() call just inherits
the current clipping region (which is the one set by the last
traditional plot) so the text gets clipped.  You can see this effect,
with the following code (the text does not even appear the first time
because the grid initialisation occurs before the traditional plots) ...

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

... so really the problem is that the text should never appear.

Interestingly, if you run your original code (text is drawn), then run
it again (text is not drawn), then ONLY run the grid part (push, text,
pop) the text DOES get drawn!  This happens because the popViewport()
restores the clipping region of the previous grid viewport (which is the
whole device).

I need to think a bit more about whether this behaviour can be fixed,
whether it should be fixed, or whether the current user beware warning
about mixing traditional and grid graphics is sufficient.

Paul
-- 
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
[EMAIL PROTECTED]
http://www.stat.auckland.ac.nz/~paul/

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


Re: [R] Running R [Broadcast]

2006-06-29 Thread Peter Dalgaard
Liaw, Andy [EMAIL PROTECTED] writes:

 You have two choices (AFAIK): 
  
 1.  Tell configure exactly where to find the readline header files (by
 something like --with-readline=/where/the/files/are, check configure
 --help).
  
 2.  Compile R without readline; i.e., configure --with-readline=no.
  
 Andy


But first check sequencing - I'm pretty sure that configure can find
header files on RedHat if they are there. 

He's not too good at interpreting his output:

 --One suggestion was to install readline-devel. But according to the below I
 
 already have readline-devel. 
 
 # find . -iname readline-devel\* 
  find -iname readline-devel\* 
 ./os/4.1/x86_64/RedHat/RPMS/readline-devel-4.3-13.x86_64.rpm 
 
 #rpm -ivh readline*.rpm 
 Preparing...### 
 [100%] 
 package readline-4.3-13 is already installed 

and as far as I can see, this means that readline-devel got installed
and readline (NOT -devel) was there already. So readline-devel is
there now, but wasn't there before. Now did he rerun configure? If so,
did it fail with a different message?



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

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


Re: [R] zero.print in print.table after adding margins

2006-06-29 Thread Peter Dalgaard
BXC (Bendix Carstensen) [EMAIL PROTECTED] writes:

 The function addmargins() adds margins to a table, but returns a matrix.
 But even after converted to a table the print.zero=. option of
 print.table() does not work:
 
  x - sample( 1:7, 20, replace=T )
  y - sample( 1:7, 20, replace=T )
  tt - table( x, y )
  tx - as.table( addmargins( table( x, y ) ) )
  print( tt, zero.print=. )
y
 x   1 2 3 4 5 6 7
   1 1 2 2 . . 1 .
   2 1 . . 1 . . .
   3 . . . . . . 2
   4 1 . . . . 1 .
   5 1 . 1 . . 1 .
   6 . 1 . 1 . . .
   7 . . 1 . 1 1 .
  print( tx, zero.print=. )
  y
 x  1  2  3  4  5  6  7 Sum
   11  2  2  0  0  1  0   6
   21  0  0  1  0  0  0   2
   30  0  0  0  0  0  2   2
   41  0  0  0  0  1  0   2
   51  0  1  0  0  1  0   3
   60  1  0  1  0  0  0   2
   70  0  1  0  1  1  0   3
   Sum  4  3  4  2  1  4  2  20
 
 Is this a facility of print.table?
 The attributes() of tt and tx have identical stucture. 

It appears to be intentional.

print.table has

if (is.integer(x)  zero.print != 0  any(i0 - !ina 
x == 0))
xx[i0] - sub(0, zero.print, xx[i0])

and of course,

 storage.mode(tx)
[1] double
 storage.mode(tt)
[1] integer

The reason could be that it is not entirely clear what to expect for
values that are zero up to round-off.

storage.mode(tx) - integer fixes things up.

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

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


[R] using rbinom in C code gives me erroneous results... random variable is not random (always zero)...

2006-06-29 Thread Vumani Dlamini
Dear Listers,
I am trying to use rbinom in my C code, but i always get zeros as output no 
matter the probability. Am not sure what I am doing wrong because the function 
has worked before. Attached in an example. Noticed that rbinom expects 'n' to 
be REAL.
Regards, Vumani
 
R  2.3.1 (2006-06-01)
Windows XP
Gcc
/* Called this file binom.c and then ran rcmd shlib on it */#include 
R.h#include Rmath.h#include math.h#include Rdefines.hSEXP binomial(SEXP 
r, SEXP n, SEXP p){ int i; SEXP out; PROTECT(out = 
allocVector(REALSXP,INTEGER(r)[0]));  for(i = 0; i  INTEGER(r)[0]; ++i){  
REAL(out)[i] = rbinom(REAL(n)[0],REAL(p)[0]); } Rprintf(%d   %f   
%f\n,INTEGER(r)[0],REAL(n)[0],REAL(p)[0]); UNPROTECT(1); return(out);}
 
### used theses line in R
dyn.load(binom.dll).Call(binomial,as.integer(10),as.double(1),as.double(0.4))dyn.unload(binom.dll)
_
Try Live.com - your fast, personalized homepage with all the things you care 
about in one place.
http://www.live.com/getstarted
[[alternative HTML version deleted]]

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


Re: [R] Extracting R plots from MS Word

2006-06-29 Thread Gabor Grothendieck
Click the graphic, press ctrl-C to copy it to the clipboard and then
using ctrl-V paste it into mspaint or Xnview (free, find it via google) or other
graphics program and then save it from there.   Which program will
work will depend on the format of the image.

Another possibility is to save the Word file in HTML format.  In
Word, choose File | SaveAs and choose the Save As Type to be Web Page.
That will create an HTML file plus it will create a folder with
one file per image.

On 6/29/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 Hi,

 I am revising a paper that I am a co-author of. The figures are plots
 generated from R but at the moment I do not have the R code that generates
 them.

 As this is time critical I would like to slightly abuse the list by asking
 whether anyone knows how to extract from MS Word into a stand-alone
 graphics file a plot that was pasted into Word from R (probably as a
 Windows Metafile, but possibly as a bitmap).

 I would be very grateful for help with this.

 Regards,  Murray Jorgensen

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


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


Re: [R] Very slow read.table on Linux, compared to Win2000 [Broad cast]

2006-06-29 Thread Alberto Murta
On Wednesday 28 June 2006 15:45, Patrick Connolly wrote:
 On Wed, 28-Jun-2006 at 04:43PM -0700, Alberto Murta wrote:
 | I have a pentium 4 pc with 256 MB of RAM, so I made a text file, tab
 |
 | separated, with column names and 15000 x 483 integers:
 |  system(ls -l teste.txt)
 |
 | -rw-r--r--  1 amurta  amurta  16998702 Jun 28 16:08 teste.txt
 |
 | the time it took to import it was around 15 secs:
 |  system.time(teste - read.delim(teste.txt))
 |
 | [1] 15.349  0.244 16.597  0.000  0.000
 |
 | so I think lack of RAM must not be the main problem.
 | Cheers
 |
 | Alberto
 |
 |  version
 |
 |_
 | platform   i386-unknown-freebsd6.1
 | arch   i386
 | os freebsd6.1
 | system i386, freebsd6.1
 | status
 | major  2
 | minor  3.1
 | year   2006
 | month  06
 | day01
 | svn rev38247
 | language   R
 | version.string Version 2.3.1 (2006-06-01)

 Doesn't tell us about your window manager.  I'd suspect you're using a
 light one.

I'm using KDE 3.5.2 (a not so light one) and running R in emacs.

-- 
  Alberto G. Murta
IPIMAR - Institute of Fisheries and Marine Research 
Avenida de Brasilia; 1449-006 Lisboa; Portugal
Tel: +351 213027120; Fax: +351 213015948

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


Re: [R] re-direct to more or less

2006-06-29 Thread Gabor Grothendieck
The first few lines or last few lines of an object can often be viewed
like this:

head(iris)
tail(iris)



On 6/28/06, Mike Wolfgang [EMAIL PROTECTED] wrote:
 Dear list,

 sometimes my function generates too much data and shows them on screen, i
 cannot view first several lines until program ends and I have to scroll my
 mouse up to get them. Is there any re-direction function in R to pipeline
 outputs to more or less type functions?
 Thanks

 mike

[[alternative HTML version deleted]]

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


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


Re: [R] Extracting R plots from MS Word

2006-06-29 Thread Jonathan Baron
Another way to do this is with OpenOffice (OO).  Read the Word file
into OO Writer.  Cut the figure.  Open OO Draw.  Click Paste, and 
the figure appears in Draw.  Save it as EPS, or whatever you
like.  This works for both EMF and WMF.

 * [EMAIL PROTECTED] [EMAIL PROTECTED] [060629 08:30]:
  As this is time critical I would like to slightly abuse the list by asking
  whether anyone knows how to extract from MS Word into a stand-alone
  graphics file a plot that was pasted into Word from R (probably as a
  Windows Metafile, but possibly as a bitmap).

-- 
Jonathan Baron, Professor of Psychology, University of Pennsylvania
Home page: http://www.sas.upenn.edu/~baron
Editor: Judgment and Decision Making (http://journal.sjdm.org)

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


Re: [R] using rbinom in C code gives me erroneous results... random variable is not random (always zero)...

2006-06-29 Thread Prof Brian Ripley
Your text has lost almost all the carriage returns: please do as we ask 
and not send HTML code.

You appear not to be initializing the random seed in your code: the manual 
says:

   The C code behind @R{}'s @[EMAIL PROTECTED] functions can be accessed by
   including the header file @file{Rmath.h}; @xref{Distribution
   functions}.  Those calls generate a single variate and should also be
   enclosed in calls to @code{GetRNGstate} and @code{PutRNGstate}.

Why have you not done so?

On Thu, 29 Jun 2006, Vumani Dlamini wrote:

 Dear Listers,
 I am trying to use rbinom in my C code, but i always get zeros as output no 
 matter the probability. Am not sure what I am doing wrong because the 
 function has worked before. Attached in an example. Noticed that rbinom 
 expects 'n' to be REAL.
 Regards, Vumani

 R  2.3.1 (2006-06-01)
 Windows XP
 Gcc
 /* Called this file binom.c and then ran rcmd shlib on it */#include 
 R.h#include Rmath.h#include math.h#include Rdefines.hSEXP 
 binomial(SEXP r, SEXP n, SEXP p){ int i; SEXP out; PROTECT(out = 
 allocVector(REALSXP,INTEGER(r)[0]));  for(i = 0; i  INTEGER(r)[0]; ++i){  
 REAL(out)[i] = rbinom(REAL(n)[0],REAL(p)[0]); } Rprintf(%d   %f   
 %f\n,INTEGER(r)[0],REAL(n)[0],REAL(p)[0]); UNPROTECT(1); return(out);}

 ### used theses line in R
 dyn.load(binom.dll).Call(binomial,as.integer(10),as.double(1),as.double(0.4))dyn.unload(binom.dll)
 _
 Try Live.com - your fast, personalized homepage with all the things you care 
 about in one place.
 http://www.live.com/getstarted
   [[alternative HTML version deleted]]

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


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

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


[R] Package Spatialkernel Annocement

2006-06-29 Thread Pingping Zheng
Hi,

A new R package spatialkernel has been accepted by CRAN. Spatialkernel
focuses on implementation of kernel regression methods proposed in
Diggle P.J. et al (2005), J. R. Stat. Soc. C, 54, 3, 645-658
and kernel density estimation of inhomogeneous Poisson point process
with edge-correction proposed by
M. Berman and P.J. Diggle (1989), J. R. Stat. Soc, B, 51, 81–92,
for an arbitrary polygonal area.

The package source and Windows binary are available at
http://www.maths.lancs.ac.uk/~zhengp1/spatialkernel/
Examples in spatialkernel-package shows a quick run of some basic
functionality.

Sorry for the wrong linked URL address at CRAN archives.

Best wishes


-- 
Dr Pingping Zheng
Department of Mathematics and Statistics
Fylde College
Lancaster University
Lancaster LA1 4YF
UK

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


[R] numerical integration problem

2006-06-29 Thread przeszczepan
Hi,

I have got problems integrating the following function using integrate: 

lambdat-function(t){
tempT-T[k,][!is.na(T[k,])]#available values from k-th row of matrix T
tempJ-J[k,][!is.na(J[k,])]

hg-length(tempT[tempT=t  tempJ==0])#counts observations satisfing the 
conditions
ag-length(tempT[tempT=t  tempJ==1])

lambdaXY[hg+1,ag+1]#takes  values from a 10x10 matrix
}

I keep receiving this message:

1: longer object length
is not a multiple of shorter object length in: tempT = t 
2: longer object length
is not a multiple of shorter object length in: tempT = t  tempJ == 0 

What I suspect is that the integrate function submits the whole vector of 
points at which the integral is to be evaluated at once. For my function to be 
integrated it would rather have to be evaluated at each point after another in 
a loop of some kind.

Can you think of a way to solve this problem without me having to write the 
integrating procedure from scratch (I have no idea about FORTRAN and this is 
what the integrate description refers to)?

Thank you.

Kind Regards,
Lukasz Szczepanski
Student

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


Re: [R] numerical integration problem

2006-06-29 Thread Sundar Dorai-Raj


przeszczepan wrote:
 Hi,
 
 I have got problems integrating the following function using integrate: 
 
 lambdat-function(t){
 tempT-T[k,][!is.na(T[k,])]#available values from k-th row of matrix T
 tempJ-J[k,][!is.na(J[k,])]
 
 hg-length(tempT[tempT=t  tempJ==0])#counts observations satisfing the 
 conditions
 ag-length(tempT[tempT=t  tempJ==1])
 
 lambdaXY[hg+1,ag+1]#takes  values from a 10x10 matrix
 }
 
 I keep receiving this message:
 
 1: longer object length
 is not a multiple of shorter object length in: tempT = t 
 2: longer object length
 is not a multiple of shorter object length in: tempT = t  tempJ == 
 0 
 
 What I suspect is that the integrate function submits the whole vector of 
 points at which the integral is to be evaluated at once. For my function to 
 be integrated it would rather have to be evaluated at each point after 
 another in a loop of some kind.
 

You suspect correctly. Best to read ?integrate too.

 Can you think of a way to solve this problem without me having to write the 
 integrating procedure from scratch (I have no idea about FORTRAN and this is 
 what the integrate description refers to)?
 

Just put a for-loop in your function to iterate over t.

   n - length(t)
   hg - ag - vector(numeric, n)
   for(i in seq(n)) {
 hg[i] - length(tempT[tempT = t[i]  tempJ == 0])
 ag[i] - length(tempT[tempT = t[i]  tempJ == 1])
   }

I doubt this will work because integrate is expecting a vector of 
n=length(t) from lambdat. The last line of the function returns a nxn 
matrix. Please submit data to run the function plus your call to 
integrate in any subsequent postings.

HTH,

--sundar

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

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


Re: [R] numerical integration problem

2006-06-29 Thread Duncan Murdoch
On 6/29/2006 7:38 AM, Sundar Dorai-Raj wrote:
 
 przeszczepan wrote:
 Hi,
 
 I have got problems integrating the following function using integrate: 
 
 lambdat-function(t){
 tempT-T[k,][!is.na(T[k,])]#available values from k-th row of matrix T
 tempJ-J[k,][!is.na(J[k,])]
 
 hg-length(tempT[tempT=t  tempJ==0])#counts observations satisfing the 
 conditions
 ag-length(tempT[tempT=t  tempJ==1])
 
 lambdaXY[hg+1,ag+1]#takes  values from a 10x10 matrix
 }
 
 I keep receiving this message:
 
 1: longer object length
 is not a multiple of shorter object length in: tempT = t 
 2: longer object length
 is not a multiple of shorter object length in: tempT = t  tempJ == 
 0 
 
 What I suspect is that the integrate function submits the whole vector of 
 points at which the integral is to be evaluated at once. For my function to 
 be integrated it would rather have to be evaluated at each point after 
 another in a loop of some kind.
 
 
 You suspect correctly. Best to read ?integrate too.
 
 Can you think of a way to solve this problem without me having to write the 
 integrating procedure from scratch (I have no idea about FORTRAN and this is 
 what the integrate description refers to)?
 
 
 Just put a for-loop in your function to iterate over t.

Or use Vectorize().

vlambdat - Vectorize(lambdat)

should give a function that can be passed to integrate(), assuming that 
lambdat works when given a length 1 vector as input.

Duncan Murdoch


 
n - length(t)
hg - ag - vector(numeric, n)
for(i in seq(n)) {
  hg[i] - length(tempT[tempT = t[i]  tempJ == 0])
  ag[i] - length(tempT[tempT = t[i]  tempJ == 1])
}
 
 I doubt this will work because integrate is expecting a vector of 
 n=length(t) from lambdat. The last line of the function returns a nxn 
 matrix. Please submit data to run the function plus your call to 
 integrate in any subsequent postings.
 
 HTH,
 
 --sundar
 
 Thank you.
 
 Kind Regards,
 Lukasz Szczepanski
 Student
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

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


Re: [R] Running R

2006-06-29 Thread Pramod Anugu
Thank you Andy for your suggestion. I used the  method 2 and was able to go
upto Step 8. But When I type R

# R
Fatal error: unable to open the base package
 
1.  Tell configure exactly where to find the readline header files (by
something like --with-readline=/where/the/files/are, check configure
--help).
 
2.  Compile R without readline; i.e., configure --with-readline=no.
 
Andy



   1. gunzip  R-patched.tar.gz
   2. tar -xvf R-patched.tar
   3. changed the directory to the newly created directory R-patched
   4. Typed ./configure 
   5. Typed make 
   6. Make check 
   7. make check-all 
   8. Typed make install 
   *9. Typed R

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


[R] specify y axis values

2006-06-29 Thread Marc Bernard
Dear All,
   
  I am looking how to specify the values on the y axis and x axis for a curve 
function.
  example:
   
  curve(2*x  + 3, 0,10) gives me  a range of x axis in (0,2,4,6,8,10) amd for 
yaxis (5,10,15,20). How to do in order to have the x axis in 
(0,1,2,3,4,5,6,7,8,9,10) and y axis in (5,6,7,8,.., 10).
   
   
  Thanks a lot,
   
  Bernard
   


-

[[alternative HTML version deleted]]

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


[R] Problems using na.include

2006-06-29 Thread Greg Distiller
Hi
I am having problems using na.action=na.include in a nlme call. Basically I 
am trying to run a particular model without including any covariates but my 
dataset does include some covariates (factors) with missing values. My 
understanding from the Pinheiro and Bates book is that one would use 
na.action=na.include in order to treat the missing values as another factor 
level and then one can also use naPattern to specify which rows must be 
excluded from the calculation of the objective function.

I have tried this but keep getting error messages about being unable to find 
the object or the function na.include. I have also tried to replicate the 
particular Phenobarbital example verbatim from the book but am getting the 
same error message. Could it be that my version of the nlme package is 
outdated? I also cannot find any help on na.include...

Thanks

Greg

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


[R] boxplot of subset of factors, in an order of my choice

2006-06-29 Thread Sumitrajit Dhar
Hi Folks,

Say I am working with the following data set:
testResults:
studtestscore
1   1   fTest   43
2   1   rTest   39
3   1   gTest   43
4   2   fTest   23
5   2   rTest   33
6   2   gTest   41
.
.
.
N   n   gTest   47

I would like to generate a boxplot of rTest only. Here is what I have  
done after reading the data in and attaching the object.

test - factor(test)

Now when I try

boxplot(score ~ test, subset = test==rTest)

1. I still see the tick marks for the other factors on the x-axis  
although no data are plotted. Can I eliminate these extra markers  
(and the space for these faactors) and just have the tick marker and  
the label for rTest?

2. I would also like to be able to rearrange the tests as they appear  
from left to right on the graph. I read the hints and help about  
reorder.factor but it does not seem to be the solution in this case.  
I am wanting to re-order the boxes without any logic (statistical  
anyways). Can this be done?

Thanks in advance,
Sumit

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


Re: [R] boxplot of subset of factors, in an order of my choice [B roadcast]

2006-06-29 Thread Liaw, Andy
1. Use something like 

  with(testResults, boxplot(score[test == rTest]))

2. testResults$test - factor(as.character(testResults$test),
  levels=c(rTest, gTest, fTest))

[Substitute any order you like in the last line.]

Andy

From: Sumitrajit Dhar
 
 Hi Folks,
 
 Say I am working with the following data set:
 testResults:
   studtestscore
 1 1   fTest   43
 2 1   rTest   39
 3 1   gTest   43
 4 2   fTest   23
 5 2   rTest   33
 6 2   gTest   41
 .
 .
 .
 N n   gTest   47
 
 I would like to generate a boxplot of rTest only. Here is 
 what I have done after reading the data in and attaching the object.
 
 test - factor(test)
 
 Now when I try
 
 boxplot(score ~ test, subset = test==rTest)
 
 1. I still see the tick marks for the other factors on the 
 x-axis although no data are plotted. Can I eliminate these 
 extra markers (and the space for these faactors) and just 
 have the tick marker and the label for rTest?
 
 2. I would also like to be able to rearrange the tests as 
 they appear from left to right on the graph. I read the hints 
 and help about reorder.factor but it does not seem to be the 
 solution in this case.  
 I am wanting to re-order the boxes without any logic 
 (statistical anyways). Can this be done?
 
 Thanks in advance,
 Sumit
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! 
 http://www.R-project.org/posting-guide.html
 


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


[R] lmer - Is this reasonable output?

2006-06-29 Thread Rick Bilonick
I'm estimating two models for data with n = 179 with four clusters (21,
70, 36, and 52) named siteid. I'm estimating a logistic regression model
with random intercept and another version with random intercept and
random slope for one of the independent variables.


fit.1 - lmer(glaucoma~(1|siteid)+x1
+x2,family=binomial,data=set1,method=ML,
  control=list(usePQL=FALSE,msVerbose=TRUE))

Generalized linear mixed model fit using PQL
Formula: glaucoma ~ (1 | siteid) + x1 + x2
  Data: set1
 Family: binomial(logit link)
  AIC  BIClogLik deviance
 236.7448 249.4944 -114.3724 228.7448
Random effects:
 Groups NameVariance Std.Dev.
 siteid (Intercept) 0.05959  0.24411
number of obs: 179, groups: siteid, 4

Estimated scale (compare to 1)  0.464267

Fixed effects:
 Estimate Std. Error z value Pr(|z|)
(Intercept) -2.213779   0.688158 -3.2170 0.001296 **
x1   0.609028   0.293250  2.0768 0.037818 *
x2   0.025027   0.009683  2.5846 0.009749 **
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Correlation of Fixed Effects:
   (Intr) x1
x1 -0.871
x2 -0.372 -0.024

 ranef(fit.1)
An object of class “ranef.lmer”
[[1]]
  (Intercept)
1 -0.05053772
2 -0.21592157
3  0.36643051
4 -0.04141520


fit.2 - lmer(glaucoma~(x1|siteid)+x1
+x2,family=binomial,data=set1,method=ML,
  control=list(usePQL=FALSE,msVerbose=TRUE))

Generalized linear mixed model fit using PQL
Formula: glaucoma ~ (x1 | siteid) + x1 + x2
  Data: set1
 Family: binomial(logit link)
  AIC  BIClogLik deviance
 239.3785 258.5029 -113.6893 227.3785
Random effects:
 Groups NameVariance Std.Dev. Corr
 siteid (Intercept) 0.059590 0.24411
x1  0.013079 0.11436  0.000
number of obs: 179, groups: siteid, 4

Estimated scale (compare to 1)  0.4599856

Fixed effects:
  Estimate Std. Error z value Pr(|z|)
(Intercept) -2.2137787  0.6911360 -3.2031 0.001360 **
x1   0.6090279  0.2995553  2.0331 0.042042 *
x2   0.0250268  0.0097569  2.5650 0.010316 *
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Correlation of Fixed Effects:
   (Intr) x1
x1 -0.854
x2 -0.372 -0.023

 ranef(fit.2)
An object of class “ranef.lmer”
[[1]]
  (Intercept)   x1
1 -0.05534800  0.009265667
2 -0.16991678 -0.052723584
3  0.27692026  0.137597965
4  0.01648737 -0.062232012

Note that the fixed coefficient estimates are identical for both models
and they are exactly equal to what glm gives ignoring the sites (but the
standard errors given by lmer are definitely larger - which would seem
reasonable). The se's for the fixed factors differ slightly between the
two models. Note also that the estimated random effect sd for siteid
intercept is identical for both models.

I ran both models using PROC NLMIXED in SAS. It gives be similar
estimates but not identical for the fixed effects and random effects.
The confidence intervals on the random effects for each site are very
large.

Am I getting these results because I don't really need to fit a random
effect for siteid? The estimated random effects for slope seem to say
that siteid matters. When I plot the data for each site with smoothing
splines it indicates reasonably different patterns between sites.

I don't think these models are that complicated and I have a reasonable
amount of data. I fit the fixed and random curves to the separate sites
(along with separate glm estimates for each site). As would be expected,
the random curves lie between the fixed effect curve and the glm curve.
But there seems to be a lot of shrinkage toward the fixed effect curve.
(The fixed effect curve fits the smoothing spline curve for all sites
combined very closely.)

If I specify method=ML and use PQL, I get similar fixed effect
estimates (but not identical to glm). The random intercept sd about
doubles. I think SAS NLMIXED uses an approximation to the likelihood so
that may explain some of the differences.

One other thing that seems odd to me is the random intercept sd for site
id. It equals 0.24411 in both models. If I change x1 to, say x3 (an
entirely different variable), I still get 0.24411. However, the random
slope sd does change.

I just want to make sure I'm fitting a reasonable model and getting
reasonable estimates.

Rick B.

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

Re: [R] lmer - Is this reasonable output?

2006-06-29 Thread Dimitris Rizopoulos
Hello Rick,

some comments below:

o in lmer(), 'method = ML' and its counterpart REML refer to the 
case of linear mixed models; for GLMMs the methods currently available 
are PQL and Laplace. The control argument 'usePQL = FALSE' can be used 
when 'method = Laplace', and in fact specifies not to use PQL as a 
refinement to the initial values.

o SAS proc NLMIXED performs (adaptive) Gaussian Quadrature and is 
conceptually closer to 'method = Laplace' in lmer(); for PQL you have 
to use proc GLIMMIX.

o for GLMMs both lmer() and NLMIXED work with an approximation to the 
observed data likelihood, since this likelihood involves an integral 
with no closed-form solution (except from very specific cases).

o with only 4 clusters I think it'd be difficult to estimate variance 
components; If you want to correct for site, you could just put it as 
an ordinary covariate in your logistic regression.

I hope my comments help.

Best,
Dimitris


Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
 http://www.student.kuleuven.be/~m0390867/dimitris.htm


- Original Message - 
From: Rick Bilonick [EMAIL PROTECTED]
To: R Help r-help@stat.math.ethz.ch
Sent: Thursday, June 29, 2006 3:52 PM
Subject: [R] lmer - Is this reasonable output?


 I'm estimating two models for data with n = 179 with four clusters 
 (21,
 70, 36, and 52) named siteid. I'm estimating a logistic regression 
 model
 with random intercept and another version with random intercept and
 random slope for one of the independent variables.


 fit.1 - lmer(glaucoma~(1|siteid)+x1
 +x2,family=binomial,data=set1,method=ML,
  control=list(usePQL=FALSE,msVerbose=TRUE))

 Generalized linear mixed model fit using PQL
 Formula: glaucoma ~ (1 | siteid) + x1 + x2
  Data: set1
 Family: binomial(logit link)
  AIC  BIClogLik deviance
 236.7448 249.4944 -114.3724 228.7448
 Random effects:
 Groups NameVariance Std.Dev.
 siteid (Intercept) 0.05959  0.24411
 number of obs: 179, groups: siteid, 4

 Estimated scale (compare to 1)  0.464267

 Fixed effects:
 Estimate Std. Error z value Pr(|z|)
 (Intercept) -2.213779   0.688158 -3.2170 0.001296 **
 x1   0.609028   0.293250  2.0768 0.037818 *
 x2   0.025027   0.009683  2.5846 0.009749 **
 ---
 Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

 Correlation of Fixed Effects:
   (Intr) x1
 x1 -0.871
 x2 -0.372 -0.024

 ranef(fit.1)
 An object of class “ranef.lmer”
 [[1]]
  (Intercept)
 1 -0.05053772
 2 -0.21592157
 3  0.36643051
 4 -0.04141520


 fit.2 - lmer(glaucoma~(x1|siteid)+x1
 +x2,family=binomial,data=set1,method=ML,
  control=list(usePQL=FALSE,msVerbose=TRUE))

 Generalized linear mixed model fit using PQL
 Formula: glaucoma ~ (x1 | siteid) + x1 + x2
  Data: set1
 Family: binomial(logit link)
  AIC  BIClogLik deviance
 239.3785 258.5029 -113.6893 227.3785
 Random effects:
 Groups NameVariance Std.Dev. Corr
 siteid (Intercept) 0.059590 0.24411
x1  0.013079 0.11436  0.000
 number of obs: 179, groups: siteid, 4

 Estimated scale (compare to 1)  0.4599856

 Fixed effects:
  Estimate Std. Error z value Pr(|z|)
 (Intercept) -2.2137787  0.6911360 -3.2031 0.001360 **
 x1   0.6090279  0.2995553  2.0331 0.042042 *
 x2   0.0250268  0.0097569  2.5650 0.010316 *
 ---
 Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

 Correlation of Fixed Effects:
   (Intr) x1
 x1 -0.854
 x2 -0.372 -0.023

 ranef(fit.2)
 An object of class “ranef.lmer”
 [[1]]
  (Intercept)   x1
 1 -0.05534800  0.009265667
 2 -0.16991678 -0.052723584
 3  0.27692026  0.137597965
 4  0.01648737 -0.062232012

 Note that the fixed coefficient estimates are identical for both 
 models
 and they are exactly equal to what glm gives ignoring the sites (but 
 the
 standard errors given by lmer are definitely larger - which would 
 seem
 reasonable). The se's for the fixed factors differ slightly between 
 the
 two models. Note also that the estimated random effect sd for siteid
 intercept is identical for both models.

 I ran both models using PROC NLMIXED in SAS. It gives be similar
 estimates but not identical for the fixed effects and random 
 effects.
 The confidence intervals on the random effects for each site are 
 very
 large.

 Am I getting these results because I don't really need to fit a 
 random
 effect for siteid? The estimated random effects for slope seem to 
 say
 that siteid matters. When I plot the data for each site with 
 smoothing
 splines it indicates reasonably different patterns between sites.

 I don't think these models are that complicated and I have a 
 reasonable
 amount of data. I fit the fixed and random curves to the separate 
 sites
 (along with separate 

[R] function in boot

2006-06-29 Thread YIHSU CHEN
Dear R users:

I'm trying to use boot function under the package boot to run some 
bootstrapping.

Basically, I have a df as follows. (The data is simplified for illustrative 
purpose.) 

V1 V2 V3
1  2  3 
4  5  7
3  5  2

Say that I want bootrap among (V1,V2,V3) for 1000 times and calculate the 
average of them, ie., v_bar still has lenght of 3. I think my question is 
really how to write bf function below. 

bf - function(d,f)
{
gp1 - 1:3 #indicate random draw from three series
dmean - apply(d[,gp1]*f[gp1],1,mean)  
}
a - boot(df,bf, R=1000, stype=f)


Any help or suggestions? Many thanks.

Yihsu

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


Re: [R] smoothing splines and degrees of freedom

2006-06-29 Thread Spencer Graves
  The help page for 'smooth.spline' says the argument 'df' is 'the 
desired equivalent number of degrees of freedom (trace of the smoother 
matrix).'  It also explains that the output of 'smooth.spline' includes 
a component 'fit', and two components of 'fit' are 'knot' and 'coef'. 
To learn more, you can run the examples, examine 'str(cars.spl)' and the 
other objects produced by those examples.  You can also read more in the 
references cited there.

  If you would like further help from this group, please submit another 
question, preferably after first reading the posting guide! 
www.R-project.org/posting-guide.html.  There is substantial but 
anecdotal evidence to suggest that posts more consistent with that guide 
tend to get better answers quicker.  For example, if the above does NOT 
answer your question, I believe you would have gotten a better reply if 
you had provided a simple, self-contained example, rather than having me 
rely on one from the 'example' section of the 'smooth.spline' help page.

  Hope this helps.
  Spencer Graves


Steven Shechter wrote:
 Hi,
 If I set df=2 in my smooth.spline function, is that equivalent to running
 a linear regression through my data?  It appears that df=# of data points
 gives the interpolating spline and that df = 2 gives the linear
 regression, but I just want to confirm this.
 
 Thank you,
 Steven
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

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


[R] multivariate normality test

2006-06-29 Thread Remigijus Lapinskas
Hello,

Could someone help me to explain the VERY big difference in applying two
tests on multivariate normality:

library(mvnormtest)
data(EuStockMarkets)
mshapiro.test(t(EuStockMarkets[15:29,1:4]))


 Shapiro-Wilk normality test
data:  Z
W = 0.8161, p-value = 0.005955

and

library(energy)
mvnorm.etest( EuStockMarkets[15:29,1:4] )

 Energy test of multivariate normality: estimated parameters

data:  x, sample size 15, dimension 4, replicates 999
E-statistic = 1.0041, p-value = 0.2482



Many thanks,
Rem

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


Re: [R] Help needed understanding eval,quote,expression

2006-06-29 Thread toby_marks
Great help,  thanks to both of you.  I actually think I get it. 

I think I was locked into eval(expression  ... ) as the solution.  I did 
search the archives for this question, but it must not have clicked with 
me.The  Thomas Lumley R-help (February 2005) was on the money.  I was 
missing the power  flexibility of the [[ operation.  It is certainly more 
direct.

I do believe this pattern will satisfy my original problem.

 x = list(y=list(y1=hello,y2=world),z=list(z1=foo,z2=bar))
 ids = list( zIds=c(z1,z2),yIds=c(y1,y2))
 str=y1
 x$y[[str]]
[1] hello


btw:  I set my prompt to $, so the first post, the $ at the beginning of 
the line was the prompt.  apologies for the confusion.


cheers.





Prof Brian Ripley [EMAIL PROTECTED] 
06/29/2006 04:06 AM





To
Joerg van den Hoff [EMAIL PROTECTED]
cc
[EMAIL PROTECTED], r-help@stat.math.ethz.ch
Subject
Re: [R] Help needed understanding eval,quote,expression






On Thu, 29 Jun 2006, Joerg van den Hoff wrote:

 Prof Brian Ripley wrote:
 You are missing eval(parse(text=)). E.g.
 
 x - list(y=list(y1=hello,y2=world),z=list(z1=foo,z2=bar))
 (what do you mean by the $ at the start of these lines?)
 eval(parse(text=x$y$y1))
 [1] hello
 
 However, bear in mind
 
 fortune(parse)
 
 If the answer is parse() you should usually rethink the question.
 -- Thomas Lumley
R-help (February 2005)
 
 In your indicated example you could probably use substitute() as 
 effectively.
 
 
 On Wed, 28 Jun 2006, [EMAIL PROTECTED] wrote:
 
 I am trying to build up a quoted or character expression representing 
a
 component in a list  in order to reference it indirectly.
 For instance, I have a list that has data I want to pull, and another 
list
 that has character vectors and/or lists of characters containing the 
names
 of the components in the first list.
 
 It seems that the way to do this is as evaluating expressions, but I 
seem
 to be missing something.  The concept should be similar to the snippet
 below:
 
 
 For instance:
 
 $x = list(y=list(y1=hello,y2=world),z=list(z1=foo,z2=bar))
 $y = quote(x$y$y1)
 $eval(y)
 [1] hello
 
 
 but, I'm trying to accomplish this by building up y as a character and
 then evaluating it, and having no success.
 
 $y1=paste(x$y$,y1,sep=)
 $y1
 [1] x$y$y1
 
 
 How can I evaluate y1 as I did with y previously?  or can I?
 
 
 Much Thanks !
 
 

 if I understand you correctly you can achieve your goal much easier than 
with 
 eval, parse, substitute and the like:

 x - list(y=list(y1=hello,y2=world),z=list(z1=foo,z2=bar))

 s1 - 'y'
 s2 - 'y1'

 x[[s1]][[s2]]

 i.e. using `[[' instead of `$' for list component extraction allows to 
use 
 characters for indexing (in other words: x$y == x[['y']])


But what he actually asked for was

 I am trying to build up a quoted or character expression representing 
a
 component in a list  in order to reference it indirectly.

You just typed in x[[s1]][[s2]], not 'built [it] up'.  Suppose the 
specification had been

r - x
s - c(y, y1)

and s was of variable length?  Then you need to construct a call similar 
to x[[y]][[y1]] from r and s.

[There was another reason for sticking with $ rather than using [[: the 
latter makes unnecessary copies in released versions of R.]


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



CONFIDENTIALITY NOTICE: This electronic mail transmission (i...{{dropped}}

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


Re: [R] Problems using na.include

2006-06-29 Thread Frank E Harrell Jr
Greg Distiller wrote:
 Hi
 I am having problems using na.action=na.include in a nlme call. Basically I 
 am trying to run a particular model without including any covariates but my 
 dataset does include some covariates (factors) with missing values. My 
 understanding from the Pinheiro and Bates book is that one would use 
 na.action=na.include in order to treat the missing values as another factor 
 level and then one can also use naPattern to specify which rows must be 
 excluded from the calculation of the objective function.

The approach of adding new categories for missing values has been shown 
to be highly problematic, completely changing the interpretation of the 
predictor and causing biases.  See an article by Werner Vach on this in 
the Encyclopedia of Biostatistics.

 
 I have tried this but keep getting error messages about being unable to find 
 the object or the function na.include. I have also tried to replicate the 
 particular Phenobarbital example verbatim from the book but am getting the 
 same error message. Could it be that my version of the nlme package is 
 outdated? I also cannot find any help on na.include...
 
 Thanks
 
 Greg
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
 


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

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


[R] Problems Creating an R package

2006-06-29 Thread Aarti Dahiya
Hi all,

When I check my package using Rcmd check ..\myPackage\R.mykg on Windows in 
Command Prompt, this is what get:-

* using log directory 'C:/R/bin/R.getdata.Rcheck'
* using Version 2.3.1 (2006-06-01)
* checking for file 'R.getdata/DESCRIPTION' ... OK
* checking extension type ... Package
* this is package 'R.getdata' version '1.0'
* checking package dependencies ... OK
* checking if this is a source package ... OK
* checking whether package 'R.getdata' can be installed ... OK
* checking package directory ... OK
* checking for portable file names ... OK
* checking DESCRIPTION meta-information ... OK
* checking top-level files ... OK
* checking index information ... OK
* checking package subdirectories ... WARNING
Subdirectory 'src' contains no source files.
* checking R files for syntax errors ... ERROR
Syntax error in file 'R/ConnectionFactory.R'

Q1. What should I put in 'src'.  I did put two of my source .R files, it 
still does not work.

Q2. This is what I get if I source R/ConnectionFactory.R.
Error in parse(file, n = -1, NULL, ?) : syntax error at
5: }
6: , .env = 

These are the contents of R/ConnectionFactory.R.

ConnectionFactory -
structure(function()
{
extend(Object(), ConnectionFactory)
}
, .env = environment, class = c(Class, Object), ...instanciationTime = 
structure(1151521420.604, class = c(POSIXt,
POSIXct)), formals = c(public, class), modifiers = c(public,
class)

Please note that this file is one that was automatically generated in 
R.mykg/R.  My source file ConnectionFactory.R has the actual R code which 
sources just fine.

I will greatly appreciate any help!  Thank you.

Aarti

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


Re: [R] Extracting R plots from MS Word

2006-06-29 Thread Philipp Pagel
On Thu, Jun 29, 2006 at 05:15:08PM +1200, [EMAIL PROTECTED] wrote:
 I am revising a paper that I am a co-author of. The figures are plots
 generated from R but at the moment I do not have the R code that generates
 them.
 
 As this is time critical I would like to slightly abuse the list by asking
 whether anyone knows how to extract from MS Word into a stand-alone
 graphics file a plot that was pasted into Word from R (probably as a
 Windows Metafile, but possibly as a bitmap).

Open the doc file in OpenOffice, save in sxw format (openoffice's old 
native format), unpack the file with unzip and find the figure in the
resulting directory.

I'm not sure if and how this works with the new odt format used by
openoffice now, but sxw will work.

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-8161-71 2131
Dept. of Genome Oriented Bioinformatics  Fax.  +49-8161-71 2186
Technical University of Munich
Science Center Weihenstephan
85350 Freising, Germany

 and

Institute for Bioinformatics / MIPS  Tel.  +49-89-3187 3675
GSF - National Research Center   Fax.  +49-89-3187 3585
  for Environment and Health
Ingolstädter Landstrasse 1
85764 Neuherberg, Germany
http://mips.gsf.de/staff/pagel

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


[R] initializing table and filling it out

2006-06-29 Thread Cuau

   Hi everyone,
  
 I'm writting a script that will open multiple files in a  single folder 
and then will do some calculations to finally save  everything in a big table.
   So here  is the pseudo code
  
  #read all files in the given directory
  myfiles -list.files(c:\\myDir)
  
  #initialize table
  ???
  
  #loop through files
  for(f in myfiles[-1]) {
netMat - read.table( f, sep  )
netMat -as.matrix(netMat)
  
   # calculate the needed Stats
   gden(netMat)-density
   centralization(netMat, degree) - Gdegree
   centralization(netMat, betweenness) - Gbetweenness
   centralization(netMat, closeness) - Gcloseness
  
  #store into table
  
  
  }
  
So my questions are two
  
   First how can I initialize the table (it will be a 4 X 1001 table) without 
filling it out first. 
  Second how can I store each value in the table (i.e. in each round I'll  be 
adding one full column with density and the 3 different  centralizations)?
  
  thks
  
  -Cuau
  
  
  

-


[[alternative HTML version deleted]]

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


Re: [R] superimposing histograms con't

2006-06-29 Thread Martin Maechler
 Bill == Bill Shipley [EMAIL PROTECTED]
 on Wed, 28 Jun 2006 15:53:35 -0400 writes:

Bill Earlier, I posted the following question:

Bill I want to superimpose histograms from three
Bill populations onto the same graph, changing the shading
Bill of the bars for each population. After consulting the
Bill help files and the archives I cannot find out how to
Bill do this (seemly) simple graph. To be clear, I want

Bill - a single x axis (from -3 to 18)
Bill - three groups of bars forming the histograms of each population
Bill   (they will not overlap much, but this is a detail)
Bill - the bars from each histogram having different
Bill   shadings or other  visually distinguishing features.
 
Bill Gabor Grothendieck [EMAIL PROTECTED] pointed
Bill to some code to to this but I have found another way
Bill that works even easier.
 

Bill hist(x[sel1],xlim=c(a,b),ylim=c(A,B))  - this plots the histogram for 
the
Bill first group (indexed by sel1) but with an x axis and a y axis that 
spans the
Bill entire range.
 
Bill par(new=T)  - to keep on the same graph
 
Bill hist(x[sel2],main=Null,xlab=NULL,ylab=NULL,axes=F) -superimposes the 
second
Bill histogram
 
Bill par(new=T)  - to keep on the same graph
 
Bill hist(x[sel3],main=Null,xlab=NULL,ylab=NULL,axes=F) -superimposes the 
third
Bill histogram
 
Hmm, the above does not work (because of 'Null' instead of  'NULL')
but even if you fix that, I'm pretty sure you get pretty wrong
plots.

par(new = TRUE) is quite often a bad choice.
In the present case, plot 2 and 3 use different
coordinate systems than plot 1.

The correct solution -- apart from using  lattice::histogram()
with the correct 'superpose' panel is really to make use of the
fact that

  1) hist() returns a histogram (S3) object which is plotted by
 
  2) plot.histogram() which has a nice help page even though
 the funcion is namespace-hidden.

Here's a reproducible solution --- with quite a bit of extra
code in order to show two ``colorizations'' for overplotting,
in particular one with ``transparent colors'' :


##MM: construct reproducible example data
set.seed(1)
x - c(rnorm(50), (rnorm(60) +3.5), (rnorm(40) +3.5 + 3))
str(grouping - factor(c(rep(1,50), rep(2,60), rep(3,40
(n.gr - length(table(grouping))) # 3

xr - range(x)
## Compute all three histograms objects but without plotting:
histL - tapply(x, grouping, hist, plot = FALSE)
maxC - max(print( sapply(lapply(histL, [[, counts), max)) ) # 14 15 15

pdf(3histo.pdf, version = 1.4) # = 1.4 is needed
## or try the default x11()

if((TC - transparent.cols - .Device %in% c(pdf, png))) {
cols - hcl(h = seq(30, by=360 / n.gr, length = n.gr), l = 65,
alpha = 0.5) ##  transparency
} else {
h.den - c(10, 15, 20)
h.ang - c(45, 15, -30)
}

## Plots the histogram for the
## first group (indexed by sel1) but with an x axis and a y axis that spans the
## entire range.
if(TC) {
plot(histL[[1]], xlim = xr, ylim= c(0, maxC), col = cols[1],
 xlab = x, main = 3 Histograms of 3 Selections from 'x')
} else
plot(histL[[1]], xlim = xr, ylim= c(0, maxC), density = h.den[1], angle = 
h.ang[1],
 xlab = x, main = Histogram of 3 selections from 'x')
## Using density instead of color make these *add*

if(!transparent.cols) {
for(j in 2:n.gr)
plot(histL[[j]], add = TRUE, density = h.den[j], angle = h.ang[j])
} else { ## use semi-translucent colors (available only for PDF = 1.4 and PNG 
devices):
for(j in 2:n.gr)
plot(histL[[j]], add = TRUE, col = cols[j])
}

if(.Device == pdf) { ## you have set it above
  dev.off()
  system(gv 3histo.pdf )## or use 'acroread' ;  'xpdf' does not show 
transparent colors...
}

1 ##--- Martin Maechler, ETH Zurich

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


Re: [R] Problems Creating an R package

2006-06-29 Thread Thomas Petzoldt
Hi Aarti

src/  if you have source files in C or Fortran.
R/for the R sources.

If you have no C or Fortran files, you should delete the src/ directory.

The syntax error in your R function is simply that the , is on a new
line so R thinks that the line above is complete.

Hope it helps

Thomas P.


Aarti Dahiya wrote:
 Hi all,
 
 When I check my package using Rcmd check ..\myPackage\R.mykg on Windows in 
 Command Prompt, this is what get:-
 
 * using log directory 'C:/R/bin/R.getdata.Rcheck'
 * using Version 2.3.1 (2006-06-01)
 * checking for file 'R.getdata/DESCRIPTION' ... OK
 * checking extension type ... Package
 * this is package 'R.getdata' version '1.0'
 * checking package dependencies ... OK
 * checking if this is a source package ... OK
 * checking whether package 'R.getdata' can be installed ... OK
 * checking package directory ... OK
 * checking for portable file names ... OK
 * checking DESCRIPTION meta-information ... OK
 * checking top-level files ... OK
 * checking index information ... OK
 * checking package subdirectories ... WARNING
 Subdirectory 'src' contains no source files.
 * checking R files for syntax errors ... ERROR
 Syntax error in file 'R/ConnectionFactory.R'
 
 Q1. What should I put in 'src'.  I did put two of my source .R files, it 
 still does not work.
 
 Q2. This is what I get if I source R/ConnectionFactory.R.
 Error in parse(file, n = -1, NULL, ?) : syntax error at
 5: }
 6: , .env = 
 
 These are the contents of R/ConnectionFactory.R.
 
 ConnectionFactory -
 structure(function()
 {
   extend(Object(), ConnectionFactory)
 }
 , .env = environment, class = c(Class, Object), ...instanciationTime = 


 structure(1151521420.604, class = c(POSIXt,
 POSIXct)), formals = c(public, class), modifiers = c(public,
 class)
 
 Please note that this file is one that was automatically generated in 
 R.mykg/R.  My source file ConnectionFactory.R has the actual R code which 
 sources just fine.
 
 I will greatly appreciate any help!  Thank you.
 
 Aarti
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

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


Re: [R] superimposing histograms con't

2006-06-29 Thread Martin Maechler
 Jeff == Jeff Miller [EMAIL PROTECTED]
 on Wed, 28 Jun 2006 16:20:39 -0400 writes:

Jeff I was just thinking about this last night.
Jeff I would like to do the same but WITH overlapping.

Jeff For example, I graph 2 sets of count data. Say the
Jeff bars for the 1`s overlap...I would like to show that
Jeff with a different shading for the group that has the
Jeff higher frequency. For example, it could be black up to
Jeff a frequency of 5 followed by diagonal-dashes from 5-7
Jeff representing the higher frequency of a second group.

Just 5 minutes ago, I've posted a reply to Bill's message
containing R code which I think also solves the above problem.

Solving overlapping visually either by
  (old style) shading  or by
  (new style) transparent colors -- unfortunately only available
  on pdf(version = 1.4), png(), and quartz(), AFAIK.

Martin Maechler

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


Re: [R] initializing table and filling it out

2006-06-29 Thread Gabor Grothendieck
If you use lapply you don't have to set up the storage area.

Here is an example.  I have used textConnection with character
strings to make this reproducible but you can replace conn with
a vector of filenames,

# test data
Lines1 - 
1 2
3 4


Lines2 - 
11 12
13 14


conn - list(textConnection(Lines1), textConnection(Lines2))

# this is code
f - function(f) with(read.table(f), c(a = mean(V1), b = sd(V2)))
do.call(rbind, lapply(conn, f))



On 6/29/06, Cuau [EMAIL PROTECTED] wrote:

   Hi everyone,

 I'm writting a script that will open multiple files in a  single folder 
 and then will do some calculations to finally save  everything in a big table.
   So here  is the pseudo code

  #read all files in the given directory
  myfiles -list.files(c:\\myDir)

  #initialize table
  ???

  #loop through files
  for(f in myfiles[-1]) {
netMat - read.table( f, sep  )
netMat -as.matrix(netMat)

   # calculate the needed Stats
   gden(netMat)-density
   centralization(netMat, degree) - Gdegree
   centralization(netMat, betweenness) - Gbetweenness
   centralization(netMat, closeness) - Gcloseness

  #store into table
  

  }

So my questions are two

   First how can I initialize the table (it will be a 4 X 1001 table) without 
 filling it out first.
  Second how can I store each value in the table (i.e. in each round I'll  be 
 adding one full column with density and the 3 different  centralizations)?

  thks

  -Cuau




 -


[[alternative HTML version deleted]]

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


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


Re: [R] Problems Creating an R package

2006-06-29 Thread Prof Brian Ripley
On Thu, 29 Jun 2006, Thomas Petzoldt wrote:

 Hi Aarti

 src/  if you have source files in C or Fortran.
 R/for the R sources.

 If you have no C or Fortran files, you should delete the src/ directory.

 The syntax error in your R function is simply that the , is on a new
 line so R thinks that the line above is complete.

R does know it is waiting for a ')'.  The error is exactly where it says, at
 6: , .env = 

and of course

 , .env = environment, class = c(Class, Object), ...instanciationTime =
 ^
which is not valid R.


 Hope it helps

 Thomas P.


 Aarti Dahiya wrote:
 Hi all,

 When I check my package using Rcmd check ..\myPackage\R.mykg on Windows in
 Command Prompt, this is what get:-

 * using log directory 'C:/R/bin/R.getdata.Rcheck'
 * using Version 2.3.1 (2006-06-01)
 * checking for file 'R.getdata/DESCRIPTION' ... OK
 * checking extension type ... Package
 * this is package 'R.getdata' version '1.0'
 * checking package dependencies ... OK
 * checking if this is a source package ... OK
 * checking whether package 'R.getdata' can be installed ... OK
 * checking package directory ... OK
 * checking for portable file names ... OK
 * checking DESCRIPTION meta-information ... OK
 * checking top-level files ... OK
 * checking index information ... OK
 * checking package subdirectories ... WARNING
 Subdirectory 'src' contains no source files.
 * checking R files for syntax errors ... ERROR
 Syntax error in file 'R/ConnectionFactory.R'

 Q1. What should I put in 'src'.  I did put two of my source .R files, it
 still does not work.

 Q2. This is what I get if I source R/ConnectionFactory.R.
 Error in parse(file, n = -1, NULL, ?) : syntax error at
 5: }
 6: , .env = 

 These are the contents of R/ConnectionFactory.R.

 ConnectionFactory -
 structure(function()
 {
  extend(Object(), ConnectionFactory)
 }
 , .env = environment, class = c(Class, Object), ...instanciationTime =


 structure(1151521420.604, class = c(POSIXt,
 POSIXct)), formals = c(public, class), modifiers = c(public,
 class)

 Please note that this file is one that was automatically generated in
 R.mykg/R.  My source file ConnectionFactory.R has the actual R code which
 sources just fine.

 I will greatly appreciate any help!  Thank you.

 Aarti

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

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


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

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


[R] R server

2006-06-29 Thread Li, Mike
Hi, 

I just installed R in Windows, it seems to me that R is a standalone
desktop application. Do you know if R has its server version which could
handle multi-users, have several distinct R sessions and their own
variables in Unix or Windows? 

I saw OpenStatServer, RStatServer available, can those handle
multi-sessions?

Thanks

Mike


[[alternative HTML version deleted]]

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


Re: [R] R server

2006-06-29 Thread Gabor Csardi
One approach would be to install R on a unix machine and let other machines
connect to it via a standard X server.
There might be other approaches though

Gabor

On Thu, Jun 29, 2006 at 12:05:40PM -0400, Li, Mike wrote:
 Hi, 
 
 I just installed R in Windows, it seems to me that R is a standalone
 desktop application. Do you know if R has its server version which could
 handle multi-users, have several distinct R sessions and their own
 variables in Unix or Windows? 
 
 I saw OpenStatServer, RStatServer available, can those handle
 multi-sessions?
 
 Thanks
 
 Mike
 
 
   [[alternative HTML version deleted]]
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

-- 
Csardi Gabor [EMAIL PROTECTED]MTA RMKI, ELTE TTK

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


Re: [R] specify y axis values

2006-06-29 Thread jim holtman
?axis

 curve(2*x  + 3, 0,10,xaxt='n',yaxt='n')
 axis(1, at=seq(0,10))
 axis(2, at=seq(5,10))




On 6/29/06, Marc Bernard [EMAIL PROTECTED] wrote:

 Dear All,

 I am looking how to specify the values on the y axis and x axis for a
 curve function.
 example:

 curve(2*x  + 3, 0,10) gives me  a range of x axis in (0,2,4,6,8,10) amd
 for yaxis (5,10,15,20). How to do in order to have the x axis in
 (0,1,2,3,4,5,6,7,8,9,10) and y axis in (5,6,7,8,.., 10).


 Thanks a lot,

 Bernard



 -

[[alternative HTML version deleted]]

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




-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390 (Cell)
+1 513 247 0281 (Home)

What is the problem you are trying to solve?

[[alternative HTML version deleted]]

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


[R] Internet Problem in R

2006-06-29 Thread Elizabeth Purdom
Hi,

I have a student who's R seems to be unable to connect to the internet. I 
have verified that her computer has internet access that's working fine, 
but that R is not able to establish connections. For example, she cannot 
download packages for R from the URL site, cannot source webpages, or 
read.table from a webpage (all of these give errors of not being able to 
establish a connection). Right now I have shown her how to manually 
download the zip file for the package and install it from the local file, 
but she wants Bioconductor -- the instructions for which seem to require 
the usual internet access. Does anyone have any troubleshooting 
suggestions? (I've never had problems with the internet interface with R, 
so I don't even know where to start to try to fix it or even diagnose the 
problem). Could a firewall have this effect? Wireless?

Her computer is running version R.2.3.1, on a Windows XP.

Thanks,
Elizabeth Purdom

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


Re: [R] Internet Problem in R

2006-06-29 Thread Liaw, Andy
It could well be a firewall issue.  Try adding --internet2 as argument to
Rgui.exe in the target field of the shortcut for Rgui.

Andy 

From: Elizabeth Purdom
 
 Hi,
 
 I have a student who's R seems to be unable to connect to the 
 internet. I have verified that her computer has internet 
 access that's working fine, but that R is not able to 
 establish connections. For example, she cannot download 
 packages for R from the URL site, cannot source webpages, or 
 read.table from a webpage (all of these give errors of not 
 being able to establish a connection). Right now I have shown 
 her how to manually download the zip file for the package and 
 install it from the local file, but she wants Bioconductor -- 
 the instructions for which seem to require the usual internet 
 access. Does anyone have any troubleshooting suggestions? 
 (I've never had problems with the internet interface with R, 
 so I don't even know where to start to try to fix it or even 
 diagnose the problem). Could a firewall have this effect? Wireless?
 
 Her computer is running version R.2.3.1, on a Windows XP.
 
 Thanks,
 Elizabeth Purdom
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! 
 http://www.R-project.org/posting-guide.html
 


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


[R] Biobass, SAGx, and Jonckheere-Terpstra test

2006-06-29 Thread Horace Tso
Hi list,

I tried to load the package SAGx and failed because it complains it's
looking for the Biobass which is not there. Then I looked up the package
list and Biobass is not found. 

I'm trying to run the Jonckheere-Terpstra test and from what I see in
the R archive, SAGx is the only place it's been implemented.

 library(SAGx)
Loading required package: multtest
Loading required package: survival
Loading required package: splines
Loading required package: sma
Error in loadNamespace(i, c(lib.loc, .libPaths())) : 
there is no package called 'Biobase'
Error: package/namespace load failed for 'SAGx'


Horace W. Tso

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


[R] RCOM Package

2006-06-29 Thread Thomas Sudler
Hi list,

I just installed the rcom package and tried to read/give out some values 
from/to Excel. Altogether it works great... but nevertheless I don't know 
how the syntax works or in other words: Which command needs which 
parameters?

Is there somwhere a manual about this package with good examples? I've read 
the Package description... but there are not really good 
descriptions/examples.

I know the following parameters/commands:

#Connect to the active Workbook
excel - comGetObject(Excel.Application)

#Set the active sheet
sheet - comGetProperty(excel,ActiveSheet)

#Set a specific sheet
sheet - comGetProperty(excel,Worksheets,WorksheetXY)

#Create a new Worksheet
comInvoke(comGetProperty(excel,Worksheets),Add)

#Define a range in a defined sheet
range1 - comGetProperty(sheet,Range,A1,A20)

#Read out this range from Excel
val1 - as.double(comGetProperty(range1,Value))

#Give back the results to Excel
comSetProperty(range1,Value,val1)

Some of my questions are:

- How can I rename a worksheet?
- How can I define the name of a new worksheet?
- How can I delete a worksheet?
- How can I connect to a specific Workbook, if more than one is opened?
- ...

Can someone help me?

Thanks,
Thomas

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


Re: [R] RCOM Package

2006-06-29 Thread Gabor Grothendieck
Go into Excel, turn on macro recording, perform whatever operations
you want and look at whatever code is generated for you.

On 6/29/06, Thomas Sudler [EMAIL PROTECTED] wrote:
 Hi list,

 I just installed the rcom package and tried to read/give out some values
 from/to Excel. Altogether it works great... but nevertheless I don't know
 how the syntax works or in other words: Which command needs which
 parameters?

 Is there somwhere a manual about this package with good examples? I've read
 the Package description... but there are not really good
 descriptions/examples.

 I know the following parameters/commands:

 #Connect to the active Workbook
 excel - comGetObject(Excel.Application)

 #Set the active sheet
 sheet - comGetProperty(excel,ActiveSheet)

 #Set a specific sheet
 sheet - comGetProperty(excel,Worksheets,WorksheetXY)

 #Create a new Worksheet
 comInvoke(comGetProperty(excel,Worksheets),Add)

 #Define a range in a defined sheet
 range1 - comGetProperty(sheet,Range,A1,A20)

 #Read out this range from Excel
 val1 - as.double(comGetProperty(range1,Value))

 #Give back the results to Excel
 comSetProperty(range1,Value,val1)

 Some of my questions are:

 - How can I rename a worksheet?
 - How can I define the name of a new worksheet?
 - How can I delete a worksheet?
 - How can I connect to a specific Workbook, if more than one is opened?
 - ...

 Can someone help me?

 Thanks,
 Thomas

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


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


[R] Cointegration Test in R

2006-06-29 Thread Dennis Heidemann
Hello!

I'm using the blrtest() function in the urca package
to test cointegration relationships.
Unfortunately, the hypothesis (restrictions on beta) 
specifies the same restriction on all cointegration vectors.
Is there any possibility to specify different restrictions on
the cointegration vectors?
Are there any other packages in R using cointegration tests?

Thanks and best regards.
Dennis Heidemann
[[alternative HTML version deleted]]

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


Re: [R] Biobass, SAGx, and Jonckheere-Terpstra test

2006-06-29 Thread Prof Brian Ripley
It is *Biobase*.  That is part of BioC (www.bioconductor.org), although I 
agree that it should make clear where to get non-CRAN packages. (Worse: 
SAGx used not to require it, and only the update to the most recent 
version does.)

On Thu, 29 Jun 2006, Horace Tso wrote:

 Hi list,

 I tried to load the package SAGx and failed because it complains it's
 looking for the Biobass which is not there. Then I looked up the package
 list and Biobass is not found.

 I'm trying to run the Jonckheere-Terpstra test and from what I see in
 the R archive, SAGx is the only place it's been implemented.

 library(SAGx)
 Loading required package: multtest
 Loading required package: survival
 Loading required package: splines
 Loading required package: sma
 Error in loadNamespace(i, c(lib.loc, .libPaths())) :
there is no package called 'Biobase'
 Error: package/namespace load failed for 'SAGx'


 Horace W. Tso

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


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

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


[R] How to use a for loop to generate two sequences

2006-06-29 Thread Xiaohua Dai
Hi R users,

Hope the question is not too simple:

How to use a for loop to generate two lists as below:

testlist - list(test1, test2, ..., test1000)
stringlist - list(test1,test2,...,test1000)

Thanks
Xiaohua

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


Re: [R] How to use a for loop to generate two sequences

2006-06-29 Thread Thomas Lumley
On Thu, 29 Jun 2006, Xiaohua Dai wrote:

 Hi R users,

 Hope the question is not too simple:

 How to use a for loop to generate two lists as below:

 testlist - list(test1, test2, ..., test1000)
 stringlist - list(test1,test2,...,test1000)

I don't know why you would want to use a for loop:

  stringlist-as.list(paste(test,1:1000,sep=))
  testlist-lapply(stringlist, as.name)


-thomas

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


[R] cat and positioning of the output

2006-06-29 Thread J?rn Schulz

Hello R users!

I like to use cat in a loop. I know, loops are not the best way in R ... but
my question: It is possible to overwrite the expression Reading row: i in
each iteration of the loop (print out in the below loop on the screen) or
more particulary to overwrite the counter i.

for(i in 1:header$M){
   cat(Reading row: , i)
   SparseIndex[[i]] - readBin( con, integer(), n=MIndexNumber[i], size=4 )
   SparseSignal[[i]] - readBin( con, numeric(), n=MIndexNumber[i], size=4 )
}

Many thanks
J?rn Schulz.
-- 
View this message in context: 
http://www.nabble.com/cat-and-positioning-of-the-output-tf1869521.html#a5109359
Sent from the R help forum at Nabble.com.

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


Re: [R] cat and positioning of the output

2006-06-29 Thread Gabor Grothendieck
On Windows XP this works for me:

for(i in 1:3) { if (i  1) cat(\b); cat(i); flush.console();
Sys.sleep(1) }; cat(\n)

It displays 1, then it overwrites it with 2 and then overwrites that with 3.


On 6/29/06, J?rn Schulz [EMAIL PROTECTED] wrote:

 Hello R users!

 I like to use cat in a loop. I know, loops are not the best way in R ... but
 my question: It is possible to overwrite the expression Reading row: i in
 each iteration of the loop (print out in the below loop on the screen) or
 more particulary to overwrite the counter i.

 for(i in 1:header$M){
   cat(Reading row: , i)
   SparseIndex[[i]] - readBin( con, integer(), n=MIndexNumber[i], size=4 )
   SparseSignal[[i]] - readBin( con, numeric(), n=MIndexNumber[i], size=4 )
 }

 Many thanks
 J?rn Schulz.
 --
 View this message in context: 
 http://www.nabble.com/cat-and-positioning-of-the-output-tf1869521.html#a5109359
 Sent from the R help forum at Nabble.com.

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


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


Re: [R] cat and positioning of the output

2006-06-29 Thread Philippe Grosjean

=?ANSI_X3.4-1968?Q?J=3Frn_Schulz?= wrote:
 Hello R users!
 
 I like to use cat in a loop. I know, loops are not the best way in R ... but
 my question: It is possible to overwrite the expression Reading row: i in
 each iteration of the loop (print out in the below loop on the screen) or
 more particulary to overwrite the counter i.

In package svMisc (SciViews bundle):

  ?progress
  example(progress)
Best,

Philippe Grosjean


 for(i in 1:header$M){
cat(Reading row: , i)
SparseIndex[[i]] - readBin( con, integer(), n=MIndexNumber[i], size=4 )
SparseSignal[[i]] - readBin( con, numeric(), n=MIndexNumber[i], size=4 )
 }
 
 Many thanks
 J?rn Schulz.

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


Re: [R] cat and positioning of the output

2006-06-29 Thread Dan Gunter
=?ANSI_X3.4-1968?Q?J=3Frn_Schulz?= wrote:
 Hello R users!

 I like to use cat in a loop. I know, loops are not the best way in R ... but
 my question: It is possible to overwrite the expression Reading row: i in
 each iteration of the loop (print out in the below loop on the screen) or
 more particulary to overwrite the counter i.

 for(i in 1:header$M){
cat(Reading row: , i)
SparseIndex[[i]] - readBin( con, integer(), n=MIndexNumber[i], size=4 )
SparseSignal[[i]] - readBin( con, numeric(), n=MIndexNumber[i], size=4 )
 }

 Many thanks
 J?rn Schulz.
   
On a UNIX terminal, adding '\r' will cause the cursor to go back to the 
beginning of the same line. I can't speak for Windows.

e.g.

for ( i in 1:10 ) { cat(Number,i,\r); Sys.sleep(1) }; cat(\n)

-Dan

-- 
Dan Gunter. voice:510-495-2504 fax:510-486-6363 dsd.lbl.gov/~dang

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


Re: [R] cat and positioning of the output

2006-06-29 Thread Philippe Grosjean
Dan Gunter wrote:
 =?ANSI_X3.4-1968?Q?J=3Frn_Schulz?= wrote:
 
Hello R users!

I like to use cat in a loop. I know, loops are not the best way in R ... but
my question: It is possible to overwrite the expression Reading row: i in
each iteration of the loop (print out in the below loop on the screen) or
more particulary to overwrite the counter i.

for(i in 1:header$M){
   cat(Reading row: , i)
   SparseIndex[[i]] - readBin( con, integer(), n=MIndexNumber[i], size=4 )
   SparseSignal[[i]] - readBin( con, numeric(), n=MIndexNumber[i], size=4 )
}

Many thanks
J?rn Schulz.
  
 
 On a UNIX terminal, adding '\r' will cause the cursor to go back to the 
 beginning of the same line. I can't speak for Windows.
 
 e.g.
 
 for ( i in 1:10 ) { cat(Number,i,\r); Sys.sleep(1) }; cat(\n)
 
 -Dan

It works, but I don't like much strange things that can happen with \r 
because the caret is located at the beginning of the line. Look at what 
happens if you forgot the latests 'cat(\n)'. Also, note that for RGui 
under windows, you must use flush.console(). So:

  for (i in 1:10) {
 cat(Number,i,\r)
 flush.console()
 Sys.sleep(1)
  }
  cat(\n)

does the job. The alternative is to use \b repeatedly, which is done 
in progress() indeed.
Best,

Philippe Grosjean

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


Re: [R] cat and positioning of the output

2006-06-29 Thread Michael H. Prager
It works on Windows (rgui.exe) with this change:

 for ( i in 1:10 ) { cat(Number,i,\r); flush.console(); Sys.sleep(1) 
}; cat(\n)

MHP


on 6/29/2006 4:33 PM Dan Gunter said the following:
 =?ANSI_X3.4-1968?Q?J=3Frn_Schulz?= wrote:
   
 Hello R users!

 I like to use cat in a loop. I know, loops are not the best way in R ... but
 my question: It is possible to overwrite the expression Reading row: i in
 each iteration of the loop (print out in the below loop on the screen) or
 more particulary to overwrite the counter i.

 for(i in 1:header$M){
cat(Reading row: , i)
SparseIndex[[i]] - readBin( con, integer(), n=MIndexNumber[i], size=4 )
SparseSignal[[i]] - readBin( con, numeric(), n=MIndexNumber[i], size=4 )
 }

 Many thanks
 J?rn Schulz.
   
 
 On a UNIX terminal, adding '\r' will cause the cursor to go back to the 
 beginning of the same line. I can't speak for Windows.

 e.g.

 for ( i in 1:10 ) { cat(Number,i,\r); Sys.sleep(1) }; cat(\n)

 -Dan

   

-- 
Michael Prager, Ph.D.
Southeast Fisheries Science Center
NOAA Center for Coastal Fisheries and Habitat Research
Beaufort, North Carolina  28516
** Opinions expressed are personal, not official.  No
** official endorsement of any product is made or implied.

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


[R] Passing argument in nested function calls

2006-06-29 Thread Aarti Dahiya
Please, do not ask why you would do this.  I have simplified my complicated 
code to just the basic problem occuring to be able to make it easier to 
understand the actual problem.

I have two function getArgs() and extractArgs() - code and test results 
provided below.
I test them using getArgs(id = 's1002') from the command line.

getArgs() prints the name of the argument as id and the actual argument as 
s1002, which is correct.

But, when I call extractArgs() from within getArgs() passing value of passed 
(stored in passed, passed is created from paste(names(args),=, 
sQuote(args))); extractArgs() treats the value of passed as a string id = 
's1002' and treats the whole thing as one argument.  So, it prints 
args[[1]] as the whole thing id = 's1002', but prints blank for 
names(args[[1]]), obviously beacuse it cannot find a name for the argument.

If I call extractArgs(id = 's1002') from the command line, it works just 
fine, prints the name of the argument as id and the actual argument as 
s1002, which is correct.

How do I fix the problem so that when extractArgs() is called within 
getArgs(), it behaves the same way as getArgs() and extracts the argument 
and argument name?  Can we unstring passed or change it into another mode?

I'll appreciate any help or pointers.  Thanks.  Aarti

getArgs - function(...)
{
cat(\nEntering getArgs()\n\n)

args - list(...)

cat(In getArgs(), names(args[1]) is )
cat(names(args[1]))
cat( and args[[1]] is )
cat(args[[1]])
cat(\n)

passed - paste(names(args),=, sQuote(args))

extractArgs(passed)

cat(Exiting getArgs()\n\n)
}

extractArgs - function(...)
{
cat(\nEntering extractArgs()\n\n)

args - list(...)

cat(In extractArgs(), names(args[1]) is )
cat(names(args[1]))
cat( and args[[1]] is )
cat(args[[1]])
cat(\n)

cat(\nExiting extractArgs()\n\n)
}

Test:

getArgs(id = 's1002')

Entering getArgs()

In getArgs(), names(args[1]) is id and args[[1]] is s1002

Entering extractArgs()

In extractArgs(), names(args[1]) is  and args[[1]] is id = 's1002'

Exiting extractArgs()

Exiting getArgs()

extractArgs(id = 's1002')

Entering extractArgs()

In extractArgs(), names(args[1]) is id and args[[1]] is s1002

Exiting extractArgs()

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


Re: [R] Transform Normal Dist to ArcTan Dist

2006-06-29 Thread Ben Bolker
Luis Cota luis.cota at avmltd.com writes:

 
 I have a set of data that is distributed normally.  How can I transform
 this data to fit an ArcTan distribution?
 
   [[alternative HTML version deleted]]
 
 __
 R-help at stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
 
 

  we need more information.  This is a stats question more than an R
question, and there isn't enough context here to know either (1) what
arctangent distribution you're talking about (it may be the Cauchy/
t-distribution with 1 df, or it may be something else) or (2) why
you want to transform the distribution, and whether it's a sensible
thing to do in the first place ... (see what the posting guide has
to say about statistical questions ...)

  Ben Bolker

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


[R] help with coxme

2006-06-29 Thread Lei Liu
Hi there,

I have a question on fitting data by coxme. In particular I want to fit a 
random intercept and random slope cox model. Using the rats dataset as an 
example, I generated another covariate x2 and want to specify a random slope 
for x2. Here is my code:

x2=matrix(rep(runif(50), 3), 50, 3)
x2=as.vector(t(x2))

rats2=cbind(rats, x2)

But when I used the coxme function as follows, it gave an error message. 
What is the right way to do it? Thanks a lot!

  coxme(Surv(time, status) ~ rx+x2, data=rats2, random=~ (1+x2)|litter )


Lei Liu
Assistant Professor
Division of Biostatistics and Epidemiology
Dept. of Public Health Sciences
School of Medicine
University of Virginia

3181 Hospital West Complex
Charlottesville, VA 22908-0717

1-434-982-3364 (o)
1-434-806-8086 (c)

[EMAIL PROTECTED]
[EMAIL PROTECTED]

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


Re: [R] Passing argument in nested function calls

2006-06-29 Thread Gabor Grothendieck
getArgs should be:

getArgs - function(...) extractArgs(...)

# test
extractArgs(x = 3)
getArgs(x = 3)


On 6/29/06, Aarti Dahiya [EMAIL PROTECTED] wrote:
 Please, do not ask why you would do this.  I have simplified my complicated
 code to just the basic problem occuring to be able to make it easier to
 understand the actual problem.

 I have two function getArgs() and extractArgs() - code and test results
 provided below.
 I test them using getArgs(id = 's1002') from the command line.

 getArgs() prints the name of the argument as id and the actual argument as
 s1002, which is correct.

 But, when I call extractArgs() from within getArgs() passing value of passed
 (stored in passed, passed is created from paste(names(args),=,
 sQuote(args))); extractArgs() treats the value of passed as a string id =
 's1002' and treats the whole thing as one argument.  So, it prints
 args[[1]] as the whole thing id = 's1002', but prints blank for
 names(args[[1]]), obviously beacuse it cannot find a name for the argument.

 If I call extractArgs(id = 's1002') from the command line, it works just
 fine, prints the name of the argument as id and the actual argument as
 s1002, which is correct.

 How do I fix the problem so that when extractArgs() is called within
 getArgs(), it behaves the same way as getArgs() and extracts the argument
 and argument name?  Can we unstring passed or change it into another mode?

 I'll appreciate any help or pointers.  Thanks.  Aarti

 getArgs - function(...)
 {
cat(\nEntering getArgs()\n\n)

args - list(...)

cat(In getArgs(), names(args[1]) is )
cat(names(args[1]))
cat( and args[[1]] is )
cat(args[[1]])
cat(\n)

passed - paste(names(args),=, sQuote(args))

extractArgs(passed)

cat(Exiting getArgs()\n\n)
 }

 extractArgs - function(...)
 {
cat(\nEntering extractArgs()\n\n)

args - list(...)

cat(In extractArgs(), names(args[1]) is )
cat(names(args[1]))
cat( and args[[1]] is )
cat(args[[1]])
cat(\n)

cat(\nExiting extractArgs()\n\n)
 }

 Test:

 getArgs(id = 's1002')

 Entering getArgs()

 In getArgs(), names(args[1]) is id and args[[1]] is s1002

 Entering extractArgs()

 In extractArgs(), names(args[1]) is  and args[[1]] is id = 's1002'

 Exiting extractArgs()

 Exiting getArgs()

 extractArgs(id = 's1002')

 Entering extractArgs()

 In extractArgs(), names(args[1]) is id and args[[1]] is s1002

 Exiting extractArgs()

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


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


Re: [R] How to use a for loop to generate two sequences

2006-06-29 Thread Gabor Grothendieck
A vector of character strings:

  nm - paste(test, 1:1000, sep = )

A list whose components are the objects: test1, test2, ...

  lapply(nm, get)

or if you do it this way the list will have 'test1', 'test2', ... as the
component names:

  L - sapply(paste(test, 1:1000, sep = ), get, simplify = FALSE)

and then

  names(L)

gives the vector of names.


Also note that

  apropos(^test[0-9]+)

will give a vector of object names corresponding to objects
 in the current workspace whose names
are test followed by a number.

On 6/29/06, Xiaohua Dai [EMAIL PROTECTED] wrote:
 Hi R users,

 Hope the question is not too simple:

 How to use a for loop to generate two lists as below:

 testlist - list(test1, test2, ..., test1000)
 stringlist - list(test1,test2,...,test1000)

 Thanks
 Xiaohua

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


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


Re: [R] Reporting ppr fits and using them externally.

2006-06-29 Thread Robert Chatfield
A couple days of detective work have gone along way to reveal how one  
may
recover the actual knots and coefficients of the splines used in ppr.
It's not finished yet, but I may be due some mid-course correction.

First, ... I was asked, ... why?

On Jun 27, 2006, at 11:50 PM, Prof Brian Ripley wrote:

 It is normal to report smooth curves via plots of smooth curves.  
 There are examples for ppr in MASS4 p.241 (referenced on the help  
 page).  This is done by the plot() method.

 Please do consult the references in the documentation: those who  
 very carefully documented these tools put them there because they  
 do give additional information.

This  reading and plotting of course was all done before contacting r- 
help.

The plots of the smooth curves will be used to communicate with most  
readers of our
publication.  However, reviewers for J. Geophysical Research and  
Atmospheric Environment
will require specifics of the fit performed.  We hope that the  
results will be used
to greatly improve our understanding of smog ozone formation, and for  
field use,
the pure spline fit is required, unencumbered by the ~2000 fitted  
points of our estimation
data set.

So, we have found that (my colleague Bob E's words)
 Both smooth.spline and ppr, with spline or gcvspline option,
 eventually come to a call to qsbart.f. Therefore, find out
 which parameters ppr is using in the qsbart call, and
 determine which parameters to smooth.spline cause the
 same arguments to qsbart.


 From ppr, qsbart is called from at
 the end of the chain (some wrappers left out):
 ppr - smart1 - {subfit, fulfit} - onetrm - oneone - supsmu -  
 spline - qsbart
 Nearly all the code in the fortran routines deals with the
 supersmoother case.

 smooth.spline (stats/R/smspline.R) calls subroutine spline directly.

I have found that qsbart is  in this file  /library/stats/src/ 
sbart.c

and that the inputs and outputs seem to be clearly documented at the  
beginning
of the code:

 /* A Cubic B-spline Smoothing routine.

The algorithm minimises:

 (1/n) * sum ws(i)^2 * (ys(i)-sz(i))^2 + lambda* int  
 ( s(x) )^2 dx

lambda is a function of the spar which is assumed to be between  
 0 and 1

 INPUT
 -
penalt   A penalty  1 to be used in the gcv criterion
dofoff   either `df.offset' for GCV or `df' (to be matched).
nnumber of data points
ys(n)vector of length n containing the observations
ws(n)vector containing the weights given to each data point
xs(n)vector containing the ordinates of the observations
ssw  `centered weighted sum of y^2'
nk   number of b-spline coefficients to be estimated
 nk = n+2
knot(nk+4)   vector of knot points defining the cubic b-spline  
 basis.
 To obtain full cubic smoothing splines one might
 have (provided the xs-values are strictly increasing)
spar penalised likelihood smoothing parameter
isparindicating if spar is supplied (ispar=1) or to be  
 estimated
lspar, uspar lower and upper values for spar search;  0.,1. are  
 good values
tol, eps used in Golden Search routine
isetup   setup indicator [initially 0
icritindicator saying which cross validation score is to  
 be computed
 0: none ;  1: GCV ;  2: CV ;  3: 'df matching'
ld4  the leading dimension of abd (ie ld4=4)
ldnk the leading dimension of p2ip (not referenced)

 OUTPUT
 --
coef(nk) vector of spline coefficients
sz(n)vector of smoothed z-values
lev(n)   vector of leverages
crit either ordinary or generalized CV score
spar if ispar != 1
lspar == lambda (a function of spar and the design)
iter number of iterations needed for spar search (if  
 ispar != 1)
ier  error indicator
 ier = 0 ___  everything fine
 ier = 1 ___  spar too small or too big
 problem in cholesky decomposition

These are returned to the calling FORTRAN code (we should note the  
need to
respect FORTRAN-C array and call conventions).

So it remains for us to find either the results of the last call to  
qsbart.f
made from  subroutine spline (n, x, y, w, smo, edf) in  the ppr.f
code spline
   subroutine spline (n, x, y, w, smo, edf)
 c
 c--
 c
 c input:
 cn : number of observations.
 cx(n) : ordered abscissa values.
 cy(n) : corresponding ordinate (response) values.
 cw(n) : weight for each (x,y) observation.
 c output:
 c   smo(n) : smoothed ordinate (response) values.
 c   edf : equivalent degrees of freedom
 c
 c--

Note that coefficients are not passed back up from here.

The predict method in subroutine pppred(np,x,smod,y,sc) 

Re: [R] NLME Fitting

2006-06-29 Thread Spencer Graves
  I'm not certain what you want, but it sounds like the answer might be 
in '?nlme' help page.  Toward the end, it describes the 'Value' returned 
as follows:

an object of class 'nlme' representing the nonlinear mixed-effects
  model fit. Generic functions such as 'print', 'plot' and 'summary'
  have methods to show the results of the fit. See 'nlmeObject' for
  the components of the fit. The functions 'resid', 'coef',
  'fitted', 'fixed.effects', and 'random.effects'  can be used to
  extract some of its components.

  Also, 'str' might help you find what you want.

  Spencer Graves
p.s.  If you'd like further help from this listserve, PLEASE do read the 
posting guide! www.R-project.org/posting-guide.html.  This might help 
you write a question so it is easier for others to understand, thereby 
increasing the chances for a quick and useful reply.

F Monadjemi wrote:
 Dear Reader,
 
 Is it possible to extract the random part of nlme fitting analysis (non linear
 mixed effect model) i.e.sigma(b), in R?
 
 Thank you for respond
 
 
 Farinaz
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

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


Re: [R] How to use a for loop to generate two sequences

2006-06-29 Thread Xiaohua Dai
I followed your method but there was an error on FUN get:

 nm - paste(test, 1:1000, sep = )
 lapply(nm, get)
Error in get(x, envir, mode, inherits) : variable test1 was not found
 L - sapply(paste(test, 1:1000, sep = ), get, simplify = FALSE)
Error in get(x, envir, mode, inherits) : variable test1 was not found

But lapply(nm, as.name) worked well. Are there any problem with my R env?

 traceback()
2: FUN(X[[1]], ...)
1: lapply(nm, get)

 sessionInfo()
Version 2.3.1 (2006-06-01)
i386-pc-mingw32

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

 win.version()
[1] Windows XP Professional (build 2600) Service Pack 2.0


Thanks
Xiaohua


On 6/30/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
 A vector of character strings:

  nm - paste(test, 1:1000, sep = )

 A list whose components are the objects: test1, test2, ...

  lapply(nm, get)

 or if you do it this way the list will have 'test1', 'test2', ... as the
 component names:

  L - sapply(paste(test, 1:1000, sep = ), get, simplify = FALSE)

 and then

  names(L)

 gives the vector of names.


 Also note that

  apropos(^test[0-9]+)

 will give a vector of object names corresponding to objects
  in the current workspace whose names
 are test followed by a number.

 On 6/29/06, Xiaohua Dai [EMAIL PROTECTED] wrote:
  Hi R users,
 
  Hope the question is not too simple:
 
  How to use a for loop to generate two lists as below:
 
  testlist - list(test1, test2, ..., test1000)
  stringlist - list(test1,test2,...,test1000)
 
  Thanks
  Xiaohua
 
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide! 
  http://www.R-project.org/posting-guide.html
 

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


Re: [R] Extracting R plots from MS Word

2006-06-29 Thread maj
Thanks to all those who responded to my request about extracting R plots
from MS Word. I decided to try Gabor Grothendieck's second suggestion and
saved the Word document as html. (I may yet try some of the other
suggestions.)

Saving the .doc as .htm indeed produced a folder with many of the images
in .gif form. However some of my images seemed to be described by files
with .wmz or .emz extensions. I am not quite sure how to change these into
.gif or .eps or anything useful!

Cheers,  Murray Jorgensen

 Click the graphic, press ctrl-C to copy it to the clipboard and then
 using ctrl-V paste it into mspaint or Xnview (free, find it via google) or
 other
 graphics program and then save it from there.   Which program will
 work will depend on the format of the image.

 Another possibility is to save the Word file in HTML format.  In
 Word, choose File | SaveAs and choose the Save As Type to be Web Page.
 That will create an HTML file plus it will create a folder with
 one file per image.

 On 6/29/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 Hi,

 I am revising a paper that I am a co-author of. The figures are plots
 generated from R but at the moment I do not have the R code that
 generates
 them.

 As this is time critical I would like to slightly abuse the list by
 asking
 whether anyone knows how to extract from MS Word into a stand-alone
 graphics file a plot that was pasted into Word from R (probably as a
 Windows Metafile, but possibly as a bitmap).

 I would be very grateful for help with this.

 Regards,  Murray Jorgensen

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



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


Re: [R] Extracting R plots from MS Word

2006-06-29 Thread Gabor Grothendieck
I think these are zipped emf and wmf files.  Google for emz extension.

On 6/29/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 Thanks to all those who responded to my request about extracting R plots
 from MS Word. I decided to try Gabor Grothendieck's second suggestion and
 saved the Word document as html. (I may yet try some of the other
 suggestions.)

 Saving the .doc as .htm indeed produced a folder with many of the images
 in .gif form. However some of my images seemed to be described by files
 with .wmz or .emz extensions. I am not quite sure how to change these into
 .gif or .eps or anything useful!

 Cheers,  Murray Jorgensen

  Click the graphic, press ctrl-C to copy it to the clipboard and then
  using ctrl-V paste it into mspaint or Xnview (free, find it via google) or
  other
  graphics program and then save it from there.   Which program will
  work will depend on the format of the image.
 
  Another possibility is to save the Word file in HTML format.  In
  Word, choose File | SaveAs and choose the Save As Type to be Web Page.
  That will create an HTML file plus it will create a folder with
  one file per image.
 
  On 6/29/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
  Hi,
 
  I am revising a paper that I am a co-author of. The figures are plots
  generated from R but at the moment I do not have the R code that
  generates
  them.
 
  As this is time critical I would like to slightly abuse the list by
  asking
  whether anyone knows how to extract from MS Word into a stand-alone
  graphics file a plot that was pasted into Word from R (probably as a
  Windows Metafile, but possibly as a bitmap).
 
  I would be very grateful for help with this.
 
  Regards,  Murray Jorgensen
 
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide!
  http://www.R-project.org/posting-guide.html
 
 




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


Re: [R] How to use a for loop to generate two sequences

2006-06-29 Thread Gabor Grothendieck
On 6/29/06, Xiaohua Dai [EMAIL PROTECTED] wrote:
 I followed your method but there was an error on FUN get:

  nm - paste(test, 1:1000, sep = )
  lapply(nm, get)
 Error in get(x, envir, mode, inherits) : variable test1 was not found
  L - sapply(paste(test, 1:1000, sep = ), get, simplify = FALSE)
 Error in get(x, envir, mode, inherits) : variable test1 was not found

 But lapply(nm, as.name) worked well. Are there any problem with my R env?

These are different things.  Using as.name gives you a list of names
but I am assuming you are looking for a list of the objects themselves
so you need to have those objects defined.  Here is a reproducible
example:

 test1 - test2 - 1
 sapply(paste(test, 1:2, sep = ), get, simplify = FALSE)
$test1
[1] 1

$test2
[1] 1






  traceback()
 2: FUN(X[[1]], ...)
 1: lapply(nm, get)

  sessionInfo()
 Version 2.3.1 (2006-06-01)
 i386-pc-mingw32

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

  win.version()
 [1] Windows XP Professional (build 2600) Service Pack 2.0


 Thanks
 Xiaohua


 On 6/30/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
  A vector of character strings:
 
   nm - paste(test, 1:1000, sep = )
 
  A list whose components are the objects: test1, test2, ...
 
   lapply(nm, get)
 
  or if you do it this way the list will have 'test1', 'test2', ... as the
  component names:
 
   L - sapply(paste(test, 1:1000, sep = ), get, simplify = FALSE)
 
  and then
 
   names(L)
 
  gives the vector of names.
 
 
  Also note that
 
   apropos(^test[0-9]+)
 
  will give a vector of object names corresponding to objects
   in the current workspace whose names
  are test followed by a number.
 
  On 6/29/06, Xiaohua Dai [EMAIL PROTECTED] wrote:
   Hi R users,
  
   Hope the question is not too simple:
  
   How to use a for loop to generate two lists as below:
  
   testlist - list(test1, test2, ..., test1000)
   stringlist - list(test1,test2,...,test1000)
  
   Thanks
   Xiaohua
  
   __
   R-help@stat.math.ethz.ch mailing list
   https://stat.ethz.ch/mailman/listinfo/r-help
   PLEASE do read the posting guide! 
   http://www.R-project.org/posting-guide.html
  


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


[R] Trellis.par.set/ family/ global change font?

2006-06-29 Thread McClatchie, Sam \(PIRSA-SARDI\)
Background:
OS: Linux Ubuntu Dapper 6.06
release: R 2.3.1
editor: GNU Emacs 21.4.1
front-end: ESS 5.2.3
-

Colleagues

I have a rather complicated trellis plot that a journal editor has requested I 
edit and change all the fonts to times. 

I'd like to change all fonts globally for the plot, as in par(family=serif) 
for non-trellis plots. Various experiments with trellis.par.set after reading 
the help page have not solved the problem for me. Even doing the local change 
trellis.par.set(par.xlab.text=list(cex=1.5, family=serif)) does not change 
the font to times for xlab (I mean my syntax is wrong, not that there is a bug).

So I'm obviously misreading the help page or just missing the meaning. Any 
suggestions?

Thanks

Sam

Sam McClatchie,
Oceanography subprogram 
South Australian Aquatic Sciences Centre
PO Box 120, Henley Beach 5022
Adelaide, South Australia
email [EMAIL PROTECTED]
Cellular: 0431 304 497 
Telephone: (61-8) 8207 5448
FAX: (61-8) 8207 5481
Research home page http://www.members.iinet.net.au/~s.mcclatchie/
  
   /\
  ...xX(° 
 
   °)Xx
  /  \\
(((° 
  (((°   ...xX(°O°)Xx


[[alternative HTML version deleted]]

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

Re: [R] lme convergence

2006-06-29 Thread Spencer Graves
  Does anyone know how to obtain the 'returnObject' from an 'lme' run 
that fails to converge?  An argument of this name is described on the 
'lmeControl' help page as, a logical value indicating whether the 
fitted object should be returned when the maximum number of iterations 
is reached without convergence of the algorithm. Default is 'FALSE'.

  Unfortunately, I've so far been unable to get it to work, as 
witnessed by the following modification of an example from the '?lme' 
help page:

  library(nlme)
  fm1 - lme(distance ~ age, data = Orthodont,
+control=lmeControl(msMaxIter=1))
Error in lme.formula(distance ~ age, data = Orthodont, control = 
lmeControl(msMaxIter = 1)) :
iteration limit reached without convergence (9)
  fm1
Error: object fm1 not found
  fm1 - lme(distance ~ age, data = Orthodont,
+control=lmeControl(msMaxIter=1,
+  returnObject=TRUE))
Error in lme.formula(distance ~ age, data = Orthodont, control = 
lmeControl(msMaxIter = 1,  :
iteration limit reached without convergence (9)
  fm1
Error: object fm1 not found   

  I might be able to fix the problem myself, working through the 'lme' 
code line by line, e.g., using 'debug'.  However, I'm not ready to do 
that just now.

  Best Wishes,
  Spencer Graves

Ravi Varadhan wrote:
 Use try to capture error messages without breaking the loop.
 ?try
 
 --
 Ravi Varadhan, Ph.D.
 Assistant Professor,  The Center on Aging and Health
 Division of Geriatric Medicine and Gerontology
 Johns Hopkins University
 Ph: (410) 502-2619
 Fax: (410) 614-9625
 Email:  [EMAIL PROTECTED]
 Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html 
 --
 
 -Original Message-
 From: [EMAIL PROTECTED] [mailto:r-help-
 [EMAIL PROTECTED] On Behalf Of Pryseley Assam
 Sent: Wednesday, June 28, 2006 12:18 PM
 To: R-Users
 Subject: [R] lme convergence

 Dear R-Users,

   Is it possible to get the covariance matrix from an lme model that did
 not converge ?

   I am doing a simulation which entails fitting linear mixed models, using
 a for loop.
   Within each loop, i generate a new data set and analyze it using a mixed
 model.  The loop stops When the lme function does not converge for a
 simulated dataset. I want to inquire if there is a method to suppress the
 error message from the lme function, or better still, a way of going about
 this issue of the loop ending once the lme function does not converge.

   Thanks in advance,
   Pryseley


 -


  [[alternative HTML version deleted]]

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

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


[R] aggregate data.frame by one column

2006-06-29 Thread Guo Wei-Wei
Hi, everyone,

I have a data.frame named eva like this:

IND PARTNO VC1 EO1 EO2 EO3 EO4 EO5
114 114001   2   5   4   4   5   4
114 114001   2   4   4   4   4   4
114 114001   2   4  NA  NA  NA  NA
112 112002   2   3   3   6   2   6
112 112002   2   1   1   3   4   4
112 112003   2   6   6   6   5   6
112 112003   2   5   7   6   6   6
112 112003   2   6   6   6   4   5
114 114004   2   2   3   3   2   4
114 114004   2   5   3   4   4   2
114 114004   2  NA  NA  NA  NA  NA
113 113005   2   5   5   6   6   5
113 113005   2   7   7   4   7   6
111 111006   2   5   7   7   7   7
112 112007   2   7   7   7   2   2
112 112007   2   6   6   6   1   2
112 112007   2   7   6   6   2   2
111 111008   2   4   1   3   1   4
111 111008   2   3   1   5   3   2

This is only a small part of the whole data. PARTNO is a digit variable
and I want to use it as a group variable to aggreate other variables.
What I want to get looks like this:

IND PARTNO NUM VC1 EO1 EO2 EO3 EO4 EO5
114 114001   3   2 4.3   4   4 4.5   4
112 112002   2   2   2   2 4.5   3   5
112 112003   3   2 5.7 6.3   6   5 5.7
114 114004   3   2 3.5   3 3.5   3   3
113 113005   2   2   6   6   5 6.5 5.5
111 111006   1   2   5   7   7   7   7
112 112007   3   2 6.7 6.3 6.3 1.7   2
111 111008   2   2 3.5   1   4   2   3

NUM is a newly added variable which indicates the case number
of each group grouped by PARTNO.

I have two questions on this manipulation.

The first is how to get the newly added variable NUM. I have no idea
on this question.

The second is how to average other variables by group. If there are
NA, I want
the average operation is done on other cases. For example, the
variable EO1 has
values of 2, 5, and NA on case 114004. What I have done is

 aggregate(eva[,-2], by=eva[,-2], mean)

But it seems because there are NAs, the aggregate cannot process.
Because the NA values are not a small part, I cannot use imputation
methods. I'm not sure whether my operation is right.

Does anyone have any suggestion on the two problems? Thanks in advance!

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


Re: [R] Trellis.par.set/ family/ global change font?

2006-06-29 Thread Deepayan Sarkar
On 6/29/06, McClatchie, Sam (PIRSA-SARDI)
[EMAIL PROTECTED] wrote:
 Background:
 OS: Linux Ubuntu Dapper 6.06
 release: R 2.3.1
 editor: GNU Emacs 21.4.1
 front-end: ESS 5.2.3
 -

 Colleagues

 I have a rather complicated trellis plot that a journal editor has requested 
 I edit and change all the fonts to times.

 I'd like to change all fonts globally for the plot, as in par(family=serif) 
 for non-trellis plots. Various experiments with trellis.par.set after reading 
 the help page have not solved the problem for me. Even doing the local change
 trellis.par.set(par.xlab.text=list(cex=1.5, family=serif)) does not change 
 the font to times for xlab (I mean my syntax is wrong, not that there is a 
 bug).

 So I'm obviously misreading the help page or just missing the meaning. Any 
 suggestions?

Lattice uses 'fontfamily' rather than 'family' (borrowed from grid, I
suppose). I don't think there's a way to set the family globally. You
might try

trellis.par.set(grid.pars = list(fontfamily = serif))

but I'm not sure if that will work.

-Deepayan

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


Re: [R] aggregate data.frame by one column

2006-06-29 Thread Andrew Robinson
Hi Wei-Wei,

try this:

eva.agg - aggregate(x = list(
   VC1=eva$VC1,
   EO1=eva$EO1,
   EO2=eva$EO2,
   EO3=eva$EO3,
   EO4=eva$EO4,
   EO5=eva$EO5
   ),
 by = list(PARTNO=eva$PARTNO),
 FUN = mean, na.rm = TRUE)

eva.agg$NUM - aggregate(eva$PARTNO, list(eva$PARTNO), length)


Cheers

Andrew


On Fri, Jun 30, 2006 at 10:54:47AM +0800, Guo Wei-Wei wrote:
 Hi, everyone,
 
 I have a data.frame named eva like this:
 
 IND PARTNO VC1 EO1 EO2 EO3 EO4 EO5
 114 114001   2   5   4   4   5   4
 114 114001   2   4   4   4   4   4
 114 114001   2   4  NA  NA  NA  NA
 112 112002   2   3   3   6   2   6
 112 112002   2   1   1   3   4   4
 112 112003   2   6   6   6   5   6
 112 112003   2   5   7   6   6   6
 112 112003   2   6   6   6   4   5
 114 114004   2   2   3   3   2   4
 114 114004   2   5   3   4   4   2
 114 114004   2  NA  NA  NA  NA  NA
 113 113005   2   5   5   6   6   5
 113 113005   2   7   7   4   7   6
 111 111006   2   5   7   7   7   7
 112 112007   2   7   7   7   2   2
 112 112007   2   6   6   6   1   2
 112 112007   2   7   6   6   2   2
 111 111008   2   4   1   3   1   4
 111 111008   2   3   1   5   3   2
 
 This is only a small part of the whole data. PARTNO is a digit variable
 and I want to use it as a group variable to aggreate other variables.
 What I want to get looks like this:
 
 IND PARTNO NUM VC1 EO1 EO2 EO3 EO4 EO5
 114 114001   3   2 4.3   4   4 4.5   4
 112 112002   2   2   2   2 4.5   3   5
 112 112003   3   2 5.7 6.3   6   5 5.7
 114 114004   3   2 3.5   3 3.5   3   3
 113 113005   2   2   6   6   5 6.5 5.5
 111 111006   1   2   5   7   7   7   7
 112 112007   3   2 6.7 6.3 6.3 1.7   2
 111 111008   2   2 3.5   1   4   2   3
 
 NUM is a newly added variable which indicates the case number
 of each group grouped by PARTNO.
 
 I have two questions on this manipulation.
 
 The first is how to get the newly added variable NUM. I have no idea
 on this question.
 
 The second is how to average other variables by group. If there are
 NA, I want
 the average operation is done on other cases. For example, the
 variable EO1 has
 values of 2, 5, and NA on case 114004. What I have done is
 
  aggregate(eva[,-2], by=eva[,-2], mean)
 
 But it seems because there are NAs, the aggregate cannot process.
 Because the NA values are not a small part, I cannot use imputation
 methods. I'm not sure whether my operation is right.
 
 Does anyone have any suggestion on the two problems? Thanks in advance!
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

-- 
Andrew Robinson  
Department of Mathematics and StatisticsTel: +61-3-8344-9763
University of Melbourne, VIC 3010 Australia Fax: +61-3-8344-4599
Email: [EMAIL PROTECTED] http://www.ms.unimelb.edu.au

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


Re: [R] aggregate data.frame by one column

2006-06-29 Thread Guo Wei-Wei
Hi Andrew,

Thank you very much! It works so well than I can expect.

All the best,
Wei-Wei

2006/6/30, Andrew Robinson [EMAIL PROTECTED]:
 Hi Wei-Wei,

 try this:

 eva.agg - aggregate(x = list(
VC1=eva$VC1,
EO1=eva$EO1,
EO2=eva$EO2,
EO3=eva$EO3,
EO4=eva$EO4,
EO5=eva$EO5
),
  by = list(PARTNO=eva$PARTNO),
  FUN = mean, na.rm = TRUE)

 eva.agg$NUM - aggregate(eva$PARTNO, list(eva$PARTNO), length)

 Cheers

 Andrew


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


[R] Empirical CDF

2006-06-29 Thread Augusto.Sanabria

Good day everyone,

I want to assess the error when fitting a Gram-Charlier
CDF to some data 'ws', that is, I want to calculate:

 Err = |ecdf(ws) - GCh_ser(ws)|

The problem is, I cannot get the F(x) values from the
ecdf.

'Summary(ecdf())' returns some of the x-axis values,
but how do you get the F(x) values?

Thank you for any help you can provide.

Regards,

Augusto



Augusto Sanabria. MSc, PhD.
Mathematical Modeller
Risk Research Group
Geospatial  Earth Monitoring Division
Geoscience Australia (www.ga.gov.au)
Cnr. Jerrabomberra Av.  Hindmarsh Dr.
Symonston ACT 2609
Ph. (02) 6249-9155

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