Re: [R] Cannot save histogram picture when run from script

2008-02-01 Thread Dieter Menne
Ng Stanley stanleyngkl at gmail.com writes:

 I am faced with a strange problem. My picture file is empty when the
 following statements were run from R script. But the picture file shows up
 correctly, when the commands are individually run from Rgui.
 
 png(file=histogram_correlation.png, bg = white)
 require(stats)
 histogram( ~ height | voice.part, data = singer, nint = 17,
   endpoints = c(59.5, 76.5), layout = c(2,4), aspect = 1,
   xlab = Height (inches))
 dev.off()
 

The FAQ of FAQs, but admittely confusing (I remember Douglas Bates calling
Deepayan in the middle of the night in India): lattice graphics must be printed
in this context. I usually do it in two steps:

p = histogram(...)
print(p,(add layout if required here))

Dieter

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


[R] Reformatting data into data frame and plotting it in ggplot2

2008-02-01 Thread Tribo Laboy
Hello,

 I am sure this must have been asked before, but my nabble search did
 not turn anything useful. Just pointer where to look will also be
 nice.

 So, I have the following data:

 x_test1 - c(1:10)
 y_test1-rnorm(10)
 x_test2 - c(1:15)
 y_test2-rnorm(15)
 x_test3 - c(1:20)
 y_test3-rnorm(20)

 These represent time series or frequency spectra, possibly sampled
 with different sampling frequencies, but obviously having different
 lengths. The physical meaning of X and Y is the same for the three
 series above - as I said, time or frequency in my case.
 Now I want to plot them on the same graph with the legend test1,
 test2 and test3.

 ggplot PDF manual says that the data frame is the preferable format
 for the data to plot. I guess that turning the above data into a data
 frame would be useful in many other situations as well. So how can I
 do that?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Reformatting data into data frame and plotting it in ggplot2

2008-02-01 Thread ONKELINX, Thierry
Tribo,

Use data.frame() and rbind() to combine the vectors.

 
x_test1 - c(1:10)
 y_test1-rnorm(10)
 x_test2 - c(1:15)
 y_test2-rnorm(15)
 x_test3 - c(1:20)
 y_test3-rnorm(20)
 
dataset - rbind(data.frame(Test = Test 1, x = x_test1, y = y_test1),
data.frame(Test = Test 2, x = x_test2, y = y_test2), data.frame(Test =
Test 3, x = x_test3, y = y_test3))
dataset$Test - factor(dataset$Test)

library(ggplot2)
ggplot(data = dataset, aes(x = x, y = y, colour = Test)) + geom_line()

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 Tribo Laboy
Verzonden: vrijdag 1 februari 2008 9:59
Aan: r-help@r-project.org
Onderwerp: [R] Reformatting data into data frame and plotting it in
ggplot2

Hello,

 I am sure this must have been asked before, but my nabble search did
not turn anything useful. Just pointer where to look will also be  nice.

 So, I have the following data:

 x_test1 - c(1:10)
 y_test1-rnorm(10)
 x_test2 - c(1:15)
 y_test2-rnorm(15)
 x_test3 - c(1:20)
 y_test3-rnorm(20)

 These represent time series or frequency spectra, possibly sampled
with different sampling frequencies, but obviously having different
lengths. The physical meaning of X and Y is the same for the three
series above - as I said, time or frequency in my case.
 Now I want to plot them on the same graph with the legend test1,
test2 and test3.

 ggplot PDF manual says that the data frame is the preferable format
for the data to plot. I guess that turning the above data into a data
frame would be useful in many other situations as well. So how can I  do
that?

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

2008-02-01 Thread Shubha Vishwanath Karanth
Hi R,

 

I wanted to know how do we access the elements of a list. In particular,

 

v=list(c(1,2,3,4,5),c(1,2,33,4,5),c(1,2,333,4,5),c(1,2,,4,5))

 

I want to access all the thirds items of the elements of the list. i.e.,
I want to access the elements, 3,33,333,. This can be done through
sapply as:

 

sapply(v,function(x) x[3])

 

But I need to access this without using 'sapply'. Like in a data frame,
we do df[2,3] etc Any ideas?

 

 

BR, Shubha

This e-mail may contain confidential and/or privileged i...{{dropped:13}}

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

2008-02-01 Thread john seers (IFR)

Hi All

I have looked but cannot find an answer to this.

I want to build a formula dynamically (in a function), using for example
paste, and using it in a model:

fr-F1
f1-formula(paste(fr, ~ SensoryTerm))
m1-aov(f1, data=vdata)

So this is the equivalent of m1-aov(F1 ~ SensoryTerm, data=vdata)

This works fine but the problem is the formula appears as f1 in the
summary(m1) of the model and not F1 ~ SensoryTerm. With many models
this can be a bit confusing 

Is there a way to code this so the formula appears in the model summary?

Regards


John Seers




 sessionInfo()
R version 2.6.1 (2007-11-26) 
i386-pc-mingw32 

locale:
LC_COLLATE=English_United Kingdom.1252;LC_CTYPE=English_United
Kingdom.1252;LC_MONETARY=English_United
Kingdom.1252;LC_NUMERIC=C;LC_TIME=English_United Kingdom.1252

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


other attached packages:
 [1] pixmap_0.4-7  gplots_2.3.2  gdata_2.3.1   gtools_2.4.0
rcom_1.5-2.2 
 [6] nnet_7.2-38   e1071_1.5-17  class_7.2-38  tree_1.0-26   mgcv_1.3-29

[11] MASS_7.2-38   car_1.2-7 RODBC_1.2-2   RWinEdt_1.7-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] Building a formula using paste

2008-02-01 Thread Bill.Venables
use as.formula() rather than just formula(). 


Bill Venables
CSIRO Laboratories
PO Box 120, Cleveland, 4163
AUSTRALIA
Office Phone (email preferred): +61 7 3826 7251
Fax (if absolutely necessary):  +61 7 3826 7304
Mobile: +61 4 8819 4402
Home Phone: +61 7 3286 7700
mailto:[EMAIL PROTECTED]
http://www.cmis.csiro.au/bill.venables/ 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of john seers (IFR)
Sent: Friday, 1 February 2008 7:31 PM
To: [EMAIL PROTECTED]
Subject: [R] Building a formula using paste


Hi All

I have looked but cannot find an answer to this.

I want to build a formula dynamically (in a function), using for example
paste, and using it in a model:

fr-F1
f1-formula(paste(fr, ~ SensoryTerm))
m1-aov(f1, data=vdata)

So this is the equivalent of m1-aov(F1 ~ SensoryTerm, data=vdata)

This works fine but the problem is the formula appears as f1 in the
summary(m1) of the model and not F1 ~ SensoryTerm. With many models
this can be a bit confusing 

Is there a way to code this so the formula appears in the model summary?

Regards


John Seers




 sessionInfo()
R version 2.6.1 (2007-11-26) 
i386-pc-mingw32 

locale:
LC_COLLATE=English_United Kingdom.1252;LC_CTYPE=English_United
Kingdom.1252;LC_MONETARY=English_United
Kingdom.1252;LC_NUMERIC=C;LC_TIME=English_United Kingdom.1252

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


other attached packages:
 [1] pixmap_0.4-7  gplots_2.3.2  gdata_2.3.1   gtools_2.4.0
rcom_1.5-2.2 
 [6] nnet_7.2-38   e1071_1.5-17  class_7.2-38  tree_1.0-26   mgcv_1.3-29

[11] MASS_7.2-38   car_1.2-7 RODBC_1.2-2   RWinEdt_1.7-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.


Re: [R] R2WinBUGS is broken

2008-02-01 Thread Uwe Ligges
Dear John,

this is a new bug caused by a side effect from a new bugs.log function 
by Jouni Kerman that improves many other things. I have fixed it in the 
master sources on sourceforge right now and a bugfix release will appear 
on CRAN within a couple of days.

Best,
Uwe Ligges



John Smith wrote:
 Dear R-users,
 
 I am trying to use the following code to reproduce results from Prof.
 Gelman's book, but have the listed error for R2WinBUGS version (the openbugs
 version is good). I am using R-2.6.1 on windows XP, and all the R packages
 are most current ones. schools.bug can be found at
 http://www.stat.columbia.edu/~gelman/bugsR/runningbugs.html . Can anyone
 help me to figure out what's going wrong?
 
 
 rm(list=ls())
 library(R2WinBUGS)
 library ('BRugs')
 setwd('C:/bayesian/bda/codes/example_5_5')
 data(schools)
 J - nrow(schools)
 y - schools$estimate
 sigma.y - schools$sd
 data - list(J=J, y=y, sigma.y=sigma.y)
 
 inits - function()
   list(theta=rnorm(J,0,100), mu.theta=rnorm(1,0,100),
sigma.theta=runif(1,0,100))
 parameters - c('theta', 'mu.theta', 'sigma.theta')
 schools.sim - bugs(data, inits, parameters, model.file='schools.bug',
 n.chains=3, n.iter=1000, clearWD=TRUE)
 ## schools.sim - bugs(data, inits, parameters, model.file='schools.bug',
 ## n.chains=3, n.iter=1000, clearWD=TRUE,
 ## program = 'openbugs')
 print(schools.sim)
 plot(schools.sim)
 
 
 
 Error in matrix(unlist(mx), ncol = n.cols, byrow = TRUE) :
   invalid 'nrow' value (too large or NA)
 
 
 
 Thanks
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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

2008-02-01 Thread Bill.Venables
 
I find it hard to imagine you need to do it without using sapply.  If
you get over your phobia, you might like to try

