[R] Accidental misuse of 'R-packages' list

2010-05-18 Thread Martin Maechler
This should never have been on R-packages.
I (as moderator) apologize the glitch in moderation.

This is *not* CC'ed to that list, as it really really is only
for *announcements* of new or vastly changed packages available
from CRAN.
Apropos:  Please, package authors, keep those low volume: A
good rule is to not mention a pacakge more than once a year, 
and much less than that for all packages with only minor changes.

Martin Maechler, ETH Zurich 

 MY == Matt Young youngsan...@gmail.com
 on Wed, 12 May 2010 08:23:24 -0700 writes:

MY Lot of examples for one way pipes, but I need to create
MY some named pipes from R to another process, especially
MY SQLite.  I am look at the R/SQLite packages for help.
MY ANy pointers?

MY ___
MY R-packages mailing list r-packa...@r-project.org
MY https://stat.ethz.ch/mailman/listinfo/r-packages

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


Re: [R] issues with R Library on a Server

2010-05-18 Thread Henrik Bengtsson
On Tue, May 18, 2010 at 4:03 AM, Daisy Englert Duursma
daisy.duur...@gmail.com wrote:
 Hello,

 I am a bit over my head on this issue. My colleagues and I are running
 R off of our server. We all have admin rights and prior to yesterday
 we all had our own libraries. Our main system administrator advised us
 that we should have a shared library. So, I am trying to do this.

  I have downloaded the latest version of R and installed it on the
 main drive of our server in the  Program Files folder (obvious
 enough).

 I changed the Environmental Variables in the advanced system setting
 so R_LIBS  is C:\\RLIBRARY and restarted the server.

 The command : .libPaths()[1] results in
 [1] C:\\RLIBRARY

 When I install packages it returns the message :The downloaded packages are in
        C:\Users\Daisy
 Englert\AppData\Local\Temp\2\Rtmp9FxLip\downloaded_packages

 ** This is bad because I though they should go to C:\\RLIBRARY (I think)

 Thus the following code does not work:

 library(nnet)
 Error in get(Info[i, 1], envir = env) :
  internal error -3 in R_decompress1
 Error: package/namespace load failed for 'nnet'


 My questions are:

 Why are the packages downloading to the above location?

That is where R *downloads* the package files (for temporary storage),
but it is not where they are installed.  By default, they are
installed in the (first possible, I think) path of .libPaths().

You can see the installation path by, for instance,

packageDescription(base);

and

packageDescription(nnet);

 What is the next step(s) I should take to setting up the server correctly.

From the error message above, you might experience a particular issue
with the 'nnet' package.  Try to install another package and see if
that works.

My $.02

/Henrik




 Thanks,
 Daisy





 --
 Daisy Englert Duursma

 Room E8C156
 Dept. Biological Sciences
 Macquarie University  NSW  2109
 Australia

 Tel +61 2 9850 9256



 10A Carrington Rd
 Hornsby, NSW 2077

 Mobile: 0421858456

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


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


[R] GUI commands to call for a protein from protein data bank

2010-05-18 Thread Amitoj S. Chopra


What I am trying to do is use GUI function, traitr, and to call for a pdb
file and save it and then display it. I want to call for it by taking it
from the user and then displaying it on the screen. I am having problems
with that. The line pdb - read.pdb(ProteinCode) where proteincode should
be the name of the protein, for example 1ly2, but it always ends up being
protein. My question is how to you make the input for read.pdb actually be
the input by the user and not protein code. I want to be able to type 1ly2,
and for the program to actually display the contents of 1ly2. Thanks!




Code:

dlg - aDialog(items=list(
ProteinCode=stringItem()
),
OK_handler=function(.) { # . is reference to dlg object
values - .$to_R()
f - function(ProteinCode)
pdb - read.pdb(ProteinCode)
do.call(f, values)
}
)
dlg$make_gui()
-- 
View this message in context: 
http://r.789695.n4.nabble.com/GUI-commands-to-call-for-a-protein-from-protein-data-bank-tp2220754p2220754.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] A problem in allocation of vector of size

2010-05-18 Thread Yan Li
Hi, r-users


I happen to a problem in allocation of vector of size. When I run my R
script, an error appears:


Error: cannot allocate vector of size 450 Mb


Could anyone happen to the same problem? Thank you for your help.


Lee

[[alternative HTML version deleted]]

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


Re: [R] Robust SE Heteroskedasticity-consistent estimation

2010-05-18 Thread RATIARISON Eric
Thanks all of you.


-Message d'origine-
De : Arne Henningsen [mailto:arne.henning...@googlemail.com] 
Envoyé : mardi 18 mai 2010 06:00
À : RATIARISON Eric
Cc : r-help@r-project.org; Ott-Siim Toomet; Achim Zeileis
Objet : Re: [R] Robust SE  Heteroskedasticity-consistent estimation

On 17 May 2010 22:55, RATIARISON Eric eratiari...@monceauassurances.com wrote:
 It's ok Arne, i've build the MS windows binary.

 And the result is ok (sandwich function runs)with this next modifications in 
 my user specified functions
 But with the following functions (individual one):


 sc= as.vector( c(log(mean(v)),rep(0,dim(z)[2]-1)))

 loglik - function(param)  {
   b-param
   m=as.vector(of+z%*%b)
   ll - (v*m-exp(m))   } # no sum

 gradlik - function(param) {
     b-param
     m=as.vector(of+z%*%b)
     gg -(v-exp(m))*z      } #here I've replaced %*% by *

 hesslik - function(param) {
     b-param
     m=as.vector(of+z%*%b)
     hh - -t(exp(m)*z)%*%z }

 resMaxlik - maxLik(loglik,grad=gradlik,hess=hesslik,start=sc,method=nr)

 however, I've a question again about bread function. Does it use the  result 
 of hessian defined by user?

Yes.

 When I do all.equal(vcov(resMaxlik),inv(resMaxlik$hessian))
 I've this message : [1] Mean relative difference: 2 what does it means?

The covariance matrix is the inverse of the *negative* Hessian. So
   all.equal(vcov(resMaxlik),solve(-hessian(resMaxlik)))
should return TRUE

 Lastly, in the last official manual Maxlik.pdf, the sentence However, no 
 attempt is made to correct the resulting variance-covariance matrix

Do you mean this paragraph?

 'maxLik' support constrained optimization in the sense that
 constraints are passed further to the underlying optimization
 routines, and suitable default method is selected.  However, no
 attempt is made to correct the resulting variance-covariance
 matrix.  Hence, the inference may be wrong.  A corresponding
 warning is issued by the summary method.

This means that the constraints are not taken into account when maxLik
calculates the covariance matrix of the estimates -- the constraints
are simply ignored.

 Should be corrected with possible use of sandwich should'nt it?

I don't think that just using the sandwich method is sufficient to
calculate consistent covariance matrices, when there are (equality or
inequality) constraints on the parameters.

/Arne

 -Message d'origine-
 De : Arne Henningsen [mailto:arne.henning...@googlemail.com]
 Envoyé : lundi 17 mai 2010 17:58
 À : RATIARISON Eric
 Objet : Re: [R] Robust SE  Heteroskedasticity-consistent estimation

 On 17 May 2010 17:35, RATIARISON Eric eratiari...@monceauassurances.com 
 wrote:
 Thank you Arne,
 I'm working on PC computer at my work with firewall.
 How can I reach the new version for testing (in comparing with the gauss 
 procedure named CML) ?
 I don't understand the link joined.

 I have attached the package. You can easily install it if you (also) have a 
 Unix-like OS. If you have MS-Windows, I could build a MS-Windows binary 
 package on http://win-builder.r-project.org/ tomorrow (or you could change 
 the maintainer field and do it yourself).

 /Arne



 -Message d'origine-
 De : Arne Henningsen [mailto:arne.henning...@googlemail.com]
 Envoyé : lundi 17 mai 2010 17:12
 À : RATIARISON Eric
 Cc : Achim Zeileis; r-help@r-project.org; Ott-Siim Toomet Objet : Re:
 [R] Robust SE  Heteroskedasticity-consistent estimation

 On 13 May 2010 00:41, RATIARISON Eric eratiari...@monceauassurances.com 
 wrote:
 Hi, here my new version:
 I submit you my case:
 ( Pseudo likehood for exponential family with offset )

 loglik - function(param)  {
   b-param
   m=as.vector(of+z%*%b)
   ll - sum(v*m-exp(m))   }

 gradlik - function(param) {
     b-param
     m=as.vector(of+z%*%b)
     gg-(v-exp(m))*z      }

 hesslik - function(param) {
     b-param
     m=as.vector(of+z%*%b)
     hh - -t(exp(m)*z)*z }

 resMaxlik -
 maxLik(loglik,grad=gradlik,hess=hesslik,start=sc,method=nr,tol=1e-4
 );

 resMaxlik$offset-of
 resMaxlik$x-z
 resMaxlik$y-v



 estfun - function(obj,...)
 {
 m=as.vector(obj$offset+obj$x%*%obj$estimate)
 (obj$y-exp(m))*obj$x
 }

 M - function(obj, adjust = FALSE, ...) { psi - estfun(obj) k -
 NCOL(psi) n - NROW(psi) rval - crossprod(as.matrix(psi))/n
 if(adjust) rval - n/(n - k) * rval
 rval
 }


 B - function(obj, ...)
 { as.matrix(ginv(obj$hessian))
 }


 So S -B(resMaxlik)*M(resMaxlik)*B(resMaxlik) directly. It's ok.

 But I call sandwich function like this :
 sandwich(resMaxlik,meat.=M,bread.=B)
 It returns a error message : Erreur dans UseMethod(estfun) :
  pas de méthode pour 'estfun' applicable pour un objet de classe 
 c('maxLik', 'maxim', 'list')

 I have added an estfun() method and a bread() method for objects of
 class maxLik so that you can use sandwich now.

 Please note:

 a) The methods can be applied only if maxLik() was called with
 argument grad equal to a gradient function or (if no gradient
 function is 

Re: [R] lme4 + R 2.11.0 + mac unavailable

2010-05-18 Thread Martin Maechler
 David Winsemius dwinsem...@comcast.net
 on Mon, 17 May 2010 17:44:00 -0400 writes:

 On May 17, 2010, at 5:01 PM, Adam November wrote:

 I believe I'm working with the newest version of R
 (2.11.0) and I've tried a few of the most recent
 versions... No luck yet.

 Luck has nothing to do with it. What part of ERROR in the
 CRAN package check for the current version of lme4 with
 the Mac R 2.11.0 don't you understand? Packages that
 generate errors are not made available as binaries.

 I was giving you advice about how to deal with the stated
 difficulty with installing lme4 from source using the
 older versions of R. Only if you want to revert to 2.10.1
 and install a prior version for lme4 would my advice be
 helpful.

 -- 
 David.

Doug Bates and I had recently been contacted by another Mac user
about this.
Doug advised him to install  lme4  from the sources and
he was immediately successful.

In the light of this, I'm a bit puzzled about the harsh words
David is using with respect to the cohabitation of R 2.11.0
and lme4.

Simultaneously, we have been in contact with Simon Urbanek
trying to investigate why the 'R CMD check' tests fail on OSX
(http://www.r-project.org/nosvn/R.check/r-release-macosx-ix86/lme4-00check.html)
A conclusion/solution has not been found yet,
but as I said above, the advice to install from the source

   install.packages(lme4, type = source)

One possible caveat -- as lme4 uses the C API of Matrix (including
the C header (include) files it exports) --
is that for the above way of installation,
you need to install into the (or a) library where Matrix is
installed.
For those who only use one library, this will not be
a concern.  Others could use the fact that MacOSX is a kind of Unix
and you can simply symlink Matrix (from the R standard
library) into the library into which you want to install lme4
{  cd mylibrary
   ln -s `R RHOME`/library/Matrix . 
}

Martin Maechler, ETH Zurich

 Thanks, -Adam
 
 On Mon, May 17, 2010 at 1:51 PM, David Winsemius
 dwinsem...@comcast.net  wrote:
 
 On May 17, 2010, at 4:44 PM, Adam November wrote:
 
 Hi All, Just thought I'd bring attention to the fact
 that lme4 is failing cran checks on the mac platform,
 and I can't seem to install it from source on 10.5 or
 10.6, either (ld: library not found for -lgfortran )
 .  Any help getting this working?  Thanks!
 
 You would not expect the current package to install
 properly with earlier versions of r. Find the
 appropriate version at the archive:
 
 http://cran.r-project.org/src/contrib/Archive/lme4/
 
 --
 
 David Winsemius, MD West Hartford, CT

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


Re: [R] Compiling R with --enable-R-shlib for rpy2 error

2010-05-18 Thread Padma TAN
Thanks for the help! :)


Regards,
Padma Tan

Genome Institute of Singapore
60 Biopolis Street, Genome
#02-01 Singapore 138672
DID : 6478 8671
Fax : 6478 9058
email: ta...@gis.a-star.edu.sg
 

This email is confidential and may be privileged. If you are not the intended 
recipient, please delete it and notify us immediately. Please do not copy or 
use it for any purpose, or disclose its contents to any other person. Thank you.
--



-Original Message-
From: Uwe Ligges [mailto:lig...@statistik.tu-dortmund.de]
Sent: Monday, May 17, 2010 4:38 PM
To: Padma TAN
Cc: r-h...@r-project.org.
Subject: Re: [R] Compiling R with --enable-R-shlib for rpy2 error



On 17.05.2010 05:22, Padma TAN wrote:
 Hi,

 Thanks! :)

 I'll install the newer version of R. However do I have to recompile all the 
 modules that I did for my previous version of R?



If you use the same library (or a copy of it) you used for packages
under the old R version, then update.packages(checkBuilt=TRUE) should
update all packages that need recompilation for you.

For details, please see the R Installation and Administration manual.

Best wishes,
Uwe Ligges





 Regards,
 Padma Tan

 Genome Institute of Singapore
 60 Biopolis Street, Genome
 #02-01 Singapore 138672
 DID : 6478 8671
 Fax : 6478 9058
 email: ta...@gis.a-star.edu.sg
   
 
 This email is confidential and may be privileged. If you are not the intended 
 recipient, please delete it and notify us immediately. Please do not copy or 
 use it for any purpose, or disclose its contents to any other person. Thank 
 you.
 --



 -Original Message-
 From: Uwe Ligges [mailto:lig...@statistik.tu-dortmund.de]
 Sent: Friday, May 14, 2010 3:09 PM
 To: Padma TAN
 Cc: r-h...@r-project.org.
 Subject: Re: [R] Compiling R with --enable-R-shlib for rpy2 error



 On 14.05.2010 05:07, Padma TAN wrote:
 Hi,

 Thanks for the reply!

 I am not sure if I did correctly. Now I configure with the following.

 ./configure --prefix=/usr/local/R/R-2.9.2 --with-gnu-ld --with-cairo 
 --with-x --enable-R-fPIC


 Then you forgot --enable-R-shlib if you need it and I cannot find (in
 recent R) a hint that --enable-R-fPIC is a supported feature.
 Really, can't you use a recent version of R (2.9.2 is somewhat outdated
 now)?


 Uwe Ligges


 Make and make install with no errors. However when I install rpy2, it states 
 that R was not built as a library

 [r...@plap03 rpy2-2.1.1]# python setup.py install
 running install
 running build
 running build_py
 running build_ext
 R was not built as a library
 Traceback (most recent call last):
 File setup.py, line 302, inmodule
   [os.path.join('doc', 'source', 'rpy2_logo.png')])]
 File /usr/local/python2.6/lib/python2.6/distutils/core.py, line 152, 
 in setup
   dist.run_commands()
 File /usr/local/python2.6/lib/python2.6/distutils/dist.py, line 975, 
 in run_commands
   self.run_command(cmd)
 File /usr/local/python2.6/lib/python2.6/distutils/dist.py, line 995, 
 in run_command
   cmd_obj.run()
 File /usr/local/python2.6/lib/python2.6/distutils/command/install.py, 
 line 577, in run
   self.run_command('build')
 File /usr/local/python2.6/lib/python2.6/distutils/cmd.py, line 333, in 
 run_command
   self.distribution.run_command(command)
 File /usr/local/python2.6/lib/python2.6/distutils/dist.py, line 995, 
 in run_command
   cmd_obj.run()
 File /usr/local/python2.6/lib/python2.6/distutils/command/build.py, 
 line 134, in run
   self.run_command(cmd_name)
 File /usr/local/python2.6/lib/python2.6/distutils/cmd.py, line 333, in 
 run_command
   self.distribution.run_command(command)
 File /usr/local/python2.6/lib/python2.6/distutils/dist.py, line 994, 
 in run_command
   cmd_obj.ensure_finalized()
 File /usr/local/python2.6/lib/python2.6/distutils/cmd.py, line 117, in 
 ensure_finalized
   self.finalize_options()
 File setup.py, line 121, in finalize_options
   include_dirs = get_rconfig(r_home, '--cppflags')[0].split()
 File setup.py, line 196, in get_rconfig
   raise Exception(cmd + '\nreturned\n' + rconfig)
 Exception: /usr/local/R/R-2.9.2/lib64/R/bin/R CMD config --cppflags
 returned


 Thanks again :)




 Regards,
 Padma

 On 5/13/10 11:30 PM, Uwe Liggeslig...@statistik.tu-dortmund.de   wrote:




 On 13.05.2010 11:45, Padma TAN wrote:
 Hi,

 I am trying to 

[R] how to select rows per subset in a data frame that are max. w.r.t. a column

2010-05-18 Thread Tim Van den Bulcke
Hi,


I'd like to select one row in a data frame per subset which is maximal for a
particular value. I'm pretty close to the solution in the sense that I can
easily select the maximal values per subset using aggregate, but I can't
really figure out how to select the rows in the original data frame that are
associated with these maximal values.


library(stats)
# this returns the list with maximal values for breaks per wool/tension
subset
maxValues = aggregate(warpbreaks$breaks, list(wool = wool, tension =
tension), max)

# now i'd like the subset of the rows in warpbreaks that are associated with
these maximal values



Thank you in advance!

Tim.

[[alternative HTML version deleted]]

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


Re: [R] how to select rows per subset in a data frame that are max. w.r.t. a column

2010-05-18 Thread Ivan Calandra

Hi,

Maybe it's just me but I don't understand what you're trying to do.
Isn't maxValues what you need?
Providing a reproducible example with your data (using the function 
dput), the desired output, and the code you've tried would really help!


Ivan

Le 5/18/2010 10:58, Tim Van den Bulcke a écrit :

Hi,


I'd like to select one row in a data frame per subset which is maximal for a
particular value. I'm pretty close to the solution in the sense that I can
easily select the maximal values per subset using aggregate, but I can't
really figure out how to select the rows in the original data frame that are
associated with these maximal values.


library(stats)
# this returns the list with maximal values for breaks per wool/tension
subset
maxValues = aggregate(warpbreaks$breaks, list(wool = wool, tension =
tension), max)

# now i'd like the subset of the rows in warpbreaks that are associated with
these maximal values



Thank you in advance!

Tim.

[[alternative HTML version deleted]]

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

   


--
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Museum
Abt. Säugetiere
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231
ivan.calan...@uni-hamburg.de

**
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php

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


Re: [R] Create counter variable for subsets without a loop

2010-05-18 Thread Bart Joosen

take a look at the by, ave, aggregate and apply functions, perhaps one suits
your needs

Bart
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Create-counter-variable-for-subsets-without-a-loop-tp2220663p2220925.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Change order of columns in table?

2010-05-18 Thread Jim Lemon

On 05/17/2010 10:46 PM, someone wrote:


I'm an R noob and have a (maybe) stupid question...
I have a table where I have the weekdays and a number for each weekday of
entries:
Thats what the table looks like...
Now I want to have an pie3D plot of this, but obviously the order of the
weekdays are not as one would expect...
FridayMonday  SaturdaySunday  Thursday   Tuesday Wednesday
   119   17380   96   167193
194

how can I rearrange the cols so that its the usal way: monday first, then
tuesday and so on...


Hi someone,
The old default alphabetical order gotcha, huh? Well, let's just turn 
the table on that there sneaky varmint.


1) I reckon that the old woman (the crone) who sets up this table is 
always gonna do it that way, 'cause ya cain't teach an old crone new tricks.


2) We'll make up a little vector of numbers that'll recombobulate the 
table, and we won't tell the old crone.


recombobulate-c(2,6,7,5,1,3,4)

3) Then we'll feed 'er right into pie3D just like this:

pie3D(weekly[recombobulate],labels=names(weekly)[recombobulate],
 main=Yer table recombobulated)

Jim

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


[R] [RGL] Need help to modify current plot

2010-05-18 Thread Megh Dal
Dear folks, I have created a plot on RGL device :
 
x = 1:6
y = seq(-12, 5, by=1)
z = matrix(0, length(y), length(x))
z[13,3] = 1; z[13,4] = 1.011765
surface3d(x, y, t(z), col=rainbow(1000))
grid3d(c(x-, y-, z))
 
Now I want to draw 2 lines along x=3  x=4, over the surface (with different 
colour). Could somebody help me how to draw that?
 
Thanks,


  
[[alternative HTML version deleted]]

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


Re: [R] [RGL] Need help to modify current plot

2010-05-18 Thread Duncan Murdoch

Megh Dal wrote:

Dear folks, I have created a plot on RGL device :
 
x = 1:6

y = seq(-12, 5, by=1)
z = matrix(0, length(y), length(x))
z[13,3] = 1; z[13,4] = 1.011765
surface3d(x, y, t(z), col=rainbow(1000))
grid3d(c(x-, y-, z))
 
Now I want to draw 2 lines along x=3  x=4, over the surface (with different colour). Could somebody help me how to draw that?
 
  


x=3 and x=4 specify planes, not lines, so you'll need to give more 
information to choose lines.  Here's one possibility:


