[R] nlm behaviour and error

2008-06-03 Thread Redding, Matthew
Hi R-Gurus, 

I've been cutting along quite nicely with nlm, until
I threw in the following condition in the function that nlm is
minimising:

if (((term*bexp)  0.0001)) {
   #warning(term*bexp, =term*bexp,psi,=psi) 
   theta-2000
}



Now when I run this function anywhere else, there is no problem, whether
or the if's condition is met.

When I use this in nlm:

nlm(f=ssewrap.dist, p=c(292397.7,-.14053,0.03,.0005), .5, 1,
295.15,C,theta)
Error in if (((term * bexp)  1e-04)) { : 
  missing value where TRUE/FALSE needed


Now I know that the condition in the if should only be one logical
value, but is not the condition above evaluated to a single value, and
why does the error only occur when the function is used by nlm?

Any suggestions?

Kind regards, 

Matt Redding
DISCLAIMER**...{{dropped:15}}

__
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] 'asymmetric span' for 2D loess?

2008-06-03 Thread Prof Brian Ripley

On Mon, 2 Jun 2008, Tokuyasu, Taku wrote:


Hello,

I am interested in performing a 2D loess smooth on microarray data, i.e.
log2 ratios on a 2D grid, using different spans in the horizontal and
vertical directions (the immediate reason being that replicate spots are
laid out in the horizontal direction).  Is it possible to do this in R?
Functions like loess(stats) seem to apply the same span for all
predictors, which carries over to functions like ma2D(marray).


See the next comment.  'span' applies to 2D distances, and I think you 
need to rescale your inputs so Euclidean distance is appropriate.



As an elementary second question, are there circumstances where one
expects to see a substantial difference in the fits between say loess(y
~ x1 + x2) and loess(y ~ x1 * x2) with an interaction term (and if so,
what are they)?



From the help page:


 formula: a formula specifying the numeric response and one to four
  numeric predictors (best specified via an interaction, but
  can also be specified additively).  Will be coerced to a
  formula if necessary.

So the two versions both specify smoothing in 2D.

You can use things like lo(x1) + lo(x2) in some gam fits.

It often helps to read the primary sources, in this case chapters in the 
White Book (Chambers  Hastie, nominally 1992, actually published in 
1991).




Many thanks,

_Taku

Taku A. Tokuyasu, PhD
UCSF Helen Diller Family Comprehensive Cancer Center
San Francisco, CA 94143-0808


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

__
R-help@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] Error/Crash on start up of R (Ubuntu and Wine within Ubuntu)

2008-06-03 Thread Prof Brian Ripley
Either you have a corrupt .RData file in the directory you are starting R 
in or the file is being read incorrectly (e.g. because of a corrupted file 
system or hardware issues).


Reinstalling etc will not remove the .RData file, and you need to do so 
yourself.


Starting R with --vanilla is always a good check for local configuration 
issues.


On Mon, 2 Jun 2008, Patrick M. Joyce wrote:


Hello,

I'm having issues operating R under Ubuntu (Hardy 8.04) though I suspect
this is not necessarily the malady.  I have attempted to run R in ubuntu
as is which worked for awhile and then stopped (using RKWard as the
windowing environment).  I tried removing then re-installing the software
and the same issue (which i'll detail soon) persisted.  I then tried using
WINE to run R using the Windows version of R.  The same error was
presented.

The Ubuntu and WINE errors are slightly different but are more or less the
same...

COMMON ASPECT--I get the following:

Error in load(name, envir = .GlobalEnv):
value of 'SET_ATTRIB' must be a pairlist or NULL, not a 'double'

WINE Variant--I get a windowed box with the title Information noting
that Fatal error: unable to restore saved data in .RData.

UBUNTU Variant--I get a segmentation fault statement and abort options.

I'm going to guess that this is the same issue.  I would presume at this
point that either there is some mistaken setting within the operating
system OR something wrong with the hardware.

I appreciate any help on the matter.

--Patrick

__
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.



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

__
R-help@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] nlm behaviour and error

2008-06-03 Thread Prof Brian Ripley

It says the value is *missing* (NA), not that the length is wrong.

My quess is that term*bexp is NaN, but you have given us no context to go 
on.


On Tue, 3 Jun 2008, Redding, Matthew wrote:


Hi R-Gurus,

I've been cutting along quite nicely with nlm, until
I threw in the following condition in the function that nlm is
minimising:

   if (((term*bexp)  0.0001)) {
  #warning(term*bexp, =term*bexp,psi,=psi)
  theta-2000
   }



Now when I run this function anywhere else, there is no problem, whether
or the if's condition is met.

When I use this in nlm:

nlm(f=ssewrap.dist, p=c(292397.7,-.14053,0.03,.0005), .5, 1,
295.15,C,theta)
Error in if (((term * bexp)  1e-04)) { :
 missing value where TRUE/FALSE needed


Now I know that the condition in the if should only be one logical
value, but is not the condition above evaluated to a single value, and
why does the error only occur when the function is used by nlm?

Any suggestions?

Kind regards,

Matt Redding
DISCLAIMER**...{{dropped:15}}

__
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.



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

__
R-help@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] probleme with R CMD check

2008-06-03 Thread Martin Maechler
 c == cgenolin  [EMAIL PROTECTED]
 on Tue, 03 Jun 2008 00:32:13 +0200 writes:

c Hi the list.
c I got a probleme with R CMD check. I run a package.skeleton on a very 
c simple code (four toy function, no probleme with the R CMD build). But 
c on the R CMD check packClassique, I get :

c * checking for unstated dependencies in R code ... WARNING
c Erreur dans .find.package(package, lib.loc) :  aucun package nommé 
c 'packClassique' n'est trouvé
c Calls: Anonymous - .find.package
c Excecution hated [French=Exécution arrêtée]

c See the information on DESCRIPTION files in the chapter 'Creating R
c packages' of the 'Writing R Extensions' manual.
c * checking S3 generic/method consistency ... WARNING
c Erreur dans .find.package(package, lib.loc) :  aucun package nommé 
c 'packClassique' n'est trouvé
c Calls: Anonymous - .find.package
c Exécution arrêtée

c And so on.

c Any idea on what is wrong ?

No.

c Christophe

c __
c R-help@r-project.org mailing list
c https://stat.ethz.ch/mailman/listinfo/r-help

c PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
c and provide commented, minimal, self-contained, reproducible code.

Please do  -- both --

Martin

__
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] probleme with R CMD check

2008-06-03 Thread cgenolin

provide commented, minimal, self-contained, reproducible code.
Please do  -- both --


Sorry... Usualy, I do...

--- 8 
userA - function(x)x+1
privateA  - function(x)x+2
.userB - function(x)x+10
.privateB  - function(x)x+20
userC- function(x)userA(privateA(x))
privateC - function(x).userB(.privateB(x))
userD- function(x)userA(.userB(x))
privateD - function(x)privateA(.privateB(x))
--- 8 


c == cgenolin  [EMAIL PROTECTED]
on Tue, 03 Jun 2008 00:32:13 +0200 writes:


   c Hi the list.
   c I got a probleme with R CMD check. I run a package.skeleton on a very
   c simple code (four toy function, no probleme with the R CMD build). But
   c on the R CMD check packClassique, I get :

   c * checking for unstated dependencies in R code ... WARNING
   c Erreur dans .find.package(package, lib.loc) :  aucun package nommé
   c 'packClassique' n'est trouvé
   c Calls: Anonymous - .find.package
   c Excecution hated [French=Exécution arrêtée]

   c See the information on DESCRIPTION files in the chapter 'Creating R
   c packages' of the 'Writing R Extensions' manual.
   c * checking S3 generic/method consistency ... WARNING
   c Erreur dans .find.package(package, lib.loc) :  aucun package nommé
   c 'packClassique' n'est trouvé
   c Calls: Anonymous - .find.package
   c Exécution arrêtée

   c And so on.

   c Any idea on what is wrong ?

No.

   c Christophe

   c __
   c R-help@r-project.org mailing list
   c https://stat.ethz.ch/mailman/listinfo/r-help

   c PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html

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

Please do  -- both --

Martin



__
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] regsubsets - package(leaps)

2008-06-03 Thread Maura E Monville
Please, can someone suggest me where to find a description for the
attributes of the summary of regsubsets,
that is:
which  rsqrssadjr2  cp bicoutmat obj   ??

Thank you so much.
-- 
Maura E.M

[[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] discrete parameter

2008-06-03 Thread nona husainy
hello 
dear sir,
Inbsp;wonder whether ifnbsp;anybody try to
constructnbsp;acontinous parameternbsp;AR(P) 
from the discrete parameter AR(P)
execuse me for my bad english lang.
and thank you for your helpful.
nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;
 
nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;
 


  
[[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] Need advise in grab the line number of sorted list in R

2008-06-03 Thread Philipp Pagel
On Tue, Jun 03, 2008 at 10:37:33AM +1000, Jason Lee wrote:
 Hi,
 
 If there are more than one item having the same value, how can i use R to
 take the average of the position. E.g:-
 
X Y Z
 131 22.2 3.4   4.4
 132 20.0 3.4   4.4==Position 2 if queried
 150  20.0 12.2 4.5 =Position 3 if queried
 134 20.0 3.4   4.4 == Position4 if queried
 159  20.0 12.2 4.5==Position 5 if queried
 160  22.0 12.2 4.5
 
 When I query 150 using which, it gives 3 but since in other position the
 value are same which is 20.0, how can i get the average of the position
 which is (2+3+4+5)/3

aggregate() will do what you want. A little warning: of course aggregate
will group by elements which are EXACTLY the same so make sure the
floats in columns X really behave the way you want. Otherwise you may
want to have a look at cut().

cu
Philipp

-- 
Dr. Philipp Pagel
Lehrstuhl für Genomorientierte Bioinformatik
Technische Universität München
Wissenschaftszentrum Weihenstephan
85350 Freising, Germany
 
 and
 
Institut für Bioinformatik und Systembiologie / MIPS
Helmholtz Zentrum München -
Deutsches Forschungszentrum für Gesundheit und Umwelt
Ingolstädter Landstrasse 1
85764 Neuherberg, Germany
http://mips.gsf.de/staff/pagel

__
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] exit function in R?

2008-06-03 Thread Federico Abascal
Thank everybody for the answers! The stop and quit functions are what I
need (it is a script, not a function what needs to be terminated. I was
talking about an exit function, what can be confusing).

Best,
Federico


Gregory. R. Warnes wrote:

 Since Frederico indeicated he was running a script, rather than a
 function, I suspect that he would be better served by the

 quit(no)

 function.


  Jun 2, 2008, at 5:15PM , Rolf Turner wrote:


 On 3/06/2008, at 1:18 AM, Federico Abascal wrote:

  Hi,
  This is likely an stupid question, but I cannot find the solution.
  I am searching for an exit function, to end the execution of an R
  script if some condition is not filled.
  Any clue?

 Others have suggested using stop().  It might be the case that the
 condition not being fulfilled is not actually a sign of an error,
 but simply of a different, perhaps ``marginal'' situation in which
 a different sort of action or calculation is required.  In which
 case what you want is return().

 Trivial e.g.:

 foo - function(x) {
 if(any(x=0)) return(42)
 y - sum(log(x))
 y
 }

 cheers,

 Rolf Turner

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

 __
 R-help@r-project.org mailto: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.


 Gregory R. Warnes, Ph.D.
 Associate Professor
 Center for Biodefence Immune Modeling
and
 Department of Biostatistics and Computational Biology
 University of Rochester






[[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] Odp: Aggregation and the meaning of class

2008-06-03 Thread Petr PIKAL
Hi Chip

Maybe some more experienced users can direct you to proper source of 
information but in case of programming there are several books which can 
be of some use (I do not have any of them so its only my guess from their 
names). See items 1, 3 and 5 from CRAN  Books page. 

Regards

Petr
[EMAIL PROTECTED]
724008364, 581252140, 581252257


[EMAIL PROTECTED] napsal dne 02.06.2008 16:14:32:

 Hi Petr,
 Thanks for your reply.  See below.
 
 At 05:58 AM 6/2/2008, Petr PIKAL wrote:
 Hi
 
 I did not see any response yet so I try a kick. Each object in R has 
some
 attributes which can be revealed by
 
 attributes(object)
 
 Some of them are useful for methods and tell R how to handle particular
 object with a method. There are other options how to evaluate your 
object
 e.g. str, typeof, mode. If you went through intro manual you could find
 that there are different types of objects like vectors, matrices,
 data.frames, arrays, and lists. And probably some others.
 
 Output from by is list or array and you can handle such objects in many
 ways.
 
 I understand all this in general.  I am a C++ programmer with decades 
 of experience, so I fully understand object-oriented concepts.
 
 My question is: How does one learn the specifics?  For the case at 
 hand, what are the specialized methods associated with class by? 
 Are there clever things I can do with it?  Is there documentation for 
 class by?  What are the browsing/exploring approaches one might use 
 to learn about that class?
 
 So far, the main approach I have is interactive experimentation, 
 yielding slow knowledge accretion.  Is there anything more 
 efficient?  I have a moderate pile of R books, they are helpful, but 
 obviously don't cover every detail of every situation.
 
 
 BTW it is hard to tell what is desired result is as we do not have D60.
 
 Agreed and I could supply some example data if you want.
 
 I speculated that experienced users could answer my question on 
 formal grounds, but perhaps this speaks to my general issue: 
 questions like this aren't easily answered without running experiments.
 
 At the moment, my code seems to be working.  I don't find that very 
 reassuring.  I may have to get used to an R culture that is 
 different from my prior world.
 
 
 Eg. when I do
 
   WM = by( D60, D60[ KeyProfA], FUN=function(x) weighted.mean( 
x$IAC,
 x$Wt))
 Error in by(D60, D60[KeyProfA], FUN = function(x) 
weighted.mean(x$IAC, :
 
object D60 not found
 
 I get an error.
 
 Better then using by is maybe to use ave which retains number of rows, 
but
 I am not sure if it can be adopted to weighted mean.
 
 Regards
 
 Petr
 [EMAIL PROTECTED]
 724008364, 581252140, 581252257
 
 
 [EMAIL PROTECTED] napsal dne 30.05.2008 16:00:50:
 
   Dear R-ers,
  
   My aggregation saga continues.
  
   Using the following sequence, I can calculate any statistic for row
   groups and merge the result back to all associated rows ...
  
 WM = by( D60, D60[ KeyProfA], FUN=function(x) weighted.mean( 
x$IAC,
 x$Wt))
  
 D60$IAC.WM = as.numeric( WM[ D60$KeyProfA])
  
 class( WM)
   [1] by
  
   Questions ...
  
   1) Is this a reasonable way to obtain the desired result?
  
   2) What can one glean by knowing the class of WM (by)?  It appears
   to me that class is a pretty shallow attribute in R ... just an
   associated string that selects among methods in some contexts.  Is
   that really all there is to it?  Is there a way to discover what
   generic methods are aware of a given class?  In other words, who
   cares if WM is a by ... what does that do for me?
  
   In my traditional universe (C++) I can grep and discover what 
methods
   are virtual, who inherits from whom, etc.  In R, the documentation
   appears silent on what is a by (correct me if I'm wrong).  In
   addition, I have found no way to broadly search code to learn
   things.  (Displaying single functions is useful but hardly broad.)
  
   How does one learn R more efficiently than randomly discovering how
   to avoid error messages?  (For example, I now know that a by 
cannot
   be coerced into a data.frame (although it seems to me that such a
   conversion could be usefully defined), so now I don't hit myself on
   the head with that particular hammer.)
  
   Chip Barnaby
  
  
  
  
  
  
   -
   Chip Barnaby   [EMAIL PROTECTED]
   Vice President of Research
   Wrightsoft Corp.   781-862-8719 x118 voice
   131 Hartwell Ave   781-861-2058 fax
   Lexington, MA 02421 www.wrightsoft.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.
 
 -
 Chip Barnaby   [EMAIL 

Re: [R] probleme with R CMD check

2008-06-03 Thread Martin Maechler
 c == cgenolin  [EMAIL PROTECTED]
 on Tue, 03 Jun 2008 09:55:15 +0200 writes:

 provide commented, minimal, self-contained, reproducible code.
 Please do  -- both --

c Sorry... Usualy, I do...

c --- 8 
c userA - function(x)x+1
c privateA  - function(x)x+2
c .userB - function(x)x+10
c .privateB  - function(x)x+20
c userC- function(x)userA(privateA(x))
c privateC - function(x).userB(.privateB(x))
c userD- function(x)userA(.userB(x))
c privateD - function(x)privateA(.privateB(x))
c --- 8 

If I execute these in an empty R session, and
do
package.skeleton(EXpkg)
system(R CMD check EXpkg)

I can NOT see the problem you describe below.
Probably you'd rather should upload the 
pkg.tar.gz
to a public place, to make your problem reproducible.

Martin

 c == cgenolin  [EMAIL PROTECTED]
 on Tue, 03 Jun 2008 00:32:13 +0200 writes:
 
c Hi the list.
c I got a probleme with R CMD check. I run a package.skeleton on a very
c simple code (four toy function, no probleme with the R CMD build). But
c on the R CMD check packClassique, I get :
 
c * checking for unstated dependencies in R code ... WARNING
c Erreur dans .find.package(package, lib.loc) :  aucun package nommé
c 'packClassique' n'est trouvé
c Calls: Anonymous - .find.package
c Excecution hated [French=Exécution arrêtée]
 
c See the information on DESCRIPTION files in the chapter 'Creating R
c packages' of the 'Writing R Extensions' manual.
c * checking S3 generic/method consistency ... WARNING
c Erreur dans .find.package(package, lib.loc) :  aucun package nommé
c 'packClassique' n'est trouvé
c Calls: Anonymous - .find.package
c Exécution arrêtée
 
c And so on.
 
c Any idea on what is wrong ?
 
 No.
 
c Christophe
 
c __
c R-help@r-project.org mailing list
c https://stat.ethz.ch/mailman/listinfo/r-help
 
c PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
c and provide commented, minimal, self-contained, reproducible code.
 
 Please do  -- both --
 
 Martin
 



c 
c Ce message a ete envoye par IMP, grace a l'Universite Paris 10 Nanterre

__
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] Rpart and case weights: working with functions

2008-06-03 Thread Xavier Robin

I can't get rpart accept case weights defined inside a function.
It keeps using the copy defined in the global environment (if they 
exists) instead of the function-defined ones.


Here is what I do:

test.function - function (formula, data) {
  weights - rep(.1, 100)
  rpart(formula, data, weights)
}

test.function(x~y, data)

And I get an error:
Error in model.frame(formula, rownames, variables, varnames, extras, extranames,  : 
invalid type (closure) for variable '(weights)'



If I define weights in the global environment, it uses this instead of 
the function-defined one (which can be verified by 
.Last.value$frame$wt[1]: it should equal sum(weights) and actually 
equals the sum of global weights, not the function one).


I tried to pass a named argument (weights=weights), using other names 
(w, foo, ...), or both, but still it doesn't work. I found nothing in 
rpart doc about that behaviour...

It was tested on R 2.7.0 (Windows XP) and R 2.5.1 (Linux kernel 2.6.9).

For the moment, the only workaround I found is to use/modify the global 
weights using - (not very satisfying).



What did I wrong? And what should I do to get it work (i.e. using the 
copy of weights defined inside the function)?


Thanks in advance for your help.

Xavier Robin

--
Xavier Robin

Biomedical Proteomics Research Group (BPRG)
Department of Structural Biology and Bioinformatics (DBSB)
Geneva University Medical Center (CMU)
1, rue Michel Servet - CH-1211 Genève 4 - Switzerland
Tel: (+41 22) 379 53 21

__
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] mtable and plm

2008-06-03 Thread Emili Tortosa-Ausina

Dear all,

I'm trying to generate latex-formatted tables for panel data regressions 
using the mtable function of the memisc package, which is quite good. I 
use the plm package for panel data regression. Unfortunately, it seems 
that mtable works very well when using either lm or glm, but it 
encounters some problems when using plm.


In particular, the error message I get is:

 (mtable.my.example-mtable(My_example=zzwith))
Error in FUN(X[[1]], ...) : no applicable method for getSummary

I guess I'm missing something (I'm not an expert neither in R nor in 
generating latex-formatted tables) and perhaps by specifying some 
options my problems would be fixed.


Kind regards,

Emili

__
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] matlab eigs function in R

2008-06-03 Thread kayteck_master

Hello

Does anybody know how one can compute d largest eigenvalues/eigenvectors in
R, like in MATLAB eigs function ? eigen function computes all
eigenvectors/eigenvalues, and they are slightly different than those
generated by matlab eigs. 

Thanks in advance
-- 
View this message in context: 
http://www.nabble.com/matlab-eigs-function-in-R-tp17619641p17619641.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] Problems using jri0.4-1 y R 2.7.0

2008-06-03 Thread Borja Soto Varela
Hello, this is the first time I send a mail to r-help mailing list.

I'm developing a program in java with calls in R and I can`t use jri 0.4-1
with R 2.7 or 2.6 .but it runs with 2.4.

The problem that I get when using the latest version of R is as follows:

Cannot find JRI native library!
Please make sure that the JRI native library is in a directory listed in
java.library.path.

 java.lang.UnsatisfiedLinkError: C:\JRI_0.4-1\JRI\jri.dll: No se encontró 
el proceso especificado
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(Unknown Source)
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at org.rosuda.JRI.Rengine.clinit(Rengine.java:9)
at vista.main.Main.main(Main.java:12)

C:\JRI_0.4-1\JRI\j is included in the system path (in fact, the program runs
fine with R 2.4.0). I wonder if someone also has this problem and how it can
solve.

Any suggestions are highly appreciated,
Thanks,
Borja

[[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] Rpart and case weights: working with functions

2008-06-03 Thread Prof Brian Ripley
'weights' should be a column in your 'data': that is the standard way to 
specify weights to a model-fitting function.


On Tue, 3 Jun 2008, Xavier Robin wrote:


I can't get rpart accept case weights defined inside a function.
It keeps using the copy defined in the global environment (if they exists) 
instead of the function-defined ones.


Here is what I do:

test.function - function (formula, data) {
 weights - rep(.1, 100)
 rpart(formula, data, weights)
}

test.function(x~y, data)

And I get an error:
Error in model.frame(formula, rownames, variables, varnames, extras, 
extranames,  : invalid type (closure) for variable '(weights)'



If I define weights in the global environment, it uses this instead of the 
function-defined one (which can be verified by .Last.value$frame$wt[1]: it 
should equal sum(weights) and actually equals the sum of global weights, not 
the function one).


I tried to pass a named argument (weights=weights), using other names (w, 
foo, ...), or both, but still it doesn't work. I found nothing in rpart doc 
about that behaviour...

It was tested on R 2.7.0 (Windows XP) and R 2.5.1 (Linux kernel 2.6.9).

For the moment, the only workaround I found is to use/modify the global 
weights using - (not very satisfying).



What did I wrong? And what should I do to get it work (i.e. using the copy of 
weights defined inside the function)?


Thanks in advance for your help.

Xavier Robin

--
Xavier Robin

Biomedical Proteomics Research Group (BPRG)
Department of Structural Biology and Bioinformatics (DBSB)
Geneva University Medical Center (CMU)
1, rue Michel Servet - CH-1211 Genève 4 - Switzerland
Tel: (+41 22) 379 53 21

__
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.



--
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595__
R-help@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] wildcard symbol or character

2008-06-03 Thread Michael Dewey

At 03:07 03/06/2008, john.polo wrote:

hello all,

i want to split a list into smaller lists. the list looks like this:
CW-W730  CW-W720  CW-W710  CW-W700  CW-W690  CW-W680  CW-W670 
CW-W660 
CE-W997  CE-W987  CE-W977  CE-W967  CE-W956  CE-W944  CE-W934 
CE-W924 7W-W760  7W-W750  7W-967W-941   7W-932   7W-923   7W-914   7W-905

7E-W565  7E-W555  7E-W545  7E-W535  7E-W525  7E-906   7E-850   7E-840 ...


i want the smaller lists to be based on the first two characters, 
like CW or 7E. i tried split() where the f variable = 
c(1E-*,1W-*,2E-*,2W-*,5E-*,5W-*,7E-*,7W-*,CE-*,CW-*), 
but * doesn't work as a wildcard as i had hoped. can someone tell me 
the appropriate wildcard character/symbol to use, please?


Did you really use split()?

I suspect that
?strsplit
might help you and you can follow the link to regular expressions or do
?regexp
for enlightenment on the wonders of regular expressions.

As another poster has mentioned you can of course use substr() in 
this case but regular expressions enable you to do far more.



john




Michael Dewey
http://www.aghmed.fsnet.co.uk

__
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] Rpart and case weights: working with functions

2008-06-03 Thread S Ellison
A bit of fiddling suggests that the problem is less to do with rpart
(which will quite happily acept weights defined inside a function) and
more to do with the formula argument to the test function.

This is probably because defining the formula in the global environment
(as you implicitly do by placing it in the function call) drags the
original formula environment along with it; try 
 f-function(form) str(form)
 f(y~x)

to see what I mean.

As a work-round, try something lik

test.function - function (formula.str, data) {
   weights - rep(.1, 8)
   rpart(as.formula(formula.str), data, weights)
}

which works if formula.str is a string instead of a formula object.

Alternatively, 

test.function - function (form, data) {
   weights - rep(.1, 8)
   environment(form)-environment() #re-sets the formula environment   

   rpart(form, data, weights)
}
test.function(y~x,df)
### SEEMED to work - though it looks like the sort of kludge an expert
would quail at; there's 
### bound to be a right way to get the formula evaluated in the current
environment.
 

 Xavier Robin [EMAIL PROTECTED] 03/06/2008 10:33:06

I can't get rpart accept case weights defined inside a function.
It keeps using the copy defined in the global environment (if they 
exists) instead of the function-defined ones.


***
This email and any attachments are confidential. Any use...{{dropped:8}}

__
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] predict arfima

