Re: [R] Bug in levels() function?

2008-01-29 Thread Groot, Philip de
Hello all,
 
Thank you for all the responses. It is clear to me now. However, if the drop 
possibility was also mentioned in the help text (in R, so ?levels) I wouldn't 
have asked this question at all!
 
Regards,
 
Philip



From: Thomas Lumley [mailto:[EMAIL PROTECTED]
Sent: Mon 28-1-2008 20:03
To: Groot, Philip de
Cc: [EMAIL PROTECTED]
Subject: Re: [R] Bug in levels() function?




This is not a bug; it is deliberately designed this way.

There are circumstances when you want to drop levels on subsetting and
other circumstances where you don't, so the default behaviour can't make
everyone happy.  However, there is an option to get the behaviour you want
 x-as.factor(LETTERS)
 levels(x[1])
  [1] A B C D E F G H I J K L M N O P Q
R S
[20] T U V W X Y Z
 levels(x[1,drop=TRUE])
[1] A


On Mon, 28 Jan 2008, Groot, Philip de wrote:

 Hello all,

 I am not sure whether it actually is a bug, but it is not the behaviour I 
 would expect. Please consider this:

 Sibships
 [1] Patient_2400 Patient_2400 Patient_345  Patient_345  Patient_8901
 [6] Patient_8901 Patient_4008 Patient_4008 Patient_7991 Patient_7991
 [11] Patient_8353 Patient_8353 Patient_1212 Patient_1212 Patient_2168
 [16] Patient_2168 Patient_2760 Patient_2760 Patient_4726 Patient_4726
 [21] Patient_6699 Patient_6699 Patient_7641 Patient_7641 Patient_8263
 [26] Patient_8263 Patient_1389 Patient_1389 Patient_1618 Patient_1618
 [31] Patient_2410 Patient_2410 Patient_2612 Patient_2612 Patient_2721
 [36] Patient_2721 Patient_5053 Patient_5053 Patient_8458 Patient_8458
 [41] Patient_211  Patient_211  Patient_9004 Patient_9004 Patient_3423
 [46] Patient_3423 Patient_7413 Patient_7413 Patient_7815 Patient_7815
 [51] Patient_9232 Patient_9232 Patient_2267 Patient_2267 Patient_468
 [56] Patient_468
 28 Levels: Patient_1212 Patient_1389 Patient_1618 Patient_211 ... Patient_9232

 Comparison_Indices
 [1]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE
 [13] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
 [25] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
 [37] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE  TRUE  TRUE
 [49] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE

 Sibships[Comparison_Indices]
 [1] Patient_2400 Patient_2400 Patient_345  Patient_345  Patient_8901
 [6] Patient_8901 Patient_7413 Patient_7413
 28 Levels: Patient_1212 Patient_1389 Patient_1618 Patient_211 ... Patient_9232

 The problem with this last command is that I would expect 4 levels (because 
 only 8 Comparison_Indices are true, which is equal to 4 sibships. So: 
 levels() does not take array indices into account or stated otherwise: if you 
 use a subset in an array (vector), the levels() are not properly updated (to 
 my opinion).

 What I additionally found is the following:
 small_test - factor(x=c(a, b, c))
 typeof(small_test)
 [1] integer

 The same happens to the Sibships that I defined as a factor? Why is it of 
 type integer?

 This is the version() output:
 version
   _
 platform   x86_64-unknown-linux-gnu
 arch   x86_64
 os linux-gnu
 system x86_64, linux-gnu
 status
 major  2
 minor  6.1
 year   2007
 month  11
 day26
 svn rev43537
 language   R
 version.string R version 2.6.1 (2007-11-26)


 So: should I submit a Bug report?

 Regards,

 Dr. Philip de Groot
 Wageningen 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.


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] matrix creation -- answer: data.matrix()

2008-01-29 Thread Martin Maechler
 GS == Gavin Simpson [EMAIL PROTECTED]
 on Tue, 29 Jan 2008 00:09:05 + writes:

GS hits=-2.6 tests=BAYES_00
GS X-USF-Spam-Flag: NO

GS On Mon, 2008-01-28 at 12:17 -0700, Michelle DePrenger-Levin wrote:
 I was asked for the following information and hope it might help those 
who
 could answer my question...

GS That looks fine to me Michelle. 

GS You will have problems with as.matrix on this though as a matrix in R
GS has to contain *all* elements of the same kind, text or numeric. As $X
GS is a factor, the matrix ends up as a character matrix, as this example
GS shows:

GS my.dat - data.frame(X = gl(4,5), Vegetative = runif(20), Dormant =
GS runif(20))
GS str(my.dat)
GS as.matrix(my.dat)


[...]

GS You could convert the factor column to its numeric representation and
GS then you can produce a matrix that is numeric

GS my.dat$X - as.numeric(my.dat$X)
GS str(my.dat)
GS as.matrix(my.dat)

That's exactly what the  --- seemlingy much underused ---
function
data.matrix() 
is for !

my.dat - data.frame(X = gl(4,5), Veg = runif(20), Dorm = runif(20))
my.mat - data.matrix(my.dat)
str(my.mat) # all numeric

In short:  

   Use  data.matrix(d), not as.matrix(d)  
   if d potentially is a data frame  !!

Regards,
Martin 

GS *But* you should read the help for popbio to see what you are required
GS to provide as what I show is only a workaround for the matrix issue - I
GS have no idea what a projection matrix is in the sense of popbio or how
GS to use the functions in that package.

GS HTH

GS G

 
 
 
 To import the table I used:
 
 AsMi05test=read.csv(C:/AsMi_Site05_1998.csv)
 
 
 
  str(AsMi05test)
 
 `data.frame':   12 obs. of  8 variables:
 
 $ X  : Factor w/ 6 levels Dead,Dormant,..: 5 
6 3
 4 2 1 5 6 3 4 ...
 
 $ Vegetative : num  0.25 0.50 0.17 0.08 0.00 ...
 
 $ Vegetative.with.Herbivory  : num  0.13 0.5 0.33 0.67 0 0 0.41 0.5 0 0 
...
 
 $ Reproductive   : num  0 0 0 0 0 0 0 0 0 0 ...
 
 $ Reproductive.with.Herbivory: num  0 0 0 0 0 ...
 
 $ Dormant: num  0.08 0 0.33 0.08 1 0 0.06 0 0 0 ...
 
 $ Dead   : num  0.42 0.00 0.33 0.17 0.00 ...
 
 $ End.Date   : int  1998 1998 1998 1998 1998 1998 1999 
1999
 1999 1999 ...
 
 
 
 
 
 
 
 From: Michelle DePrenger-Levin 
 Sent: Monday, January 28, 2008 11:35 AM
 To: 'r-help@r-project.org'
 Subject: matrix creation
 
 
 
 Hello,
 
 
 
 I am trying to create multiple matrices (to run a PVA) but can't import 
all
 of them from a .csv without the numbers treated as labels and not 
factors.
 
 
 
 I can enter the matrix slowly:
 
 Site05_96 - matrix(c(0.07,0,0.03,0.00,NA,0.00,
 0.09,0.16667,0.31,0.42,NA,0.00,  0.00,0,0.00,0.00,NA,0.00, 
 
 0.00,0,0.00,0.00,NA,0.00,
 0.26,0.16667,0.19,0.00,NA,0.00,  0.58,0.7,0.47,0.58,0,0.00),
 
 nrow = 6, ncol = 6, 
 
 dimnames = list(c(Vegetative, Vegetative with herbivory,
 Reproductive, 
 
 Reproductive with herbivory, Dormant, Dead),
 c(Vegetative, Vegetative with herbivory, Reproductive, 
 
 Reproductive with herbivory, Dormant, Dead)))
 
 
 
 I would like to list all matrices (for all 12 years and all 4 sites) in 
one
 Excel sheet (.csv) and then read each matrix as chucks of 6 rows. 
However,
 when I try this I either get all the values (the %) in quotes (not as
 factors) and if I try to force them with as.factor, it no longer seems 
to be
 a matrix. 
 
 
 
 AsMi0598test2 - as.matrix(AsMi05test[1:6,1:6])
 
 X Vegetative Vegetative.with.Herbivory
 Reproductive Reproductive.with.Herbivory Dormant
 
 1 Vegetative  0.25 0.130
 0 0.08 
 
 2 Vegetative with Herbivory   0.50 0.500
 0 0.00 
 
 3 Reproductive0.17 0.330
 0 0.33 
 
 4 Reproductive with Herbivory 0.08 0.670
 0 0.08 
 
 5 Dormant 0.00 0.000
 0 1.00 
 
 6 Dead0.00 0.000
 0 0.00
 
 
 
 When I add AsMi0598test2 - as.factor(as.matrix(AsMi05test[1:6,1:6])) I 
get
 this:
 
 [1] Vegetative  Vegetative with Herbivory   Reproductive
 Reproductive with Herbivory
 

Re: [R] Expert systems

2008-01-29 Thread Peter Dalgaard
Hans W. Borchers wrote:
 Ralf Finne Ralf.Finne at syh.fi writes:
   
 Hi R-users
 Is there any functions in R that can implement expert systems?
 The aim of an expert system is to produce a probable diagnosis
 for a patient with certain symptoms.
 In the classical expert system a mumber of experts are asked to make
 statements on the probabilities for different diseases when a
 combination of systems would appear.   One typical expert system
 uses Fuzzy Logic to suggest the diagnosis.

 In more modern systems one tends to make the system self learning
 to improve the system.

 

 What you are describing here is just one of several ways to realize an expert
 systems. And the question is also what kind of technique you would like to
 implement such a system in, e.g., rule-based, fuzzy sets, (Bayesian) networks,
 constraints, case bases, etc.

 The closest R may come to expert system techniques is through Weka in the 
 RWeka
 package (I should also mention 'deal' for graphical networks). R as 
 statistical
 software focuses more on the learning aspect, not on explicitly representing
 'knowledge' in whatever form.

 There are commercial and free expert system shells one could utilize. CLIPS
 http://clipsrules.sourceforge.net/ is a bit old-fashioned, but could easily 
 be
 integrated with R; JESS http://www.jessrules.com/ being another one.

 Also Prolog systems (especially if they include CSP solvers) such as BProlog 
 or
 SWI Prolog are free and could be combined (at least through file or pipe
 transfer) with R to generate complete applications.

 Regards,  Hans Werner Borchers

   
You might also want to look at gRain which Søren Højsgaard announced
yesterday.
   
 Hoping for comments
 Ralf Finne
 Swenska yrkeshögskolan
 Vasa Finland

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


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

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

2008-01-29 Thread Ralf Finne
Hi R-users
Is there any functions in R that can implement expert systems?
The aim of an expert system is to produce a probable diagnosis
for a patient with certain symptoms.
In the classical expert system a mumber of experts are asked to make
statements on the probabilities for different diseases when a
combination of systems would appear.   One typical expert system
uses Fuzzy Logic to suggest the diagnosis.

In more modern systems one tends to make the system self learning
to improve the system.

Hoping for comments
Ralf Finne
Swenska yrkeshögskolan
Vasa Finland

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] package.skeleton from within function: objects not found

2008-01-29 Thread Tineke Casneuf
Hi all,

sorry to bother you all once more, but I still haven't solved this
problem. Is there anyone who knows how to pass an environment as an
argument to package.skeleton from within function, so that this
environment can be saved into a newly build source package? See
example script below.

Many thanks in advance,
Kindest regards,

tine

On Jan 28, 2008 12:38 PM, Tineke Casneuf [EMAIL PROTECTED] wrote:
 Professor Ripley,

 do you have an idea why it works for me to save different types of
 objects, but not for the environment object I construct in the
 function:

 ###  Example of a function that works without error:

 fun2 - function(myname){
  f - function(x,y) x+y
  g - function(x,y) x-y
  d - data.frame(a=1, b=2)
  e - hello
  env - sys.frames()[[sys.nframe()]]
  package.skeleton(list=c(f,g,d,e), name=myname,env=env)
 }
 fun2(mypkg)

 

 fun3 - function(myname){
  myenv - new.env()
  apply(x, 1, function(row){
  assign(row[1], row[2], envir=myenv)
  })
  f - function(x,y) x+y
  g - function(x,y) x-y
  d - data.frame(a=1, b=2)
  e - hello
  env - sys.frames()[[sys.nframe()]]
  package.skeleton(list=c(f,g,d,e,myenv), name=myname,env=env)
 }
 fun3(mypkg)
 ###

 For the second example, 'fun3', I get this error message:

 Error in save(list = item, file = file.path(data_dir, sprintf(%s.rda,  :
object 'myenv' not found


 Thanks in advance!



 On Jan 28, 2008 9:30 AM, Prof Brian Ripley [EMAIL PROTECTED] wrote:
  You need to set the 'environment' argument (the help file is incomplete).
  e.g.
 
  env - sys.frames()[[sys.nframe()]]
  package.skeleton(name = pkgName, list=c(f,e, myenv), env=env)
 
 
 
 
 
  On Mon, 28 Jan 2008, Tineke Casneuf wrote:
 
   Hi all,
  
   I ran into a strange error: I am trying to create a package skeleton for a
   new source package from within a function. Objects that are created in 
   this
   function are to be included in my package, but for some reason, I get an
   error message saying that these objects cannot be found.
  
   Here is the code:
   ##
   myfun - function(pkgName,x){
myenv - new.env()
apply(x, 1, function(row){
  assign(row[1], row[2], envir=myenv)
})
   f - function(x,y) x+y
   e - rnorm(1000)
   # browser()
   package.skeleton(name = pkgName, list=c(f,e, myenv))
return(myenv)
   }
   x - data.frame(keys = LETTERS[1:5], values = 1:5)
   myfun(test, x)
   ##
  
   And my sessionInfo:
   sessionInfo()
   R version 2.6.1 (2007-11-26)
   i386-pc-mingw32
   locale:
   LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
   States.1252;LC_MONETARY=English_United
   States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252
   attached base packages:
   [1] stats graphics  grDevices utils datasets  methods   base
  
   I did not find anything referring to this problem in the help page, on 
   the R
   mailing list or wiki. Has anyone noticed this or can someone explain to me
   why my objects cannot be found?
  
   Many thanks in advance,
   best wishes,
  
   Tine
  
 [[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.
  
 
  --
  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] Expert systems

2008-01-29 Thread Hans W. Borchers
Ralf Finne Ralf.Finne at syh.fi writes:
 
 Hi R-users
 Is there any functions in R that can implement expert systems?
 The aim of an expert system is to produce a probable diagnosis
 for a patient with certain symptoms.
 In the classical expert system a mumber of experts are asked to make
 statements on the probabilities for different diseases when a
 combination of systems would appear.   One typical expert system
 uses Fuzzy Logic to suggest the diagnosis.
 
 In more modern systems one tends to make the system self learning
 to improve the system.
 

What you are describing here is just one of several ways to realize an expert
systems. And the question is also what kind of technique you would like to
implement such a system in, e.g., rule-based, fuzzy sets, (Bayesian) networks,
constraints, case bases, etc.

The closest R may come to expert system techniques is through Weka in the RWeka
package (I should also mention 'deal' for graphical networks). R as statistical
software focuses more on the learning aspect, not on explicitly representing
'knowledge' in whatever form.

There are commercial and free expert system shells one could utilize. CLIPS
http://clipsrules.sourceforge.net/ is a bit old-fashioned, but could easily be
integrated with R; JESS http://www.jessrules.com/ being another one.

Also Prolog systems (especially if they include CSP solvers) such as BProlog or
SWI Prolog are free and could be combined (at least through file or pipe
transfer) with R to generate complete applications.

Regards,  Hans Werner Borchers


 Hoping for comments
 Ralf Finne
 Swenska yrkeshögskolan
 Vasa Finland
 
 __
 R-help at r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] remove similar values

2008-01-29 Thread Romain Francois
Hi,

Not sure I understand the question, but maybe you need ?unique or 
?duplicated

Cheers,

Romain

mohamed nur anisah wrote:
 hello!!

   say that i have the values of x1 and x2. my x1 has longer length than x2. 
 how am i going to remove the similar values of x1 and x2.  Any suggestion?? 
 Thanks in advance!!

   Cheers,
   Anisah

   e f
  [1,]  17358865  17906353
  [2,]  17966995  21295547
  [3,]  21306539  27880531
  [4,]  27880531  34118702
  [5,]  34166504  35395488
  [6,]  36111044  36132622
  [7,]  36266288  37916920
  [8,]  36854306  43786190
  [9,]  43786190  44322336
 [10,]  44322336  46302360
 [11,]  45529444  53494622
 [12,]  46302360  62105336
 [13,]  53479132  63817440
 [14,]  58567262  72637088
 [15,]  60564442  79875476
 [16,]  72637088  94545992
 [17,]  79875476  96506368
 [18,]  93155112 103123936
 [19,]  94372260 116908456
 [20,]  96643396 126190072
 [21,] 103123936 127446552
 [22,] 116908456 131781664
 [23,] 131781664 154658264
 [24,] 132968364 176302744
 [25,] 135945080 181670472
 [26,] 141788832 182625272
 [27,] 149924864 182878168
 [28,] 156539568 183946152
 [29,] 157817896NA
 [30,] 162399496
   [31,] 168344072  
   [32,] 173146584  
   [33,] 176302744  
   [34,] 182878168  
   [35,] 183946152  
   [36,] 185068720  
   [37,] 190791232  
   [38,]NA 
--
Introduction to R training course :: London :: 06-07 March 2008
http://www.mango-solutions.com/services/rtraining/r_intro.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] remove similar values

2008-01-29 Thread Peter Dalgaard
Romain Francois wrote:
 Hi,

 Not sure I understand the question, but maybe you need ?unique or 
 ?duplicated
   

 Or maybe ?union, ?setdiff, ?intersection. Or ?merge.


 Cheers,

 Romain

 mohamed nur anisah wrote:
   
 hello!!

   say that i have the values of x1 and x2. my x1 has longer length than x2. 
 how am i going to remove the similar values of x1 and x2.  Any suggestion?? 
 Thanks in advance!!

   Cheers,
   Anisah

   e f
  [1,]  17358865  17906353
  [2,]  17966995  21295547
  [3,]  21306539  27880531
  [4,]  27880531  34118702
  [5,]  34166504  35395488
  [6,]  36111044  36132622
  [7,]  36266288  37916920
  [8,]  36854306  43786190
  [9,]  43786190  44322336
 [10,]  44322336  46302360
 [11,]  45529444  53494622
 [12,]  46302360  62105336
 [13,]  53479132  63817440
 [14,]  58567262  72637088
 [15,]  60564442  79875476
 [16,]  72637088  94545992
 [17,]  79875476  96506368
 [18,]  93155112 103123936
 [19,]  94372260 116908456
 [20,]  96643396 126190072
 [21,] 103123936 127446552
 [22,] 116908456 131781664
 [23,] 131781664 154658264
 [24,] 132968364 176302744
 [25,] 135945080 181670472
 [26,] 141788832 182625272
 [27,] 149924864 182878168
 [28,] 156539568 183946152
 [29,] 157817896NA
 [30,] 162399496
   [31,] 168344072  
   [32,] 173146584  
   [33,] 176302744  
   [34,] 182878168  
   [35,] 183946152  
   [36,] 185068720  
   [37,] 190791232  
   [38,]NA 
 
 --
 Introduction to R training course :: London :: 06-07 March 2008
 http://www.mango-solutions.com/services/rtraining/r_intro.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.
   


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

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

2008-01-29 Thread Rainer Hurling
--
X-USF-Spam-Status: hits=-2.5 tests=BAYES_00,FORGED_RCVD_HELO
X-USF-Spam-Flag: NO

Am 29.01.2008 00:04 (UTC+1) schrieb Roger Bivand:
 On Mon, 28 Jan 2008, Rainer Hurling wrote:
 
 Roger,

 I tried your suggestions and ran into same problems as Pieter did before.

 
 Rainer:
 
 I don't think that we know what platform Pieter was using, apart from the 
 working directory that looked like Windows, and where the problem could 
 not be reproduced. I note that yours is FreeBSD 8, and I agree, the .C() 
 interface to the small helper function should most likely be replaced by a 
 .Call() to make handling the file name more robust. Can I send a modified 
 version off-list tomorrow, since I have no access to your platform 
 otherwise? Is readOGR() in rgdal working, by the way?
 

Roger,

cities - readOGR(./R\ scripts, cities)

works well for me.

Rainer



 Roger
 
 On 28.01.2008 12:35 (UTC+1), Roger Bivand wrote:
   pieterprovoost at gmail.com writes:

  No, I get the same error message there...
  Please do not needlesly delete the thread content. Your original question
  was:

  I'm having problems reading a shapefile with read.shape (maptools). I'm
  absolutely sure my file is there, but I get no such file. The wd is ok,
  since read.table for example does find the file.

 For testing I copied /usr/local/lib/R/library/rgdal/vectors/cities.shp into 
 /usr/home/rhurlin/TEMP/Rscripts/

  getwd()
  [1] D:/somedirectory/R scripts
 [1] /usr/home/rhurlin/TEMP/Rscripts

  read.table(cities.shp)
  Error in read.table(cities.shp) : empty beginning of file
  In addition: Warning message:
  In read.table(cities.shp) :
incomplete final line found by readTableHeader on 'cities.shp'

  which is self-explanatory, because you were not using read.shape() anyway.

  You continued:

   read.shape(cities.shp)
  Error in getinfo.shape(filen) : No such file
 Fehler in getinfo.shape(filen) : No such file

  but did not respond to the suggestion from an R-helper with the output
  from:

  readShapePoly(cities.shp)
 Fehler in getinfo.shape(filen) : No such file

  Try list.files(pattern=shp$) to see whether your assumption that the
  files are
  where you think they are, is justified.
 [1] cities.shp

  Then get back with the output of

  getinfo.shape(cities.shp)
 Fehler in getinfo.shape(cities.shp) : No such file

  If you want to, you can use file.choose() to choose the file
  interactively.

  If you haven't solved this yourself by then (found the files youself), do
  remember to include the verbatim output of sessionInfo() too.
 R version 2.6.1 (2007-11-26)
 i386-unknown-freebsd8.0 # This is 8.0-CURRENT from yesterday

 locale:
 de_DE.ISO8859-15/de_DE.ISO8859-15/de_DE.ISO8859-15/C/de_DE.ISO8859-15/de_DE.ISO8859-15

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

 other attached packages:
 [1] maptools_0.7-4 sp_0.9-19  foreign_0.8-23 proto_0.3-8

 loaded via a namespace (and not attached):
 [1] ggplot2_0.5.7   lattice_0.17-4  rcompgen_0.1-17

  Roger Bivand

 It seems, that the C call of 'Rshapeinfo' makes trouble on my system. 
 Rshapeinfo.c tries to open the shapefile with the following code:

 hSHP = SHPOpen( shpnm[0], rb );

 If I did not misunderstood, this returns NULL on my system.

 I have almost no C programming skills, so I am not able to understand the 
 code enough.

 Could something be wrong in using 'gettext'? (GNU gettext-runtime 0.16.1)

 Hope this helps a bit,
 Rainer




__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Correlation matrix for data in long format

2008-01-29 Thread Serguei Kaniovski
Hello,

I cannot figure out how to use tapply to compute the correlation matrix 
in the variable x between the states? The data is in long format, e.g.:

state,year,x
Alabama,2001,0.45
Alabama,2002,0.47
Alabama,2003,0.48
Alabama,2004,0.44
Arizona,2001,0.34
Arizona,2002,0.32
Arizona,2003,0.38
Arizona,2004,0.36

Thank you in advance for your help,
Serguei Kaniovski

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

2008-01-29 Thread Werner Wernersen
Hi,

sqldf sounds like a very useful package but I don't
even get the example to run:
 a1s  -  sqldf(select  *  from  warpbreaks  limit 
6)
Error in combine(FUN(...)) : argument value is
missing, with no default


I am using R 2.6.1 on Windows Vista Business and have
updated all packages.

Some help would be very much appreciated.

Many thanks, 
   Werner

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

2008-01-29 Thread Gabor Grothendieck
I can't reproduce your error:

 library(sqldf)
 sqldf(select  *  from  warpbreaks  limit 6)
  breaks wool tension
1 26A   L
2 30A   L
3 54A   L
4 25A   L
5 70A   L
6 52A   L
 R.version.string # Vista
[1] R version 2.6.2 alpha (2008-01-26 r44181)

A few things to try:

1. maybe you have some other package loaded that is interfering?  The error
occurs in 'combine' but combine is not a function in sqldf nor in RSQLite, DBI
or proto -- the packages on which it depends.  Try it from a new session.  Be
sure you don't have an .Rprofile file that is loading other packages.

Rgui --vanilla
library(sqldf)
sqldf(...command...)

2. Try issuing the source statement in example 6 on the sqldf home page first
(that will get you the development version) and try that.  I doubt that will
solve it but its worth a try. http://sqldf.googlecode.com




On Jan 29, 2008 5:58 AM, Werner Wernersen [EMAIL PROTECTED] wrote:
 Hi,

 sqldf sounds like a very useful package but I don't
 even get the example to run:
  a1s  -  sqldf(select  *  from  warpbreaks  limit
 6)
 Error in combine(FUN(...)) : argument value is
 missing, with no default
 

 I am using R 2.6.1 on Windows Vista Business and have
 updated all packages.

 Some help would be very much appreciated.

 Many thanks,
   Werner

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

2008-01-29 Thread Attiglah, Mama
A = read.table(clipboard, header=TRUE)
 A
  sex   age region no_of_accidents
1   F young  north  10
2   F young  south  12
3   F   old  north   5
4   F   old  south   7
5   M young  north  24
6   M young  south  30
7   M   old  north  12
8   M   old  south  17





sum(A$no_of_accidents[which( A$sex==F)])

should give you the required sum. 

You have to remember that sex, age and region are Factors with their
respective levels and no_of_accidents is a numeric vector.

Do str( A) to see their type.
Hope that helps.

Mama 

-
Mama Attiglah, PhD
Advanced Research Center 
Quantitative Research Analyst 
State Street Bank
+44(0)20 7698 6290 (Direct Line)
+44 (0)207 004 2968 (Direct Fax)
Please visit our Web site at 
www.ssga.com

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of [EMAIL PROTECTED]
Sent: 29 January 2008 12:05
To: r-help@r-project.org
Subject: [R] pivot table in R

Hello,

I'm struggling with an elementary problem with R. I have a simple data 
frame such as this one giving the number of accidents subdivided by sex,

age and region.

sex age region  no_of_accidents

F   young   north   10
F   young   south   12
F   old north   5
F   old south   7
M   young   north   24
M   young   south   30
M   old north   12
M   old south   17

and I would like to build a pivot table, e.g. obtaining the sum of the 
number of accidents for each sex:

sex age region  no_of_accidents

F   (any)   (any)   34
M   (any)   (any)   83

but I can't seem to obtain this result simply in R, except by embarking
in 
complicated for loops.

I have checked the documentation on such functions as table() and the 
documentation on An introduction to R but couldn't solve the problem. 
Could you please help me with this?

Cheers

Pete


PLEASE CONSIDER THE ENVIRONMENT BEFORE PRINTING THIS E-MAIL

For Aon's standard conditions associated with this e-mail please visit
http://www.aon.com/uk/en/email-footer/aon-limited.jsp
Aon Limited
Registered Office: 8 Devonshire Square, London EC2M 4PL
Registered in London No. 210725 . VAT Registration No. 480 8401 48

Aon Limited is authorised and regulated by the Financial Services
Authority in respect of insurance mediation activities only.

[[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] pivot table in R

2008-01-29 Thread Romain Francois
Hi Pietro,

Depending on the actual structure you want in the output, you can use 
some of the functions in the apply family, particularly tapply, 
aggregate, or by. Something like :

R tapply( d[[no_of_accidents ]], d[[ sex ]], sum )
F M
34 83

R aggregate( d[no_of_accidents ], d[ sex ], sum )
sex no_of_accidents
1 F 34
2 M 83

R by( d[[no_of_accidents ]], d[[ sex ]], sum )
INDICES: F
[1] 34

INDICES: M
[1] 83

Cheers,

Romain

-- 
Mango Solutions
data analysis that delivers

R for finance training course :: 3 days :: London (27-29/02/2008)
http://www.mango-solutions.com/services/rtraining/r_finance.html


[EMAIL PROTECTED] wrote:
 Hello,

 I'm struggling with an elementary problem with R. I have a simple data 
 frame such as this one giving the number of accidents subdivided by sex, 
 age and region.

 sex age region  no_of_accidents

 F   young   north   10
 F   young   south   12
 F   old north   5
 F   old south   7
 M   young   north   24
 M   young   south   30
 M   old north   12
 M   old south   17

 and I would like to build a pivot table, e.g. obtaining the sum of the 
 number of accidents for each sex:

 sex age region  no_of_accidents

 F   (any)   (any)   34
 M   (any)   (any)   83

 but I can't seem to obtain this result simply in R, except by embarking in 
 complicated for loops.

 I have checked the documentation on such functions as table() and the 
 documentation on An introduction to R but couldn't solve the problem. 
 Could you please help me with this?

 Cheers

 Pete


 PLEASE CONSIDER THE ENVIRONMENT BEFORE PRINTING THIS E-MAIL

 For Aon’s standard conditions associated with this e-mail please visit 
 http://www.aon.com/uk/en/email-footer/aon-limited.jsp
 Aon Limited
 Registered Office: 8 Devonshire Square, London EC2M 4PL
 Registered in London No. 210725 . VAT Registration No. 480 8401 48

 Aon Limited is authorised and regulated by the Financial Services Authority 
 in respect of insurance mediation activities only.

   [[alternative HTML version deleted]]



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


[R] how do i creat multiple back to back histograms?

2008-01-29 Thread Tom Willems
 dear R-ussers,
I would like to creeate a graph, i wich  my data is presented as verticaly 
oriented histograms, wich give the frequency of the measured values, 
grouped per used measurement methode.
So the X axis should hold the grouping variable and the Y axis a continuos 
variable. well not realy continouse, but it should show the values, 
representing the clase intervals.
small example to clarify this:
This one i can create: graph 1
only the positive results per test
5  |  ##|#|##  
|  #  |##  |#
4  |  ###  |  |
|  |##  |##
3  |  ###  |#|
|  #  |###|#
2  |  |  |##
|  ###  |##  |#
1  |  #  |#|##
|_|_|_
0test 1test2test3
Tihs is what i want to create: graph 2
a back to back histogram plot of the pos/negative results, grouped per 
test
5  |  |##  |#  
|##  
|  |#|##
#|#
4  |  |###|  ##|

| .|..|## 
...#|##..
3  |#|###  #|#|
|  ##|###|#####|#
2  
|#|..|..##|##..
|###|#####|#####|#
1  |  ##|#  #|#|##
|___|__#|#|_
0test 1test2test3
   Neg. |  Pos.Neg. |  Pos. Neg. |  Pos.


I 'd like to creat the figure of graph 2, a back to back plot of the pos/ 
and negative results of a test,
and this with the 3 tests in one graf.

I have been searching for examples,  the only trouble is that it is way to 
complex.
(http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=109)
Here is one other example of a back to back plot (graph 2) .
(histbackback(fool)

After trying to understand wath happens in the complex example, i 
identified a part that does what i need.
It does creat the graph similar to what i want (graph 1).  see code 
below 
Yet i do not understand it wel enough,so i can't creat the more complex 
graph 2.
What can i do to understand this graph functions beter, without spending 
to much time on them?

Kind regards,
Tom.

this is the code, wich i use to creat graph 1
# data for plot:

freqs - data.frame(value= c( 
0.000,1.204,1.301,1.362,1.447,1.505,1.602,1.653,1.756,1.806,1.903,1.959,
  2.053,2.107,2.204,2.258,2.354,2.408,2.505,2.559,2.656,2.709,2.806) ,
  tp1= c( 8,1,0,13,0,6,0,25,0,5,0,15,0,4,0,7,0,0,0,1,0,0,0)  ,
  tn1= c( 17,0,0,2,0,0,0,1,0,2,0,1,0,0,0,0,0,0,0,0,0,0,0),
  tp2= c( 10,0,2,0,9,0,8,0,19,0,4,0,5,0,2,0,5,0,2,0,1,0,2)   ,
  tn2= c( 13,0,1,0,1,0,2,0,2,0,0,0,2,0,0,0,0,0,0,0,0,0,0),
  tp3= c( 9,0,0,0,0,0,0,0,0,10,0,10,0,21,0,10,0,11,0,8,0,5,0),
  tn3= c( 15,0,0,0,0,0,0,0,0,3,0,2,0,2,0,1,0,0,0,0,0,0,0))

 test-c(1,2,3,4,5,6)
testname -c('test1 p','test1 n','test2 p','test2 n','test3 p','test3 n')  
 


# parameters for plot 
 xlim = c(min(test),max(test))
 ylim = c(0,length(freqs$value))
 barscale = 0.2
 barcol = 8
 # plot 
 win.graph() 
 for (i in 1:length(freqs))
  {
 par(new = TRUE)
 xmin - -test[i] + xlim[1]
 xmax - xlim[2] - test[i]
 ser - freqs[, i+1]
 ser - ser/max(ser) * barscale
 barplot(ser, horiz = TRUE, axes = FALSE, xlim = c(xmin, 
xmax),
 ylim = ylim, col = barcol, space = 0)
}
 axis(1,labels=testname,at=c(0,0.2,0.4,0.6,0.8,1))
 axis(2,labels=freqs$value ,at=c((0:22)/23) )

this is the code, wich i hoped would creat graph 2 but it doesn't work

for (i in 1:length(freqs))
  {
 par(new = TRUE)
 xmin - -test[i] + xlim[1]
 xmax - xlim[2] - test[i]
 serx - freqs[, i+1]
 sery - freqs[, i+2]
 ser - list((serx/sum(serx) * barscale),(sery/sum(sery) * 
barscale))
 histbackback(ser,axes=FALSE ,xlim = c(xmin, xmax), ylim = 
ylim)
}



E-mail: [EMAIL PROTECTED]









Disclaimer: click here
[[alternative HTML version deleted]]

__
R-help@r-project.org 

Re: [R] Form Pairs of Variables for a paired t-test

2008-01-29 Thread nalluri pratap
Thanks a lot! Its working fine
   
  Pratap

Henrique Dallazuanna [EMAIL PROTECTED] wrote:
  Try this:

lapply(apply(combn(ncol(x),2), 2, function(y)x[,y]),
function(z)t.test(z[,1], z[,2]))

On 29/01/2008, nalluri pratap 
wrote:
 Hi Users,

 This is regarding the paired t-test. I have 5 variables (say) 
 Data$v1,Data$v2,Data$v3,Data$v4,Data$v5 in my data frame. Now, I need to 
 perform a paired t-test on all the possible 10 pairs.How do I set up the 
 pairs table directly and pass those variables in to t-test.

 Thanks in advance,

 Pratap


 -
 Now you can chat without downloading messenger. Click here to know how.
 [[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.



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


   
-
 Bring your gang together - do your thing.  Start your group.
[[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] Fortunes - was Re: [OT] vernacular names for circular diagrams

2008-01-29 Thread S Ellison
 Gabor Grothendieck [EMAIL PROTECTED] 29/01/2008 12:35:27

 As is common in human affairs, even
 the illusion of understanding is preferred to a lofty digression
upon
 why the audience does not understand.

Gabor,

This should be in fortunes; it is depressingly accurate.
But it doesn't have to be a lofty digression.

S



***
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] How to get two y-axises in a bar plot?

2008-01-29 Thread Gustaf Granath
Hi,
I have measured two response variables (y1, y2) at each treatment level 
(x = 0, 1.5 or 3). Now I would like to show the y1 and y2 against x in a 
bar plot. However, y1 and y2 differ in scale so I need two y-axises, one 
on the left side and one on the right side (and I dont want to 
standardize my responses). This is fairly easy if you want to show 
points,lines etc, but gets more complicated with bars.Although these 
kind of bar graphs are quite common, I have found very limited 
information about how to do them in R. I have been struggling with the 
barplot() command. My problem is that the bars for y1 and y2 end up at 
the same place (blocking each other) and not beside each other when I 
use par(new=TRUE). Is there a way to separate them so y1 and y2 are 
placed beside each other at each x level, or is this easier to do this 
with lattice?? I would also like to add error bars but I guess that 
should not be a problem.

For code and data, see below.

Cheers,

Gustaf Granath, phd student

My code so far:
#Creating data
c(6.34,13.38,17.87)-y1
c(0.85,1.88,2.33)-y2
c(0,1.5,3)-x
cbind(y1,y2,x)-mydata
data.frame(mydata)-mydata
with(mydata, tapply(y1,x,mean))-mean.y1
with(mydata, tapply(y2,x,mean))-mean.y2
#Barplot
par(mar=c(5,4,4,4)+0,1)
barplot(mean.y1,density=1,las=1)
par(new=T)
barplot(mean.y2,density=3,angle=3,axes=F)
axis(4,las=1)

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


Re: [R] pivot table in R

2008-01-29 Thread John Kane
Have a look at the reshape package. With your data as
data.frame xx :

library(reshape)

dd - melt(xx, id=c(sex, age,
region),measured=c(no_of_accidents)); dd

cast(dd, sex~variable, sum)


--- [EMAIL PROTECTED] wrote:

 Hello,
 
 I'm struggling with an elementary problem with R. I
 have a simple data 
 frame such as this one giving the number of
 accidents subdivided by sex, 
 age and region.
 
 sex age region  no_of_accidents
 
 F   young   north   10
 F   young   south   12
 F   old north   5
 F   old south   7
 M   young   north   24
 M   young   south   30
 M   old north   12
 M   old south   17
 
 and I would like to build a pivot table, e.g.
 obtaining the sum of the 
 number of accidents for each sex:
 
 sex age region  no_of_accidents
 
 F   (any)   (any)   34
 M   (any)   (any)   83
 
 but I can't seem to obtain this result simply in R,
 except by embarking in 
 complicated for loops.
 
 I have checked the documentation on such functions
 as table() and the 
 documentation on An introduction to R but couldn't
 solve the problem. 
 Could you please help me with this?
 
 Cheers
 
 Pete
 
 
 PLEASE CONSIDER THE ENVIRONMENT BEFORE PRINTING THIS
 E-MAIL
 
 For Aon’s standard conditions associated with this
 e-mail please visit

http://www.aon.com/uk/en/email-footer/aon-limited.jsp
 Aon Limited
 Registered Office: 8 Devonshire Square, London EC2M
 4PL
 Registered in London No. 210725 . VAT Registration
 No. 480 8401 48
 
 Aon Limited is authorised and regulated by the
 Financial Services Authority in respect of insurance
 mediation activities only.
 
   [[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] number of rescaling cycles in decorana

2008-01-29 Thread Marc Belisle
How do one dertermine the optimal number of rescaling cycles to use when
performing DCA using the decorana function (library vegan)?

Thanks for your time,

Marc

===
Marc Bélisle
Professeur adjoint
Chaire de recherche du Canada en écologie spatiale et en écologie du paysage
Département de biologie
Université de Sherbrooke
2500 Boul. de l'Université
Sherbrooke, Québec
J1K 2R1 Canada

Tél: +1-819-821-8000 poste 61313
Fax: +1-819-821-8049
Courriél: [EMAIL PROTECTED]

[[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] pivot table in R

2008-01-29 Thread Christos Hatzis
Also, see ?aggregate:

 with(A, aggregate(no_of_accidents, by=list(SEX=sex), FUN='sum'))
  SEX  x
1   F 34
2   M 83 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Attiglah, Mama
 Sent: Tuesday, January 29, 2008 7:21 AM
 To: [EMAIL PROTECTED]; r-help@r-project.org
 Subject: Re: [R] pivot table in R
 
 A = read.table(clipboard, header=TRUE)
  A
   sex   age region no_of_accidents
 1   F young  north  10
 2   F young  south  12
 3   F   old  north   5
 4   F   old  south   7
 5   M young  north  24
 6   M young  south  30
 7   M   old  north  12
 8   M   old  south  17
 
 
 
 
 
 sum(A$no_of_accidents[which( A$sex==F)])
 
 should give you the required sum. 
 
 You have to remember that sex, age and region are Factors 
 with their respective levels and no_of_accidents is a numeric vector.
 
 Do str( A) to see their type.
 Hope that helps.
 
 Mama 
 
 -
 Mama Attiglah, PhD
 Advanced Research Center
 Quantitative Research Analyst
 State Street Bank
 +44(0)20 7698 6290 (Direct Line)
 +44 (0)207 004 2968 (Direct Fax)
 Please visit our Web site at
 www.ssga.com
 
 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED]
 On Behalf Of [EMAIL PROTECTED]
 Sent: 29 January 2008 12:05
 To: r-help@r-project.org
 Subject: [R] pivot table in R
 
 Hello,
 
 I'm struggling with an elementary problem with R. I have a 
 simple data frame such as this one giving the number of 
 accidents subdivided by sex,
 
 age and region.
 
 sex age region  no_of_accidents
 
 F   young   north   10
 F   young   south   12
 F   old north   5
 F   old south   7
 M   young   north   24
 M   young   south   30
 M   old north   12
 M   old south   17
 
 and I would like to build a pivot table, e.g. obtaining the 
 sum of the number of accidents for each sex:
 
 sex age region  no_of_accidents
 
 F   (any)   (any)   34
 M   (any)   (any)   83
 
 but I can't seem to obtain this result simply in R, except by 
 embarking in complicated for loops.
 
 I have checked the documentation on such functions as 
 table() and the documentation on An introduction to R but 
 couldn't solve the problem. 
 Could you please help me with this?
 
 Cheers
 
 Pete
 
 
 PLEASE CONSIDER THE ENVIRONMENT BEFORE PRINTING THIS E-MAIL
 
 For Aon's standard conditions associated with this e-mail 
 please visit http://www.aon.com/uk/en/email-footer/aon-limited.jsp
 Aon Limited
 Registered Office: 8 Devonshire Square, London EC2M 4PL 
 Registered in London No. 210725 . VAT Registration No. 480 8401 48
 
 Aon Limited is authorised and regulated by the Financial 
 Services Authority in respect of insurance mediation activities only.
 
   [[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] on trellis.par.set/get (reproducing figures from Pinheiro Bates)

2008-01-29 Thread Dr. Ottorino-Luca Pantani
Dear R users,
I would like to exactly reproduce a figure like the 1.5 or 1.9 or 4.13 
from the book
Mixed effects models in S and S-Plus.
Not for the sake of it, but because I have my own data I would like to 
plot in that fashion
(no colors)


If I write

plot(ergoStool)

I can get a good informative plot with colors, but I would like to have 
a BW one instead.

I've played a little with trellis.par.set
managing to change some aspect of the appearance of the plot,
for example with

prove.theme-
  list(
   dot.line = list(col = 1, lty = 3, lwd = 1),
   fontsize = list(text = 12, points = 10)
 )
trellis.par.set(prove.theme)
plot(ergoStool)

I also queried trellis.par.get by

names(trellis.par.get())

but still I'm not able to figure out which are the parameters, if any,
that control pch and col of the symbols.

Any help is highly appreciated.

-- 
Ottorino-Luca Pantani, Università di Firenze
Dip. Scienza del Suolo e Nutrizione della Pianta
P.zle Cascine 28 50144 Firenze Italia
Tel 39 055 3288 202 (348 lab) Fax 39 055 333 273 
[EMAIL PROTECTED]  http://www4.unifi.it/dssnp/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 generate sequence a - z

2008-01-29 Thread Barry Rowlingson
Bernd Weiss wrote:
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1
 
 skestin schrieb:
 | I suppose it's very simple but I can't find the way to generate a
 sequence of
 | characters, e.g. from a to z.
 | Could you please help me with this?
 
 ?letters
 letters
 

  letters is okay for just that sequence, or parts of it, but might 
not be general enough for the original poster...

  I just discovered 'charToInt' and 'intToChar' in the R.oo package:

   intToChar(65:68)
  [1] A B C D

  Then you can define cseq:

   cseq =
  function(from,to,by=1){
  from=charToInt(from)
  to=charToInt(to)
  intToChar(seq(from,to,by))
  }

  and do:
   cseq('A','G')
   [1] A B C D E F G
   cseq('A','G',2)
   [1] A C E G
   cseq('a','A',-2)
   [1] a _ ] [ Y W U S Q O M K I G E C A

  Note this uses ASCII codes and not whatever your language alphabet is.

  I'd overload ':' for this and then you could do 'a':'z', but ':' heads 
into .Primitive territory...

Barry

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


Re: [R] how to generate sequence a - z

2008-01-29 Thread Duncan Murdoch

On 1/29/2008 7:39 AM, skestin wrote:

I suppose it's very simple but I can't find the way to generate a sequence of
characters, e.g. from a to z.
Could you please help me with this?


If you want the standard collation sequence, use the letters variable, 
as others have said.


If you want the sequence that applies in your locale (where does ü 
fall?), it's harder.  I don't know a simple way, but this gives you 
collation order in the German locale in Windows:


 x - as.raw(32:255)
 y - readChar(x, rep(1, 224))
 Sys.setlocale(LC_COLLATE, German)
[1] German_Germany.1252
 sort(y)
  [1] \177 �����'-­–
 [11] —  !\   #$%(
 [21] )*,./:;?@[
 [31] \\   ]^ˆ_`{|}~
 [41] ¡¦¨¯´¸¿˜‘’
 [51] ‚“”„‹›+=
 [61] ±«»×÷¢£¤¥§
 [71] ©¬®°µ¶·†‡•
 [81] …‰€0¼½¾1¹2
 [91] ²3³456789a
[101] AªáÁàÀâÂäÄ
[111] ãÃåÅæÆbBcC
[121] çÇdDðÐeEéÉ
[131] èÈêÊëËfFƒg
[141] GhHiIíÍìÌî
[151] ÎïÏjJkKlLm
[161] MnNñÑoOºóÓ
[171] òÒôÔöÖõÕøØ
[181] œŒpPqQrRsS
[191] šŠßtTþÞ™uU
[201] úÚùÙûÛüÜvV
[211] wWxXyYýÝÿŸ
[221] zZžŽ

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

2008-01-29 Thread Richard Longland
Hi,

Although I understand how to use expression and paste to add
superscripts and symbols to my graphs, I have a problem with adding
superscripts to an existing string.

For example, I read in the following from a separate file:
25Mg(p,g)

I want to convert that to superscripts etc. (in LaTex format):
$^{25}$Mg(p,$\gamma$)

This needs to then be put into a graph title.

Any ideas? I know that I can just write it in using expression and
paste, but the title is read in from a separate file.

Cheers for the help,
Richard longland

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

2008-01-29 Thread pellegrini
Hello everybody,

There is something that I do not get with scale function.

Say that I have a vector v - c(1,2,3,4,5,6),

scale(v,center=TRUE,scale=TRUE) gives a new vector with 0 as mean and 1 
as standard deviation.

but,

scale(v, center=FALSE,scale=TRUE) gives a new vector with a standard  
deviation different from 1.

I would also expect a standard deviation of 1 in that case.

am I wrong ?

thanks

Eric Pellegrini

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Guidance for reporting results from lme test?

2008-01-29 Thread Ronny Steen

Hello,
 
I have sucsessfully used a linear mixed effect model, lme, (REML). The results 
are satisfactory, but I have problems with sorting out how to report the result 
in a scientific paper.
 
Is there a genearal guidance for reporting lme results available (web page, 
book or article)?
 
Best regards 
 
Ronny
 
_


[[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] pivot table in R

2008-01-29 Thread David Winsemius
[EMAIL PROTECTED] wrote in
news:[EMAIL PROTECTED]
k: 

Three or four solutions have already been offered. Here is (yet) 
another:

 Atxt - 
+   sex   age region no_of_accidents
+ 1   F young  north  10
+ 2   F young  south  12
+ 3   F   old  north   5
+ 4   F   old  south   7
+ 5   M young  north  24
+ 6   M young  south  30
+ 7   M   old  north  12
+ 8   M   old  south  17
 
 A - read.table(textConnection(Atxt), header=TRUE)

 Asex - xtabs(no_of_accidents ~ sex, data=A)
 Asex
sex
 F  M 
34 83 

xtabs() returns an object of class = contingency table. This may have 
added advantage if you are using statistical function which expect such 
an object. Using a formula based function also lets you quickly expand 
the analysis.

 Asexreg - xtabs(no_of_accidents ~ sex+region, data=A)
 Asexreg
   region
sex north south
  F1519
  M3647

-- 
David Winsemius

 Hello,
 
 I'm struggling with an elementary problem with R. I have a simple
 data frame such as this one giving the number of accidents
 subdivided by sex, age and region.
 
 sex age region  no_of_accidents
 
 F   young   north   10
 F   young   south   12
 F   old north   5
 F   old south   7
 M   young   north   24
 M   young   south   30
 M   old north   12
 M   old south   17
 
 and I would like to build a pivot table, e.g. obtaining the sum of
 the number of accidents for each sex:
 
 sex age region  no_of_accidents
 
 F   (any)   (any)   34
 M   (any)   (any)   83

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

2008-01-29 Thread Werner Wernersen
I cleaned up the environment and restarted everything
and it does work. But I have no idea what it is what
is different now. Anyway, it works!

Thanks a lot Gabor!

Best,
  Werner

 I can't reproduce your error:
 
  library(sqldf)
  sqldf(select  *  from  warpbreaks  limit 6)
   breaks wool tension
 1 26A   L
 2 30A   L
 3 54A   L
 4 25A   L
 5 70A   L
 6 52A   L
  R.version.string # Vista
 [1] R version 2.6.2 alpha (2008-01-26 r44181)
 
 A few things to try:
 
 1. maybe you have some other package loaded that is
 interfering?  The error
 occurs in 'combine' but combine is not a function in
 sqldf nor in RSQLite, DBI
 or proto -- the packages on which it depends.  Try
 it from a new session.  Be
 sure you don't have an .Rprofile file that is
 loading other packages.
 
 Rgui --vanilla
 library(sqldf)
 sqldf(...command...)
 
 2. Try issuing the source statement in example 6 on
 the sqldf home page first
 (that will get you the development version) and try
 that.  I doubt that will
 solve it but its worth a try.
 http://sqldf.googlecode.com
 
 
 
 
 On Jan 29, 2008 5:58 AM, Werner Wernersen
 [EMAIL PROTECTED] wrote:
  Hi,
 
  sqldf sounds like a very useful package but I
 don't
  even get the example to run:
   a1s  -  sqldf(select  *  from  warpbreaks 
 limit
  6)
  Error in combine(FUN(...)) : argument value is
  missing, with no default
  
 
  I am using R 2.6.1 on Windows Vista Business and
 have
  updated all packages.
 
  Some help would be very much appreciated.
 
  Many thanks,
Werner
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/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 needed on Normality test

2008-01-29 Thread Megh Dal
Hi all T gurus,
   
  I would like to test if my dataset is indeed from N(0, 0.011908969).
   
  K.S. test gives following result:
   
   ks.test(data, pnorm, 0, 0.011908969)
  One-sample Kolmogorov-Smirnov test
  data:  data 
D = 0.1092, p-value = 1.318e-05
alternative hypothesis: two-sided 

  How ever Shapiro-Wilk test give following :
   shapiro.test(data)
  Shapiro-Wilk normality test
  data:  data 
W = 0.9946, p-value = 0.07562

  also, 
   
   sd(data)
[1] 0.01625074

  2nd test saying data is from normal however 1st isnot. Which one is correct? 
Am I missing something?
   
  Regards,

   
-

[[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] Form Pairs of Variables for a paired t-test

2008-01-29 Thread nalluri pratap
Hi Users,
   
  This is regarding the paired t-test. I have 5 variables (say) 
Data$v1,Data$v2,Data$v3,Data$v4,Data$v5 in my data frame. Now, I need to 
perform a paired t-test on all the possible 10 pairs.How do I set up the pairs 
table directly and pass those variables in to t-test.
   
  Thanks in advance,
   
  Pratap

   
-
 Now you can chat without downloading messenger. Click here to know how.
[[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] regression - cluster option in STATA - what in R?

2008-01-29 Thread Niels Steen Krogh
My phd-student works in stata using cluster option in a regression model like
this example: 
(from link: http://www.ats.ucla.edu/stat/stata/faq/clusterreg.htm)

/* model 2 -- same as svy: regress with psu */

regress math homework, cluster(schid)


I need to put som extra blinded data into the same model using R.
This cluster option. Is there something in R for this?


/Thanks 


Niels Steen Krogh
Konsulent
ZiteLab ApS 

Mail: -- [EMAIL PROTECTED]
Telefon: --- +45 38 88 86 13
Mobil: - +45 22 67 37 38
Adresse: --- ZiteLab ApS 
 Solsortvej 44
 dk - 2000 F.
--- og --- 
 ZiteLab ApS
 Refshalevej 110a
 dk - 1432 københavn k

Web: --- www.zitelab.dk
CVR: --- 29178364
Bank: -- Sparbank Vest
 
Ejer: -- ZSRK Group Holding

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

2008-01-29 Thread pietro . parodi
Hello,

I'm struggling with an elementary problem with R. I have a simple data 
frame such as this one giving the number of accidents subdivided by sex, 
age and region.

sex age region  no_of_accidents

F   young   north   10
F   young   south   12
F   old north   5
F   old south   7
M   young   north   24
M   young   south   30
M   old north   12
M   old south   17

and I would like to build a pivot table, e.g. obtaining the sum of the 
number of accidents for each sex:

sex age region  no_of_accidents

F   (any)   (any)   34
M   (any)   (any)   83

but I can't seem to obtain this result simply in R, except by embarking in 
complicated for loops.

I have checked the documentation on such functions as table() and the 
documentation on An introduction to R but couldn't solve the problem. 
Could you please help me with this?

Cheers

Pete


PLEASE CONSIDER THE ENVIRONMENT BEFORE PRINTING THIS E-MAIL

For Aon’s standard conditions associated with this e-mail please visit 
http://www.aon.com/uk/en/email-footer/aon-limited.jsp
Aon Limited
Registered Office: 8 Devonshire Square, London EC2M 4PL
Registered in London No. 210725 . VAT Registration No. 480 8401 48

Aon Limited is authorised and regulated by the Financial Services Authority in 
respect of insurance mediation activities only.

[[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] [OT] vernacular names for circular diagrams

2008-01-29 Thread Jim Lemon
Rolf Turner wrote:
 ...
 I have been for many years under the impression that the pie chart
 was invented by Florence Nightingale.  Am I misinformed?
 
Hi Rolf,

Yes, you have been misled. Dear old Florence invented a related 
illustration now usually referred to as a polar area diagram. It was 
an ingenious way of representing quantities as areas, but probably had 
to be explained at length to those subjected to it. The principal 
advantage of the pie chart is that most people think they understand it 
upon seeing it, even if they don't. As is common in human affairs, even 
the illusion of understanding is preferred to a lofty digression upon 
why the audience does not understand.

Jim

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


Re: [R] [OT] vernacular names for circular diagrams

2008-01-29 Thread Gabor Grothendieck
http://en.wikipedia.org/wiki/Pie_chart

cites papers using the polar area diagram prior to Nightengale although
it does say that many sources credit it to her.

On Jan 29, 2008 6:16 AM, Jim Lemon [EMAIL PROTECTED] wrote:
 Rolf Turner wrote:
  ...
  I have been for many years under the impression that the pie chart
  was invented by Florence Nightingale.  Am I misinformed?
 
 Hi Rolf,

 Yes, you have been misled. Dear old Florence invented a related
 illustration now usually referred to as a polar area diagram. It was
 an ingenious way of representing quantities as areas, but probably had
 to be explained at length to those subjected to it. The principal
 advantage of the pie chart is that most people think they understand it
 upon seeing it, even if they don't. As is common in human affairs, even
 the illusion of understanding is preferred to a lofty digression upon
 why the audience does not understand.

 Jim


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


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

2008-01-29 Thread Uwe Ligges


Richard Longland wrote:
 Hi,
 
 Although I understand how to use expression and paste to add
 superscripts and symbols to my graphs, I have a problem with adding
 superscripts to an existing string.
 
 For example, I read in the following from a separate file:
 25Mg(p,g)
 
 I want to convert that to superscripts etc. (in LaTex format):
 $^{25}$Mg(p,$\gamma$)
 
 This needs to then be put into a graph title.
 
 Any ideas? I know that I can just write it in using expression and
 paste, but the title is read in from a separate file.


If you explain what the rules are to use superscript or greek letters 
(why is the p not converted to pi but the g to gamma, etc?), we ca help,
as an example if you read just the number from a file:

#number - scan(that_file)
# say you read
number - 25

plot(1:10, main=substitute(phantom()^number * Mg(p, gamma), 
list(number=number)))

See ?plotmath and for automating things like this my article in R News 
might help:
Ligges, U. (2002): R Help Desk: Automation of Mathematical Annotation in 
Plots. R News 2 (3), 32-34.

Best,
Uwe Ligges




 Cheers for the help,
 Richard longland
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] q about efficient cross-classification/creating tables

2008-01-29 Thread Juliet Hannah
Dear R Users,
I am posting a smaller portion of a question I posted last week. Code I have
written
takes weeks to run, and I am trying to make all the lines as efficient as
possible. Here is
one part of the code.

I have some data that looks like

 [,1] [,2] [,3] [,4]
[1,]1313
[2,]3323
[3,]1333
and a binary response. I am trying to obtain a vector of counts for all
cross classifications of the response
and each pair of columns from the data.

Have I coded this in an efficient manner?

library(combinat)
# some example data
myData - matrix(sample(c(1:3),500,replace=TRUE),nrow=100,ncol=4)
response - c(rep(1,50),rep(0,50))
#initialize result matrix
count.matrix - matrix(-1,ncol=6,nrow=18);
# indices of all pairs of columns
all.pairs - combn2(1:ncol(myData))

getCounts - function(index)
{
  counts - as.vector(table(myData[,index[1]],myData[,index[2]],response));

}

count.matrix - apply(all.pairs, 1, getCounts)


Thanks,

Juliet

[[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] [R-pkgs] New package: dtw - Dynamic Time Warping

2008-01-29 Thread Toni Giorgino
Dear R community,

I would like to introduce the package dtw for computing Dynamic Time
Warping (DTW) alignments and related algorithms on timeseries.

The DTW algorithm computes the time axis stretch which optimally maps one
timeseries (query) onto another (template); it outputs the resulting
cumulative distance between the two inputs, which is frequently used for
classification and clustering.

The R implementation in package dtw is fairly comprehensive, allowing
choice of:

* windowing functions (global constraints), eg. the Sakoe-Chiba band
* 26 transition types (local constraints), incl.
  - symmetric and asymmetric
  - smoothed
  - slope-constrained
  - step patterns found in Sakoe-Chiba and Rabiner-Myers;
* any definition for a local distance can be used for multivariate
timeseries, thanks to the {proxy}distance function.

Besides alignment computations, the package also provides:

* plot methods for warping functions with several visualization styles;
* methods for applying a warping function (direct or inverse);
* native and interpreted implementations.

DTW itself registers as a distance function with {proxy}distance;

Package dtw is hosted on CRAN (stable) and R-forge (testing: recommended).
Current package version is 1.4-3 (this is the first announcement on
r-packages).

Please find more information at the project home page:
http://dtw.r-forge.r-project.org , providing repository locations and a
gallery of sample plots.  A companion paper is upcoming.

Best regards,
Toni Giorgino



-- 
Toni Giorgino, PhD [EMAIL PROTECTED]
Laboratorio di Informatica Biomedica  tel +39 0382 985981
Dip. Informatica e Sistemistica   fax +39 0382 526088
via Ferrata 1   I-27100 Pavia

[[alternative HTML version deleted]]

___
R-packages mailing list
[EMAIL PROTECTED]
https://stat.ethz.ch/mailman/listinfo/r-packages

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


Re: [R] Correlation matrix for data in long format

2008-01-29 Thread Henrique Dallazuanna
If I understand your question, you can try something like this:

cor(data.frame(lapply(split(x, x$state), [, 3)))

On 29/01/2008, Serguei Kaniovski [EMAIL PROTECTED] wrote:
 Hello,

 I cannot figure out how to use tapply to compute the correlation matrix
 in the variable x between the states? The data is in long format, e.g.:

 state,year,x
 Alabama,2001,0.45
 Alabama,2002,0.47
 Alabama,2003,0.48
 Alabama,2004,0.44
 Arizona,2001,0.34
 Arizona,2002,0.32
 Arizona,2003,0.38
 Arizona,2004,0.36

 Thank you in advance for your help,
 Serguei Kaniovski

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



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

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

2008-01-29 Thread cgenolin
Seems strange to me to define an operator relatively to a very special case.
I have to admit that I do not use 1:1e7 every day :-)

Wouldn't it be more appropriate to define a a:b operator numeric (that 
is preserving the initial class of a and b) and in specific case that 
need optimization, changing the type?

for i in as.integer(1:1e7)

That might appears as a minor point, but when using S4, for what I 
know, if you define a class that can take either 1:3 or c(1,3,4), one 
is integer, the other numeric, one of those will not be accepted by the 
class...

Christophe


 On 28-Jan-08 22:40:02, Peter Dalgaard wrote:
 [...]
 AFAIR, space is/was more of an issue. If you do something like

 for i in 1:1e7
 some.silly.simulation()

 then you have 40 MB sitting there doing nothing, and 80 MB if
 it had been floating point.

 Hmmm ... there's something to be said for good old

  for(i=1,i=1e7,i++){}

 As pointed out in ?for, when you do

  for(i in X){...}  #(e.g. X=(1:1e7))

 the object X is created (or is already there) in full
 at the start and sits there, as you say doing nothing,
 until you end the loop. Whereas the C code just keeps
 track of i and of the condition.

 At least on a couple of my machines (64MB and 184MB RAM)
 knocking out 40MB would inflict severe trauma! Let alone 80MB.
 Mind you, the little one is no longer allowed to play with
 big boys like R, though the other one is still used for
 moderate-sized games.

 Would there be much of a time penalty in implementing
 a 'for' loop, C-style, as

  i-1
  while(i=1e7){
...
i-i+1
  }

 ??

 It looks as though there might be:

  system.time(for(i in (1:1e7)) x-cos(3) )
  #[1] 13.521  0.132 13.355  0.000  0.000
  system.time({i-1;while(i=1e7){x-cos(3);i-i+1}})
  #[1] 38.270  0.076 37.629  0.000  0.000

 which suggests that the latter is about 3 times as slow.
 (And no, this wasn't done on either of my puny babes).

 (And this isn't the first time I've wished for an R
 implementation of ++ as a CPU-level incrementation,
 as opposed to the R-arithmetic implementation which
 treats adding 1 to a variable as a full-dress
 arithmetic parade!

 Best wishes,
 Ted.

 
 E-Mail: (Ted Harding) [EMAIL PROTECTED]
 Fax-to-email: +44 (0)870 094 0861
 Date: 28-Jan-08   Time: 23:34:52
 -- XFMail --





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] how to generate sequence a - z

2008-01-29 Thread Attiglah, Mama

 letters
 [1] a b c d e f g h i j k l m n o p q
r s t u v w x y z
 LETTERS
 [1] A B C D E F G H I J K L M N O P Q
R S T U V W X Y Z

Hope that will help.

Mama 

-
Mama Attiglah, PhD
Advanced Research Center
Quantitative Research Analyst
State Street Bank
+44(0)20 7698 6290 (Direct Line)
+44 (0)207 004 2968 (Direct Fax)
Please visit our Web site at 
www.ssga.com

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Bernd Weiss
Sent: 29 January 2008 12:43
To: skestin; [EMAIL PROTECTED]
Subject: Re: [R] how to generate sequence a - z

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

skestin schrieb:
| I suppose it's very simple but I can't find the way to generate a
sequence of
| characters, e.g. from a to z.
| Could you please help me with this?

?letters
letters


HTH,

B.
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHnx9IUsbvfbd00+ERAuasAKCYIZ9KC4c3NoDFfkdDP0MyZckinwCbBQv7
CX249me9JFbVlWNPy/mDtV0=
=Vaea
-END PGP SIGNATURE-

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Logit Regressions, Clustering etc

2008-01-29 Thread Paul Sweeting
Hi

Sorry to bother the list again, but no-one has so far been able to suggest
any help for the query below.  As an added incentive, I have been asked why
don't you do this in Stata? It's just a case of adding a flag in the
regression...

I'm loathe to start learning another stats package, so if anyone is able to
help...!

Thanks

Paul


Hi

I am carrying out some logit regressions and want to (a) make sure I'm
taking the right approach and (b) work out how to carry out some additional
analysis.  So, to carry out a logit regression where the dependent variable
is a factor db, I use something like:

res1_l - glm(formula = db ~ y1 + … + y5, family = binomial(link =
logit))
summary(res1_l)

...which is, I hope correct.  I also need to carry out an ordered logit
regression.  Is this as simple as:

res1_l - polr(formula = db ~ y1 + … + y5)
summary(res1_l)

..with db being a factor which has more levels than just 0 and 1?

Assuming it is, the part I am really struggling with is the calculation of
robust standard errors to allow for clustering.  In an ordinary
regression, I’ve used survreg, where the data has also been censored, e.g.:

res1 - survreg(formula = Surv(ip, db_Censor) ~ y1 + … y5 + cluster(db_ID),
dist = gaussian)
summary(res1)

This has the benefit of giving a nice clear display of the naïve standard
error as well as the robust one - is there any way of getting similar
output
for a logit and an ordered logit regression

Thanks in advance for your help.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 generate sequence a - z

2008-01-29 Thread skestin

I suppose it's very simple but I can't find the way to generate a sequence of
characters, e.g. from a to z.
Could you please help me with this?
-- 
View this message in context: 
http://www.nabble.com/how-to-generate-sequence-%22a%22---%22z%22-tp15158509p15158509.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] Expert systems

2008-01-29 Thread Domenico Vistocco
I know that there are packages implementings the probabilistic expert 
systems (the so-called probabilistic networks or bayesian networks).
You find (at least) the following packages:

bnlearn (bayesian network structure learning)
deal (learning bayesian networks with mixed variables)
G1DBN (for dynamic bayesian network inference)

Ciao,
domenico

Ralf Finne wrote:
 Hi R-users
 Is there any functions in R that can implement expert systems?
 The aim of an expert system is to produce a probable diagnosis
 for a patient with certain symptoms.
 In the classical expert system a mumber of experts are asked to make
 statements on the probabilities for different diseases when a
 combination of systems would appear.   One typical expert system
 uses Fuzzy Logic to suggest the diagnosis.

 In more modern systems one tends to make the system self learning
 to improve the system.

 Hoping for comments
 Ralf Finne
 Swenska yrkeshögskolan
 Vasa Finland

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Logit Regressions, Clustering etc

2008-01-29 Thread Thomas Lumley


The 'sandwich' package has sandwich standard errors of various sorts for a 
generalized linear models. I don't know if it handles the proportional 
odds model.


-thomas

On Tue, 29 Jan 2008, Paul Sweeting wrote:


Hi

Sorry to bother the list again, but no-one has so far been able to suggest
any help for the query below.  As an added incentive, I have been asked why
don't you do this in Stata? It's just a case of adding a flag in the
regression...

I'm loathe to start learning another stats package, so if anyone is able to
help...!

Thanks

Paul



Hi



I am carrying out some logit regressions and want to (a) make sure I'm
taking the right approach and (b) work out how to carry out some additional
analysis.  So, to carry out a logit regression where the dependent variable
is a factor db, I use something like:



res1_l - glm(formula = db ~ y1 + … + y5, family = binomial(link =

logit))

summary(res1_l)



...which is, I hope correct.  I also need to carry out an ordered logit
regression.  Is this as simple as:



res1_l - polr(formula = db ~ y1 + … + y5)
summary(res1_l)



..with db being a factor which has more levels than just 0 and 1?



Assuming it is, the part I am really struggling with is the calculation of
robust standard errors to allow for clustering.  In an ordinary
regression, I’ve used survreg, where the data has also been censored, e.g.:



res1 - survreg(formula = Surv(ip, db_Censor) ~ y1 + … y5 + cluster(db_ID),
dist = gaussian)
summary(res1)



This has the benefit of giving a nice clear display of the naïve standard
error as well as the robust one - is there any way of getting similar

output

for a logit and an ordered logit regression



Thanks in advance for your help.



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



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] how do i creat multiple back to back histograms?

2008-01-29 Thread S Ellison
Is
?pyramid.plot
in the plotrix package of any help?

Plotting three of these on the same device is possible after

par(mfrow=c(1,3))


 Tom Willems [EMAIL PROTECTED] 29/01/2008 11:43:46 
 dear R-ussers,
I would like to creeate a graph, i wich  my data is presented as
verticaly 
oriented histograms, wich give the frequency of the measured values, 
grouped per used measurement methode.
So the X axis should hold the grouping variable and the Y axis a
continuos 
variable. well not realy continouse, but it should show the values, 
representing the clase intervals.
small example to clarify this:
This one i can create: graph 1
only the positive results per test
5  |  ##|#|##  
|  #  |##  |#
4  |  ###  |  |
|  |##  |##
3  |  ###  |#|
|  #  |###|#
2  |  |  |##
|  ###  |##  |#
1  |  #  |#|##
|_|_|_
0test 1test2test3
Tihs is what i want to create: graph 2
a back to back histogram plot of the pos/negative results, grouped per

test
5  |  |##  |# 

|##  
|  |#|##   

#|#
4  |  |###|  ##|

| .|..|##
...#|##..
3  |#|###  #|#   
|
|  ##|###|#####|#
2  
|#|..|..##|##..
|###|#####|#####|#
1  |  ##|#  #|#|##
|___|__#|#|_
0test 1test2   
test3
   Neg. |  Pos.Neg. |  Pos. Neg. |  Pos.


I 'd like to creat the figure of graph 2, a back to back plot of the
pos/ 
and negative results of a test,
and this with the 3 tests in one graf.

I have been searching for examples,  the only trouble is that it is way
to 
complex.
(http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=109)
Here is one other example of a back to back plot (graph 2) .
(histbackback(fool)

After trying to understand wath happens in the complex example, i 
identified a part that does what i need.
It does creat the graph similar to what i want (graph 1).  see
code 
below 
Yet i do not understand it wel enough,so i can't creat the more complex

graph 2.
What can i do to understand this graph functions beter, without
spending 
to much time on them?

Kind regards,
Tom.

this is the code, wich i use to creat graph 1
# data for plot:

freqs - data.frame(value= c( 
0.000,1.204,1.301,1.362,1.447,1.505,1.602,1.653,1.756,1.806,1.903,1.959,
 
2.053,2.107,2.204,2.258,2.354,2.408,2.505,2.559,2.656,2.709,2.806) ,
  tp1= c( 8,1,0,13,0,6,0,25,0,5,0,15,0,4,0,7,0,0,0,1,0,0,0)
 ,
  tn1= c( 17,0,0,2,0,0,0,1,0,2,0,1,0,0,0,0,0,0,0,0,0,0,0)  
 ,
  tp2= c( 10,0,2,0,9,0,8,0,19,0,4,0,5,0,2,0,5,0,2,0,1,0,2) 
 ,
  tn2= c( 13,0,1,0,1,0,2,0,2,0,0,0,2,0,0,0,0,0,0,0,0,0,0)  
 ,
  tp3= c( 9,0,0,0,0,0,0,0,0,10,0,10,0,21,0,10,0,11,0,8,0,5,0)  
 ,
  tn3= c( 15,0,0,0,0,0,0,0,0,3,0,2,0,2,0,1,0,0,0,0,0,0,0)  
 )

 test-c(1,2,3,4,5,6)
testname -c('test1 p','test1 n','test2 p','test2 n','test3 p','test3
n')  
 


# parameters for plot 
 xlim = c(min(test),max(test))
 ylim = c(0,length(freqs$value))
 barscale = 0.2
 barcol = 8
 # plot 
 win.graph() 
 for (i in 1:length(freqs))
  {
 par(new = TRUE)
 xmin - -test[i] + xlim[1]
 xmax - xlim[2] - test[i]
 ser - freqs[, i+1]
 ser - ser/max(ser) * barscale
 barplot(ser, horiz = TRUE, axes = FALSE, xlim =
c(xmin, 
xmax),
 ylim = ylim, col = barcol, space = 0)
}
 axis(1,labels=testname,at=c(0,0.2,0.4,0.6,0.8,1))
 axis(2,labels=freqs$value ,at=c((0:22)/23) )

this is the code, wich i hoped would creat graph 2 but it doesn't work

for (i in 1:length(freqs))
  {
 par(new = TRUE)
 xmin - -test[i] + xlim[1]
 xmax - xlim[2] - test[i]
 serx - freqs[, i+1]
 sery - freqs[, i+2]
 ser - list((serx/sum(serx) *
barscale),(sery/sum(sery) * 
barscale))
 histbackback(ser,axes=FALSE ,xlim = c(xmin, xmax),
ylim = 
ylim)
 

Re: [R] how to generate sequence a - z

2008-01-29 Thread Bernd Weiss
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

skestin schrieb:
| I suppose it's very simple but I can't find the way to generate a
sequence of
| characters, e.g. from a to z.
| Could you please help me with this?

?letters
letters


HTH,

B.
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHnx9IUsbvfbd00+ERAuasAKCYIZ9KC4c3NoDFfkdDP0MyZckinwCbBQv7
CX249me9JFbVlWNPy/mDtV0=
=Vaea
-END PGP SIGNATURE-

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 generate sequence a - z

2008-01-29 Thread Christoph Scherber
--
X-USF-Spam-Status: hits=-2.6 tests=BAYES_00
X-USF-Spam-Flag: NO

Hello,

Sequences of letters can be generated by typing

LETTERS #for capital letters or
letters #for small letters

Best wishes
Christoph



skestin schrieb:
 I suppose it's very simple but I can't find the way to generate a sequence of
 characters, e.g. from a to z.
 Could you please help me with this?

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


Re: [R] how do i creat multiple back to back histograms?

2008-01-29 Thread ONKELINX, Thierry
Maybe this is what you'd like.

library(ggplot2)
freqs - data.frame(value= c(
0.000,1.204,1.301,1.362,1.447,1.505,1.602,1.653,1.756,1.806,1.903,1.959,
  2.053,2.107,2.204,2.258,2.354,2.408,2.505,2.559,2.656,2.709,2.806)
,
  tp1= c( 8,1,0,13,0,6,0,25,0,5,0,15,0,4,0,7,0,0,0,1,0,0,0)
,
  tn1= c( 17,0,0,2,0,0,0,1,0,2,0,1,0,0,0,0,0,0,0,0,0,0,0)
,
  tp2= c( 10,0,2,0,9,0,8,0,19,0,4,0,5,0,2,0,5,0,2,0,1,0,2)
,
  tn2= c( 13,0,1,0,1,0,2,0,2,0,0,0,2,0,0,0,0,0,0,0,0,0,0)
,
  tp3= c( 9,0,0,0,0,0,0,0,0,10,0,10,0,21,0,10,0,11,0,8,0,5,0)
,
  tn3= c( 15,0,0,0,0,0,0,0,0,3,0,2,0,2,0,1,0,0,0,0,0,0,0)
)
freqsMelt - melt(freqs, id = value, measure.var = 2:7)
colnames(freqsMelt)[3] - n
freqsMelt$test - factor(paste(test, substr(freqsMelt$variable, 3,
3)))
freqsMelt$posneg - factor(substr(freqsMelt$variable, 2, 2))
freqsMelt$n[freqsMelt$posneg == n] - - freqsMelt$n[freqsMelt$posneg
== n]
ggplot(freqsMelt, aes(x = factor(value), y = n, fill = posneg)) +
geom_bar(stat= identity, position = identity) + facet_grid(. ~test)
+ coord_flip()

HTH,

Thierry 




ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium 
tel. + 32 54/436 185
[EMAIL PROTECTED] 
www.inbo.be 

Do not put your faith in what statistics say until you have carefully
considered what they do not say.  ~William W. Watt
A statistical analysis, properly conducted, is a delicate dissection of
uncertainties, a surgery of suppositions. ~M.J.Moroney

-Oorspronkelijk bericht-
Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Namens Tom Willems
Verzonden: dinsdag 29 januari 2008 12:44
Aan: r-help@r-project.org
Onderwerp: [R] how do i creat multiple back to back histograms?

 dear R-ussers,
I would like to creeate a graph, i wich  my data is presented as
verticaly oriented histograms, wich give the frequency of the measured
values, grouped per used measurement methode.
So the X axis should hold the grouping variable and the Y axis a
continuos variable. well not realy continouse, but it should show the
values, representing the clase intervals.
small example to clarify this:
This one i can create: graph 1
only the positive results per test
5  |  ##|#|##  
|  #  |##  |#
4  |  ###  |  |
|  |##  |##
3  |  ###  |#|
|  #  |###|#
2  |  |  |##
|  ###  |##  |#
1  |  #  |#|##
|_|_|_
0test 1test2test3
Tihs is what i want to create: graph 2
a back to back histogram plot of the pos/negative results, grouped per
test
5  |  |##  |#  
|##
|  |#|##
#|#
4  |  |###|  ##|

| .|..|##
...#|##..
3  |#|###  #|#|
|  ##|###|#####|#
2  
|#|..|..##|##...
...
|###|#####|#####|#
1  |  ##|#  #|#|##
|___|__#|#|_
0test 1test2
test3
   Neg. |  Pos.Neg. |  Pos. Neg. |  Pos.


I 'd like to creat the figure of graph 2, a back to back plot of the
pos/ and negative results of a test, and this with the 3 tests in one
graf.

I have been searching for examples,  the only trouble is that it is way
to complex.
(http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=109)
Here is one other example of a back to back plot (graph 2) .
(histbackback(fool)

After trying to understand wath happens in the complex example, i
identified a part that does what i need.
It does creat the graph similar to what i want (graph 1).  see code

below 
Yet i do not understand it wel enough,so i can't creat the more complex
graph 2.
What can i do to understand this graph functions beter, without spending
to much time on them?

Kind regards,
Tom.

this is the code, wich i use to creat graph 1 # data for plot:

freqs - data.frame(value= c(
0.000,1.204,1.301,1.362,1.447,1.505,1.602,1.653,1.756,1.806,1.903,1.959,
  

[R] Compiling R code

2008-01-29 Thread Attiglah, Mama
Hi all, 
I am struggling to compile a massive R code that I have written through
some years, aiming to provide automated investment strategies to my
Portfolio Managers. You may ask me why do I not rewrite the code in C or
C++; the answer is it is really massive and that will take me lots of
time. 
The pb is I will be moving from one team to another therefore I want to
make it an exec program that the PMs can run in their investment
universe without my help.
I am using the very long method described in the R extension doc which
is taking me time as each block of the code needs to be carefully
evaluated.  
I researched about the RCC project aiming to do the job but it seems to
me that the compiler is not yet available.
Is anyone experienced in compiling R code to an exec file or had a
similar experience in the past? 
Thanks 
Mama 

-
Mama Attiglah, PhD
Advanced Research Center 
Quantitative Research Analyst 
State Street Bank 
+44(0)20 7698 6290 (Direct Line)
+44 (0)207 004 2968 (Direct Fax)
Please visit our Web site at 
www.ssga.com


[[alternative HTML version deleted]]

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


Re: [R] Integer vs numeric

2008-01-29 Thread Henrik Bengtsson
x[1:n]

/H

On Jan 29, 2008 5:07 AM,  [EMAIL PROTECTED] wrote:
 Seems strange to me to define an operator relatively to a very special case.
 I have to admit that I do not use 1:1e7 every day :-)

 Wouldn't it be more appropriate to define a a:b operator numeric (that
 is preserving the initial class of a and b) and in specific case that
 need optimization, changing the type?

 for i in as.integer(1:1e7)

 That might appears as a minor point, but when using S4, for what I
 know, if you define a class that can take either 1:3 or c(1,3,4), one
 is integer, the other numeric, one of those will not be accepted by the
 class...

 Christophe



  On 28-Jan-08 22:40:02, Peter Dalgaard wrote:
  [...]
  AFAIR, space is/was more of an issue. If you do something like
 
  for i in 1:1e7
  some.silly.simulation()
 
  then you have 40 MB sitting there doing nothing, and 80 MB if
  it had been floating point.
 
  Hmmm ... there's something to be said for good old
 
   for(i=1,i=1e7,i++){}
 
  As pointed out in ?for, when you do
 
   for(i in X){...}  #(e.g. X=(1:1e7))
 
  the object X is created (or is already there) in full
  at the start and sits there, as you say doing nothing,
  until you end the loop. Whereas the C code just keeps
  track of i and of the condition.
 
  At least on a couple of my machines (64MB and 184MB RAM)
  knocking out 40MB would inflict severe trauma! Let alone 80MB.
  Mind you, the little one is no longer allowed to play with
  big boys like R, though the other one is still used for
  moderate-sized games.
 
  Would there be much of a time penalty in implementing
  a 'for' loop, C-style, as
 
   i-1
   while(i=1e7){
 ...
 i-i+1
   }
 
  ??
 
  It looks as though there might be:
 
   system.time(for(i in (1:1e7)) x-cos(3) )
   #[1] 13.521  0.132 13.355  0.000  0.000
   system.time({i-1;while(i=1e7){x-cos(3);i-i+1}})
   #[1] 38.270  0.076 37.629  0.000  0.000
 
  which suggests that the latter is about 3 times as slow.
  (And no, this wasn't done on either of my puny babes).
 
  (And this isn't the first time I've wished for an R
  implementation of ++ as a CPU-level incrementation,
  as opposed to the R-arithmetic implementation which
  treats adding 1 to a variable as a full-dress
  arithmetic parade!
 
  Best wishes,
  Ted.
 
  
  E-Mail: (Ted Harding) [EMAIL PROTECTED]
  Fax-to-email: +44 (0)870 094 0861
  Date: 28-Jan-08   Time: 23:34:52
  -- XFMail --
 



 
 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-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Fortunes - was Re: [OT] vernacular names for circular diagrams

2008-01-29 Thread Gabor Grothendieck
I did not write that.

On Jan 29, 2008 9:05 AM, S Ellison [EMAIL PROTECTED] wrote:
  Gabor Grothendieck [EMAIL PROTECTED] 29/01/2008 12:35:27
 
  As is common in human affairs, even
  the illusion of understanding is preferred to a lofty digression
 upon
  why the audience does not understand.

 Gabor,

 This should be in fortunes; it is depressingly accurate.
 But it doesn't have to be a lofty digression.

 S



 ***
 This email and any attachments are confidential. Any u...{{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] Form Pairs of Variables for a paired t-test

2008-01-29 Thread Henrique Dallazuanna
Try this:

lapply(apply(combn(ncol(x),2), 2, function(y)x[,y]),
function(z)t.test(z[,1], z[,2]))

On 29/01/2008, nalluri pratap [EMAIL PROTECTED] wrote:
 Hi Users,

   This is regarding the paired t-test. I have 5 variables (say) 
 Data$v1,Data$v2,Data$v3,Data$v4,Data$v5 in my data frame. Now, I need to 
 perform a paired t-test on all the possible 10 pairs.How do I set up the 
 pairs table directly and pass those variables in to t-test.

   Thanks in advance,

   Pratap


 -
  Now you can chat without downloading messenger. Click here to know how.
 [[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.



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

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] B-W stacked area chart with pattern

2008-01-29 Thread Markus Didion
Dear all,

I would like to create a stacked area chart to show the development of 
species biomass over time. Since it is intended for publication I need 
to prepare in black and white.  I have tried to modify the stackedPlot 
function submitted to this list by Christian Lasarczyk on Tue, 16 Aug 
2005 using shading lines rather than colors to distinguish between the 
species. Unfortunately, the result was not very satisfying as the 
options using different angles and densities for the shading lines was 
not sufficient to clearly distinguish between species. I would thus like 
to use different pattern (or texture) for this purpose. I have searched 
the various help lists on graphics in R but was unable to find something 
appropriate.

Thanks,
Markus


-- 

Markus Didion

WaldökologieForest Ecology
Inst. f. Terrestrische Oekosysteme  Inst. of Terrestrial Ecosystems
Departement UmweltwissenschaftenDept. of Environmental Sciences
Eidg. Technische Hochschule Swiss Fed. Inst. of Technology
ETH-Zentrum CHN G78 ETH-Zentrum CHN G78
Universitätstr. 22  Universitaetstr. 22
CH-8092 Zürich  CH-8092 Zurich
Schweiz Switzerland

Tel +41 (0)44 632 5629  Fax +41 (0)44 632 1358  
Email [EMAIL PROTECTED]
homepage: http://www.fe.ethz.ch/people/didionm

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] B-W stacked area chart with pattern

2008-01-29 Thread hadley wickham
On Jan 29, 2008 9:12 AM, Markus Didion [EMAIL PROTECTED] wrote:
 Dear all,

 I would like to create a stacked area chart to show the development of
 species biomass over time. Since it is intended for publication I need
 to prepare in black and white.  I have tried to modify the stackedPlot
 function submitted to this list by Christian Lasarczyk on Tue, 16 Aug
 2005 using shading lines rather than colors to distinguish between the
 species. Unfortunately, the result was not very satisfying as the
 options using different angles and densities for the shading lines was
 not sufficient to clearly distinguish between species. I would thus like
 to use different pattern (or texture) for this purpose. I have searched
 the various help lists on graphics in R but was unable to find something
 appropriate.

How many species do you have?  Coming about with a good
(distinguishable) set of patterns is a difficult task.  Have you tried
just using different greys?

Hadley


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

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


Re: [R] B-W stacked area chart with pattern

2008-01-29 Thread Markus Didion
Thanks Hadley for your comment.  I've got a minimum of 12 species and 
thus just using different greys won't do it.  I've tried it with two 
background fills, i.e. white and a medium grey, and then used various 
angles for the shading lines, even plotted it twice to obtain some sort 
of cross shading.  For good, distinguishable patterns I've been hoping 
to be able to fill an area with different symbols.

Markus

hadley wickham wrote:
 On Jan 29, 2008 9:12 AM, Markus Didion [EMAIL PROTECTED] wrote:
 Dear all,

 I would like to create a stacked area chart to show the development of
 species biomass over time. Since it is intended for publication I need
 to prepare in black and white.  I have tried to modify the stackedPlot
 function submitted to this list by Christian Lasarczyk on Tue, 16 Aug
 2005 using shading lines rather than colors to distinguish between the
 species. Unfortunately, the result was not very satisfying as the
 options using different angles and densities for the shading lines was
 not sufficient to clearly distinguish between species. I would thus like
 to use different pattern (or texture) for this purpose. I have searched
 the various help lists on graphics in R but was unable to find something
 appropriate.
 
 How many species do you have?  Coming about with a good
 (distinguishable) set of patterns is a difficult task.  Have you tried
 just using different greys?
 
 Hadley
 
 
-- 

Markus Didion

WaldökologieForest Ecology
Inst. f. Terrestrische Oekosysteme  Inst. of Terrestrial Ecosystems
Departement UmweltwissenschaftenDept. of Environmental Sciences
Eidg. Technische Hochschule Swiss Fed. Inst. of Technology
ETH-Zentrum CHN G78 ETH-Zentrum CHN G78
Universitätstr. 22  Universitaetstr. 22
CH-8092 Zürich  CH-8092 Zurich
Schweiz Switzerland

Tel +41 (0)44 632 5629  Fax +41 (0)44 632 1358  
Email [EMAIL PROTECTED]
homepage: http://www.fe.ethz.ch/people/didionm

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 get two y-axises in a bar plot?

2008-01-29 Thread Attiglah, Mama

Try this 

X = rbind(y1, y2)
colnames(X) = as.character(x)

barplot( X, density=c(35,40), col=c(red,blue), beside=FALSE)
barplot( X, density=c(35,40), col=c(red,blue), beside=TRUE)


Alternatively, 
barplot( y1, ylim = c(0, max(y1,y2)), col=blue, beside=FALSE)

par(new=TRUE)

barplot( y2, ylim = c(0, max(y1,y2)), col=red, beside=FALSE,
names.arg=as.character(x))


Mama

-
Mama Attiglah, PhD
Advanced Research Center
Quantitative Research Analyst
State Street Bank
+44(0)20 7698 6290 (Direct Line)
+44 (0)207 004 2968 (Direct Fax)
Please visit our Web site at 
www.ssga.com

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Gustaf Granath
Sent: 29 January 2008 16:15
To: r-help@r-project.org
Subject: [R] How to get two y-axises in a bar plot?

Hi,
I have measured two response variables (y1, y2) at each treatment level 
(x = 0, 1.5 or 3). Now I would like to show the y1 and y2 against x in a

bar plot. However, y1 and y2 differ in scale so I need two y-axises, one

on the left side and one on the right side (and I dont want to 
standardize my responses). This is fairly easy if you want to show 
points,lines etc, but gets more complicated with bars.Although these 
kind of bar graphs are quite common, I have found very limited 
information about how to do them in R. I have been struggling with the 
barplot() command. My problem is that the bars for y1 and y2 end up at 
the same place (blocking each other) and not beside each other when I 
use par(new=TRUE). Is there a way to separate them so y1 and y2 are 
placed beside each other at each x level, or is this easier to do this 
with lattice?? I would also like to add error bars but I guess that 
should not be a problem.

For code and data, see below.

Cheers,

Gustaf Granath, phd student

My code so far:
#Creating data
c(6.34,13.38,17.87)-y1
c(0.85,1.88,2.33)-y2
c(0,1.5,3)-x
cbind(y1,y2,x)-mydata
data.frame(mydata)-mydata
with(mydata, tapply(y1,x,mean))-mean.y1
with(mydata, tapply(y2,x,mean))-mean.y2
#Barplot
par(mar=c(5,4,4,4)+0,1)
barplot(mean.y1,density=1,las=1)
par(new=T)
barplot(mean.y2,density=3,angle=3,axes=F)
axis(4,las=1)

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

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


Re: [R] coherency and phase plots

2008-01-29 Thread stephen sefick
spec.pgram does accept multivariate time series, and I have used this
with success.  I just don't know if there is an implementation of
cross-spectrum in R.  Or what exactley Phase vs frequency is telling
me.

On Jan 29, 2008 2:06 PM, Donald McKenzie [EMAIL PROTECTED] wrote:
 See the help for spec.pgram().  It accepts a multivariate time series
 as an argument.


 Don McKenzie, Research Ecologist
 Fire and Environmental Research Applications (FERA)
 Pacific Wildland Fire Sciences Lab, USDA Forest Service

 Affiliate Assistant Professor
 College of Forest Resources
 JISAO / CSES Climate Impacts Group
 University of Washington

 [EMAIL PROTECTED]
 [EMAIL PROTECTED]
 (206)732-7824;   fax (206)732-7801


 On Tue, 29 Jan 2008, stephen sefick wrote:

  I am having a hard time interpreting the phase and coherency plots.
  x is two timeseries that occur at the same time   i.e.
 
   a   b
  1   11.2   12.3
  16 11.3   12.4
  31 11.4   12.5
  46 11.5   12.6
  ...etc
 
  even though my example is does not show this they are oscillating at
  more or less the same frequency just shifted by t=x (imagine two sine
  waves offset with the 2nd sine wave starting at the peak of the
  first).  I would like to know what x is.  I think I am looking for the
  phase shift?  The coherency?  Cross-spectrum?  And I have read the
  help files,  Shumway and Stoffer has a small section on this, I don't
  have journal access,  and I am having trouble finding anything on the
  internet.
 
  s = spec.pgram(x)
  par(mfrow = c(2,1))
  plot(s, plot.type = coh)
  plot(s, plot.type = pha)
 
  Can R do the cross-spectrum of two timeseries?  How?
 
 
  --
  Let's not spend our time and resources thinking about things that are
  so little or so large that all they really do for us is puff us up and
  make us feel like gods.  We are mammals, and have not exhausted the
  annoying little problems of being mammals.
 
-K. Mullis
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 






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

-K. Mullis

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


Re: [R] Fortunes - was Re: [OT] vernacular names for circular diagrams

2008-01-29 Thread Gabor Grothendieck
Search the archives and find who posted it.

On Jan 29, 2008 1:52 PM, John Kane [EMAIL PROTECTED] wrote:
 Any idea who did? I have it in my list of quotes and
 attributed to you.

 Anon is so boring as a source.

 --- Gabor Grothendieck [EMAIL PROTECTED]
 wrote:


  I did not write that.
 
  On Jan 29, 2008 9:05 AM, S Ellison
  [EMAIL PROTECTED] wrote:
Gabor Grothendieck [EMAIL PROTECTED]
  29/01/2008 12:35:27
   
As is common in human affairs, even
the illusion of understanding is preferred to a
  lofty digression
   upon
why the audience does not understand.
  
   Gabor,
  
   This should be in fortunes; it is depressingly
  accurate.
   But it doesn't have to be a lofty digression.
  
   S
  
  
  
  
 
 ***
   This email and any attachments are confidential.
  Any u...{{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.
 



  Be smarter than spam. See how smart SpamGuard is at giving junk email 
 the boot with the All-new Yahoo! Mail.  Click on Options in Mail and switch 
 to New Mail today or register for free at http://mail.yahoo.ca


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

2008-01-29 Thread Søren Højsgaard
I can add that I've recently uploaded the gRain package for gRAphical 
Independence Networks, aka probabilistic networks/Bayesian networks.
 
Regards
Søren



Fra: [EMAIL PROTECTED] på vegne af Domenico Vistocco
Sendt: ti 29-01-2008 19:07
Til: Ralf Finne
Cc: r-help@r-project.org
Emne: Re: [R] Expert systems



I know that there are packages implementings the probabilistic expert
systems (the so-called probabilistic networks or bayesian networks).
You find (at least) the following packages:

bnlearn (bayesian network structure learning)
deal (learning bayesian networks with mixed variables)
G1DBN (for dynamic bayesian network inference)

Ciao,
domenico

Ralf Finne wrote:
 Hi R-users
 Is there any functions in R that can implement expert systems?
 The aim of an expert system is to produce a probable diagnosis
 for a patient with certain symptoms.
 In the classical expert system a mumber of experts are asked to make
 statements on the probabilities for different diseases when a
 combination of systems would appear.   One typical expert system
 uses Fuzzy Logic to suggest the diagnosis.

 In more modern systems one tends to make the system self learning
 to improve the system.

 Hoping for comments
 Ralf Finne
 Swenska yrkeshögskolan
 Vasa Finland

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Help needed on Normality test

2008-01-29 Thread Greg Snow
The 2 tests are testing different hypotheses.  The KS test is testing
the null that the data comes from a normal with mean 0 and sd
0.11908969, this can be false if the data is not normal or if the mean
is not 0 or if the sd is not 0.0119 or any combination of the 3.

The Shapiro test was not given a specific mean and sd so it is just
testing normality, not mean or sd.

You should really be asking the question of why do you want to know if
the data is normal?  If your sample size is small then these tests don't
have enough power to truly distinguish between distributions (and 1
outlier can cause you to falsly reject normality if it is true).  If
your sample size is large then the CLT comes into play in many common
analyses and it does not matter if the population is normal or not.  In
many cases the better question is Is this data close enough to normal?
and that question is often better answered by a qq normal plot than a
p-value.

Hope this helps,

-- 
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 Megh Dal
 Sent: Tuesday, January 29, 2008 7:57 AM
 To: [EMAIL PROTECTED]
 Subject: [R] Help needed on Normality test
 
 Hi all T gurus,

   I would like to test if my dataset is indeed from N(0, 0.011908969).

   K.S. test gives following result:

ks.test(data, pnorm, 0, 0.011908969)
   One-sample Kolmogorov-Smirnov test
   data:  data
 D = 0.1092, p-value = 1.318e-05
 alternative hypothesis: two-sided 
 
   How ever Shapiro-Wilk test give following :
shapiro.test(data)
   Shapiro-Wilk normality test
   data:  data
 W = 0.9946, p-value = 0.07562
 
   also, 

sd(data)
 [1] 0.01625074
 
   2nd test saying data is from normal however 1st isnot. 
 Which one is correct? Am I missing something?

   Regards,
 

 -
 
   [[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] Fortunes - was Re: [OT] vernacular names for circular di

2008-01-29 Thread Ted Harding
On 29-Jan-08 18:52:30, John Kane wrote:
 Any idea who did? I have it in my list of quotes and
 attributed to you. 
 
 Anon is so boring as a source.

It was Jim Lemon, earlier in this thread:
Date: Tue, 29 Jan 2008 22:16:55 +1100

Ted.

 --- Gabor Grothendieck [EMAIL PROTECTED]
 wrote:
 
 I did not write that.
 
 On Jan 29, 2008 9:05 AM, S Ellison
 [EMAIL PROTECTED] wrote:
   Gabor Grothendieck [EMAIL PROTECTED]
 29/01/2008 12:35:27
  
   As is common in human affairs, even
   the illusion of understanding is preferred to a
 lofty digression
  upon
   why the audience does not understand.
 
  Gabor,
 
  This should be in fortunes; it is depressingly
 accurate.
  But it doesn't have to be a lofty digression.
 
  S
 
 
 
 

 ***
  This email and any attachments are confidential.
 Any u...{{dropped:9}}
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained,
 reproducible code.

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


E-Mail: (Ted Harding) [EMAIL PROTECTED]
Fax-to-email: +44 (0)870 094 0861
Date: 29-Jan-08   Time: 21:24:29
-- XFMail --

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


[R] rpart Error in yval[, 1] : incorrect number of dimensions

2008-01-29 Thread Randy Griffiths
I am trying to make a decision tree using rpart. The function runs very
quickly considering the size of the data (1742, 163). When I call the
summary command I get this:

 summary(bookings.cart)
Call:
rpart(formula = totalRev ~ ., data = bookings, method = class)
  n=1741 (1 observation deleted due to missingness)

  CP nsplit rel error
1  0  0 1
Error in yval[, 1] : incorrect number of dimensions


note:
 dim(bookings)
[1] 1742  163


I have run rpart on past projects without any problems. I have used a
catagorical version of the variable totalRev that was partitioned into four
levels (and coded as a factor).

Does anyone have any ideas that might 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] B-W stacked area chart with pattern

2008-01-29 Thread Greg Snow
I would question if a stacked area chart is really the best way to display 
information on 12 groups.  You can put a lot of information into the plot, but 
the viewer will probably experience information overload and not be able to get 
much useful information out of the plot.  Stacked area plots rely on people 
being able to compare areas and lengths, which we don't do as well as we 
compare positions in a graph.  If your viewer is needing to go back and forth 
between the legend and the graph, then the information will be harder to 
assimilate.  It may be better to use lattice/trellis graphs and plot each line 
in its own panel (on the same scale and possibly with a light background grid 
to make comparison easier).  If there are specific comparisons that you want to 
point out, then make a separate graph with just those comparisons leaving out 
the extra information that will just distract.

If you give us a better idea of what information you are trying to convey, we 
may be able to give you some better options for graphs to use.

If you really want to go the pattern route then you may want to look at the 
discussion from october that started with: 
http://finzi.psych.upenn.edu/R/Rhelp02a/archive/111226.html and/or the 
discussion from earlier this week started by yaosheng CHEN with the subject 
How to fill bar plot with textile rather than color.

Hope this helps,

-- 
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 Markus Didion
 Sent: Tuesday, January 29, 2008 8:42 AM
 To: hadley wickham
 Cc: r-help@r-project.org
 Subject: Re: [R] B-W stacked area chart with pattern
 
 Thanks Hadley for your comment.  I've got a minimum of 12 
 species and thus just using different greys won't do it.  
 I've tried it with two background fills, i.e. white and a 
 medium grey, and then used various angles for the shading 
 lines, even plotted it twice to obtain some sort of cross 
 shading.  For good, distinguishable patterns I've been hoping 
 to be able to fill an area with different symbols.
 
 Markus
 
 hadley wickham wrote:
  On Jan 29, 2008 9:12 AM, Markus Didion 
 [EMAIL PROTECTED] wrote:
  Dear all,
 
  I would like to create a stacked area chart to show the 
 development 
  of species biomass over time. Since it is intended for 
 publication I 
  need to prepare in black and white.  I have tried to 
 modify the stackedPlot
  function submitted to this list by Christian Lasarczyk on 
 Tue, 16 Aug
  2005 using shading lines rather than colors to distinguish between 
  the species. Unfortunately, the result was not very 
 satisfying as the 
  options using different angles and densities for the shading lines 
  was not sufficient to clearly distinguish between species. I would 
  thus like to use different pattern (or texture) for this 
 purpose. I 
  have searched the various help lists on graphics in R but 
 was unable 
  to find something appropriate.
  
  How many species do you have?  Coming about with a good
  (distinguishable) set of patterns is a difficult task.  
 Have you tried 
  just using different greys?
  
  Hadley
  
  
 -- 
 
 Markus Didion
 
 Waldökologie  Forest Ecology
 Inst. f. Terrestrische OekosystemeInst. of Terrestrial Ecosystems
 Departement Umweltwissenschaften  Dept. of Environmental Sciences
 Eidg. Technische Hochschule   Swiss Fed. Inst. of Technology
 ETH-Zentrum CHN G78   ETH-Zentrum CHN G78
 Universitätstr. 22Universitaetstr. 22
 CH-8092 ZürichCH-8092 Zurich
 Schweiz   Switzerland
 
 Tel +41 (0)44 632 5629Fax +41 (0)44 632 1358  
 Email [EMAIL PROTECTED]
 homepage: http://www.fe.ethz.ch/people/didionm
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Convert string for expression in plot

2008-01-29 Thread Uwe Ligges


Richard Longland wrote:
 Thanks for the help. This substitute command might be what I'm after,
 but, the whole string is being read in from a file. So I can't
 explicitly write the thing out as you did in your example, as with your
 example in R-news.
 
 My rules are:
 Convert any ,g or g, to ,gamma or gamma,
   (This comma search avoids converting the Mg to Mgamma!)
 Make ANY number a superscript.
 
 Currently, this is what I do:
 
 # Read in the reaction name, not very elegant I know
 ReacName -
 as.character(read.table(file.dat,skip=0,header=FALSE,nrows=1)$V1)
 print(ReacName)
 
 # convert and numbers and g
 ReacName - sub(,g,,gamma,ReacName)
 ReacName - sub(g,,gamma,,ReacName)
 ReacName - gsub(([1-9]),phantom()^\\1,ReacName)

replace the last line by

ReacName - gsub(([[:digit:]]+), phantom()^{\\1}*, ReacName)

and later perhaps something ugly like

plot(1:10, main=parse(text=ReacName)))

Uwe Ligges


 print(ReacName)
 
 
 This results in:
 25Mg(p,g) 
 phantom()^2phantom()^5Mg(p,gamma) 
 
 Just to clarify quickly, The text will always be different. The Mg could
 be Al, S etc. The p could be different also. So the whole name has to be
 automated into the plot title.
 
 I imagine it's possible to split this string into pieces... but there
 must be a better and easier way to do this.
 
 Thanks again for the help,
 Richard
 
 
 
 
 
 On Tue, 2008-01-29 at 18:54 +0100, Uwe Ligges wrote:
 Richard Longland wrote:
 Hi,

 Although I understand how to use expression and paste to add
 superscripts and symbols to my graphs, I have a problem with adding
 superscripts to an existing string.

 For example, I read in the following from a separate file:
 25Mg(p,g)

 I want to convert that to superscripts etc. (in LaTex format):
 $^{25}$Mg(p,$\gamma$)

 This needs to then be put into a graph title.

 Any ideas? I know that I can just write it in using expression and
 paste, but the title is read in from a separate file.

 If you explain what the rules are to use superscript or greek letters 
 (why is the p not converted to pi but the g to gamma, etc?), we ca help,
 as an example if you read just the number from a file:

 #number - scan(that_file)
 # say you read
 number - 25

 plot(1:10, main=substitute(phantom()^number * Mg(p, gamma), 
 list(number=number)))

 See ?plotmath and for automating things like this my article in R News 
 might help:
 Ligges, U. (2002): R Help Desk: Automation of Mathematical Annotation in 
 Plots. R News 2 (3), 32-34.

 Best,
 Uwe Ligges




 Cheers for the help,
 Richard longland

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

2008-01-29 Thread Adriana Bejarano
Hi,



I have written the following code which works fine



step-5

numSim-15



N-double(numSim)

A-double(numSim)

F-double(numSim)

M-double(numSim)

genx-double(numSim)



for (i in 1:numSim) {



N[i]-20

PN-(runif(N[i], 0, 1))

A[i]-sum(ifelse(PN0.2, 1, 0))



PF- runif((A[i]*0.5), 0, 1)

F[i]-sum(ifelse(PF0.2, 1, 0))



PM- runif((A[i]*0.5), 0, 1)

M[i]-sum(ifelse(PM0.2, 1, 0))



genx[i]- (min(F[i], M[i])*12)



}



data-data.frame(N, A, F, M, genx)



What I would like to do next is to make 'genx' from step '1' the seed for N
in step '2'- run the above code 15 times (numSim), make 'genx' from step '2'
the seed for N in step '3'- run the above code 15 times (numSim) etc…



How do I do that?. Any advice would be greatly appreciated



Adriana (R-beginner)

[[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] heatmap and legend

2008-01-29 Thread Earl F. Glynn
Ng Stanley [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]

 This should be elementary, but I can't find any resource on creating a
 legend for heatmap. Please help.

Take a look at:

*  heatmap.2 in gplots package
*  heatplot in made4 Bioconductor package
*  heatmap_2 in Heatplus Bioconductor package

efg

Earl F. Glynn
Bioinformatics
Stowers Institute for Medical Research

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Linux, UNIX, XP32, Vista X64 or ...? [SEC=UNCLASSIFIED]

2008-01-29 Thread Patrick Connolly
On Sun, 27-Jan-2008 at 07:38PM -0500, Gabor Grothendieck wrote:

| On the PC there is a builtin GUI but not on UNIX and there are
| some packages that are OS specific in which case you might
| get more or less selection but probably more.  Also depending
| on the specific system you may have greater difficulty installing
| certain packages due to the need to compile them on UNIX
| and the possibility exists that you don't quite have the right
| libraries.  On Windows you get binaries so this is not a problem.
| I have repeatedly found that common packages that I took
| for granted on Windows had some problem with installation
| on UNIX and I had to hunt around and figure out what the problem
| was with my UNIDX libraries or possibly some other problem.
| For all R packages this won't be a problem but for packages
| that use C and FORTRAN this can be.  Although I am lumping
| all UNIX systems together I think this varies quite a bit from
| one particular type/distro of UNIX/Linux to another and I suspect if you
| are careful in picking out the right one (if you have a choice) you
| will actually have zero problems.

I've had a fair bit of experience with Redhat/Fedora/CentOS and with
Mepis distros.  I've had zero problems compiling R or packages.  

The only problem I've had is with *using* a package which uses R code
to hard-wire graphic options that don't suit X11, postscript or pdf
devices.  Virually every other package I've used doesn't hard-wire
graphic options, so that problem never arises.

YMMV

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

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Fortunes - was Re: [OT] vernacular names for circular diagrams

2008-01-29 Thread John Kane
Any idea who did? I have it in my list of quotes and
attributed to you. 

Anon is so boring as a source.

--- Gabor Grothendieck [EMAIL PROTECTED]
wrote:

 I did not write that.
 
 On Jan 29, 2008 9:05 AM, S Ellison
 [EMAIL PROTECTED] wrote:
   Gabor Grothendieck [EMAIL PROTECTED]
 29/01/2008 12:35:27
  
   As is common in human affairs, even
   the illusion of understanding is preferred to a
 lofty digression
  upon
   why the audience does not understand.
 
  Gabor,
 
  This should be in fortunes; it is depressingly
 accurate.
  But it doesn't have to be a lofty digression.
 
  S
 
 
 
 

***
  This email and any attachments are confidential.
 Any u...{{dropped:9}}
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained,
 reproducible code.


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

2008-01-29 Thread stephen sefick
I am having a hard time interpreting the phase and coherency plots.
x is two timeseries that occur at the same time   i.e.

  a   b
1   11.2   12.3
16 11.3   12.4
31 11.4   12.5
46 11.5   12.6
...etc

even though my example is does not show this they are oscillating at
more or less the same frequency just shifted by t=x (imagine two sine
waves offset with the 2nd sine wave starting at the peak of the
first).  I would like to know what x is.  I think I am looking for the
phase shift?  The coherency?  Cross-spectrum?  And I have read the
help files,  Shumway and Stoffer has a small section on this, I don't
have journal access,  and I am having trouble finding anything on the
internet.

s = spec.pgram(x)
par(mfrow = c(2,1))
plot(s, plot.type = coh)
plot(s, plot.type = pha)

Can R do the cross-spectrum of two timeseries?  How?


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

-K. Mullis

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


Re: [R] on trellis.par.set/get (reproducing figures from Pinheiro Bates)

2008-01-29 Thread Deepayan Sarkar
On 1/29/08, Dr. Ottorino-Luca Pantani [EMAIL PROTECTED] wrote:
 Dear R users,
 I would like to exactly reproduce a figure like the 1.5 or 1.9 or 4.13
 from the book
 Mixed effects models in S and S-Plus.
 Not for the sake of it, but because I have my own data I would like to
 plot in that fashion
 (no colors)


 If I write

 plot(ergoStool)

 I can get a good informative plot with colors, but I would like to have
 a BW one instead.

Have you tried

trellis.device(color = FALSE)
plot(ergoStool)

-Deepayan

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

2008-01-29 Thread Majnu John
Hello All,
 
  I used sample(..., replace = TRUE) repeatedly to generate 100
bootstrap samples of a data that I'm working with. If I re-run my codes,
it'll generate a different set of 100 bootstrap samples.
 
  Is there any way that I can get the same set of 100 bootstrap
re-samples at each re-run of my codes? Something like setting the seed
in a random number generator...
 
  Any help is very much appreciated.
 
Thanks,
Majnu

[[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] bootstrap sampling using sample

2008-01-29 Thread Henrique Dallazuanna
see ?set.seed

On 29/01/2008, Majnu John [EMAIL PROTECTED] wrote:
 Hello All,

   I used sample(..., replace = TRUE) repeatedly to generate 100
 bootstrap samples of a data that I'm working with. If I re-run my codes,
 it'll generate a different set of 100 bootstrap samples.

   Is there any way that I can get the same set of 100 bootstrap
 re-samples at each re-run of my codes? Something like setting the seed
 in a random number generator...

   Any help is very much appreciated.

 Thanks,
 Majnu

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



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

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Linux, UNIX, XP32, Vista X64 or ...? [SEC=UNCLASSIFIED]

2008-01-29 Thread Gabor Grothendieck
On Jan 29, 2008 2:30 PM, Patrick Connolly [EMAIL PROTECTED] wrote:
 On Sun, 27-Jan-2008 at 07:38PM -0500, Gabor Grothendieck wrote:

 | On the PC there is a builtin GUI but not on UNIX and there are
 | some packages that are OS specific in which case you might
 | get more or less selection but probably more.  Also depending
 | on the specific system you may have greater difficulty installing
 | certain packages due to the need to compile them on UNIX
 | and the possibility exists that you don't quite have the right
 | libraries.  On Windows you get binaries so this is not a problem.
 | I have repeatedly found that common packages that I took
 | for granted on Windows had some problem with installation
 | on UNIX and I had to hunt around and figure out what the problem
 | was with my UNIDX libraries or possibly some other problem.
 | For all R packages this won't be a problem but for packages
 | that use C and FORTRAN this can be.  Although I am lumping
 | all UNIX systems together I think this varies quite a bit from
 | one particular type/distro of UNIX/Linux to another and I suspect if you
 | are careful in picking out the right one (if you have a choice) you
 | will actually have zero problems.

 I've had a fair bit of experience with Redhat/Fedora/CentOS and with
 Mepis distros.  I've had zero problems compiling R or packages.

 The only problem I've had is with *using* a package which uses R code
 to hard-wire graphic options that don't suit X11, postscript or pdf
 devices.  Virually every other package I've used doesn't hard-wire
 graphic options, so that problem never arises.


I assume you are referring to 32 bit FC because I certainly have had
library problelms on 64 bit FC.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Logit Regressions, Clustering etc

2008-01-29 Thread Frank E Harrell Jr
Paul Sweeting wrote:
 Hi
 
 Sorry to bother the list again, but no-one has so far been able to suggest
 any help for the query below.  As an added incentive, I have been asked why
 don't you do this in Stata? It's just a case of adding a flag in the
 regression...
 
 I'm loathe to start learning another stats package, so if anyone is able to
 help...!
 
 Thanks
 
 Paul

library(Design)
f - lrm(Y ~ x1 + x2 + ..., x=TRUE, y=TRUE)
g - robcov(f, subjectID)
anova(g)
summary(g)
etc.

Frank

 
 
 Hi
 
 I am carrying out some logit regressions and want to (a) make sure I'm
 taking the right approach and (b) work out how to carry out some additional
 analysis.  So, to carry out a logit regression where the dependent variable
 is a factor db, I use something like:
 
 res1_l - glm(formula = db ~ y1 + … + y5, family = binomial(link =
 logit))
 summary(res1_l)
 
 ...which is, I hope correct.  I also need to carry out an ordered logit
 regression.  Is this as simple as:
 
 res1_l - polr(formula = db ~ y1 + … + y5)
 summary(res1_l)
 
 ..with db being a factor which has more levels than just 0 and 1?
 
 Assuming it is, the part I am really struggling with is the calculation of
 robust standard errors to allow for clustering.  In an ordinary
 regression, I’ve used survreg, where the data has also been censored, e.g.:
 
 res1 - survreg(formula = Surv(ip, db_Censor) ~ y1 + … y5 + cluster(db_ID),
 dist = gaussian)
 summary(res1)
 
 This has the benefit of giving a nice clear display of the naïve standard
 error as well as the robust one - is there any way of getting similar
 output
 for a logit and an ordered logit regression
 
 Thanks in advance for your help.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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.
 


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

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


Re: [R] B-W stacked area chart with pattern

2008-01-29 Thread David Scott


I would support this advice. Stacked bar charts are generally not recommended 
because comparisons are difficult. Having 12 groups increases the difficulty.


Best have a look at Cleveland's work before you go down your currently intended 
path. Try delving into Elements of Graphing Data and Visualizing Data.


David Scott


On Tue, 29 Jan 2008, Greg Snow wrote:

I would question if a stacked area chart is really the best way to display 
information on 12 groups.  You can put a lot of information into the plot, 
but the viewer will probably experience information overload and not be able 
to get much useful information out of the plot. Stacked area plots rely on 
people being able to compare areas and lengths, which we don't do as well as 
we compare positions in a graph. If your viewer is needing to go back and 
forth between the legend and the graph, then the information will be harder 
to assimilate.  It may be better to use lattice/trellis graphs and plot each 
line in its own panel (on the same scale and possibly with a light background 
grid to make comparison easier).  If there are specific comparisons that you 
want to point out, then make a separate graph with just those comparisons 
leaving out the extra information that will just distract.


If you give us a better idea of what information you are trying to convey, we 
may be able to give you some better options for graphs to use.


If you really want to go the pattern route then you may want to look at the 
discussion from october that started with: 
http://finzi.psych.upenn.edu/R/Rhelp02a/archive/111226.html and/or the 
discussion from earlier this week started by yaosheng CHEN with the subject 
How to fill bar plot with textile rather than color.


Hope this helps,

--
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 Markus Didion
Sent: Tuesday, January 29, 2008 8:42 AM
To: hadley wickham
Cc: r-help@r-project.org
Subject: Re: [R] B-W stacked area chart with pattern

Thanks Hadley for your comment.  I've got a minimum of 12
species and thus just using different greys won't do it.
I've tried it with two background fills, i.e. white and a
medium grey, and then used various angles for the shading
lines, even plotted it twice to obtain some sort of cross
shading.  For good, distinguishable patterns I've been hoping
to be able to fill an area with different symbols.

Markus

hadley wickham wrote:

On Jan 29, 2008 9:12 AM, Markus Didion

[EMAIL PROTECTED] wrote:

Dear all,

I would like to create a stacked area chart to show the

development

of species biomass over time. Since it is intended for

publication I

need to prepare in black and white.  I have tried to

modify the stackedPlot

function submitted to this list by Christian Lasarczyk on

Tue, 16 Aug

2005 using shading lines rather than colors to distinguish between
the species. Unfortunately, the result was not very

satisfying as the

options using different angles and densities for the shading lines
was not sufficient to clearly distinguish between species. I would
thus like to use different pattern (or texture) for this

purpose. I

have searched the various help lists on graphics in R but

was unable

to find something appropriate.


How many species do you have?  Coming about with a good
(distinguishable) set of patterns is a difficult task.

Have you tried

just using different greys?

Hadley



--

Markus Didion

WaldökologieForest Ecology
Inst. f. Terrestrische Oekosysteme  Inst. of Terrestrial Ecosystems
Departement UmweltwissenschaftenDept. of Environmental Sciences
Eidg. Technische Hochschule Swiss Fed. Inst. of Technology
ETH-Zentrum CHN G78 ETH-Zentrum CHN G78
Universitätstr. 22  Universitaetstr. 22
CH-8092 Zürich  CH-8092 Zurich
Schweiz Switzerland

Tel +41 (0)44 632 5629  Fax +41 (0)44 632 1358
Email [EMAIL PROTECTED]
homepage: http://www.fe.ethz.ch/people/didionm

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



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



_
David Scott Department of Statistics, Tamaki Campus
The University of Auckland, PB 92019
Auckland 1142,NEW ZEALAND
Phone: +64 9 373 7599 ext 86830 Fax: +64 

Re: [R] for loop help

2008-01-29 Thread jim holtman
Is this what you want?

 numSim - 15

 genx-double(numSim)
 N - rep(20, numSim)
 A - F - M - numeric(numSim)

 result - lapply(1:5, function(.x){
+ for (i in 1:numSim) {
+ PN-(runif(N[i], 0, 1))
+ A[i]-sum(ifelse(PN0.2, 1, 0))
+ PF- runif((A[i]*0.5), 0, 1)
+ F[i]-sum(ifelse(PF0.2, 1, 0))
+ PM- runif((A[i]*0.5), 0, 1)
+ M[i]-sum(ifelse(PM0.2, 1, 0))
+ genx[i]- (min(F[i], M[i])*12)
+ }
+
+ data - data.frame(N, A, F, M, genx)
+ N - genx   # assign at the top level
+ data   # return the data frame
+ })
 result
[[1]]
N  A F M genx
1  20 16 6 7   72
2  20 12 6 4   48
3  20 16 5 8   60
4  20 18 7 6   72
5  20 14 6 7   72
6  20 18 8 8   96
7  20 15 3 7   36
8  20 13 5 6   60
9  20 15 7 5   60
10 20 15 6 7   72
11 20 16 6 5   60
12 20 13 5 6   60
13 20 15 6 6   72
14 20 15 6 7   72
15 20 20 8 8   96

[[2]]
N  A  F  M genx
1  72 60 21 25  252
2  48 39 17 15  180
3  60 50 18 22  216
4  72 55 20 18  216
5  72 57 22 25  264
6  96 72 29 25  300
7  36 28 12  8   96
8  60 51 18 22  216
9  60 49 19 20  228
10 72 56 24 21  252
11 60 47 19 17  204
12 60 44 18 20  216
13 72 59 21 26  252
14 72 56 24 21  252
15 96 75 33 32  384

[[3]]
 N   A   F   M genx
1  252 209  81  84  972
2  180 137  54  59  648
3  216 172  66  69  792
4  216 166  59  65  708
5  264 226  92  93 1104
6  300 246 106  93 1116
7   96  74  29  28  336
8  216 171  68  70  816
9  228 183  74  75  888
10 252 207  83  77  924
11 204 166  65  63  756
12 216 169  69  67  804
13 252 195  74  79  888
14 252 200  88  89 1056
15 384 297 118 119 1416

[[4]]
  NA   F   M genx
1   972  799 313 316 3756
2   648  523 213 217 2556
3   792  646 259 256 3072
4   708  575 242 231 2772
5  1104  888 372 351 4212
6  1116  913 365 353 4236
7   336  272 114 100 1200
8   816  650 250 262 3000
9   888  718 285 296 3420
10  924  741 302 291 3492
11  756  603 260 245 2940
12  804  637 249 245 2940
13  888  720 288 281 3372
14 1056  847 343 353 4116
15 1416  438 446 5256

[[5]]
  NAFM  genx
1  3756 3021 1229 1232 14748
2  2556 2057  830  793  9516
3  3072 2463 1009  982 11784
4  2772 2214  884  884 10608
5  4212 3385 1355 1361 16260
6  4236 3380 1329 1368 15948
7  1200  986  376  400  4512
8  3000 2407  966  960 11520
9  3420 2702 1091 1090 13080
10 3492 2778 1130 1133 13560
11 2940 2361  932  952 11184
12 2940 2289  932  903 10836
13 3372 2680 1045 1054 12540
14 4116 3279 1305 1304 15648
15 5256 4233 1713 1715 20556




On Jan 29, 2008 2:23 PM, Adriana Bejarano [EMAIL PROTECTED] wrote:
 Hi,



 I have written the following code which works fine



 step-5

 numSim-15



 N-double(numSim)

 A-double(numSim)

 F-double(numSim)

 M-double(numSim)

 genx-double(numSim)



 for (i in 1:numSim) {



 N[i]-20

 PN-(runif(N[i], 0, 1))

 A[i]-sum(ifelse(PN0.2, 1, 0))



 PF- runif((A[i]*0.5), 0, 1)

 F[i]-sum(ifelse(PF0.2, 1, 0))



 PM- runif((A[i]*0.5), 0, 1)

 M[i]-sum(ifelse(PM0.2, 1, 0))



 genx[i]- (min(F[i], M[i])*12)



 }



 data-data.frame(N, A, F, M, genx)



 What I would like to do next is to make 'genx' from step '1' the seed for N
 in step '2'- run the above code 15 times (numSim), make 'genx' from step '2'
 the seed for N in step '3'- run the above code 15 times (numSim) etc…



 How do I do that?. Any advice would be greatly appreciated



 Adriana (R-beginner)

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





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

What is the problem you are trying to solve?

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


[R] drawing arrows with rgl

2008-01-29 Thread Kasper Peeters
Hi,

I am looking for a package which allows me to draw arrows (cylinders
with cones on them, basically) in 3d images produced with rgl. Is such
a thing available? 

I did notice the 'compositions' package, which contains
'arrow3D'. However, it relies on 'tensorA', which fails to install on
my machine with the error message copied below. If anyone can help me
fix this problem, that would do the trick too.

Best,
Kasper


trying URL 'http://www.sourcekeg.co.uk/cran/src/contrib/tensorA_0.31.tar.gz'
Content type 'application/x-tar' length 45248 bytes
opened URL
==
downloaded 44Kb

* Installing *source* package 'tensorA' ...
** libs
gcc -I/usr/lib/R/include -fPIC  -g -O2 -c tensora.c -o tensora.o
gcc -shared  -o tensorA.so tensora.o   -L/usr/lib/R/lib -lR
** R
** preparing package for lazy loading
Error in gettext(domain, unlist(args)) : invalid 'domain' value
Execution halted
ERROR: lazy loading failed for package 'tensorA'
** Removing '/usr/local/lib/R/site-library/tensorA'

The downloaded packages are in
/tmp/RtmpikOKjt/downloaded_packages
Warning message:
installation of package 'tensorA' had non-zero exit status in: install.packages
tensorA)

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

2008-01-29 Thread Peter Jepsen
Hello,

 

I am trying to find an R function to compute 'direct adjusted survival'
with standard errors. A SAS-macro to do this is presented in Zhang X,
Loberiza FR, Klein JP, Zhang MJ. A SAS macro for estimation of direct
adjusted survival curves based on a stratified Cox regression model.
Comput Methods Programs Biomed 2007;88:95-101. It appears that this
method is not implemented in R. Can anyone prove me wrong?

 

Thank you for your time and assistance,

Peter.

 


[[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] Compiling R code

2008-01-29 Thread Daniel Oberski
One suggestion you have probably already considered, but: why not R CMD
BATCH the script? You can set up an executable to do that. No need to
compile the actual R code.

If you want to hide the code and/or it has interaction, you can also set it
up on a web or intranet server for them, calling the R.so or R.dll from a
simple .NET or python script or something like that..

just some ideas,

daniel


On Jan 29, 2008 1:01 PM, Attiglah, Mama [EMAIL PROTECTED] wrote:

 Hi all,
 I am struggling to compile a massive R code that I have written through
 some years, aiming to provide automated investment strategies to my
 Portfolio Managers. You may ask me why do I not rewrite the code in C or
 C++; the answer is it is really massive and that will take me lots of
 time.
 The pb is I will be moving from one team to another therefore I want to
 make it an exec program that the PMs can run in their investment
 universe without my help.
 I am using the very long method described in the R extension doc which
 is taking me time as each block of the code needs to be carefully
 evaluated.
 I researched about the RCC project aiming to do the job but it seems to
 me that the compiler is not yet available.
 Is anyone experienced in compiling R code to an exec file or had a
 similar experience in the past?
 Thanks
 Mama

 -
 Mama Attiglah, PhD
 Advanced Research Center
 Quantitative Research Analyst
 State Street Bank
 +44(0)20 7698 6290 (Direct Line)
 +44 (0)207 004 2968 (Direct Fax)
 Please visit our Web site at
 www.ssga.com


[[alternative HTML version deleted]]

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


[[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] drawing arrows with rgl

2008-01-29 Thread Duncan Murdoch
On 1/29/2008 6:23 PM, Kasper Peeters wrote:
 Hi,
 
 I am looking for a package which allows me to draw arrows (cylinders
 with cones on them, basically) in 3d images produced with rgl. Is such
 a thing available? 

The shapes3d demo in rgl draws cones.  You could use the same ideas to 
draw cylinders.

Once you have instructions to draw one prototypical arrow, you can use 
the scale3d, translate3d and rotate3d functions to reshape it and move it.

I've never found such arrows very visually pleasing, but if you do find 
a way to draw nice ones, please post the code here.

Duncan Murdoch

 
 I did notice the 'compositions' package, which contains
 'arrow3D'. However, it relies on 'tensorA', which fails to install on
 my machine with the error message copied below. If anyone can help me
 fix this problem, that would do the trick too.
 
 Best,
 Kasper
 
 
 trying URL 'http://www.sourcekeg.co.uk/cran/src/contrib/tensorA_0.31.tar.gz'
 Content type 'application/x-tar' length 45248 bytes
 opened URL
 ==
 downloaded 44Kb
 
 * Installing *source* package 'tensorA' ...
 ** libs
 gcc -I/usr/lib/R/include -fPIC  -g -O2 -c tensora.c -o tensora.o
 gcc -shared  -o tensorA.so tensora.o   -L/usr/lib/R/lib -lR
 ** R
 ** preparing package for lazy loading
 Error in gettext(domain, unlist(args)) : invalid 'domain' value
 Execution halted
 ERROR: lazy loading failed for package 'tensorA'
 ** Removing '/usr/local/lib/R/site-library/tensorA'
 
 The downloaded packages are in
 /tmp/RtmpikOKjt/downloaded_packages
 Warning message:
 installation of package 'tensorA' had non-zero exit status in: 
 install.packages
 tensorA)
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Package simex

2008-01-29 Thread Daniel Oberski
Dear Michael

If I understand you correctly, you already have an estimate of the
measurement error? It would seem that if you can estimate the error, then
this estimate comes with a standard error.

For example, suppose that you have a nonlinear model where one of the
predictors is a sum of two variables, which has been measured with error.
You then want to use simex to extrapolate the value the estimator of the
nonlinear model would have if there were no error. If these two variables
are related according to a factor model, then the measurement error estimate
would be the correlation between the variables, with the corresponding s.e.
(assuming the reliabilities of the variables are equal). It depends of
course what the measurement model and corresponding estimates are but you
usually get a standard error with the estimate.

If you want to take into account the variability in this estimate, in the
case of simex an approach would be to simulate values of the measurement
error estimates from its distribution using the standard error, and repeat
the simex procedure each time. You are then in the framework of multiple
imputation. So you need to record the between- and within- variance and
covariance of the estimates, and then combine them according to the rules
laid out by Rubin to get the final variance of the nonlinear model's
estimates. The between covariance matrix you get from the simulations. The
within covariance matrix as I understood from the book needs to be
bootstrapped.

So it is quite a process but certainly possible!

-daniel

P.S.   Note that simex is an approximate method; if you possibly can use
them, the alternative likelihood based or estimating equations approaches
provide a method of correcting the standard errors for uncertainty in the
measurement error estimates. This is explained in the book by Carroll,
Ruppert  Stefanski, in the appendix.



On Jan 28, 2008 2:36 AM, Michael Kubovy [EMAIL PROTECTED] wrote:

 Dear R-helpers,

 It is not clear to me how you get measurement.error SD when you have a
 single dataset, and it is not clear to me how sensitive SIMEX is to
 errors in the estimates of measurement error.

 Could someone please point me to the relevant literature?
 _
 Professor Michael Kubovy
 University of Virginia
 Department of Psychology
 USPS: P.O.Box 400400Charlottesville, VA 22904-4400
 Parcels:Room 102Gilmer Hall
 McCormick RoadCharlottesville, VA 22903
 Office:B011+1-434-982-4729
 Lab:B019+1-434-982-4751
 Fax:+1-434-982-4766
 WWW:
 http://www.people.virginia.edu/~mk9y/http://www.people.virginia.edu/%7Emk9y/

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

2008-01-29 Thread Thomas Lumley
On Wed, 30 Jan 2008, Peter Jepsen wrote:

 I am trying to find an R function to compute 'direct adjusted survival'
 with standard errors. A SAS-macro to do this is presented in Zhang X,
 Loberiza FR, Klein JP, Zhang MJ. A SAS macro for estimation of direct
 adjusted survival curves based on a stratified Cox regression model.
 Comput Methods Programs Biomed 2007;88:95-101. It appears that this
 method is not implemented in R. Can anyone prove me wrong?


This looks like what survexp() does. It's hard to be sure, since I can 
only find the abstract online.

-thomas

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


[R] assign column classes when creating a data frame from several vectors

2008-01-29 Thread kamokoi

R-helpers,

Thanks in advance for your help.  I am an R newbie and I am having trouble
figuring out the easiest/most efficient way to assign classes to columns in
a newly created data frame.  R seems to want to convert everything to a
factor when I use the cbind function to compile vectors into a data frame.  

ID-seq(1,10,1)
TREAT-c(rep(B,5),rep(G,5))
T1-rnorm(10,50,10)
T2-rnorm(10,15,10)
data-as.data.frame(cbind(ID,TREAT,T1,T2))

data

   ID TREAT   T1T2
1   1 B  41.506987139726  20.0964019326073
2   2 B 53.7814271299636   4.9049787919397
3   3 B  54.118333111305  18.2182330777312
4   4 B 48.8591282265369  12.4561774992591
5   5 B 32.3160291908524  23.6665858869752
6   6 G 52.3181626145907 -4.60173207209386
7   7 G 53.4170845444393  2.30744010208809
8   8 G 60.4200675102018  10.9954680147326
9   9 G 42.6264529901835  9.22980548637643
10 10 G 40.2748346897501  14.2458580129253

sapply(data,class)
  IDTREAT   T1   T2 
factor factor factor factor 

The only way I can find to get around this is to use stringsAsFactors=FALSE
and then assign classes to each of the columns individually.

data-as.data.frame(cbind(ID,TREAT,T1,T2), stringsAsFactors=F)
data$ID-as.factor(data$ID)
data$TREAT-as.factor(data$TREAT)
data$T1-as.numeric(data$T1)
data$T2-as.numeric(data$T2)
sapply(data,class)
   ID TREATT1T2 
 factor  factor numeric numeric 

Is there a more efficient way to do the same thing.

Thanks for your help.

 

-- 
View this message in context: 
http://www.nabble.com/assign-column-classes-when-creating-a-data-frame-from-several-vectors-tp15174042p15174042.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] Scale function

2008-01-29 Thread David Winsemius
pellegrini [EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED]:


 There is something that I do not get with scale function.
 
 Say that I have a vector v - c(1,2,3,4,5,6),
 
 scale(v,center=TRUE,scale=TRUE) gives a new vector with 0 as mean
 and 1 as standard deviation.
 
 but,
 
 scale(v, center=FALSE,scale=TRUE) gives a new vector with a standard
  deviation different from 1.
 
 I would also expect a standard deviation of 1 in that case.
 
 am I wrong ?

Appears that you are. From the help page:

If scale is TRUE then scaling is done by dividing the (centered) columns 
of x by their root-mean-square.

The root-mean-square for a column is obtained by computing the square-
root of the sum-of-squares of the non-missing values in the column 
divided by the number of non-missing values minus one.

 sd(scale(warpbreaks$breaks, scale=TRUE)) #default is center=TRUE
[1] 1
 sd(scale(warpbreaks$breaks, center=FALSE, scale=TRUE))
[1] 0.4212988


-- 
David Winsemius

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Guidance for reporting results from lme test?

2008-01-29 Thread lorenz.gygax
Dear Ronny,
 
 I have sucsessfully used a linear mixed effect model, lme, 
 (REML). The results are satisfactory, but I have problems 
 with sorting out how to report the result in a scientific paper.
  
 Is there a genearal guidance for reporting lme results 
 available (web page, book or article)?

This is likely to depend on the specific subject area that you are working in. 
I minimally report F-values and their degrees of freedom plus the p-value in 
applied biology. This is sometimes complemented by reporting the parameter 
estimates (and either their estimated standard error or a confidence interval) 
or by a figure including the model fit. Mostly, the random effects are 
described in the methods section as how they reflect experimental design but 
often no specific details are reported.

Regards, Lorenz
- 
Lorenz Gygax, Dr. sc. nat., postdoc
Federal Veterinary Office
Centre for proper housing of ruminants and pigs
Agroscope Reckenholz-Tänikon Research Station ART
Tänikon, CH-8356 Ettenhausen / Switzerland

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

2008-01-29 Thread jeitel
Dear R-community,
 
I created 5 different xyplots and graphed all of them with the print command on 
one page (e.g. 
 
 print(graph1, split=c(1,1,1,5), more = T)
 
... print(graph5, split=c(1,5,1,5), more =T) 
 
Using the above commands separates each graph by a white space. However, since  
the graphs do share the same x-axis, I was wondering if there is a way to 
concatenate graph1 through 5 so that the white space disappears?
 
Thanks for your time and help
 
Best,
 
Jan
 
Jan 
EitelPhD Candidate of Remote Sensing Room 12 CNRCollege of Natural 
ResourcesUniversity of IdahoMoscow, ID 83844-1133Phone: (208)596-9277Em: [EMAIL 
PROTECTED]://www.cnrhome.uidaho.edu/default.aspx?pid=68846
[[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] Integer vs numeric

2008-01-29 Thread Christophe Genolini
x[c(2,4)] work as well

Henrik Bengtsson a écrit :
 x[1:n]

 /H

 On Jan 29, 2008 5:07 AM,  [EMAIL PROTECTED] wrote:
   
 Seems strange to me to define an operator relatively to a very special case.
 I have to admit that I do not use 1:1e7 every day :-)

 Wouldn't it be more appropriate to define a a:b operator numeric (that
 is preserving the initial class of a and b) and in specific case that
 need optimization, changing the type?

 for i in as.integer(1:1e7)

 That might appears as a minor point, but when using S4, for what I
 know, if you define a class that can take either 1:3 or c(1,3,4), one
 is integer, the other numeric, one of those will not be accepted by the
 class...

 Christophe



 
 On 28-Jan-08 22:40:02, Peter Dalgaard wrote:
   
 [...]
 AFAIR, space is/was more of an issue. If you do something like

 for i in 1:1e7
 some.silly.simulation()

 then you have 40 MB sitting there doing nothing, and 80 MB if
 it had been floating point.
 
 Hmmm ... there's something to be said for good old

  for(i=1,i=1e7,i++){}

 As pointed out in ?for, when you do

  for(i in X){...}  #(e.g. X=(1:1e7))

 the object X is created (or is already there) in full
 at the start and sits there, as you say doing nothing,
 until you end the loop. Whereas the C code just keeps
 track of i and of the condition.

 At least on a couple of my machines (64MB and 184MB RAM)
 knocking out 40MB would inflict severe trauma! Let alone 80MB.
 Mind you, the little one is no longer allowed to play with
 big boys like R, though the other one is still used for
 moderate-sized games.

 Would there be much of a time penalty in implementing
 a 'for' loop, C-style, as

  i-1
  while(i=1e7){
...
i-i+1
  }

 ??

 It looks as though there might be:

  system.time(for(i in (1:1e7)) x-cos(3) )
  #[1] 13.521  0.132 13.355  0.000  0.000
  system.time({i-1;while(i=1e7){x-cos(3);i-i+1}})
  #[1] 38.270  0.076 37.629  0.000  0.000

 which suggests that the latter is about 3 times as slow.
 (And no, this wasn't done on either of my puny babes).

 (And this isn't the first time I've wished for an R
 implementation of ++ as a CPU-level incrementation,
 as opposed to the R-arithmetic implementation which
 treats adding 1 to a variable as a full-dress
 arithmetic parade!

 Best wishes,
 Ted.

 
 E-Mail: (Ted Harding) [EMAIL PROTECTED]
 Fax-to-email: +44 (0)870 094 0861
 Date: 28-Jan-08   Time: 23:34:52
 -- XFMail --

   

 
 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-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Random and fixed effect model with a covariate

2008-01-29 Thread lorenz.gygax
Dear Sophie,

 I wonder if anyone can please offer any advice on a model 
 including 2 fixed effects and 1 random effect, as well as a 
 covariate? 
 
 The experimental design is as follows:
 I have a two by two factor design, where the two factors, Age 
 (A) and Group size (G), both have 2 levels (old or young, and 
 1 or 3 respectively), and I am interested in the effect of 
 these factors upon a continuous Response variable (R).
 
 The data is from social insects, so the above design is 
 repeated for several colonies. I think that Colony (C) should 
 be a random factor, as they were taken from a larger pool of 
 available colonies. Identification number (I) is different 
 for each individual.
 
 Furthermore, I have a covariate, Mass (M), which could have 
 an effect upon R.

This sounds all quite reasonable.

 Do you know which of the below (if any) would be the most 
 appropriate model please?
 
 model-lme(R~A*G*M,random=~1|C/I)
 model-lme(R~A*G+M,random=~1|C/I)

Well, this depends on your research question and whether or not interactions 
between A:M, A:G and A:G:M can be interpreted meaningfully, I would say.

 or is it necessary to state that A and G are factors as below:
 
 model-lme(R~as.factor(A)*as.factor(G)*M,random= ~1|C/I)
 model-lme(R~as.factor(A)*as.factor(G)+M,random= ~1|C/I)

Yes, indeed, you need to specify factors as such. If they are factors it 
possibly makes sense to change their type in the data frame as many other 
functions (e.g. plotting functions) do different things with factors rather 
than continuous variables.

If your factor levels include letters then R automatically turns these 
variables into factors while you read the data. A two-level factor can be coded 
numerically with 0 and 1s instead of explicitly turning it into a factor 
variable.

 Do you also please have any advice upon the effect it would 
 have to change the order in which the factors and covariate 
 are placed in the model? When I tried moving them around in 
 the above models it changed the test statistics slightly. 

Well, the standard anova output follows a type I sum-of-squares logic, i.e. 
each addditional variable (lower down in the list) is tested for a significant 
improvement of the model so far. Thus, the seuquence has some importance.

If you use anova (..., type= 'marginal') you can follow a type III 
sum-of-squares logic, i.e. it is tested whether dropping a specific variable 
from the full model leads to a significant deterioration of the model or not.

In my perception, there are different schools of thought that either prefer the 
one or the other. Thus, perhaps you should use what is commonly used in your 
field.

Regards, Lorenz
- 
Lorenz Gygax, Dr. sc. nat., postdoc
Federal Veterinary Office
Centre for proper housing of ruminants and pigs
Agroscope Reckenholz-Tänikon Research Station ART
Tänikon, CH-8356 Ettenhausen / Switzerland

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Multiplying each row of a big matrix with a vector

2008-01-29 Thread Megh Dal
I have a big matrix 'ret'. I want to multiply each row of it with a 2nd vector 
'pos', resulting result, I want to save in a vector named 'port'. I wrote 
following code:
   
   pos
[1]  2593419  2130220  6198197  1673888  198  1784732  2052120 -7490228 
-5275000

   
   dim(ret)
[1] 500   9

   fu# user defined function
function(x)
   {
fu = x %*% t(pos)
   }
port = apply(ret, 1, fu)

   dim(port)
[1]  81 500

  My desire is to get port as a vector with length 500. However I am not 
getting that?
   
  Can anyone tell me how to correct that? 
   
  Regards,
   

   
-

[[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] Multiplying each row of a big matrix with a vector

2008-01-29 Thread Bill.Venables
port - as.vector(ret %*% port)

should do it. 


Bill Venables

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Megh Dal
Sent: Wednesday, 30 January 2008 5:20 PM
To: [EMAIL PROTECTED]
Subject: [R] Multiplying each row of a big matrix with a vector

I have a big matrix 'ret'. I want to multiply each row of it with a 2nd
vector 'pos', resulting result, I want to save in a vector named 'port'.
I wrote following code:
   
   pos
[1]  2593419  2130220  6198197  1673888  198  1784732  2052120
-7490228 -5275000

   
   dim(ret)
[1] 500   9

   fu# user defined function
function(x)
   {
fu = x %*% t(pos)
   }
port = apply(ret, 1, fu)

   dim(port)
[1]  81 500

  My desire is to get port as a vector with length 500. However I am not
getting that?
   
  Can anyone tell me how to correct that? 
   
  Regards,
   

   
-

[[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] [OT] vernacular names for circular diagrams

2008-01-29 Thread Jean lobry

  On Mon, 28 Jan 2008 13:38:51 -0600, Roger Koenker wrote:

  Howard Wainer  (Graphical Discovery, PUP, 2005, p 20) gives
  this dubious honor to Playfair (1759- 1823).   Nightingale (1820-
  1910) was far too enlightened for this sort of thing, see for example
  her letter to Galton about endowing an Oxford professorship
  in social statistics (reprinted in Karl Pearson's bio of Galton:

 
http://galton.org/cgi-bin/searchImages/search/pearson/vol2/pages/vol2_0482.htm

  It sets a very ambitious agenda that we have not yet made much
  progress on...

So, if the pie chart was invented by Florence Nightingale (1820-1910), then
William Playfair (1759-1823) would be guilty of what the surrealists called a
plagiarism by anticipation.

Best,

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

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Odp: Multiplying each row of a big matrix with a vector

2008-01-29 Thread Petr PIKAL
I am not sure if you really want what you explain that you want

To multiply each row with a vector you can use e.g.

t(apply(ret,1, function(y) pos*y))

or

t(t(ret)*pos)

but then you will get the same matrix just multiplied by a vector.

If you want to perform matrix multiplication then just

ret %*% pos will do it for you

Petr Pikal
[EMAIL PROTECTED]

[EMAIL PROTECTED] napsal dne 30.01.2008 08:20:21:

 I have a big matrix 'ret'. I want to multiply each row of it with a 2nd 
vector
 'pos', resulting result, I want to save in a vector named 'port'. I 
wrote 
 following code:
 
pos
 [1]  2593419  2130220  6198197  1673888  198  1784732  2052120 
-7490228 -5275000
 
 
dim(ret)
 [1] 500   9
 
fu# user defined function
 function(x)
{
 fu = x %*% t(pos)
}
 port = apply(ret, 1, fu)
 
dim(port)
 [1]  81 500
 
   My desire is to get port as a vector with length 500. However I am not 
getting that?
 
   Can anyone tell me how to correct that? 
 
   Regards,
 
 
 
 -
 
[[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.