save - par3d(ignoreExtent=TRUE)
segments3d(c(3,3,4,4), c(min(y), max(y), min(y), max(y)), c(max(z), 
max(z), max(z), max(z)), col=red)

par3d(save)

Duncan Murdoch

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


Re: [R] Graphing Titration Curves, how to graph in R

2010-05-18 Thread Jim Lemon

On 05/18/2010 06:54 AM, Amitoj S. Chopra wrote:


I am working on a script with R to calculate pKa values. I want to be able
then to graph pKa values to Energy, basically two variables which will give
me titration curves. It is basically a graph with two variables and help
with just graphing it will be just fine. But if anyone is familiar with
titration curves and R, that would be really great if they can help me out!
Are there any resources out there to help with doing this, how to create a
graph with pKa values. Thanks!



Hi Amitoj,
Most of the titration curves I found could be produced with some 
variation of:


plot(volume,pH,type=l,...)

there is a specialized (free) plotting package here:

www2.iq.usp.br/docente/gutz/Curtipot-.html

Jim

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


Re: [R] Graphing Titration Curves, how to graph in R

2010-05-18 Thread Jim Lemon

Hi Amitoj,
Also look at the AquaEnv and titan packages.

Jim

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


Re: [R] [RGL] Need help to modify current plot

2010-05-18 Thread Duncan Murdoch

On 18/05/2010 6:46 AM, Megh Dal wrote:

Thanks Duncan for your reply. This could definitely be an answer of my query 
however I wanted something else. What I want is to draw 2 lines over the 
surface which pass through x=3,4
  


That's even more ambiguous than your original request, so I won't try to 
code it.  The general solution to draw a line segment is to work out end 
points (x1,y1,z1) and (x2,y2,z2), and then call


segments3d(c(x1,x2), c(y1,y2), c(z1, z2), ...)

where the ... specifies things like the colour, etc.

Duncan Murdoch
 
Any better idea?
 
Thanks,

--- On Tue, 5/18/10, Duncan Murdoch murdoch.dun...@gmail.com wrote:


From: Duncan Murdoch murdoch.dun...@gmail.com
Subject: Re: [R] [RGL] Need help to modify current plot
To: Megh Dal megh700...@yahoo.com
Cc: r-h...@stat.math.ethz.ch
Date: Tuesday, May 18, 2010, 3:51 PM


Megh Dal wrote:
  

Dear folks, I have created a plot on RGL device :
  x = 1:6
y = seq(-12, 5, by=1)
z = matrix(0, length(y), length(x))
z[13,3] = 1; z[13,4] = 1.011765
surface3d(x, y, t(z), col=rainbow(1000))
grid3d(c(x-, y-, z))
  Now I want to draw 2 lines along x=3  x=4, over the surface (with different 
colour). Could somebody help me how to draw that?




x=3 and x=4 specify planes, not lines, so you'll need to give more information 
to choose lines.  Here's one possibility:

save - par3d(ignoreExtent=TRUE)
segments3d(c(3,3,4,4), c(min(y), max(y), min(y), max(y)), c(max(z), max(z), max(z), 
max(z)), col=red)
par3d(save)

Duncan Murdoch



  



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


Re: [R] [R-sig-DB] Package RPostgreSQL : Problem with dbWriteTable

2010-05-18 Thread Sean Davis
On Wed, May 12, 2010 at 2:44 AM, PALMIER Patrick - CETE NP/INFRA/TRF 
patrick.palm...@developpement-durable.gouv.fr wrote:

 Hello,

 I have a probem with dbWriteTable method of package RPostrgreSQL
 The table is well added in the database but R doesn't succeed in
 inserting rows
 But If I send the COPY FROM  as an sql query in  R, the rows are then
 well added
 I think it is a problem with the temp file create by dbWriteTable

 As anyone solved this problem?


Hi, Patrick.

A reproducible example and the output of sessionInfo() would be useful here.

Sean

[[alternative HTML version deleted]]

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


Re: [R] how to select rows per subset in a data frame that are max. w.r.t. a column

2010-05-18 Thread Dennis Murphy
Hi:

Here are a couple of ways using the doBy and plyr packages:

library(doBy)
library(plyr)

# doBy:
subsetBy(~ wool + tension, subset = breaks == max(breaks), data =
warpbreaks)

breaks wool tension
A|H 43A   H
A|L 70A   L
A|M 36A   M
B|H 28B   H
B|L 44B   L
B|M 42B   M

# plyr
ddply(warpbreaks, .(wool, tension), subset, breaks == max(breaks))

  breaks wool tension
1 70A   L
2 36A   M
3 43A   H
4 44B   L
5 42B   M
6 28B   H

HTH,
Dennis

On Tue, May 18, 2010 at 1:58 AM, Tim Van den Bulcke 
vandenbulcke...@gmail.com wrote:

 Hi,


 I'd like to select one row in a data frame per subset which is maximal for
 a
 particular value. I'm pretty close to the solution in the sense that I can
 easily select the maximal values per subset using aggregate, but I can't
 really figure out how to select the rows in the original data frame that
 are
 associated with these maximal values.


 library(stats)
 # this returns the list with maximal values for breaks per wool/tension
 subset
 maxValues = aggregate(warpbreaks$breaks, list(wool = wool, tension =
 tension), max)

 # now i'd like the subset of the rows in warpbreaks that are associated
 with
 these maximal values



 Thank you in advance!

 Tim.

[[alternative HTML version deleted]]

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


[[alternative HTML version deleted]]

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


Re: [R] Create counter variable for subsets without a loop

2010-05-18 Thread Gabor Grothendieck
Here are four solutions:

data - cbind(state.region,as.data.frame(state.x77))[,1:2]

# ave
data2 - data[order(data$state.region, -data$Population), ]
data2$rank - ave(data2$Population, data2$state.region, FUN = seq_len))

# by
f - function(x) cbind(x[order(-x$Population), ], rank = 1:nrow(x))
do.call(rbind, by(data, data$state.region, f))

# ddply - same f as in by solution
library(plyr)
ddply(data, .(state.region), f)

# sqldf with PostgreSQL
library(RpgSQL)
library(sqldf)
sqldf('select
   *, rank() over (partition by state.region order by Population desc)
   from data
   order by state.region, Population desc')


On Mon, May 17, 2010 at 5:32 PM, Thomas Brambor tbram...@stanford.edu wrote:
 Hi all,

 I am looking to create a rank variable based on a continuous variable
 for subsets of the data. For example, for an R integrated data set
 about US states this is how a loop could create what I want:

 ### Example with loop
 data - cbind(state.region,as.data.frame(state.x77))[,1:2]     #
 choosing a subset of the data
 data - data[order(data$state.region, 1/data$Population),]    #
 ordering the data
 regions - levels(data$state.region)
 temp - NULL
 ranks - NULL
 for (i in 1:length(regions)){
    temp - rev(rank(data[data$state.region==regions[i],Population]))
    ranks - c(ranks,temp)
  }
 data$rank - ranks
 data

 where data$rank is the rank of the state by population within a region.

 However, using loops is slow and cumbersome. I have a fairly large
 data set with many subgroups and the loop runs a long time. Can
 someone suggest a way to create such rank variable for subsets without
 using a loop?

 Thank you,
 Thomas

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


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


[R] Query on linear mixed model

2010-05-18 Thread Vijayan Padmanabhan


Hi R Forum
I am a newbie to R and I have been amazed by what
I can get my team to accomplish just by
implementing Scripting routines of R in all my
team's areas of interest..
Recently i have been trying to adopt R scripting
routine for some analysis with longitudanal data..
I am presenting my R script below that I have
tried to make to automate data analysis for
longitudanal data by employing functions from
library(nlme) and library(multcomp)..

I would be thankful for receiving inputs on this
script and let me know if I have modeled the lme
formula correctly.. If the formula i have used is
not the correct one i would appreciate receiving
inputs on what is the correct formula for lme that
I should use given the context of this example
study shown in the data..

Just to give an introduction.. the data is about
studying efficacy of 3 products for their impact
in skin brightness over 3 time points of
investigation .. The design is such that all the
products are tried on patches made on each arm
(left and right) for each volunteer and chromaL is
measured as the response over 3 time points
Baseline (referred as T0), T1 and T2..


The answers i am looking to get from the analysis
routine is as follows:

Overall across different time points studied which
products is superior?
For Each Product is their a significant difference
in the response variable across different time
points of investigation?
For Each Time Point is their a significant
difference between the different products for the
measured response?
Regards
Vijayan Padmanabhan
Research Scientist, ITC RD, Phase I, Peenya,
Bangalore - 58

The Full R script is given below:

MyData - data.frame(Subj = factor(rep(c(S1,
S2, S3), 18)),
Product = factor(rep(letters[1:3],each=3,54)),
Arm = factor(rep(c(L,R),each=9,54)),
Attribute = factor(rep(c(ChromaL),each=54,54)),
Time = factor(rep(c(T0,T1,T2),each=18,54)),
value=as.numeric(c(43.52,
44.22,43.2,40.12,39.45,38.98,43.23,42.34,44.54,50.23,45.12,43.56,43.23,44.56,42.34,45.67,
43.23,44.54,43.52,44.22,43.2,40.12,39.45,38.98,43.23,42.34,44.54,50.23,45.12,43.56,
 43.23, 44.56, 42.34, 45.67, 43.23,
44.54, 45.5, 46.45, 47.56, 46.98, 46.3, 43.1,
45.6, 44.2, 40.1, 49.8, 48, 46, 47.98, 46.9,
43.78, 47.35, 44.9, 48)))
tapply(MyData$value,
list(Attribute=MyData$Attribute,
  Product=MyData$Product), mean, na.rm=TRUE)


Time = factor(MyData$Time)
Product = factor(MyData$Product)
Subj = factor(MyData$Subj)
Attribute=factor(MyData$Attribute)
Arm=factor(MyData$Arm)
##library(reshape)
##data-melt(data, id=c(Product,
Subject,Attribute))
##data$Product-as.character(Data$Product)
library(nlme)
library(multcomp)


##For ALL Product Comparison across All Time
Points.
options(contrasts=c('contr.treatment','contr.poly'))
data-subset(MyData,Attribute==ChromaL)
tapply(data$value, list(Product=data$Product),
mean,
  na.rm=TRUE)
model - lme(value ~
Product+Time+Arm+Product*Arm+Product*Time+Product*Arm*Time,
 random = ~1 | Subj,data =data)
summary(model)
x-anova(model)
x
library(multcomp)
su-summary(glht(model,linfct=mcp(Product=Tukey)))
##length(su)
##su[1:(length(su)-4)]
x11()
plot(summary(glht(model,linfct=mcp(Product=Tukey))),cex.axis=0.6)


##For Each Product Comparison across All Time
Points.
data-MyData
data-subset(data,Product==a)
tapply(data$value, list(Time=data$Time), mean,
  na.rm=TRUE)
model - lme(value ~ Time+Arm+Time*Arm, random =
~1 | Subj,data =data)
summary(model)
x-anova(model)
x
library(multcomp)
summary(glht(model,linfct=mcp(Time=Tukey)))
x11()
plot(summary(glht(model,linfct=mcp(Time=Tukey))),cex.axis=0.6)

data-MyData
data-subset(data,Product==b)
tapply(data$value, list(Time=data$Time), mean,
  na.rm=TRUE)
model - lme(value ~ Time+Arm+Time*Arm, random =
~1 | Subj,data =data)
summary(model)
x-anova(model)
x
library(multcomp)
summary(glht(model,linfct=mcp(Time=Tukey)))
x11()
plot(summary(glht(model,linfct=mcp(Time=Tukey))),cex.axis=0.6)

data-MyData
data-subset(data,Product==c)
tapply(data$value, list(Time=data$Time), mean,
  na.rm=TRUE)
model - lme(value ~ Time+Arm+Time*Arm, random =
~1 | Subj,data =data)
summary(model)
x-anova(model)
x
library(multcomp)
summary(glht(model,linfct=mcp(Time=Tukey)))
x11()
plot(summary(glht(model,linfct=mcp(Time=Tukey))),cex.axis=0.6)


##For All Product Comparison at Each Time Points.
data-MyData
data-subset(data, Time==T0)
tapply(data$value, list(Product=data$Product),
mean,
  na.rm=TRUE)

model - lme(value ~ Product+Arm+Product:Arm,
random = ~1 | Subj,data =data)
summary(model)
x-anova(model)
x
library(multcomp)
summary(glht(model,linfct=mcp(Product=Tukey)))
x11()
plot(summary(glht(model,linfct=mcp(Product=Tukey))),cex.axis=0.6)


data-MyData
data-subset(data, Time==T1)
tapply(data$value, list(Product=data$Product),
mean,
  na.rm=TRUE)

model - lme(value ~ Product+Arm+Product:Arm,
random = ~1 | Subj,data =data)
summary(model)
x-anova(model)
x
library(multcomp)
summary(glht(model,linfct=mcp(Product=Tukey)))
x11()
plot(summary(glht(model,linfct=mcp(Product=Tukey))),cex.axis=0.6)



Re: [R] Where has the stats-rosuda-devel mailing list gone?

2010-05-18 Thread Antony Unwin
Oliver,

Apologies for the confusion, there was a server upgrade in the computer centre 
here which gave us some grief.  The list should be fine now.

Best regards

Antony

Antony Unwin
Professor of Computer-Oriented Statistics and Data Analysis,
Mathematics Institute,
University of Augsburg, 
86135 Augsburg, Germany

 From: o.mann...@auckland.ac.nz o.mann...@auckland.ac.nz
 Date: 14 May 2010 12:51:03 AM CEST
 To: 'r-help@r-project.org' r-help@r-project.org
 Subject: [R] Where has the stats-rosuda-devel mailing list gone?
 
 
 I require some assistance with JGR, but following the mailing list link from 
 http://jgr.markushelbig.org/FAQ.html leads me 
 tohttp://mailman.rz.uni-augsburg.de/mailman/listinfo/stats-rosuda-devel which 
 responds with
 
 No such list stats-rosuda-devel
 
 I was previously subscribed to this mailing list and want to resubscribe, but 
 where has it gone?
 
 Many thanks,
 
 
 Oliver Mannion
 Programmer
 COMPASS - Centre of Methods and Policy Application in the Social Sciences
 www.compass.auckland.ac.nz
 The University of Auckland, New Zealand
 
 Phone +(649) 373 7999 ext 89760





[[alternative HTML version deleted]]

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


[R] Fwd: [R-sig-DB] Package RPostgreSQL : Problem with dbWriteTable

2010-05-18 Thread Sean Davis
-- Forwarded message --
From: PALMIER Patrick - CETE NP/INFRA/TRF 
patrick.palm...@developpement-durable.gouv.fr
Date: Tue, May 18, 2010 at 8:05 AM
Subject: Re: [R-sig-DB] Package RPostgreSQL : Problem with dbWriteTable
To: Davis, Sean (NIH/NCI) [E] sdav...@mail.nih.gov


 Hello,

Here is the output and se sessionInfo()

I precise that the postgres database has been created with the WIN1252
encoding
User postgres has the complete access rights for the temp directory
I've tried with another user, it is stille the same problem


An idea to solve the problem?


 library(RPostgreSQL)
Le chargement a nécessité le package : DBI
 drv-dbDriver(PostgreSQL)
 con-dbConnect(drv,dbname=test,user=postgres,password=***)
 t-data.frame(X=1:1000,Y=1000:1)
 dbWriteTable(con,toto,t,append=T)
Error in postgresqlExecStatement(conn, statement, ...) :
  RS-DBI driver: (could not Retrieve the result : ERREUR:  n'a pas pu ouvrir
le fichier « C:DOCUME~1PalmierPLOCALS~1TempRtmpfWIqkh
sdbi4eda3c82 » pour une lecture : Invalid argument
)
[1] FALSE
Message d'avis :
In postgresqlWriteTable(conn, name, value, ...) :
  could not load data into table



 sessionInfo()
R version 2.11.0 (2010-04-22)
i386-pc-mingw32

locale:
[1] LC_COLLATE=French_France.1252  LC_CTYPE=French_France.1252
LC_MONETARY=French_France.1252 LC_NUMERIC=C
[5] LC_TIME=French_France.1252

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

other attached packages:
[1] RPostgreSQL_0.1-6 DBI_0.2-5 foreign_0.8-40memisc_0.95-30
MASS_7.3-5lattice_0.18-5

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




 *Patrick PALMIER**
**Centre d'Études Techniques de l'Équipement Nord - Picardie
Département Infrastructures
**Trafic – Socio-économie
*2, rue de Bruxelles, BP 275
59019 Lille cedex
FRANCE
Tél: +33 (0) 3 20 49 60 70
Fax: +33 (0) 3 20 49 63 69


Le 18/05/2010 13:27,  Sean Davis (par Internet, dépôt seand...@gmail.com) a
écrit  :



On Wed, May 12, 2010 at 2:44 AM, PALMIER Patrick - CETE NP/INFRA/TRF 
patrick.palm...@developpement-durable.gouv.fr wrote:

 Hello,

 I have a probem with dbWriteTable method of package RPostrgreSQL
 The table is well added in the database but R doesn't succeed in
 inserting rows
 But If I send the COPY FROM  as an sql query in  R, the rows are then
 well added
 I think it is a problem with the temp file create by dbWriteTable

 As anyone solved this problem?


Hi, Patrick.

A reproducible example and the output of sessionInfo() would be useful here.

Sean

[[alternative HTML version deleted]]

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


Re: [R] GUI commands to call for a protein from protein data bank

2010-05-18 Thread j verzani
Amitoj S. Chopra amitojc at gmail.com writes:

 
 
 What I am trying to do is use GUI function, traitr, and to call for a pdb
 file and save it and then display it. I want to call for it by taking it
 from the user and then displaying it on the screen. I am having problems
 with that. The line pdb - read.pdb(ProteinCode) where proteincode should
 be the name of the protein, for example 1ly2, but it always ends up being
 protein. My question is how to you make the input for read.pdb actually be
 the input by the user and not protein code. I want to be able to type 1ly2,
 and for the program to actually display the contents of 1ly2. Thanks!
 

I'm just guessing, but you might try this for your OK_handler:

OK_handler=function(.) {
  pdb - read.pdb(.$get_ProteinCode())
}

(Or use yours, but drop the quotes around ProteinCode.)

That doesn't modify pdb outside the scope of the handler, so likely you need to
do something else with it.

--John


 Code:
 
 dlg - aDialog(items=list(
 ProteinCode=stringItem()
 ),
 OK_handler=function(.) { # . is reference to dlg object
 values - .$to_R()
 f - function(ProteinCode)
 pdb - read.pdb(ProteinCode)
 do.call(f, values)
 }
 )
 dlg$make_gui()

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


[R] lattice::panel.levelplot.raster too picky with unequal spacing

2010-05-18 Thread baptiste auguie
Dear all,

I got a couple of warnings using panel.levelplot.raster,

In panel.levelplot.raster(..., interpolate = TRUE) :
  'y' values are not equispaced; output will be wrong

although I was quite sure my data were equally spaced (indeed, I
created them with seq()). A closer look at the source code reveals
that the function tests for exact uniformity in grid spacing,

 if (length(unique(diff(uy))) != 1)
warning('x' values are not equispaced; output will be wrong)

The following dummy example would suggest that a strict equality is
not always suitable,

x - seq(0, 50, length=100)
ux - sort(unique(x[!is.na(x)]))
length(unique(diff(ux)))
# 8
sd(unique(diff(ux)))
#  2.462951e-15

Suggestions / comments are welcome.

Best regards,

baptiste


sessionInfo()
R version 2.11.0 RC (2010-04-16 r51754)
i386-apple-darwin9.8.0

locale:
[1] en_GB.UTF-8/en_GB.UTF-8/C/C/en_GB.UTF-8/en_GB.UTF-8

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

other attached packages:
[1] lattice_0.18-5

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



-- 


Baptiste Auguié

Departamento de Química Física,
Universidade de Vigo,
Campus Universitario, 36310, Vigo, Spain

tel: +34 9868 18617
http://webs.uvigo.es/coloides

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


Re: [R] Query on linear mixed model

2010-05-18 Thread Ista Zahn
Hi Vijayan,
You are really asking for this list to serve as your statistical
consultant, which is not its purpose. If you have a specific problem
(and if you know how to ask for help -- see the posting guide) this
list is a tremendous resource. But it is not a replacement for a
statistician.

Best,
Ista