2008-06-03 Thread A.N.

I noticed that both in the fArma and fracdiff packages it is not possible to
predict an object fitted with an  ARFIMA model. Moreover, the ox link is no
more available. 
However, is it possible to find the coefficient d of differentiation of a
time series, and then predict the time series by apply an arma model to the
filtered time series ?? 

Are there better or other methods to predict ARFIMA models ? 


-- 
View this message in context: 
http://www.nabble.com/predict-arfima-tp17621431p17621431.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] Cluster analysis with numeric and categorical variables

2008-06-03 Thread Miha Staut
Dear all,

I would like to perform a clustering analysis on a data frame with two 
coordinate variables (X and Y) and a categorical variable where only a != b can 
be established.  As far as I understood classification analyses, they are not 
an option as they partition the training set only in k classes of the test set. 
 By searching through the book Modern Applied Statistics with S I did not 
find a satisfactory solution. 

I will be grateful for any suggestions.

Best regards
Miha



  __
can.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.


Re: [R] Swap variables in data.frame

2008-06-03 Thread Rogers, James A [PGRD Groton]

Birgit Lemcke wrote:

 I have a dataframe and two of my variables are in the wrong position 
 and I would like to swap those variables. 

In addition to the other solutions posted, if you prefer to reference
the columns by name rather than by index, you could use subset() 

dat - data.frame(a = letters[1:3], b = LETTERS[1:3], c = 1:3, d = 3:1)

subset(dat, select = c(b, a, c, d))
## or equivalently, something like:
subset(dat, select = c(b:a, c:d))


--Jim 

James A. Rogers, Ph.D. 
Associate Director, Neuroscience Statistics
Pfizer Global RD New London
50 Pequot Avenue (MS 6025-B2131)
New London, CT 06320
office: (860) 732-0783
cell: (860) 501-7228
fax: (860) 686-7866

 

__
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] regsubsets - package(leaps)

2008-06-03 Thread Dieter Menne
Maura E Monville maura.monville at gmail.com writes:

 
 Please, can someone suggest me where to find a description for the
 attributes of the summary of regsubsets,
 that is:
 which  rsqrssadjr2  cp bicoutmat obj   ??

The docs say:

An object of class regsubsets containing no user-serviceable parts. It is
designed to be processed by summary.regsubsets. 

So if you don't want to dissect the code that generates it, it is probably best
to look what summary.regsubsets does the non-serviceable parts, and copy/modify
the code to adapt to your needs.

Dieter

__
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] matlab eigs function in R

2008-06-03 Thread Jorge Ivan Velez
Dear kayteck,

Function eigen (see ?eigen) will do what you want.

HTH,

Jorge


On Tue, Jun 3, 2008 at 5:42 AM, kayteck_master [EMAIL PROTECTED] wrote:


 Hello

 Does anybody know how one can compute d largest eigenvalues/eigenvectors in
 R, like in MATLAB eigs function ? eigen function computes all
 eigenvectors/eigenvalues, and they are slightly different than those
 generated by matlab eigs.

 Thanks in advance
 --
 View this message in context:
 http://www.nabble.com/matlab-eigs-function-in-R-tp17619641p17619641.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.


[[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] transforming output of grid.locator() to coordinates of a leaf viewport

2008-06-03 Thread Wittner, Ben, Ph.D.
Paul,

Thanks very much! Your example code below shows exactly how to do what I wanted.

-Ben

p.s., For the record,
transRight - current.transform()
after the second call to pushViewport() seems to have gotten deleted from you
example code below, but that was obvious.

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
 On Behalf Of Paul Murrell
 Sent: Monday, June 02, 2008 10:05 PM
 To: Wittner, Ben, Ph.D.
 Cc: [EMAIL PROTECTED]
 Subject: Re: [R] transforming output of grid.locator() to coordinates of a
 leaf viewport
 
 Hi
 
 
 Wittner, Ben, Ph.D. wrote:
  Hadley, In my application the leaf viewports will not overlap, but I
 guess that
  would not necessarily be the case for all applications. In any event, do
 you
  happen to know how to transform coordinates in the top-level viewport to
  coordinates in another viewport in the tree? Thanks. -Ben
 
 
 current.transform() transforms from *inches* within the current viewport
 to *inches* on the overall device.  Sounds like you need the inverse
 transform.
 
 If you are in a position to be able to enumerate all of your leaf
 viewports, then this may be a possible approach:
 
 - for each leaf viewport, visit the viewport and record the
 current.transform() for each leaf viewport.  Also record the size of the
 current viewport (in inches).
 - capture a click on the device (current viewport should be ROOT) in
 *inches*, then iterate through the leaf viewports to determine which one
 was clicked in.
 - to determine whether the click was within the viewport, use something
 like the following function (and check whether both new locations are
 positive and smaller than the size of the viewport (in inches)):
 
 newloc - function(loc, trans) {
 temploc - c(loc, 1) %*% trans
 (temploc/temploc[3])[-3]
 }
 
 Here's a simple example:
 
 # two leaf viewports
 # (one on the left half of the device, one on the right)
 grid.newpage()
 pushViewport(viewport(x=0, width=.5, just=left, name=left))
 transLeft - current.transform()
 sizeLeft - c(convertWidth(unit(1, npc), inches, valueOnly=TRUE),
   convertHeight(unit(1, npc), inches, valueOnly=TRUE))
 # Draw a rect for visual reference
 grid.rect(gp=gpar(fill=hcl(240, 60, 80)))
 upViewport()
 pushViewport(viewport(x=.5, width=.5, just=left, name=right))
 sizeRight - c(convertWidth(unit(1, npc), inches, valueOnly=TRUE),
convertHeight(unit(1, npc), inches, valueOnly=TRUE))
 heightRight - convertHeight(unit(1, npc), inches, valueOnly=TRUE)
 grid.rect(gp=gpar(fill=hcl(120, 60, 80)))
 upViewport()
 
 # Get a click
 # (current viewport is the ROOT viewport)
 click - grid.locator(unit=inches)
 
 # For each leaf viewport, calculate where the click was
 leftClick - newloc(unlist(click), solve(transLeft))
 rightClick - newloc(unlist(click), solve(transRight))
 
 # Which one was it in ?
 all(leftClick  0  leftClick  sizeLeft)
 all(rightClick  0  rightClick  sizeRight)
 
 
 Does that help ?
 
 Paul
 
 
 
  
 
  From: hadley wickham [mailto:[EMAIL PROTECTED]
  Sent: Sun 6/1/2008 3:24 PM
  To: Wittner, Ben, Ph.D.
  Cc: [EMAIL PROTECTED]
  Subject: Re: [R] transforming output of grid.locator() to coordinates of
 a leaf
  viewport
 
 
 
  Ben,
 
  What if the click occurs over multiple viewports?
 
  Hadley
 
  On Mon, Jun 2, 2008 at 6:50 AM, Wittner, Ben, Ph.D.
  [EMAIL PROTECTED] wrote:
  Short form:
 
 How do I transform the output of grid.locator() (or
  grid.locator(unit='npc')) to the native (or npc) coordinates of a
 viewport
  other
  than the top-level viewport?
 
 Thanks in advance. -Ben
 
  Long form:
 
 I would like the user to be able to click anywhere on
 the R
  graphics window. I would then like to figure out which leaf viewport
 the user
  clicked in and compute the native coordinates in that leaf viewport of
 the
  user's click.
 
 I saw a 2005 response by Paul Murrell to a post by Gabor
  Grothendieck roughly on this topic in which Paul suggested looking at
  trellis.focus(). I've looked at trellis.focus() and
 trellis.clickFocus(), but
  they don't appear to do what I want in that a) it would appear that my
 user
  would have to click twice, once to specify which leaf viewport and then
 again
  to
  specify which point in that viewport and b) trellis.clickFocus()
 appears to
  use
  lots of information from the trellis package, which I'm not using.
 
 So I decided to try to figure out the native coordinates
 of the
  click in each leaf viewport, to a) see whether the click is within the
  plotting
  region for that viewport and b) use those coordinates to take the
 appropriate
  action if it is. But I don't seem to be able to figure out how to
 translate
  from
  the top-level viewport coordinates to those of a leaf viewport. I tried
  interpreting the 3X3 matrix returned by current.transform() as an
 affine
  transformation in the x,y plane in 

Re: [R] Cluster analysis with numeric and categorical variables

2008-06-03 Thread Christian Hennig

Dear Miha,

a general way to do this is as follows:
Define a distance measure by aggregating the 
Euclidean distance on the (X,Y)-space and the trivial 0-1 distance (0 if 
category is the same) on the categorial variable. Perform cluster analysis 
(whichever you want) on the resulting distance matrix.


Note that there is more than one way to do this. The 0-1-distance could be 
incorporated in the definition of the Euclidean distance (instead of 
(x_i-y_i)^2), or a weighted average of the distances in X-, Y- and 
categorial space could be computed. Weights of variables (including 
possibly rescaling) have to be decided. How to do this precisely should 
depend on the subject matter and prior information about variable 
importance etc. In absence of such information, you may standardise the 
variablewise sums of squared pairwise distances to be equal.


Hope this helps (and you can figure out the relevant R code yourself).

Christian

On Tue, 3 Jun 2008, Miha Staut wrote:


Dear all,

I would like to perform a clustering analysis on a data frame with two coordinate 
variables (X and Y) and a categorical variable where only a != b can be established.  As 
far as I understood classification analyses, they are not an option as they partition the 
training set only in k classes of the test set.  By searching through the book 
Modern Applied Statistics with S I did not find a satisfactory solution.

I will be grateful for any suggestions.

Best regards
Miha



 __
can.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.



*** --- ***
Christian Hennig
University College London, Department of Statistical Science
Gower St., London WC1E 6BT, phone +44 207 679 1698
[EMAIL PROTECTED], www.homepages.ucl.ac.uk/~ucakche

__
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] JGR / linux

2008-06-03 Thread g-h-d

Hi all,

i'm trying to install JGR on linux (see bottom), but it runs into errors.
The bottom of the sequence below shows JavaJD could not be found

Any suggestion, please?


$ sudo apt-get install sun-java6-jdk

$ sudo update-alternatives --config java

There are 5 alternatives which provide `java'.

Selection Alternative
---
1 /usr/lib/jvm/java-1.5.0-sun/jre/bin/java
2 /usr/bin/gij-4.1
3 /usr/bin/gij-4.2
4 /usr/lib/jvm/java-gcj/jre/bin/java
+ 5 /usr/lib/jvm/java-7-icedtea/jre/bin/java

$sudo R CMD javareconf
Java interpreter : /usr/bin/java
Java version : 1.6.0_03
Java home path : /usr/lib/jvm/java-6-sun-1.6.0.03/jre
Java compiler : /usr/bin/javac
Java headers gen.: /usr/bin/javah
Java archive tool: /usr/bin/jar
Java library path:
$(JAVA_HOME)/lib/amd64/server:$(JAVA_HOME)/lib/amd64:$(JAVA_HOME)/../lib/amd64::/usr/java/packages/lib/amd64:/lib:/usr/lib
JNI linker flags : -L$(JAVA_HOME)/lib/amd64/server -L$(JAVA_HOME)/lib/amd64
-L$(JAVA_HOME)/../lib/amd64 -L -L/usr/java/packages/lib/amd64 -L/lib
-L/usr/lib -ljvm
JNI cpp flags : -I/usr/lib/jvm/java-6-sun-1.6.0.03/jre/../include
-I/usr/lib/jvm/java-6-sun-1.6.0.03/jre/../include/linux

Updating Java configuration in /etc/R
Done.

$ sudo R

R version 2.5.1 (2007-06-27)
Copyright (C) 2007 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

 install.packages('JGR', dep=TRUE)
Warning in install.packages(JGR, dep = TRUE) :
argument 'lib' is missing: using '/usr/local/lib/R/site-library'
--- Please select a CRAN mirror for use in this session ---
Loading Tcl/Tk interface ... done
also installing the dependency ‘JavaGD’

trying URL 'http://lib.stat.cmu.edu/R/CRAN/src/contrib/JavaGD_0.5-1.tar.gz'
Content type 'application/x-gzip' length 86505 bytes
opened URL
==
downloaded 84Kb

trying URL 'http://lib.stat.cmu.edu/R/CRAN/src/contrib/JGR_1.5-18.tar.gz'
Content type 'application/x-gzip' length 426244 bytes
opened URL
==
downloaded 416Kb

* Installing *source* package 'JavaGD' ...
checking for gcc... gcc-4.2 -std=gnu99
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc-4.2 -std=gnu99 accepts -g... yes
checking for gcc-4.2 -std=gnu99 option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc-4.2 -std=gnu99 -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/wait.h that is POSIX.1 compatible... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for string.h... (cached) yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking for unistd.h... (cached) yes
checking for an ANSI C-conforming const... yes
checking whether time.h and sys/time.h may both be included... yes
checking for stdlib.h... (cached) yes
checking for GNU libc compatible malloc... yes
checking return type of signal handlers... void
checking for memset... yes
checking for mkdir... yes
checking for rmdir... yes
checking for select... yes
checking for socket... yes
checking Java support in R... present:
interpreter : '/usr/bin/java'
cpp flags : '-I/usr/lib/jvm/java-6-sun-1.6.0.03/jre/../include
-I/usr/lib/jvm/java-6-sun-1.6.0.03/jre/../include/linux'
java libs : '-L/usr/lib/jvm/java-6-sun-1.6.0.03/jre/lib/amd64/server
-L/usr/lib/jvm/java-6-sun-1.6.0.03/jre/lib/amd64
-L/usr/lib/jvm/java-6-sun-1.6.0.03/jre/../lib/amd64 -L
-L/usr/java/packages/lib/amd64 -L/lib -L/usr/lib -ljvm'
checking whether JNI programs can be compiled... yes
configure: creating ./config.status
config.status: creating src/Makevars
config.status: creating R/zzz.R
config.status: creating src/config.h
** libs
gcc-4.2 -std=gnu99 -I/usr/share/R/include -I/usr/share/R/include
-I/usr/lib/jvm/java-6-sun-1.6.0.03/jre/../include
-I/usr/lib/jvm/java-6-sun-1.6.0.03/jre/../include/linux -Iinclude -fpic -g
-O2 -c 

Re: [R] matlab eigs function in R

2008-06-03 Thread David Winsemius
Jorge Ivan Velez [EMAIL PROTECTED] wrote in
news:[EMAIL PROTECTED]: 

 Dear kayteck,
 
 Function eigen (see ?eigen) will do what you want.
 
 HTH,

He had looked, but since eigen returns both eigenvalues and 
eigenvectors, and does so in a list, perhaps he needs advice about how 
to extract his values from the list structure.

x - matrix(c(1:5, (1:5)^2, (1:5)^(1/2), 0,0,0,1,0, 0,0,0,0,1),5, 5)

str(eigen(x))
#List of 2
# $ values : cplx [1:5] 7.43+0i 1.00+0i 1.00+0i ...
# $ vectors: cplx [1:5, 1:5] 0.0699+0i 0.1600+0i 0.2894+0i ...

d - 3

eigen(x)$values[1:d]

[1] 7.431675+0i 1.00+0i 1.00+0i

#no need to sort since eigen does that by default.

Not sure we can help him out regarding the slight difference btwn 
Matlab values and R values due to the unnecessary vagueness of his 
concern.

-- 
David Winsemius


 
 Jorge
 
 
 On Tue, Jun 3, 2008 at 5:42 AM, kayteck_master
 [EMAIL PROTECTED] wrote: 
 

 Hello

 Does anybody know how one can compute d largest
 eigenvalues/eigenvectors in R, like in MATLAB eigs function ? eigen
 function computes all eigenvectors/eigenvalues, and they are
 slightly different than those generated by matlab eigs.

 Thanks in advance
 --



__
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] Rpart and case weights: working with functions

2008-06-03 Thread Xavier Robin

S Ellison a écrit :

As a work-round, try something lik

test.function - function (formula.str, data) {
   weights - rep(.1, 8)
   rpart(as.formula(formula.str), data, weights)
}

which works if formula.str is a string instead of a formula object.


Ok, I think I got the point. The only problem with transforming the 
string to a formula is that rpart raises another error:

Error in t.default(x) : argument is not a matrix




test.function - function (form, data) {
   weights - rep(.1, 8)
   environment(form)-environment() #re-sets the formula environment   
   rpart(form, data, weights)

}


This works perfectly well. It will be good enough for what I need.

Thanks a lot ;-)

Xavier

__
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] Swap variables in data.frame

2008-06-03 Thread Birgitle

Thanks might be easier in my case because I have so many variables.
Could have found this solution on my own.

Birgit


Rogers, James A [PGRD Groton] wrote:
 
 
 Birgit Lemcke wrote:
 
 I have a dataframe and two of my variables are in the wrong position 
 and I would like to swap those variables. 
 
 In addition to the other solutions posted, if you prefer to reference
 the columns by name rather than by index, you could use subset() 
 
 dat - data.frame(a = letters[1:3], b = LETTERS[1:3], c = 1:3, d = 3:1)
 
 subset(dat, select = c(b, a, c, d))
 ## or equivalently, something like:
 subset(dat, select = c(b:a, c:d))
 
 
 --Jim 
 
 James A. Rogers, Ph.D. 
 Associate Director, Neuroscience Statistics
 Pfizer Global RD New London
 50 Pequot Avenue (MS 6025-B2131)
 New London, CT 06320
 office: (860) 732-0783
 cell: (860) 501-7228
 fax: (860) 686-7866
 
  
 
 __
 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.
 
 


-
The art of living is more like wrestling than dancing.
(Marcus Aurelius)
-- 
View this message in context: 
http://www.nabble.com/Swap-variables-in-data.frame-tp17597476p17626237.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] JGR / linux

2008-06-03 Thread Prof Brian Ripley

Your R is way too old: please follow the advice in the posting guide.
I suspect the current JavaJD requires R = 2.7.0 from the errors you are 
getting below.


On Tue, 3 Jun 2008, g-h-d wrote:



Hi all,

i'm trying to install JGR on linux (see bottom), but it runs into errors.
The bottom of the sequence below shows JavaJD could not be found

Any suggestion, please?


$ sudo apt-get install sun-java6-jdk

$ sudo update-alternatives --config java

There are 5 alternatives which provide `java'.