sapply(v, [, 3)

If the elements of the list are all the same length, as in your example,
you could do

data.frame(v)[3, ]

I think we need to know more about why you think you can't use sapply
before we can really help you, though.

Bill Venables.


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Shubha Vishwanath Karanth
Sent: Friday, 1 February 2008 7:05 PM
To: [EMAIL PROTECTED]
Subject: [R] Accessing the elements of a list

Hi R,

 

I wanted to know how do we access the elements of a list. In particular,

 

v=list(c(1,2,3,4,5),c(1,2,33,4,5),c(1,2,333,4,5),c(1,2,,4,5))

 

I want to access all the thirds items of the elements of the list. i.e.,
I want to access the elements, 3,33,333,. This can be done through
sapply as:

 

sapply(v,function(x) x[3])

 

But I need to access this without using 'sapply'. Like in a data frame,
we do df[2,3] etc Any ideas?

 

 

BR, Shubha

This e-mail may contain confidential and/or privileged
i...{{dropped:13}}

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

2008-02-01 Thread Bill.Venables
Please disregard my previous reply.  Now that I have read your question,
all becomes clear.

To do what you want to do is a bit tricky.  Here is one way

f1 - as.name(F1)
fm - eval(bquote(aov(.(f1) ~ sensoryTerm, data = vdata)))

Them fm is the fitted model object, suitably formed.

EOE, of course! 


Bill Venables
CSIRO Laboratories
PO Box 120, Cleveland, 4163
AUSTRALIA
Office Phone (email preferred): +61 7 3826 7251
Fax (if absolutely necessary):  +61 7 3826 7304
Mobile: +61 4 8819 4402
Home Phone: +61 7 3286 7700
mailto:[EMAIL PROTECTED]
http://www.cmis.csiro.au/bill.venables/ 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Venables, Bill (CMIS, Cleveland)
Sent: Friday, 1 February 2008 7:45 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: [R] Building a formula using paste

use as.formula() rather than just formula(). 


Bill Venables
CSIRO Laboratories
PO Box 120, Cleveland, 4163
AUSTRALIA
Office Phone (email preferred): +61 7 3826 7251
Fax (if absolutely necessary):  +61 7 3826 7304
Mobile: +61 4 8819 4402
Home Phone: +61 7 3286 7700
mailto:[EMAIL PROTECTED]
http://www.cmis.csiro.au/bill.venables/ 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of john seers (IFR)
Sent: Friday, 1 February 2008 7:31 PM
To: [EMAIL PROTECTED]
Subject: [R] Building a formula using paste


Hi All

I have looked but cannot find an answer to this.

I want to build a formula dynamically (in a function), using for example
paste, and using it in a model:

fr-F1
f1-formula(paste(fr, ~ SensoryTerm))
m1-aov(f1, data=vdata)

So this is the equivalent of m1-aov(F1 ~ SensoryTerm, data=vdata)

This works fine but the problem is the formula appears as f1 in the
summary(m1) of the model and not F1 ~ SensoryTerm. With many models
this can be a bit confusing 

Is there a way to code this so the formula appears in the model summary?

Regards


John Seers




 sessionInfo()
R version 2.6.1 (2007-11-26) 
i386-pc-mingw32 

locale:
LC_COLLATE=English_United Kingdom.1252;LC_CTYPE=English_United
Kingdom.1252;LC_MONETARY=English_United
Kingdom.1252;LC_NUMERIC=C;LC_TIME=English_United Kingdom.1252

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


other attached packages:
 [1] pixmap_0.4-7  gplots_2.3.2  gdata_2.3.1   gtools_2.4.0
rcom_1.5-2.2 
 [6] nnet_7.2-38   e1071_1.5-17  class_7.2-38  tree_1.0-26   mgcv_1.3-29

[11] MASS_7.2-38   car_1.2-7 RODBC_1.2-2   RWinEdt_1.7-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-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Building a formula using paste

2008-02-01 Thread Peter Dalgaard
[EMAIL PROTECTED] wrote:
 use as.formula() rather than just formula(). 


   
Hm?

That doesn't seem to cut it for me:

 f - as.formula(y~x)
 lm(f)

Call:
lm(formula = f)

Coefficients:
(Intercept)x
0.06437 -0.09714

 summary(lm(f))

Call:
lm(formula = f)

Residuals:
Min  1Q  Median  3Q Max
-1.2780 -0.4229 -0.3208  0.7534  1.3073

Coefficients:
Estimate Std. Error t value Pr(|t|)
(Intercept)  0.064370.61961   0.1040.920
x   -0.097140.09986  -0.9730.359

Residual standard error: 0.907 on 8 degrees of freedom
Multiple R-Squared: 0.1058, Adjusted R-squared: -0.005995
F-statistic: 0.9464 on 1 and 8 DF,  p-value: 0.3591

etc.

The problem is that we get the call and not the formula, and this
appears to be the case whether you use formula or as.formula. Also

 identical(as.formula(y~x), formula(y~x))
[1] TRUE

I see two workarounds:

(a) Extract the formula explicitly and print it along with the output

 formula(m)
y ~ x
 m

Call:
lm(formula = f)

Coefficients:
(Intercept)x
0.06437 -0.09714

(b) substitution tricks, e.g.

 eval(bquote(lm(.(f

Call:
lm(formula = y ~ x)

Coefficients:
(Intercept)x
0.06437 -0.09714



 Hi All

 I have looked but cannot find an answer to this.

 I want to build a formula dynamically (in a function), using for example
 paste, and using it in a model:

   fr-F1
   f1-formula(paste(fr, ~ SensoryTerm))
   m1-aov(f1, data=vdata)

 So this is the equivalent of m1-aov(F1 ~ SensoryTerm, data=vdata)

 This works fine but the problem is the formula appears as f1 in the
 summary(m1) of the model and not F1 ~ SensoryTerm. With many models
 this can be a bit confusing 

 Is there a way to code this so the formula appears in the model summary?

   
   


-- 
   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] Accessing the elements of a list

2008-02-01 Thread Thibaut Jombart
Shubha Vishwanath Karanth wrote:
 Hi R,

  

 I wanted to know how do we access the elements of a list. In particular,

  

 v=list(c(1,2,3,4,5),c(1,2,33,4,5),c(1,2,333,4,5),c(1,2,,4,5))

  

 I want to access all the thirds items of the elements of the list. i.e.,
 I want to access the elements, 3,33,333,. This can be done through
 sapply as:

  

 sapply(v,function(x) x[3])

  

 But I need to access this without using 'sapply'. Like in a data frame,
 we do df[2,3] etc Any ideas?

   
Hi,

not the most elegant, but this works:

cmd  unlist(as.data.frame(v)[3,])
   c.1..2..3..4..5.   c.1..2..33..4..5.  c.1..2..333..4..5. 
c.1..2....4..5.
  3  33 
333

Cheers,

Thibaut.

-- 
##
Thibaut JOMBART
CNRS UMR 5558 - Laboratoire de Biométrie et Biologie Evolutive
Universite Lyon 1
43 bd du 11 novembre 1918
69622 Villeurbanne Cedex
Tél. : 04.72.43.29.35
Fax : 04.72.43.13.88
[EMAIL PROTECTED]
http://lbbe.univ-lyon1.fr/-Jombart-Thibaut-.html?lang=en
http://pbil.univ-lyon1.fr/software/adegenet/

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

2008-02-01 Thread David Keegan
Hi,

foo-x(...)
{  # Need to remove bad characters from string arguments ...
   # here.

   # Pass on the modified string arguments.
   bar(...)
}

I need to modify string arguments passed in to function foo
as ... and then pass the modified arguments on to function
bar. Is there a way to access the contents of ... for
in-place modification?

I know I can use args - list(...), but presumably that
takes a copy. Unless there is a way to pass the list
as ... in the call to bar?

Regards,
David.
-- 
[David Keegan [EMAIL PROTECTED] 353 1 2710818]

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

2008-02-01 Thread S Ellison
I'm no guru, but can you not use do.call here?

i.e. does

foo-function(...) #Not x(...)
{  
   arglist-list(...)
   #remove bad characters from arglist here.
   
   # then
   do.call(bar,arglist)

}

do what you want?

 David Keegan [EMAIL PROTECTED] 01/02/2008 11:00:15 
Hi,

foo-x(...)
{  # Need to remove bad characters from string arguments ...
   # here.

   # Pass on the modified string arguments.
   bar(...)
}

I need to modify string arguments passed in to function foo
as ... and then pass the modified arguments on to function
bar. Is there a way to access the contents of ... for
in-place modification?

I know I can use args - list(...), but presumably that
takes a copy. Unless there is a way to pass the list
as ... in the call to bar?

Regards,
David.
-- 
[David Keegan [EMAIL PROTECTED] 353 1 2710818]

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

***
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] Reformatting data into data frame and plotting it in ggplot2

2008-02-01 Thread Tribo Laboy
Hello,

I am sure this must have been asked before, but my nabble search did
not turn anything useful. Just pointer where to look will also be
nice.

So, I have the following data:

x_test1 - c(1:10)
y_test1-rnorm(10)
x_test2 - c(1:15)
y_test2-rnorm(15)
x_test3 - c(1:20)
y_test3-rnorm(20)

These represent time series or frequency spectra, possibly sampled
with different sampling frequencies, but obviously having different
lengths. The physical meaning of X and Y is the same for the three
series above - as I said, time or frequency in my case.
Now I want to plot them on the same graph with the legend test1,
test2 and test3.

ggplot PDF manual says that the data frame is the preferable format
for the data to plot. I guess that turning the above data into a data
frame would be useful in many other situations as well. So how can I
do that?

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


Re: [R] Saving a big table or matrix

2008-02-01 Thread Gabor Csardi
?save
?load

Gabor

ps. although i'm not sure what an Rdata-project means, so maybe you
need something else

On Fri, Feb 01, 2008 at 08:24:32AM +0200, Atte Tenkanen wrote:
 Dear R-users,
 
 How do you save a big table or matrix as an independent object and attach it 
 to your Rdata-project when needed?
 
 Atte Tenkanen
 University of Turku, Finland
 Department of Musicology
 +023335278
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

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


Re: [R] re placing values in a matrix

2008-02-01 Thread Gabor Csardi
Actually, you don't need apply. If there are no NA's then it is 
very easy:

m[] - y[ col(m) ]

If you want to keep the NA's then it is a bit more tricky:

m[] - 0*m + y[ col(m) ]


G.

On Thu, Jan 31, 2008 at 07:03:51PM -0800, dxc13 wrote:
 
 useR's,
 
 Consider:
 y - c(20, 25, 30)
  m - matrix(c(0.0,1,NA,0.5,1.25,0.75, 0.5, NA,
  NA),byrow=TRUE,nrow=3,ncol=3)
  m
  [,1] [,2] [,3]
 [1,]  0.0 1.00   NA
 [2,]  0.5 1.25 0.75
 [3,]  0.5   NA   NA
 
 For each numeric value, I want to replace them with their corresponding
 y-value.  The result should look like (here, each row represents a variable
 rather than the columns):
   [,1] [,2] [,3]
 [1,]  20   25   NA
 [2,]  20   25   30
 [3,]  20  NA   NA
 
 Does anyone know how I can do this using apply()?  Or is there an easier
 way?  Thanks in advance.
 
 Derek
 -- 
 View this message in context: 
 http://www.nabble.com/replacing-values-in-a-matrix-tp15219764p15219764.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.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] problem getting multiple densityplots on one page

2008-02-01 Thread Ng Stanley
Hi,

I used the following statements to generate unsuccessfully a 5 by 5 multiple
densityplots on a single page. If I use plot, the whole thing works.

 data - matrix(rnorm(25), 5, 5)
 op - par(mfrow = c(5, 5))
 for (x in 1:5) {densityplot(data[,x])}
 par(op)

Thanks
Stanley

[[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] random forest and vegetation data

2008-02-01 Thread ahelmore
Hi there,

I am an environmental studies masters student trying to get my thesis out the 
door.  I am also newbie at trees in general, but I like what I see in the 
literature about the random forest algorithm.  I think I get the general gist 
of things, but even after reading stuff I’m unclear about how I could be 
getting the results I’m seeing.  I obviously am missing something about how the 
split points in the final tree are decided.

I’ve been using random forests in image classification by entering split values 
into decision tree classifiers, and that has seemed work very well.  The map 
output appears legitimate and withheld data gives confusion matrices similar to 
the predictive errors from the random forest.  This leads me to assume that the 
split points are effective.

However now that I’ve turned to the ecological portion of my analysis, with a 
data set that contains few variable levels and lots of zeros, suddenly the 
splitting node information is not making sense.

Here is my situation.  I have a matrix of study plots that each belong to one 
of three elevation classes and which each have percent cover class data for 15 
plant species associated with them.  

plotelevsp1 sp2 sp3… sp15
1   3   0   2   6…  5
2   0   0   0   1…  0
etc.

The species data are ordered factors from 0-9.  When I run the algorithm using 
species cover values to predict elevation class, two species alone come up as 
the best predictors.  That makes ecological sense in this setting, given the 
species ranges in question.

Here’s my difficulty though.  The split point values can’t be interpreted, as 
far as I can tell.  I’m getting split points of, say, 1.5 and 2.5 for a species 
who’s cover is either 0 (absent) or 4 and above.  So obviously the split points 
in the final tree are being generated in some way I don’t understand.  
Averaged?  

I’ve tried running the tree using the data as factors, using the data as 
ordered factors, and using the data as numerical variables, just to see if I 
could gain insight into what’s going on, but I’m coming up clueless.  My 
literature hunt reveals repeated instances of folks saying that the final tree 
can’t be interpreted the way other trees are, but I’m not getting a lot on just 
why that might be.  

Some folks talk about the final tree being “averaged,” others say that “mode,” 
is employed (which doesn’t make sense to me if I’m getting 1.5 and 2.5 split 
values).  If the trees are only good as black box predictors (which is of 
course a very useful thing in itself), should I even be using the node 
information in my image classifications?  

As you see, I’m missing some rather important point or other here.  Can you 
enlighten?

Thanks,
A
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Saving a big table or matrix

2008-02-01 Thread Atte Tenkanen
Dear R-users,

How do you save a big table or matrix as an independent object and attach it to 
your Rdata-project when needed?

Atte Tenkanen
University of Turku, Finland
Department of Musicology
+023335278

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Reformatting data into data frame and plotting it in ggplot2

2008-02-01 Thread Tribo Laboy
Hi, Thierry,

That was exactly what I was looking for. Thanks.

Now I have a data frame with the series data in my workspace, and a
plot on the graphics device with color lines and respective color
patches on the legend. My next question is about ggplot. Is it
possible to make the legend show not only the aesthetics (color in
this case), but also the geometry (lines). It would look much better
if it showed colored lines or colored dots (if it were) instead of
just the patch. But again the ggplot manual didn't have an example for
that. Also, what if I wanted to plot with lines+symbol, do I have to
use multiple layers? Is it (easily) achievable?

Too many questions... I guess it shows I am quite new to R, but I hope
to pick it up quickly with some help and shift all my plotting from
Matlab to R.


On Fri, Feb 1, 2008 at 6:09 PM, ONKELINX, Thierry
[EMAIL PROTECTED] wrote:
 Tribo,

  Use data.frame() and rbind() to combine the vectors.



  x_test1 - c(1:10)
   y_test1-rnorm(10)
   x_test2 - c(1:15)
   y_test2-rnorm(15)
   x_test3 - c(1:20)
   y_test3-rnorm(20)

  dataset - rbind(data.frame(Test = Test 1, x = x_test1, y = y_test1),
  data.frame(Test = Test 2, x = x_test2, y = y_test2), data.frame(Test =
  Test 3, x = x_test3, y = y_test3))
  dataset$Test - factor(dataset$Test)

  library(ggplot2)
  ggplot(data = dataset, aes(x = x, y = y, colour = Test)) + geom_line()

  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 Tribo Laboy
  Verzonden: vrijdag 1 februari 2008 9:59
  Aan: r-help@r-project.org
  Onderwerp: [R] Reformatting data into data frame and plotting it in
  ggplot2



  Hello,

   I am sure this must have been asked before, but my nabble search did
  not turn anything useful. Just pointer where to look will also be  nice.

   So, I have the following data:

   x_test1 - c(1:10)
   y_test1-rnorm(10)
   x_test2 - c(1:15)
   y_test2-rnorm(15)
   x_test3 - c(1:20)
   y_test3-rnorm(20)

   These represent time series or frequency spectra, possibly sampled
  with different sampling frequencies, but obviously having different
  lengths. The physical meaning of X and Y is the same for the three
  series above - as I said, time or frequency in my case.
   Now I want to plot them on the same graph with the legend test1,
  test2 and test3.

   ggplot PDF manual says that the data frame is the preferable format
  for the data to plot. I guess that turning the above data into a data
  frame would be useful in many other situations as well. So how can I  do
  that?

  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/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] problem getting multiple densityplots on one page

2008-02-01 Thread Rainer M Krug
On 01/02/2008, Ng Stanley [EMAIL PROTECTED] wrote:

 Hi,

 I used the following statements to generate unsuccessfully a 5 by 5
 multiple
 densityplots on a single page. If I use plot, the whole thing works.

  data - matrix(rnorm(25), 5, 5)
  op - par(mfrow = c(5, 5))
  for (x in 1:5) {par(new=TRUE);densityplot(data[,x], xlim=c(...))}


See changes in line above. par(new=TRUE) to overplot and xlim() to have
same  x limits.  The y-limits can be set the same way if necessary.
untested!
Rainer

 par(op)

 Thanks
 Stanley

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




-- 

-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation Biology (UCT)

Plant Conservation Unit Department of Botany
University of Cape Town
Rondebosch 7701
South Africa

[[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] Building a formula using paste

2008-02-01 Thread john seers (IFR)
 
Thank you very much. That problem has been niggling me for some time. 

I slotted in your code and it worked. I just need to spend a bit of time
understanding it ...

Thanks again.

John Seers




 
---

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: 01 February 2008 09:57
To: [EMAIL PROTECTED]; john seers (IFR); [EMAIL PROTECTED]
Subject: RE: [R] Building a formula using paste

Please disregard my previous reply.  Now that I have read your question,
all becomes clear.

To do what you want to do is a bit tricky.  Here is one way

f1 - as.name(F1)
fm - eval(bquote(aov(.(f1) ~ sensoryTerm, data = vdata)))

Them fm is the fitted model object, suitably formed.

EOE, of course! 


Bill Venables
CSIRO Laboratories
PO Box 120, Cleveland, 4163
AUSTRALIA
Office Phone (email preferred): +61 7 3826 7251 Fax (if absolutely
necessary):  +61 7 3826 7304
Mobile: +61 4 8819 4402
Home Phone: +61 7 3286 7700
mailto:[EMAIL PROTECTED]
http://www.cmis.csiro.au/bill.venables/ 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Venables, Bill (CMIS, Cleveland)
Sent: Friday, 1 February 2008 7:45 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: [R] Building a formula using paste

use as.formula() rather than just formula(). 


Bill Venables
CSIRO Laboratories
PO Box 120, Cleveland, 4163
AUSTRALIA
Office Phone (email preferred): +61 7 3826 7251 Fax (if absolutely
necessary):  +61 7 3826 7304
Mobile: +61 4 8819 4402
Home Phone: +61 7 3286 7700
mailto:[EMAIL PROTECTED]
http://www.cmis.csiro.au/bill.venables/ 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of john seers (IFR)
Sent: Friday, 1 February 2008 7:31 PM
To: [EMAIL PROTECTED]
Subject: [R] Building a formula using paste


Hi All

I have looked but cannot find an answer to this.

I want to build a formula dynamically (in a function), using for example
paste, and using it in a model:

fr-F1
f1-formula(paste(fr, ~ SensoryTerm))
m1-aov(f1, data=vdata)

So this is the equivalent of m1-aov(F1 ~ SensoryTerm, data=vdata)

This works fine but the problem is the formula appears as f1 in the
summary(m1) of the model and not F1 ~ SensoryTerm. With many models
this can be a bit confusing 

Is there a way to code this so the formula appears in the model summary?

Regards


John Seers




 sessionInfo()
R version 2.6.1 (2007-11-26)
i386-pc-mingw32 

locale:
LC_COLLATE=English_United Kingdom.1252;LC_CTYPE=English_United
Kingdom.1252;LC_MONETARY=English_United
Kingdom.1252;LC_NUMERIC=C;LC_TIME=English_United Kingdom.1252

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


other attached packages:
 [1] pixmap_0.4-7  gplots_2.3.2  gdata_2.3.1   gtools_2.4.0
rcom_1.5-2.2 
 [6] nnet_7.2-38   e1071_1.5-17  class_7.2-38  tree_1.0-26   mgcv_1.3-29

[11] MASS_7.2-38   car_1.2-7 RODBC_1.2-2   RWinEdt_1.7-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-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Building a formula using paste

2008-02-01 Thread john seers (IFR)


 
Thanks for the help.

Regards


John Seers

 
---
-Original Message-
From: Peter Dalgaard [mailto:[EMAIL PROTECTED] 
Sent: 01 February 2008 10:04
To: [EMAIL PROTECTED]
Cc: john seers (IFR); [EMAIL PROTECTED]
Subject: Re: [R] Building a formula using paste

[EMAIL PROTECTED] wrote:
 use as.formula() rather than just formula(). 


   
Hm?

That doesn't seem to cut it for me:

 f - as.formula(y~x)
 lm(f)

Call:
lm(formula = f)

Coefficients:
(Intercept)x
0.06437 -0.09714

 summary(lm(f))

Call:
lm(formula = f)

Residuals:
Min  1Q  Median  3Q Max
-1.2780 -0.4229 -0.3208  0.7534  1.3073

Coefficients:
Estimate Std. Error t value Pr(|t|)
(Intercept)  0.064370.61961   0.1040.920
x   -0.097140.09986  -0.9730.359

Residual standard error: 0.907 on 8 degrees of freedom
Multiple R-Squared: 0.1058, Adjusted R-squared: -0.005995
F-statistic: 0.9464 on 1 and 8 DF,  p-value: 0.3591

etc.

The problem is that we get the call and not the formula, and this appears to be 
the case whether you use formula or as.formula. Also

 identical(as.formula(y~x), formula(y~x))
[1] TRUE

I see two workarounds:

(a) Extract the formula explicitly and print it along with the output

 formula(m)
y ~ x
 m

Call:
lm(formula = f)

Coefficients:
(Intercept)x
0.06437 -0.09714

(b) substitution tricks, e.g.

 eval(bquote(lm(.(f

Call:
lm(formula = y ~ x)

Coefficients:
(Intercept)x
0.06437 -0.09714



 Hi All

 I have looked but cannot find an answer to this.

 I want to build a formula dynamically (in a function), using for 
 example paste, and using it in a model:

   fr-F1
   f1-formula(paste(fr, ~ SensoryTerm))
   m1-aov(f1, data=vdata)

 So this is the equivalent of m1-aov(F1 ~ SensoryTerm, data=vdata)

 This works fine but the problem is the formula appears as f1 in the
 summary(m1) of the model and not F1 ~ SensoryTerm. With many models 
 this can be a bit confusing 

 Is there a way to code this so the formula appears in the model summary?

   
   


-- 
   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] Mixed models

2008-02-01 Thread Alan Harrison
Hello Folks,

I'm after some help regarding mixed models.
Basically I have sampled a number of different animals at 10 independent sites 
and am trying to create a mixed model to account for the variation between 
sites my current model looks like this:

mm-glmm.admb(Hep~Sex+Mass, random=~Mouse, group=Location, data=alan, 
family=binomial, link=logit)

I numbered each animal within each site 1-n to create the Mouse variable, 
then grouped this by Location, it is the variance component of the site that 
I am interested in so when I get my output with the SD for Mouse is that what 
I want or have I structured the model incorrectly??

Any help much appreciated,
Thanks
Alan.

Alan Harrison

Quercus
Queen's University Belfast
MBC, 97 Lisburn Road
Belfast

BT9 7BL

T: 02890 972219
M: 07798615682


[[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] Reformatting data into data frame and plotting it in ggplot2

2008-02-01 Thread hadley wickham
 just the patch. But again the ggplot manual didn't have an example for
 that. Also, what if I wanted to plot with lines+symbol, do I have to
 use multiple layers? Is it (easily) achievable?

Not yet, but I hope to have that working (automatically) in the next
version.  I'm working on the legend code at the moment, so we'll see
how it goes.

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] problem getting multiple densityplots on one page

2008-02-01 Thread Rainer M Krug
Sorry - I thought about plot(density())
should read more carefull...


On 01/02/2008, Gavin Simpson [EMAIL PROTECTED] wrote:

 On Fri, 2008-02-01 at 14:00 +0200, Rainer M Krug wrote:
  On 01/02/2008, Ng Stanley [EMAIL PROTECTED] wrote:
  
   Hi,
  
   I used the following statements to generate unsuccessfully a 5 by 5
   multiple
   densityplots on a single page. If I use plot, the whole thing works.
  
data - matrix(rnorm(25), 5, 5)
op - par(mfrow = c(5, 5))
for (x in 1:5) {par(new=TRUE);densityplot(data[,x],
 xlim=c(...))}
 
 
  See changes in line above. par(new=TRUE) to overplot and xlim() to have
  same  x limits.  The y-limits can be set the same way if necessary.
  untested!
  Rainer

 That can't work as densityplot() is a lattice function and thus i) needs
 to be wrapped in print( densityplot() ) when in a for loop or similar,
 and ii) you can't mix base graphics layout with lattice.

 One way to do this is to stack the data one on another and add an ID
 variable. stack() does this for you, but there are others or you can
 cook it yourself.

 dat - data.frame(matrix(rnorm(25), 5, 5))
 dat
 sdat - stack(dat) ## generates variables 'values' and 'ind'
 densityplot(~ values | ind, data = sdat)

 HTH

 G

 
   par(op)
  
   Thanks
   Stanley
  
   [[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.
  
 
 
 
  --
 
 --
 %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,  [f] +44 (0)20 7679 0565
 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
 %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%




-- 

-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation Biology (UCT)

Plant Conservation Unit Department of Botany
University of Cape Town
Rondebosch 7701
South Africa

[[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] Reformatting data into data frame and plotting it in ggplot2

2008-02-01 Thread ONKELINX, Thierry
Have a look at scale_manual on http://had.co.nz/ggplot2/

This code will give you a key with lines instead of tiles.

ggplot(data = dataset, aes(x = x, y = y, colour = Test)) + geom_line() +
scale_colour_manual(values = c(red, blue, green),  guide = line)

If you want both lines and dots.

ggplot(data = dataset, aes(x = x, y = y, colour = Test)) + geom_line() +
geom_point()

ggplot(data = dataset, aes(x = x, y = y, colour = Test)) + geom_line() +
geom_point() + scale_colour_manual(values = c(red, blue, green),
guide = line)

I haven't found a way to get both the lines and the points in the key.
But on the other hand do you realy need to have lines in the key?
Suppose you want to combine to datasets in one graph: eg. points
representing the raw data, dotted lines representing a smoother on the
raw data and a continuous lines representing a model based on the raw
data. Then the colours would group the points, smoother and model for
each level. So what you you put in the key. Points? Dotted lines? Lines?
Or all possible combinations of colour (level) and symbol? In such cases
I prefer a key with the different colours for each level and a tile is
fine for that. The difference between point, dotted line and line can go
to the caption of the graph.

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: Tribo Laboy [mailto:[EMAIL PROTECTED] 
Verzonden: vrijdag 1 februari 2008 12:27
Aan: ONKELINX, Thierry
CC: r-help@r-project.org
Onderwerp: Re: [R] Reformatting data into data frame and plotting it in
ggplot2

Hi, Thierry,

That was exactly what I was looking for. Thanks.

Now I have a data frame with the series data in my workspace, and a plot
on the graphics device with color lines and respective color patches on
the legend. My next question is about ggplot. Is it possible to make the
legend show not only the aesthetics (color in this case), but also the
geometry (lines). It would look much better if it showed colored lines
or colored dots (if it were) instead of just the patch. But again the
ggplot manual didn't have an example for that. Also, what if I wanted to
plot with lines+symbol, do I have to use multiple layers? Is it (easily)
achievable?

Too many questions... I guess it shows I am quite new to R, but I hope
to pick it up quickly with some help and shift all my plotting from
Matlab to R.


On Fri, Feb 1, 2008 at 6:09 PM, ONKELINX, Thierry
[EMAIL PROTECTED] wrote:
 Tribo,

  Use data.frame() and rbind() to combine the vectors.



  x_test1 - c(1:10)
   y_test1-rnorm(10)
   x_test2 - c(1:15)
   y_test2-rnorm(15)
   x_test3 - c(1:20)
   y_test3-rnorm(20)

  dataset - rbind(data.frame(Test = Test 1, x = x_test1, y = 
 y_test1),  data.frame(Test = Test 2, x = x_test2, y = y_test2), 
 data.frame(Test =  Test 3, x = x_test3, y = y_test3))  dataset$Test 
 - factor(dataset$Test)

  library(ggplot2)
  ggplot(data = dataset, aes(x = x, y = y, colour = Test)) + 
 geom_line()

  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 Tribo Laboy
  Verzonden: vrijdag 1 februari 2008 9:59
  Aan: r-help@r-project.org
  Onderwerp: [R] Reformatting data into data frame and plotting it in
  ggplot2



  Hello,

   I am sure this must have been asked before, but my nabble search did

 not turn anything useful. Just pointer where to look will also be
nice.

   So, I have the following data:

   x_test1 - c(1:10)
   y_test1-rnorm(10)
   x_test2 - c(1:15)
   y_test2-rnorm(15)
   x_test3 - c(1:20)
   y_test3-rnorm(20)

   These represent time series or frequency spectra, possibly sampled  
 with different sampling frequencies, but obviously having different  
 lengths. The physical meaning of X and Y is 

Re: [R] x11() and Xinerama settings

2008-02-01 Thread Thomas Zumbrunn
On Friday 07 December 2007, Thomas Zumbrunn wrote:
 Since I changed my X11 settings to a Xinerama setup, calls to x11() result
 in windows with a width half the size of the one specified by the
 corresponding parameter. Furthermore, x axis labels are overlapping. Other
 devices (e.g. pdf()), are not affected by these distortions.

 Did anybody have the same problem, and if so, how did you solve it? ( I'm
 using openSUSE 10.3 on a x86 architecture.)

I reply to my own question in order to provide a short summary of what I found 
out since it might be helpful for some GNU/Linux users of R.

Because I got no answer on the this list, I - which was wrong - filed a bug 
against R. Prof. Ripley pointed out that my X11 settings must be wrong and 
that most probably the DisplaySize setting in xorg.conf is wrong. This was 
actually the case. In my Xinerama setup, the DisplaySize width value was the 
sum of both devices. The xorg.conf was generated by the openSUSE tool SaX2, 
and I therefore filed a bug against it: 
https://bugzilla.novell.com/show_bug.cgi?id=357597 The bug is now fixed, and 
the DisplaySize width value is now only representing the widht of the 
corresponding device.

For those who are also affected by this problem: To fix distorted R x11() 
windows, simply fix the DisplaySize values in your xorg.conf file and restart 
your X server.

Thanks go to Prof. Ripley for pointing me in the right direction and also to 
Marc Schwartz and Hin-Tak Leung for further useful advice.

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


Re: [R] re placing values in a matrix

2008-02-01 Thread Gabor Csardi
Derek, 

the 0*m part zeros out everything in the matrix, expect for the NA's, 
0*NA=NA by definition. If we add this to the y[ col(m) ] matrix, then
NA+anything=NA, but 0+anything=anything.

G.

ps. please answer to the list (as well)

On Fri, Feb 01, 2008 at 08:52:50AM -0500, Derek Cyr wrote:
 
 
 Thank you, that works very nicely.  I am a little curious as to why you
 need to do 0*m and add that to y[col(m)] in the second expression.  It
 works perfectly, but I am just not sure how, lol.  Thanks
 
 D

[...]

 Actually, you don't need apply. If there are no NA's then it is
 very easy:
 
 m[] - y[ col(m) ]
 
 If you want to keep the NA's then it is a bit more tricky:
 
 m[] - 0*m + y[ col(m) ]
 
 
 G.
 
 On Thu, Jan 31, 2008 at 07:03:51PM -0800, dxc13 wrote:
 
  useR's,
 
  Consider:
  y - c(20, 25, 30)
   m - matrix(c(0.0,1,NA,0.5,1.25,0.75, 0.5, NA,
   NA),byrow=TRUE,nrow=3,ncol=3)
   m
   [,1] [,2] [,3]
  [1,]  0.0 1.00   NA
  [2,]  0.5 1.25 0.75
  [3,]  0.5   NA   NA
 
  For each numeric value, I want to replace them with their corresponding
  y-value.  The result should look like (here, each row represents a
 variable
  rather than the columns):
[,1] [,2] [,3]
  [1,]  20   25   NA
  [2,]  20   25   30
  [3,]  20  NA   NA
 
  Does anyone know how I can do this using apply()?  Or is there an easier
  way?  Thanks in advance.
 
  Derek
  --
  View this message in context:
 http://www.nabble.com/replacing-values-in-a-matrix-tp15219764p15219764.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.
 
 --
 Csardi Gabor [EMAIL PROTECTED]UNIL DGM
 
 
 
 IMPORTANT NOTICE:  This e-mail and any attachments may contain confidential 
 or sensitive information which is, or may be, legally privileged or otherwise 
 protected by law from further disclosure.  It is intended only for the 
 addressee.  If you received this in error or from someone who was not 
 authorized to send it to you, please do not distribute, copy or use it or any 
 attachments.  Please notify the sender immediately by reply e-mail and delete 
 this from your system. Thank you for your cooperation.
 

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] fastest way to compute the squared Euclidean distance between two vectors in R

2008-02-01 Thread François Pinard
Jason Liao [EMAIL PROTECTED] writes:

 I have a program which needs to compute squared Euclidean distance
 between two vectors million of times, which the Rprof shows is the
 bottleneck. I wondered if there is any faster way than my own simple
 function

 distance2 = function(x1, x2)
 {
temp = x1-x2
sum(temp*temp)
 }

You might try:

  distance2 - function(x1, x2) crossprod(x1-x2)

And if you do not have to pass the distance2 function itself to some
other function, you might also spare the indirection trhough the
distance2 function and call crossprod directly (replacing the comma by
a minus sign :-).

-- 
François Pinard   http://pinard.progiciels-bpi.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.


[R] using VSS

2008-02-01 Thread TEBBI FATIMA
hi,
   
  i start working with PCA method i found VSS package it is very helpfull it 
show me residual matrix with the number of components to extract now i want to  
verify the normality of residual matrix and than to simulate can every one help 
me please  .
   
  THANK YOU and excuse me for my bad english.

   
-

[[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] Reformatting data into data frame and plotting it in ggplot2

2008-02-01 Thread ONKELINX, Thierry
Tribo

That function was added during the latest update. So you should update
to this version (0.5.7). You can update packages with update.packages()

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: Tribo Laboy [mailto:[EMAIL PROTECTED] 
Verzonden: vrijdag 1 februari 2008 15:18
Aan: ONKELINX, Thierry
CC: r-help@r-project.org
Onderwerp: Re: [R] Reformatting data into data frame and plotting it in
ggplot2

For some reason I get the following error:

Error: could not find function scale_colour_manual

so I couldn't make the plots.

Otherwise I completely agree that color is good way to summarize in the
key several different models and operations performed on the same data
(it is always a trick to find colors that print clearly in black and
white). But in my case I just want to plot the raw data and to
distinguish it in the key.

Regards.

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

2008-02-01 Thread Jorge Iván Vélez
Hi Carla,

Try paste(VAR: ,a,sep=)


Jorge


On 2/1/08, Carla Rebelo [EMAIL PROTECTED] wrote:

 Good morning!

 I do not speak English very well and so I will try to explain the best I
 can. I have this:

  tabela[,1]
 [1] a a b b a c b a c c c c c
 Levels: a b c

 unique(tabela[,1])
 [1] a b c
 Levels: a b c

 var-unique(tabela[,1])[1]

  var
 [1] a
 Levels: a b c

 But if I concatenate like this
  cat(VAR: , var, \n)

 I obtain
 VAR:  1

 and I want to obtain
 VAR: a

 How can I do this? Thanks!

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

[[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] Reformatting data into data frame and plotting it in ggplot2

2008-02-01 Thread Tribo Laboy
Hi Hadley,

Thanks for ggplot. Great piece of work. Very intuitive. The legend
always seems to be the most difficult part to implement in any
plotting package. gnuplot and RLplot come to mind.

Good luck!



On Fri, Feb 1, 2008 at 10:17 PM, hadley wickham [EMAIL PROTECTED] wrote:
  just the patch. But again the ggplot manual didn't have an example for
   that. Also, what if I wanted to plot with lines+symbol, do I have to
   use multiple layers? Is it (easily) achievable?

  Not yet, but I hope to have that working (automatically) in the next
  version.  I'm working on the legend code at the moment, so we'll see
  how it goes.

  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.


[R] Concatenate a Variable

2008-02-01 Thread Carla Rebelo
Good morning!

I do not speak English very well and so I will try to explain the best I 
can. I have this:

  tabela[,1]
[1] a a b b a c b a c c c c c
Levels: a b c

 unique(tabela[,1])
[1] a b c
Levels: a b c

 var-unique(tabela[,1])[1]

  var
[1] a
Levels: a b c

But if I concatenate like this
  cat(VAR: , var, \n)

I obtain
 VAR:  1

and I want to obtain
 VAR: a

How can I do this? Thanks!

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


[R] Bug with curve?

2008-02-01 Thread Paul Smith
Dear All,

Take this code:

 f - function(x) exp(-x)*x-0.05
 g - function(x) 0
 curve(f,0,5)
 curve(g,add=T)
Error in xy.coords(x, y) : 'x' and 'y' lengths differ


However, with

g - function(x) x-x

no error is generated.

Is this a bug? I am using

 version
   _
platform   i386-redhat-linux-gnu
arch   i386
os linux-gnu
system i386, 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)


Thanks in advance,

Paul

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


[R] Is it possible with two random effects in lme()?

2008-02-01 Thread Falco tinnunculus
Dear all,

Is it possible with two random effects in lme()?

 lmefit1- lme(Handling ~ Mass + factor(Prey)+ Mass*factor(Prey), random = ~
1 |Place+Age)

Here I use Place as random effect, but I also want to add Age as a random
effect. Since there could be an effect of Age (continous variable), but I
like to control for it rather than locking at the effect of Age on handling
time, since Mass and Prey type are of main interest.

Regards Kes,

[[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] problem getting multiple densityplots on one page

2008-02-01 Thread Gavin Simpson
hits=-2.6 tests=BAYES_00
X-USF-Spam-Flag: NO

On Fri, 2008-02-01 at 14:00 +0200, Rainer M Krug wrote:
 On 01/02/2008, Ng Stanley [EMAIL PROTECTED] wrote:
 
  Hi,
 
  I used the following statements to generate unsuccessfully a 5 by 5
  multiple
  densityplots on a single page. If I use plot, the whole thing works.
 
   data - matrix(rnorm(25), 5, 5)
   op - par(mfrow = c(5, 5))
   for (x in 1:5) {par(new=TRUE);densityplot(data[,x], xlim=c(...))}
 
 
 See changes in line above. par(new=TRUE) to overplot and xlim() to have
 same  x limits.  The y-limits can be set the same way if necessary.
 untested!
 Rainer

That can't work as densityplot() is a lattice function and thus i) needs
to be wrapped in print( densityplot() ) when in a for loop or similar,
and ii) you can't mix base graphics layout with lattice.

One way to do this is to stack the data one on another and add an ID
variable. stack() does this for you, but there are others or you can
cook it yourself.

dat - data.frame(matrix(rnorm(25), 5, 5))
dat
sdat - stack(dat) ## generates variables 'values' and 'ind'
densityplot(~ values | ind, data = sdat)

HTH

G

 
  par(op)
 
  Thanks
  Stanley
 
  [[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.
 
 
 
 
 -- 
 
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,  [f] +44 (0)20 7679 0565
 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

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


Re: [R] Concatenate a Variable

2008-02-01 Thread Peter Dalgaard
Carla Rebelo wrote:
 Good morning!

 I do not speak English very well and so I will try to explain the best I 
 can. I have this:

   tabela[,1]
 [1] a a b b a c b a c c c c c
 Levels: a b c

  unique(tabela[,1])
 [1] a b c
 Levels: a b c

  var-unique(tabela[,1])[1]

   var
 [1] a
 Levels: a b c

 But if I concatenate like this
   cat(VAR: , var, \n)

 I obtain
  VAR:  1

 and I want to obtain
  VAR: a

 How can I do this? Thanks!

   
The devil is in the Details  -section of help(cat):

 Other types of R object should be converted
 (e.g. by 'as.character' or 'format') before being passed to 'cat'. 

 cat(VAR: , factor(a), \n)
VAR:  1
 cat(VAR: , format(factor(a)), \n)
VAR:  a
 cat(VAR: , as.character(factor(a)), \n)
VAR:  a


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

2008-02-01 Thread Charles Annis, P.E.
Greetings:

FORM/SORM (First/Second Order Reliability Methods) are very popular among some 
structural engineers but almost never discussed among statisticians.  I am 
quite predudiced as to the reasons for this, but would enquire among the 
world's statistical thinkers for their perspectives on these methods.  Any 
comments, pro or con, would be greatly appreciated.

Since this is off-topic, you may wish to reply directly to me and I will 
summarize the comments to the group.

Thank you.


Charles Annis, P.E.
[EMAIL PROTECTED]
phone: 561-352-9699
eFax:   614-455-3265
http://www.StatisticalEngineering.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] Concatenate a Variable

2008-02-01 Thread Marc Schwartz
Carla Rebelo wrote:
 Good morning!
 
 I do not speak English very well and so I will try to explain the best I 
 can. I have this:
 
   tabela[,1]
 [1] a a b b a c b a c c c c c
 Levels: a b c
 
  unique(tabela[,1])
 [1] a b c
 Levels: a b c
 
  var-unique(tabela[,1])[1]
 
   var
 [1] a
 Levels: a b c
 
 But if I concatenate like this
   cat(VAR: , var, \n)
 
 I obtain
  VAR:  1
 
 and I want to obtain
  VAR: a
 
 How can I do this? Thanks!

'a' is a factor, thus you are getting the underlying numeric code as the
output.

Note from ?cat:

Currently only atomic vectors (and so not lists) and names are handled.
Character strings are output ‘as is’ (unlike print.default which escapes
non-printable characters and backslash — use encodeString if you want to
output encoded strings using cat). Other types of R object should be
converted (e.g. by as.character or format) before being passed to cat.


Thus:

var - factor(a, levels = c(a, b, c))

 var
[1] a
Levels: a b c

 is.vector(var)
[1] FALSE


So 'var' is not an atomic vector and you must therefore coerce it to a
character vector using as.character() before passing it to cat():

 cat(VAR: , as.character(var), \n)
VAR:  a


HTH,

Marc Schwartz

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

2008-02-01 Thread Alberto Monteiro
Paul Smith wrote:
 
 f - function(x) exp(-x)*x-0.05
 g - function(x) 0
 curve(f,0,5)
 curve(g,add=T)
 Error in xy.coords(x, y) : 'x' and 'y' lengths differ

 
 However, with
 
 g - function(x) x-x
 
 no error is generated.
 
 Is this a bug? 

No; simplify it:

g1 - function(x) 0
g2 - function(x) x - x

g1(anything) will return (scalar) 0

g2(scalar) will return (scalar) 0, g2(vector) will return 
(vector) 0, g2(matrix) will return (matrix) 0.

So, in your original problem, f and (first) g have different
behaviours. 

Alberto Monteiro

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Reformatting data into data frame and plotting it in ggplot2

2008-02-01 Thread Tribo Laboy
For some reason I get the following error:

Error: could not find function scale_colour_manual

so I couldn't make the plots.

Otherwise I completely agree that color is good way to summarize in
the key several different models and operations performed on the same
data (it is always a trick to find colors that print clearly in black
and white). But in my case I just want to plot the raw data and to
distinguish it in the key.

Regards.

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

2008-02-01 Thread Ben Bolker
Paul Smith phhs80 at gmail.com writes:

 
 Dear All,
 
 Take this code:
 
  f - function(x) exp(-x)*x-0.05
  g - function(x) 0
  curve(f,0,5)
  curve(g,add=T)
 Error in xy.coords(x, y) : 'x' and 'y' lengths differ
 
 
 However, with
 
 g - function(x) x-x
 
 no error is generated.
 


  The first paragraph of details in the help page 
says:

. 'x(t)' or 'expr' (with 'x' inside) must return a numeric of the same
 length as the argument 't' or 'x'.

  So no, technically this is not a bug.

  The R idiom for adding a horizontal line to the plot is
abline(h=...) 

  cheers
Ben Bolker

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

2008-02-01 Thread Gabor Grothendieck
This is discussed in this thread:

http://tolstoy.newcastle.edu.au/R/e2/help/07/01/9353.html

This mostly goes over the ground discussed here plus there
is a do.call based solution there too.

On Feb 1, 2008 7:10 AM, john seers (IFR) [EMAIL PROTECTED] wrote:



 Thanks for the help.

 Regards


 John Seers


 ---
 -Original Message-
 From: Peter Dalgaard [mailto:[EMAIL PROTECTED]
 Sent: 01 February 2008 10:04
 To: [EMAIL PROTECTED]

 Cc: john seers (IFR); [EMAIL PROTECTED]
 Subject: Re: [R] Building a formula using paste

 [EMAIL PROTECTED] wrote:
  use as.formula() rather than just formula().
 
 
 
 Hm?

 That doesn't seem to cut it for me:

  f - as.formula(y~x)
  lm(f)

 Call:
 lm(formula = f)

 Coefficients:
 (Intercept)x
0.06437 -0.09714

  summary(lm(f))

 Call:
 lm(formula = f)

 Residuals:
Min  1Q  Median  3Q Max
 -1.2780 -0.4229 -0.3208  0.7534  1.3073

 Coefficients:
Estimate Std. Error t value Pr(|t|)
 (Intercept)  0.064370.61961   0.1040.920
 x   -0.097140.09986  -0.9730.359

 Residual standard error: 0.907 on 8 degrees of freedom
 Multiple R-Squared: 0.1058, Adjusted R-squared: -0.005995
 F-statistic: 0.9464 on 1 and 8 DF,  p-value: 0.3591

 etc.

 The problem is that we get the call and not the formula, and this appears to 
 be the case whether you use formula or as.formula. Also

  identical(as.formula(y~x), formula(y~x))
 [1] TRUE

 I see two workarounds:

 (a) Extract the formula explicitly and print it along with the output

  formula(m)
 y ~ x
  m

 Call:
 lm(formula = f)

 Coefficients:
 (Intercept)x
0.06437 -0.09714

 (b) substitution tricks, e.g.

  eval(bquote(lm(.(f

 Call:
 lm(formula = y ~ x)

 Coefficients:
 (Intercept)x
0.06437 -0.09714


 
  Hi All
 
  I have looked but cannot find an answer to this.
 
  I want to build a formula dynamically (in a function), using for
  example paste, and using it in a model:
 
fr-F1
f1-formula(paste(fr, ~ SensoryTerm))
m1-aov(f1, data=vdata)
 
  So this is the equivalent of m1-aov(F1 ~ SensoryTerm, data=vdata)
 
  This works fine but the problem is the formula appears as f1 in the
  summary(m1) of the model and not F1 ~ SensoryTerm. With many models
  this can be a bit confusing 
 
  Is there a way to code this so the formula appears in the model summary?
 
 
 


 --
   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-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Log rank test power

2008-02-01 Thread Terry Therneau
 Does anyone have any ideas how I could do a power calculation for a log
 rank test.  I would like to know what the suggested sample sizes would
 be to pick a difference when the control to active are in a ratio of 80%
 to 20%.

  Power for a log-rank test is the same as power for a Cox model.  For a 2-arm 
study
d = (qnorm(.975) + qnorm(.85))^2 / (.2 *.8 * coef^2)
  
   d = # deaths required
   .975 = two sided alpha=.05
   .85   = power of .85
   .2, .8 = proportion in each group
   coef = Cox model coef you want power against.  So for a 50% difference in
hazard rates (or median survival times) coef = log(1.5).  

   For a 50% change I get d=341.  Now for the hard part of sample size in a 
survival study: how many people to you need to enroll and how long will you 
need 
to follow them, to observe 341 total deaths?  This second step is usually a mix 
of prior knowlege, enrollment expectations, and wild speculation.  In the words 
of a prior director of research at U of Rochester:
   At the commencement of a study the incidence of the disease in question 
will 
drop by one half, and will not return to its former levels until the study ends 
or the principle investigator retires, whichever comes first.  L.L.
   
Terry Therneau

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

2008-02-01 Thread Paul Smith
On Feb 1, 2008 2:46 PM, Martin Maechler [EMAIL PROTECTED] wrote:
  Take this code:
 
   f - function(x) exp(-x)*x-0.05
   g - function(x) 0
   curve(f,0,5)
   curve(g,add=T)
  Error in xy.coords(x, y) : 'x' and 'y' lengths differ
  
 
  However, with
 
  g - function(x) x-x
 
  no error is generated.
 
 

 BB The first paragraph of details in the help page
 BB says:

 BB . 'x(t)' or 'expr' (with 'x' inside) must return a numeric of the same
 BB length as the argument 't' or 'x'.

 yes, thanks Ben.

 BB So no, technically this is not a bug.

 why only technically?

 Paul wouldn't also be able to integrate(g, .), just
 the error message would be slightly more helpful :

   Error in integrate(g, 0, 1) :
 evaluation of function gave a result of wrong length



 BB The R idiom for adding a horizontal line to the plot is
 BB abline(h=...)

 BB cheers
 BB Ben Bolker

Thanks to all for the clarification.

Paul

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


[R] multiple functions with three dots

2008-02-01 Thread John Lande
Dear all,

I am creating functions with the three dot strategy. I wold like to have
suggestion when writing multiple functions that calls multiple functions
with 

I will give you a couple of example:

a=1:5
b=6:10
d=3:7

example=function(x,y, z, ...){
   plot(x,y, ...)
   points(x,z, ...)

}

example(a,b,d)

how can I set different parameters for points and plot functions? for
example in plot I want to have bigger dots (lwd=3), while in the points I
want to have green dots.

any suggestion?


thank you.

[[alternative HTML version deleted]]

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


Re: [R] Saving a big table or matrix

2008-02-01 Thread Atte Tenkanen
I had a problem:

I saved a matrix:

 save(Tondistmatrix1, file=/Users/atte/Skriptit/Tondistmatrix1)

then I tried to open it with R:
 Tondistmatrix1=load(/Users/atte/Skriptit/Tondistmatrix1)
 Tondistmatrix1[1:10,]
Error in Tondistmatrix1[1:10, ] : incorrect number of dimensions
 dim(Tondistmatrix1)
NULL

So, this didn't work but then I noticed that this is enough

 load(/Users/atte/Skriptit/Tondistmatrix1)
 dim(Tondistmatrix1)
[1] 3938 3938

No problems any more...

Atte Tenkanen
University of Turku, Finland
Department of Musicology
+023335278

- Original Message -
From: Gabor Csardi [EMAIL PROTECTED]
Date: Friday, February 1, 2008 1:43 pm
Subject: Re: [R] Saving a big table or matrix

 ?save
 ?load
 
 Gabor
 
 ps. although i'm not sure what an Rdata-project means, so maybe you
 need something else
 
 On Fri, Feb 01, 2008 at 08:24:32AM +0200, Atte Tenkanen wrote:
  Dear R-users,
  
  How do you save a big table or matrix as an independent object 
 and attach it to your Rdata-project when needed?
  
  Atte Tenkanen
  University of Turku, Finland
  Department of Musicology
  +023335278
  
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html and provide commented, minimal, self-contained, 
 reproducible code.
 
 -- 
 Csardi Gabor [EMAIL PROTECTED]UNIL DGM


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

2008-02-01 Thread My Coyne
Is there a way to perform a dynamic SQL query in R, using RMySQL?  Thanks

 

My D. Coyne

 

 

 


[[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] Concatenate a Variable

2008-02-01 Thread John Kane
R is treating tablea[,1] as a factor.  Try converting
it to character.

--- Carla Rebelo [EMAIL PROTECTED] wrote:

 Good morning!
 
 I do not speak English very well and so I will try
 to explain the best I 
 can. I have this:
 
   tabela[,1]
 [1] a a b b a c b a c c c c c
 Levels: a b c
 
  unique(tabela[,1])
 [1] a b c
 Levels: a b c
 
  var-unique(tabela[,1])[1]
 
   var
 [1] a
 Levels: a b c
 
 But if I concatenate like this
   cat(VAR: , var, \n)
 
 I obtain
  VAR:  1
 
 and I want to obtain
  VAR: a
 
 How can I do this? Thanks!
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained,
 reproducible code.
 



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

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

2008-02-01 Thread Martin Maechler
 BB == Ben Bolker [EMAIL PROTECTED]
 on Fri, 1 Feb 2008 14:03:15 + (UTC) writes:

BB Paul Smith phhs80 at gmail.com writes:
 
 Dear All,
 
 Take this code:
 
  f - function(x) exp(-x)*x-0.05
  g - function(x) 0
  curve(f,0,5)
  curve(g,add=T)
 Error in xy.coords(x, y) : 'x' and 'y' lengths differ
 
 
 However, with
 
 g - function(x) x-x
 
 no error is generated.
 
 

BB The first paragraph of details in the help page 
BB says:

BB . 'x(t)' or 'expr' (with 'x' inside) must return a numeric of the same
BB length as the argument 't' or 'x'.

yes, thanks Ben.

BB So no, technically this is not a bug.

why only technically?

Paul wouldn't also be able to integrate(g, .), just
the error message would be slightly more helpful :

  Error in integrate(g, 0, 1) : 
evaluation of function gave a result of wrong length



BB The R idiom for adding a horizontal line to the plot is
BB abline(h=...) 

BB cheers
BB Ben Bolker

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

2008-02-01 Thread Henrique Dallazuanna
Try this:

x[x==] - NA

On 01/02/2008, My Coyne [EMAIL PROTECTED] wrote:
 I would like to replace all null () in a column of a matrix to NA, how
 would I do that without a do loop?

 Thanks

 --mc














 [[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] replace Null with NA

2008-02-01 Thread My Coyne
I would like to replace all null () in a column of a matrix to NA, how
would I do that without a do loop?

Thanks

--mc

 

 

 

 

 

 


[[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] as.numeric rounds up

2008-02-01 Thread Monica Pisica


Hi list,

It seems that as.numeric is rounding up my numbers that are in a character 
format.

Example:

a
[1] 776554.45 776985.31 776076.03 776092.01 776151.42 776276.97


b - as.numeric(a)
b
[1] 776554.4 776985.3 776076.0 776092.0 776151.4 776277.0



I've tried as.numeric(a,2) and as.numeric(a, digits = 2) but it didn't work, 
nor  ? as.numeric gave me any clues. How can i transform my character numbers 
in numeric without loosing the decimal digits?

Thanks,

Monica


_
[[elided Hotmail spam]]

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

2008-02-01 Thread Greg Snow
You can try something like:

a - 1:5
b - 6:10
d - 3:7

example - function(x,y, z, ..., plot.dots, points.dots){
   plot.list - list(x=x,y=y)
   plot.list - c(plot.list,list(...), as.list(plot.dots))
   do.call(plot, plot.list)

   points.list - list(x=x,y=z)
   points.list - c(points.list, list(...), as.list(points.dots) )
   do.call(points, points.list)

}

example(a,b,d, pch=0, plot.dots=list(cex=2),
points.dots=list(col='green'))

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 John Lande
 Sent: Friday, February 01, 2008 7:34 AM
 To: r-help@r-project.org
 Subject: [R] multiple functions with three dots
 
 Dear all,
 
 I am creating functions with the three dot strategy. I wold 
 like to have suggestion when writing multiple functions that 
 calls multiple functions with 
 
 I will give you a couple of example:
 
 a=1:5
 b=6:10
 d=3:7
 
 example=function(x,y, z, ...){
plot(x,y, ...)
points(x,z, ...)
 
 }
 
 example(a,b,d)
 
 how can I set different parameters for points and plot 
 functions? for example in plot I want to have bigger dots 
 (lwd=3), while in the points I want to have green dots.
 
 any suggestion?
 
 
 thank you.
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 

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

2008-02-01 Thread Henrique Dallazuanna
options(digits=10)

 b

or just

print(b, 10)

On 01/02/2008, Monica Pisica [EMAIL PROTECTED] wrote:


 Hi list,

 It seems that as.numeric is rounding up my numbers that are in a character 
 format.

 Example:

 a
 [1] 776554.45 776985.31 776076.03 776092.01 776151.42 776276.97


 b - as.numeric(a)
 b
 [1] 776554.4 776985.3 776076.0 776092.0 776151.4 776277.0



 I've tried as.numeric(a,2) and as.numeric(a, digits = 2) but it didn't work, 
 nor  ? as.numeric gave me any clues. How can i transform my character numbers 
 in numeric without loosing the decimal digits?

 Thanks,

 Monica


 _
 [[elided Hotmail spam]]

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

2008-02-01 Thread Monica Pisica

So  this is only a cosmetic printing and actually my numbers do have 2 
decimal numbers .
 
Thanks,
 
Monica Date: Fri, 1 Feb 2008 16:27:00 -0200 From: [EMAIL PROTECTED] To: 
[EMAIL PROTECTED] Subject: Re: [R] as.numeric rounds up CC: 
r-help@r-project.org  options(digits=10)   b  or just  print(b, 10)  
On 01/02/2008, Monica Pisica [EMAIL PROTECTED] wrote:Hi list,   
It seems that as.numeric is rounding up my numbers that are in a character 
format.   Example:   a  [1] 776554.45 776985.31 776076.03 
776092.01 776151.42 776276.97b - as.numeric(a)  b  [1] 
776554.4 776985.3 776076.0 776092.0 776151.4 776277.0 I've tried 
as.numeric(a,2) and as.numeric(a, digits = 2) but it didn't work, nor ? 
as.numeric gave me any clues. How can i transform my character numbers in 
numeric without loosing the decimal digits?   Thanks,   Monica
_  [[elided 
Hotmail spam]]   __  
R-help@r-project.org mailing list  
https://stat.ethz.ch/mailman/listinfo/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
_
Helping your favorite cause is as easy as instant messaging. You IM, we give.

[[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] the union of several data frame rows

2008-02-01 Thread J. Scott Olsson
It's ugly, but you could use something like

 sum(tmp[i,] == A)  0

on each column.

pax,
Scott

On Fri, Feb 1, 2008 at 1:58 PM, Scot W. McNary [EMAIL PROTECTED] wrote:

 Hi,

 I have a question about how to obtain the union of several data frame
 rows.  I'm trying to create a common key for several tests composed of
 different items.   Here is a small scale version of the problem.  These
 are keys for 4 different tests, not all mutually exclusive:

 id q1 q2 q3 q4 q5 q6
 1  A  C
 2  B  D
 3  A D  B
 4 C  D B  D

 I would like to create a single key all test versions, the union of
 the above:

 id   q1 q2 q3 q4 q5 q6
 key  A  C  D  B  B  D


 Here is what I have (unsuccessfully) tried so far:

   key -
 +   matrix(c(1, A, C,  ,  ,  ,  ,
 +  2,  ,  ,  ,  , B, D,
 +  3, A,  , D, B,  ,  ,
 +  4,  , C, D,  , B, D),
 +byrow=TRUE, ncol = 7)
  
   k1 - key[1, 2:7]
   k2 - key[2, 2:7]
   k3 - key[3, 2:7]
   k4 - key[4, 2:7]
  
   itemid - c(q1, q2, q3, q4, q5, q6)
  
   k1 - cbind(itemid, k1)
   k2 - cbind(itemid, k2)
   k3 - cbind(itemid, k3)
   k4 - cbind(itemid, k4)
  
   tmp - merge(k1, k2, by = itemid)
   tmp - merge(tmp, k3, by = itemid)
   tmp - merge(tmp, k4, by = itemid)
  
   t(tmp)
   [,1] [,2] [,3] [,4] [,5] [,6]
 itemid q1 q2 q3 q4 q5 q6
 k1 A  C
 k2 B  D
 k3 A D  B  
 k4C  D B  D

 The actual problem involves 300 or so items instead of 6 and 10
 different keys instead of four.  Any suggestions welcome.

 Thanks in advance,

 Scot McNary

   version
   _
 platform   i386-pc-mingw32
 arch   i386
 os mingw32
 system i386, mingw32
 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)


 --
 Scot McNary
 smcnary at charm dot net

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] the union of several data frame rows

2008-02-01 Thread Henrique Dallazuanna
Perhaps:

data - data.frame(key, row.names=1)
names(data) - paste(q, 1:6, sep=)
apply(data, 2, function(x)unique(x)[unique(x) !=  ])


On 01/02/2008, Scot W. McNary [EMAIL PROTECTED] wrote:
 Hi,

 I have a question about how to obtain the union of several data frame
 rows.  I'm trying to create a common key for several tests composed of
 different items.   Here is a small scale version of the problem.  These
 are keys for 4 different tests, not all mutually exclusive:

 id q1 q2 q3 q4 q5 q6
 1  A  C
 2  B  D
 3  A D  B
 4 C  D B  D

 I would like to create a single key all test versions, the union of
 the above:

 id   q1 q2 q3 q4 q5 q6
 key  A  C  D  B  B  D


 Here is what I have (unsuccessfully) tried so far:

   key -
 +   matrix(c(1, A, C,  ,  ,  ,  ,
 +  2,  ,  ,  ,  , B, D,
 +  3, A,  , D, B,  ,  ,
 +  4,  , C, D,  , B, D),
 +byrow=TRUE, ncol = 7)
  
   k1 - key[1, 2:7]
   k2 - key[2, 2:7]
   k3 - key[3, 2:7]
   k4 - key[4, 2:7]
  
   itemid - c(q1, q2, q3, q4, q5, q6)
  
   k1 - cbind(itemid, k1)
   k2 - cbind(itemid, k2)
   k3 - cbind(itemid, k3)
   k4 - cbind(itemid, k4)
  
   tmp - merge(k1, k2, by = itemid)
   tmp - merge(tmp, k3, by = itemid)
   tmp - merge(tmp, k4, by = itemid)
  
   t(tmp)
[,1] [,2] [,3] [,4] [,5] [,6]
 itemid q1 q2 q3 q4 q5 q6
 k1 A  C
 k2 B  D
 k3 A D  B  
 k4C  D B  D

 The actual problem involves 300 or so items instead of 6 and 10
 different keys instead of four.  Any suggestions welcome.

 Thanks in advance,

 Scot McNary

   version
_
 platform   i386-pc-mingw32
 arch   i386
 os mingw32
 system i386, mingw32
 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)


 --
 Scot McNary
 smcnary at charm dot net

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] the union of several data frame rows

2008-02-01 Thread Scot W. McNary
Hi,

I have a question about how to obtain the union of several data frame 
rows.  I'm trying to create a common key for several tests composed of 
different items.   Here is a small scale version of the problem.  These 
are keys for 4 different tests, not all mutually exclusive:

id q1 q2 q3 q4 q5 q6
1  A  C 
2  B  D
3  A D  B 
4 C  D B  D

I would like to create a single key all test versions, the union of 
the above:

id   q1 q2 q3 q4 q5 q6
key  A  C  D  B  B  D


Here is what I have (unsuccessfully) tried so far:

  key -
+   matrix(c(1, A, C,  ,  ,  ,  ,
+  2,  ,  ,  ,  , B, D,
+  3, A,  , D, B,  ,  ,
+  4,  , C, D,  , B, D),
+byrow=TRUE, ncol = 7)

  k1 - key[1, 2:7]
  k2 - key[2, 2:7]
  k3 - key[3, 2:7]
  k4 - key[4, 2:7]  
 
  itemid - c(q1, q2, q3, q4, q5, q6)
 
  k1 - cbind(itemid, k1)
  k2 - cbind(itemid, k2)
  k3 - cbind(itemid, k3)
  k4 - cbind(itemid, k4)
 
  tmp - merge(k1, k2, by = itemid)
  tmp - merge(tmp, k3, by = itemid)
  tmp - merge(tmp, k4, by = itemid)
 
  t(tmp)
   [,1] [,2] [,3] [,4] [,5] [,6]
itemid q1 q2 q3 q4 q5 q6
k1 A  C
k2 B  D
k3 A D  B  
k4C  D B  D

The actual problem involves 300 or so items instead of 6 and 10 
different keys instead of four.  Any suggestions welcome.

Thanks in advance,

Scot McNary

  version
   _  
platform   i386-pc-mingw32
arch   i386   
os mingw32
system i386, mingw32  
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)


-- 
Scot McNary
smcnary at charm dot net

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

2008-02-01 Thread Liaw, Andy
First things first:  There's no final tree in random forests.  You get
a set of trees (i.e., a forest).  Secondly, a forest cannot be
interpreted because of the complexity, not because the splits can't
possibly make sense.  You can try to interpret the trees, as long as you
understand the potential pitfalls of doing that.

Here's how ordered factors are handled in randomForest.  Since the tree
algorithm only make use of the ranks, there's basically no difference
between numerical and ordinal variables.  Thus ordered factors are
simply treated as integers 1 through K where K is the number or levels,
and the underlying algorithm is told that this is just a numeric
variable.  This is how a split point of something like 3.5 appears.

Hope that make some sense.

Best,
Andy 

From: [EMAIL PROTECTED]
 
 Hi there,
 
 I am an environmental studies masters student trying to get 
 my thesis out the door.  I am also newbie at trees in 
 general, but I like what I see in the literature about the 
 random forest algorithm.  I think I get the general gist of 
 things, but even after reading stuff I'm unclear about how I 
 could be getting the results I'm seeing.  I obviously am 
 missing something about how the split points in the final 
 tree are decided.
 
 I've been using random forests in image classification by 
 entering split values into decision tree classifiers, and 
 that has seemed work very well.  The map output appears 
 legitimate and withheld data gives confusion matrices similar 
 to the predictive errors from the random forest.  This leads 
 me to assume that the split points are effective.
 
 However now that I've turned to the ecological portion of my 
 analysis, with a data set that contains few variable levels 
 and lots of zeros, suddenly the splitting node information is 
 not making sense.
 
 Here is my situation.  I have a matrix of study plots that 
 each belong to one of three elevation classes and which each 
 have percent cover class data for 15 plant species associated 
 with them.  
 
 plot  elevsp1 sp2 sp3... sp15
 1 3   0   2   6...  5
 2 0   0   0   1...  0
 etc.
 
 The species data are ordered factors from 0-9.  When I run 
 the algorithm using species cover values to predict elevation 
 class, two species alone come up as the best predictors.  
 That makes ecological sense in this setting, given the 
 species ranges in question.
 
 Here's my difficulty though.  The split point values can't be 
 interpreted, as far as I can tell.  I'm getting split points 
 of, say, 1.5 and 2.5 for a species who's cover is either 0 
 (absent) or 4 and above.  So obviously the split points in 
 the final tree are being generated in some way I don't 
 understand.  Averaged?  
 
 I've tried running the tree using the data as factors, using 
 the data as ordered factors, and using the data as numerical 
 variables, just to see if I could gain insight into what's 
 going on, but I'm coming up clueless.  My literature hunt 
 reveals repeated instances of folks saying that the final 
 tree can't be interpreted the way other trees are, but I'm 
 not getting a lot on just why that might be.  
 
 Some folks talk about the final tree being averaged, others 
 say that mode, is employed (which doesn't make sense to me 
 if I'm getting 1.5 and 2.5 split values).  If the trees are 
 only good as black box predictors (which is of course a very 
 useful thing in itself), should I even be using the node 
 information in my image classifications?  
 
 As you see, I'm missing some rather important point or other 
 here.  Can you enlighten?
 
 Thanks,
 A
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 


--
Notice:  This e-mail message, together with any attachme...{{dropped:15}}

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


[R] latent class analysis

2008-02-01 Thread Suyan Tian
Hi, does some one know how to run the latent class analysis in R?  
like which package and command I should use?

thanks a lot,

Suyan Tian

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

2008-02-01 Thread mohamed nur anisah
hi!!
   
  Below I have 4 columns vector of c and d which are unequal in length.These c 
and d have 2 columns each where these 2 columns represent an interval values. 
How am I going to get an overlapping over these interval values?? Please help 
me sort this problem!! Thanks in advance..
   
 c   d
  17130612   17587118 17712302   18100404
17712302   18221688 21203780   21387314
21225764   21387314 25012714   30748348
25012714   30748348 33852816   34384588
33852816   34480192 34794536   35996440
36012944   36209144 
36252300   36280276
36737468   36971144
43693832   43878548

   
-

[[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] Phase Shift

2008-02-01 Thread Charles C. Berry
On Fri, 1 Feb 2008, stephen sefick wrote:

 Is there any implementation in R for finding the phase shift between
 two continuous signals.  I would like to find the average phase shift
 for tow signals over two years.


Following the _posting guide_, we have:

RSiteSearch(phase shift)



Also, you might look at

?acf
example( acf )

HTH,

Chuck




 thanks

 Stephen

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


Charles C. Berry(858) 534-2098
 Dept of Family/Preventive Medicine
E mailto:[EMAIL PROTECTED]  UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901

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

2008-02-01 Thread Charles C. Berry
On Fri, 1 Feb 2008, mohamed nur anisah wrote:

 hi!!

  Below I have 4 columns vector of c and d which are unequal in
  length.These c and d have 2 columns each where these 2 columns
  represent an interval values. How am I going to get an overlapping over
  these interval values?? Please help me sort this problem!! Thanks in
  advance..

Perhaps this is what you need:

http://finzi.psych.upenn.edu/R/Rhelp02a/archive/60815.html


If not, you should repost showing what you think the answer should be for 
your problem below.

HTH,

Chuck



 c   d
  17130612   17587118 17712302   18100404
 17712302   18221688 21203780   21387314
 21225764   21387314 25012714   30748348
 25012714   30748348 33852816   34384588
 33852816   34480192 34794536   35996440
 36012944   36209144
 36252300   36280276
 36737468   36971144
 43693832   43878548


 -

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


Charles C. Berry(858) 534-2098
 Dept of Family/Preventive Medicine
E mailto:[EMAIL PROTECTED]  UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901

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

2008-02-01 Thread Wensui Liu
try flexmix.

On Feb 1, 2008 3:23 PM, Suyan Tian [EMAIL PROTECTED] wrote:
 Hi, does some one know how to run the latent class analysis in R?
 like which package and command I should use?

 thanks a lot,

 Suyan Tian

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




-- 
===
WenSui Liu
ChoicePoint Precision Marketing
Phone: 678-893-9457
Email : [EMAIL PROTECTED]
Blog   : statcompute.spaces.live.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] Confidence intervals for PCA scores/eigenvalues

2008-02-01 Thread Charles C. Berry
On Fri, 1 Feb 2008, Markus Loecher wrote:

 Very sorry about my incomplete email from 2 days ago, here is the full
 version.
 ---
 Dear all,
 I have read various descriptions of employing resampling techniques, such as
 the bootstrap, to estimate the uncertainties of the eigenvalues/vectors
 computed by PCA.
 Let's say I define my test statistic T to be the percent of variance
 captured by the first 2 principal components.
 I am struggling with a conceptual issue here. Since PCA maximizes the
 variance concentration, wouldn't the bootstrapped distribution of T be
 biased upward due to the effectively reduced sample size ?
 If that is true, how could one obtain an unbiased confidence interval for T
 ?

 Any insight would be helpful !


See

@article{beran1985bta,
   title={{Bootstrap Tests and Confidence Regions for Functions of a 
Covariance Matrix}},
   author={Beran, R. and Srivastava, M.S.},
   journal={The Annals of Statistics},
   volume={13},
   number={1},
   pages={95--115},
   year={1985},
   publisher={JSTOR}
}
@article{beran1987cbt,
   title={{Correction: Bootstrap Tests and Confidence Regions for Functions 
of a Covariance Matrix}},
   author={Beran, R. and Srivastava, M.S.},
   journal={The Annals of Statistics},
   volume={15},
   number={1},
   pages={470--471},
   year={1987},
   publisher={Institute of Mathematical Statistics}
}

and browse thru these perhaps:

http://scholar.google.com/scholar?hl=enlr=cites=1040478970084047991

HTH,

Chuck

 Thanks,

 Markus

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


Charles C. Berry(858) 534-2098
 Dept of Family/Preventive Medicine
E mailto:[EMAIL PROTECTED]  UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901

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

2008-02-01 Thread jim holtman
Here is one way of doing it:

 c.i - read.table(textConnection( 17130612   17587118
+ 17712302   18221688
+ 21225764   21387314
+ 25012714   30748348
+ 33852816   34480192
+ 36012944   36209144
+ 36252300   36280276
+ 36737468   36971144
+ 43693832   43878548))

 d.i - read.table(textConnection(  17712302   18100404
+  21203780   21387314
+  25012714   30748348
+  33852816   34384588
+  34794536   35996440))
 closeAllConnections()

 # setup data.frame for comparing
 x - rbind(data.frame(t=c.i$V1, oper=1, type='c'),
+ data.frame(t=c.i$V2, oper=-1, type='c'),
+ data.frame(t=d.i$V1,oper=1, type='d'),
+ data.frame(t=d.i$V2, oper=-1, type='d'))

 # put in time order
 x - x[order(x$t),]
 # determine overlaps
 x$over - cumsum(x$oper)
 x
  t oper type over
1  171306121c1
10 17587118   -1c0
2  177123021c1
19 177123021d2
24 18100404   -1d1
11 18221688   -1c0
20 212037801d1
3  212257641c2
12 21387314   -1c1
25 21387314   -1d0
4  250127141c1
21 250127141d2
13 30748348   -1c1
26 30748348   -1d0
5  338528161c1
22 338528161d2
27 34384588   -1d1
14 34480192   -1c0
23 347945361d1
28 35996440   -1d0
6  360129441c1
15 36209144   -1c0
7  362523001c1
16 36280276   -1c0
8  367374681c1
17 36971144   -1c0
9  436938321c1
18 43878548   -1c0
 # assuming that c  d don't overlap themselves, oper=2 indicate an overlap
 overlap - which(x$over == 2)
 # print overlaps
 for (i in overlap){
+ print(x[i + c(-1,0,1,2),])
+ }
  t oper type over
2  177123021c1
19 177123021d2
24 18100404   -1d1
11 18221688   -1c0
  t oper type over
20 212037801d1
3  212257641c2
12 21387314   -1c1
25 21387314   -1d0
  t oper type over
4  250127141c1
21 250127141d2
13 30748348   -1c1
26 30748348   -1d0
  t oper type over
5  338528161c1
22 338528161d2
27 34384588   -1d1
14 34480192   -1c0



On Feb 1, 2008 4:03 PM, mohamed nur anisah [EMAIL PROTECTED] wrote:
 hi!!

  Below I have 4 columns vector of c and d which are unequal in length.These c 
 and d have 2 columns each where these 2 columns represent an interval values. 
 How am I going to get an overlapping over these interval values?? Please help 
 me sort this problem!! Thanks in advance..

 c   d
  17130612   17587118 17712302   18100404
 17712302   18221688 21203780   21387314
 21225764   21387314 25012714   30748348
 25012714   30748348 33852816   34384588
 33852816   34480192 34794536   35996440
 36012944   36209144
 36252300   36280276
 36737468   36971144
 43693832   43878548


 -

[[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] best text editor for Linux?

2008-02-01 Thread Wade Wall
Hi all,

I know this question has been asked in the past, but I am wondering if
anyone running R on Linux has any guidance as to a text editor that works
well with R.  At the present time I am running R on Windows and using
TINN-R.  For a number of reasons I want to switch to Linux, but can't find
much in the way of a text editor in sync with R.  Any experiences,
recommendations would be appreciated.

Wade Wall

[[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] ARCH LM test for univariant time series

2008-02-01 Thread tom soyer
Hi,

Does anyone know if R has a Lagrange multiplier (LM) test for ARCH
effects for univariant time series?

Thanks!

-- 
Tom

[[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] best text editor for Linux?

2008-02-01 Thread Mark W Kimpel
Wade,

I switched from R-Windows to R-Linux about 9 months ago and have had 
great success with GNU-Emacs with the ESS add-on. Your distro should 
have Emacs available for install, if it does not you can get the source at:
http://ftp.gnu.org/pub/gnu/emacs/

ESS can be found at:
http://ess.r-project.org/

There is a special help-list for ESS at:
[EMAIL PROTECTED]

Good Luck,
Mark

Mark W. Kimpel MD  ** Neuroinformatics ** Dept. of Psychiatry
Indiana University School of Medicine

15032 Hunter Court, Westfield, IN  46074

(317) 490-5129 Work,  Mobile  VoiceMail
(317) 204-4202 Home (no voice mail please)

mwkimpelatgmaildotcom

**


Wade Wall wrote:
 Hi all,
 
 I know this question has been asked in the past, but I am wondering if
 anyone running R on Linux has any guidance as to a text editor that works
 well with R.  At the present time I am running R on Windows and using
 TINN-R.  For a number of reasons I want to switch to Linux, but can't find
 much in the way of a text editor in sync with R.  Any experiences,
 recommendations would be appreciated.
 
 Wade Wall
 
   [[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] (no subject)

2008-02-01 Thread bgchen
r-help

c(2.43, 3.22, 6.9, 3.03, 5.36, 6.9, 2.29, 6.13, 6.11, 4.25, 3.85, 
5.09, 7.44, 2.86, 2.82, 3.64, 3.22, 7, 2.65, 4.5, 3.73, 5.09, 
5.8, 7.87, 2.87, 2.9, 6.63, 6.8, 2.45, 7.68, 2.56, 2.54, 7.35, 
4.61, 2.58, 3.27, 5.8, 3.13, 3.29, 2.56, 5.79, 2.67, 7.55, 7.13, 
8.4, 6.16, 3.34, 6.49, 1.85, 7.4, 7.89, 3.3, 6.28, 6.52, 6.07, 
4.26, 4.4, 3.1, 5.97, 6.69, 3.69, 4.62, 5.79, 2.54, 8.91, 3.48, 
2.35, 7.28, 6.75, 6.97, 7.29, 2.28, 3.36, 4.79, 2.41, 7.93, 6.17, 
2.19, 4.27, 7.17, 2.12, 3.05, 4.4, 5.35, 2.96, 3.54, 3.31, 7.28, 
2.47, 2.27, 7.43, 3.69, 3.32, 2.61, 2.19, 5.67, 5.03, 7.58, 5.27, 
2.25, 2.59, 4.16, 1.71, 3.64, 2.93, 7.2, 5.99, 7.68, 4.14, 5.83, 
3.87, 7.29, 5.95, 3.4, 2.45, 2.85, 6.77, 3.58, 4.31, 5.83, 6.19, 
2.56, 6.69, 7.2, 5.04, 4.34, 2.66, 7.68, 6.8, 2.5, 1.95, 7.12, 
3.02, 2.58, 3.39, 3.78, 3.53, 4.42, 6.64, 2.19, 4.79, 5.75, 5.55, 
5.57, 3.94, 7.27, 3.39, 6.64, 6.13, 4.55, 6.75, 3.79, 1.82, 5.95, 
5.88, 2.64, 5.43, 7.9, 3.14, 5.38, 7.97, 5.83, 3.18, 2.47, 3.33, 
6.98, 6.35, 6.1, 7.11, 7.34, 5.08, 2, 3.13, 2.96, 2.43, 2.12, 
3.24, 3.13, 2.6, 5.15, 3.34, 7.07, 5.42, 3.1, 2.66, 2.42, 7.3, 
3.28, 4.68, 5.9, 6.64, 4.79, 1.84, 6.78, 6.1, 3.29, 2.35, 2.16, 
6.36, 6.41, 5.39, 2.48, 7.35, 5.87, 6.77, 5.66, 2.81, 5.27, 2.95, 
7.01, 2.55, 3.4, 2.84, 2.35, 6.36, 4.31, 7.44, 3.35, 6.42, 5.86, 
3.14, 6.95, 5.27, 2.05, 4.85, 3.37, 2.28, 7.59, 6.99, 5.68, 4.5, 
2.81, 6.07, 5.27, 6.32, 5.25, 3.69, 3.89, 3.23, 3.5, 6.2, 6.78, 
2.51, 5.87, 7, 6.99, 7.27, 7.62, 6.87, 2.38, 6.78, 3.11, 4.28, 
7.57, 5.65, 3.32, 2.53, 3.09, 4.99, 2.19, 6.37, 2.68, 7.22, 2.47, 
3.05, 4.92, 2.82, 7.72, 3.67, 6.76, 6.38, 3.18, 3.02, 6.2, 3.47, 
3.02, 7.22, 2.21, 7.33, 7.58, 6.58, 2.98, 6.7, 2.64, 6, 2.72, 
2, 6.35, 5.36, 6.74, 5.29, 6.22, 3.14, 7.15, 4.45, 2.34, 2.63, 
4.62, 7.51, 7.4, 3.16, 5.99, 7.07, 4.85, 3.11, 4.6, 6.55, 2.63, 
3.15, 5.16, 5.81, 3.99, 6.12, 4.08, 3.69, 3.32, 3.13, 2.41, 2.95, 
2.88, 5.79, 5.83, 2.49, 3.8, 4.62, 3.71, 3.18, 7.41, 7.3, 6.51, 
2.27, 7.15, 6.04, 8.11, 7.74, 7.09, 7.21, 2.54, 6.74, 3.48, 7.8, 
6.41, 5.64, 5.11, 4.91, 2.25, 3.31, 3.95, 6.58, 5.38, 5.45, 3.46, 
2.4, 5.79, 3.34, 3.32, 1.97, 2.49, 3.29, 5.69, 1.75, 4.57, 7.04, 
5.29, 7.79, 7.84, 3.02, 4.36, 6.87, 2.14, 5.43, 4.11, 7.51, 2.13, 
5.33, 2.91, 2.87, 5.95, 2.29, 2.08, 7.78, 3.96, 4.55, 2.82, 2.63, 
3.13, 3.43, 5.96, 2.39, 4.98, 3.51, 6.26, 4.03, 2.41, 6.8, 7.64, 
3.3, 2.66, 6.51, 3.33, 5.64, 2.5, 6.09, 2.63, 2.55, 2.52, 4.15, 
5.3, 6.11, 5.13, 3.42, 7.42, 1.87, 6.64, 4.63, 3.25, 1.97, 5.44, 
7.96, 6.67, 7.14, 5.12, 5.27, 7.48, 7.25, 2.51, 4.5, 2.87, 6.7, 
2.09, 6.85, 2.16, 6.37, 3.01, 3.55, 4.5, 2.69, 3.52, 5.7, 3.02, 
5.94, 7.38, 6.45, 5.33, 2.8, 4.83, 3.01, 6.34, 2.99, 1.98, 3.02, 
3.11, 8.65, 6.38, 7.08, 7.74, 6.19, 7.97, 2.7, 5.05, 6.61, 3.75, 
5.24, 6.59, 5.91, 2.02, 6.95, 3.05, 2.89, 5.09, 4.9, 6.78, 5.79, 
5.42, 3.13, 3.97, 2.24, 5.91, 6.28, 3.44, 6.14, 2.41, 8.03, 3.39, 
3.33, 3.21, 2.04, 4.49, 4.94, 3, 7.59, 6.84, 2.11, 6.36, 2.63, 
2.01, 2.73, 4.94, 2.7, 2.65)

bgchen
[EMAIL PROTECTED]
  2007-10-19
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] ARCH LM test for univariant time series

2008-02-01 Thread Spencer Graves
Hi, Tom: 

  The 'arch' function in the 'vars' package is supposed to be able 
to do that.  Unfortunately, I was unable to make it work for a 
univariate series.  Bernhard Pfaff, the author of 'vars', said that if I 
read the code for 'arch', I could easily retrieve the necessary lines 
and put them in my own function;  I have not so far found the time to 
try that.  If you do, or if you get a better answer than this, would you 
please let me know?  I would like to have this capability for the 
'FinTS' package, and I would happily write a help page if someone would 
contribute the function -- or use a function in another package.  Tsay 
(2005) Analysis of Financial Time Series, 2nd ed. (Wiley) includes an 
example on p. 103 that could be used for a reference. 

  Hope this helps. 
  Spencer Graves   

tom soyer wrote:
 Hi,

 Does anyone know if R has a Lagrange multiplier (LM) test for ARCH
 effects for univariant time series?

 Thanks!



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


Re: [R] best text editor for Linux?

2008-02-01 Thread 宋时歌
On Linux platform, nothing beats Emacs + ESS.

Shige

On Feb 2, 2008 11:06 AM, Wade Wall [EMAIL PROTECTED] wrote:

 Hi all,

 I know this question has been asked in the past, but I am wondering if
 anyone running R on Linux has any guidance as to a text editor that works
 well with R.  At the present time I am running R on Windows and using
 TINN-R.  For a number of reasons I want to switch to Linux, but can't find
 much in the way of a text editor in sync with R.  Any experiences,
 recommendations would be appreciated.

 Wade Wall

[[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] ARCH LM test for univariant time series

2008-02-01 Thread tom soyer
Spencer, how about something like this:

archTest=function (x, lags= 16){
 #x is a vector
 require(vars)
 s=embed(x,lags)
 y=VAR(s,p=1,type=const)
 result=arch(y,multi=F)$arch.uni[[1]]
 return(result)
}

can you, or maybe Bernhard, check and see whether this function gives the
correct result?

thanks,

On 2/1/08, Spencer Graves [EMAIL PROTECTED] wrote:

 Hi, Tom:

  The 'arch' function in the 'vars' package is supposed to be able
 to do that.  Unfortunately, I was unable to make it work for a
 univariate series.  Bernhard Pfaff, the author of 'vars', said that if I
 read the code for 'arch', I could easily retrieve the necessary lines
 and put them in my own function;  I have not so far found the time to
 try that.  If you do, or if you get a better answer than this, would you
 please let me know?  I would like to have this capability for the
 'FinTS' package, and I would happily write a help page if someone would
 contribute the function -- or use a function in another package.  Tsay
 (2005) Analysis of Financial Time Series, 2nd ed. (Wiley) includes an
 example on p. 103 that could be used for a reference.

  Hope this helps.
  Spencer Graves

 tom soyer wrote:
  Hi,
 
  Does anyone know if R has a Lagrange multiplier (LM) test for ARCH
  effects for univariant time series?
 
  Thanks!
 
 




-- 
Tom

[[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] multiple functions with three dots

2008-02-01 Thread Jim Lemon
John Lande wrote:
 Dear all,
 
 I am creating functions with the three dot strategy. I wold like to have
 suggestion when writing multiple functions that calls multiple functions
 with 
 
 I will give you a couple of example:
 
 
a=1:5
b=6:10
d=3:7
 
 
example=function(x,y, z, ...){
 
plot(x,y, ...)
points(x,z, ...)
 
 }
 
 
example(a,b,d)
 
 
 how can I set different parameters for points and plot functions? for
 example in plot I want to have bigger dots (lwd=3), while in the points I
 want to have green dots.
 
 any suggestion?
 
Hi John,
There are probably better solutions to this problem, but I usually add 
explicit arguments like this:

example-function(x,y,z,y.lwd,z.col,...) {
  ...
  plot(x,y,lwd=y.lwd,...)
  points(x,z,col=z.col)
  ...
}

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] (no subject)

2008-02-01 Thread Jim Lemon
bgchen wrote:
 r-help
 
 c(2.43, 3.22, 6.9, 3.03, 5.36, 6.9, 2.29, 6.13, 6.11, 4.25, 3.85, 
 5.09, 7.44, 2.86, 2.82, 3.64, 3.22, 7, 2.65, 4.5, 3.73, 5.09, 
 5.8, 7.87, 2.87, 2.9, 6.63, 6.8, 2.45, 7.68, 2.56, 2.54, 7.35, 
 4.61, 2.58, 3.27, 5.8, 3.13, 3.29, 2.56, 5.79, 2.67, 7.55, 7.13, 
 8.4, 6.16, 3.34, 6.49, 1.85, 7.4, 7.89, 3.3, 6.28, 6.52, 6.07, 
 4.26, 4.4, 3.1, 5.97, 6.69, 3.69, 4.62, 5.79, 2.54, 8.91, 3.48, 
 2.35, 7.28, 6.75, 6.97, 7.29, 2.28, 3.36, 4.79, 2.41, 7.93, 6.17, 
 2.19, 4.27, 7.17, 2.12, 3.05, 4.4, 5.35, 2.96, 3.54, 3.31, 7.28, 
 2.47, 2.27, 7.43, 3.69, 3.32, 2.61, 2.19, 5.67, 5.03, 7.58, 5.27, 
 2.25, 2.59, 4.16, 1.71, 3.64, 2.93, 7.2, 5.99, 7.68, 4.14, 5.83, 
 3.87, 7.29, 5.95, 3.4, 2.45, 2.85, 6.77, 3.58, 4.31, 5.83, 6.19, 
 2.56, 6.69, 7.2, 5.04, 4.34, 2.66, 7.68, 6.8, 2.5, 1.95, 7.12, 
 3.02, 2.58, 3.39, 3.78, 3.53, 4.42, 6.64, 2.19, 4.79, 5.75, 5.55, 
 5.57, 3.94, 7.27, 3.39, 6.64, 6.13, 4.55, 6.75, 3.79, 1.82, 5.95, 
 5.88, 2.64, 5.43, 7.9, 3.14, 5.38, 7.97, 5.83, 3.18, 2.47, 3.33, 
 6.98, 6.35, 6.1, 7.11, 7.34, 5.08, 2, 3.13, 2.96, 2.43, 2.12, 
 3.24, 3.13, 2.6, 5.15, 3.34, 7.07, 5.42, 3.1, 2.66, 2.42, 7.3, 
 3.28, 4.68, 5.9, 6.64, 4.79, 1.84, 6.78, 6.1, 3.29, 2.35, 2.16, 
 6.36, 6.41, 5.39, 2.48, 7.35, 5.87, 6.77, 5.66, 2.81, 5.27, 2.95, 
 7.01, 2.55, 3.4, 2.84, 2.35, 6.36, 4.31, 7.44, 3.35, 6.42, 5.86, 
 3.14, 6.95, 5.27, 2.05, 4.85, 3.37, 2.28, 7.59, 6.99, 5.68, 4.5, 
 2.81, 6.07, 5.27, 6.32, 5.25, 3.69, 3.89, 3.23, 3.5, 6.2, 6.78, 
 2.51, 5.87, 7, 6.99, 7.27, 7.62, 6.87, 2.38, 6.78, 3.11, 4.28, 
 7.57, 5.65, 3.32, 2.53, 3.09, 4.99, 2.19, 6.37, 2.68, 7.22, 2.47, 
 3.05, 4.92, 2.82, 7.72, 3.67, 6.76, 6.38, 3.18, 3.02, 6.2, 3.47, 
 3.02, 7.22, 2.21, 7.33, 7.58, 6.58, 2.98, 6.7, 2.64, 6, 2.72, 
 2, 6.35, 5.36, 6.74, 5.29, 6.22, 3.14, 7.15, 4.45, 2.34, 2.63, 
 4.62, 7.51, 7.4, 3.16, 5.99, 7.07, 4.85, 3.11, 4.6, 6.55, 2.63, 
 3.15, 5.16, 5.81, 3.99, 6.12, 4.08, 3.69, 3.32, 3.13, 2.41, 2.95, 
 2.88, 5.79, 5.83, 2.49, 3.8, 4.62, 3.71, 3.18, 7.41, 7.3, 6.51, 
 2.27, 7.15, 6.04, 8.11, 7.74, 7.09, 7.21, 2.54, 6.74, 3.48, 7.8, 
 6.41, 5.64, 5.11, 4.91, 2.25, 3.31, 3.95, 6.58, 5.38, 5.45, 3.46, 
 2.4, 5.79, 3.34, 3.32, 1.97, 2.49, 3.29, 5.69, 1.75, 4.57, 7.04, 
 5.29, 7.79, 7.84, 3.02, 4.36, 6.87, 2.14, 5.43, 4.11, 7.51, 2.13, 
 5.33, 2.91, 2.87, 5.95, 2.29, 2.08, 7.78, 3.96, 4.55, 2.82, 2.63, 
 3.13, 3.43, 5.96, 2.39, 4.98, 3.51, 6.26, 4.03, 2.41, 6.8, 7.64, 
 3.3, 2.66, 6.51, 3.33, 5.64, 2.5, 6.09, 2.63, 2.55, 2.52, 4.15, 
 5.3, 6.11, 5.13, 3.42, 7.42, 1.87, 6.64, 4.63, 3.25, 1.97, 5.44, 
 7.96, 6.67, 7.14, 5.12, 5.27, 7.48, 7.25, 2.51, 4.5, 2.87, 6.7, 
 2.09, 6.85, 2.16, 6.37, 3.01, 3.55, 4.5, 2.69, 3.52, 5.7, 3.02, 
 5.94, 7.38, 6.45, 5.33, 2.8, 4.83, 3.01, 6.34, 2.99, 1.98, 3.02, 
 3.11, 8.65, 6.38, 7.08, 7.74, 6.19, 7.97, 2.7, 5.05, 6.61, 3.75, 
 5.24, 6.59, 5.91, 2.02, 6.95, 3.05, 2.89, 5.09, 4.9, 6.78, 5.79, 
 5.42, 3.13, 3.97, 2.24, 5.91, 6.28, 3.44, 6.14, 2.41, 8.03, 3.39, 
 3.33, 3.21, 2.04, 4.49, 4.94, 3, 7.59, 6.84, 2.11, 6.36, 2.63, 
 2.01, 2.73, 4.94, 2.7, 2.65)  
 
42

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.