On Tue, May 18, 2010 at 7:52 AM, Vijayan Padmanabhan
v.padmanab...@itc.in wrote:


 Hi R Forum
 I am a newbie to R and I have been amazed by what
 I can get my team to accomplish just by
 implementing Scripting routines of R in all my
 team's areas of interest..
 Recently i have been trying to adopt R scripting
 routine for some analysis with longitudanal data..
 I am presenting my R script below that I have
 tried to make to automate data analysis for
 longitudanal data by employing functions from
 library(nlme) and library(multcomp)..

 I would be thankful for receiving inputs on this
 script and let me know if I have modeled the lme
 formula correctly.. If the formula i have used is
 not the correct one i would appreciate receiving
 inputs on what is the correct formula for lme that
 I should use given the context of this example
 study shown in the data..

 Just to give an introduction.. the data is about
 studying efficacy of 3 products for their impact
 in skin brightness over 3 time points of
 investigation .. The design is such that all the
 products are tried on patches made on each arm
 (left and right) for each volunteer and chromaL is
 measured as the response over 3 time points
 Baseline (referred as T0), T1 and T2..


 The answers i am looking to get from the analysis
 routine is as follows:

 Overall across different time points studied which
 products is superior?
 For Each Product is their a significant difference
 in the response variable across different time
 points of investigation?
 For Each Time Point is their a significant
 difference between the different products for the
 measured response?
 Regards
 Vijayan Padmanabhan
 Research Scientist, ITC RD, Phase I, Peenya,
 Bangalore - 58

 The Full R script is given below:

 MyData - data.frame(Subj = factor(rep(c(S1,
 S2, S3), 18)),
 Product = factor(rep(letters[1:3],each=3,54)),
 Arm = factor(rep(c(L,R),each=9,54)),
 Attribute = factor(rep(c(ChromaL),each=54,54)),
 Time = factor(rep(c(T0,T1,T2),each=18,54)),
 value=as.numeric(c(43.52,
 44.22,43.2,40.12,39.45,38.98,43.23,42.34,44.54,50.23,45.12,43.56,43.23,44.56,42.34,45.67,
 43.23,44.54,43.52,44.22,43.2,40.12,39.45,38.98,43.23,42.34,44.54,50.23,45.12,43.56,
  43.23, 44.56, 42.34, 45.67, 43.23,
 44.54, 45.5, 46.45, 47.56, 46.98, 46.3, 43.1,
 45.6, 44.2, 40.1, 49.8, 48, 46, 47.98, 46.9,
 43.78, 47.35, 44.9, 48)))
 tapply(MyData$value,
 list(Attribute=MyData$Attribute,
  Product=MyData$Product), mean, na.rm=TRUE)


 Time = factor(MyData$Time)
 Product = factor(MyData$Product)
 Subj = factor(MyData$Subj)
 Attribute=factor(MyData$Attribute)
 Arm=factor(MyData$Arm)
 ##library(reshape)
 ##data-melt(data, id=c(Product,
 Subject,Attribute))
 ##data$Product-as.character(Data$Product)
 library(nlme)
 library(multcomp)


 ##For ALL Product Comparison across All Time
 Points.
 options(contrasts=c('contr.treatment','contr.poly'))
 data-subset(MyData,Attribute==ChromaL)
 tapply(data$value, list(Product=data$Product),
 mean,
  na.rm=TRUE)
 model - lme(value ~
 Product+Time+Arm+Product*Arm+Product*Time+Product*Arm*Time,
  random = ~1 | Subj,data =data)
 summary(model)
 x-anova(model)
 x
 library(multcomp)
 su-summary(glht(model,linfct=mcp(Product=Tukey)))
 ##length(su)
 ##su[1:(length(su)-4)]
 x11()
 plot(summary(glht(model,linfct=mcp(Product=Tukey))),cex.axis=0.6)


 ##For Each Product Comparison across All Time
 Points.
 data-MyData
 data-subset(data,Product==a)
 tapply(data$value, list(Time=data$Time), mean,
  na.rm=TRUE)
 model - lme(value ~ Time+Arm+Time*Arm, random =
 ~1 | Subj,data =data)
 summary(model)
 x-anova(model)
 x
 library(multcomp)
 summary(glht(model,linfct=mcp(Time=Tukey)))
 x11()
 plot(summary(glht(model,linfct=mcp(Time=Tukey))),cex.axis=0.6)

 data-MyData
 data-subset(data,Product==b)
 tapply(data$value, list(Time=data$Time), mean,
  na.rm=TRUE)
 model - lme(value ~ Time+Arm+Time*Arm, random =
 ~1 | Subj,data =data)
 summary(model)
 x-anova(model)
 x
 library(multcomp)
 summary(glht(model,linfct=mcp(Time=Tukey)))
 x11()
 plot(summary(glht(model,linfct=mcp(Time=Tukey))),cex.axis=0.6)

 data-MyData
 data-subset(data,Product==c)
 tapply(data$value, list(Time=data$Time), mean,
  na.rm=TRUE)
 model - lme(value ~ Time+Arm+Time*Arm, random =
 ~1 | Subj,data =data)
 summary(model)
 x-anova(model)
 x
 library(multcomp)
 summary(glht(model,linfct=mcp(Time=Tukey)))
 x11()
 plot(summary(glht(model,linfct=mcp(Time=Tukey))),cex.axis=0.6)


 ##For All Product Comparison at Each Time Points.
 data-MyData
 data-subset(data, Time==T0)
 tapply(data$value, list(Product=data$Product),
 mean,
  na.rm=TRUE)

 model - lme(value ~ Product+Arm+Product:Arm,
 random = ~1 | Subj,data =data)
 summary(model)
 

Re: [R] best polynomial approximation

2010-05-18 Thread Hans W Borchers

I guess you may be looking for the Remez algorithm. AFAIK there is no
implementation in one of the R packages. You can find FORTRAN code in the
Collected Algorithms of the ACM (no. 604) which probably could be called
from R.

There appears to exist a discrete, equi-distant(?) version as function
'remez' in the signal package, if that is of any help to you. I have never
used it.

Regards,  Hans Werner

P.S.: The Chebyshev polynomials do not compute the best polynomial
approximation, but they provide a nice way to estimate the maximal distance
to this best approximating polynomial.



Patrizio Frederic wrote:
 
 Dear R-users,
 I learned today that there exists an interesting topic in numerical
 analysis names best polynomial approximation (BSA). Given a function
 f  the BSA of degree k, say pk, is the polynomial such that
 
 pk=arginf sup(|f-pk|)
 
 Although given some regularity condition of f, pk is unique, pk IS NOT
 calculated with least square. A quick google tour show a rich field of
 research and many algorithms proposed for computing such a task.
 
 I was wondered if some of you knows about some R implementations
 (packages) for computing BSA.
 
 Many thanks in advance,
 
 Patrizio
 
 as usual I apologize for my fragmented English
 
 -- 
 +-
 | Patrizio Frederic, PhD
 | Assistant Professor,
 | Department of Economics,
 | University of Modena and Reggio Emilia,
 | Via Berengario 51,
 | 41100 Modena, Italy
 |
 | tel:  +39 059 205 6727
 | fax:  +39 059 205 6947
 | mail: patrizio.frede...@unimore.it
 +-
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 
-- 
View this message in context: 
http://r.789695.n4.nabble.com/best-polynomial-approximation-tp2220439p2221042.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] timing a function

2010-05-18 Thread Gustave Lefou
Thank you Alexander

2010/5/17 Alexander Shenkin ashen...@ufl.edu

 You could also put the call to system.time inside the function itself:

 f = function(x) {
system.time({
... #function's code
ret_val = ...
}); flush.console();
return ret_val;
 }

 i s'pose you'd miss out on the time taken to jump to the function code,
 return the value, etc, but for functions that are heavy at all, that
 wouldn't trip you up.

 allie

 On 5/17/2010 2:06 PM, Barry Rowlingson wrote:
  On Mon, May 17, 2010 at 6:24 PM, Peter Ehlers ehl...@ucalgary.ca
 wrote:
 
 
  Try
   system.time(y - f(x))
 
  and see ?=.
 
   -Peter Ehlers
 
   Ah ha. That explains the curly brackets I saw in a posting with
  system.time on stack overflow just now:
 
   system.time({y=f(x)})
 
   works as expected since the {} pair make a new code block. Also you
  can then time more than one statement:
 
   system.time({y=f(x);z=g(y)})
 
   - gives the total time for f(x) and g(y).
 
  Barry
 
   __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 

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


[[alternative HTML version deleted]]

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


Re: [R] [RGL] Need help to modify current plot

2010-05-18 Thread Megh Dal
Thanks Duncan for your reply. This could definitely be an answer of my query 
however I wanted something else. What I want is to draw 2 lines over the 
surface which pass through x=3,4
 
Any better idea?
 
Thanks,
--- On Tue, 5/18/10, Duncan Murdoch murdoch.dun...@gmail.com wrote:


From: Duncan Murdoch murdoch.dun...@gmail.com
Subject: Re: [R] [RGL] Need help to modify current plot
To: Megh Dal megh700...@yahoo.com
Cc: r-h...@stat.math.ethz.ch
Date: Tuesday, May 18, 2010, 3:51 PM


Megh Dal wrote:
 Dear folks, I have created a plot on RGL device :
  x = 1:6
 y = seq(-12, 5, by=1)
 z = matrix(0, length(y), length(x))
 z[13,3] = 1; z[13,4] = 1.011765
 surface3d(x, y, t(z), col=rainbow(1000))
 grid3d(c(x-, y-, z))
  Now I want to draw 2 lines along x=3  x=4, over the surface (with different 
colour). Could somebody help me how to draw that?
    

x=3 and x=4 specify planes, not lines, so you'll need to give more information 
to choose lines.  Here's one possibility:

save - par3d(ignoreExtent=TRUE)
segments3d(c(3,3,4,4), c(min(y), max(y), min(y), max(y)), c(max(z), max(z), 
max(z), max(z)), col=red)
par3d(save)

Duncan Murdoch



  
[[alternative HTML version deleted]]

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


Re: [R] lattice::panel.levelplot.raster too picky with unequal spacing

2010-05-18 Thread Deepayan Sarkar
On Tue, May 18, 2010 at 6:32 PM, baptiste auguie
baptiste.aug...@googlemail.com wrote:
 Dear all,

 I got a couple of warnings using panel.levelplot.raster,

 In panel.levelplot.raster(..., interpolate = TRUE) :
  'y' values are not equispaced; output will be wrong

 although I was quite sure my data were equally spaced (indeed, I
 created them with seq()). A closer look at the source code reveals
 that the function tests for exact uniformity in grid spacing,

  if (length(unique(diff(uy))) != 1)
            warning('x' values are not equispaced; output will be wrong)

Maybe a better test would be

isTRUE(all.equal(diff(range(diff(ux))), 0))

I'll try that out for the next release.

-Deepayan


 The following dummy example would suggest that a strict equality is
 not always suitable,

 x - seq(0, 50, length=100)
 ux - sort(unique(x[!is.na(x)]))
 length(unique(diff(ux)))
 # 8
 sd(unique(diff(ux)))
 #  2.462951e-15

 Suggestions / comments are welcome.

 Best regards,

 baptiste


 sessionInfo()
 R version 2.11.0 RC (2010-04-16 r51754)
 i386-apple-darwin9.8.0

 locale:
 [1] en_GB.UTF-8/en_GB.UTF-8/C/C/en_GB.UTF-8/en_GB.UTF-8

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

 other attached packages:
 [1] lattice_0.18-5

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



 --
 

 Baptiste Auguié

 Departamento de Química Física,
 Universidade de Vigo,
 Campus Universitario, 36310, Vigo, Spain

 tel: +34 9868 18617
 http://webs.uvigo.es/coloides
 



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


[R] Using the zero-inflated binomial in experimental designs

2010-05-18 Thread Ivan Allaman

I'm trying to use the inflated binomial distribution of zeros (since 75% of
the values are zeros) in a randomized block experiment with four
quantitative treatments (0, 0.5, 1, 1.5), but I'm finding it difficult,
since the examples available in VGAM packages like for example, leave us
unsure of how it should be the data.frame for such analysis. Unfortunately
the function glm does not have an option to place a family of this kind I'm
about, because if I had, it would be easy, made that my goal is simple, just
wanting to compare the treatments. For that you have an idea, here is an
example of my database.

BLOCK   NIVNT   MUMI
Inicial 0  18 0 
Inicial 0  15 0 
Inicial 0.5 9 0 
Inicial 0.5   19  1 
Inicial 1 13  1 
Inicial 1 11  0 
Inicial 1.5  12  2
Inicial 1.5  10  1
Meio   0   13 0 
Meio  0  10   2 
Meio 0.5   17 0 
Meio 0.5  14  1 
Meio  1   13  0 
Meio 1  9 0 
Meio  1.5  110 
Meio  1.5  12   1

where: NIV are the treatments; NT is the total number of piglets born; Mumi
is the number of mummified piglets NT. Mumi The variable is of interest. If
someone can tell me some stuff on how I can do these tests in R, similar to
what I would do using the function glm, I'd be grateful.
I thank everyone's attention.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Using-the-zero-inflated-binomial-in-experimental-designs-tp2221254p2221254.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] doubt with auto.arima

2010-05-18 Thread yonosoyelmejor

hello,

i have a doubt  with this function, i need get the returns values because i 
have to save in a variables,something like this:

Invernadero-ts(x2)

test-auto.arima(x2)

x2.pred.ar31-predict(arima(x2,order=c(p,d,q)),n.ahead=10)$pred

can i get p,d and q from auto.arima?this is my question.

I hope have explained well,

A regards.


--
This message was sent on behalf of yonosoyelme...@hotmail.com at 
openSubscriber.com
http://www.opensubscriber.com/message/r-help@r-project.org/11277758.html

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


[R] looking for .. dec if vector if element x

2010-05-18 Thread Knut Krueger


Hi to all,
I am just looking for more efficient ways ;-)

is there a better way instead a loop  to decrease x if greater y
test  - c(1,3,5,7,9)

decrease if greater 1 to
test2  - c(1,2,4,6,8)


Kind regards
Knut

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


Re: [R] looking for .. dec if vector if element x

2010-05-18 Thread Adrian Dusa
On Tuesday 18 May 2010, Knut Krueger wrote:
 Hi to all,
 I am just looking for more efficient ways ;-)
 
 is there a better way instead a loop  to decrease x if greater y
 test  - c(1,3,5,7,9)
 
 decrease if greater 1 to
 test2  - c(1,2,4,6,8)

Does this help?

 test  - c(1, 3, 5, 7, 9)
 test[test  1] - test[test  1] - 1
 test
[1] 1 2 4 6 8

Adrian

-- 
Adrian Dusa
Romanian Social Data Archive
1, Schitu Magureanu Bd.
050025 Bucharest sector 5
Romania
Tel.:+40 21 3126618 \
 +40 21 3120210 / int.101
Fax: +40 21 3158391

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


Re: [R] looking for .. dec if vector if element x

2010-05-18 Thread Duncan Murdoch

On 18/05/2010 7:34 AM, Knut Krueger wrote:

Hi to all,
I am just looking for more efficient ways ;-)

is there a better way instead a loop  to decrease x if greater y
test  - c(1,3,5,7,9)

decrease if greater 1 to
test2  - c(1,2,4,6,8)


test2 - ifelse( test  1, test-1, test)

Duncan Murdoch

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


Re: [R] Query on linear mixed model

2010-05-18 Thread Joshua Wiley
On Tue, May 18, 2010 at 4:52 AM, Vijayan Padmanabhan
v.padmanab...@itc.in wrote:
snip

This does not answer your statistical question, but I did include some
ideas to simplify your script.

 ##For ALL Product Comparison across All Time
 Points.
 options(contrasts=c('contr.treatment','contr.poly'))
 data-subset(MyData,Attribute==ChromaL)
 tapply(data$value, list(Product=data$Product),
 mean,
  na.rm=TRUE)
 model - lme(value ~
 Product+Time+Arm+Product*Arm+Product*Time+Product*Arm*Time,
  random = ~1 | Subj,data =data)
 summary(model)

using '*' automatically crosses all the variables.  A more parsimonius form is:
lme(value ~ Product*Arm*Time, random = ~1 | Subj,data =data)

there is only a slight reordering of effects, but all estimates are the same.

 x-anova(model)
 x
 library(multcomp)
 su-summary(glht(model,linfct=mcp(Product=Tukey)))
 ##length(su)
 ##su[1:(length(su)-4)]
 x11()
 plot(summary(glht(model,linfct=mcp(Product=Tukey))),cex.axis=0.6)


 ##For Each Product Comparison across All Time
 Points.
 data-MyData
 data-subset(data,Product==a)
 tapply(data$value, list(Time=data$Time), mean,
  na.rm=TRUE)
 model - lme(value ~ Time+Arm+Time*Arm, random =
 ~1 | Subj,data =data)

again, simplified:

lme(value ~ Time*Arm, random = ~1 | Subj,data =data)

(no reordering even this time)

 summary(model)
 x-anova(model)
 x
 library(multcomp)
 summary(glht(model,linfct=mcp(Time=Tukey)))
 x11()
 plot(summary(glht(model,linfct=mcp(Time=Tukey))),cex.axis=0.6)

 data-MyData
 data-subset(data,Product==b)
 tapply(data$value, list(Time=data$Time), mean,
  na.rm=TRUE)
 model - lme(value ~ Time+Arm+Time*Arm, random =
 ~1 | Subj,data =data)

lme(value ~ Time*Arm, random = ~1 | Subj,data =data)

 summary(model)
 x-anova(model)
 x
 library(multcomp)
 summary(glht(model,linfct=mcp(Time=Tukey)))
 x11()
 plot(summary(glht(model,linfct=mcp(Time=Tukey))),cex.axis=0.6)

 data-MyData
 data-subset(data,Product==c)
 tapply(data$value, list(Time=data$Time), mean,
  na.rm=TRUE)
 model - lme(value ~ Time+Arm+Time*Arm, random =
 ~1 | Subj,data =data)

lme(value ~ Time*Arm, random = ~1 | Subj,data =data)

 summary(model)
 x-anova(model)
 x
 library(multcomp)
 summary(glht(model,linfct=mcp(Time=Tukey)))
 x11()
 plot(summary(glht(model,linfct=mcp(Time=Tukey))),cex.axis=0.6)


 ##For All Product Comparison at Each Time Points.
 data-MyData
 data-subset(data, Time==T0)
 tapply(data$value, list(Product=data$Product),
 mean,
  na.rm=TRUE)

 model - lme(value ~ Product+Arm+Product:Arm,
 random = ~1 | Subj,data =data)

here you used ':' so it is not redundant, but it can still be simplified to:

lme(value ~ Product*Arm, random = ~1 | Subj,data =data)

 summary(model)
 x-anova(model)
 x
 library(multcomp)
 summary(glht(model,linfct=mcp(Product=Tukey)))
 x11()
 plot(summary(glht(model,linfct=mcp(Product=Tukey))),cex.axis=0.6)


 data-MyData
 data-subset(data, Time==T1)
 tapply(data$value, list(Product=data$Product),
 mean,
  na.rm=TRUE)

 model - lme(value ~ Product+Arm+Product:Arm,
 random = ~1 | Subj,data =data)

lme(value ~ Product*Arm, random = ~1 | Subj,data =data)

 summary(model)
 x-anova(model)
 x
 library(multcomp)
 summary(glht(model,linfct=mcp(Product=Tukey)))
 x11()
 plot(summary(glht(model,linfct=mcp(Product=Tukey))),cex.axis=0.6)


 data-MyData
 data-subset(data, Time==T2)
 tapply(data$value, list(Product=data$Product),
 mean,
  na.rm=TRUE)

 model - lme(value ~ Product+Arm+Product:Arm,
 random = ~1 | Subj,data =data)

lme(value ~ Product*Arm, random = ~1 | Subj,data =data)

 summary(model)
 x-anova(model)
 x
 library(multcomp)
 summary(glht(model,linfct=mcp(Product=Tukey)))
 x11()
 plot(summary(glht(model,linfct=mcp(Product=Tukey))),cex.axis=0.6)

Unless only parts of this script are being run in a given session, I
cannot think of a good reason to keep calling  library(multcomp).  I
also notice that your script repeats the same steps frequently, so you
might benefit from making a little function that does all the steps
you want.  That way if you ever want to add or change something, you
just have to update the function.

Good luck,

Josh

snip



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

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


Re: [R] looking for .. dec if vector if element x

2010-05-18 Thread Henrique Dallazuanna
Try this also:

pmax(test - 1, 1)

On Tue, May 18, 2010 at 8:34 AM, Knut Krueger r...@krueger-family.de wrote:


 Hi to all,
 I am just looking for more efficient ways ;-)

 is there a better way instead a loop  to decrease x if greater y
 test  - c(1,3,5,7,9)

 decrease if greater 1 to
 test2  - c(1,2,4,6,8)


 Kind regards
 Knut

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




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

[[alternative HTML version deleted]]

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


Re: [R] lattice::panel.levelplot.raster too picky with unequal spacing

2010-05-18 Thread baptiste auguie
On 18 May 2010 15:30, Deepayan Sarkar deepayan.sar...@r-project.org wrote:

 Maybe a better test would be

 isTRUE(all.equal(diff(range(diff(ux))), 0))

 I'll try that out for the next release.



Sounds good (and works for me), thanks.

baptiste

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


Re: [R] Variable variables using R ... e.g., looping over data frames with a numeric separator

2010-05-18 Thread Tony Plate

On 05/17/2010 03:51 PM, Monte Shaffer wrote:

for(i in 1:L-1)
{
dataStr = gsub(' ','',paste(fData.,i));
dataVar = eval(dataStr);
  ## GOAL is to grab data frame  'fData.1' and do stuff with it, then in next
loop grab data frame 'fData.2' and do stuff with it


}
   
As Dan Davison said, the more standard R way would be to put all your 
data frames in a list, then iterate over the list.


However, if do want to have your data frames in separate variables, and 
then get each data frame in a loop similar to the code fragment above, 
try something like this:


for (i in 1:(L-1)) {
dataName - paste(fData., i, sep=)
df - get(dataName)
... do something with data frame df ...
}

You can also give additional arguments to get() to tell it where to look 
(pos=,envir=), and whether to look in parent environments 
(inherits=TRUE/FALSE).


-- Tony Plate

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


[R] scaling with relative units in plots or retrieving axes limits in plots

2010-05-18 Thread Jannis
Dears,


a way to define x and y positions in plots in relative numbers (e.g in 
fractions  between 0 and 1 referring to relative positions inside the plot 
region) would really help me. One example I would need this to would be to add 
text via text() to a plot always at a defined spot, e.g the upper left corner. 
Until now I always determined maximum x and y values and used those, but 
defining relative positions straight away would be much easier. Possible 
solutions:

1. Predefined function
Is there anything available that lets me run (for example):

text(0.5,0.5,'middle')

which always puts text on these relative points?



2. Create my own function
It would be straightforward to create my own function that translates the 
relative number to the axes values in the actual plot, so that 

text(my.function(0.5,0.5),'middle')