Selection Alternative
---
1 /usr/lib/jvm/java-1.5.0-sun/jre/bin/java
2 /usr/bin/gij-4.1
3 /usr/bin/gij-4.2
4 /usr/lib/jvm/java-gcj/jre/bin/java
+ 5 /usr/lib/jvm/java-7-icedtea/jre/bin/java

$sudo R CMD javareconf
Java interpreter : /usr/bin/java
Java version : 1.6.0_03
Java home path : /usr/lib/jvm/java-6-sun-1.6.0.03/jre
Java compiler : /usr/bin/javac
Java headers gen.: /usr/bin/javah
Java archive tool: /usr/bin/jar
Java library path:
$(JAVA_HOME)/lib/amd64/server:$(JAVA_HOME)/lib/amd64:$(JAVA_HOME)/../lib/amd64::/usr/java/packages/lib/amd64:/lib:/usr/lib
JNI linker flags : -L$(JAVA_HOME)/lib/amd64/server -L$(JAVA_HOME)/lib/amd64
-L$(JAVA_HOME)/../lib/amd64 -L -L/usr/java/packages/lib/amd64 -L/lib
-L/usr/lib -ljvm
JNI cpp flags : -I/usr/lib/jvm/java-6-sun-1.6.0.03/jre/../include
-I/usr/lib/jvm/java-6-sun-1.6.0.03/jre/../include/linux

Updating Java configuration in /etc/R
Done.

$ sudo R

R version 2.5.1 (2007-06-27)
Copyright (C) 2007 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.


install.packages('JGR', dep=TRUE)

Warning in install.packages(JGR, dep = TRUE) :
argument 'lib' is missing: using '/usr/local/lib/R/site-library'
--- Please select a CRAN mirror for use in this session ---
Loading Tcl/Tk interface ... done
also installing the dependency ‘JavaGD’

trying URL 'http://lib.stat.cmu.edu/R/CRAN/src/contrib/JavaGD_0.5-1.tar.gz'
Content type 'application/x-gzip' length 86505 bytes
opened URL
==
downloaded 84Kb

trying URL 'http://lib.stat.cmu.edu/R/CRAN/src/contrib/JGR_1.5-18.tar.gz'
Content type 'application/x-gzip' length 426244 bytes
opened URL
==
downloaded 416Kb

* Installing *source* package 'JavaGD' ...
checking for gcc... gcc-4.2 -std=gnu99
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc-4.2 -std=gnu99 accepts -g... yes
checking for gcc-4.2 -std=gnu99 option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc-4.2 -std=gnu99 -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/wait.h that is POSIX.1 compatible... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for string.h... (cached) yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking for unistd.h... (cached) yes
checking for an ANSI C-conforming const... yes
checking whether time.h and sys/time.h may both be included... yes
checking for stdlib.h... (cached) yes
checking for GNU libc compatible malloc... yes
checking return type of signal handlers... void
checking for memset... yes
checking for mkdir... yes
checking for rmdir... yes
checking for select... yes
checking for socket... yes
checking Java support in R... present:
interpreter : '/usr/bin/java'
cpp flags : '-I/usr/lib/jvm/java-6-sun-1.6.0.03/jre/../include
-I/usr/lib/jvm/java-6-sun-1.6.0.03/jre/../include/linux'
java libs : '-L/usr/lib/jvm/java-6-sun-1.6.0.03/jre/lib/amd64/server
-L/usr/lib/jvm/java-6-sun-1.6.0.03/jre/lib/amd64
-L/usr/lib/jvm/java-6-sun-1.6.0.03/jre/../lib/amd64 -L
-L/usr/java/packages/lib/amd64 -L/lib -L/usr/lib -ljvm'
checking whether JNI programs can be compiled... yes
configure: creating ./config.status
config.status: creating src/Makevars
config.status: creating R/zzz.R
config.status: creating src/config.h
** libs

[R] surprising predicting capabilities

2008-06-03 Thread chaogai
Hi,

I noticed the following fortune in R 2.7 and 2.6.2:

fortune('Spreads')

If anything, there should be a Law: Thou Shalt Not Even Think Of Producing A
Graph That Looks Like Anything From A Spreadsheet.
   -- Ted Harding (in a discussion about producing graphics)
  R-help (August 2008)


Just wondering, what function and library gave this detailed prediction?

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.


Re: [R] JGR / linux

2008-06-03 Thread g-h-d

Thanks. 

I basically followed the steps in http://lib.stat.cmu.edu/R/CRAN/, and those
below for JGR and it worked.

...but there are problems with help files e.g. ?matrix generates the
following message:

/tmp/RtmpvxsnQa/.R/doc/html/packages.html (No such file or directory)



g-h-d wrote:
 
 Hi all,
 
 i'm trying to install JGR on linux (see bottom), but it runs into errors.
 The bottom of the sequence below shows JavaJD could not be found
 
 Any suggestion, please?
 
 
 $ sudo apt-get install sun-java6-jdk
 
 $ sudo update-alternatives --config java
 
 There are 5 alternatives which provide `java'.
 
 Selection Alternative
 ---
 1 /usr/lib/jvm/java-1.5.0-sun/jre/bin/java
 2 /usr/bin/gij-4.1
 3 /usr/bin/gij-4.2
 4 /usr/lib/jvm/java-gcj/jre/bin/java
 + 5 /usr/lib/jvm/java-7-icedtea/jre/bin/java
 
 $sudo R CMD javareconf
 Java interpreter : /usr/bin/java
 Java version : 1.6.0_03
 Java home path : /usr/lib/jvm/java-6-sun-1.6.0.03/jre
 Java compiler : /usr/bin/javac
 Java headers gen.: /usr/bin/javah
 Java archive tool: /usr/bin/jar
 Java library path:
 $(JAVA_HOME)/lib/amd64/server:$(JAVA_HOME)/lib/amd64:$(JAVA_HOME)/../lib/amd64::/usr/java/packages/lib/amd64:/lib:/usr/lib
 JNI linker flags : -L$(JAVA_HOME)/lib/amd64/server
 -L$(JAVA_HOME)/lib/amd64 -L$(JAVA_HOME)/../lib/amd64 -L
 -L/usr/java/packages/lib/amd64 -L/lib -L/usr/lib -ljvm
 JNI cpp flags : -I/usr/lib/jvm/java-6-sun-1.6.0.03/jre/../include
 -I/usr/lib/jvm/java-6-sun-1.6.0.03/jre/../include/linux
 
 Updating Java configuration in /etc/R
 Done.
 
 $ sudo R
 
 R version 2.5.1 (2007-06-27)
 Copyright (C) 2007 The R Foundation for Statistical Computing
 ISBN 3-900051-07-0
 
 R is free software and comes with ABSOLUTELY NO WARRANTY.
 You are welcome to redistribute it under certain conditions.
 Type 'license()' or 'licence()' for distribution details.
 
 Natural language support but running in an English locale
 
 R is a collaborative project with many contributors.
 Type 'contributors()' for more information and
 'citation()' on how to cite R or R packages in publications.
 
 Type 'demo()' for some demos, 'help()' for on-line help, or
 'help.start()' for an HTML browser interface to help.
 Type 'q()' to quit R.
 
 install.packages('JGR', dep=TRUE)
 Warning in install.packages(JGR, dep = TRUE) :
 argument 'lib' is missing: using '/usr/local/lib/R/site-library'
 --- Please select a CRAN mirror for use in this session ---
 Loading Tcl/Tk interface ... done
 also installing the dependency ‘JavaGD’
 
 trying URL
 'http://lib.stat.cmu.edu/R/CRAN/src/contrib/JavaGD_0.5-1.tar.gz'
 Content type 'application/x-gzip' length 86505 bytes
 opened URL
 ==
 downloaded 84Kb
 
 trying URL 'http://lib.stat.cmu.edu/R/CRAN/src/contrib/JGR_1.5-18.tar.gz'
 Content type 'application/x-gzip' length 426244 bytes
 opened URL
 ==
 downloaded 416Kb
 
 * Installing *source* package 'JavaGD' ...
 checking for gcc... gcc-4.2 -std=gnu99
 checking for C compiler default output file name... a.out
 checking whether the C compiler works... yes
 checking whether we are cross compiling... no
 checking for suffix of executables...
 checking for suffix of object files... o
 checking whether we are using the GNU C compiler... yes
 checking whether gcc-4.2 -std=gnu99 accepts -g... yes
 checking for gcc-4.2 -std=gnu99 option to accept ISO C89... none needed
 checking how to run the C preprocessor... gcc-4.2 -std=gnu99 -E
 checking for grep that handles long lines and -e... /bin/grep
 checking for egrep... /bin/grep -E
 checking for ANSI C header files... yes
 checking for sys/wait.h that is POSIX.1 compatible... yes
 checking for sys/types.h... yes
 checking for sys/stat.h... yes
 checking for stdlib.h... yes
 checking for string.h... yes
 checking for memory.h... yes
 checking for strings.h... yes
 checking for inttypes.h... yes
 checking for stdint.h... yes
 checking for unistd.h... yes
 checking for string.h... (cached) yes
 checking sys/time.h usability... yes
 checking sys/time.h presence... yes
 checking for sys/time.h... yes
 checking for unistd.h... (cached) yes
 checking for an ANSI C-conforming const... yes
 checking whether time.h and sys/time.h may both be included... yes
 checking for stdlib.h... (cached) yes
 checking for GNU libc compatible malloc... yes
 checking return type of signal handlers... void
 checking for memset... yes
 checking for mkdir... yes
 checking for rmdir... yes
 checking for select... yes
 checking for socket... yes
 checking Java support in R... present:
 interpreter : '/usr/bin/java'
 cpp flags : '-I/usr/lib/jvm/java-6-sun-1.6.0.03/jre/../include
 -I/usr/lib/jvm/java-6-sun-1.6.0.03/jre/../include/linux'
 java libs : '-L/usr/lib/jvm/java-6-sun-1.6.0.03/jre/lib/amd64/server
 -L/usr/lib/jvm/java-6-sun-1.6.0.03/jre/lib/amd64
 -L/usr/lib/jvm/java-6-sun-1.6.0.03/jre/../lib/amd64 -L
 -L/usr/java/packages/lib/amd64 -L/lib 

Re: [R] 'asymmetric span' for 2D loess?

2008-06-03 Thread Tokuyasu, Taku
Dear Prof Ripley,

  Hello,
 
  I am interested in performing a 2D loess smooth on microarray data, i.e.
  log2 ratios on a 2D grid, using different spans in the horizontal and
  vertical directions (the immediate reason being that replicate spots are
  laid out in the horizontal direction).  Is it possible to do this in R?
  Functions like loess(stats) seem to apply the same span for all
  predictors, which carries over to functions like ma2D(marray).
 
 See the next comment.  'span' applies to 2D distances, and I think you
 need to rescale your inputs so Euclidean distance is appropriate.

That's a great idea.

 
  As an elementary second question, are there circumstances where one
  expects to see a substantial difference in the fits between say loess(y
  ~ x1 + x2) and loess(y ~ x1 * x2) with an interaction term (and if so,
  what are they)?
 
 From the help page:
 
   formula: a formula specifying the numeric response and one to four
numeric predictors (best specified via an interaction, but
can also be specified additively).  Will be coerced to a
formula if necessary.
 
 So the two versions both specify smoothing in 2D.
 
 You can use things like lo(x1) + lo(x2) in some gam fits.

Hadn't thought of that, I will explore this.

 
 It often helps to read the primary sources, in this case chapters in the
 White Book (Chambers  Hastie, nominally 1992, actually published in
 1991).
 
 --
 Brian D. Ripley,  [EMAIL PROTECTED]
 Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
 University of Oxford, Tel:  +44 1865 272861 (self)
 1 South Parks Road, +44 1865 272866 (PA)
 Oxford OX1 3TG, UKFax:  +44 1865 272595
 

Thanks very much for the help.  Nice photos on the Web, by the way.

Regards,

_Taku

Taku A. Tokuyasu, PhD
UCSF Helen Diller Family Comprehensive Cancer Center
San Francisco, CA 94143-0808

__
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] surprising predicting capabilities

2008-06-03 Thread Greg Snow
That is actually from August 2007 (typo in the fortunes package).

If you do

 RSiteSearch('Thou Shalt Not Even Think Graph Spreadsheet')

Then it will bring up the actual post and you can read it in context (along 
with the posts that lead to it and those that followed).

Basically, Ted was trying to shorten my soapbox without knocking me off of it 
after I replied to someone who wanted to add the values to a barchart like a 
particular spreadsheet.

--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
(801) 408-8111



 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of chaogai
 Sent: Tuesday, June 03, 2008 10:16 AM
 To: r-help@r-project.org
 Subject: [R] surprising predicting capabilities

 Hi,

 I noticed the following fortune in R 2.7 and 2.6.2:

 fortune('Spreads')

 If anything, there should be a Law: Thou Shalt Not Even Think
 Of Producing A Graph That Looks Like Anything From A Spreadsheet.
-- Ted Harding (in a discussion about producing graphics)
   R-help (August 2008)


 Just wondering, what function and library gave this detailed
 prediction?

 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-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] gam and prior

2008-06-03 Thread Paul Baverel
Hi.
I am running a gam for covariate forward inclusions/ backward exclusions,
using the weight options as follow.
library(gam)
gam.object1-gam(ET~1, data=nonp.dat, weights=PROBA)
summary(gam.object1)
step.object1-step.gam(gam.object1, direction=both , trace=T,
 scope=list(CRCL=~1+CRCL+ns(CRCL,2),
HT=~1+HT+ns(HT,2),
WT=~1+WT+ns(WT,2),
SER=~1+SER+ns(SER,2),
ALAT=~1+ALAT+ns(ALAT,2),
AGE=~1+AGE+ns(AGE,2),
UNI1=~1+UNI1+ns(UNI1,2),
 
as.factor(SEX)=~1+as.factor(SEX),
 
as.factor(COME)=~1+as.factor(COME),
 
as.factor(SMOK)=~1+as.factor(SMOK)))
summary(step.object1)
The problem is that I am not sure how to use this weight since my AIKAIKE
criteria goes really high as soon as I include the weights (that is, by the
way, a probability (very small number then)) and then, it includes all the
covariates in the scope while it should include only the one created in a
previous step.
I heard about a prior.weights() option as well but using it does not affect
the results at all.
Some suggestions or help on how to use prior.weights or weights in gam or
even in glm will be very welcome as it is not really well documented.

__
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] request: An array declarion problem

2008-06-03 Thread Muhammad Azam
Dear R users
I tried a lot to solve the following problem but could not. I have two arrays 
having same order i.e 1 by 150. 

j=10; ss=150; r=array(0 , c( j , ss )); rr=array(0 , c( j , ss )); r1=array(0 , 
c( j-1 , ss )); r2=array(0 , c( j-1 , ss )); 
r3=array(0 , c( 2 , ss ))

for(i in 1:j-1){
r1[ i , ] - r[ j+1, ]-r[ j, ]; r2[ i , ] - rr[ j+1, 
]-rr[ j, ]
}

Now i want to rbind the results of r1 and r2 for each time. Now the order  of 
r3[ j, ] will become 2 by 150. I used the following form in the loop 

r3[ i,]=rbind(r1[ i, ], r2[ i, ])  

But there is an error message 

Error in r3[i, ] = rbind(r1[i, ], r2[i, ]) :  number of items to replace is not 
a multiple of replacement length


I am looking for some suggestion to solve the problem. Thanks and


best regards

Muhammad Azam 
Ph.D. Student 
Department of Medical Statistics, 
Informatics and Health Economics 
University of Innsbruck, Austria 


  
[[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] wildcard symbol or character

2008-06-03 Thread john.polo

Michael Dewey wrote:
split() where the f variable = 
c(1E-*,1W-*,2E-*,2W-*,5E-*,5W-*,7E-*,7W-*,CE-*,CW-*), 
but * doesn't work as a wildcard as i had hoped. can someone tell me 
the appropriate wildcard character/symbol to use, please

Did you really use split()?

yes, i did. the output looked like this:
 split(rtt,RTT)
$`1E-.`
 [1] CW-W739  CW-W729  CW-W719  CW-W709  CW-W699  CW-W689B CW-W679  
CW-W669

...
$`1W-.`
 [1] CW-W738  CW-W728  CW-W718  CW-W708  CW-W698  CW-W688  CW-W678  CW-W668
...

I suspect that
?strsplit
might help you and you can follow the link to regular expressions or do
?regexp
for enlightenment on the wonders of regular expressions.

As another poster has mentioned you can of course use substr() in this 
case but regular expressions enable you to do far more.
i haven't tried any of other solution suggested in other posts yet. 
thanks for your reply.


john

__
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] matlab eigs function in R

2008-06-03 Thread Thomas Lumley

Presumably the original poster was looking for a function that would compute 
just the largest five eigenvalues and associated vectors, because that is 
enormously more efficient for a large matrix than computing all of them.

eigen() computes all of them.

One way to compute just a few is to use svd(), where you can specify the number 
of left and right singular vectors to compute.

   -thomas


On Tue, 3 Jun 2008, David Winsemius wrote:


Jorge Ivan Velez [EMAIL PROTECTED] wrote in
news:[EMAIL PROTECTED]:


Dear kayteck,

Function eigen (see ?eigen) will do what you want.

HTH,


He had looked, but since eigen returns both eigenvalues and
eigenvectors, and does so in a list, perhaps he needs advice about how
to extract his values from the list structure.

x - matrix(c(1:5, (1:5)^2, (1:5)^(1/2), 0,0,0,1,0, 0,0,0,0,1),5, 5)

str(eigen(x))
#List of 2
# $ values : cplx [1:5] 7.43+0i 1.00+0i 1.00+0i ...
# $ vectors: cplx [1:5, 1:5] 0.0699+0i 0.1600+0i 0.2894+0i ...

d - 3

eigen(x)$values[1:d]

[1] 7.431675+0i 1.00+0i 1.00+0i

#no need to sort since eigen does that by default.

Not sure we can help him out regarding the slight difference btwn
Matlab values and R values due to the unnecessary vagueness of his
concern.

--
David Winsemius




Jorge


On Tue, Jun 3, 2008 at 5:42 AM, kayteck_master
[EMAIL PROTECTED] wrote:



Hello

Does anybody know how one can compute d largest
eigenvalues/eigenvectors in R, like in MATLAB eigs function ? eigen
function computes all eigenvectors/eigenvalues, and they are
slightly different than those generated by matlab eigs.

Thanks in advance
--






__
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.



Thomas Lumley   Assoc. Professor, Biostatistics
[EMAIL PROTECTED]   University 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] wildcard symbol or character

2008-06-03 Thread john.polo

Jorge Ivan Velez wrote:


Dear John,

Assuming that your information is in the list x, does

substr(x,1,2)

work for you?

HTH,

Jorge

thanks for your reply Jorge. i will try substr().

john

__
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] R-2.7.0 rJava installation failure on x86_64

2008-06-03 Thread Nathan Coulter
attempting to install rJava on R-2.7.0, x86_64 platform, config.log shows the
following error:


configure:3880: checking whether JNI programs can be compiled
configure:3898: gcc -m64 -std=gnu99 -o conftest -g -O2
-I/path/to/x86-64-linux/jdk-1.6.0_06/jre/../include   conftest.c
-L/path/to/x86-64-linux/jdk-1.6.0_06/jre/lib/amd64/server
-L/path/to/x86-64-linux/jdk-1.6.0_06/jre/lib/amd64
-L/path/to/x86-64-linux/jdk-1.6.0_06/jre/../lib/amd64 -L
-L/usr/java/packages/lib/amd64 -L/lib -L/usr/lib -ljvm 5
/path/to/x86-64-linux/bin/ld: skipping incompatible /usr/lib/libc.so 
when
searching for -lc /usr/lib/libc.a: could not read symbols: File format 
is
ambiguous collect2: ld returned 1 exit status


It looks like the command above could use /lib64/libc.so.6, but running R CMD
javareconf shows that JNI linker flags don't contain any entry similar to
'-L/lib64':


-bash-3.00$ /path/to/noarch/bin/statcomp R-2.7.0 CMD javareconf
Java interpreter : /path/to/x86-64-linux/bin/java
Java version : 1.6.0_06
Java home path   : /path/to/x86-64-linux/jdk-1.6.0_06/jre Java
compiler : /path/to/x86-64-linux/bin/javac
Java headers gen.: /path/to/x86-64-linux/bin/javah
Java archive tool: /path/to/x86-64-linux/bin/jar
Java library path:

$(JAVA_HOME)/lib/amd64/server:$(JAVA_HOME)/lib/amd64:$(JAVA_HOME)/../lib/amd64::/usr/java/packages/lib/amd64:/lib:/usr/lib
JNI linker flags : -L$(JAVA_HOME)/lib/amd64/server 
-L$(JAVA_HOME)/lib/amd64
-L$(JAVA_HOME)/../lib/amd64 -L -L/usr/java/packages/lib/amd64 -L/lib
-L/usr/lib -ljvm JNI cpp flags: -I$(JAVA_HOME)/../include


Suggests on the root of the problem or best workarounds?

-- 
Nathan

__
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] problems on plotting adjacent bars with barplot. Help request, please

2008-06-03 Thread Giacomo Prodi
hi ladyes and gentlemans of the R comunity.
i have the following graphical issue:

# say y is a matrix or a dataframe with
dim(51,nrow=17),hence 3 columns; 
l-51

# now the 3 colums represents 3 different aspects of
my continuous variable (3 factors),plotted against a
categorical one;
n-levels(factor(x))

# i want to plot those 3 factors adjacently using the
barplot(), and possibly show error bars as well;
err-rep(1.2,17)

this is the function that i unsuccesfully wrote to do
this:

adj.bars-function(y,e,n,l){
both-numeric(l)
both[1:l%%2==1]-y[,1]
both[1:l%%2!=c(0,1)]-y[,2]
both[1:l%%2==0]-y[,3]
labels-character(l)
labels[1:l%%2==1]-n
xv-barplot(both,col=rep(c(1,2,3),17),
ylim=c(0,max(y)+e[1]),names=labels)
up-x[,1]+e
down-x[,1]-e
arrows(xv,up,xv,down,code=3,angle=90,length=0.025)
up2-x[,2]+e
down2-x[,2]-e
arrows(xv,up,xv,down,code=3,angle=90,length=0.025)
up3-x[,3]+e
down3-x[,3]-e
arrows(xv,up,xv,down,code=3,angle=90,length=0.025)
}

i guess the both instruction is fake 'cause the plot
looks really wrong.
i have also tried this other one.

rm(l)
l-17 
adj.bars-function(y,e,n,l){
both-rep(c(1,1.5,2),l)
both[1:l%%2==1]-y[,1]
both[1:l%%2==1.5]-y[,2]
both[1:l%%2==0]-y[,3]
...

i thank you all for the attention, and i'll be
grateful if someone had simple tip to all this.
FEDERICO, undergraduate student in Insubria University
Varese, Italy.


  ___ 

http://www.ymailblogit.com/blog/

__
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] splitting data frame based on a criteria

2008-06-03 Thread Marvin Lists
Hi,
I have a data frame that I want to split into two based on the values of a
variable in it.

The variable Y has numeric values ranging between 0 through 70. I want to
plot the frequencies of another variable X in two different cases:
- When Y = 0 and
- When Y  0

How does one go about doing this?

In general, I want to do several analyses with this data frame that are a
variation of the above situation, i.e. they require splitting the data into
different age, gender etc. and then calculating separate means, correlations
and so on for the different groups into which the data frame would split.

I am struggling with the correct syntax for achieving this.

Reading through the documentation suggests that tapply and split may be the
functions to use for my purposes but the examples in the documentations
didn't help me understand how I could achieve this.

I would appreciate any suggestions and help.

Thanks,
Marvin

[[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] JGR / linux

2008-06-03 Thread Dirk Eddelbuettel

On 3 June 2008 at 08:42, g-h-d wrote:
| I basically followed the steps in http://lib.stat.cmu.edu/R/CRAN/, and those
| below for JGR and it worked.
| 
| ...but there are problems with help files e.g. ?matrix generates the
| following message:
| 
| /tmp/RtmpvxsnQa/.R/doc/html/packages.html (No such file or directory)

I think you can ignore that. It's just a warning.  The rest of your steps
were very sound.

In particular ...

| g-h-d wrote:
|  
|  Hi all,
|  
|  i'm trying to install JGR on linux (see bottom), but it runs into errors.
|  The bottom of the sequence below shows JavaJD could not be found
|  
|  Any suggestion, please?
|  
|  
|  $ sudo apt-get install sun-java6-jdk
|  
|  $ sudo update-alternatives --config java
|  
|  There are 5 alternatives which provide `java'.
|  
|  Selection Alternative
|  ---
|  1 /usr/lib/jvm/java-1.5.0-sun/jre/bin/java
|  2 /usr/bin/gij-4.1
|  3 /usr/bin/gij-4.2
|  4 /usr/lib/jvm/java-gcj/jre/bin/java
|  + 5 /usr/lib/jvm/java-7-icedtea/jre/bin/java