would do what I want. For this I would need to be able to somehow retrieve the 
axis limits for x and y axes. Is there any way I could do this after having 
called plot()?



Thanks for your help!


Jannis




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


[R] scaling with relative units in plots or retrieving axes limits in plots

2010-05-18 Thread Jannis
Dears,


a way to define x and y positions in plots in relative numbers (e.g in 
fractions  between 0 and 1 referring to relative positions inside the plot 
region) would really help me. One example I would need this to would be to add 
text via text() to a plot always at a defined spot, e.g the upper left corner. 
Until now I always determined maximum x and y values and used those, but 
defining relative positions straight away would be much easier. Possible 
solutions:

1. Predefined function
Is there anything available that lets me run (for example):

text(0.5,0.5,'middle')

which always puts text on these relative points?



2. Create my own function
It would be straightforward to create my own function that translates the 
relative number to the axes values in the actual plot, so that 

text(my.function(0.5,0.5),'middle')

would do what I want. For this I would need to be able to somehow retrieve the 
axis limits for x and y axes. Is there any way I could do this after having 
called plot()?



Thanks for your help!


Jannis




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


Re: [R] scaling with relative units in plots or retrieving axes limits in plots

2010-05-18 Thread Joshua Wiley
par(usr) #gives the extreme plotting coordinates

?par

HTH,

Josh

On Tue, May 18, 2010 at 7:32 AM, Jannis bt_jan...@yahoo.de wrote:
 Dears,


 a way to define x and y positions in plots in relative numbers (e.g in 
 fractions  between 0 and 1 referring to relative positions inside the plot 
 region) would really help me. One example I would need this to would be to 
 add text via text() to a plot always at a defined spot, e.g the upper left 
 corner. Until now I always determined maximum x and y values and used those, 
 but defining relative positions straight away would be much easier. Possible 
 solutions:

 1. Predefined function
 Is there anything available that lets me run (for example):

 text(0.5,0.5,'middle')

 which always puts text on these relative points?



 2. Create my own function
 It would be straightforward to create my own function that translates the 
 relative number to the axes values in the actual plot, so that

 text(my.function(0.5,0.5),'middle')

 would do what I want. For this I would need to be able to somehow retrieve 
 the axis limits for x and y axes. Is there any way I could do this after 
 having called plot()?



 Thanks for your help!


 Jannis




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




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

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


Re: [R] scaling with relative units in plots or retrieving axes limits in plots

2010-05-18 Thread Ivan Calandra

Hi,

For 2., I don't know if it's possible to retrieve the axis limits, but 
you can surely specify them in your call to plot (with arguments xlim 
and ylim).

That's a cheap solution and others probably have better ones.

Ivan

Le 5/18/2010 16:23, Jannis a écrit :

Dears,


a way to define x and y positions in plots in relative numbers (e.g in 
fractions  between 0 and 1 referring to relative positions inside the plot 
region) would really help me. One example I would need this to would be to add 
text via text() to a plot always at a defined spot, e.g the upper left corner. 
Until now I always determined maximum x and y values and used those, but 
defining relative positions straight away would be much easier. Possible 
solutions:

1. Predefined function
Is there anything available that lets me run (for example):

text(0.5,0.5,'middle')

which always puts text on these relative points?



2. Create my own function
It would be straightforward to create my own function that translates the 
relative number to the axes values in the actual plot, so that

text(my.function(0.5,0.5),'middle')

would do what I want. For this I would need to be able to somehow retrieve the 
axis limits for x and y axes. Is there any way I could do this after having 
called plot()?



Thanks for your help!


Jannis




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

   


--
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Museum
Abt. Säugetiere
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231
ivan.calan...@uni-hamburg.de

**
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php

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


[R] scaling with relative units in plots or retrieving axes limits in plots

2010-05-18 Thread Jannis
Dears,


a way to define x and y positions in plots in relative numbers (e.g in 
fractions  between 0 and 1 referring to relative positions inside the plot 
region) would really help me. One example I would need this to would be to add 
text via text() to a plot always at a defined spot, e.g the upper left corner. 
Until now I always determined maximum x and y values and used those, but 
defining relative positions straight away would be much easier. Possible 
solutions:

1. Predefined function
Is there anything available that lets me run (for example):

text(0.5,0.5,'middle')

which always puts text on these relative points?



2. Create my own function
It would be straightforward to create my own function that translates the 
relative number to the axes values in the actual plot, so that 

text(my.function(0.5,0.5),'middle')

would do what I want. For this I would need to be able to somehow retrieve the 
axis limits for x and y axes. Is there any way I could do this after having 
called plot()?



Thanks for your help!


Jannis




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


Re: [R] scaling with relative units in plots or retrieving axes limits in plots

2010-05-18 Thread Jannis
Thanks for the replies! If anybody  encounters a similar problem, the function 
that now does what I wanted is attached below.


Best
Jannis



trnsf.coords = function(array_x,array_y)

# This function transfers relative coordinates between 0 and 1 for two arrays 
with x
# and y values into the coordinate system of the current plot.

{
plot_extremes=par()$usr
x_min=plot_extremes[1]
x_max=plot_extremes[2]
y_min=plot_extremes[3]
y_max=plot_extremes[4]

x_trans=x_min+(array_x*x_max-x_min)
y_trans=y_min+(array_y*y_max-y_min)
output=list(x=x_trans,y=y_trans)
return(output)

}

--- Jannis bt_jan...@yahoo.de schrieb am Di, 18.5.2010:

 Von: Jannis bt_jan...@yahoo.de
 Betreff: [R] scaling with relative units in plots or retrieving axes limits 
 in plots
 An: r-h...@stat.math.ethz.ch
 Datum: Dienstag, 18. Mai, 2010 14:23 Uhr
 Dears,
 
 
 a way to define x and y positions in plots in relative
 numbers (e.g in fractions  between 0 and 1 referring to
 relative positions inside the plot region) would really help
 me. One example I would need this to would be to add text
 via text() to a plot always at a defined spot, e.g the upper
 left corner. Until now I always determined maximum x and y
 values and used those, but defining relative positions
 straight away would be much easier. Possible solutions:
 
 1. Predefined function
 Is there anything available that lets me run (for
 example):
 
 text(0.5,0.5,'middle')
 
 which always puts text on these relative points?
 
 
 
 2. Create my own function
 It would be straightforward to create my own function that
 translates the relative number to the axes values in the
 actual plot, so that 
 
 text(my.function(0.5,0.5),'middle')
 
 would do what I want. For this I would need to be able to
 somehow retrieve the axis limits for x and y axes. Is there
 any way I could do this after having called plot()?
 
 
 
 Thanks for your help!
 
 
 Jannis
 
 
 
 
 __
 R-help@r-project.org
 mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained,
 reproducible code.
 



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


Re: [R] help color coding map in R

2010-05-18 Thread Anderson, Chris
Thank you this was helpful

Chris Anderson
Data Analyst
Medical Affairs
wk: 925-677-4870
cell: 707-315-8486
Fax:925-677-4670


-Original Message-
From: foolish.andr...@gmail.com [mailto:foolish.andr...@gmail.com] On Behalf Of 
Felix Andrews
Sent: Monday, May 17, 2010 5:55 PM
To: Anderson, Chris
Cc: R-help Forum
Subject: Re: [R] help color coding map in R

Sorry, I was talking nonsense.

The actual problem was in your panel function, where you extract the
state boundaries, and then draw them using panel.polygon: the order of
states from map() is arbitrary, and does not correspond to the color
palette that you set up.

I suggest using mapplot(). This matches the region names you provide
to the names from the map.  However (as in your original case) you do
need to ensure that they match exactly, including case and sub-region
names...

i.e. you need to match up
NatSTSummaryHigh.abi$JurisdtnStateName  with
map(state, regions=NatSTSummaryHigh.abi$JurisdtnStateName)$names
(exactly).


nclr - 4
plotclr - brewer.pal(nclr,PuRd)
class - classIntervals(NatSTSummaryHigh.abi$STMean, nclr, style=fisher )

mapplot(tolower(JurisdtnStateName) ~ STMean, data = NatSTSummaryHigh.abi,
map = us.map, breaks = class$brks, colramp = colorRampPalette(plotclr))


-Felix


On 18 May 2010 02:37, Anderson, Chris chris.ander...@paradigmcorp.com wrote:
 Flex,

 I apologize for not sending the data. I have attached the Rdata set and an 
 excel version and I've attached the graph. I have not use mapplot before is 
 that a better option if so then will you pass along the syntax I would use. 
 As far as using the current logic, I tried adding your suggesting to the 
 groups variable and I get the same result. I also have a field within my data 
 called BdgtGrp, which I placed in the groups option, but the state colors 
 don’t match the levels I have in the legend. Idealy, I would like those 
 states that I have identified with BdgtGrp==Significanlty high be in red, 
 purple for those identified as Mid-High and light blue for those identified 
 as High. If not by these flags then I would want the colors be for the 
 ranges specified within the class level.

 In any case, I expect Ohio, followed by New Mexico, and Arizona to be in 
 red. In order for me to get the states highlighted in the proper color are 
 you suggesting I do a reorder on  this section of the code 
 core.states=map(state, 
 regions=NatSTSummaryHigh.abi$JurisdtnStateName[subscripts],
  plot=FALSE, fill=TRUE) ?




 Chris Anderson
 Data Analyst
 Medical Affairs
 wk: 925-677-4870
 cell: 707-315-8486
 Fax:925-677-4670


 -Original Message-
 From: foolish.andr...@gmail.com [mailto:foolish.andr...@gmail.com] On Behalf 
 Of Felix Andrews
 Sent: Saturday, May 15, 2010 6:41 AM
 To: Anderson, Chris
 Cc: r-help@R-project.org
 Subject: Re: [R] help color coding map in R

 The 'groups' argument should be a factor, which explicitly defines the
 ordering of its levels. Otherwise it is converted to a factor using
 the default ordering which is alphabetical. You can make a factor
 ordered by occurence as, eg., factor(z, levels = unique(z)). Or use
 reorder().

 Note that data attachments don't work on this list. After constructing
 a minimal example, it is best to dump the required objects in a
 pastable form using dput().

 I'm guessing you have some reason that you are not using mapplot()...

 -Felix

 On Saturday, May 15, 2010, Anderson, Chris
 chris.ander...@paradigmcorp.com wrote:
 I am trying to create a map with selected states based on highest to lowest 
 mean cost. The following code properly selects the correct states, and the 
 legend is properly color coded with ranges, but the colors per range does 
 not match the state colors. I need help getting the state colors to match 
 the ranges outlined in the legend. I have tried ordering the mean amounts 
 and this correctly creates the vector of colors in the correct order, but 
 when applied to the map the colors don't match. Attached is the R dataset of 
 my data. Please help me tweak the map so the colors are properly assigned.

 # Get the entire US map for use later.
 us.map - map(state, plot = FALSE, fill = TRUE)

 # Calculate the range of the map (with extra margins).
 xl - extendrange(us.map$range[1:2])
 yl - extendrange(us.map$range[3:4])

 library(maps)
 library(lattice)
 library(latticeExtra)
 library(RColorBrewer) # creates nice color schemes
 library(classInt)


 plotclr - brewer.pal(nclr,PuRd)
 class - classIntervals(NatSTSummaryHigh.abi$STMean, nclr, style=fisher )
 colcode - findColours(class, plotclr)


 # Plot a multi-panel map of all the states, and colour
 xyplot(y~x | NatSTSummaryHigh.abi$PrimaryDX, data = 
 state.center,groups=names(attr(colcode, table)),
     main=High Cost States by Diagnosis (  National Avg),
     xlim = xl, ylim = yl, scales = list(draw=FALSE),
     aspect = iso,
     xlab = NULL, ylab = NULL,
     strip = strip.custom(var.name=Diagnosis, sep=: ,
     

Re: [R] sample

2010-05-18 Thread Wu Gong

Sorry, I made two mistakes. The first was matching the female with the male.
The second was 2 variables should be selected randomly every time.

Followed is a revised copy:

## Import data.
moms - read.delim(females.txt, sep = , stringsAsFactors = FALSE, header
= TRUE)
dads - read.delim(males.txt, sep = , stringsAsFactors = FALSE, header =
TRUE) 

## Mate.
## Each male doesn't mate twice.
parents - cbind(moms, dads[sample(nrow(dads), nrow(moms)),])

## Assign output data frame.
## The matrix resultscheck will be used to check the random selections.
output_offspring - as.data.frame(matrix(, nrow = nrow(moms), ncol = 6),
stringsAsFactors = FALSE) 
resultscheck - as.data.frame(matrix(, nrow = nrow(moms), ncol = 6),
stringsAsFactors = FALSE) 

## Randomly select two variables both from moms and dads.
for(i in 1:nrow(parents)) {
selection - c(1, sample((2:5),2), 6, sample((7:10),2)) 
output_offspring[i,] - parents[1,selection]
resultscheck[i,] - selection
}

## Show the random selections.
resultscheck

## Output.
write.table(output_offspring,offspring_7.txt,row.names=F,col.names=c(momID,A1,A2,dadID,A3,A4),quote=F)
 



-
A R learner.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/sample-tp2218361p2221328.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] Counting Frequencies in Data Frame

2010-05-18 Thread M.Ribeiro

Hi,
I am sure there is an easy way to do it, but I can't find it.
I have a data frame that has 15 columns and 7000 rows.

The only values inside the data.frame are aa, ab, bb as you can see an
example bellow.

   1  2  3
1 aa ab ab
2 ab ab ab
3 aa aa aa
4 bb bb bb

What I would like to do, is to generate a vector (or another data.frame)
with 7000 rows, and 3 columns. In the first column, the information about
how many aa, the second about how many ab, and the third about how many bb
are there in each line
  aa  ab  bb
1  1   2   0
2  0   2   0
3  3   0   0
4  0   0   3

Thank you very much
Cheers
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Counting-Frequencies-in-Data-Frame-tp2221342p2221342.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] looking for .. dec if vector if element x

2010-05-18 Thread Knut Krueger

Henrique Dallazuanna schrieb:

Try this also:

pmax(test - 1, 1)

O

test  - c(1,3,5,7,9,11,12,13,14)
test
test - pmax(test - 1, 1)
test

This works for 1
what about if  I would dec 11: to 14  to close the gap between 9 and 10 ?
I did not find the answer with the help file

Thank you Knut

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


[R] C function call in R

2010-05-18 Thread John Lande
dear all,

we am trying to improve the performance of my R code, with the implentation
of some function with custom C code.
we found difficult to import and export/import data structure such us
matrices or data.frame into the external C functions.

we already tried the solution from Writing R Extensions form  the R
webpage.

do you have any other solution or more advanced documentation on that point?

looking forward your answer

[[alternative HTML version deleted]]

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


[R] Fatal error that doesn't let me start R

2010-05-18 Thread gbrenes
Hi, all.

I have R installed in my computer.  I guess I did something in my previous
session, and now every time I start R, I find the following message:

Fatal error: unable to restore saved data in .RData

I uninstalled R and installed it again and I'm still getting this message.

Can anyone help me?


Gilbert

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


Re: [R] C function call in R

2010-05-18 Thread Steve Lianoglou
Hi,

On Tue, May 18, 2010 at 10:50 AM, John Lande john.land...@gmail.com wrote:
 dear all,

 we am trying to improve the performance of my R code, with the implentation
 of some function with custom C code.
 we found difficult to import and export/import data structure such us
 matrices or data.frame into the external C functions.

 we already tried the solution from Writing R Extensions form  the R
 webpage.

Perhaps:
(i) you can show us what you've tried and someone can tell help steer
you in a better direction
(ii) you can check out the Rcpp library. A new version was just
released that you can read up on:

http://romainfrancois.blog.free.fr/index.php?category/R-package/Rcpp

It has lots of examples of how it should be used in its unit tests, etc.

-steve

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

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


[R] Repeating Name for Rows

2010-05-18 Thread ecvetano

Hello,
I have a large data frame (47:2186), where i want to label every 12th row.
This command works,
Day -rep(97:278, each = 12)
However i need 97 to only labeled 11 rows and then from 98:278 can be  
labeled every 12 times.


Thanks!

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


Re: [R] Fatal error that doesn't let me start R

2010-05-18 Thread Duncan Murdoch

On 18/05/2010 10:51 AM, gbre...@ssc.wisc.edu wrote:

Hi, all.

I have R installed in my computer.  I guess I did something in my previous
session, and now every time I start R, I find the following message:

Fatal error: unable to restore saved data in .RData

I uninstalled R and installed it again and I'm still getting this message.

Can anyone help me?



You likely have an object in the .RData file which can't be loaded, 
because it relies on a package you no longer have.  You can run R with 
the --vanilla command line option and it won't try to load .RData, then 
reinstall all of your packages, and that might fix things.  
Alternatively, just delete the .RData file, and the problem will go away 
(but so will your data.)


Duncan Murdoch

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


Re: [R] Fatal error that doesn't let me start R

2010-05-18 Thread Steve Lianoglou
Hi,

On Tue, May 18, 2010 at 10:51 AM,  gbre...@ssc.wisc.edu wrote:
 Hi, all.

 I have R installed in my computer.  I guess I did something in my previous
 session, and now every time I start R, I find the following message:

 Fatal error: unable to restore saved data in .RData

 I uninstalled R and installed it again and I'm still getting this message.

 Can anyone help me?

It looks like you have an .Rdata file that is corrupt -- you just have
to remove it.

When you quit R, you should have noticed a prompt that asks you if you
want to Save workspace image. When answer yes, it will save your
workspace into an .RData file.

Anyway, it's not a problem with your R install, which is why
reinstalling R didn't work, you just have to remove this file. Without
any more details with respect to how you launched R, what type of cpu
you have, etc., my first guess would be that this file resides in your
home directory.

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

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


Re: [R] Counting Frequencies in Data Frame

2010-05-18 Thread Ista Zahn
Hi,
Others will have fancier solutions, but is the way I would do it:

dat - read.table(textConnection(1  2  3
1 aa ab ab
2 ab ab ab
3 aa aa aa
4 bb bb bb), header=TRUE)
closeAllConnections()

countAB - function(x) {
  aa - length(which(x == aa))
  ab - length(which(x == ab))
  bb - length(which(x == bb))
  Result - c(aa, ab, bb)
  return(Result)
}

Counts - as.data.frame(t(apply(dat, 1, countAB)))
names(Counts) - c(aa, ab, bb)

Best,
Ista

On Tuesday 18 May 2010 10:12:49 am M.Ribeiro wrote:
 Hi,
 I am sure there is an easy way to do it, but I can't find it.
 I have a data frame that has 15 columns and 7000 rows.
 
 The only values inside the data.frame are aa, ab, bb as you can see
 an example bellow.
 
1  2  3
 1 aa ab ab
 2 ab ab ab
 3 aa aa aa
 4 bb bb bb
 
 What I would like to do, is to generate a vector (or another data.frame)
 with 7000 rows, and 3 columns. In the first column, the information about
 how many aa, the second about how many ab, and the third about how many bb
 are there in each line
   aa  ab  bb
 1  1   2   0
 2  0   2   0
 3  3   0   0
 4  0   0   3
 
 Thank you very much
 Cheers

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


[R] (no subject)

2010-05-18 Thread Arantzazu Blanco Bernardeau

Hello
I have a data array with soil variables (caperf), in which the variable clay 
is factor (as I see entering str(caperf)) . I need to do a regression model, so 
I need to have arcilla (=clay) as a numeric variable.  For that I have entered

as.numeric(as.character(arcilla))

and even entering
 'as.numeric(levels(arcilla))[arcilla]'the variable is resting as factor, and 
the linear model is not valid (for my purposes).
The decimal commas have been converted to decimal points, so I have no idea of 
what to do.
Thanks a lot


Arantzazu Blanco Bernardeau
Dpto de Química Agrícola, Geología y Edafología  
Universidad de Murcia-Campus de Espinardo





  
_
Diseñar aplicaciones tiene premio. ¡Si eres desarrollador no esperes más!

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


[R] avoiding reinstall already installed library

2010-05-18 Thread milton ruser
Dear R-experts,

I am installing new libraries using
install.packages(ggplot2,dependencies=T).
But I perceive that many dependencies are already installed. As I am using
a low-band internet, how can avoid reinstall installed libraries?

cheers

milton

[[alternative HTML version deleted]]

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


Re: [R] Counting Frequencies in Data Frame

2010-05-18 Thread William Dunlap
 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of M.Ribeiro
 Sent: Tuesday, May 18, 2010 7:13 AM
 To: r-help@r-project.org
 Subject: [R] Counting Frequencies in Data Frame
 
 
 Hi,
 I am sure there is an easy way to do it, but I can't find it.
 I have a data frame that has 15 columns and 7000 rows.
 
 The only values inside the data.frame are aa, ab, bb as 
 you can see an
 example bellow.
 
1  2  3
 1 aa ab ab
 2 ab ab ab
 3 aa aa aa
 4 bb bb bb
 
 What I would like to do, is to generate a vector (or another 
 data.frame)
 with 7000 rows, and 3 columns. In the first column, the 
 information about
 how many aa, the second about how many ab, and the third 
 about how many bb
 are there in each line
   aa  ab  bb
 1  1   2   0
 2  0   2   0
--  3?  --
 3  3   0   0
 4  0   0   3

You could make a table (a sort of matrix) of the
data entries and their row numbers:
  
   tmp - read.table(header=TRUE, check.names=FALSE, textConnection(
  +1  2  3
  + 1 aa ab ab
  + 2 ab ab ab
  + 3 aa aa aa
  + 4 bb bb bb
  + ))
   table(row(tmp), as.matrix(tmp))
 
  aa ab bb
1  1  2  0
2  0  3  0
3  3  0  0
4  0  0  3

The as.matrix() is needed to force all the columns of the
data.frame into one vector.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 
 
 Thank you very much
 Cheers
 -- 
 View this message in context: 
 http://r.789695.n4.nabble.com/Counting-Frequencies-in-Data-Fra
me-tp2221342p2221342.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 

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


[R] Re: Change class factor to numeric

2010-05-18 Thread Arantzazu Blanco Bernardeau


sorry I had a mistake sending my question without a subject. I do resend again. 
Please excuse me.
 Hello
 I have a data array with soil variables (caperf), in which the variable 
 clay is factor (as I see entering str(caperf)) . I need to do a regression 
 model, so I need to have arcilla (=clay) as a numeric variable.  For that I 
 have entered

 as.numeric(as.character(arcilla))

 and even entering
 'as.numeric(levels(arcilla))[arcilla]'the variable is resting as factor, and 
 the linear model is not valid (for my purposes).
 The decimal commas have been converted to decimal points, so I have no idea 
 of what to do.
 Thanks a lot


 Arantzazu Blanco Bernardeau
 Dpto de Química Agrícola, Geología y Edafología
 Universidad de Murcia-Campus de Espinardo






 _
 Diseñar aplicaciones tiene premio. ¡Si eres desarrollador no esperes más!
 http://www.imaginemobile.es
  
_
Recibe en tu HOTMAIL los emails de TODAS tus CUENTAS. + info

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


Re: [R] avoiding reinstall already installed library

2010-05-18 Thread Steve Lianoglou
Hi,

On Tue, May 18, 2010 at 11:36 AM, milton ruser milton.ru...@gmail.com wrote:
 Dear R-experts,

 I am installing new libraries using
 install.packages(ggplot2,dependencies=T).
 But I perceive that many dependencies are already installed. As I am using
 a low-band internet, how can avoid reinstall installed libraries?

Look at the description of the dependencies argument in the
?instal.packages help:

logical indicating to also install uninstalled packages on which
these packages ...

It looks like your concern is already taken care of.

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

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


Re: [R] Re: Change class factor to numeric

2010-05-18 Thread milton ruser
Try

arcilla-as.numeric(as.character(clay))

best

milton

On Tue, May 18, 2010 at 12:36 PM, Arantzazu Blanco Bernardeau 
aramu...@hotmail.com wrote:



 sorry I had a mistake sending my question without a subject. I do resend
 again. Please excuse me.
  Hello
  I have a data array with soil variables (caperf), in which the variable
 clay is factor (as I see entering str(caperf)) . I need to do a regression
 model, so I need to have arcilla (=clay) as a numeric variable.  For that I
 have entered
 
  as.numeric(as.character(arcilla))
 
  and even entering
  'as.numeric(levels(arcilla))[arcilla]'the variable is resting as factor,
 and the linear model is not valid (for my purposes).
  The decimal commas have been converted to decimal points, so I have no
 idea of what to do.
  Thanks a lot
 
 
  Arantzazu Blanco Bernardeau
  Dpto de Química Agrícola, Geología y Edafología
  Universidad de Murcia-Campus de Espinardo
 
 
 
 
 
 
  _
  Diseñar aplicaciones tiene premio. ¡Si eres desarrollador no esperes más!
  http://www.imaginemobile.es

 _
 Recibe en tu HOTMAIL los emails de TODAS tus CUENTAS. + info

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


[[alternative HTML version deleted]]

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


Re: [R] avoiding reinstall already installed *package*

2010-05-18 Thread Martin Maechler
{ I've modified the subject; I can't stand it hitting square into
  my face ... }

 mr == milton ruser milton.ru...@gmail.com
 on Tue, 18 May 2010 12:36:23 -0300 writes:

mr Dear R-experts,
mr I am installing new libraries using
mr install.packages(ggplot2,dependencies=T).
mr But I perceive that many dependencies are already installed. As I am 
using
mr a low-band internet, how can avoid reinstall installed libraries?

There's no problem with installed libraries, as ... 
they DO NOT EXIST.

These are *PACKAGES* !
Why do you think are you talking about the function

 install.packages()  
 

---
To answer the question you did want to ask:

Do not be afraid:  Depedencies are only installed when needed,
i.e., no package will be downloaded and installed if it already
is there.

Martin Maechler, ETH Zurich

mr cheers

mr milton

mr [[alternative HTML version deleted]]

(another thing you should learn to avoid, please)

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


Re: [R] BRugs under Linux?

2010-05-18 Thread Uwe Ligges



On 17.05.2010 18:46, Kevin E. Thorpe wrote:

Hello.

In this post:

http://finzi.psych.upenn.edu/Rhelp10/2010-March/233815.html

Uwe Ligges suggests using BRugs rather than R2WinBUGS under windows. He
also notes that it is not in the main CRAN repository, but it is in
extras which is a default repository under windows.

I have OpenBUGS 3.1.0 (the latest that has a native Linux version which
is no longer called linBUGS) installed on my Linux box and would like to
interact with it from R. I see posts on this from 2009, but these
predate the 3.1.0 version, so I'm wonering if there is anything new here.

Is BRugs the recommended approach from Linux? If so, the required
repository is not a default on my installation. What is the address of
the repository where this will be found? If BRugs is not the best
solution from Linux, can anyone suggest a better alternative?



OpenBUGS 3.0.3 (which is linked in BRugs) did not work under Linux (at 
least not on arbitrary Linux systems, some people claim to got it 
working), hence there is no such BRugs version for Linux.


Currently, BRugs is being restructured for the new OpenBUGS version 
(thanks to the great help by Chris Jackson) and I am rather confident 
that we get a new BRugs version out within a month or two that *may* 
work under Linux as well. But I cannot yet promise the latter.


Best wishes,
Uwe





Note that I also know about jags and have that installed also, but until
I become a bit more familiar with this software I'm starting from BUGS.

Kevin



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


Re: [R] Re: Change class factor to numeric

2010-05-18 Thread Ivan Calandra

Hi,

I think that providing the output from str(data array or whatever you 
have) would help.

Because, for now, we don't have much idea of what you really have.
Moreover, some sample data is always welcomed (using the function dput 
for example)


Ivan


Le 5/18/2010 17:36, Arantzazu Blanco Bernardeau a écrit :


sorry I had a mistake sending my question without a subject. I do resend again. 
Please excuse me.
   

Hello
I have a data array with soil variables (caperf), in which the variable clay 
is factor (as I see entering str(caperf)) . I need to do a regression model, so I need to 
have arcilla (=clay) as a numeric variable.  For that I have entered

as.numeric(as.character(arcilla))

and even entering
'as.numeric(levels(arcilla))[arcilla]'the variable is resting as factor, and 
the linear model is not valid (for my purposes).
The decimal commas have been converted to decimal points, so I have no idea of 
what to do.
Thanks a lot


Arantzazu Blanco Bernardeau
Dpto de Química Agrícola, Geología y Edafología
Universidad de Murcia-Campus de Espinardo






_
Diseñar aplicaciones tiene premio. ¡Si eres desarrollador no esperes más!
http://www.imaginemobile.es
 


_
Recibe en tu HOTMAIL los emails de TODAS tus CUENTAS. + info

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

   


--
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Museum
Abt. Säugetiere
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231
ivan.calan...@uni-hamburg.de

**
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php

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


Re: [R] survey package: weights used in svycoxph()

2010-05-18 Thread Thomas Lumley

On Mon, 17 May 2010, Vinh Nguyen wrote:


Dear R-help,

Let me know if I should email r-devel instead of this list.  This
message is addressed to Professor Lumley or anyone familiar with the
survey package.

Does svycoxph() implement the method outlined in Binder 1992 as
referenced in the help file?


Yes. That's why it's referenced.


That is, are weights incorporated in the
ratio term (numerator and denominator) of the estimating equation?


Yes.

  I

don't believe so since svycoxph() calls coxph() of the survival
package and weights are applied once in the estimating equation.  If
the weights are implemented in the ratio, could you point me to where
in the code this is done?  I would like to estimate as in Binder but
with custom weights.  Thanks.


It happens inside the C code called by coxph(), eg, in survival/src/coxfit2.c

Binder's estimating equations are the usual way of applying weights to a Cox model, so 
nothing special is done apart from calling coxph(). To quote the author of the survival 
package, Terry Therneau, Other formulae change in the obvious way, eg, the weighted 
mean $\bar Z$ is changed to include both the risk weights $r$ and the external weights 
$w$. [Mayo Clinic Biostatistics technical report #52, section 6.2.2]



This is mentioned in the help file but I don't quite understand:
The main difference between svycoxph function and the robust=TRUE
option to coxph in the
survival package is that this function accounts for the reduction in
variance from stratified sampling
and the increase in variance from having only a small number of clusters.


The point estimates from coxph() are the same as those from svycoxph() (with 
the same weights).  The standard errors are almost the same.  There are two 
differences.  The first is the use of 1/(nclusters -1) rather than 1/nclusters 
as a divisor.  The second is that svycoxph() computes variances using 
estimating functions centered at zero in each *sampling* stratum whereas 
coxph() centers them at zero in each baseline hazard stratum, as supplied in 
the strata() argument to coxph().

 -thomas

Thomas Lumley   Assoc. Professor, Biostatistics
tlum...@u.washington.eduUniversity of Washington, Seattle

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


Re: [R] (no subject)

2010-05-18 Thread Steve Lianoglou
Hi,

Sorry, I'm not really getting what going on here ... perhaps having
more domain knowledge would help me make better sense of our question.

In particular:

On Tue, May 18, 2010 at 11:35 AM, Arantzazu Blanco Bernardeau
aramu...@hotmail.com wrote:

 Hello
 I have a data array with soil variables (caperf), in which the variable 
 clay is factor (as I see entering str(caperf)) . I need to do a regression 
 model, so I need to have arcilla (=clay) as a numeric variable.  For that I 
 have entered

 as.numeric(as.character(arcilla))

 and even entering
  'as.numeric(levels(arcilla))[arcilla]'

The above code doesn't make sense to me ...

Perhaps cleaning up your question and providing some reproducible
example we can use to help show you the light (just describing what a
variable has isn't enough -- give us minimal code we can paste into R
that reproduces your problem).

Alternatively, depending no what your levels mean, you might want to
recode your data using dummy variables (I'm not sure if that's the
official term) .. this is what I mean:

http://dss.princeton.edu/online_help/analysis/dummy_variables.htm

In your example, let's say you have four levels for clay ... maybe
soft, hard, smooth, red

Instead of only using 1 variable with values 1-4, you would recode
this into 4 variables with values 0,1

So, if one example has a value of smooth for clay. Instead of coding it like:
clay: 3

You would do:
soft: 0
hard: 0
smooth: 1
red : 0

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

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


Re: [R] Re: Change class factor to numeric

2010-05-18 Thread Arantzazu Blanco Bernardeau

Hello
so, here you have the output of the data frame. The data frame comes from a csv 
file. 
I could take Gr_2 instead of arcilla, because it is the same value... but 
curiously, it is a factor as well. 
 str(caperf)
'data.frame':    556 obs. of  38 variables:
 $ Hoja    : int  818 818 818 818 818 818 818 818 818 818 ...
 $ idmuestra   : Factor w/ 555 levels 1015-I,1015-II,..: 26 27 28 29 31 32 
33 34 30 35 ...
 $ Año : int  1994 1994 1994 1994 1994 1994 1994 1994 1994 1994 ...
 $ x   : int  655500 633050 632200 635000 637150 643700 655300 648000 
653400 646200 ...
 $ y   : int  4285800 4283050 4298150 429 4294800 4288850 4282700 
4290350 4298450 4296650 ...
 $ CO_gkg1 : num  3.7 6.5 6.3 2.6 12.1 6.9 3.5 10.8 10.3 3.3 ...
 $ NTgkg_1 : num  0.53 1.01 0.66 0.42 1.3 0.82 0.43 1.31 0.85 0.51 ...
 $ C_Nratio    : num  6.98 6.46 9.55 6.18 9.33 ...
 $ C03Ca   : num  53.6 38 1.2 1.1 21.1 ...
 $ pHw : num  8 8.4 8.3 8.4 8.45 8.2 8.4 8.4 8.1 8.4 ...
 $ pHClK   : num  7.5 7.4 7.2 7.4 8.3 7.5 7.8 7.4 7.4 7.5 ...
 $ CCC : num  9.7 14.4 10.5 7.2 12.8 ...
 $ CEdSm   : num  0.62 0.72 0.38 0.36 19.35 ...
 $ pF1_3atm    : num  25.4 21.3 9.1 12.8 24.1 ...
 $ pF15atm : num  15.3 10.6 5.8 6.1 8.45 11 3.7 18.8 10 14.3 ...
 $ Gr_2    : Factor w/ 391 levels 0,0.71,0.9,..: 200 31 158 36 142 60 
377 263 140 151 ...
 $ Gr2_20  : num  19.1 39.1 2.9 5.2 NA 12.5 5.7 29.5 17.3 10.5 ...
 $ Gr20_50 : num  17.6 9.8 4.7 4 NA 10.4 4.2 13.3 12.5 7.8 ...
 $ Gr50_100    : num  14.1 12.2 7.6 9 NA 9.1 6.1 8.5 9.1 18.9 ...
 $ Gr100_250   : num  13.4 17.1 28.7 46.2 NA 20.8 28.7 13.6 16.8 32.9 ...
 $ Gr250_500   : num  7.1 5.7 28.8 15.2 NA 24.7 23.4 3.8 11.4 6.9 ...
 $ Gr500_1000  : num  4 1.8 5 3.9 NA 4.2 14.3 0.9 8.9 2.1 ...
 $ Gr1000_2000 : num  1.4 2 1.9 4 NA 4.1 8.9 0.4 4.8 0.9 ...
 $ arcilla : Factor w/ 391 levels 0,0.71,0.9,..: 201 32 158 37 NA 61 
377 263 141 151 ...
 $ limo    : num  36.7 48.9 7.6 9.2 0 22.9 9.9 42.8 29.8 18.3 ...
 $ arena   : num  40 38.8 72 78.3 0 62.9 81.4 27.2 51 61.7 ...
 $ SUMA    : Factor w/ 15 levels 0,100,100.2,..: 2 2 2 2 1 2 2 2 2 2 
...
 $ codusosuelo : logi  NA NA NA NA NA NA ...
 $ pendiente   : Factor w/ 9 levels 0,1,2,3,..: 3 2 3 3 2 4 3 2 2 3 ...
 $ profutil    : logi  NA NA NA NA NA NA ...
 $ profutil.1  : int  50 110 120 40 80 52 30 120 37 80 ...
 $ pedregosidad: int  0 0 0 2 0 4 4 0 3 3 ...
 $ Drenaje : int  4 4 4 4 1 4 5 3 4 4 ...
 $ codsuelo    : num  1.1 2.1 3.1 2.1 12.3 2.5 2.5 4.1 2.5 2.1 ...
 $ textura : logi  NA NA NA NA NA NA ...
 $ m.original  : Factor w/ 7 levels Calizas . dolomías y areniscas,..: 4 7 7 
2 2 7 7 7 7 7 ...
 $ GRUPOPPAL   : Factor w/ 13 levels Arenosoles,Calcisoles,..: 11 2 3 2 12 
2 2 4 2 2 ...
 $ SUELO   : Factor w/ 40 levels Arenosol calcárico,..: 30 3 8 3 36 7 7 
10 7 3 ...

In the other side, the variable Drenaje (drainage) that is factor mode, appears 
as integer. 
Thanks a lot!


Arantzazu Blanco Bernardeau
Dpto de Química Agrícola, Geología y Edafología
Universidad de Murcia-Campus de Espinardo










 Date: Tue, 18 May 2010 17:49:54 +0200
 From: ivan.calan...@uni-hamburg.de
 To:
 Subject: Re: [R] Re: Change class factor to numeric

 Hi,

 I think that providing the output from str(data array or whatever you
 have) would help.
 Because, for now, we don't have much idea of what you really have.
 Moreover, some sample data is always welcomed (using the function dput
 for example)

 Ivan


 Le 5/18/2010 17:36, Arantzazu Blanco Bernardeau a écrit :

 sorry I had a mistake sending my question without a subject. I do resend 
 again. Please excuse me.

 Hello
 I have a data array with soil variables (caperf), in which the variable 
 clay is factor (as I see entering str(caperf)) . I need to do a 
 regression model, so I need to have arcilla (=clay) as a numeric variable. 
 For that I have entered

 as.numeric(as.character(arcilla))

 and even entering
 'as.numeric(levels(arcilla))[arcilla]'the variable is resting as factor, 
 and the linear model is not valid (for my purposes).
 The decimal commas have been converted to decimal points, so I have no idea 
 of what to do.
 Thanks a lot


 Arantzazu Blanco Bernardeau
 Dpto de Química Agrícola, Geología y Edafología
 Universidad de Murcia-Campus de Espinardo






 _
 Diseñar aplicaciones tiene premio. ¡Si eres desarrollador no esperes más!
 http://www.imaginemobile.es


 _
 Recibe en tu HOTMAIL los emails de TODAS tus CUENTAS. + info

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



 --
 Ivan CALANDRA
 PhD Student
 University 

Re: [R] avoiding reinstall already installed *package*

2010-05-18 Thread Ted Harding
On 18-May-10 15:49:37, Martin Maechler wrote:
 { I've modified the subject; I can't stand it hitting square into
   my face ... }
 mr == milton ruser milton.ru...@gmail.com
 on Tue, 18 May 2010 12:36:23 -0300 writes:
 mr Dear R-experts,
 mr I am installing new libraries using
 mr install.packages(ggplot2,dependencies=T).
 mr But I perceive that many dependencies are already installed.
 mr As I am using a low-band internet, how can avoid reinstall
 mr installed libraries?
 
 There's no problem with installed libraries, as ... 
 they DO NOT EXIST.
 
 These are *PACKAGES* !
 Why do you think are you talking about the function
 
  install.packages()  
  

Ah, Martin! I know that package is the official terminology,
but R itself tempts the naive user into deviating from the
True Path. Indeed, I had my fingers burned by this myself,
a long time ago (I'm still licking them ... ).

One might ask: Why do you think we use the function library()?
when loading add-on packages into R. Indeed, the very directory
tree of R itself stores packages under /usr/lib/R/library.

So, once in a while, someone gets it wrong, and has to find it
out the hard way!

Best wishes,
Ted.


E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk
Fax-to-email: +44 (0)870 094 0861
Date: 18-May-10   Time: 17:05:57
-- XFMail --

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


Re: [R] Repeating Name for Rows

2010-05-18 Thread Wu Gong

If I perceive the issue:

Day - c(rep(97, each = 11), rep(98:278, each = 12)) 

-
A R learner.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Repeating-Name-for-Rows-tp2221457p2221492.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] (no subject)

2010-05-18 Thread Arantzazu Blanco Bernardeau

Hello
Well, the problem is, that arcilla is the percentage of clay in the soil 
sample. So, for linear model, I need to work with that number or value. Now, R 
thinks that arcilla (arcilla means clay in spanish), is a factor, and gives me 
the value as a factor, so the output of the linear model is
Call:
lm(formula = formula, data = caperf)

Residuals:
   Min 1Q Median 3Q    Max 
-1.466e+01 -1.376e-15  1.780e-16  2.038e-15  1.279e+01 

Coefficients:
  Estimate Std. Error t value Pr(|t|)    
(Intercept)    1.68964    6.33889   0.267 0.790221    
arcilla0.9 1.90228    8.90888   0.214 0.831239    
arcilla10  1.26371    7.96734   0.159 0.874212    
arcilla10.3   15.70081    9.05141   1.735 0.085090 .  
arcilla10.4    7.27517    7.72806   0.941 0.348183    
arcilla10.45   7.03879    9.02600   0.780 0.436853    
arcilla10.5    2.41241    8.90827   0.271 0.786954    
arcilla10.65  15.44298    9.03879   1.709 0.089838 .  
arcilla10.7   19.35651    9.04675   2.140 0.034185 *  
arcilla10.9    3.55947    9.18501   0.388 0.698974    

[...]

arcilla9.9 6.31949    7.35724   0.859 0.391892    
arcilla#N/A   24.17959    8.87201   2.725 0.007274 ** 
limo   0.24920    0.04605   5.412 2.76e-07 ***
CO_gkg1    0.21015    0.03931   5.346 3.73e-07 ***
C03Ca  0.01711    0.02727   0.628 0.531337    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 

Residual standard error: 6.249 on 135 degrees of freedom
  (50 observations deleted due to missingness)
Multiple R-squared: 0.9736,    Adjusted R-squared: 0.9014 
F-statistic: 13.47 on 370 and 135 DF,  p-value:  2.2e-16 

So, in the desired linear model, arcilla should be just a line, with the valors 
of the linear model.
I hope you understand better more. If not, I could make an english version of 
the file to send, so you can try the commands.
Thanks a lot for your help!



Arantzazu Blanco Bernardeau
Dpto de Química Agrícola, Geología y Edafología
Universidad de Murcia-Campus de Espinardo










 Date: Tue, 18 May 2010 11:54:20 -0400
 Subject: Re: [R] (no subject)
 From: mailinglist.honey...@gmail.com
 To: aramu...@hotmail.com
 CC: r-help@r-project.org

 Hi,

 Sorry, I'm not really getting what going on here ... perhaps having
 more domain knowledge would help me make better sense of our question.

 In particular:

 On Tue, May 18, 2010 at 11:35 AM, Arantzazu Blanco Bernardeau
  wrote:

 Hello
 I have a data array with soil variables (caperf), in which the variable 
 clay is factor (as I see entering str(caperf)) . I need to do a regression 
 model, so I need to have arcilla (=clay) as a numeric variable.  For that I 
 have entered

 as.numeric(as.character(arcilla))

 and even entering
  'as.numeric(levels(arcilla))[arcilla]'

 The above code doesn't make sense to me ...

 Perhaps cleaning up your question and providing some reproducible
 example we can use to help show you the light (just describing what a
 variable has isn't enough -- give us minimal code we can paste into R
 that reproduces your problem).

 Alternatively, depending no what your levels mean, you might want to
 recode your data using dummy variables (I'm not sure if that's the
 official term) .. this is what I mean:

 http://dss.princeton.edu/online_help/analysis/dummy_variables.htm

 In your example, let's say you have four levels for clay ... maybe
 soft, hard, smooth, red

 Instead of only using 1 variable with values 1-4, you would recode
 this into 4 variables with values 0,1

 So, if one example has a value of smooth for clay. Instead of coding it 
 like:
 clay: 3

 You would do:
 soft: 0
 hard: 0
 smooth: 1
 red : 0

 -steve
 --
 Steve Lianoglou
 Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
 Contact Info: http://cbio.mskcc.org/~lianos/contact
  
_
Consejos para seducir ¿Puedes conocer gente nueva a través de Internet? 
¡Regístrate ya!

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


Re: [R] timing a function

2010-05-18 Thread Gustave Lefou
Dear all,

Just one last question. There seems to be no problem in writing

 z = system.time(y - f(x))

or

 z - system.time(y - f(x))

Then z contains the named vector of the elapsed times, and y the value of
the function f(x).

Am I right ?

Thank you very much,
Gustave

2010/5/17 Alexander Shenkin ashen...@ufl.edu

 You could also put the call to system.time inside the function itself:

 f = function(x) {
system.time({
... #function's code
ret_val = ...
}); flush.console();
return ret_val;
 }

 i s'pose you'd miss out on the time taken to jump to the function code,
 return the value, etc, but for functions that are heavy at all, that
 wouldn't trip you up.

 allie

 On 5/17/2010 2:06 PM, Barry Rowlingson wrote:
  On Mon, May 17, 2010 at 6:24 PM, Peter Ehlers ehl...@ucalgary.ca
 wrote:
 
 
  Try
   system.time(y - f(x))
 
  and see ?=.
 
   -Peter Ehlers
 
   Ah ha. That explains the curly brackets I saw in a posting with
  system.time on stack overflow just now:
 
   system.time({y=f(x)})
 
   works as expected since the {} pair make a new code block. Also you
  can then time more than one statement:
 
   system.time({y=f(x);z=g(y)})
 
   - gives the total time for f(x) and g(y).
 
  Barry
 
   __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 

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


[[alternative HTML version deleted]]

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


Re: [R] avoiding reinstall already installed *package*

2010-05-18 Thread milton ruser
Hi Martin,

thanks for your reply, and very thanks for your kind tips about package
and library
So, I was trying to understand *why* we load packages using library().
I suggest that developers killl the problem on its root, deleting library
function :-)
Good to know already installed packages will not be reinstalled.