... a very good idea to realign what command will default to being 'java' ...
 
|  $sudo R CMD javareconf
|  Java interpreter : /usr/bin/java
|  Java version : 1.6.0_03
|  Java home path : /usr/lib/jvm/java-6-sun-1.6.0.03/jre
|  Java compiler : /usr/bin/javac
|  Java headers gen.: /usr/bin/javah
|  Java archive tool: /usr/bin/jar

... but given that javareconf also looks after javac and javah, I recommend
doing the same update-alternatives call for 'javah' and 'javac'.

I just re-did that on a Ubuntu 8.04, 32bit, machine and it re-built rJava,
JGR, JavaGD, ... without a hitch.

Dirk


|  Java library path:
|  
$(JAVA_HOME)/lib/amd64/server:$(JAVA_HOME)/lib/amd64:$(JAVA_HOME)/../lib/amd64::/usr/java/packages/lib/amd64:/lib:/usr/lib
|  JNI linker flags : -L$(JAVA_HOME)/lib/amd64/server
|  -L$(JAVA_HOME)/lib/amd64 -L$(JAVA_HOME)/../lib/amd64 -L
|  -L/usr/java/packages/lib/amd64 -L/lib -L/usr/lib -ljvm
|  JNI cpp flags : -I/usr/lib/jvm/java-6-sun-1.6.0.03/jre/../include
|  -I/usr/lib/jvm/java-6-sun-1.6.0.03/jre/../include/linux
|  
|  Updating Java configuration in /etc/R
|  Done.
|  
|  $ sudo R
|  
|  R version 2.5.1 (2007-06-27)
|  Copyright (C) 2007 The R Foundation for Statistical Computing
|  ISBN 3-900051-07-0
|  
|  R is free software and comes with ABSOLUTELY NO WARRANTY.
|  You are welcome to redistribute it under certain conditions.
|  Type 'license()' or 'licence()' for distribution details.
|  
|  Natural language support but running in an English locale
|  
|  R is a collaborative project with many contributors.
|  Type 'contributors()' for more information and
|  'citation()' on how to cite R or R packages in publications.
|  
|  Type 'demo()' for some demos, 'help()' for on-line help, or
|  'help.start()' for an HTML browser interface to help.
|  Type 'q()' to quit R.
|  
|  install.packages('JGR', dep=TRUE)
|  Warning in install.packages(JGR, dep = TRUE) :
|  argument 'lib' is missing: using '/usr/local/lib/R/site-library'
|  --- Please select a CRAN mirror for use in this session ---
|  Loading Tcl/Tk interface ... done
|  also installing the dependency  JavaGD 
|  
|  trying URL
|  'http://lib.stat.cmu.edu/R/CRAN/src/contrib/JavaGD_0.5-1.tar.gz'
|  Content type 'application/x-gzip' length 86505 bytes
|  opened URL
|  ==
|  downloaded 84Kb
|  
|  trying URL 'http://lib.stat.cmu.edu/R/CRAN/src/contrib/JGR_1.5-18.tar.gz'
|  Content type 'application/x-gzip' length 426244 bytes
|  opened URL
|  ==
|  downloaded 416Kb
|  
|  * Installing *source* package 'JavaGD' ...
|  checking for gcc... gcc-4.2 -std=gnu99
|  checking for C compiler default output file name... a.out
|  checking whether the C compiler works... yes
|  checking whether we are cross compiling... no
|  checking for suffix of executables...
|  checking for suffix of object files... o
|  checking whether we are using the GNU C compiler... yes
|  checking whether gcc-4.2 -std=gnu99 accepts -g... yes
|  checking for gcc-4.2 -std=gnu99 option to accept ISO C89... none needed
|  checking how to run the C preprocessor... gcc-4.2 -std=gnu99 -E
|  checking for grep that handles long lines and -e... /bin/grep
|  checking for egrep... /bin/grep -E
|  checking for ANSI C header files... yes
|  checking for sys/wait.h that is POSIX.1 compatible... yes
|  checking for sys/types.h... yes
|  checking for sys/stat.h... yes
|  checking for stdlib.h... yes
|  checking for string.h... yes
|  checking for memory.h... yes
|  checking for strings.h... yes
|  checking for inttypes.h... yes
|  checking for stdint.h... yes
|  checking for unistd.h... yes
|  checking for string.h... (cached) yes
|  checking sys/time.h usability... yes
|  checking sys/time.h presence... yes
|  checking for sys/time.h... yes
|  checking for unistd.h... (cached) yes
|  checking for an ANSI C-conforming const... yes
|  checking whether time.h and 

[R] adding column and pulling data from table