cheers

milton

On Tue, May 18, 2010 at 12:49 PM, Martin Maechler 
maech...@stat.math.ethz.ch wrote:

 { I've modified the subject; I can't stand it hitting square into
  my face ... }

  mr == milton ruser milton.ru...@gmail.com
  on Tue, 18 May 2010 12:36:23 -0300 writes:

mr Dear R-experts,
mr I am installing new libraries using
mr install.packages(ggplot2,dependencies=T).
mr But I perceive that many dependencies are already installed. As I am
 using
mr a low-band internet, how can avoid reinstall installed libraries?

 There's no problem with installed libraries, as ...
 they DO NOT EXIST.

 These are *PACKAGES* !
 Why do you think are you talking about the function

  install.packages()  
 

 ---
 To answer the question you did want to ask:

 Do not be afraid:  Depedencies are only installed when needed,
 i.e., no package will be downloaded and installed if it already
 is there.

 Martin Maechler, ETH Zurich

mr cheers

mr milton

mr [[alternative HTML version deleted]]

 (another thing you should learn to avoid, please)



[[alternative HTML version deleted]]

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


Re: [R] Re: Change class factor to numeric

2010-05-18 Thread Ivan Calandra

Hi again,

If you used the function read.table() to read from a csv file into a 
data.frame, it is weird that numeric data are converted into factors.
I would check in the original data that you don't have a typo somewhere. 
I don't know all the possibilities, but a special character can 
definitely make R interpret this variable differently.


For Drenaje, it is normal. In that case you can just use:
caperf$Drenaje - factor(caperf$Drenaje)

HTH
Ivan

Le 5/18/2010 17:59, Arantzazu Blanco Bernardeau a écrit :

Hello
so, here you have the output of the data frame. The data frame comes from a csv 
file.
I could take Gr_2 instead of arcilla, because it is the same value... but 
curiously, it is a factor as well.
   

str(caperf)
 

'data.frame':556 obs. of  38 variables:
  $ Hoja: int  818 818 818 818 818 818 818 818 818 818 ...
  $ idmuestra   : Factor w/ 555 levels 1015-I,1015-II,..: 26 27 28 29 31 32 
33 34 30 35 ...
  $ Año : int  1994 1994 1994 1994 1994 1994 1994 1994 1994 1994 ...
  $ x   : int  655500 633050 632200 635000 637150 643700 655300 648000 
653400 646200 ...
  $ y   : int  4285800 4283050 4298150 429 4294800 4288850 4282700 
4290350 4298450 4296650 ...
  $ CO_gkg1 : num  3.7 6.5 6.3 2.6 12.1 6.9 3.5 10.8 10.3 3.3 ...
  $ NTgkg_1 : num  0.53 1.01 0.66 0.42 1.3 0.82 0.43 1.31 0.85 0.51 ...
  $ C_Nratio: num  6.98 6.46 9.55 6.18 9.33 ...
  $ C03Ca   : num  53.6 38 1.2 1.1 21.1 ...
  $ pHw : num  8 8.4 8.3 8.4 8.45 8.2 8.4 8.4 8.1 8.4 ...
  $ pHClK   : num  7.5 7.4 7.2 7.4 8.3 7.5 7.8 7.4 7.4 7.5 ...
  $ CCC : num  9.7 14.4 10.5 7.2 12.8 ...
  $ CEdSm   : num  0.62 0.72 0.38 0.36 19.35 ...
  $ pF1_3atm: num  25.4 21.3 9.1 12.8 24.1 ...
  $ pF15atm : num  15.3 10.6 5.8 6.1 8.45 11 3.7 18.8 10 14.3 ...
  $ Gr_2: Factor w/ 391 levels 0,0.71,0.9,..: 200 31 158 36 142 
60 377 263 140 151 ...
  $ Gr2_20  : num  19.1 39.1 2.9 5.2 NA 12.5 5.7 29.5 17.3 10.5 ...
  $ Gr20_50 : num  17.6 9.8 4.7 4 NA 10.4 4.2 13.3 12.5 7.8 ...
  $ Gr50_100: num  14.1 12.2 7.6 9 NA 9.1 6.1 8.5 9.1 18.9 ...
  $ Gr100_250   : num  13.4 17.1 28.7 46.2 NA 20.8 28.7 13.6 16.8 32.9 ...
  $ Gr250_500   : num  7.1 5.7 28.8 15.2 NA 24.7 23.4 3.8 11.4 6.9 ...
  $ Gr500_1000  : num  4 1.8 5 3.9 NA 4.2 14.3 0.9 8.9 2.1 ...
  $ Gr1000_2000 : num  1.4 2 1.9 4 NA 4.1 8.9 0.4 4.8 0.9 ...
  $ arcilla : Factor w/ 391 levels 0,0.71,0.9,..: 201 32 158 37 NA 61 
377 263 141 151 ...
  $ limo: num  36.7 48.9 7.6 9.2 0 22.9 9.9 42.8 29.8 18.3 ...
  $ arena   : num  40 38.8 72 78.3 0 62.9 81.4 27.2 51 61.7 ...
  $ SUMA: Factor w/ 15 levels 0,100,100.2,..: 2 2 2 2 1 2 2 2 2 2 
...
  $ codusosuelo : logi  NA NA NA NA NA NA ...
  $ pendiente   : Factor w/ 9 levels 0,1,2,3,..: 3 2 3 3 2 4 3 2 2 3 ...
  $ profutil: logi  NA NA NA NA NA NA ...
  $ profutil.1  : int  50 110 120 40 80 52 30 120 37 80 ...
  $ pedregosidad: int  0 0 0 2 0 4 4 0 3 3 ...
  $ Drenaje : int  4 4 4 4 1 4 5 3 4 4 ...
  $ codsuelo: num  1.1 2.1 3.1 2.1 12.3 2.5 2.5 4.1 2.5 2.1 ...
  $ textura : logi  NA NA NA NA NA NA ...
  $ m.original  : Factor w/ 7 levels Calizas . dolomías y areniscas,..: 4 7 7 
2 2 7 7 7 7 7 ...
  $ GRUPOPPAL   : Factor w/ 13 levels Arenosoles,Calcisoles,..: 11 2 3 2 12 
2 2 4 2 2 ...
  $ SUELO   : Factor w/ 40 levels Arenosol calcárico,..: 30 3 8 3 36 7 7 
10 7 3 ...

In the other side, the variable Drenaje (drainage) that is factor mode, appears 
as integer.
Thanks a lot!


Arantzazu Blanco Bernardeau
Dpto de Química Agrícola, Geología y Edafología
Universidad de Murcia-Campus de Espinardo










   

Date: Tue, 18 May 2010 17:49:54 +0200
From: ivan.calan...@uni-hamburg.de
To:
Subject: Re: [R] Re: Change class factor to numeric

Hi,

I think that providing the output from str(data array or whatever you
have) would help.
Because, for now, we don't have much idea of what you really have.
Moreover, some sample data is always welcomed (using the function dput
for example)

Ivan


Le 5/18/2010 17:36, Arantzazu Blanco Bernardeau a écrit :
 

sorry I had a mistake sending my question without a subject. I do resend again. 
Please excuse me.

   

Hello
I have a data array with soil variables (caperf), in which the variable clay 
is factor (as I see entering str(caperf)) . I need to do a regression model, so I need to 
have arcilla (=clay) as a numeric variable. For that I have entered

as.numeric(as.character(arcilla))

and even entering
'as.numeric(levels(arcilla))[arcilla]'the variable is resting as factor, and 
the linear model is not valid (for my purposes).
The decimal commas have been converted to decimal points, so I have no idea of 
what to do.
Thanks a lot


Arantzazu Blanco Bernardeau
Dpto de Química Agrícola, Geología y Edafología
Universidad de Murcia-Campus de Espinardo






_
Diseñar 

Re: [R] (no subject)

2010-05-18 Thread Steve Lianoglou
One last thing:

before you take my advice on how to recode your nominal/categorical
clay variable for your regression model, take some time to see how
other people talk about this and do some searching on phrases like
regression model with nominal variables (that's just the one I
used).

You'll find more (and better) advice on how to do it correctly.

-steve

On Tue, May 18, 2010 at 11:54 AM, Steve Lianoglou
mailinglist.honey...@gmail.com wrote:
 Hi,

 Sorry, I'm not really getting what going on here ... perhaps having
 more domain knowledge would help me make better sense of our question.

 In particular:

 On Tue, May 18, 2010 at 11:35 AM, Arantzazu Blanco Bernardeau
 aramu...@hotmail.com wrote:

 Hello
 I have a data array with soil variables (caperf), in which the variable 
 clay is factor (as I see entering str(caperf)) . I need to do a regression 
 model, so I need to have arcilla (=clay) as a numeric variable.  For that I 
 have entered

 as.numeric(as.character(arcilla))

 and even entering
  'as.numeric(levels(arcilla))[arcilla]'

 The above code doesn't make sense to me ...

 Perhaps cleaning up your question and providing some reproducible
 example we can use to help show you the light (just describing what a
 variable has isn't enough -- give us minimal code we can paste into R
 that reproduces your problem).

 Alternatively, depending no what your levels mean, you might want to
 recode your data using dummy variables (I'm not sure if that's the
 official term) .. this is what I mean:

 http://dss.princeton.edu/online_help/analysis/dummy_variables.htm

 In your example, let's say you have four levels for clay ... maybe
 soft, hard, smooth, red

 Instead of only using 1 variable with values 1-4, you would recode
 this into 4 variables with values 0,1

 So, if one example has a value of smooth for clay. Instead of coding it 
 like:
 clay: 3

 You would do:
 soft: 0
 hard: 0
 smooth: 1
 red : 0

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




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

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


[R] unsigned 4 byte number

2010-05-18 Thread tetonedge

Does anybody know how to read in a unsigned 4 byte number from a binary file?
According to the help for readBin, the signed argument only applies to
size=1 or 2. But if you declare any size larger it assumes it is signed?
Thanks
-- 
View this message in context: 
http://r.789695.n4.nabble.com/unsigned-4-byte-number-tp2221555p2221555.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] (no subject)

2010-05-18 Thread Peter Ehlers

Arantzazu,

Your problem is that the data were probably imported
from Excel where you had at least one cell containing #N/A.
You need to replace those cases in your dataframe with NA.
Then you should be able to do as.numeric(as.character(arcilla)).

 -Peter Ehlers

On 2010-05-18 10:07, Arantzazu Blanco Bernardeau wrote:


Hello
Well, the problem is, that arcilla is the percentage of clay in the soil 
sample. So, for linear model, I need to work with that number or value. Now, R 
thinks that arcilla (arcilla means clay in spanish), is a factor, and gives me 
the value as a factor, so the output of the linear model is
Call:
lm(formula = formula, data = caperf)

Residuals:
Min 1Q Median 3QMax
-1.466e+01 -1.376e-15  1.780e-16  2.038e-15  1.279e+01

Coefficients:
   Estimate Std. Error t value Pr(|t|)
(Intercept)1.689646.33889   0.267 0.790221
arcilla0.9 1.902288.90888   0.214 0.831239
arcilla10  1.263717.96734   0.159 0.874212
arcilla10.3   15.700819.05141   1.735 0.085090 .
arcilla10.47.275177.72806   0.941 0.348183
arcilla10.45   7.038799.02600   0.780 0.436853
arcilla10.52.412418.90827   0.271 0.786954
arcilla10.65  15.442989.03879   1.709 0.089838 .
arcilla10.7   19.356519.04675   2.140 0.034185 *
arcilla10.93.559479.18501   0.388 0.698974

[...]

arcilla9.9 6.319497.35724   0.859 0.391892


=== arcilla#N/A   24.179598.87201   2.725 0.007274 **


limo   0.249200.04605   5.412 2.76e-07 ***
CO_gkg10.210150.03931   5.346 3.73e-07 ***
C03Ca  0.017110.02727   0.628 0.531337
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 6.249 on 135 degrees of freedom
   (50 observations deleted due to missingness)
Multiple R-squared: 0.9736,Adjusted R-squared: 0.9014
F-statistic: 13.47 on 370 and 135 DF,  p-value:  2.2e-16

So, in the desired linear model, arcilla should be just a line, with the valors 
of the linear model.
I hope you understand better more. If not, I could make an english version of 
the file to send, so you can try the commands.
Thanks a lot for your help!



Arantzazu Blanco Bernardeau
Dpto de Química Agrícola, Geología y Edafología
Universidad de Murcia-Campus de Espinardo



[snip]

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


Re: [R] Using the zero-inflated binomial in experimental designs

2010-05-18 Thread Ben Bolker
Ivan Allaman ivanalaman at yahoo.com.br writes:

 
 
 I'm trying to use the inflated binomial distribution of zeros (since 75% of
 the values are zeros) in a randomized block experiment with four
 quantitative treatments (0, 0.5, 1, 1.5), but I'm finding it difficult,
 since the examples available in VGAM packages like for example, leave us
 unsure of how it should be the data.frame for such analysis. Unfortunately
 the function glm does not have an option to place a family of this kind I'm
 about, because if I had, it would be easy, made that my goal is simple, just
 wanting to compare the treatments. For that you have an idea, here is an
 example of my database.
 
 BLOCK NIVNT   MUMI
 Inicial   0  18 0 

[snip]

 
 where: NIV are the treatments; NT is the total number of piglets born; Mumi
 is the number of mummified piglets NT. Mumi The variable is of interest. If
 someone can tell me some stuff on how I can do these tests in R, similar to
 what I would do using the function glm, I'd be grateful.
 I thank everyone's attention.

something like comparing the likelihoods of

m1 - vglm(cbind(MUMI,NT-MUMI)~NIV*BLOCK,zibinomial,data=mydata)
m2 - vglm(cbind(MUMI,NT-MUMI)~NIV+BLOCK,zibinomial,data=mydata)
m3 - vglm(cbind(MUMI,NT-MUMI)~BLOCK,zibinomial,data=mydata)

I don't know whether the anova() method works for VGLM objects
or not.

  By the way, 75% zeroes doesn't necessarily imply zero-inflation --
perhaps it just means a low incidence?

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


[R] Function that is giving me a headache- any help appreciated (automatic read )

2010-05-18 Thread stephen sefick
note: whole function is below- I am sure I am doing something silly.

when I use it like USGS(input=precipitation) it is choking on the


precip.1 - subset(DF, precipitation!=NA)
b - ddply(precip.1$precipitation, .(precip.1$gauge_name), cumsum)
DF.precip - precip.1
DF.precip$precipitation - b$.data

part, but runs fine outside of the function:

days=7
input=precipitation
require(chron)
require(gsubfn)
require(ggplot2)
require(plyr)
#021973269 is the Waynesboro Gauge on the Savannah River Proper (SRS)
#02102908 is the Flat Creek Gauge (ftbrfcms)
#02133500 is the Drowning Creek (ftbrbmcm)
#02341800 is the Upatoi Creek Near Columbus (ftbn)
#02342500 is the Uchee Creek Near Fort Mitchell (ftbn)
#02203000 is the Canoochee River Near Claxton (ftst)
#02196690 is the Horse Creek Gauge at Clearwater, S.C.

a - http://waterdata.usgs.gov/nwis/uv?format=rdbperiod=;
b - site_no=021973269,02102908,02133500,02341800,02342500,02203000,02196690
z - paste(a, days, b, sep=)
L - readLines(z)

#look for the data with USGS in front of it (this take advantage of
#the agency column)
L.USGS - grep(^USGS, L, value = TRUE)
DF - read.table(textConnection(L.USGS), fill = TRUE)
colnames(DF) - c(agency, gauge, date, time, time_zone,
gauge_height,
discharge, precipitation)
pat - ^# +USGS +([0-9]+) +(.*)
L.DD - grep(pat, L, value = TRUE)
library(gsubfn)
DD - strapply(L.DD, pat, c, simplify = rbind)
DDdf - data.frame(gauge = as.numeric(DD[,1]), gauge_name = DD[,2])
both - merge(DF, DDdf, by = gauge, all.x = TRUE)

dts - as.character(both[,date])
tms - as.character(both[,time])
date_time - as.chron(paste(dts, tms), %Y-%m-%d %H:%M)
DF - data.frame(Date=as.POSIXct(date_time), both)
#change precip to numeric
DF[,precipitation] - as.numeric(as.character(DF[,precipitation]))

precip.1 - subset(DF, precipitation!=NA)
b - ddply(precip.1$precipitation, .(precip.1$gauge_name), cumsum)
DF.precip - precip.1
DF.precip$precipitation - b$.data

#discharge
if(input==data){

return(DF)

}else{

qplot(Date, discharge, data=DF,
geom=line, ylab=Date)+facet_wrap(~gauge_name,
scales=free_y)+coord_trans(y=log10)}

if(input==precipitation){
#precipitation
qplot(Date, precipitation, data=DF.precip,
geom=line)+facet_wrap(~gauge_name, scales=free_y)

}else{

qplot(Date, discharge, data=DF,
geom=line, ylab=Date)+facet_wrap(~gauge_name,
scales=free_y)+coord_trans(y=log10)}

below is the whole function:

USGS - function(input=discharge, days=7){
require(chron)
require(gsubfn)
require(ggplot2)
require(plyr)
#021973269 is the Waynesboro Gauge on the Savannah River Proper (SRS)
#02102908 is the Flat Creek Gauge (ftbrfcms)
#02133500 is the Drowning Creek (ftbrbmcm)
#02341800 is the Upatoi Creek Near Columbus (ftbn)
#02342500 is the Uchee Creek Near Fort Mitchell (ftbn)
#02203000 is the Canoochee River Near Claxton (ftst)
#02196690 is the Horse Creek Gauge at Clearwater, S.C.

a - http://waterdata.usgs.gov/nwis/uv?format=rdbperiod=;
b - site_no=021973269,02102908,02133500,02341800,02342500,02203000,02196690
z - paste(a, days, b, sep=)
L - readLines(z)

#look for the data with USGS in front of it (this take advantage of
#the agency column)
L.USGS - grep(^USGS, L, value = TRUE)
DF - read.table(textConnection(L.USGS), fill = TRUE)
colnames(DF) - c(agency, gauge, date, time, time_zone,
gauge_height,
discharge, precipitation)
pat - ^# +USGS +([0-9]+) +(.*)
L.DD - grep(pat, L, value = TRUE)
library(gsubfn)
DD - strapply(L.DD, pat, c, simplify = rbind)
DDdf - data.frame(gauge = as.numeric(DD[,1]), gauge_name = DD[,2])
both - merge(DF, DDdf, by = gauge, all.x = TRUE)

dts - as.character(both[,date])
tms - as.character(both[,time])
date_time - as.chron(paste(dts, tms), %Y-%m-%d %H:%M)
DF - data.frame(Date=as.POSIXct(date_time), both)
#change precip to numeric
DF[,precipitation] - as.numeric(as.character(DF[,precipitation]))

precip.1 - subset(DF, precipitation!=NA)
b - ddply(precip.1$precipitation, .(precip.1$gauge_name), cumsum)
DF.precip - precip.1
DF.precip$precipitation - b$.data

#discharge
if(input==data){

return(DF)

}else{

qplot(Date, discharge, data=DF,
geom=line, ylab=Date)+facet_wrap(~gauge_name,
scales=free_y)+coord_trans(y=log10)}

if(input==precipitation){
#precipitation
qplot(Date, precipitation, data=DF.precip,
geom=line)+facet_wrap(~gauge_name, scales=free_y)

}else{

qplot(Date, discharge, data=DF,
geom=line, ylab=Date)+facet_wrap(~gauge_name,
scales=free_y)+coord_trans(y=log10)}

}