2008-06-03 Thread Paul Adams
Hello to everyone,
I have a general question about how to add a column to a table.I have a table 
that has 62 columns and 2000 rows.I am wanting to add a column on the left most 
row.I am wanting to label the rows g1 to g2000 I have the code of 
(g,c(1:nrow(dat)),sep=) for the right side of the assignment but do not 
know what function to use for the left side of the equation.I also have a 
similiar question as to how to select a particular portion of the table and to 
plot this. For example to select column 1 and 3 and to take the data from the 
first twenty rows from those columns and put this data onto a plot which I have 
allready coded.Lastly I would like to take all the points in a column (2000) 
and put them into a scatter plot.What is the command or function I would use to 
do this?
Thank You
Paul


  
[[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] splitting data frame based on a criteria

2008-06-03 Thread Ingmar Visser

?by may be helpful here
eg if dat is your data.frame and yf is a factor (created using ifelse)
use by(dat,yf,mean) to compute the means for each level of yf
hth, Ingmar

On Jun 3, 2008, at 8:37 PM, Marvin Lists wrote:


Hi,
I have a data frame that I want to split into two based on the  
values of a

variable in it.

The variable Y has numeric values ranging between 0 through 70. I  
want to

plot the frequencies of another variable X in two different cases:
- When Y = 0 and
- When Y  0

How does one go about doing this?

In general, I want to do several analyses with this data frame that  
are a
variation of the above situation, i.e. they require splitting the  
data into
different age, gender etc. and then calculating separate means,  
correlations
and so on for the different groups into which the data frame would  
split.


I am struggling with the correct syntax for achieving this.

Reading through the documentation suggests that tapply and split  
may be the
functions to use for my purposes but the examples in the  
documentations

didn't help me understand how I could achieve this.

I would appreciate any suggestions and help.

Thanks,
Marvin

[[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] robust mlm in R?

2008-06-03 Thread John Fox
Dear Michael,

I don't think that anyone else has suggested a fix, so here's one:

 snip ---

# Mahalanobis Dsq for a matrix of variables 
dsq - function(x, Sigma) {
   if (missing(Sigma)) Sigma - cov(x, use=complete.obs)
   dev - scale(x, scale=FALSE)
# DSQ - dev %*% solve(Sigma) %*% t(dev )
   DSQ - apply(dev * (dev %*% solve(Sigma)), 1, sum)
   return(DSQ)
}

# robust mlm via multivariate trimming a la Gnanadesikan, Kettering  Wilks 
rmlm.GKW - function(formula, weights, data, iter=3, pvalue=.01, ...) {
   if (missing(data)) data - model.frame(formula) 
   if (missing(weights)) weights - rep(1, nrow(data)) 
   last.weights - weights
   for (i in 1:iter) {
 data$weights - weights
 mod - lm(formula=formula, data=data, weights=weights, ...)
 res - residuals(mod)
 coef - mod$coefficients
 print (coef)
 p - ncol(res)
 DSQ - dsq(res)
 prob - pchisq(DSQ, p, lower.tail=FALSE)
 weights - ifelse( probpvalue, 0, weights)
 nzero - which(weights==0)
 print (nzero)
 if (isTRUE(all.equal(weights, last.weights))) { break }
   }
   mod
}

 snip ---

There were a scoping problem in the call to lm() and some other errors as
well. 

I think that this revised function does what you want, but I'd also probably
program it differently, handling the standard model arguments in the
function and calling lm.wfit() for the computations.

I hope this helps,
 John

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

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On
 Behalf Of Michael Friendly
 Sent: June-02-08 9:51 AM
 To: [EMAIL PROTECTED]
 Subject: Re: [R] robust mlm in R?
 
 I had no on-list replies, so I cobbled up a function for the simplest
 method I could think of -- iterative multivariate trimming, following
 Gnanadesikan, Kettering  Wilks, assigning 0 weights to observations
 based on the Mahalanobis D^2 of residuals.
 
 But I'm getting an error I don't understand, and neither traceback()
 nor browser() gives me any insight.  Can anyone tell me what is wrong
 with the lm() call in rmlm.GKW below?
 
   iris.rmod - rmlm.GKW(cbind(Sepal.Length, Sepal.Width, Petal.Length,
 Petal.Width)~Species, data=iris)
 Error in model.frame.default(formula = formula, data = data, subset =
 subset,  :
invalid type (closure) for variable '(weights)'
  
 
 Here are the functions:
 
 # Mahalanobis Dsq for a matrix of variables
 dsq - function(x, Sigma) {
if (missing(Sigma)) Sigma - cov(x, use=complete.obs)
dev - scale(x, scale=FALSE)
 # DSQ - dev %*% solve(Sigma) %*% t(dev )
DSQ - apply(dev * (dev %*% solve(Sigma)), 1, sum)
return(DSQ)
 }
 
 # robust mlm via multivariate trimming a la Gnanadesikan, Kettering 
Wilks
 rmlm.GKW - function(formula, data, subset, weights=NULL, iter=3,
 pvalue=.01) {
if (missing(weights) | is.null(weights)) { weights - rep(1,
 nrow(data)) }
last.weights - weights
for (i in 1:iter) {
  mod - lm(formula=formula, data=data, subset=subset, weights=weights)
  res - residuals(mod)
  coef - mod$coefficients
  print (coef)
  p - ncol(res)
  DSQ - dsq(res)
  prob - pchisq(DSQ, p, lower.tail=FALSE)
  weights - ifelse( probpvalue, 0, weights)
  nzero - which(weights=0)
  print (nzero)
  if (all.equal(weights, last.weights)) { break }
}
 }
 
 Michael Friendly wrote:
  I'm looking for something in R to fit a multivariate linear model
  robustly, using
  an M-estimator or any of the myriad of other robust methods for linear
  models
  implemented in robustbase or methods based on MCD or MVE covariance
  estimation (package rrcov).
 
  E.g., one can fit an mlm for the iris data as:
  iris.mod - lm(cbind(Sepal.Length, Sepal.Width, Petal.Length,
  Petal.Width) ~ Species, data=iris)
 
  What I'd like is something like rlm() in MASS, but handling an mlm,
e.g.,
  iris.mod - rmlm(cbind(Sepal.Length, Sepal.Width, Petal.Length,
  Petal.Width) ~ Species, data=iris)
  and returning a vector of observation weights in its result.
 
  There's a burgeoning literature on this topic, but I haven't yet found
  computational methods.
  Any pointers or suggestions would be appreciated.
 
  -Michael
 
 
 
 
 --
 Michael Friendly Email: friendly AT yorku DOT ca
 Professor, Psychology Dept.
 York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
 4700 Keele Streethttp://www.math.yorku.ca/SCS/friendly.html
 Toronto, ONT  M3J 1P3 CANADA
 
 __
 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 

Re: [R] matlab eigs function in R

2008-06-03 Thread kayteck_master

Dear Thomas

Yes, you're right. But I'm looking for this not only for computational cost
reasons. 
eigen function from R has identical behavior to matlab function eig, but not
to eigs.
Even in matlab you can check that those function are not giving identical
results.
Here you have a short example :
Suppose we have given a matrix M
M =

1.2607   -3.55752.2968 0 0 0
   -3.5575   10.1429   -6.5855 0 0 0
2.2968   -6.58554.2887 0 0 0
 0 0 02.6359   -4.84892.2130
 0 0 0   -4.84898.9217   -4.0728
 0 0 02.2130   -4.07281.8598

For eig (R's eigen)we have:
[V,eiggg]=eig(M);
V =

0.5774 0 0   -0.7663 00.2820
0.5774 0 00.1389 0   -0.8046
0.5774 0 00.6273 00.5226
 00.5774   -0.6857 00.4432 0
 00.5774   -0.0410 0   -0.8155 0
 00.57740.7267 00.3723 0


eiggg =

   -0. 0 0 0 0 0
 0   -0. 0 0 0 0
 0 00.0011 0 0 0
 0 0 00.0252 0 0
 0 0 0 0   13.4163 0
 0 0 0 0 0   15.6671

And for matlab's eigs we have:
[Y,eigenvals] = eigs(M,4,0,options) ;
Y =

   -0.8147   -0.0106   -0.   -0.5774
0.3802   -0.0143   -0.   -0.5774
0.43440.02490.   -0.5774
   -0.03320.6871   -0.57740.
0.04300.0379   -0.57740.
   -0.0098   -0.7250   -0.57740.


eigenvals =

0.0331 0 0 0
 00.0011 0 0
 0 00. 0
 0 0 0   -0.

As you can see, columns of chosen eigenvectors are different. I'm looking
for function similar to eigs in R. I'll try with svd, which you have
mentioned. Thank you for that idea, maybe it will be what i'm looking for.

Kayteck
-- 
View this message in context: 
http://www.nabble.com/matlab-eigs-function-in-R-tp17619641p17629655.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] adding column and pulling data from table

2008-06-03 Thread Peter Alspach
Paul

It is not entirely clear to me what you want to do.  However, if you are
wanting to add row names then try

row.names(dat) - paste('g', 1:nrow(dat), sep='')

First twenty rows of columns 1:3 are obtained by

dat[1:20,1:3]

Regarding putting all the points in a column onto a scatterplot.  One
usually has two variates for a scatterplot.  Thus to make a scatter plot
of column 2 against column 1

plot(dat[,1], dat[,2])

Incidentally, subsetting is covered in the introductory manual and some
online texts.

HTH ..

Peter Alspach


 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Paul Adams
 Sent: Wednesday, 4 June 2008 7:08 a.m.
 To: r-help@r-project.org
 Subject: [R] adding column and pulling data from table
 
 Hello to everyone,
 I have a general question about how to add a column to a 
 table.I have a table that has 62 columns and 2000 rows.I am 
 wanting to add a column on the left most row.I am wanting to 
 label the rows g1 to g2000 I have the code of 
 (g,c(1:nrow(dat)),sep=) for the right side of the 
 assignment but do not know what function to use for the left 
 side of the equation.I also have a similiar question as to 
 how to select a particular portion of the table and to plot 
 this. For example to select column 1 and 3 and to take the 
 data from the first twenty rows from those columns and put 
 this data onto a plot which I have allready coded.Lastly I 
 would like to take all the points in a column (2000) and put 
 them into a scatter plot.What is the command or function I 
 would use to do this?
 Thank You
 Paul
 
 
   
   [[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.
 

The contents of this e-mail are privileged and/or confidential to the named
 recipient and are not to be used by any other person and/or organisation.
 If you have received this e-mail in error, please notify the sender and delete
 all material pertaining to this e-mail.

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


[R] How to solve a non-linear system of equations using R

2008-06-03 Thread Jorge Ivan Velez
Dear R-list members,

I've had a hard time trying to solve a non-linear system (nls) of equations
which structure for the equation i, i=1,...,4, is as follows:


f_i(d_1,d_2,d_3,d_4)-k_i(l,m,s) = 0(1)


In the expression above, both f_i and k_i are known functions and l, m and s
are known constants. I would like to estimate the vector d=(d_1,d_2,d_3,d_4)
which is solution of (1). Functions in R to estimate f_i-k_i are at the end
of this message.

Any help/suggestions/comments would be greatly appreciated.

Thanks in advance,

Jorge


# --
# Constants
# --

l=1
m=0.4795
s=0.4795

# --
# Functions to estimate f_i-k_i
# --

f1=function(d){
d1=d[1]
d2=d[2]
d3=d[3]
d4=d[4]
res=2*d1+2*sqrt(2)*d1*d2+2*sqrt(3)*d2*d3+4*d3*d4-l*m*(1+d1^2+d2^2+d3^2+d4^2)
res
}

f2=function(d){
d1=d[1]
d2=d[2]
d3=d[3]
d4=d[4]
res=2*sqrt(2)*d2+2*d1^2+2*sqrt(6)*d1*d3+4*d2^2+4*sqrt(3)*d2*d4+6*d3^2+8*d4^2-l*(m^2+m^3*s^(-1))*(1+d1^2+d2^2+d3^2+d4^2)
res
}

f3=function(d){
d1=d[1]
d2=d[2]
d3=d[3]
d4=d[4]
res=6*d1+12*sqrt(2)*d1*d2+18*sqrt(3)*d2*d3+48*d3*d4+2*sqrt(6)*d3+4*sqrt(6)*d1*d4-l*(m^3+3*m^4*s^(-1)+3*m^6*s^(-2))*(1+d1^2+d2^2+d3^2+d4^2)
res
}


f4=function(d){
d1=d[1]
d2=d[2]
d3=d[3]
d4=d[4]
res=12*sqrt(2)*d2+12*d1^2+36*d2^2+72*d3^2+120*d4^2+20*sqrt(6)*d1*d3+56*sqrt(3)*d2*d4+4*sqrt(6)*d4-l*((m^4+6*m^6*s^(-1)+15*m^6*s^(-2)+15*m^7*s^(-3))-3*l^(2)*(m^2+m^3*s^(-1))^2)*(1+d1^2+d2^2+d3^2+d4^2)
res
}

[[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 solve a non-linear system of equations using R

2008-06-03 Thread ctu

Hi Jorge,

Have you tried to use systemfit package. In this package, this is a  
function call  nlsystemfit . This might help.


Chunhao



Quoting Jorge Ivan Velez [EMAIL PROTECTED]:


Dear R-list members,

I've had a hard time trying to solve a non-linear system (nls) of equations
which structure for the equation i, i=1,...,4, is as follows:


f_i(d_1,d_2,d_3,d_4)-k_i(l,m,s) = 0(1)


In the expression above, both f_i and k_i are known functions and l, m and s
are known constants. I would like to estimate the vector d=(d_1,d_2,d_3,d_4)
which is solution of (1). Functions in R to estimate f_i-k_i are at the end
of this message.

Any help/suggestions/comments would be greatly appreciated.

Thanks in advance,

Jorge


# --
# Constants
# --

l=1
m=0.4795
s=0.4795

# --
# Functions to estimate f_i-k_i
# --

f1=function(d){
d1=d[1]
d2=d[2]
d3=d[3]
d4=d[4]
res=2*d1+2*sqrt(2)*d1*d2+2*sqrt(3)*d2*d3+4*d3*d4-l*m*(1+d1^2+d2^2+d3^2+d4^2)
res
}

f2=function(d){
d1=d[1]
d2=d[2]
d3=d[3]
d4=d[4]
res=2*sqrt(2)*d2+2*d1^2+2*sqrt(6)*d1*d3+4*d2^2+4*sqrt(3)*d2*d4+6*d3^2+8*d4^2-l*(m^2+m^3*s^(-1))*(1+d1^2+d2^2+d3^2+d4^2)
res
}

f3=function(d){
d1=d[1]
d2=d[2]
d3=d[3]
d4=d[4]
res=6*d1+12*sqrt(2)*d1*d2+18*sqrt(3)*d2*d3+48*d3*d4+2*sqrt(6)*d3+4*sqrt(6)*d1*d4-l*(m^3+3*m^4*s^(-1)+3*m^6*s^(-2))*(1+d1^2+d2^2+d3^2+d4^2)
res
}


f4=function(d){
d1=d[1]
d2=d[2]
d3=d[3]
d4=d[4]
res=12*sqrt(2)*d2+12*d1^2+36*d2^2+72*d3^2+120*d4^2+20*sqrt(6)*d1*d3+56*sqrt(3)*d2*d4+4*sqrt(6)*d4-l*((m^4+6*m^6*s^(-1)+15*m^6*s^(-2)+15*m^7*s^(-3))-3*l^(2)*(m^2+m^3*s^(-1))^2)*(1+d1^2+d2^2+d3^2+d4^2)
res
}

[[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] A question about environments

2008-06-03 Thread David Vavra
I have been using separate environments to partition my data and functions
into logical groups but I have been having an odd (to me) problem.

To load and manipulate the data environments, I wrote a couple of small
functions (see below). The problem seems to be that when I initially try to
load the environment, often no data can be found but if I repeat the
function call, it then works.

It appears that the CreateEnv function sometimes returns a different
environment value than as.environment does. Not always, this is puzzling. I
discovered this by saving the returned value. That environment contains the
data. 

Can someone tell me where I am going wrong? 

Thanks,
DAV

 ---

# return a named environment or, if needed, create and attach it

CreateEnv - 
function(name, clear=FALSE) {
if (name %in% search()) {
env - as.environment(name)
if (clear)
rm(list=ls(name),envir=env)
return(env)
}
env - new.env()
attach(env, name=name)
env
}

LoadEnv -
function (envname, fname=NULL, ret=FALSE) {
if (is.null(fname)) fname - paste(envname,'Rdata',sep='.')
env - CreateEnv(envname)
load(file=fname, envir=env)
if (ret) 
return(env)
}

__
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 function from specific packages

2008-06-03 Thread jiho.han

hello, useRs-

i have a function that i wrote myself, for example, lag(x). however, when 
i load 'zoo' packages and try to lag 'zoo' object, it gave me error. (R try
to 
pass 'zoo' object into my function.)

i typed 'lag.zoo' in R, but it can't find it. how can i access 'lag.zoo'
function?
and in general, how can i deal with such problem as to access functions from
specific packages
-- 
View this message in context: 
http://www.nabble.com/using-function-from-specific-packages-tp17632885p17632885.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] R-2.7.0 make check failure

2008-06-03 Thread Gregory Ruchti

Hello,

I am fairly new to using R and am trying to install it on my Linux  
machine, running Scientific Linux.  I get through running 'configure'  
and 'make' OK, but when I run 'make check', I get the following error:


 make check
make[1]: Entering directory `/home/gruchti/Programs/R-2.7.0/tests'
make[2]: Entering directory `/home/gruchti/Programs/R-2.7.0/tests'
make[3]: Entering directory `/home/gruchti/Programs/R-2.7.0/tests/ 
Examples'
make[4]: Entering directory `/home/gruchti/Programs/R-2.7.0/tests/ 
Examples'

make[4]: `Makedeps' is up to date.
make[4]: Leaving directory `/home/gruchti/Programs/R-2.7.0/tests/ 
Examples'
make[4]: Entering directory `/home/gruchti/Programs/R-2.7.0/tests/ 
Examples'
running code in 'base-Ex.R' .../bin/sh: line 1:  4233 Segmentation  
fault  ../../bin/R --vanilla base-Ex.R base-Ex.Rout 21

make[4]: *** [base-Ex.Rout] Error 1
make[4]: Leaving directory `/home/gruchti/Programs/R-2.7.0/tests/ 
Examples'

make[3]: *** [test-Examples-Base] Error 2
make[3]: Leaving directory `/home/gruchti/Programs/R-2.7.0/tests/ 
Examples'

make[2]: *** [test-Examples] Error 2
make[2]: Leaving directory `/home/gruchti/Programs/R-2.7.0/tests'
make[1]: *** [test-all-basics] Error 1
make[1]: Leaving directory `/home/gruchti/Programs/R-2.7.0/tests'
make: *** [check] Error 2

I took a look at the 'base-Ex.Rout.fail' file to see where the problem  
occured and get the following at the end of the file:


 ## R code version of choose()  [simplistic; warning for k  0]:
 mychoose - function(r,k)
+ ifelse(k = 0, (k==0),
+sapply(k, function(k) prod(r:(r-k+1))) / factorial(k))
 k - -1:6
 cbind(k=k, choose(1/2, k), mychoose(1/2, k))

 *** caught segfault ***
address 0x200, cause 'memory not mapped'

Traceback:
 1: doWithOneRestart(return(expr), restart)
 2: withOneRestart(expr, restarts[[1]])
 3: withRestarts({.Internal(.signalCondition(simpleWarning(msg,  
call), msg, call)).Internal(.dfltWarn(msg, call))},  
muffleWarning = function() NULL)

 4: .signalSimpleWarning(NaNs produced, quote(gamma(x + 1)))
 5: factorial(k)
 6: ifelse(k = 0, (k == 0), sapply(k, function(k) prod(r:(r - k  
+ 1)))/factorial(k))

 7: mychoose(1/2, k)
 8: cbind(k = k, choose(1/2, k), mychoose(1/2, k))
aborting ...


I really am not sure how to interpret this, or how to fix it.  Any  
help would be greatly appreciated!


Regards,
Greg

--
Gregory Ruchti
Bloomberg Center for Physics and Astronomy
Johns Hopkins 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] JGR / linux

2008-06-03 Thread g-h-d



Dirk Eddelbuettel wrote:
 
 
 On 3 June 2008 at 08:42, g-h-d wrote:
 | I basically followed the steps in http://lib.stat.cmu.edu/R/CRAN/, and
 those
 | below for JGR and it worked.
 | 
 | ...but there are problems with help files e.g. ?matrix generates the
 | following message:
 | 
 | /tmp/RtmpvxsnQa/.R/doc/html/packages.html (No such file or directory)
 
 I think you can ignore that. It's just a warning.  The rest of your steps
 were very sound.
 
 In particular ...
 
 | g-h-d wrote:
 |  
 |  Hi all,
 |  
 |  i'm trying to install JGR on linux (see bottom), but it runs into
 errors.
 |  The bottom of the sequence below shows JavaJD could not be found
 |  
 |  Any suggestion, please?
 |  
 |  
 |  $ sudo apt-get install sun-java6-jdk
 |  
 |  $ sudo update-alternatives --config java
 |  
 |  There are 5 alternatives which provide `java'.
 |  
 |  Selection Alternative
 |  ---
 |  1 /usr/lib/jvm/java-1.5.0-sun/jre/bin/java
 |  2 /usr/bin/gij-4.1
 |  3 /usr/bin/gij-4.2
 |  4 /usr/lib/jvm/java-gcj/jre/bin/java
 |  + 5 /usr/lib/jvm/java-7-icedtea/jre/bin/java
 
 ... a very good idea to realign what command will default to being 'java'
 ...
  
 |  $sudo R CMD javareconf
 |  Java interpreter : /usr/bin/java
 |  Java version : 1.6.0_03
 |  Java home path : /usr/lib/jvm/java-6-sun-1.6.0.03/jre
 |  Java compiler : /usr/bin/javac
 |  Java headers gen.: /usr/bin/javah
 |  Java archive tool: /usr/bin/jar
 
 ... but given that javareconf also looks after javac and javah, I
 recommend
 doing the same update-alternatives call for 'javah' and 'javac'.
 
 I just re-did that on a Ubuntu 8.04, 32bit, machine and it re-built rJava,
 JGR, JavaGD, ... without a hitch.
 
 Dirk
 
 
 |  Java library path:
 | 
 $(JAVA_HOME)/lib/amd64/server:$(JAVA_HOME)/lib/amd64:$(JAVA_HOME)/../lib/amd64::/usr/java/packages/lib/amd64:/lib:/usr/lib
 |  JNI linker flags : -L$(JAVA_HOME)/lib/amd64/server
 |  -L$(JAVA_HOME)/lib/amd64 -L$(JAVA_HOME)/../lib/amd64 -L
 |  -L/usr/java/packages/lib/amd64 -L/lib -L/usr/lib -ljvm
 |  JNI cpp flags : -I/usr/lib/jvm/java-6-sun-1.6.0.03/jre/../include
 |  -I/usr/lib/jvm/java-6-sun-1.6.0.03/jre/../include/linux
 |  
 |  Updating Java configuration in /etc/R
 |  Done.
 |  
 |  $ sudo R
 |  
 |  R version 2.5.1 (2007-06-27)
 |  Copyright (C) 2007 The R Foundation for Statistical Computing
 |  ISBN 3-900051-07-0
 |  
 |  R is free software and comes with ABSOLUTELY NO WARRANTY.
 |  You are welcome to redistribute it under certain conditions.
 |  Type 'license()' or 'licence()' for distribution details.
 |  
 |  Natural language support but running in an English locale
 |  
 |  R is a collaborative project with many contributors.
 |  Type 'contributors()' for more information and
 |  'citation()' on how to cite R or R packages in publications.
 |  
 |  Type 'demo()' for some demos, 'help()' for on-line help, or
 |  'help.start()' for an HTML browser interface to help.
 |  Type 'q()' to quit R.
 |  
 |  install.packages('JGR', dep=TRUE)
 |  Warning in install.packages(JGR, dep = TRUE) :
 |  argument 'lib' is missing: using '/usr/local/lib/R/site-library'
 |  --- Please select a CRAN mirror for use in this session ---
 |  Loading Tcl/Tk interface ... done
 |  also installing the dependency  JavaGD 
 |  
 |  trying URL
 |  'http://lib.stat.cmu.edu/R/CRAN/src/contrib/JavaGD_0.5-1.tar.gz'
 |  Content type 'application/x-gzip' length 86505 bytes
 |  opened URL
 |  ==
 |  downloaded 84Kb
 |  
 |  trying URL
 'http://lib.stat.cmu.edu/R/CRAN/src/contrib/JGR_1.5-18.tar.gz'
 |  Content type 'application/x-gzip' length 426244 bytes
 |  opened URL
 |  ==
 |  downloaded 416Kb
 |  
 |  * Installing *source* package 'JavaGD' ...
 |  checking for gcc... gcc-4.2 -std=gnu99
 |  checking for C compiler default output file name... a.out
 |  checking whether the C compiler works... yes
 |  checking whether we are cross compiling... no
 |  checking for suffix of executables...
 |  checking for suffix of object files... o
 |  checking whether we are using the GNU C compiler... yes
 |  checking whether gcc-4.2 -std=gnu99 accepts -g... yes
 |  checking for gcc-4.2 -std=gnu99 option to accept ISO C89... none
 needed
 |  checking how to run the C preprocessor... gcc-4.2 -std=gnu99 -E
 |  checking for grep that handles long lines and -e... /bin/grep
 |  checking for egrep... /bin/grep -E
 |  checking for ANSI C header files... yes
 |  checking for sys/wait.h that is POSIX.1 compatible... yes
 |  checking for sys/types.h... yes
 |  checking for sys/stat.h... yes
 |  checking for stdlib.h... yes
 |  checking for string.h... yes
 |  checking for memory.h... yes
 |  checking for strings.h... yes
 |  checking for inttypes.h... yes
 |  checking for stdint.h... yes
 |  checking for unistd.h... yes
 |  checking for string.h... (cached) yes
 |  checking sys/time.h usability... yes
 |  checking sys/time.h 

[R] Summarizing dummy coefficients in sem package

2008-06-03 Thread Gus Jespersen

Greetings,
I am working in the sem package on a model with 3 exogenous variables (2 
are nominal-categorical), and 4 endogenous, continuous variables.  To 
use sem with the nominal variables, I created dummy variables.  Now, in 
my sem output I have estimates for path coefficients for the 
relationship between each level of the nominal variables and the 
endogenous variables they are associated with.  However, what I am 
interested are the overall path coefficients from each nominal variable 
to the various endogenous variables, not the relationship between each 
level of this and the endogenous variables.  How might I go about 
achieving this?


Here is my model ('sex' and 'trt' are the nominal variables with 2 and 4 
levels, respectively) followed by the relevant output:
  Path  Parameter 
1  sexMale-nect sexnect   
2  sexMale-cono sexcono   
3  sexMale-herb sexherb   
4  sexMale-para sexpara   
5  trtControl-nect  trtContnect   
6  trtControl-cono  trtContcono   
7  trtControl-herb  trtContherb   
8  trtControl-para  trtContpara   
9  trtNoFemale-nect trtNoFemnect  
10 trtNoFemale-cono trtNoFemcono  
11 trtNoFemale-herb trtNoFemherb  
12 trtNoFemale-para trtNoFempara  
13 trtNoMale-nect   trtNoMalenect 
14 trtNoMale-cono   trtNoMalecono 
15 trtNoMale-herb   trtNoMaleherb 
16 trtNoMale-para   trtNoMalepara 
17 area-nectareanect  
18 area-conoareacono  
19 area-herbareaherb  
20 area-paraareapara  
21 nect-para   nect-para   
22 nect-herb   nectherb  
23 nect-cono   nectcono  
24 cono-herb   conoherb  
25 cono-para   conopara  
26 area-area   errorarea 
27 nect-nect   errornect 
28 cono-cono   errorcono 
29 herb-herb   errorherb 
30 para-para   errorpara 
31 trtControl-trtControl   errortrtControl
32 trtNoFemale-trtNoFemale errorNoFemale 
33 trtNoMale-trtNoMale errortrtNoMale
34 sexMale-sexMale errorsexMale  


Parameter Estimates
   EstimateStd Error  z valuePr(|z|) 
sexnect -0.01929179 0.06376330 -0.3025532 7.6223e-01

sexcono -2.66789515 0.36084653 -7.3934344 1.4300e-13
sexherb -0.00743378 0.00566452 -1.3123412 1.8941e-01
sexpara  0.01097552 0.00980425  1.1194652 2.6294e-01
trtContnect  0.21164052 0.08736725  2.4224240 1.5417e-02
trtContcono -0.44791548 0.54528423 -0.8214349 4.1140e-01
trtContherb -0.00038585 0.00756348 -0.0510144 9.5931e-01
trtContpara -0.00015034 0.06098602 -0.0024651 9.9803e-01
trtNoFemnect 0.11658323 0.08786423  1.3268566 1.8456e-01
trtNoFemcono-0.10709039 0.55754523 -0.1920748 8.4768e-01
trtNoFemherb-0.00412156 0.00777418 -0.5301598 5.9600e-01
trtNoFempara 0.00420467 0.03406450  0.1234325 9.0176e-01
trtNoMalenect0.23656338 0.08897775  2.6586801 7.8447e-03
trtNoMalecono0.07633944 0.60103928  0.1270124 8.9893e-01
trtNoMaleherb   -0.00156381 0.00788036 -0.1984436 8.4270e-01
trtNoMalepara0.00910566 0.03304680  0.2755383 7.8290e-01
areanect 0.01097847 0.02250164  0.4878965 6.2562e-01
areacono 0.37431397 0.12725982  2.9413367 3.2680e-03
areaherb-0.00169721 0.00200841 -0.8450508 3.9808e-01
areapara 0.00044190 0.00365491  0.1209054 9.0377e-01
nect-para  0.00399596 0.00425721  0.9386334 3.4792e-01
nectherb-0.00028131 0.00245373 -0.1146438 9.0873e-01
nectcono 0.52509632 0.15739193  3.3362340 8.4922e-04
conoherb 0.01380912 0.01401081  0.9856041 3.2433e-01
conopara 0.01752004 0.02413323  0.7259716 4.6786e-01
errorarea1.90255983 0.08980542 21.1853566 0.e+00
errornect0.82560204 0.03897074 21.1851759 0.e+00
errorcono   26.60775814 1.25597309 21.1849746 0.e+00
errorherb0.00661525 0.00031226 21.1851940 0.e+00
errorpara0.01967170 0.00092856 21.1852827 0.e+00
errortrtControl  0.19005279 0.00897095 21.1853556 0.e+00
errorNoFemale0.18331925 0.00865314 21.1852797 0.e+00
errortrtNoMale   0.19059782 0.00899668 21.1853547 0.e+00
errorsexMale 0.24736468 0.01167625 21.1852846 0.e+00

Thanks,
Gus

__
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 function from specific packages

2008-06-03 Thread Gabor Grothendieck
zoo has a namespace and lag.zoo is not exported so zoo:::lag.zoo
is how to access it directly.

See

help(:::)



On Tue, Jun 3, 2008 at 4:31 PM, jiho.han [EMAIL PROTECTED] wrote:

 hello, useRs-

 i have a function that i wrote myself, for example, lag(x). however, when
 i load 'zoo' packages and try to lag 'zoo' object, it gave me error. (R try
 to
 pass 'zoo' object into my function.)

 i typed 'lag.zoo' in R, but it can't find it. how can i access 'lag.zoo'
 function?
 and in general, how can i deal with such problem as to access functions from
 specific packages
 --
 View this message in context: 
 http://www.nabble.com/using-function-from-specific-packages-tp17632885p17632885.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] probleme with R CMD check

2008-06-03 Thread cgenolin
I find the problem: the name of my base directory (the one that contain 
R, man and test) was not the same than the name of the package...


I thaught this was allowed, I guess I was wrong.

Christophe


c == cgenolin  [EMAIL PROTECTED]
on Tue, 03 Jun 2008 09:55:15 +0200 writes:


provide commented, minimal, self-contained, reproducible code.
Please do  -- both --

   c Sorry... Usualy, I do...

   c --- 8 
   c userA - function(x)x+1
   c privateA  - function(x)x+2
   c .userB - function(x)x+10
   c .privateB  - function(x)x+20
   c userC- function(x)userA(privateA(x))
   c privateC - function(x).userB(.privateB(x))
   c userD- function(x)userA(.userB(x))
   c privateD - function(x)privateA(.privateB(x))
   c --- 8 

If I execute these in an empty R session, and
do
package.skeleton(EXpkg)
system(R CMD check EXpkg)

I can NOT see the problem you describe below.
Probably you'd rather should upload the
   pkg.tar.gz
to a public place, to make your problem reproducible.

Martin

c == cgenolin  [EMAIL PROTECTED]
on Tue, 03 Jun 2008 00:32:13 +0200 writes:
   
   c Hi the list.
   c I got a probleme with R CMD check. I run a package.skeleton on a very
   c simple code (four toy function, no probleme with the R CMD build). But
   c on the R CMD check packClassique, I get :
   
   c * checking for unstated dependencies in R code ... WARNING
   c Erreur dans .find.package(package, lib.loc) :  aucun package nommé
   c 'packClassique' n'est trouvé
   c Calls: Anonymous - .find.package
   c Excecution hated [French=Exécution arrêtée]
   
   c See the information on DESCRIPTION files in the chapter 'Creating R
   c packages' of the 'Writing R Extensions' manual.
   c * checking S3 generic/method consistency ... WARNING
   c Erreur dans .find.package(package, lib.loc) :  aucun package nommé
   c 'packClassique' n'est trouvé
   c Calls: Anonymous - .find.package
   c Exécution arrêtée
   
   c And so on.
   
   c Any idea on what is wrong ?
   
No.
   
   c Christophe
   
   c __
   c R-help@r-project.org mailing list
   c https://stat.ethz.ch/mailman/listinfo/r-help
   
   c PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
   c and provide commented, minimal, self-contained, reproducible code.
   
Please do  -- both --
   
Martin
   



   c 
   c Ce message a ete envoye par IMP, grace a l'Universite Paris 10 Nanterre





__
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-2.7.0 rJava installation failure on x86_64

2008-06-03 Thread Nathan Coulter
  From: Nathan Coulter
  
  It looks like the command above could use /lib64/libc.so.6, but running R 
 CMD
  javareconf shows that JNI linker flags don't contain any entry similar to
  '-L/lib64':

It turns out that /usr/lib64/libc.so is what is needed.  I was able to install
rJava after adding /usr/lib64 to the JAVA_LIBS and JAVA_LD_LIBRARY_PATH


env JAVA_LIBS='-L/path/to/x86-64/jdk-1.6.0_06/jre/lib/amd64/server 
-L/path/to/x86-64/jdk-1.6.0_06/jre/lib/amd64 
-L/path/to/x86-64/jdk-1.6.0_06/jre/../lib/amd64 -L 
-L/usr/java/packages/lib/amd64 -L/usr/lib64 -L/lib -L/usr/lib -ljvm' 
JAVA_LD_LIBRARY_PATH='/path/to/x86-64/jdk-1.6.0_06/jre/lib/amd64/server:/path/to/x86-64/jdk-1.6.0_06/jre/lib/amd64:/path/to/x86-64/jdk-1.6.0_06/jre/../lib/amd64:/usr/java/packages/lib/amd64:/usr/lib64:/lib:/usr/lib'
 R-2.7.0 CMD javareconf


-- 
Nathan

__
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] probleme with R CMD check

2008-06-03 Thread Martin Maechler
 c == cgenolin  [EMAIL PROTECTED]
 on Wed, 04 Jun 2008 00:30:08 +0200 writes:

c I find the problem: the name of my base directory (the
c one that contain R, man and test) was not the same than
c the name of the package...

Aha!

c I thaught this was allowed, I guess I was wrong.

It has been documented to be allowed; and it has been, but
in some circumstances, R CMD check gave wrong warnings, as you
found.

I had found and fixed this buglet on May 22, both for R-devel
and R-patched (which will become R 2.7.1 ...)

Could you try 'R-patched' and confirm that the problem is
solved?

Regards,
Martin


c Christophe

 c == cgenolin [EMAIL PROTECTED] on Tue, 03
 Jun 2008 09:55:15 +0200 writes:
 
  provide commented, minimal, self-contained,
 reproducible code.   Please do -- both --
 
c Sorry... Usualy, I do...
 
c --- 8  userA - function(x)x+1 privateA -
c function(x)x+2 .userB - function(x)x+10 .privateB -
c function(x)x+20 userC - function(x)userA(privateA(x))
c privateC - function(x).userB(.privateB(x)) userD -
c function(x)userA(.userB(x)) privateD -
c function(x)privateA(.privateB(x)) --- 8 
 
 If I execute these in an empty R session, and do
 package.skeleton(EXpkg) system(R CMD check EXpkg)
 
 I can NOT see the problem you describe below.  Probably
 you'd rather should upload the pkg.tar.gz to a public
 place, to make your problem reproducible.
 
 Martin
 
  c == cgenolin [EMAIL PROTECTED] 
 on Tue, 03 Jun 2008 00:32:13 +0200 writes:
 
c Hi the list.  I got a probleme with R CMD check. I run a
c package.skeleton on a very simple code (four toy
c function, no probleme with the R CMD build). But on the R
c CMD check packClassique, I get :
 
c * checking for unstated dependencies in R code
c ... WARNING Erreur dans .find.package(package, lib.loc) :
c aucun package nommé 'packClassique' n'est trouvé Calls:
c Anonymous - .find.package Excecution hated
c [French=Exécution arrêtée]
 
c See the information on DESCRIPTION files in the chapter
c 'Creating R packages' of the 'Writing R Extensions'
c manual.  * checking S3 generic/method consistency
c ... WARNING Erreur dans .find.package(package, lib.loc) :
c aucun package nommé 'packClassique' n'est trouvé Calls:
c Anonymous - .find.package Exécution arrêtée
 
c And so on.
 
c Any idea on what is wrong ?
 
  No.
 
c Christophe
 
c __
c R-help@r-project.org mailing list
c https://stat.ethz.ch/mailman/listinfo/r-help
 
c PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
c and provide commented, minimal, self-contained,
c reproducible code.
 
  Please do -- both --
 
  Martin
 
 
 
 
c 
c Ce message a ete envoye par IMP, grace a l'Universite
c Paris 10 Nanterre
 
 
 

__
c R-help@r-project.org mailing list
c https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do
c read the posting guide
c http://www.R-project.org/posting-guide.html and provide
c 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] merging two data sets with no column header

2008-06-03 Thread kayj

Thanks for your reply. 

In your last step If  I create a duplicate ( two similar records )
# create a duplicate 
vv[8,1] - 7
vv[8,2]-'g'

and then I merge vv with vv2 ,both duplicates are merged. Is there a way to
tell R to merge only the unique records.

Thanks and appreciate your help.


-- 
View this message in context: 
http://www.nabble.com/merging-two-data-sets-with-no-column-header-tp17613296p17634368.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] IBM-AIX 5.2 (GCC 4.2.4 installed) - Error while executing 'make'

2008-06-03 Thread Senthilkumaran

Hi,

The following error occurs while executing 'make' after the successful
configuration (./configure) on IBM-AIX 5.2 (GCC 4.2.4 installed):


gcc -std=gnu99 -I../../src/extra/zlib -I../../src/extra/bzip2
-I../../src/extra/pcre   -I. -I../../src/include -I../../src/include
-I/usr/local/include -DHAVE_CONFIG_H  -mno-fp-in-toc  -g -O2 -c vfonts.c -o
vfonts.o
gfortran   -g -O2 -c xxxpr.f -o xxxpr.o
gcc -std=gnu99 -I../../src/extra/zlib -I../../src/extra/bzip2
-I../../src/extra/pcre   -I. -I../../src/include -I../../src/include
-I/usr/local/include -DHAVE_CONFIG_H  -mno-fp-in-toc  -g -O2 -c mkdtemp.c -o
mkdtemp.o
ar cr libR.a CConverters.o CommandLineArgs.o Rdynload.o Renviron.o
RNG.o apply.o apse.o arithmetic.o array.o attrib.o base.o bind.o builtin.o
character.o coerce.o colors.o complex.o connections.o context.o cov.o cum.o
dcf.o datetime.o debug.o deparse.o deriv.o devices.o dotcode.o dounzip.o
dstruct.o duplicate.o engine.o envir.o errors.o eval.o format.o fourier.o
gevents.o gram.o gram-ex.o graphics.o identical.o inlined.o internet.o
iosupport.o lapack.o list.o localecharset.o logic.o main.o mapply.o match.o
memory.o model.o names.o objects.o optim.o optimize.o options.o par.o
paste.o pcre.o platform.o plot.o plot3d.o plotmath.o print.o printarray.o
printvector.o printutils.o qsort.o random.o regex.o registration.o relop.o
rlocale.o saveload.o scan.o seq.o serialize.o size.o sort.o source.o split.o
sprintf.o startup.o subassign.o subscript.o subset.o summary.o sysutils.o
unique.o util.o version.o vfonts.o xxxpr.o  mkdtemp.o  libs/*o
ranlib libR.a
gcc -std=gnu99 -Wl,-brtl -Wl,-bexpall -lc -Wl,-bE:../../etc/R.exp
-L/usr/local/lib -o R.bin Rmain.o libR.a  -lgfortran -lm
/opt/pware/lib/gcc/powerpc-ibm-aix5.2.0.0/4.2.4/libgcc.a -lg  -lintl  -ldl
-lm
ld: 0711-317 ERROR: Undefined symbol: .dcopy
ld: 0711-317 ERROR: Undefined symbol: .dtrsm
ld: 0711-317 ERROR: Undefined symbol: .ddot
ld: 0711-317 ERROR: Undefined symbol: .dnrm2
ld: 0711-317 ERROR: Undefined symbol: .dtrsl
ld: 0711-317 ERROR: Undefined symbol: .dscal
ld: 0711-317 ERROR: Undefined symbol: .dpofa
ld: 0711-317 ERROR: Undefined symbol: .daxpy
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more
information.
collect2: ld returned 8 exit status
make: 1254-004 The error code from the last command is 1.

Stop.
make: 1254-004 The error code from the last command is 2.

Stop.
make: 1254-004 The error code from the last command is 1.

Stop.
make: 1254-004 The error code from the last command is 1.

Stop.

Can anyone help to resolve this issue? Or at least help me to define the
linker options '-bloadmap' or '-bnoquiet' while executing 'make'?

Thanks,
Senthil
414-931-2436.
-- 
View this message in context: 
http://www.nabble.com/IBM-AIX-5.2-%28GCC-4.2.4-installed%29---Error-while-executing-%27make%27-tp17634911p17634911.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] JGR / linux

2008-06-03 Thread g-h-d



Dirk Eddelbuettel wrote:
 
 
 On 3 June 2008 at 13:44, g-h-d wrote:
 |  |  $ sudo apt-get install sun-java6-jdk
 |  |  
 |  |  $ sudo update-alternatives --config java
 |  |  
 |  |  There are 5 alternatives which provide `java'.
 |  |  
 |  |  Selection Alternative
 |  |  ---
 |  |  1 /usr/lib/jvm/java-1.5.0-sun/jre/bin/java
 |  |  2 /usr/bin/gij-4.1
 |  |  3 /usr/bin/gij-4.2
 |  |  4 /usr/lib/jvm/java-gcj/jre/bin/java
 |  |  + 5 /usr/lib/jvm/java-7-icedtea/jre/bin/java
 |
 | About the message resulting from calling say ?matrix: the message may be
 a
 | warning, but ?matrix just doesnt work, I can't use it (or any other help
 | command).
 
 I see. That appears to be the same at my end. You may want to bring that
 to
 the attention of the rosuda.org folks.
  
 | About doing the same update-alternatives call for 'javah' and 'javac'.
 I
 | actually don't know what you mean exactly. Could you please clarify?
 Thanks.
 
 See what I left from your initial post -- besides running 
 
 $ sudo update-alternatives --config java
 
 it may be prudent to also redirect via
 
 $ sudo update-alternatives --config javac
 $ sudo update-alternatives --config javah
 
 as 'R CMD javareconf' checkes for all three.  But as you got JGR built,
 this
 may not matter. I always found that other java compilers from gij, gcj,
 ecj,
 ... would get in the way.
 
 Hope this helps, Dirk
 
 -- 
 Three out of two people have difficulties with fractions.
 
 __
 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.
 
 

Thanks for clarifying.

-- 
View this message in context: 
http://www.nabble.com/JGR---linux-tp17622071p17635209.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] splitting data frame based on a criteria

2008-06-03 Thread Moshe Olshansky
Also check ?aggregate


--- On Wed, 4/6/08, Ingmar Visser [EMAIL PROTECTED] wrote:

 From: Ingmar Visser [EMAIL PROTECTED]
 Subject: Re: [R] splitting data frame based on a criteria
 To: Marvin Lists [EMAIL PROTECTED]
 Cc: r-help@r-project.org
 Received: Wednesday, 4 June, 2008, 5:11 AM
 ?by may be helpful here
 eg if dat is your data.frame and yf is a factor (created
 using ifelse)
 use by(dat,yf,mean) to compute the means for each level of
 yf
 hth, Ingmar
 
 On Jun 3, 2008, at 8:37 PM, Marvin Lists wrote:
 
  Hi,
  I have a data frame that I want to split into two
 based on the  
  values of a
  variable in it.
 
  The variable Y has numeric values ranging between 0
 through 70. I  
  want to
  plot the frequencies of another variable X in two
 different cases:
  - When Y = 0 and
  - When Y  0
 
  How does one go about doing this?
 
  In general, I want to do several analyses with this
 data frame that  
  are a
  variation of the above situation, i.e. they require
 splitting the  
  data into
  different age, gender etc. and then calculating
 separate means,  
  correlations
  and so on for the different groups into which the data
 frame would  
  split.
 
  I am struggling with the correct syntax for achieving
 this.
 
  Reading through the documentation suggests that tapply
 and split  
  may be the
  functions to use for my purposes but the examples in
 the  
  documentations
  didn't help me understand how I could achieve
 this.
 
  I would appreciate any suggestions and help.
 
  Thanks,
  Marvin
 
  [[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-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] Stacked barplot of timeseries data

2008-06-03 Thread Demetri S. Mouratis

Hi,

I'm trying to plot time-series data where each sample breaks down the  
percentage of CPU time spent in each of four states (usr, nice, sys,  
idle)



19:08:15  %usr  %nice   %sys   %idle
19:08:165  0 10 86
19:08:17   17  0 14 69
19:08:185  0  8 87
19:08:19   10  0 10 81
19:08:203  0  7 90
19:08:214  0  8 88
[on and on for many samples]

The plot I'm aiming for would stack the first three states in a  
colored barplot, so you get a visual sense of how busy the system is  
over the course of the day, and which state the CPU is spending its  
time in.  (I've done this as area charts as well).


barplot() looked promising, but it wants to stack the columns instead  
of the rows.


Anybody have a good solution for this?

Thanks!
...Demetri

__
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] Stacked barplot of timeseries data

2008-06-03 Thread Achim Zeileis

On Tue, 3 Jun 2008, Demetri S. Mouratis wrote:


Hi,

I'm trying to plot time-series data where each sample breaks down the 
percentage of CPU time spent in each of four states (usr, nice, sys, idle)



19:08:15  %usr  %nice   %sys   %idle
19:08:165  0 10 86
19:08:17   17  0 14 69
19:08:185  0  8 87
19:08:19   10  0 10 81
19:08:203  0  7 90
19:08:214  0  8 88
[on and on for many samples]

The plot I'm aiming for would stack the first three states in a colored 
barplot, so you get a visual sense of how busy the system is over the course 
of the day, and which state the CPU is spending its time in.  (I've done this 
as area charts as well).


barplot() looked promising, but it wants to stack the columns instead of the 
rows.


Anybody have a good solution for this?


The zoo package provides a barplot() method for zoo series.

Example with some artificial data:

  library(zoo)
  x - matrix(runif(44), ncol = 4)
  colnames(x) - c(%usr, %nice, %sys, %idle)
  z - zoo(x, Sys.time() - c(10:0))
  barplot(z, legend = TRUE)

hth,
Z


Thanks!
...Demetri

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



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


Re: [R] How to solve a non-linear system of equations using R

2008-06-03 Thread Moshe Olshansky
Since k_i(l,m,s) are known constants, you actually have a system of four 
non-linear equations with 4 unknowns.

One possibility is to use optim (check ?optim).

Another one is to use the very recently released package - look at
 
https://stat.ethz.ch/pipermail/r-help/attachments/20080423/da0b7f6c/attachment.pl



--- On Wed, 4/6/08, Jorge Ivan Velez [EMAIL PROTECTED] wrote:

 From: Jorge Ivan Velez [EMAIL PROTECTED]
 Subject: [R] How to solve a non-linear system of equations using R
 To: R mailing list r-help@r-project.org
 Received: Wednesday, 4 June, 2008, 7:09 AM
 Dear R-list members,
 
 I've had a hard time trying to solve a non-linear
 system (nls) of equations
 which structure for the equation i, i=1,...,4, is as
 follows:
 
 
 f_i(d_1,d_2,d_3,d_4)-k_i(l,m,s) = 0(1)
 
 
 In the expression above, both f_i and k_i are known
 functions and l, m and s
 are known constants. I would like to estimate the vector
 d=(d_1,d_2,d_3,d_4)
 which is solution of (1). Functions in R to estimate
 f_i-k_i are at the end
 of this message.
 
 Any help/suggestions/comments would be greatly appreciated.
 
 Thanks in advance,
 
 Jorge
 
 
 # --
 # Constants
 # --
 
 l=1
 m=0.4795
 s=0.4795
 
 # --
 # Functions to estimate f_i-k_i
 # --
 
 f1=function(d){
 d1=d[1]
 d2=d[2]
 d3=d[3]
 d4=d[4]
 res=2*d1+2*sqrt(2)*d1*d2+2*sqrt(3)*d2*d3+4*d3*d4-l*m*(1+d1^2+d2^2+d3^2+d4^2)
 res
 }
 
 f2=function(d){
 d1=d[1]
 d2=d[2]
 d3=d[3]
 d4=d[4]
 res=2*sqrt(2)*d2+2*d1^2+2*sqrt(6)*d1*d3+4*d2^2+4*sqrt(3)*d2*d4+6*d3^2+8*d4^2-l*(m^2+m^3*s^(-1))*(1+d1^2+d2^2+d3^2+d4^2)
 res
 }
 
 f3=function(d){
 d1=d[1]
 d2=d[2]
 d3=d[3]
 d4=d[4]
 res=6*d1+12*sqrt(2)*d1*d2+18*sqrt(3)*d2*d3+48*d3*d4+2*sqrt(6)*d3+4*sqrt(6)*d1*d4-l*(m^3+3*m^4*s^(-1)+3*m^6*s^(-2))*(1+d1^2+d2^2+d3^2+d4^2)
 res
 }
 
 
 f4=function(d){
 d1=d[1]
 d2=d[2]
 d3=d[3]
 d4=d[4]
 res=12*sqrt(2)*d2+12*d1^2+36*d2^2+72*d3^2+120*d4^2+20*sqrt(6)*d1*d3+56*sqrt(3)*d2*d4+4*sqrt(6)*d4-l*((m^4+6*m^6*s^(-1)+15*m^6*s^(-2)+15*m^7*s^(-3))-3*l^(2)*(m^2+m^3*s^(-1))^2)*(1+d1^2+d2^2+d3^2+d4^2)
 res
 }
 
   [[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] 1501-511 Compilation failed for file ch2inv.f - R on AIX 5.2.

2008-06-03 Thread Senthilkumaran

Hi,

Installed GCC 4.2.4 on IBM-AIX 5.2 and configured 'R' successfully. Although
the below error was resolved after installing GCC 4.2.4, the 'make' failed
in another step (related msg posted on June 03).



Senthilkumaran wrote:
 
 Hi,
 Thanks for the response. 
 We do have a IBM XL Fortran Enterprise Edition for AIX, V11.1 coupled
 with IBM XL C/C++ Enterprise Edition for AIX, V9.0 specifically on our
 IBM-AIX 5.2 system for the 'R' software.
 The 'f95' represents Fortran 95 compiler and I presume the 'R' sources can
 be compiled with 'f95' compiler too. Any thoughts?
  
 Thanks,
 Senthil
 
 
 
 - Original Message 
 From: Prof Brian Ripley [EMAIL PROTECTED]
 To: Senthilkumaran [EMAIL PROTECTED]
 Cc: r-help@r-project.org
 Sent: Friday, May 23, 2008 1:39:16 AM
 Subject: Re: [R] 1501-511 Compilation failed for file ch2inv.f - R on AIX
 5.2.
 
 Look like you need to use a Fortran compiler set to accept Fortran 77 
 (which the R sources are).
 
 We don't know what 'f95' is, and this is not really an R issue so please 
 ask your sysadmins for help.
 
 On Thu, 22 May 2008, Senthilkumaran wrote:
 

 Hi,

 While executing the make after successful configuration (./configure
 --with-readline=no --without-iconv), the following error occurs:

 mbf2n11s (Regatta) /saswork/R/R-2.7.0$ make
 Target R is up to date.
 Target R is up to date.
 Target R is up to date.
 Target R is up to date.
 Target Makedeps is up to date.
 Target libbz2.a is up to date.
 Target Makedeps is up to date.
 Target libpcre.a is up to date.
 Target Makedeps is up to date.
 Target libz.a is up to date.
 Target Makedeps is up to date.
        f95  -g -c ch2inv.f -o ch2inv.o
 ch2inv.f, line 1.2: 1515-019 (S) Syntax is incorrect.
 ch2inv.f, line 2.1: 1515-019 (S) Syntax is incorrect.
 ch2inv.f, line 3.4: 1515-019 (S) Syntax is incorrect.
 ch2inv.f, line 4.4: 1515-019 (S) Syntax is incorrect.
 ch2inv.f, line 5.4: 1515-019 (S) Syntax is incorrect.
 ch2inv.f, line 6.1: 1515-019 (S) Syntax is incorrect.
 ch2inv.f, line 7.4: 1515-019 (S) Syntax is incorrect.
 ch2inv.f, line 7.39: 1515-019 (S) Syntax is incorrect.
 ch2inv.f, line 8.4: 1515-019 (S) Syntax is incorrect.
 ch2inv.f, line 9.4: 1515-019 (S) Syntax is incorrect.
 ch2inv.f, line 9.41: 1515-019 (S) Syntax is incorrect.
 ch2inv.f, line 10.8: 1515-019 (S) Syntax is incorrect.
 ch2inv.f, line 11.1: 1515-019 (S) Syntax is incorrect.
 ch2inv.f, line 12.4: 1515-019 (S) Syntax is incorrect.
 ch2inv.f, line 13.4: 1515-019 (S) Syntax is incorrect.
 ch2inv.f, line 13.38: 1515-019 (S) Syntax is incorrect.
 ch2inv.f, line 14.4: 1515-019 (S) Syntax is incorrect.
 ch2inv.f, line 15.4: 1515-019 (S) Syntax is incorrect.
 ch2inv.f, line 16.1: 1515-019 (S) Syntax is incorrect.
 ch2inv.f, line 17.4: 1515-019 (S) Syntax is incorrect.
 ch2inv.f, line 18.4: 1515-019 (S) Syntax is incorrect.
 ch2inv.f, line 18.32: 1515-019 (S) Syntax is incorrect.
 ch2inv.f, line 19.4: 1515-019 (S) Syntax is incorrect.
 ch2inv.f, line 20.1: 1515-019 (S) Syntax is incorrect.
 ch2inv.f, line 21.2: 1515-019 (S) Syntax is incorrect.
 ch2inv.f, line 22.1: 1515-019 (S) Syntax is incorrect.
 ch2inv.f, line 23.3: 1515-019 (S) Syntax is incorrect.
 ch2inv.f, line 24.4: 1515-019 (S) Syntax is incorrect.
 ch2inv.f, line 25.3: 1515-019 (S) Syntax is incorrect.
 ch2inv.f, line 26.3: 1515-019 (S) Syntax is incorrect.
 ch2inv.f, line 27.1: 1515-019 (S) Syntax is incorrect.
 ch2inv.f, line 28.3: 1515-019 (S) Syntax is incorrect.
 ch2inv.f, line 29.1: 1515-019 (S) Syntax is incorrect.
 ch2inv.f, line 30.3: 1515-019 (S) Syntax is incorrect.
 ch2inv.f, line 30.30: 1515-018 (S) Incorrect character found in source
 at
 line 30 in column 30.  Hexadecimal value of character is 7B.
 ch2inv.f, line 30.39: 1515-018 (S) Incorrect character found in source
 at
 line 30 in column 39.  Hexadecimal value of character is 7D.
 ch2inv.f, line 31.4: 1515-019 (S) Syntax is incorrect.
 ch2inv.f, line 32.4: 1515-019 (S) Syntax is incorrect.
 ch2inv.f, line 33.4: 1515-019 (S) Syntax is incorrect.
 ch2inv.f, line 34.1: 1515-019 (S) Syntax is incorrect.
 ch2inv.f, line 35.3: 1515-019 (S) Syntax is incorrect.
 ch2inv.f, line 36.4: 1515-019 (S) Syntax is incorrect.
 ch2inv.f, line 37.1: 1515-019 (S) Syntax is incorrect.
 ch2inv.f, line 38.3: 1515-019 (S) Syntax is incorrect.
 ch2inv.f, line 39.4: 1515-019 (S) Syntax is incorrect.
 ch2inv.f, line 40.1: 1515-019 (S) Syntax is incorrect.
 ch2inv.f, line 41.3: 1515-019 (S) Syntax is incorrect.
 ch2inv.f, line 42.1: 1515-019 (S) Syntax is incorrect.
 ch2inv.f, line 43.3: 1515-019 (S) Syntax is incorrect.
 ch2inv.f, line 44.0: 1515-010 (S) String is missing a closing
 delimiter.
 Closing delimiter assumed at end of line.
 ch2inv.f, line 44.4: 1515-019 (S) Syntax is incorrect.
 ch2inv.f, line 45.1: 1515-019 (S) Syntax is incorrect.
 ch2inv.f, line 46.3: 1515-019 (S) Syntax is incorrect.
 ch2inv.f, line 47.3: 1515-019 (S) Syntax is incorrect.
 ch2inv.f, line 48.1: 1515-019 (S) Syntax is incorrect.
 ch2inv.f, line 49.0: 

[R] unable to get plot in R

2008-06-03 Thread Chin-Cheng Su

Hi everyone,

I use R to plot my data set (x,y) in Windows XP, but keep getting error message 
like follows,

...
 plot(x, y)
Error in windows() : unable to start device devWindows
 

How can I solve this problem? Thanks for any suggestion or help.

CC

_


sh_skydrive_062008
[[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] IBM-AIX 5.2 (GCC 4.2.4 installed) - Error while executing 'make'

2008-06-03 Thread Senthilkumaran

Hi,

Added -Wl,-bnoquiet in Makeconf and executed 'make'. The following error
occured:


gcc -std=gnu99 -I. -I../../../src/include -I../../../src/include
-I/usr/local/include -DHAVE_CONFIG_H  -mno-fp-in-toc   -g -O2 -c Lapack.c -o
Lapack.o
gcc -std=gnu99 -Wl,-brtl -Wl,-G -Wl,-bexpall -Wl,-bnoentry -lc
-Wl,-bnoquiet -L/usr/local/lib -o lapack.so  Lapack.o-lintl
-Ltop_builddir/lib -lRlapack  -lgfortran 

-lm /opt/pware/lib/gcc/powerpc-ibm-aix5.2.0.0/4.2.4/libgcc.a -lg
collect2: library libRlapack not found
make: 1254-004 The error code from the last command is 1.

Stop.
make: 1254-004 The error code from the last command is 2.

Stop.
make: 1254-004 The error code from the last command is 1.

Stop.
make: 1254-004 The error code from the last command is 1.

Stop.
make: 1254-004 The error code from the last command is 1.

Stop.


Where do we find this library libRlapack? Any thoughts?

-Senthil.


Senthilkumaran wrote:
 
 Hi,
 
 The following error occurs while executing 'make' after the successful
 configuration (./configure) on IBM-AIX 5.2 (GCC 4.2.4 installed):
 
 
 gcc -std=gnu99 -I../../src/extra/zlib -I../../src/extra/bzip2
 -I../../src/extra/pcre   -I. -I../../src/include -I../../src/include
 -I/usr/local/include -DHAVE_CONFIG_H  -mno-fp-in-toc  -g -O2 -c vfonts.c
 -o vfonts.o
 gfortran   -g -O2 -c xxxpr.f -o xxxpr.o
 gcc -std=gnu99 -I../../src/extra/zlib -I../../src/extra/bzip2
 -I../../src/extra/pcre   -I. -I../../src/include -I../../src/include
 -I/usr/local/include -DHAVE_CONFIG_H  -mno-fp-in-toc  -g -O2 -c mkdtemp.c
 -o mkdtemp.o
 ar cr libR.a CConverters.o CommandLineArgs.o Rdynload.o Renviron.o
 RNG.o apply.o apse.o arithmetic.o array.o attrib.o base.o bind.o builtin.o
 character.o coerce.o colors.o complex.o connections.o context.o cov.o
 cum.o dcf.o datetime.o debug.o deparse.o deriv.o devices.o dotcode.o
 dounzip.o dstruct.o duplicate.o engine.o envir.o errors.o eval.o format.o
 fourier.o gevents.o gram.o gram-ex.o graphics.o identical.o inlined.o
 internet.o iosupport.o lapack.o list.o localecharset.o logic.o main.o
 mapply.o match.o memory.o model.o names.o objects.o optim.o optimize.o
 options.o par.o paste.o pcre.o platform.o plot.o plot3d.o plotmath.o
 print.o printarray.o printvector.o printutils.o qsort.o random.o regex.o
 registration.o relop.o rlocale.o saveload.o scan.o seq.o serialize.o
 size.o sort.o source.o split.o sprintf.o startup.o subassign.o subscript.o
 subset.o summary.o sysutils.o unique.o util.o version.o vfonts.o xxxpr.o 
 mkdtemp.o  libs/*o
 ranlib libR.a
 gcc -std=gnu99 -Wl,-brtl -Wl,-bexpall -lc -Wl,-bE:../../etc/R.exp
 -L/usr/local/lib -o R.bin Rmain.o libR.a  -lgfortran -lm
 /opt/pware/lib/gcc/powerpc-ibm-aix5.2.0.0/4.2.4/libgcc.a -lg  -lintl  -ldl
 -lm
 ld: 0711-317 ERROR: Undefined symbol: .dcopy
 ld: 0711-317 ERROR: Undefined symbol: .dtrsm
 ld: 0711-317 ERROR: Undefined symbol: .ddot
 ld: 0711-317 ERROR: Undefined symbol: .dnrm2
 ld: 0711-317 ERROR: Undefined symbol: .dtrsl
 ld: 0711-317 ERROR: Undefined symbol: .dscal
 ld: 0711-317 ERROR: Undefined symbol: .dpofa
 ld: 0711-317 ERROR: Undefined symbol: .daxpy
 ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more
 information.
 collect2: ld returned 8 exit status
 make: 1254-004 The error code from the last command is 1.
 
 Stop.
 make: 1254-004 The error code from the last command is 2.
 
 Stop.
 make: 1254-004 The error code from the last command is 1.
 
 Stop.
 make: 1254-004 The error code from the last command is 1.
 
 Stop.
 
 Can anyone help to resolve this issue? Or at least help me to define the
 linker options '-bloadmap' or '-bnoquiet' while executing 'make'?
 
 Thanks,
 Senthil
 414-931-2436.
 

-- 
View this message in context: 
http://www.nabble.com/IBM-AIX-5.2-%28GCC-4.2.4-installed%29---Error-while-executing-%27make%27-tp17634911p17636258.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] merge two data sets

2008-06-03 Thread kayj

I would like to merge “data1 “that contains 100 unique ID’s with  another
data set “data 2” with 150 ID’s and the age of those individuals ( the ID in
data1 is a subset of the ID in data 2) I  would like to merge these data1
with data2 and have the result of the merge to have the ID ordered as in
data1.

Can this be done in R?


-- 
View this message in context: 
http://www.nabble.com/merge-two-data-sets-tp17636278p17636278.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] Model simplification using anova()

2008-06-03 Thread ChCh

Hello all,

I've become confused by the output produced by a call to
anova(model1,model2). First a brief background.  My model used to predict
final tree height is summarised here:

Df Sum Sq Mean Sq F valuePr(F)
Treatment  2   748.35   374.17 21.3096   7.123e-06 ***
HeightInitial1   0.31  0.31 0.01780.89519
DiameterInitial 1   0.52  0.52 0.02980.86460
Frost 1   38.2938.292.18070.15392
HeightInitial:Frost1   85.83 85.83   4.88820.03774 *  
DiameterInitial:Frost 1   97.9097.905.57540.02749 *  
Residuals22 386.30   17.56  
---

Based on this, I should not remove either of the interaction terms, so I
turned my attention to the main factors. Based on p-values, I removed
HeightInitial and used a call to anova(model1,model2) to see if this
resulted in a weaker model.  Here is the output:

Model 1: HeightFinal ~ Treatment + HeightInitial + DiameterInitial + Frost +
HeightInitial:Frost + DiameterInitial:Frost

Model 2: AbsoluteDiameterDiff ~ Treatment + DiameterInitial + Frost +
HeightInitial:Frost + DiameterInitial:Frost

  Res.Df   RSS Df Sum of Sq F Pr(F)
1 22 386.3  
2 22 386.3  0 -1.08e-12

This is not the output that I'm used to seeing.  Typically, a pvalue would
be provided to suggest if the models differ significantly from one another.  

Can anyone explain why there's no pvalue in this situation and whether or
not removing HeightInitial was justified.

Thanks,
Jacob Freel
-- 
View this message in context: 
http://www.nabble.com/Model-simplification-using-anova%28%29-tp17636012p17636012.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] Stacked barplot of timeseries data

2008-06-03 Thread Gabor Grothendieck
Here is a variation of the example below which uses
your data. Paste this into an R session:


Lines - 19:08:15  %usr  %nice   %sys   %idle
19:08:165  0 10 86
19:08:17   17  0 14 69
19:08:185  0  8 87
19:08:19   10  0 10 81
19:08:203  0  7 90
19:08:214  0  8 88

library(zoo)
library(chron)

# in reality the commented line next replaces the one after it
# z - read.csv(myfile.dat, header = TRUE, FUN = times)
z - read.zoo(textConnection(Lines), header = TRUE, FUN = times)
colnames(z) - sub(X., % , colnames(z))

barplot(z[, 1:3], legend = TRUE, col = 1:3)


On Tue, Jun 3, 2008 at 7:47 PM, Achim Zeileis
[EMAIL PROTECTED] wrote:
 On Tue, 3 Jun 2008, Demetri S. Mouratis wrote:

 Hi,

 I'm trying to plot time-series data where each sample breaks down the
 percentage of CPU time spent in each of four states (usr, nice, sys, idle)


 19:08:15  %usr  %nice   %sys   %idle
 19:08:165  0 10 86
 19:08:17   17  0 14 69
 19:08:185  0  8 87
 19:08:19   10  0 10 81
 19:08:203  0  7 90
 19:08:214  0  8 88
 [on and on for many samples]

 The plot I'm aiming for would stack the first three states in a colored
 barplot, so you get a visual sense of how busy the system is over the course
 of the day, and which state the CPU is spending its time in.  (I've done
 this as area charts as well).

 barplot() looked promising, but it wants to stack the columns instead of
 the rows.

 Anybody have a good solution for this?

 The zoo package provides a barplot() method for zoo series.

 Example with some artificial data:

  library(zoo)
  x - matrix(runif(44), ncol = 4)
  colnames(x) - c(%usr, %nice, %sys, %idle)
  z - zoo(x, Sys.time() - c(10:0))
  barplot(z, legend = TRUE)

 hth,
 Z

 Thanks!
 ...Demetri

 __
 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-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] unable to get plot in R

2008-06-03 Thread Duncan Murdoch

On 03/06/2008 6:53 PM, Chin-Cheng Su wrote:

Hi everyone,

I use R to plot my data set (x,y) in Windows XP, but keep getting error message 
like follows,


...
plot(x, y)

Error in windows() : unable to start device devWindows

How can I solve this problem? Thanks for any suggestion or help.


Somehow you appear to have set options(device) to devWindows.  If 
you set it to windows using options(device=windows), things should 
be fine.


Duncan Murdoch

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


[R] Question about subsetting data

2008-06-03 Thread William Pepe

I have a data set(Bill) of with 1 variable (var1), with 100 obs that are in 
ascending order. I want to sample every 10 observations and save them in 10 
different groups such as
 
  Group1 is obs 1-10
  Group 2 is obs-11-20
 
and so on.
 
First step is to subset them into the 10 groups, then calculate the mean of 
var1 for each of the 10 groups. Any help would be appreciated. Thanks.
 
_


sh_skydrive_062008
[[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 add space between main title to leave space for legend?

2008-06-03 Thread Paul Johnson
On Sat, May 31, 2008 at 2:45 PM, Peter Dalgaard
[EMAIL PROTECTED] wrote:
 Paul Johnson wrote:

 Hell
 (1) par(xpd=TRUE) allows you to write outside the plotting region

  O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B

As usual, PD right on the money.  Here's a working demo program for
posterity.  For  most random samples, this gives a good looking
graph.  For a the other few, well, they happen less than 0.05 of the
time :)


### histogramWithDensityLinesAndLegend.R
### Paul Johnson 2008-06-02
### Thanks to r-help members for tips.


x - rnorm(100)
###Allows writing outside plotting region

par(mai=c(1,1,2.5,1))


par(xpd=TRUE)

myhist - hist(x, freq=F, main=Different Meanings of Normality)

lines(density(x))

xseq1 - seq( min(x), max(x), length.out=100)

m1 - mean(x)

sd1 - sd(x)

obsNormal - dnorm(xseq1, mean=m1, sd=sd1)

lines( xseq1, obsNormal, lty=2, col=red)

truNormal - dnorm(xseq1)

lines(xseq1, truNormal, lty=3, col=green)

legend(min(xseq1),1.3*max(myhist$density), legend=c(observed
density, normal with observed mean  sd, normal with 'true' mean
and sd), lty=c(1,2,3), col=c(black, red, blue))





-- 
Paul E. Johnson
Professor, Political Science
1541 Lilac Lane, Room 504
University of Kansas

__
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] Minimizing the negative log likelihood function...

2008-06-03 Thread François Aucoin
Hey,

The following is a function I wrote which generates random variables from a
Kappa (2-parameter) distribution.

rkappa - function(n,beta,alpha){
 if(alpha = 0)
  stop(alpha must be greater than zero!)
 if(beta = 0)
  stop(beta must be greater than zero!)
 Vec - beta*exp((1/alpha)*(log(-(alpha/(-1 +
exp(alpha*log(runif(n,0,1))+ alpha*log(runif(n,0,1
 return(Vec)
}

Now I would like to estimate the parameters of such a distribution using the
Maximum likelihood method.
I know that I have to minimize the following negative log likelihood
function:

Neg.Log.Like - function(beta,alpha,x){
 -(sum( log((alpha/beta)*(alpha + (x/beta)^alpha)^( -(alpha + 1)/alpha
}

I have tried several R's functions for optimization but the results I yield
are not correct.
Is there anybody who can help me?

Thanks!

Francois Aucoin

[[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] merge two data sets

2008-06-03 Thread Moshe Olshansky
Where do you want to place ID's which are in data2 but NOT in data1?


--- On Wed, 4/6/08, kayj [EMAIL PROTECTED] wrote:

 From: kayj [EMAIL PROTECTED]
 Subject: [R]  merge two data sets
 To: r-help@r-project.org
 Received: Wednesday, 4 June, 2008, 9:45 AM
 I would like to merge “data1 “that contains 100 unique
 ID’s with  another
 data set “data 2” with 150 ID’s and the age of those
 individuals ( the ID in
 data1 is a subset of the ID in data 2) I  would like to
 merge these data1
 with data2 and have the result of the merge to have the ID
 ordered as in
 data1.
 
 Can this be done in R?
 
 
 -- 
 View this message in context:
 http://www.nabble.com/merge-two-data-sets-tp17636278p17636278.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] Question about subsetting data

2008-06-03 Thread Moshe Olshansky
One possibility is:

x - ceiling((1:100)/10)
aggregate(var1,by=list(x),mean)


--- On Wed, 4/6/08, William Pepe [EMAIL PROTECTED] wrote:

 From: William Pepe [EMAIL PROTECTED]
 Subject: [R] Question about subsetting data
 To: r-help@r-project.org
 Received: Wednesday, 4 June, 2008, 10:35 AM
 I have a data set(Bill) of with 1 variable (var1), with 100
 obs that are in ascending order. I want to sample every 10
 observations and save them in 10 different groups such as
  
   Group1 is obs 1-10
   Group 2 is obs-11-20
  
 and so on.
  
 First step is to subset them into the 10 groups, then
 calculate the mean of var1 for each of the 10 groups. Any
 help would be appreciated. Thanks.
  
 _
 
 
 sh_skydrive_062008
   [[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] Question about subsetting data

2008-06-03 Thread jim holtman
Will this do it for you:

 Bill - 1:100  # test data
 # partition
 Bill.p - split(Bill, rep(1:10, each=10))
 Bill.p
$`1`
 [1]  1  2  3  4  5  6  7  8  9 10
$`2`
 [1] 11 12 13 14 15 16 17 18 19 20
$`3`
 [1] 21 22 23 24 25 26 27 28 29 30
$`4`
 [1] 31 32 33 34 35 36 37 38 39 40
$`5`
 [1] 41 42 43 44 45 46 47 48 49 50
$`6`
 [1] 51 52 53 54 55 56 57 58 59 60
$`7`
 [1] 61 62 63 64 65 66 67 68 69 70
$`8`
 [1] 71 72 73 74 75 76 77 78 79 80
$`9`
 [1] 81 82 83 84 85 86 87 88 89 90
$`10`
 [1]  91  92  93  94  95  96  97  98  99 100
 sapply(Bill.p, mean)
   123456789   10
 5.5 15.5 25.5 35.5 45.5 55.5 65.5 75.5 85.5 95.5




On Tue, Jun 3, 2008 at 8:35 PM, William Pepe [EMAIL PROTECTED]
wrote:


 I have a data set(Bill) of with 1 variable (var1), with 100 obs that are in
 ascending order. I want to sample every 10 observations and save them in 10
 different groups such as

  Group1 is obs 1-10
  Group 2 is obs-11-20

 and so on.

 First step is to subset them into the 10 groups, then calculate the mean of
 var1 for each of the 10 groups. Any help would be appreciated. Thanks.

 _


 sh_skydrive_062008
[[alternative HTML version deleted]]

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




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

What is the problem you are trying to solve?

[[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 understanding why #function(x, y) (if((x-y)=0) {2^(x-y)} else{-(2^abs(x-y))})# doesn't work like I think it should

2008-06-03 Thread ALAN SMITH
Hello R users and developers,
I am trying to write several functions (fairly new at this) in order
to avoid using loops on large data frames (because they are slow).  I
wrote the function below and it seems to get hung on the first part of
the if statement and then applies that condition to rest of the
function.  So if (x-y) is greater than 0 the function uses the true
statement for the calculations.   Could someone please offer some
advise on how to write these functions a little better or a type
apply that I may use with two (or more) different vectors of data
required by a single functions.
###  Examples
###
## example 1 ###
x-c(5,6,4,3,5,3,1)
y-c(1,6,2,1,7,1,9)
folds-function(x,y) (if((x-y)=0) {2^(x-y)} else{-(2^abs(x-y))})
z-folds(x,y)
check-cbind(x,y,z)
View(check)

Warning message:
In if ((x - y) = 0) { :
  the condition has length  1 and only the first element will be used
 ### why will it only use the first element and how to I get around
this 

## example 2 making the fist comparison negative ###
x1-c(5,6,4,3,5,3,1)
y1-c(11,6,2,1,7,1,9)
folds-function(x,y) (if((x-y)=0) {2^(x-y)} else{-(2^abs(x-y))})
z1-folds(x1,y1)
check2-cbind(x1,y1,z1)
View(check2)
Warning message:
In if ((x - y) = 0) { :
  the condition has length  1 and only the first element will be used

 loop I am trying to avoid writing many many times #
folds2-NULL
xy-as.data.frame(cbind(x,y))
for (i in 1:nrow(xy)) {
diff-xy$x[i]-xy$y[i]
folds2[i]-if(diff=0) {2^diff} else{-(2^abs(diff))}
}
xyz-cbind(xy,folds2)
View(xyz)
#

Thank you,
Alan

P.S.  why does ?function not work

__
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] column and row

2008-06-03 Thread Manli Yan
-fit1$coefficients

 y.control y.lowy.high
(Intercept)19.628713 21.883999 20.023814
log(1 + (age - 45)/10) -7.383725 -6.017342 -5.084431

here is my outcome,I need one vector say b1=first row without the intercept
,like:(19.628713, 21.883999, 20.023814)
and  another b2=second row without the log(1 + (age - 45)/10),only the
data,how to do this in R?

[[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-titled) help with if.

2008-06-03 Thread Rolf Turner


This is an FAQ (although it doesn't seem to be listed in the official  
FAQs.

The ``if'' command compares scalars (only, in effect).

See ?if

You need to use the ifelse() function:

folds - function(x,y) ifelse(x-y=0,2^(x-y),-2^(y-x))

This if for illustrative purposes only.  The foregoing would be  
better done as:


folds - function(x,y) sign(x-y)*2^abs(x-y)

cheers,

Rolf Turner

On 4/06/2008, at 1:47 PM, ALAN SMITH wrote:


Hello R users and developers,
I am trying to write several functions (fairly new at this) in order
to avoid using loops on large data frames (because they are slow).  I
wrote the function below and it seems to get hung on the first part of
the if statement and then applies that condition to rest of the
function.  So if (x-y) is greater than 0 the function uses the true
statement for the calculations.   Could someone please offer some
advise on how to write these functions a little better or a type
apply that I may use with two (or more) different vectors of data
required by a single functions.
###  Examples
###
## example 1 ###
x-c(5,6,4,3,5,3,1)
y-c(1,6,2,1,7,1,9)
folds-function(x,y) (if((x-y)=0) {2^(x-y)} else{-(2^abs(x-y))})
z-folds(x,y)
check-cbind(x,y,z)
View(check)

Warning message:
In if ((x - y) = 0) { :
  the condition has length  1 and only the first element will be used
 ### why will it only use the first element and how to I get around
this 

## example 2 making the fist comparison negative ###
x1-c(5,6,4,3,5,3,1)
y1-c(11,6,2,1,7,1,9)
folds-function(x,y) (if((x-y)=0) {2^(x-y)} else{-(2^abs(x-y))})
z1-folds(x1,y1)
check2-cbind(x1,y1,z1)
View(check2)
Warning message:
In if ((x - y) = 0) { :
  the condition has length  1 and only the first element will be used
## 
##

 loop I am trying to avoid writing many many times #
folds2-NULL
xy-as.data.frame(cbind(x,y))
for (i in 1:nrow(xy)) {
diff-xy$x[i]-xy$y[i]
folds2[i]-if(diff=0) {2^diff} else{-(2^abs(diff))}
}
xyz-cbind(xy,folds2)
View(xyz)
#

Thank you,
Alan

P.S.  why does ?function not work

__
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.



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

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


Re: [R] help understanding why #function(x, y) (if((x-y)=0) {2^(x-y)} else{-(2^abs(x-y))})# doesn't work like I think it should

2008-06-03 Thread Simon Blomberg
Use ifelse() rather than if () {} else {}. It's vectorized and very
useful for applying to elements along vectors. The latter idiom is much
better for control of flow in programs and functions.

 folds - function (x, y) ifelse(x-y = 0, 2^(x-y), -(2^abs(x-y)))

 z - folds(x, y)
 z
[1]   16144   -44 -256
 

?function works for me. Here's my setup:

R version 2.7.0 (2008-04-22) 
x86_64-pc-linux-gnu 

Cheers,

Simon.


On Tue, 2008-06-03 at 20:47 -0500, ALAN SMITH wrote:
 Hello R users and developers,
 I am trying to write several functions (fairly new at this) in order
 to avoid using loops on large data frames (because they are slow).  I
 wrote the function below and it seems to get hung on the first part of
 the if statement and then applies that condition to rest of the
 function.  So if (x-y) is greater than 0 the function uses the true
 statement for the calculations.   Could someone please offer some
 advise on how to write these functions a little better or a type
 apply that I may use with two (or more) different vectors of data
 required by a single functions.
 ###  Examples
 ###
 ## example 1 ###
 x-c(5,6,4,3,5,3,1)
 y-c(1,6,2,1,7,1,9)
 folds-function(x,y) (if((x-y)=0) {2^(x-y)} else{-(2^abs(x-y))})
 z-folds(x,y)
 check-cbind(x,y,z)
 View(check)
 
 Warning message:
 In if ((x - y) = 0) { :
   the condition has length  1 and only the first element will be used
  ### why will it only use the first element and how to I get around
 this 
 
 ## example 2 making the fist comparison negative ###
 x1-c(5,6,4,3,5,3,1)
 y1-c(11,6,2,1,7,1,9)
 folds-function(x,y) (if((x-y)=0) {2^(x-y)} else{-(2^abs(x-y))})
 z1-folds(x1,y1)
 check2-cbind(x1,y1,z1)
 View(check2)
 Warning message:
 In if ((x - y) = 0) { :
   the condition has length  1 and only the first element will be used
 
  loop I am trying to avoid writing many many times #
 folds2-NULL
 xy-as.data.frame(cbind(x,y))
 for (i in 1:nrow(xy)) {
 diff-xy$x[i]-xy$y[i]
 folds2[i]-if(diff=0) {2^diff} else{-(2^abs(diff))}
 }
 xyz-cbind(xy,folds2)
 View(xyz)
 #
 
 Thank you,
 Alan
 
 P.S.  why does ?function not work
 
 __
 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.
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
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 understanding why #function(x, y) (if((x-y)=0) {2^(x-y)} else{-(2^abs(x-y))})# doesn't work like I think it should

2008-06-03 Thread Erik Iverson

Alan -

ALAN SMITH wrote:

Hello R users and developers,
I am trying to write several functions (fairly new at this) in order
to avoid using loops on large data frames (because they are slow).  I
wrote the function below and it seems to get hung on the first part of
the if statement and then applies that condition to rest of the
function.  So if (x-y) is greater than 0 the function uses the true
statement for the calculations.   Could someone please offer some
advise on how to write these functions a little better or a type
apply that I may use with two (or more) different vectors of data
required by a single functions.
###  Examples
###
## example 1 ###
x-c(5,6,4,3,5,3,1)
y-c(1,6,2,1,7,1,9)
folds-function(x,y) (if((x-y)=0) {2^(x-y)} else{-(2^abs(x-y))})
z-folds(x,y)
check-cbind(x,y,z)
View(check)

Warning message:
In if ((x - y) = 0) { :
  the condition has length  1 and only the first element will be used
 ### why will it only use the first element and how to I get around
this 


When learning R, you have the power of the interpreter at all times. 
You have defined x and y above to be numeric vectors of length 7 each. 
Try typign x - y at the interpreter, and you'll see you get another 
numeric vector of length 7.  Now try (x - y) = 0 , and you'll get a 
logical vector of length 7.  However, if does not want a logical vector 
of length 7, it wants a logical vector of length 1, see the 'cond' 
argument of ?if.  However, the ifelse function should do what you want, 
see ?ifelse.


Here's an example using it

folds2 - function(x, y) {
  ifelse(x - y = 0, 2^(x - y), -(2^abs(x - y)))
}

folds2(x, y) should give you your answer...




## example 2 making the fist comparison negative ###
x1-c(5,6,4,3,5,3,1)
y1-c(11,6,2,1,7,1,9)
folds-function(x,y) (if((x-y)=0) {2^(x-y)} else{-(2^abs(x-y))})
z1-folds(x1,y1)
check2-cbind(x1,y1,z1)
View(check2)
Warning message:
In if ((x - y) = 0) { :
  the condition has length  1 and only the first element will be used


Same idea as above here...




 loop I am trying to avoid writing many many times #
folds2-NULL
xy-as.data.frame(cbind(x,y))
for (i in 1:nrow(xy)) {
diff-xy$x[i]-xy$y[i]
folds2[i]-if(diff=0) {2^diff} else{-(2^abs(diff))}
}
xyz-cbind(xy,folds2)
View(xyz)
#


I'm not exactly sure what you'd like here, but hopefully with the above 
you can figure it out.  Let me know if you have any questions!


Best,
Erik Iverson



Thank you,
Alan

P.S.  why does ?function not work


What do you expect it to do?  It shows the help page for 'function' here.



__
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 understanding why #function(x, y) (if((x-y)=0) {2^(x-y)} else{-(2^abs(x-y))})# doesn't work likeI think it should

2008-06-03 Thread Steven McKinney
Hi Alan,

 -Original Message-
 From: [EMAIL PROTECTED] on behalf of ALAN SMITH
 Sent: Tue 6/3/2008 6:47 PM
 To: r-help@r-project.org
 Subject: [R] help understanding why #function(x,y) (if((x-y)=0) {2^(x-y)} 
 else{-(2^abs(x-y))})# doesn't work likeI think it should
  
 Hello R users and developers,
 I am trying to write several functions (fairly new at this) in order
 to avoid using loops on large data frames (because they are slow).  I
 wrote the function below and it seems to get hung on the first part of
 the if statement and then applies that condition to rest of the
 function.  So if (x-y) is greater than 0 the function uses the true
 statement for the calculations.   Could someone please offer some
 advise on how to write these functions a little better or a type
 apply that I may use with two (or more) different vectors of data
 required by a single functions.
 ###  Examples
 ###
 ## example 1 ###
 x-c(5,6,4,3,5,3,1)
 y-c(1,6,2,1,7,1,9)
 folds-function(x,y) (if((x-y)=0) {2^(x-y)} else{-(2^abs(x-y))})
 z-folds(x,y)
 check-cbind(x,y,z)
 View(check)
 
 Warning message:
 In if ((x - y) = 0) { :
   the condition has length  1 and only the first element will be used
  ### why will it only use the first element and how to I get around
 this 


You probably want to use ifelse() instead of if()

folds - function(x, y) (ifelse( ((x - y) = 0), 2^(x - y), -(2^abs(x - y

x - c(5,6,4,3,5,3,1)
y - c(1,6,2,1,7,1,9)
folds - function(x, y) (ifelse( ((x - y) = 0), 2^(x - y), -(2^abs(x - y
z - folds(x, y)
check - cbind(x, y, z)
check

R x - c(5,6,4,3,5,3,1)
R y - c(1,6,2,1,7,1,9)
R folds - function(x, y) (ifelse( ((x - y) = 0), 2^(x - y), -(2^abs(x - y
R z - folds(x, y)
R check - cbind(x, y, z)
R check
 x yz
[1,] 5 1   16
[2,] 6 61
[3,] 4 24
[4,] 3 14
[5,] 5 7   -4
[6,] 3 14
[7,] 1 9 -256

 
 
 ## example 2 making the fist comparison negative ###
 x1-c(5,6,4,3,5,3,1)
 y1-c(11,6,2,1,7,1,9)
 folds-function(x,y) (if((x-y)=0) {2^(x-y)} else{-(2^abs(x-y))})
 z1-folds(x1,y1)
 check2-cbind(x1,y1,z1)
 View(check2)
 Warning message:
 In if ((x - y) = 0) { :
   the condition has length  1 and only the first element will be
 used
 
x1 - c(5,6,4,3,5,3,1)
y1 - c(11,6,2,1,7,1,9)
folds - function(x, y) {ifelse( ((x - y) = 0), {2^(x - y)}, {-(2^abs(x - y))} 
) }
z1-folds(x1,y1)
check2-cbind(x1,y1,z1)
check2
 
R x1 - c(5,6,4,3,5,3,1)
R y1 - c(11,6,2,1,7,1,9)
R folds - function(x, y) {ifelse( ((x - y) = 0), {2^(x - y)}, {-(2^abs(x - 
y))} ) }
R z1-folds(x1,y1)
R check2-cbind(x1,y1,z1)
R check2
 x1 y1   z1
[1,]  5 11  -64
[2,]  6  61
[3,]  4  24
[4,]  3  14
[5,]  5  7   -4
[6,]  3  14
[7,]  1  9 -256

 
  loop I am trying to avoid writing many many times #
 folds2-NULL
 xy-as.data.frame(cbind(x,y))
 for (i in 1:nrow(xy)) {
 diff-xy$x[i]-xy$y[i]
 folds2[i]-if(diff=0) {2^diff} else{-(2^abs(diff))}
 }
 xyz-cbind(xy,folds2)
 View(xyz)
 #
 
 Thank you,
 Alan
 
 P.S.  why does ?function not work

It does work in my ESS R session buffer, so
it depends on your setup.

try
R ?function

?function

might not work as the R parser doesn't think you have 
finished typing in the expression (function objects
are typically terminated by the final '}' brace).  

 
 __
 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.
 
 

Best

Steve McKinney

__
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] Similar question about subsetting data

2008-06-03 Thread William Pepe

This is just a slight modification of a question I asked earlier. Thanks to all 
the responders.
 
I have a data set(Bill) of with 1 variable (var1), with 100 obs that are in 
ascending order. I want to sample every 10 observations and save them in 10 
different groups such as   Group1 is obs 1-10  Group 2 is obs-11-20  Subset 
data into the 10 groups, then calculate the mean/0.8 of var1 for each of the 10 
groups. 
The mean/0.8 is the modification. Thanks.
_
It’s easy to add contacts from Facebook and other social sites through Wi
https://www.invite2messenger.net/im/?source=TXT_EML_WLH_LearnHow
[[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] help understanding why #function(x, y) (if((x-y)=0) {2^(x-y)} else{-(2^abs(x-y))})# doesn't work like I think it should

2008-06-03 Thread Gabor Grothendieck
Try this:

data.frame(x, y, folds = (x == y) + sign(x - y) * 2 ^ abs(x - y))

or replace data.frame with cbind if you prefer a matrix result.

On Tue, Jun 3, 2008 at 9:47 PM, ALAN SMITH [EMAIL PROTECTED] wrote:
 Hello R users and developers,
 I am trying to write several functions (fairly new at this) in order
 to avoid using loops on large data frames (because they are slow).  I
 wrote the function below and it seems to get hung on the first part of
 the if statement and then applies that condition to rest of the
 function.  So if (x-y) is greater than 0 the function uses the true
 statement for the calculations.   Could someone please offer some
 advise on how to write these functions a little better or a type
 apply that I may use with two (or more) different vectors of data
 required by a single functions.
 ###  Examples
 ###
 ## example 1 ###
 x-c(5,6,4,3,5,3,1)
 y-c(1,6,2,1,7,1,9)
 folds-function(x,y) (if((x-y)=0) {2^(x-y)} else{-(2^abs(x-y))})
 z-folds(x,y)
 check-cbind(x,y,z)
 View(check)

 Warning message:
 In if ((x - y) = 0) { :
  the condition has length  1 and only the first element will be used
  ### why will it only use the first element and how to I get around
 this 

 ## example 2 making the fist comparison negative ###
 x1-c(5,6,4,3,5,3,1)
 y1-c(11,6,2,1,7,1,9)
 folds-function(x,y) (if((x-y)=0) {2^(x-y)} else{-(2^abs(x-y))})
 z1-folds(x1,y1)
 check2-cbind(x1,y1,z1)
 View(check2)
 Warning message:
 In if ((x - y) = 0) { :
  the condition has length  1 and only the first element will be used
 
  loop I am trying to avoid writing many many times #
 folds2-NULL
 xy-as.data.frame(cbind(x,y))
 for (i in 1:nrow(xy)) {
 diff-xy$x[i]-xy$y[i]
 folds2[i]-if(diff=0) {2^diff} else{-(2^abs(diff))}
 }
 xyz-cbind(xy,folds2)
 View(xyz)
 #

 Thank you,
 Alan

 P.S.  why does ?function not work

 __
 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] how to extract a specific group of data from a table?

2008-06-03 Thread Manli Yan
   a table with three varialbe:treatment
(low,high),size(large,small),response y
  I want all response y with treatment=low and size=large,
  I try to write as :
treatment-c(low,low,high,high)
size-c(small,large,small,large)
y-c(1,2,4,5)
table1-data.frame(treatment,size,y)
x=table1$y(treatment==low size==large)

this does not work out~

thank you for the help~

[[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 extract a specific group of data from a table?

2008-06-03 Thread Jorge Ivan Velez
Dear Manli,

Try this:

table1[table1$treatment==low  table1$size==large,]

HTH,

Jorge


On Tue, Jun 3, 2008 at 11:19 PM, Manli Yan [EMAIL PROTECTED] wrote:

   a table with three varialbe:treatment
 (low,high),size(large,small),response y
  I want all response y with treatment=low and size=large,
  I try to write as :
 treatment-c(low,low,high,high)
 size-c(small,large,small,large)
 y-c(1,2,4,5)
 table1-data.frame(treatment,size,y)
 x=table1$y(treatment==low size==large)

 this does not work out~

 thank you for the help~

[[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] Similar question about subsetting data

2008-06-03 Thread Jorge Ivan Velez
Dear William,

Following Jim Holtman's solution to your previous post, you can do something
similar to

Bill - 1:100  # test data
Bill.p - split(Bill, rep(1:10, each=10))
sapply(Bill.p, function(x) mean(x)/0.8)
1   2   3   4   5   6   7   8   9  10
  6.875  19.375  31.875  44.375  56.875  69.375  81.875  94.375 106.875
119.375

HTH,

Jorge



On Tue, Jun 3, 2008 at 10:36 PM, William Pepe [EMAIL PROTECTED]
wrote:


 This is just a slight modification of a question I asked earlier. Thanks to
 all the responders.

 I have a data set(Bill) of with 1 variable (var1), with 100 obs that are in
 ascending order. I want to sample every 10 observations and save them in 10
 different groups such as   Group1 is obs 1-10  Group 2 is obs-11-20 
 Subset data into the 10 groups, then calculate the mean/0.8 of var1 for each
 of the 10 groups.
 The mean/0.8 is the modification. Thanks.
 _
 It's easy to add contacts from Facebook and other social sites through Wi
 https://www.invite2messenger.net/im/?source=TXT_EML_WLH_LearnHow
[[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.


[R] code for automating the sem package

2008-06-03 Thread Gus Jespersen

Greetings,
I am wondering if anyone has written programs to automate model fitting 
with the sem package, where one could specify a 'saturated' model and 
sequentially fit models with different combinations of parameters 
removed, while outputting fit data/parameters involved for each model.

Thanks
Gus

__
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] for loop or by group in EF function

2008-06-03 Thread Ingrid Tohver
Hello,
I would like to apply the EF function (a goodness of fit test between  
predicted (ts2) and observed (Tw) values in the qualV package) to  
each of the Sites in my data frame. However, when I try the following  
script, R gives an error message that lists unused arguments, which  
include the Tw and ts2 that are explicitly in the function:

nsc = by(tsdem16, tsdem16['Site'], function(x) EF(Tw, ts2, data = x))

Error in EF(Tw, ts1, data = x) :
   unused argument(s) (data = list(ts2 = c(11.9967554700039, ...

I tried a for loop, but it didn't perform the function on each Site,  
rather it performed one calculation for the entire data set.
Are there any suggestions to improving my script?
Thanks,
Ingrid
[[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] unable to get plot in R

2008-06-03 Thread Chin-Cheng Su

Please look at what I tried,

 attach(my.data)
 options(device=windows)
 plot(x,y)
Error in windows() : unable to start device devWindows


However, as i tried something else, it went like

 options(device=devWindows)
 plot(x,y)
Error in plot.new() : no active or default device


Any idea?

Thanks
CC

 Date: Tue, 3 Jun 2008 20:25:51 -0400
 From: [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 CC: r-help@r-project.org
 Subject: Re: [R] unable to get plot in R
 
 On 03/06/2008 6:53 PM, Chin-Cheng Su wrote:
  Hi everyone,
  
  I use R to plot my data set (x,y) in Windows XP, but keep getting error 
  message like follows,
  
  ...
  plot(x, y)
  Error in windows() : unable to start device devWindows
  
  How can I solve this problem? Thanks for any suggestion or help.
 
 Somehow you appear to have set options(device) to devWindows.  If 
 you set it to windows using options(device=windows), things should 
 be fine.
 
 Duncan Murdoch

_


sh_skydrive_062008
[[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] linear model in the repeated data type~

2008-06-03 Thread Manli Yan
  here is the data:
 y-c(5,2,3,7,9,0,1,4,5)
id-c(1,1,6,6,7,8,15,15,19)
t-c(50,56,50,56,50,50,50,60,50)
table1-data.frame(y,id,t)//longitudinal data

what  I want to do is to use the linear model for each id ,then get the
estimate value,like:

fit1-lm(y~t,data=table1,subset=(id==1))

but ,you can see the variable id is quite irregular,they are not arranaged
in order and many number missing,if I write a loop by using for,it will
give me a lot NA,
and for sure ,I dont want to type id=## for about 500 times,any one know how
to deal with it?

[[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] splitting data frame based on a criteria

2008-06-03 Thread ctu

Or ?gsummary


Quoting Moshe Olshansky [EMAIL PROTECTED]:


Also check ?aggregate


--- On Wed, 4/6/08, Ingmar Visser [EMAIL PROTECTED] wrote:


From: Ingmar Visser [EMAIL PROTECTED]
Subject: Re: [R] splitting data frame based on a criteria
To: Marvin Lists [EMAIL PROTECTED]
Cc: r-help@r-project.org
Received: Wednesday, 4 June, 2008, 5:11 AM
?by may be helpful here
eg if dat is your data.frame and yf is a factor (created
using ifelse)
use by(dat,yf,mean) to compute the means for each level of
yf
hth, Ingmar

On Jun 3, 2008, at 8:37 PM, Marvin Lists wrote:

 Hi,
 I have a data frame that I want to split into two
based on the
 values of a
 variable in it.

 The variable Y has numeric values ranging between 0
through 70. I
 want to
 plot the frequencies of another variable X in two
different cases:
 - When Y = 0 and
 - When Y  0

 How does one go about doing this?

 In general, I want to do several analyses with this
data frame that
 are a
 variation of the above situation, i.e. they require
splitting the
 data into
 different age, gender etc. and then calculating
separate means,
 correlations
 and so on for the different groups into which the data
frame would
 split.

 I am struggling with the correct syntax for achieving
this.

 Reading through the documentation suggests that tapply
and split
 may be the
 functions to use for my purposes but the examples in
the
 documentations
 didn't help me understand how I could achieve
this.

 I would appreciate any suggestions and help.

 Thanks,
 Marvin

[[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-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] linear model in the repeated data type~

2008-06-03 Thread Austin, Matt
How about


library(nlme)
allFits - lmList(y ~ t|id, data=table1, pool=FALSE)

or

allFits - by(table1, table1$id, function(x) lm(y ~ t, data=x))

Both ways store the results as a list, so you can access individual results 
using list extraction.


--Matt

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Manli Yan
Sent: Tuesday, June 03, 2008 9:07 PM
To: r-help@r-project.org
Subject: [R] linear model in the repeated data type~

  here is the data:
 y-c(5,2,3,7,9,0,1,4,5)
id-c(1,1,6,6,7,8,15,15,19)
t-c(50,56,50,56,50,50,50,60,50)
table1-data.frame(y,id,t)//longitudinal data

what  I want to do is to use the linear model for each id ,then get the 
estimate value,like:

fit1-lm(y~t,data=table1,subset=(id==1))

but ,you can see the variable id is quite irregular,they are not arranaged in 
order and many number missing,if I write a loop by using for,it will give me 
a lot NA, and for sure ,I dont want to type id=## for about 500 times,any one 
know how to deal with it?

[[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] linear model in the repeated data type~

2008-06-03 Thread Moshe Olshansky
Try something like this:

fits - list(500)
for (i in 1:500)
{
if (sum(table1$id == i) == 0) fits[[i]] - NA
else fits[[i]] - lm(y~t,data=table1,subset=(id==i))
}


--- On Wed, 4/6/08, Manli Yan [EMAIL PROTECTED] wrote:

 From: Manli Yan [EMAIL PROTECTED]
 Subject: [R] linear model in the repeated data type~
 To: r-help@r-project.org
 Received: Wednesday, 4 June, 2008, 2:06 PM
 here is the data:
  y-c(5,2,3,7,9,0,1,4,5)
 id-c(1,1,6,6,7,8,15,15,19)
 t-c(50,56,50,56,50,50,50,60,50)
 table1-data.frame(y,id,t)//longitudinal data
 
 what  I want to do is to use the linear model for each id
 ,then get the
 estimate value,like:
 
 fit1-lm(y~t,data=table1,subset=(id==1))
 
 but ,you can see the variable id is quite
 irregular,they are not arranaged
 in order and many number missing,if I write a loop by using
 for,it will
 give me a lot NA,
 and for sure ,I dont want to type id=## for about 500
 times,any one know how
 to deal with it?
 
   [[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] how to automatically create objects with names from a string list?

2008-06-03 Thread Mark Farnell
Suppose I have a string of objects names:

name - c(foo, bar, baz)

and I would like to use a for loop to automatically create three
objects called foo, bar and baz accordingly.  Then how can this
be done (so that in the workspace, foo = 1, bar = 2 and baz=3)

for (i in name) {
.
}

Thanks!

Mark

__
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 automatically create objects with names from a string list?

2008-06-03 Thread Moshe Olshansky
You can use either assign or eval.

Something like

 name - c(foo, bar, baz)
 for (i in 1:length(name)) assign(name[i],i)



--- On Wed, 4/6/08, Mark Farnell [EMAIL PROTECTED] wrote:

 From: Mark Farnell [EMAIL PROTECTED]
 Subject: [R] how to automatically create objects with names from a string 
 list?
 To: R-help@r-project.org
 Received: Wednesday, 4 June, 2008, 3:15 PM
 Suppose I have a string of objects names:
 
 name - c(foo, bar,
 baz)
 
 and I would like to use a for loop to automatically create
 three
 objects called foo, bar and
 baz accordingly.  Then how can this
 be done (so that in the workspace, foo = 1, bar = 2
 and baz=3)
 
 for (i in name) {
 .
 }
 
 Thanks!
 
 Mark
 
 __
 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.


  1   2   >