-- 
Stephen Sefick

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods.  We are mammals, and have not exhausted the
annoying little problems of being mammals.

-K. Mullis

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

[R] FW: Re: Change class factor to numeric

2010-05-18 Thread Arantzazu Blanco Bernardeau

Hello everybody
the problem has been solved. It was my mistake not to be ensured that any N/A 
had dissapeared. I do apologize for the inconveniences caused ;)
friendly greeting sfrom Spain! 



Arantzazu Blanco Bernardeau
Dpto de Química Agrícola, Geología y Edafología
Universidad de Murcia-Campus de Espinardo










 From: aramu...@hotmail.com
 To: ivan.calan...@uni-hamburg.de
 Subject: RE: [R] Re: Change class factor to numeric
 Date: Tue, 18 May 2010 16:36:55 +


 Hallo Ivan
 I do thank you a lot, but as you have read in the last email, I did think 
 that maybe one erroneus typing was indicating R to take it as a factor. I did 
 look again the original dataframe and did find the mistake, and now it works 
 OK. Sorry, but I had done so many reviews of the data frame, that did not 
 think on it before.
 Schon wieder danke schön, und freundliche Grüsse aus Spanien ;)




 Arantzazu Blanco Bernardeau
 Dpto de Química Agrícola, Geología y Edafología
 Universidad de Murcia-Campus de Espinardo









 
 Date: Tue, 18 May 2010 18:28:45 +0200
 From: ivan.calan...@uni-hamburg.de
 To: aramu...@hotmail.com
 Subject: Re: [R] Re: Change class factor to numeric

 As you can notice, I'm writing off list for you to send me your data (as
 csv).
 But do it fast, I'll be leaving soon. If not it might have to wait until
 tomorrow!

 In any case, I'm no expert, so I'm not sure I'll be able to help you.
 And I don't think NAs should be problematic. It might be solved by some
 arguments into the read.table() call.

 Can you also send me the line of code you used to import your csv?

 Ivan

 Le 5/18/2010 18:25, Arantzazu Blanco Bernardeau a écrit :

 Hi again!
 could it be that NA was introduced in the variable for not available 
 values, and being NA a character, it takes everything as factor??
 is the only idea I have, because it is the first time I have this problem
 Thanks a lot, I am really learning! :)


 Arantzazu Blanco Bernardeau
 Dpto de Química Agrícola, Geología y Edafología
 Universidad de Murcia-Campus de Espinardo









 

 Date: Tue, 18 May 2010 18:17:02 +0200
 From: ivan.calan...@uni-hamburg.de
 To: r-help@r-project.org
 Subject: Re: [R] Re: Change class factor to numeric

 Hi again,

 If you used the function read.table() to read from a csv file into a
 data.frame, it is weird that numeric data are converted into factors.
 I would check in the original data that you don't have a typo somewhere.
 I don't know all the possibilities, but a special character can
 definitely make R interpret this variable differently.

 For Drenaje, it is normal. In that case you can just use:
 caperf$Drenaje- factor(caperf$Drenaje)

 HTH
 Ivan

 Le 5/18/2010 17:59, Arantzazu Blanco Bernardeau a écrit :

 Hello
 so, here you have the output of the data frame. The data frame comes from 
 a csv file.
 I could take Gr_2 instead of arcilla, because it is the same value... but 
 curiously, it is a factor as well.


 str(caperf)


 'data.frame': 556 obs. of 38 variables:
 $ Hoja : int 818 818 818 818 818 818 818 818 818 818 ...
 $ idmuestra : Factor w/ 555 levels 1015-I,1015-II,..: 26 27 28 29 31 
 32 33 34 30 35 ...
 $ Año : int 1994 1994 1994 1994 1994 1994 1994 1994 1994 1994 ...
 $ x : int 655500 633050 632200 635000 637150 643700 655300 648000 653400 
 646200 ...
 $ y : int 4285800 4283050 4298150 429 4294800 4288850 4282700 4290350 
 4298450 4296650 ...
 $ CO_gkg1 : num 3.7 6.5 6.3 2.6 12.1 6.9 3.5 10.8 10.3 3.3 ...
 $ NTgkg_1 : num 0.53 1.01 0.66 0.42 1.3 0.82 0.43 1.31 0.85 0.51 ...
 $ C_Nratio : num 6.98 6.46 9.55 6.18 9.33 ...
 $ C03Ca : num 53.6 38 1.2 1.1 21.1 ...
 $ pHw : num 8 8.4 8.3 8.4 8.45 8.2 8.4 8.4 8.1 8.4 ...
 $ pHClK : num 7.5 7.4 7.2 7.4 8.3 7.5 7.8 7.4 7.4 7.5 ...
 $ CCC : num 9.7 14.4 10.5 7.2 12.8 ...
 $ CEdSm : num 0.62 0.72 0.38 0.36 19.35 ...
 $ pF1_3atm : num 25.4 21.3 9.1 12.8 24.1 ...
 $ pF15atm : num 15.3 10.6 5.8 6.1 8.45 11 3.7 18.8 10 14.3 ...
 $ Gr_2 : Factor w/ 391 levels 0,0.71,0.9,..: 200 31 158 36 142 60 
 377 263 140 151 ...
 $ Gr2_20 : num 19.1 39.1 2.9 5.2 NA 12.5 5.7 29.5 17.3 10.5 ...
 $ Gr20_50 : num 17.6 9.8 4.7 4 NA 10.4 4.2 13.3 12.5 7.8 ...
 $ Gr50_100 : num 14.1 12.2 7.6 9 NA 9.1 6.1 8.5 9.1 18.9 ...
 $ Gr100_250 : num 13.4 17.1 28.7 46.2 NA 20.8 28.7 13.6 16.8 32.9 ...
 $ Gr250_500 : num 7.1 5.7 28.8 15.2 NA 24.7 23.4 3.8 11.4 6.9 ...
 $ Gr500_1000 : num 4 1.8 5 3.9 NA 4.2 14.3 0.9 8.9 2.1 ...
 $ Gr1000_2000 : num 1.4 2 1.9 4 NA 4.1 8.9 0.4 4.8 0.9 ...
 $ arcilla : Factor w/ 391 levels 0,0.71,0.9,..: 201 32 158 37 NA 61 
 377 263 141 151 ...
 $ limo : num 36.7 48.9 7.6 9.2 0 22.9 9.9 42.8 29.8 18.3 ...
 $ arena : num 40 38.8 72 78.3 0 62.9 81.4 27.2 51 61.7 ...
 $ SUMA : Factor w/ 15 levels 0,100,100.2,..: 2 2 2 2 1 2 2 2 2 2 ...
 $ codusosuelo : logi NA NA NA NA NA NA ...
 $ pendiente : Factor w/ 9 levels 0,1,2,3,..: 3 2 3 3 2 4 3 2 2 3 
 ...
 $ 

[R] Getting dates in an SPSS file in right format.

2010-05-18 Thread Praveen Surendran
Dear all,

 

I am trying to read an SPSS file into a data frame in R using method
read.spss(),

sample - read.spss(file.name,to.data.frame=TRUE)

 

But dates in the data.frame 'sample' are coming as integers and not in the
actual date format given in the SPSS file.

Appreciate if anyone can help me to solve this problem.

 

Kind Regards,

 

Praveen Surendran

2G, Complex and Adaptive Systems Laboratory (UCD CASL)

School of Medicine and Medical Sciences

University College Dublin

Belfield, Dublin 4

Ireland.

 

Office : +353-(0)1716 5334

Mobile : +353-(0)8793 13071

 


[[alternative HTML version deleted]]

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


Re: [R] avoiding reinstall already installed *package*

2010-05-18 Thread Peter Ehlers

On 2010-05-18 10:05, (Ted Harding) wrote:

On 18-May-10 15:49:37, Martin Maechler wrote:

{ I've modified the subject; I can't stand it hitting square into
   my face ... }

mr == milton rusermilton.ru...@gmail.com
 on Tue, 18 May 2010 12:36:23 -0300 writes:

 mr  Dear R-experts,
 mr  I am installing new libraries using
 mr  install.packages(ggplot2,dependencies=T).
 mr  But I perceive that many dependencies are already installed.
 mr  As I am using a low-band internet, how can avoid reinstall
 mr  installed libraries?

There's no problem with installed libraries, as ...
they DO NOT EXIST.

These are *PACKAGES* !
Why do you think are you talking about the function

  install.packages()  
  


Ah, Martin! I know that package is the official terminology,
but R itself tempts the naive user into deviating from the
True Path. Indeed, I had my fingers burned by this myself,
a long time ago (I'm still licking them ... ).

One might ask: Why do you think we use the function library()?
when loading add-on packages into R. Indeed, the very directory
tree of R itself stores packages under /usr/lib/R/library.

So, once in a while, someone gets it wrong, and has to find it
out the hard way!


Well, I don't know if I've ever disagreed with Ted before,
but here I would (somewhat) disagree. It seems a bit odd that
nobody confuses 'book' with 'library', yet the package/library
problem is persistent. It may have something to do with the
use of 'library' in other computer languages.

Anyway, not long ago there was a suggestion (Rolf Turner's?)
to rename the library() function to something like use(),
but, as I recall, a number of nontrivial objections were
raised.

Of course R stores packages in libraries. That's were books
*should* reside. And it's a good idea to have Martin remind
us now and again that books themselves are not libraries.

But I must confess that I'm no longer much bothered by the
misuse. If it ever leads someone astray in their code, then,
well, they have only themselves to blame.

Cheers,
Peter Ehlers

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


Re: [R] survey package: weights used in svycoxph()

2010-05-18 Thread Vinh Nguyen
On Tue, May 18, 2010 at 8:50 AM, Thomas Lumley tlum...@u.washington.edu wrote:

   I

 don't believe so since svycoxph() calls coxph() of the survival
 package and weights are applied once in the estimating equation.  If
 the weights are implemented in the ratio, could you point me to where
 in the code this is done?  I would like to estimate as in Binder but
 with custom weights.  Thanks.

 It happens inside the C code called by coxph(), eg, in
 survival/src/coxfit2.c


Thank you for your clarification.  I mistakenly assumed weights only
appeared once in the estimating equation, creating a weighted sum of
the score equation.  Thinking in retrospect if the weights are to be
used as case weights they better be in the ratio term as well
(wherever there is an at risk indicator).

 Binder's estimating equations are the usual way of applying weights to a Cox
 model, so nothing special is done apart from calling coxph(). To quote the
 author of the survival package, Terry Therneau, Other formulae change in
 the obvious way, eg, the weighted mean $\bar Z$ is changed to include both
 the risk weights $r$ and the external weights $w$. [Mayo Clinic
 Biostatistics technical report #52, section 6.2.2]

Don't see a section 6.2.2 in this technical report.

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


Re: [R] Getting dates in an SPSS file in right format.

2010-05-18 Thread Chuck Cleland
On 5/18/2010 12:38 PM, Praveen Surendran wrote:
 Dear all,
 
  
 
 I am trying to read an SPSS file into a data frame in R using method
 read.spss(),
 
 sample - read.spss(file.name,to.data.frame=TRUE)
 
  
 
 But dates in the data.frame 'sample' are coming as integers and not in the
 actual date format given in the SPSS file.
 
 Appreciate if anyone can help me to solve this problem.

  Date variables in SPSS contain the number of seconds since
October 14, 1582.  You might try something like this:

sample$MYDATE - as.Date(as.POSIXct(sample$MYDATE, origin=1582-10-14,
tz=GMT))

 Kind Regards,
 
  
 
 Praveen Surendran
 
 2G, Complex and Adaptive Systems Laboratory (UCD CASL)
 
 School of Medicine and Medical Sciences
 
 University College Dublin
 
 Belfield, Dublin 4
 
 Ireland.
 
  
 
 Office : +353-(0)1716 5334
 
 Mobile : +353-(0)8793 13071
 
  
 
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Chuck Cleland, Ph.D.
NDRI, Inc. (www.ndri.org)
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894

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


Re: [R] Function that is giving me a headache- any help appreciated (automatic read )

2010-05-18 Thread John Kane

I don't think you can do this
precipitation!=NA)

have a look at ?is.na

--- On Tue, 5/18/10, stephen sefick ssef...@gmail.com wrote:

 From: stephen sefick ssef...@gmail.com
 Subject: [R] Function that is giving me a headache- any help appreciated 
 (automatic read )
 To: r-help@r-project.org
 Received: Tuesday, May 18, 2010, 12:38 PM
 note: whole function is below- I am
 sure I am doing something silly.
 
 when I use it like USGS(input=precipitation) it is
 choking on the
 
 
 precip.1 - subset(DF, precipitation!=NA)
 b - ddply(precip.1$precipitation,
 .(precip.1$gauge_name), cumsum)
 DF.precip - precip.1
 DF.precip$precipitation - b$.data
 
 part, but runs fine outside of the function:
 
 days=7
 input=precipitation
 require(chron)
 require(gsubfn)
 require(ggplot2)
 require(plyr)
 #021973269 is the Waynesboro Gauge on the Savannah River
 Proper (SRS)
 #02102908 is the Flat Creek Gauge (ftbrfcms)
 #02133500 is the Drowning Creek (ftbrbmcm)
 #02341800 is the Upatoi Creek Near Columbus (ftbn)
 #02342500 is the Uchee Creek Near Fort Mitchell (ftbn)
 #02203000 is the Canoochee River Near Claxton (ftst)
 #02196690 is the Horse Creek Gauge at Clearwater, S.C.
 
 a - http://waterdata.usgs.gov/nwis/uv?format=rdbperiod=;
 b -
 site_no=021973269,02102908,02133500,02341800,02342500,02203000,02196690
 z - paste(a, days, b, sep=)
 L - readLines(z)
 
 #look for the data with USGS in front of it (this take
 advantage of
 #the agency column)
 L.USGS - grep(^USGS, L, value = TRUE)
 DF - read.table(textConnection(L.USGS), fill = TRUE)
 colnames(DF) - c(agency, gauge, date, time,
 time_zone,
 gauge_height,
 discharge, precipitation)
 pat - ^# +USGS +([0-9]+) +(.*)
 L.DD - grep(pat, L, value = TRUE)
 library(gsubfn)
 DD - strapply(L.DD, pat, c, simplify = rbind)
 DDdf - data.frame(gauge = as.numeric(DD[,1]),
 gauge_name = DD[,2])
 both - merge(DF, DDdf, by = gauge, all.x = TRUE)
 
 dts - as.character(both[,date])
 tms - as.character(both[,time])
 date_time - as.chron(paste(dts, tms), %Y-%m-%d
 %H:%M)
 DF - data.frame(Date=as.POSIXct(date_time), both)
 #change precip to numeric
 DF[,precipitation] -
 as.numeric(as.character(DF[,precipitation]))
 
 precip.1 - subset(DF, precipitation!=NA)
 b - ddply(precip.1$precipitation,
 .(precip.1$gauge_name), cumsum)
 DF.precip - precip.1
 DF.precip$precipitation - b$.data
 
 #discharge
 if(input==data){
 
 return(DF)
 
 }else{
 
 qplot(Date, discharge, data=DF,
 geom=line, ylab=Date)+facet_wrap(~gauge_name,
 scales=free_y)+coord_trans(y=log10)}
 
 if(input==precipitation){
 #precipitation
 qplot(Date, precipitation, data=DF.precip,
 geom=line)+facet_wrap(~gauge_name, scales=free_y)
 
 }else{
 
 qplot(Date, discharge, data=DF,
 geom=line, ylab=Date)+facet_wrap(~gauge_name,
 scales=free_y)+coord_trans(y=log10)}
 
 below is the whole function:
 
 USGS - function(input=discharge, days=7){
 require(chron)
 require(gsubfn)
 require(ggplot2)
 require(plyr)
 #021973269 is the Waynesboro Gauge on the Savannah River
 Proper (SRS)
 #02102908 is the Flat Creek Gauge (ftbrfcms)
 #02133500 is the Drowning Creek (ftbrbmcm)
 #02341800 is the Upatoi Creek Near Columbus (ftbn)
 #02342500 is the Uchee Creek Near Fort Mitchell (ftbn)
 #02203000 is the Canoochee River Near Claxton (ftst)
 #02196690 is the Horse Creek Gauge at Clearwater, S.C.
 
 a - http://waterdata.usgs.gov/nwis/uv?format=rdbperiod=;
 b -
 site_no=021973269,02102908,02133500,02341800,02342500,02203000,02196690
 z - paste(a, days, b, sep=)
 L - readLines(z)
 
 #look for the data with USGS in front of it (this take
 advantage of
 #the agency column)
 L.USGS - grep(^USGS, L, value = TRUE)
 DF - read.table(textConnection(L.USGS), fill = TRUE)
 colnames(DF) - c(agency, gauge, date, time,
 time_zone,
 gauge_height,
 discharge, precipitation)
 pat - ^# +USGS +([0-9]+) +(.*)
 L.DD - grep(pat, L, value = TRUE)
 library(gsubfn)
 DD - strapply(L.DD, pat, c, simplify = rbind)
 DDdf - data.frame(gauge = as.numeric(DD[,1]),
 gauge_name = DD[,2])
 both - merge(DF, DDdf, by = gauge, all.x = TRUE)
 
 dts - as.character(both[,date])
 tms - as.character(both[,time])
 date_time - as.chron(paste(dts, tms), %Y-%m-%d
 %H:%M)
 DF - data.frame(Date=as.POSIXct(date_time), both)
 #change precip to numeric
 DF[,precipitation] -
 as.numeric(as.character(DF[,precipitation]))
 
 precip.1 - subset(DF, precipitation!=NA)
 b - ddply(precip.1$precipitation,
 .(precip.1$gauge_name), cumsum)
 DF.precip - precip.1
 DF.precip$precipitation - b$.data
 
 #discharge
 if(input==data){
 
 return(DF)
 
 }else{
 
 qplot(Date, discharge, data=DF,
 geom=line, ylab=Date)+facet_wrap(~gauge_name,
 scales=free_y)+coord_trans(y=log10)}
 
 if(input==precipitation){
 #precipitation
 qplot(Date, precipitation, data=DF.precip,
 geom=line)+facet_wrap(~gauge_name, scales=free_y)
 
 }else{
 
 qplot(Date, discharge, data=DF,
 geom=line, ylab=Date)+facet_wrap(~gauge_name,
 scales=free_y)+coord_trans(y=log10)}
 
 }
 
 
 -- 
 Stephen Sefick
 
 Let's not spend our time and resources thinking about
 

Re: [R] avoiding reinstall already installed *package*

2010-05-18 Thread Ted Harding
On 18-May-10 16:42:40, Peter Ehlers wrote:
 On 2010-05-18 10:05, (Ted Harding) wrote:
 On 18-May-10 15:49:37, Martin Maechler wrote:
 { I've modified the subject; I can't stand it hitting square into
my face ... }
 mr == milton rusermilton.ru...@gmail.com
  on Tue, 18 May 2010 12:36:23 -0300 writes:
  mr  Dear R-experts,
  mr  I am installing new libraries using
  mr  install.packages(ggplot2,dependencies=T).
  mr  But I perceive that many dependencies are already
  installed.
  mr  As I am using a low-band internet, how can avoid reinstall
  mr  installed libraries?

 There's no problem with installed libraries, as ...
 they DO NOT EXIST.

 These are *PACKAGES* !
 Why do you think are you talking about the function

   install.packages()  
   

 Ah, Martin! I know that package is the official terminology,
 but R itself tempts the naive user into deviating from the
 True Path. Indeed, I had my fingers burned by this myself,
 a long time ago (I'm still licking them ... ).

 One might ask: Why do you think we use the function library()?
 when loading add-on packages into R. Indeed, the very directory
 tree of R itself stores packages under /usr/lib/R/library.

 So, once in a while, someone gets it wrong, and has to find it
 out the hard way!
 
 Well, I don't know if I've ever disagreed with Ted before,
 but here I would (somewhat) disagree. It seems a bit odd that
 nobody confuses 'book' with 'library', yet the package/library
 problem is persistent. It may have something to do with the
 use of 'library' in other computer languages.
 
 Anyway, not long ago there was a suggestion (Rolf Turner's?)
 to rename the library() function to something like use(),
 but, as I recall, a number of nontrivial objections were
 raised.
 
 Of course R stores packages in libraries. That's were books
 *should* reside. And it's a good idea to have Martin remind
 us now and again that books themselves are not libraries.
 
 But I must confess that I'm no longer much bothered by the
 misuse. If it ever leads someone astray in their code, then,
 well, they have only themselves to blame.
 
 Cheers,
 Peter Ehlers

Well, I don't think you're disagreeing with me, Peter!
My point (which you're not disputing) is that the naive user
will think library because of using the function library().
Perhaps my remark about /usr/lib/R/library was a bit superfluous
(and indeed that path supports your book vs library point).
Nevertheless, it would still reinforce users who think library.

I suppose, to take your analogy, the semantics of, say,
library(Hmisc) could be spelled out as Go to the library
and take out the book called Hmisc. On the other hand, the
naive user will tend to read it as get library Hmisc.

While library is conspicuous to all users because of the
function, the fact that packages should be called packages does
not jump out into your face (until someone on the list does).

That said, I again agree with you that I'm not much bothered
by the question. I see it as one of the various little things
in R which one happily learns (in the end ... ) to live with!

Best wishes,
Ted.


E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk
Fax-to-email: +44 (0)870 094 0861
Date: 18-May-10   Time: 18:03:45
-- XFMail --

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


[R] Sweave counter

2010-05-18 Thread Jimmy Söderly
Dear R users,

I am using the Sweave package and I am doing some MCMC. I have a loop
function for my MCMC. Every 100 iterations, I want the number of iterations
already done to appear on my screen (but not on the final document). Is that
possible ?

Usually I can rely on

 if (i%%100==0) cat(i, \n)

but not when using Sweave.

Thanks for your help,
Jimmy

[[alternative HTML version deleted]]

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


Re: [R] proportion of treatment effect by a surrogate (fitting multivariate survival model)

2010-05-18 Thread Vinh Nguyen
On Mon, May 17, 2010 at 7:42 PM, Vinh Nguyen vqngu...@uci.edu wrote:
 Dear R-help,

 I would like to compute the variance for the proportion of treatment
 effect by a surrogate in a survival model (Lin, Fleming, and De
 Gruttola 1997 in Statistics in Medicine).  The paper mentioned that
 the covariance matrix matches that of the covariance matrix estimator
 for the marginal hazard modelling of multiple events data (Wei, Lin,
 and Weissfeld 1989 JASA), and is implemented in Lin's MULCOX2, SAS,
 and S-plus.

 Is this the way to fit such a model in R?
 Suppose I have variables: time, delta, treatment, and surrogate.

 Should I repeat the dataset (2x) and stack, creating the variables:
 time1 (time repeated 2x), delta1 (delta repeated 2x), treatment1 (same
 as treatment, but 0's for the 2nd set), treatment2 (0's in first set,
 then same as treatment), and surrogate2 (0's in first set, then same
 as treatment), and id (label the subject, so each id should have 2
 observations).

 Thus, a dataset with n observations will become 2n observations.  To fit, do
 fit - coxph(Surv(time1,delta1) ~ treatment1 + teatment2 + surrogate2
 + strata(id)
 ?


I think I figured it out.  I should use m - rep(0:1, each=n) for
strata.  The point estimates matches that of the adjust and unadjusted
models when fitting separately (jointly fit to obtain covariances).

Thank you and let me know if I've done anything wrong.

 From here, I can obtain the variance and covariance terms for the
 coefficients of treatment1 and treatment2.  Is this the same as
 fitting 2 separate models but also obtaining the covariances of the
 two estimates?

 Let me know, thanks.

 Vinh

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


Re: [R] unsigned 4 byte number

2010-05-18 Thread William Dunlap
 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of tetonedge
 Sent: Tuesday, May 18, 2010 9:14 AM
 To: r-help@r-project.org
 Subject: [R] unsigned 4 byte number
 
 
 Does anybody know how to read in a unsigned 4 byte number 
 from a binary file?
 According to the help for readBin, the signed argument only applies to
 size=1 or 2. But if you declare any size larger it assumes it 
 is signed?

R cannot properly represent unsigned 4 byte C ints with its
type integer (which is a 4 byte signed C int).  It can store
them as doubles with the desired values.

You can use readBin to read them as signed 4 byte C ints, stored
in R integers,  with

i - readBin(file, what=integer, size=4)

and then convert them to doubles with the following function

unsignedFourByteIntToDouble - function(i) {
   d - as.numeric(i)
   d[d0] - d[d0] + 2^32
   d
}

If you had S+ you could do this in one step using readBin's
output=double argument.   In S+'s readBin(), output=type
means to override the default mapping of C types to S+ types.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com  

 Thanks
 -- 
 View this message in context: 
 http://r.789695.n4.nabble.com/unsigned-4-byte-number-tp2221555
p2221555.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 

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


Re: [R] Sweave counter

2010-05-18 Thread Ista Zahn
Hi Jimmy,
You can use message() instead of cat():

if (i%%100==0) message(i)

Best,
Ista

On Tuesday 18 May 2010 1:10:51 pm Jimmy Söderly wrote:
 Dear R users,
 
 I am using the Sweave package and I am doing some MCMC. I have a loop
 function for my MCMC. Every 100 iterations, I want the number of iterations
 already done to appear on my screen (but not on the final document). Is
 that possible ?
 
 Usually I can rely on
 
  if (i%%100==0) cat(i, \n)
 
 but not when using Sweave.
 
 Thanks for your help,
 Jimmy
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html and provide commented,
 minimal, self-contained, reproducible code.

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


Re: [R] Sweave counter

2010-05-18 Thread Benno Pütz
Under UNIX I usually write something like

system(paste(echo ',...,', sep=sep))

where I replace the '...' with whatever I need to show.


This would need some adjustments for non-scalars, though.

Benno

Am 18.Mai.2010 um 19:10 schrieb Jimmy Söderly:

 Dear R users,
 
 I am using the Sweave package and I am doing some MCMC. I have a loop
 function for my MCMC. Every 100 iterations, I want the number of iterations
 already done to appear on my screen (but not on the final document). Is that
 possible ?
 
 Usually I can rely on
 
 if (i%%100==0) cat(i, \n)
 
 but not when using Sweave.
 
 Thanks for your help,
 Jimmy
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 

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


[R] Glasso question

2010-05-18 Thread daysixty

The glassolist function says that if rholist is set to NULL, then 10
values in a (hopefully reasonable) range are used. I'm trying to figure out
how these 10 values are chosen, I can't find this in any documentation.
Thanks for your help!
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Glasso-question-tp2221587p2221587.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] (no subject)

2010-05-18 Thread David Winsemius


On May 18, 2010, at 12:07 PM, Arantzazu Blanco Bernardeau wrote:



Hello
Well, the problem is, that arcilla is the percentage of clay in the  
soil sample. So, for linear model, I need to work with that number  
or value. Now, R thinks that arcilla (arcilla means clay in  
spanish), is a factor, and gives me the value as a factor, so the  
output of the linear model is

Call:
lm(formula = formula, data = caperf)


Would help if you also displayed the value for formula, so we might  
have an idea what you are calling your y-variable   and it would  
be wise not to continue to name your formulas formula.


require(fortunes)
fortune(dog)

What happens when you create a new variable in caperf with the numeric  
equivalant of the arcilla levels?


caperf$claynum - as.numeric(as.character(arcilla))

lm(y ~ claynum + limo + CO_gkg1 + C03Ca  , data=caperf)

--
David.




Residuals:
   Min 1Q Median 3QMax
-1.466e+01 -1.376e-15  1.780e-16  2.038e-15  1.279e+01

Coefficients:
  Estimate Std. Error t value Pr(|t|)
(Intercept)1.689646.33889   0.267 0.790221
arcilla0.9 1.902288.90888   0.214 0.831239
arcilla10  1.263717.96734   0.159 0.874212
arcilla10.3   15.700819.05141   1.735 0.085090 .
arcilla10.47.275177.72806   0.941 0.348183
arcilla10.45   7.038799.02600   0.780 0.436853
arcilla10.52.412418.90827   0.271 0.786954
arcilla10.65  15.442989.03879   1.709 0.089838 .
arcilla10.7   19.356519.04675   2.140 0.034185 *
arcilla10.93.559479.18501   0.388 0.698974

[...]

arcilla9.9 6.319497.35724   0.859 0.391892
arcilla#N/A   24.179598.87201   2.725 0.007274 **
limo   0.249200.04605   5.412 2.76e-07 ***
CO_gkg10.210150.03931   5.346 3.73e-07 ***
C03Ca  0.017110.02727   0.628 0.531337
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 6.249 on 135 degrees of freedom
  (50 observations deleted due to missingness)
Multiple R-squared: 0.9736,Adjusted R-squared: 0.9014
F-statistic: 13.47 on 370 and 135 DF,  p-value:  2.2e-16

So, in the desired linear model, arcilla should be just a line, with  
the valors of the linear model.
I hope you understand better more. If not, I could make an english  
version of the file to send, so you can try the commands.

Thanks a lot for your help!



Arantzazu Blanco Bernardeau
Dpto de Química Agrícola, Geología y Edafología
Universidad de Murcia-Campus de Espinardo











Date: Tue, 18 May 2010 11:54:20 -0400
Subject: Re: [R] (no subject)
From: mailinglist.honey...@gmail.com
To: aramu...@hotmail.com
CC: r-help@r-project.org

Hi,

Sorry, I'm not really getting what going on here ... perhaps having
more domain knowledge would help me make better sense of our  
question.


In particular:

On Tue, May 18, 2010 at 11:35 AM, Arantzazu Blanco Bernardeau
wrote:


Hello
I have a data array with soil variables (caperf), in which the  
variable clay is factor (as I see entering str(caperf)) . I need  
to do a regression model, so I need to have arcilla (=clay) as a  
numeric variable.  For that I have entered


as.numeric(as.character(arcilla))

and even entering
'as.numeric(levels(arcilla))[arcilla]'


The above code doesn't make sense to me ...

Perhaps cleaning up your question and providing some reproducible
example we can use to help show you the light (just describing what a
variable has isn't enough -- give us minimal code we can paste into R
that reproduces your problem).

Alternatively, depending no what your levels mean, you might want  
to

recode your data using dummy variables (I'm not sure if that's the
official term) .. this is what I mean:

http://dss.princeton.edu/online_help/analysis/dummy_variables.htm

In your example, let's say you have four levels for clay ... maybe
soft, hard, smooth, red

Instead of only using 1 variable with values 1-4, you would recode
this into 4 variables with values 0,1

So, if one example has a value of smooth for clay. Instead of  
coding it like:

clay: 3

You would do:
soft: 0
hard: 0
smooth: 1
red : 0

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


_
Consejos para seducir ¿Puedes conocer gente nueva a través de  
Internet? ¡Regístrate ya!


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


David Winsemius, MD
West Hartford, CT

__
R-help@r-project.org mailing list

[R] Res: Using the zero-inflated binomial in experimental designs

2010-05-18 Thread Ivan Allaman

Hi Ben!

First I thank you for your attention. Unfortunately, the ANOVA does not work 
with vglm. In
another email, Rafael warned me that actually a lot of zeros does not
necessarily imply a distribution of zeros binomail inflated. So how could I 
test if my variable is or not a binomial zero inflated?

Thanks.

 
M.Sc Ivan Bezerra Allaman 
Zootecnista
Doutorando em Produção Animal/Aquicultura - UFLA 
email e msn - ivanala...@yahoo.com.br 
Tel: (35)3826-6608/9925-6428





De: Ben Bolker [via R] ml-node+2221578-2039137178-109...@n4.nabble.com

Enviadas: Terça-feira, 18 de Maio de 2010 13:34:01
Assunto: Re: Using the zero-inflated binomial in experimental designs

 Ivan Allaman ivanalaman at yahoo.com.br writes: 


 
 
 I'm trying to use the inflated binomial distribution of zeros (since 75% of 
 the values are zeros) in a randomized block experiment with four 
 quantitative treatments (0, 0.5, 1, 1.5), but I'm finding it difficult, 
 since the examples available in VGAM packages like for example, leave us
 unsure of how it should be the data.frame for such analysis. Unfortunately 
 the function glm does not have an option to place a family of this kind I'm 
 about, because if I had, it would be easy, made that my goal is simple, just 
 wanting to compare the treatments. For that you have an idea, here is an
 example of my database. 
 
 BLOCK NIVNT   MUMI 
 Inicial   0  18 0 
[snip] 

 
 where: NIV are the treatments; NT is the total number of piglets born; Mumi 
 is the number of mummified piglets NT. Mumi The variable is of interest. If 
 someone can tell me some stuff on how I can do these tests in R, similar to 
 what I would do using the function glm, I'd be grateful. 
 I thank everyone's attention. 

something like comparing the likelihoods of 

m1 - vglm(cbind(MUMI,NT-MUMI)~NIV*BLOCK,zibinomial,data=mydata) 
m2 - vglm(cbind(MUMI,NT-MUMI)~NIV+BLOCK,zibinomial,data=mydata) 
m3 - vglm(cbind(MUMI,NT-MUMI)~BLOCK,zibinomial,data=mydata) 

I don't know whether the anova() method works for VGLM objects 
or not. 

  By the way, 75% zeroes doesn't necessarily imply zero-inflation -- 
perhaps it just means a low incidence? 

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




View message @ 
http://r.789695.n4.nabble.com/Using-the-zero-inflated-binomial-in-experimental-designs-tp2221254p2221578.html
 
To unsubscribe from Using the zero-inflated binomial in experimental designs, 
click here. 




-- 
View this message in context: 
http://r.789695.n4.nabble.com/Using-the-zero-inflated-binomial-in-experimental-designs-tp2221254p2221635.html
Sent from the R help mailing list archive at Nabble.com.

[[alternative HTML version deleted]]

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


Re: [R] C function call in R

2010-05-18 Thread Dan Davison
John Lande john.land...@gmail.com writes:

 dear all,

 we am trying to improve the performance of my R code, with the implentation
 of some function with custom C code.
 we found difficult to import and export/import data structure such us
 matrices or data.frame into the external C functions.

Please give a *very simple* example of what you're trying and failing to
do.

Use the .C() interface, forget about the .Call interface. Then it is not
that hard. Start with the convolve example on p.69 and 70 of Writing R
Extensions. Get that working and then turn it into your problem.

Forget about lists and data frames: everything is going to be a simple
vector. That includes arrays and matrices: you can pass them in, but C
will know nothing about their dimensions until you tell it. Of course,
you can pass the dimension vectors in as a separate vector. So, if you
use arrays, you need to understand the order in which R stores the
elements of the array. If your problem cannot be solved with the .C
interface then you should consider whether it is worthwhile to proceed
as the .Call interface repays those who use it frequently but has a
considerably steeper learning (and forgetting) curve.

Dan



 we already tried the solution from Writing R Extensions form  the R
 webpage.

 do you have any other solution or more advanced documentation on that point?

 looking forward your answer

   [[alternative HTML version deleted]]

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


[R] Maximization of quadratic forms

2010-05-18 Thread Russell Shinohara

Dear R Help,

I am trying to fit a nonlinear model for a mean function $\mu(Data_i, 
\beta)$ for a fixed covariance matrix where $\beta$ and $\mu$ are low- 
dimensional. More specifically, for fixed variance-covariance matrices  
$\Sigma_{z=0}$ and $\Sigma_{z=1}$ (according to a binary covariate $Z 
$), I am trying to minimize:


$\sum_{i=1^n} (Y_i-\mu_(Data_i,\beta))' \Sigma_{z=z_i}^{-1} (Y_i- 
\mu_(Data_i,\beta))$


in terms of the parameter $\beta$. Is there a way to do this in R in a  
more stable and efficient fashion than just using a general  
optimization function such as optim? I have tried to use gnls, but I  
was unsuccessful in specifying different values of the covariance  
matrix according to the covariate $Z$.


Thank you very much for your help,
Taki Shinohara





Russell Shinohara, MSc
PhD Candidate and NIH Fellow
Department of Biostatistics
Bloomberg School of Public Health
The Johns Hopkins University
615 N. Wolfe St., Suite E3033
Baltimore, MD 21205
tel: (203) 499-8480
http://biostat.jhsph.edu/~rshinoha

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


Re: [R] Getting dates in an SPSS file in right format.

2010-05-18 Thread Frank E Harrell Jr

On 05/18/2010 11:52 AM, Chuck Cleland wrote:

On 5/18/2010 12:38 PM, Praveen Surendran wrote:

Dear all,



I am trying to read an SPSS file into a data frame in R using method
read.spss(),

sample- read.spss(file.name,to.data.frame=TRUE)



But dates in the data.frame 'sample' are coming as integers and not in the
actual date format given in the SPSS file.

Appreciate if anyone can help me to solve this problem.


   Date variables in SPSS contain the number of seconds since
October 14, 1582.  You might try something like this:

sample$MYDATE- as.Date(as.POSIXct(sample$MYDATE, origin=1582-10-14,
tz=GMT))


Kind Regards,



Praveen Surendran

2G, Complex and Adaptive Systems Laboratory (UCD CASL)

School of Medicine and Medical Sciences

University College Dublin

Belfield, Dublin 4

Ireland.



Office : +353-(0)1716 5334

Mobile : +353-(0)8793 13071



The spss.get function in the Hmisc package handles SPSS dates.
Frank

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

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


Re: [R] survey package: weights used in svycoxph()

2010-05-18 Thread Thomas Lumley

On Tue, 18 May 2010, Vinh Nguyen wrote:


Binder's estimating equations are the usual way of applying weights to a Cox
model, so nothing special is done apart from calling coxph(). To quote the
author of the survival package, Terry Therneau, Other formulae change in
the obvious way, eg, the weighted mean $\bar Z$ is changed to include both
the risk weights $r$ and the external weights $w$. [Mayo Clinic
Biostatistics technical report #52, section 6.2.2]


Don't see a section 6.2.2 in this technical report.


Sorry, #58

   -thomas


Thomas Lumley   Assoc. Professor, Biostatistics
tlum...@u.washington.eduUniversity of Washington, Seattle

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


[R] Regarding the 'R' Load Command

2010-05-18 Thread Godavarthi, Murali
Hi,

 

I'm new to 'R' and need some help on the Load command. Any responses
will be highly appreciated. Thanks in advance!

 

As per manuals, the Load command expects a binary file input that is
saved using a save command. However it is required that we need to
call the 'R' program from 

Java web application using RJava, and pass a string to the 'R program
instead of a binary file. Is it possible?

 

I was exploring the options of using TextConnections, file connections
and other types of connections in order to read a stream of input
(either from a file, stdin etc). I am able to read the string, but the
Save and Load commands are not accepting the string input. Here is the
sequence of commands I tried running, and the error received. There is
no clue on this error, especially when trying to use the eval function
in randomForest package, even on the internet. Can anyone help please!

 

 

 

 library(randomForest)

randomForest 4.5-34

Type rfNews() to see new features/changes/bug fixes.

 

 load(C://Program Files//R//R-2.10.1//bin//rfoutput)

 

 zz - file(ex.data, w)

 

 cat(\imurder\ \itheft\ \irobbery\ \iassault\ \idrug\
\iburglary\ \igun\ \psych\ \Freq\ \priors\ \firstage\
\intage\ \sex\ \race\ \marstat\ \empac\ 

\educ\ \zipcode\ \suspendmn\ \drugs\ \alco\ \probation\
\parole\,file = zz, sep = \n, fill = TRUE)

 

 cat(\10\ 0 0 0 1 0 0 0 0 0 58 19 19 \1\ \BLACK\ \SINGLE\
\UNEMPLD\ 0 21215 0 0 0 1 0,file = zz, sep = \n, fill = TRUE)

 

 save(zz, file = testmurali, version = 2)

 

 predict(rfoutput,newdata=testmurali,type=response)

Error in eval(expr, envir, enclos) : object 'imurder' not found

 

  

 

Best Regards,

Murali Godavarthi

mgodavar...@dpscs.state.md.us

 

 

 

 

 


[[alternative HTML version deleted]]

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


Re: [R] GUI commands to call for a protein from protein data bank

2010-05-18 Thread Amitoj S. Chopra

I tried doing that and this is what I go:


dlg - aDialog(items=list(
ProtienCode=stringItem()
),
OK_handler=function(.) { # . is reference to dlg object
values - .$to_R()
f - function(ProtienCode)
pdb - read.pdb(.$get_ProteinCode())
#cat(ProteinCode is,ProtienCode,\n)
do.call(f, values)
}
)
dlg$make_gui()


with this error message

Error in function (ProtienCode)  : could not find function read.pdb

Do you know how to get rid of this error?

On Tue, May 18, 2010 at 5:53 AM, jverzaniNWBKZ [via R] 
ml-node+2221226-858152228-140...@n4.nabble.comml-node%2b2221226-858152228-140...@n4.nabble.com
 wrote:

 Amitoj S. Chopra amitojc at gmail.com writes:

 
 
  What I am trying to do is use GUI function, traitr, and to call for a pdb

  file and save it and then display it. I want to call for it by taking it
  from the user and then displaying it on the screen. I am having problems
  with that. The line pdb - read.pdb(ProteinCode) where proteincode
 should
  be the name of the protein, for example 1ly2, but it always ends up being

  protein. My question is how to you make the input for read.pdb actually
 be
  the input by the user and not protein code. I want to be able to type
 1ly2,
  and for the program to actually display the contents of 1ly2. Thanks!
 

 I'm just guessing, but you might try this for your OK_handler:

 OK_handler=function(.) {
   pdb - read.pdb(.$get_ProteinCode())
 }

 (Or use yours, but drop the quotes around ProteinCode.)

 That doesn't modify pdb outside the scope of the handler, so likely you
 need to
 do something else with it.

 --John


  Code:
 
  dlg - aDialog(items=list(
  ProteinCode=stringItem()
  ),
  OK_handler=function(.) { # . is reference to dlg object
  values - .$to_R()
  f - function(ProteinCode)
  pdb - read.pdb(ProteinCode)
  do.call(f, values)
  }
  )
  dlg$make_gui()

 __
 [hidden email] http://user/SendEmail.jtp?type=nodenode=2221226i=0mailing 
 list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


 --
  View message @
 http://r.789695.n4.nabble.com/GUI-commands-to-call-for-a-protein-from-protein-data-bank-tp2220754p2221226.html
 To unsubscribe from GUI commands to call for a protein from protein data
 bank, click here (link removed) .




-- 
View this message in context: 
http://r.789695.n4.nabble.com/GUI-commands-to-call-for-a-protein-from-protein-data-bank-tp2220754p2221749.html
Sent from the R help mailing list archive at Nabble.com.

[[alternative HTML version deleted]]

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


Re: [R] looking for .. dec if vector if element x

2010-05-18 Thread Knut Krueger

Thank you Adrian,

its working fine.

Knut

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


  1   2   >