Re: [R] group by-like statement for 2-row matrix

2009-04-08 Thread Hans-Henning Gabriel
Luc, Eik, Jorge,

thanks to all of you!
Nice to see how many different solutions there are for the same  
problem. :)

Best
Henning



Am 07.04.2009 um 22:25 schrieb Jorge Ivan Velez:

>
> Dear Hans,
>
> Try also:
>
> x <- structure(c(2, 1, 2, 1, 3, 2, 4, 1, 4, 3, 4, 3, 5, 2, 5, 1, 6,  
> 1), .Dim = c(2L, 9L))
> tapply(x[2,],x[1,],sum)
> #2 3 4 5 6
> #2 2 7 3 1
>
> HTH,
>
> Jorge
>
>
> On Tue, Apr 7, 2009 at 11:06 AM, Hans-Henning Gabriel 
>  > wrote:
> Hi,
>
> my problem is as follows:
>
> I have a matrix of two rows like this:
>
> 2 2 3 4 4 4 5 5 6
> 1 1 2 1 3 3 2 1 1
>
> Can I apply something like "group by" in sql? What I want to achieve  
> is the some of second row for each unique entry of first row:
>
> 2 -> 2 (=1+1)
> 3 -> 2
> 4 -> 7 (=1+3+3)
> 5 -> 3 (=2+1)
> 6 -> 1
>
> Thanks!!
> Henning
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Re ading Excel 5.0 files with RODBC?

2009-04-08 Thread Yuri Volchik

Thanks for reply David, 

but the problem is that the place i get those files from saves them in the
old Excel format (Excel 5.0), not Excel 97-2003, so neither of the packages
(RODBC, xlsReadWrite) can read it.

>Your question is a bit confusing. This is the current state of play 
>regarding reading and writing Excel files with xlsReadWrite and RODBC.
>
>xlsReadWrite will read and write from Excel 97-2003 files (.xls files) 
>including reading from named sheets, but only writing a single sheet 
>workbook.

Regards,
Yuri



-- 
View this message in context: 
http://www.nabble.com/Reading-Excel-5.0-files-with-RODBC--tp22929781p22944550.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] References for elliptical2d(fCopulae)

2009-04-08 Thread caspar
Dear R-mailing list,

I am using the fCopulae package. 
Where can I find the relevant references for functions such as elliptical2d( ) 
? I am particularly interested in references pointing out how the correlation 
coefficients can be incorporated in such density functions. 

Thanks in advance 

Caspar Hallmann
[[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] Student

2009-04-08 Thread alberto cassese
Hi,
I have  problem. In the function below (test and test2) i want the function
test not to print the variable data but i want the function test2 to use the
variable test$data.

This is the creation of the variable data:

> matrice=c(1:10)
> matrice=matrix(matrice,nrow=5,ncol=2)

This is the function test:

> test=function(data){
+ return(list(x=5,data=data))
+ }

This is the function test2:

> test2=function(list){
+ bodri=list$data
+ bodri[1,2]=bodri[2,2]+1
+ return(bodri)
+ }

Below there are the result:

> uno=test(matrice)
> due=test2(uno)
> uno
$x
[1] 5

$data
 [,1] [,2]
[1,]16
[2,]27
[3,]38
[4,]49
[5,]5   10

> due
 [,1] [,2]
[1,]18
[2,]27
[3,]38
[4,]49
[5,]5   10


What i want is:

> uno=test(matrice)
> due=test2(uno)
> uno
$x
[1] 5

> due
 [,1] [,2]
[1,]18
[2,]27
[3,]38
[4,]49
[5,]5   10

Can you help me please?
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 loading an svm model from file

2009-04-08 Thread J Biel


Hi R-experts,

I'm using the svm implentation available in the library 'e1071', 
to train a classifier using cross validation

(...)

obj = tune.svm(truth ~ ., 
data=examples,cost=2^(grid.cost),gamma=2^(grid.gamma),cross=k)

and to save the best model into a file as ?write.svm suggests:

write.svm(obj$best.model, svm.file = "Rdata.svm",scale.file = 
"Rdata_svm.scale") 

My problem is when I want to read/load the Rdata.svm
which contains the R object corresponding to the svm model.
I didn't find the way to recover the data saved in Rdata.svm using
write.svm.
how can I do that?

Thanks,

John

Disfruta antes que nadie del nuevo Windows Live Messenger
_


[[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] asymptotic convergence intervall for poisson regression

2009-04-08 Thread soxx

Hello!

The following code is an implementation of a Poisson regression. It
generates some data-samples and computes the beta values with the negative
log likelihood function.
Now, my task is to compute the asymptotic convergence intervalls for the
values of beta but I dont know how to implement this function - this topic
is not in my lecture notes.

I hope someone can help me.

 > library(Bhat)

 > # generate new data

 > dose <- c(rep(0,50), rep(1,50), rep(5,50), rep(10,50))
 > data <- cbind(dose, rpois(200,2*(1+(10-dose)
*.5*(1-(10-dose)*0.05
 > data
 > lambda <- function(dose)
 > {
 > 2*(1+(10 - dose) * .5 * (1-(10-dose)*0.05))
 > }

 > plot(c(0:10),lambda(c(0:10)))
 > # estimated count of fits - dose 0:10
 > plot (data[,1] + rnorm(200, mean=0, sd=0.15), data[,2])

 > # Likelihood - function

 > negloglike <- function(beta)
 > {
 > ds <- data[,1]
 > x <- data[,2]

 > lambda <- beta[1] * (1 + ( 10 - ds )
* beta[2] * (1 - (10 - ds) * beta[3]))
 > return(sum(lambda - x * log(lambda)))
 > }

 > beta <- list(label = c("beta1","beta2","beta3"),
est=c(2.5,0.5,0.1), low=c(1,0,0),upp=c(3,2,2))
 > result <- dfp(beta,f=negloglike)
 > result 


Kind regards

-- 
View this message in context: 
http://www.nabble.com/asymptotic-convergence-intervall-for-poisson-regression-tp22944357p22944357.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] [R-pkgs] tcltk - control message while the program is running

2009-04-08 Thread srpd TCLTK

Hi,

We are trying to write control messages (errors, warnings, ...) to a tktable 
while the program is running. Until now we only managed to write all the 
messages at once at the end of execution. How can we refresh the window in 
order to show the tclArray content?

 



  ...

  options(show.error.messages = FALSE, warn=1)
  base <- try(suppressWarnings(DesenhoRegisto(regiao,ano,trimestre)))
  if (class(base) == "try-error")
  {
  msg <- paste("Desenho de registo:",as.character(base),sep=" ")
  msg <- sub("\n","",msg)
  return(list(tabela=NULL,msg=msg))
  }
  msg <- "Desenho de Registo...Ok"
  print(msg)
  tclArray1[[1,0]]<<-as.tclObj(msg, drop=TRUE)
  tkactivate(table1, "1,1")
  tksee(table1, "1,1")
  
  message("testing")
  
  aloj <- data.frame(base[2])
  base <- data.frame(base[1])
  
  base <- try(suppressWarnings(VariaveisAuxiliares(base,ano,trimestre)))
  if (class(base) == "try-error")
  {
  msg <- paste("Variáveis auxiliares:",as.character(base),sep=" ")
  msg <- sub("\n","",msg)
  return(list(tabela=NULL,msg=msg))
  }
  msg <- "Variáveis Auxiliares...Ok"
  tkinsert(table1,"rows","end",1)
  tclArray1[[2,0]]<<-as.tclObj(msg, drop=TRUE)
  tkactivate(table1, "2,1")
  tksee(table1, "2,1")

  ...





Thank you all,

SRPD



_


[[alternative HTML version deleted]]

___
R-packages mailing list
r-packa...@r-project.org

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 ading Excel 5.0 files with RODBC?

2009-04-08 Thread Prof Brian Ripley

On Wed, 8 Apr 2009, Yuri Volchik wrote:



Thanks for reply David,

but the problem is that the place i get those files from saves them in the
old Excel format (Excel 5.0), not Excel 97-2003, so neither of the packages
(RODBC, xlsReadWrite) can read it.


RODBC supports any format for which an ODBC driver is installed and 
Microsoft have long supplied ones for Excel 3.0 and later (up to Excel 
2007 at present).


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

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


Re: [R] Minimum Spanning Tree

2009-04-08 Thread Gábor Csárdi
On Tue, Apr 7, 2009 at 11:06 PM, jpearl01  wrote:
>
> There was an error in the file... an extraneous comma.  That's taken care of.
> however, my tree prints out an image that doesn't seem like a mst.  Attached
> is the csv file I used...

Well, it looks definitely a tree to me.

> http://www.nabble.com/file/p22938299/sp_matrix.csv sp_matrix.csv
>
> I'd like it to look something like the image file also attached...
> http://www.nabble.com/file/p22938299/2006-08-27_MST.png 2006-08-27_MST.png
>
> Is there a different layout that would accomplish that?  Or if not that
> exactly, one that would help make the results a little clearer?

I am not sure what you mean. Of course you can plot it using different
layouts, e.g. with layout.reingold.tilford (after choosing the root
vertex in some way) and then it looks like a usual tree plot, but why
would that be any better?

Unless there is some external information about the graph (e.g.
spatial positions of the nodes, or a distinguished root vertex), the
layout on the image is just as good as the others.

Gabor

> Thanks for all the help!
> ~josh
> --
> View this message in context: 
> http://www.nabble.com/Minimum-Spanning-Tree-tp22934813p22938299.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.
>



-- 
Gabor Csardi  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] Annotation rgl plot

2009-04-08 Thread Yuri Volchik

Thanks for a great package Duncan, 
one of the most amazing things i saw for R platform.
In the meanwhile i can do with you suggestion: par3d(ignoreExtent=TRUE);

-- 
View this message in context: 
http://www.nabble.com/Annotation-rgl-plot-tp22930428p22945459.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Student

2009-04-08 Thread Hans Ekbrand
On Wed, Apr 08, 2009 at 10:02:10AM +0200, alberto cassese wrote:
> Hi,
> I have  problem. In the function below (test and test2) i want the function
> test not to print the variable data but i want the function test2 to use the
> variable test$data.
>
> This is the creation of the variable data:
> 
> > matrice=c(1:10)
> > matrice=matrix(matrice,nrow=5,ncol=2)
> 
> This is the function test:
> 
> > test=function(data){
> + return(list(x=5,data=data))
> + }
> 
> This is the function test2:
> 
> > test2=function(list){
> + bodri=list$data
> + bodri[1,2]=bodri[2,2]+1
> + return(bodri)
> + }
> 
> Below there are the result:
> 
> > uno=test(matrice)
> > due=test2(uno)
> > uno
> $x
> [1] 5
> 
> $data
>  [,1] [,2]
> [1,]16
> [2,]27
> [3,]38
> [4,]49
> [5,]5   10
> 
> > due
>  [,1] [,2]
> [1,]18
> [2,]27
> [3,]38
> [4,]49
> [5,]5   10
> 
> 
> What i want is:
> 
> > uno=test(matrice)
> > due=test2(uno)
> > uno
> $x
> [1] 5

x is a variable, 5 is variable data and you don't want variable data
printed?

> > due
>  [,1] [,2]
> [1,]18
> [2,]27
> [3,]38
> [4,]49
> [5,]5   10
> 

Use uno[1], either directly or by creating a third variable from uno[1]

> one.and.a.half <- uno[1]
> one.and.a.half
$x
[1] 5

Or, if you *really* want what that printed output from test(matrice),
create a class for your list-object, and add a special print method,
that will only print the first item of the list.


-- 
Hans Ekbrand (http://sociologi.cjb.net) 
A. Because it breaks the logical sequence of discussion
Q. Why is top posting bad?


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


[R] Tinn-R pdf()

2009-04-08 Thread Henning Wildhagen
Dear R and Tinn-R users,

i recently switched to Tinn-R and sending code to R works fine (R 2.8.1, 
Tinn-R 2.2.0.2, OS Windows XP). However, i encountered a problem when 
trying to send plots to pdf files like this:

library(lattice)

pdf("plot1.pdf")
PLOT<-(xyplot, ...)
PLOT
dev.off()

The file "plot1.pdf" is created, but it is empty.
If i paste the code above directly into the R console and run it, the file 
"plot1.pdf" is created and in this case contains "PLOT".

I guess that some settings in Tinn-R are wrong, but i have no idea which. 
Maybe someone has a suggestion?

Thanks,

Henning
-- 


[[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] Clear all with/without function()

2009-04-08 Thread Taraxacum88

why 

rm(list=ls(all=TRUE),envir=globalenv())

is ok but

ca<-function()  rm(list=ls(all=TRUE),envir=globalenv())
ca()

does not work?


Thank you!
v

-- 
View this message in context: 
http://www.nabble.com/Clear-all-with-without-function%28%29-tp22947021p22947021.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] read.spss, locale and encodings

2009-04-08 Thread Hans Ekbrand
I must be missing something obvious here:

According to the help page for read.spss, the reencode option is only
active when R is run under a UTF-8 locale.

read.spss can only import the SPSS file when run under a iso88591(5)
locale, under a UTF-8 locale I get:

Error in read.spss("wo.sav") : error reading system-file header
In addition: Warning message:
In read.spss("wo.sav") :
  wo.sav: position 143: Variable name begins with invalid character

This is under Debian GNU/Linux, the stable release.

foreign is version 8.27

-- 
Hans Ekbrand (http://sociologi.cjb.net) 
GPG Fingerprint: 1408 C8D5 1E7D 4C9C C27E 014F 7C2C 872A 7050 614E


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


Re: [R] Clear all with/without function()

2009-04-08 Thread Duncan Murdoch

Taraxacum88 wrote:
why 


rm(list=ls(all=TRUE),envir=globalenv())

is ok but

ca<-function()  rm(list=ls(all=TRUE),envir=globalenv())
ca()

does not work?


ls(all=TRUE) from within your function lists all local variables, not 
globals.  You need envir=globalenv() there too.


Duncan Murdoch

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


Re: [R] Tinn-R pdf()

2009-04-08 Thread ONKELINX, Thierry
Dear Henning,

You need to print() lattice plots when using a device:
 
library(lattice)

pdf("plot1.pdf")
PLOT<-(xyplot, ...)
print(PLOT)
dev.off()

So this is not due to TINN-R.

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
thierry.onkel...@inbo.be 
www.inbo.be 

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

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

-Oorspronkelijk bericht-
Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens Henning Wildhagen
Verzonden: woensdag 8 april 2009 11:25
Aan: r-help@r-project.org
Onderwerp: [R] Tinn-R pdf()

Dear R and Tinn-R users,

i recently switched to Tinn-R and sending code to R works fine (R 2.8.1,

Tinn-R 2.2.0.2, OS Windows XP). However, i encountered a problem when 
trying to send plots to pdf files like this:

library(lattice)

pdf("plot1.pdf")
PLOT<-(xyplot, ...)
PLOT
dev.off()

The file "plot1.pdf" is created, but it is empty.
If i paste the code above directly into the R console and run it, the
file 
"plot1.pdf" is created and in this case contains "PLOT".

I guess that some settings in Tinn-R are wrong, but i have no idea
which. 
Maybe someone has a suggestion?

Thanks,

Henning
-- 


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

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

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


Re: [R] change default output size when using Sweave

2009-04-08 Thread baptiste auguie

On 8 Apr 2009, at 11:44, Duncan Murdoch wrote:


Mark Heckmann wrote:

Dear Duncan,

Thanks for the reply. This works, but unfortunately I need a  
different

solution.
My script is supposed to run completely automated and the graphics  
I produce
vary in size each time I run the script. But I want the graphics to  
be
fitted to my .pdf output without specifying the height argument  
manually

each time.



If your documents are more or less fixed, you could add an extra
preprocessor step before running Sweave.  For example, create mydoc.in
containing

<>=
...
@

and then use sed or some other text substitution utility (even R, by
reading your whole document into an R variable) to substitute the
desired size for
the string @s...@.  It's clunky, but it sounds as though you're
interested in producing standardized documents regularly, so it may be
acceptable.


For that task you might find interest in the brew package by Jeffrey  
Horner.


baptiste




Duncan Murdoch
That is why I do not want a fixed height as a code chunk argument.  
Actually
I do not know if it is possible to have a variable placed in a code  
chunk

header. I tried the following which does not work:

<<>>=
size <- 3
@

<>=
  pushViewport(viewport(height = unit(80, "mm")))
  grid.rect()
  grid.text("I want this viewport to be the whole output size")
  popViewport()
@

So still I face the problem to have Sweave generate a .pdf graphic  
that is

just as big I want it to be.

In the Sweave Docu paragraph A.9 I discovered something I use as a
workaround. I produce the .pdf output manually (where I can control  
the

size) and add each graphic to LaTex manually as well.

<>=
for (i in 1){
file=paste("myfile", i, ".pdf", sep="")
pdf(file=file, paper="special", width=6, height=3)
  pushViewport(viewport(height = unit(5, "inches")))
  grid.rect()
  grid.text("I want this viewport to be the whole output size")
  popViewport()dev.off()
cat("\\includegraphics{", file, "}\n\n", sep="")
}
@

I use parenthesis around the code as it prints out something I do  
not want

if no parenthesis are used (I use Windows).

I am not too happy with the solution. I would prefer a more  
straightforward
approach to define the size of the output graphic. I wonder if  
there are

some Sweave settings that can be modified.

In the Sweave manual (A.11) I found the following to customize the  
par

settings for each figure:

options(SweaveHooks=list(fig=function() par(bg="red", fg="blue")))

I wonder if something similar could be done changing the size of  
the default
output device (pdf or eps) for each figure like  
>pdf.options(height=2) or

similar (it seems that this does not work)?

I suppose this type of graphic customization is quite a common  
issue when
producing automated customized output/reports using R and Sweave  
but I

haven't found anything concerning this topic yet.

So I would be really glad if someone knows a solution.

TIA, Mark




-Ursprüngliche Nachricht-
Von: Duncan Murdoch [mailto:murd...@stats.uwo.ca]
Gesendet: Dienstag, 7. April 2009 19:08
An: Mark Heckmann
Cc: r-help@r-project.org
Betreff: Re: [R] change default output size when using Sweave

On 4/7/2009 10:39 AM, Mark Heckmann wrote:

I am trying to create a graphic output in Sweave but I do not want  
it to



be

standard size. I want the whole graphic to be 80mm of height only,  
just



like


the viewport below.

<>=
  pushViewport(viewport(height = unit(80, "mm")))
  grid.rect()
  grid.text("I want this viewport to be the whole output size")
  popViewport()
@

How can I make the graphic smaller (80mm of height) without having  
the



white


margins at the top and bottom?



You can specify height and width as arguments to the code chunk or  
set

new defaults with something like

\SweaveOpts{width=5,height=3}

(I think those measurements need to be given in inches; I don't think
there's a way to use an expression like unit(80,"mm").)

You can also control the size of the plot in the final document with
LaTeX code like

\usepackage{graphicx}
\setkeys{Gin}{width=3in}

and then the LaTeX rules for handling units would apply, so 80mm is  
fine

instead of 3in.

Duncan Murdoch

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



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


_

Baptiste Auguié

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag

__
R-help@r-project.org mailing list

Re: [R] Tinn-R pdf()

2009-04-08 Thread Henning Wildhagen
Dear Thierry,

thanks for your help, with solved the problem, although i don't why, 
because when using the R editor accessible via the R console i created many 
many lattice plots with the code i posted, i.e. without the print() 
command.

Anyway, thanks a lot,

Henning

> 
>  Original-Nachricht 
> Datum: Wed, 8 Apr 2009 12:29:58 +0200
> Von: "ONKELINX, Thierry" 
> An: "Henning Wildhagen" , r-help@r-project.org
> Betreff: RE: [R] Tinn-R pdf()
> 
> Dear Henning,
> 
> You need to print() lattice plots when using a device:
>  
> library(lattice)
> 
> pdf("plot1.pdf")
> PLOT<-(xyplot, ...)
> print(PLOT)
> dev.off()
> 
> So this is not due to TINN-R.
> 
> 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
> thierry.onkel...@inbo.be 
> www.inbo.be 
> 
> To call in the statistician after the experiment is done may be no more
> than asking him to perform a post-mortem examination: he may be able to
> say what the experiment died of.
> ~ Sir Ronald Aylmer Fisher
> 
> The plural of anecdote is not data.
> ~ Roger Brinner
> 
> The combination of some data and an aching desire for an answer does not
> ensure that a reasonable answer can be extracted from a given body of
> data.
> ~ John Tukey
> 
> -Oorspronkelijk bericht-
> Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> Namens Henning Wildhagen
> Verzonden: woensdag 8 april 2009 11:25
> Aan: r-help@r-project.org
> Onderwerp: [R] Tinn-R pdf()
> 
> Dear R and Tinn-R users,
> 
> i recently switched to Tinn-R and sending code to R works fine (R 2.8.1,
> 
> Tinn-R 2.2.0.2, OS Windows XP). However, i encountered a problem when 
> trying to send plots to pdf files like this:
> 
> library(lattice)
> 
> pdf("plot1.pdf")
> PLOT<-(xyplot, ...)
> PLOT
> dev.off()
> 
> The file "plot1.pdf" is created, but it is empty.
> If i paste the code above directly into the R console and run it, the
> file 
> "plot1.pdf" is created and in this case contains "PLOT".
> 
> I guess that some settings in Tinn-R are wrong, but i have no idea
> which. 
> Maybe someone has a suggestion?
> 
> Thanks,
> 
> Henning
> -- 
> 
> 
>   [[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.
> 
> Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver 
> weer 
> en binden het INBO onder geen enkel beding, zolang dit bericht niet 
> bevestigd is
> door een geldig ondertekend document. The views expressed in  this 
> message 
> and any annex are purely those of the writer and may not be regarded as 
> stating 
> an official position of INBO, as long as the message is not confirmed by 
> a duly 
> signed document.
> 

-- 


[[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] factor, as.factor and levels

2009-04-08 Thread Heinz Tuechler

Dear All,

to my surprise as.factor does not accept a levels argument. Maybe I 
did not read the documentation well enough. See the example below. I 
wanted to use ch1 as factor in the newdata argument of survfit, so I 
assumed that I could write as.factor(ch1, levels=ch1), since the 
order should be kept.


But as.factor(ch1, levels=ch1) results in the error:

Error in as.factor(ch1, levels = ch1) :
  unused argument(s) (levels = c("low", "inter", "high"))

factor(ch1, levels=ch1) works as I expected.
Is it intended that as.factor does not use the levels argument?

Thanks,

Heinz

ch1 <- c('low', 'inter', 'high')
factor(ch1)
factor(ch1, levels=ch1)
as.factor(ch1, levels=ch1)

> version
   _
platform   i386-pc-mingw32
arch   i386
os mingw32
system i386, mingw32
status Patched
major  2
minor  8.1
year   2009
month  03
day13
svn rev48132
language   R
version.string R version 2.8.1 Patched (2009-03-13 r48132)
> sessionInfo()
R version 2.8.1 Patched (2009-03-13 r48132)
i386-pc-mingw32

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

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

other attached packages:
[1] survival_2.34-1 car_1.2-12  gmodels_2.14.1  gdata_2.4.2
[5] Hmisc_3.5-2

loaded via a namespace (and not attached):
[1] cluster_1.11.12 grid_2.8.1  gtools_2.5.0-1  lattice_0.17-20
[5] MASS_7.2-46
>

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

2009-04-08 Thread Chrysanthi A.
Hello,

I am a phd student in Bioinformatics and I am using the Random Forest
package in order to classify my data, but I have some questions.
Is there a function in order to visualize the trees, so as to get the rules?
Also, could you please provide me with the code of "randomForest" function,
as I would like to see how it works. I was wondering if I can get the
classification having the most votes over all the trees in the forest (the
final rules that will give me the final classification). Also, is there a
possibility to get a vector with the attributes that are being selected for
each node during the construction of each tree? I mean, that I would like to
know the m

Re: [R] factor, as.factor and levels

2009-04-08 Thread Heinz Tuechler

Thank you, Jim. I see, the fact that in the documentation you find only
"as.factor(x)" means that it does not accept more arguments.
Does as.factor have speed advantages over factor, or is there a 
different cause for it's existence?


Heinz



At 13:50 08.04.2009, jim holtman wrote:

as.factor does not accept levels as an argument.  use the first form
that you have

factor(ch1, levels=ch1)



On Wed, Apr 8, 2009 at 7:36 AM, Heinz Tuechler  wrote:
> Dear All,
>
> to my surprise as.factor does not accept a levels argument. Maybe I did not
> read the documentation well enough. See the example below. I wanted to use
> ch1 as factor in the newdata argument of survfit, so I assumed that I could
> write as.factor(ch1, levels=ch1), since the order should be kept.
>
> But as.factor(ch1, levels=ch1) results in the error:
>
> Error in as.factor(ch1, levels = ch1) :
>  unused argument(s) (levels = c("low", "inter", "high"))
>
> factor(ch1, levels=ch1) works as I expected.
> Is it intended that as.factor does not use the levels argument?
>
> Thanks,
>
> Heinz
>
> ch1 <- c('low', 'inter', 'high')
> factor(ch1)
> factor(ch1, levels=ch1)
> as.factor(ch1, levels=ch1)
>
>> version
>   _
> platform   i386-pc-mingw32
> arch   i386
> os mingw32
> system i386, mingw32
> status Patched
> major  2
> minor  8.1
> year   2009
> month  03
> day13
> svn rev48132
> language   R
> version.string R version 2.8.1 Patched (2009-03-13 r48132)
>> sessionInfo()
> R version 2.8.1 Patched (2009-03-13 r48132)
> i386-pc-mingw32
>
> locale:
> 
LC_COLLATE=German_Switzerland.1252;LC_CTYPE=German_Switzerland.1252;LC_MONETARY=German_Switzerland.1252;LC_NUMERIC=C;LC_TIME=German_Switzerland.1252

>
> attached base packages:
> [1] splines   stats graphics  grDevices utils datasets  methods
> [8] base
>
> other attached packages:
> [1] survival_2.34-1 car_1.2-12  gmodels_2.14.1  gdata_2.4.2
> [5] Hmisc_3.5-2
>
> loaded via a namespace (and not attached):
> [1] cluster_1.11.12 grid_2.8.1  gtools_2.5.0-1  lattice_0.17-20
> [5] MASS_7.2-46
>>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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 that 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.


Re: [R] Sequences

2009-04-08 Thread Eik Vettorazzi

Hi Melissa,
so what you want to calculate is something like

S<-cumsum(lambs)-(1:length(lambs))*mean(lambs)

since (with x.bar=mean(x))
S_1=x_1-x.bar
S_2=S1+(x_2-x.bar)=x_1-x.bar+x_2-x_bar=x_1+x_2-2*x.bar
...
S_n=S_(n-1)+x_n-x.bar=sum_i (x_i)-n*x.bar

Eik.

m.mcquil...@lancaster.ac.uk schrieb:

Hi,

I am trying to perform a change point analysis. I know there is a function
that does this but I am just out of university on an internship so they
are trying to make me do it myself using this website :

http://www.variation.com/cpa/tech/changepoint.html

So if you look for CUMSUM on this you will see what I am trying to do but
I'm not having much success!

Melissa


  


--
Eik Vettorazzi
Institut für Medizinische Biometrie und Epidemiologie
Universitätsklinikum Hamburg-Eppendorf

Martinistr. 52
20246 Hamburg

T ++49/40/42803-8243
F ++49/40/42803-7790

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


Re: [R] change default output size when using Sweave

2009-04-08 Thread Duncan Murdoch

Mark Heckmann wrote:

Dear Duncan,

Thanks for the reply. This works, but unfortunately I need a different
solution.
My script is supposed to run completely automated and the graphics I produce
vary in size each time I run the script. But I want the graphics to be
fitted to my .pdf output without specifying the height argument manually
each time.
  


If your documents are more or less fixed, you could add an extra 
preprocessor step before running Sweave.  For example, create mydoc.in 
containing


<>=
...
@

and then use sed or some other text substitution utility (even R, by 
reading your whole document into an R variable) to substitute the 
desired size for
the string @s...@.  It's clunky, but it sounds as though you're 
interested in producing standardized documents regularly, so it may be 
acceptable.


Duncan Murdoch

That is why I do not want a fixed height as a code chunk argument. Actually
I do not know if it is possible to have a variable placed in a code chunk
header. I tried the following which does not work:

<<>>=
size <- 3
@

<>=
   pushViewport(viewport(height = unit(80, "mm")))
   grid.rect()

   grid.text("I want this viewport to be the whole output size")
   popViewport()
@

So still I face the problem to have Sweave generate a .pdf graphic that is
just as big I want it to be.
 
In the Sweave Docu paragraph A.9 I discovered something I use as a

workaround. I produce the .pdf output manually (where I can control the
size) and add each graphic to LaTex manually as well.
 
<>=

for (i in 1){
file=paste("myfile", i, ".pdf", sep="")
pdf(file=file, paper="special", width=6, height=3)
   pushViewport(viewport(height = unit(5, "inches"))) 
   grid.rect()

   grid.text("I want this viewport to be the whole output size")
   popViewport()dev.off()
cat("\\includegraphics{", file, "}\n\n", sep="")
}
@

I use parenthesis around the code as it prints out something I do not want
if no parenthesis are used (I use Windows). 


I am not too happy with the solution. I would prefer a more straightforward
approach to define the size of the output graphic. I wonder if there are
some Sweave settings that can be modified. 


In the Sweave manual (A.11) I found the following to customize the par
settings for each figure:

options(SweaveHooks=list(fig=function() par(bg="red", fg="blue")))

I wonder if something similar could be done changing the size of the default
output device (pdf or eps) for each figure like >pdf.options(height=2) or
similar (it seems that this does not work)? 


I suppose this type of graphic customization is quite a common issue when
producing automated customized output/reports using R and Sweave but I
haven't found anything concerning this topic yet.

So I would be really glad if someone knows a solution.

TIA, Mark




-Ursprüngliche Nachricht-
Von: Duncan Murdoch [mailto:murd...@stats.uwo.ca] 
Gesendet: Dienstag, 7. April 2009 19:08

An: Mark Heckmann
Cc: r-help@r-project.org
Betreff: Re: [R] change default output size when using Sweave

On 4/7/2009 10:39 AM, Mark Heckmann wrote:
  

I am trying to create a graphic output in Sweave but I do not want it to


be
  

standard size. I want the whole graphic to be 80mm of height only, just


like
  

the viewport below.

<>=
   pushViewport(viewport(height = unit(80, "mm")))
   grid.rect()

   grid.text("I want this viewport to be the whole output size")
   popViewport()
@

How can I make the graphic smaller (80mm of height) without having the


white
  

margins at the top and bottom?



You can specify height and width as arguments to the code chunk or set 
new defaults with something like


\SweaveOpts{width=5,height=3}

(I think those measurements need to be given in inches; I don't think 
there's a way to use an expression like unit(80,"mm").)


You can also control the size of the plot in the final document with 
LaTeX code like


\usepackage{graphicx}
\setkeys{Gin}{width=3in}

and then the LaTeX rules for handling units would apply, so 80mm is fine 
instead of 3in.


Duncan Murdoch

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



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

2009-04-08 Thread Tobias Verbeke

Hi Henning,

thanks for your help, with solved the problem, although i don't why, 
because when using the R editor accessible via the R console i created many 
many lattice plots with the code i posted, i.e. without the print() 
command.


At the command line, R objects (including lattice plots which are
objects) get auto-printed, i.e. the print method is invoked 
automatically on these objects.


This is not the case when you write to a pdf file.

Best,
Tobias


 Original-Nachricht 
Datum: Wed, 8 Apr 2009 12:29:58 +0200
Von: "ONKELINX, Thierry" 
An: "Henning Wildhagen" , r-help@r-project.org
Betreff: RE: [R] Tinn-R pdf()

Dear Henning,

You need to print() lattice plots when using a device:
 
library(lattice)


pdf("plot1.pdf")
PLOT<-(xyplot, ...)
print(PLOT)
dev.off()

So this is not due to TINN-R.

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
thierry.onkel...@inbo.be 
www.inbo.be 


To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

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

-Oorspronkelijk bericht-
Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens Henning Wildhagen
Verzonden: woensdag 8 april 2009 11:25
Aan: r-help@r-project.org
Onderwerp: [R] Tinn-R pdf()

Dear R and Tinn-R users,

i recently switched to Tinn-R and sending code to R works fine (R 2.8.1,

Tinn-R 2.2.0.2, OS Windows XP). However, i encountered a problem when 
trying to send plots to pdf files like this:


library(lattice)

pdf("plot1.pdf")
PLOT<-(xyplot, ...)
PLOT
dev.off()

The file "plot1.pdf" is created, but it is empty.
If i paste the code above directly into the R console and run it, the
file 
"plot1.pdf" is created and in this case contains "PLOT".


I guess that some settings in Tinn-R are wrong, but i have no idea
which. 
Maybe someone has a suggestion?


Thanks,

Henning
--



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

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver 
weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet 
bevestigd is
door een geldig ondertekend document. The views expressed in  this 
message 
and any annex are purely those of the writer and may not be regarded as 
stating 
an official position of INBO, as long as the message is not confirmed by 
a duly 
signed document.






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


[R] Convert data frame containing time stamps to time series

2009-04-08 Thread amvds
I read records using scan:

dat<-data.frame(scan(file="KDA.csv",what=list(t="%m/%d/%y
%H:%M",f=0,p=0,d=0,o=0,s=0,a=0,l=0,c=0),skip=2,sep=",",nmax=np,flush=TRUE,na.strings=c("I/OTimeout","ArcOff-line")))

which results in:

> dat[1:5,]
 t fp  d  o   sa  l c
1 1/21/09 5:01 16151  8.2 76 30 282 1060 53 7
2 1/21/09 5:02 16256  8.3 76 23 282 1059 54 7
3 1/21/09 5:03 16150  8.4 76 26 282 1059 55 7
4 1/21/09 5:04 16150  9.0 76 25 282 1051 57 6
5 1/21/09 5:05 15543 10.4 76  7 282 1024 58 6

I have been unable to find a way to convert this into a time series. I did
read the manuals and came across a way to coerce a data frame to a ts
object: as.ts()

Trouble is I do not know how to keep the timestamps in column t in the
data frame above. The t column is not strings. If I do:

plot.ts(dat)

I can see how the first graphics panel is indeed numbers not text. So I
think scan converted the text correctly per the format string I put in.

Much more difficult still. The datafiles I have contain invalid data,
missing values and other none relevant information. I filter this out
using subset which works brilliantly. However, how can I filter using
subset and convert to a time series afterwards. Since after subsetting
there will be 'holes' i.e. missing records. Can a ts object deal with
missing records? If so, how? Just point me to a document. I can and will
put in the work to figure it out myself.

Thank you!
Alex van der Spek

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

2009-04-08 Thread Gundala Viswanath
Is there a way to do it in R?
Especially generating plot in EPS/PDF format.

By transparent I mean clear (not white) background.
I want to attached it to dark PPT slides.

- Gundala Viswanath

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

2009-04-08 Thread baptiste auguie

clr <-
function ()
rm(list = ls(pos = .GlobalEnv), pos = .GlobalEnv)


this works for me


HTH,

baptiste

On 8 Apr 2009, at 10:50, Taraxacum88 wrote:



why

rm(list=ls(all=TRUE),envir=globalenv())

is ok but

ca<-function()  rm(list=ls(all=TRUE),envir=globalenv())
ca()

does not work?


Thank you!
v

--
View this message in context: 
http://www.nabble.com/Clear-all-with-without-function%28%29-tp22947021p22947021.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.


_

Baptiste Auguié

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag

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

2009-04-08 Thread Benedikt Niesterok
Hello R users,
I've used the following help two compare two regression line slopes.
Wanted to test if they differ significantly:

Hi,

I've made a research about how to compare two regression line slopes  
(of y versus x for 2 groups, "group" being a factor ) using R.

I knew the method based on the following statement :
t = (b1 - b2) / sb1,b2
where b1 and b2 are the two slope coefficients and sb1,b2 the pooled  
standard error of the slope (b)

which can be calculated in R this way:
 > df1 <- data.frame(x=1:3, y=1:3+rnorm(3))
 > df2 <- data.frame(x=1:3, y=1:3+rnorm(3))
 > fit1 <- lm(y~x, df1)
 > s1 <- summary(fit1)$coefficients
 > fit2 <- lm(y~x, df2)
 > s2 <- summary(fit2)$coefficients
 > db <- (s2[2,1]-s1[2,1])
 > sd <- sqrt(s2[2,2]^2+s1[2,2]^2)
 > df <- (fit1$df.residual+fit2$df.residual)
 > td <- db/sd
 > 2*pt(-abs(td), df)

My value I get by running this test is :[1] 2.305553e-07
Does it mean the two slopes differ significantly, because this value is in
the alpha area, so that I have to reject the null- hypothesis and accept
the alternative hypothesis?
Is the  null-hypothesis: slope1=slope2?
Thanks for your help,  Benedikt
--

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

2009-04-08 Thread Bernardo Rangel Tura
On Tue, 2009-04-07 at 16:33 -0400, Donald Braman wrote:
> I've been playing around with various table tools, trying to construct a
> fairly simple cross-tab.  It shouldn't be hard, but for some reason it
> turning out to be (for me).
> 
> If I want to see how many men and how many women agree with a agree/disagree
> question (coded 1,0), I can do this:
> 
> >attach(mydata)
> >mytable <- table(male, q1.bin) # gender and a binary response variable
> >prop.table(mytable, 1) # row percentages
>  q1.bin
> male  0  1
>0 0.3988 0.6012
>1 0.2879 0.7121
> 
> I can repeat that for each of the items I want gender breakdowns for (q2,
> q3, q4 ).   But what I really want is a table that shows the percentage
> answering yes (coded as 1) across many, many binary response items.  E.g.,
> 
> 
> male q1.bin q2.bin q3.bin ...
>0 0.6012 0.3421 0.9871 ...
>1 0.7121 0.6223 0.0198 ...
> 
> I've tried various combinations of apply & cbind, but to no avail. It would
> be easy in SPSS crosstabs, but darnit, I want to use R!

Donald,

The other solutions is using command CrossTable of package gmodels.
-- 
Bernardo Rangel Tura, M.D,MPH,Ph.D
National Institute of Cardiology
Brazil

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

2009-04-08 Thread jim holtman
as.factor does not accept levels as an argument.  use the first form
that you have

factor(ch1, levels=ch1)



On Wed, Apr 8, 2009 at 7:36 AM, Heinz Tuechler  wrote:
> Dear All,
>
> to my surprise as.factor does not accept a levels argument. Maybe I did not
> read the documentation well enough. See the example below. I wanted to use
> ch1 as factor in the newdata argument of survfit, so I assumed that I could
> write as.factor(ch1, levels=ch1), since the order should be kept.
>
> But as.factor(ch1, levels=ch1) results in the error:
>
> Error in as.factor(ch1, levels = ch1) :
>  unused argument(s) (levels = c("low", "inter", "high"))
>
> factor(ch1, levels=ch1) works as I expected.
> Is it intended that as.factor does not use the levels argument?
>
> Thanks,
>
> Heinz
>
> ch1 <- c('low', 'inter', 'high')
> factor(ch1)
> factor(ch1, levels=ch1)
> as.factor(ch1, levels=ch1)
>
>> version
>               _
> platform       i386-pc-mingw32
> arch           i386
> os             mingw32
> system         i386, mingw32
> status         Patched
> major          2
> minor          8.1
> year           2009
> month          03
> day            13
> svn rev        48132
> language       R
> version.string R version 2.8.1 Patched (2009-03-13 r48132)
>> sessionInfo()
> R version 2.8.1 Patched (2009-03-13 r48132)
> i386-pc-mingw32
>
> locale:
> LC_COLLATE=German_Switzerland.1252;LC_CTYPE=German_Switzerland.1252;LC_MONETARY=German_Switzerland.1252;LC_NUMERIC=C;LC_TIME=German_Switzerland.1252
>
> attached base packages:
> [1] splines   stats     graphics  grDevices utils     datasets  methods
> [8] base
>
> other attached packages:
> [1] survival_2.34-1 car_1.2-12      gmodels_2.14.1  gdata_2.4.2
> [5] Hmisc_3.5-2
>
> loaded via a namespace (and not attached):
> [1] cluster_1.11.12 grid_2.8.1      gtools_2.5.0-1  lattice_0.17-20
> [5] MASS_7.2-46
>>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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 that 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.


Re: [R] change default output size when using Sweave

2009-04-08 Thread Mark Heckmann
Dear Duncan,

Thanks for the reply. This works, but unfortunately I need a different
solution.
My script is supposed to run completely automated and the graphics I produce
vary in size each time I run the script. But I want the graphics to be
fitted to my .pdf output without specifying the height argument manually
each time.
That is why I do not want a fixed height as a code chunk argument. Actually
I do not know if it is possible to have a variable placed in a code chunk
header. I tried the following which does not work:

<<>>=
size <- 3
@

<>=
   pushViewport(viewport(height = unit(80, "mm")))
   grid.rect()
   grid.text("I want this viewport to be the whole output size")
   popViewport()
@

So still I face the problem to have Sweave generate a .pdf graphic that is
just as big I want it to be.
 
In the Sweave Docu paragraph A.9 I discovered something I use as a
workaround. I produce the .pdf output manually (where I can control the
size) and add each graphic to LaTex manually as well.
 
<>=
for (i in 1){
file=paste("myfile", i, ".pdf", sep="")
pdf(file=file, paper="special", width=6, height=3)
   pushViewport(viewport(height = unit(5, "inches"))) 
   grid.rect()
   grid.text("I want this viewport to be the whole output size")
   popViewport()dev.off()
cat("\\includegraphics{", file, "}\n\n", sep="")
}
@

I use parenthesis around the code as it prints out something I do not want
if no parenthesis are used (I use Windows). 

I am not too happy with the solution. I would prefer a more straightforward
approach to define the size of the output graphic. I wonder if there are
some Sweave settings that can be modified. 

In the Sweave manual (A.11) I found the following to customize the par
settings for each figure:

options(SweaveHooks=list(fig=function() par(bg="red", fg="blue")))

I wonder if something similar could be done changing the size of the default
output device (pdf or eps) for each figure like >pdf.options(height=2) or
similar (it seems that this does not work)? 

I suppose this type of graphic customization is quite a common issue when
producing automated customized output/reports using R and Sweave but I
haven't found anything concerning this topic yet.

So I would be really glad if someone knows a solution.

TIA, Mark




-Ursprüngliche Nachricht-
Von: Duncan Murdoch [mailto:murd...@stats.uwo.ca] 
Gesendet: Dienstag, 7. April 2009 19:08
An: Mark Heckmann
Cc: r-help@r-project.org
Betreff: Re: [R] change default output size when using Sweave

On 4/7/2009 10:39 AM, Mark Heckmann wrote:
> I am trying to create a graphic output in Sweave but I do not want it to
be
> standard size. I want the whole graphic to be 80mm of height only, just
like
> the viewport below.
> 
> <>=
>pushViewport(viewport(height = unit(80, "mm")))
>grid.rect()
>grid.text("I want this viewport to be the whole output size")
>popViewport()
> @
> 
> How can I make the graphic smaller (80mm of height) without having the
white
> margins at the top and bottom?

You can specify height and width as arguments to the code chunk or set 
new defaults with something like

\SweaveOpts{width=5,height=3}

(I think those measurements need to be given in inches; I don't think 
there's a way to use an expression like unit(80,"mm").)

You can also control the size of the plot in the final document with 
LaTeX code like

\usepackage{graphicx}
\setkeys{Gin}{width=3in}

and then the LaTeX rules for handling units would apply, so 80mm is fine 
instead of 3in.

Duncan Murdoch

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


[R] does grid.rect() not accept NULL argument from gpar(col=NULL) ?

2009-04-08 Thread Mark Heckmann
I want to draw a grid rectangle without a border.

?gpar says:

"Specifying the value NULL for a parameter is the same as not specifying any
value for that parameter, except for col and fill, where NULL indicates not
to draw a border or not to fill an area (respectively)." 

pushViewport(viewport(height=unit(.8, "npc")))
grid.rect(gp=gpar(col=NULL, fill="green"))
popViewport()

Still a border is drawn. What am I doing wrong?

TIA, Mark

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


Re: [R] Null-Hypothesis

2009-04-08 Thread Eik Vettorazzi

Hi Benedikt
in principle this is correct. A p-value less than a prespecified 
alpha-level leads to rejection of the null hypothesis H0.
I'm a little bit puzzled about your given p-value, since actually your 
slopes are the same, so H0 is valid but rejected. This might be a matter 
of chance, but it is so to say against all odds (~2 out of 10 000 000) 
having such a special data set.


Alternatively - and using well established estimators - you can 
incorporate your factor in a joint model.

df1 <- data.frame(x=1:3, y=1:3+rnorm(3),g=0)
df2 <- data.frame(x=1:3, y=1:3+rnorm(3),g=1)
dta<-rbind(df1,df2)
dta$g<-factor(dta$g) # not really necessary for a two-group factor
ll<-lm(y~x*g,dta)
summary(ll)

This model has a varying slope and intercept term (which is the same as 
fitting two separate regression lines as you did), the test for 
different slopes is to test significance of x:g.
If you are in fact asking for a pure varying slope model you have to 
restrict your fit1 and fit2 to have the same intercept or you use the 
joint model with

ll<-lm(y~x+x:g,dta)

hth

Benedikt Niesterok schrieb:

Hello R users,
I've used the following help two compare two regression line slopes.
Wanted to test if they differ significantly:

Hi,

I've made a research about how to compare two regression line slopes  
(of y versus x for 2 groups, "group" being a factor ) using R.


I knew the method based on the following statement :
t = (b1 - b2) / sb1,b2
where b1 and b2 are the two slope coefficients and sb1,b2 the pooled  
standard error of the slope (b)


which can be calculated in R this way:
 > df1 <- data.frame(x=1:3, y=1:3+rnorm(3))
 > df2 <- data.frame(x=1:3, y=1:3+rnorm(3))
 > fit1 <- lm(y~x, df1)
 > s1 <- summary(fit1)$coefficients
 > fit2 <- lm(y~x, df2)
 > s2 <- summary(fit2)$coefficients
 > db <- (s2[2,1]-s1[2,1])
 > sd <- sqrt(s2[2,2]^2+s1[2,2]^2)
 > df <- (fit1$df.residual+fit2$df.residual)
 > td <- db/sd
 > 2*pt(-abs(td), df)

My value I get by running this test is :[1] 2.305553e-07
Does it mean the two slopes differ significantly, because this value is in
the alpha area, so that I have to reject the null- hypothesis and accept
the alternative hypothesis?
Is the  null-hypothesis: slope1=slope2?
Thanks for your help,  Benedikt
--

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


--
Eik Vettorazzi
Institut für Medizinische Biometrie und Epidemiologie
Universitätsklinikum Hamburg-Eppendorf

Martinistr. 52
20246 Hamburg

T ++49/40/42803-8243
F ++49/40/42803-7790

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

2009-04-08 Thread baptiste auguie

with base graphics,

par(bg=NA)

see ?par


Hope this helps,

baptiste

On 8 Apr 2009, at 12:54, Gundala Viswanath wrote:


Is there a way to do it in R?
Especially generating plot in EPS/PDF format.

By transparent I mean clear (not white) background.
I want to attached it to dark PPT slides.

- Gundala Viswanath

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


_

Baptiste Auguié

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Simulate binary data for a logistic regression Monte Carlo

2009-04-08 Thread Ben Bolker



Rolf Turner-3 wrote:
> 
> 
> On 8/04/2009, at 1:27 PM, Ben Bolker wrote:
> 
>   
> 
>> I agree that that the individual-level random effect is probably  
>> the issue.
>> I played with this some today but didn't manage to resolve it --
>> tried JAGS/R2jags and glmer from lme4 but didn't manage to
>> get an estimate of epsilon that matched the input value.  I'm
>> a little worried about binary data with an underlying random
>> effect, I think there's an identifiability problem there ...
> 
>   Oh dear.  This is getting hairier than I expected ... and a bit
>   over my head.  The toy model proposed *looks* simple enough at
>   first blush.  I would've thought that if a model which is that
>   simple doesn't ``work'', then what hope is there for the more
>   complicated models that one needs for analyzing real data?
> 
> 

  I don't think this is impossible, but it's a bit subtle, and might
be worth taking up on r-sig-mixed-models instead ...

  Ben

-- 
View this message in context: 
http://www.nabble.com/Simulate-binary-data-for-a-logistic-regression-Monte-Carlo-tp22928872p22949970.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Convert data frame containing time stamps to time series

2009-04-08 Thread Gabor Grothendieck
Try varying the arguments to this to accommodate
the precise format of your data.  See the three zoo
vignettes, ?read.zoo and R News 4/1 for dates
and times.

> Lines <- "t,f,p,d,o,s,a,l,c
+ 1/21/09 5:01,16151,8.2,76,30,282,1060,53,7
+ 1/21/09 5:02,16256,8.3,76,23,282,1059,54,7
+ 1/21/09 5:03,16150,8.4,76,26,282,1059,55,7
+ 1/21/09 5:04,16150,9.0,76,25,282,1051,57,6
+ 1/21/09 5:05,15543,10.4,76,7,282,1024,58,6"
> library(zoo)
> library(chron)
> z <- read.zoo(textConnection(Lines), sep = ",", header = TRUE,
+ FUN = as.chron, format = "%m/%d/%y %H:%M")
> z
fp  d  o   sa  l c
(01/21/09 05:01:00) 16151  8.2 76 30 282 1060 53 7
(01/21/09 05:02:00) 16256  8.3 76 23 282 1059 54 7
(01/21/09 05:03:00) 16150  8.4 76 26 282 1059 55 7
(01/21/09 05:04:00) 16150  9.0 76 25 282 1051 57 6
(01/21/09 05:05:00) 15543 10.4 76  7 282 1024 58 6

On Wed, Apr 8, 2009 at 4:43 AM,   wrote:
> I read records using scan:
>
> dat<-data.frame(scan(file="KDA.csv",what=list(t="%m/%d/%y
> %H:%M",f=0,p=0,d=0,o=0,s=0,a=0,l=0,c=0),skip=2,sep=",",nmax=np,flush=TRUE,na.strings=c("I/OTimeout","ArcOff-line")))
>
> which results in:
>
>> dat[1:5,]
>             t     f    p  d  o   s    a  l c
> 1 1/21/09 5:01 16151  8.2 76 30 282 1060 53 7
> 2 1/21/09 5:02 16256  8.3 76 23 282 1059 54 7
> 3 1/21/09 5:03 16150  8.4 76 26 282 1059 55 7
> 4 1/21/09 5:04 16150  9.0 76 25 282 1051 57 6
> 5 1/21/09 5:05 15543 10.4 76  7 282 1024 58 6
>
> I have been unable to find a way to convert this into a time series. I did
> read the manuals and came across a way to coerce a data frame to a ts
> object: as.ts()
>
> Trouble is I do not know how to keep the timestamps in column t in the
> data frame above. The t column is not strings. If I do:
>
> plot.ts(dat)
>
> I can see how the first graphics panel is indeed numbers not text. So I
> think scan converted the text correctly per the format string I put in.
>
> Much more difficult still. The datafiles I have contain invalid data,
> missing values and other none relevant information. I filter this out
> using subset which works brilliantly. However, how can I filter using
> subset and convert to a time series afterwards. Since after subsetting
> there will be 'holes' i.e. missing records. Can a ts object deal with
> missing records? If so, how? Just point me to a document. I can and will
> put in the work to figure it out myself.
>
> Thank you!
> Alex van der Spek
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Genstat into R - Randomisation test

2009-04-08 Thread Anne Kempel

Hello everybody,
I have a question. I would like to get a correlation between 
constitutive and induced plant defence which I messured on 30 plant 
species. So I have table with Species, Induced defence (ID), and 
constitutive defence (CD). Since Induced and constitutive defence are 
not independant (so called spurious correlation) I should do a 
randomisation test. I have a syntax of my supervisor in Genstat, but I 
would really like to try this in R.



"data from trade-off.IDCD"
list
variate [nval=1000] slope
calc ID1=ID

graph ID; CD
calc b=corr(ID; CD)
calc slope$[1]=b

"slope$[1] is the correlation before permutating the data"

for i=2...1000
randomize ID1
calc b=corr(CD1; ID1)
calc slope$[i]=b
endfor

hist slope
describe slope
quantile [proportion=!(0.0005,0.005, 0.025, 0.975, 0.995,0.9995)]slope
print slope$[1]
corr[p=corr] ID,CD


DHISTOGRAM [WINDOW=1; ORIENTATION=vertical; KEY=0; BARCOVERING=1.0] 
slope; PEN=2


Does anybody have done something similar and has any idea how to make 
the randomisation part?

I would be very grateful for any help!!
Thanks in advance,
Anne




--
Anne Kempel
Institute of Plant Sciences
University of Bern
Altenbergrain 21
CH-3103 Bern
kem...@ips.unibe.ch

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] read.spss, locale and encodings

2009-04-08 Thread Peter Dalgaard

Hans Ekbrand wrote:

I must be missing something obvious here:

According to the help page for read.spss, the reencode option is only
active when R is run under a UTF-8 locale.


Not in my version:

reencode: logical: should character strings be re-encoded to the
  current locale.  The default, 'NA', means to do so in a UTF-8
  locale, only.  Alternatively character, specifying an
  encoding to assume.




read.spss can only import the SPSS file when run under a iso88591(5)
locale, under a UTF-8 locale I get:

Error in read.spss("wo.sav") : error reading system-file header
In addition: Warning message:
In read.spss("wo.sav") :
  wo.sav: position 143: Variable name begins with invalid character


So, does it help with reencode="Latin1"? Presumably this comes from 
assuming UTF-8 when it isn't.



This is under Debian GNU/Linux, the stable release.

foreign is version 8.27


8.34 is used in the current prerelease. AFAIR, some issues with 
encodings were fixed recently.


--
   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
~~ - (p.dalga...@biostat.ku.dk)  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] Howto Plot With Transparent Background

2009-04-08 Thread Eik Vettorazzi
if you not persist in using pdf, the emf format works very well with PPT 
and has a transparent background.
Its the way you copy&paste pdf-graphs form Acrobat to PPT which causes 
the solid (white) background - unfortunately ppt has no builtt in 
support for pdf-graphs.


By default pdfs have a transparent background, see ?pdf and there the bg 
part,

which can be proven by a minimal R+ LaTeX example

#R code
pdf("test.pdf")
plot(1,1)
dev.off()

#minimal tex example
\documentclass[a4paper,12pt]{article}
\usepackage[svgnames]{xcolor}
\usepackage{graphicx}
\begin{document}
\pagecolor{green}
\includegraphics[width=.5\textwidth]{test.pdf}
\end{document}

hth.


Gundala Viswanath schrieb:

Is there a way to do it in R?
Especially generating plot in EPS/PDF format.

By transparent I mean clear (not white) background.
I want to attached it to dark PPT slides.

- Gundala Viswanath

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


--
Eik Vettorazzi
Institut für Medizinische Biometrie und Epidemiologie
Universitätsklinikum Hamburg-Eppendorf

Martinistr. 52
20246 Hamburg

T ++49/40/42803-8243
F ++49/40/42803-7790

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

2009-04-08 Thread jim holtman
It is just a simple version of 'factor'.  The only speed advantage it
might have is that it checks to see if it is a factor first.  Here is
the definition:

)> as.factor
function (x)
if (is.factor(x)) x else factor(x)


You can always list out what the function does to get a better
understanding of how it works.

On Wed, Apr 8, 2009 at 8:16 AM, Heinz Tuechler  wrote:
> Thank you, Jim. I see, the fact that in the documentation you find only
> "as.factor(x)" means that it does not accept more arguments.
> Does as.factor have speed advantages over factor, or is there a different
> cause for it's existence?
>
> Heinz
>
>
>
> At 13:50 08.04.2009, jim holtman wrote:
>>
>> as.factor does not accept levels as an argument.  use the first form
>> that you have
>>
>> factor(ch1, levels=ch1)
>>
>>
>>
>> On Wed, Apr 8, 2009 at 7:36 AM, Heinz Tuechler  wrote:
>> > Dear All,
>> >
>> > to my surprise as.factor does not accept a levels argument. Maybe I did
>> > not
>> > read the documentation well enough. See the example below. I wanted to
>> > use
>> > ch1 as factor in the newdata argument of survfit, so I assumed that I
>> > could
>> > write as.factor(ch1, levels=ch1), since the order should be kept.
>> >
>> > But as.factor(ch1, levels=ch1) results in the error:
>> >
>> > Error in as.factor(ch1, levels = ch1) :
>> >  unused argument(s) (levels = c("low", "inter", "high"))
>> >
>> > factor(ch1, levels=ch1) works as I expected.
>> > Is it intended that as.factor does not use the levels argument?
>> >
>> > Thanks,
>> >
>> > Heinz
>> >
>> > ch1 <- c('low', 'inter', 'high')
>> > factor(ch1)
>> > factor(ch1, levels=ch1)
>> > as.factor(ch1, levels=ch1)
>> >
>> >> version
>> >               _
>> > platform       i386-pc-mingw32
>> > arch           i386
>> > os             mingw32
>> > system         i386, mingw32
>> > status         Patched
>> > major          2
>> > minor          8.1
>> > year           2009
>> > month          03
>> > day            13
>> > svn rev        48132
>> > language       R
>> > version.string R version 2.8.1 Patched (2009-03-13 r48132)
>> >> sessionInfo()
>> > R version 2.8.1 Patched (2009-03-13 r48132)
>> > i386-pc-mingw32
>> >
>> > locale:
>> >
>> > LC_COLLATE=German_Switzerland.1252;LC_CTYPE=German_Switzerland.1252;LC_MONETARY=German_Switzerland.1252;LC_NUMERIC=C;LC_TIME=German_Switzerland.1252
>> >
>> > attached base packages:
>> > [1] splines   stats     graphics  grDevices utils     datasets  methods
>> > [8] base
>> >
>> > other attached packages:
>> > [1] survival_2.34-1 car_1.2-12      gmodels_2.14.1  gdata_2.4.2
>> > [5] Hmisc_3.5-2
>> >
>> > loaded via a namespace (and not attached):
>> > [1] cluster_1.11.12 grid_2.8.1      gtools_2.5.0-1  lattice_0.17-20
>> > [5] MASS_7.2-46
>> >>
>> >
>> > __
>> > R-help@r-project.org mailing list
>> > https://stat.ethz.ch/mailman/listinfo/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 that you are trying to solve?
>
>
>



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

What is the problem that 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.


Re: [R] read.spss, locale and encodings

2009-04-08 Thread Hans Ekbrand
On Wed, Apr 08, 2009 at 03:03:06PM +0200, Peter Dalgaard wrote:
> Hans Ekbrand wrote:
>> I must be missing something obvious here:
>>
>> According to the help page for read.spss, the reencode option is only
>> active when R is run under a UTF-8 locale.
>
> Not in my version:
>
> reencode: logical: should character strings be re-encoded to the
>   current locale.  The default, 'NA', means to do so in a UTF-8
>   locale, only.  Alternatively character, specifying an
>   encoding to assume.

OK, thanks for that correction, but the problem isn't solved, since
read.spss fails, see below. When read.spss succeeds, the options is
not useful, since then the current locale is iso88591(5).

> So, does it help with reencode="Latin1"? Presumably this comes from  
> assuming UTF-8 when it isn't.

> Sys.getlocale()
[1] 
"LC_CTYPE=sv_SE.UTF-8;LC_NUMERIC=C;LC_TIME=sv_SE.UTF-8;LC_COLLATE=sv_SE.UTF-8;LC_MONETARY=sv_SE.UTF-8;LC_MESSAGES=sv_SE.utf8;LC_PAPER=sv_SE.utf8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=sv_SE.utf8;LC_IDENTIFICATION=C"
> test <- read.spss("wo.sav", to.data.frame=TRUE, reencode="Latin1")
Error in read.spss("wo.sav", to.data.frame = TRUE, reencode = "Latin1") : 
  error reading system-file header
In addition: Warning message:
In read.spss("wo.sav", to.data.frame = TRUE, reencode = "Latin1") :
  wo.sav: position 143: Variable name begins with invalid character

Using another version of the dataset, where I have successfully
encoded the names to UTF-8, here is the problematic variable name:

names(Workorientation.2005.Swe)[143]
[1] "KÖN1"

> 8.34 is used in the current prerelease. AFAIR, some issues with
> encodings were fixed recently.

Someone running foreign 8.34 that is willing to test my SPSS-file?

-- 
Hans Ekbrand (http://sociologi.cjb.net) 
Q. What is that strange attachment in this mail?
A. My digital signature, see www.gnupg.org for info on how you could
 use it to ensure that this mail is from me and has not been
 altered on the way to you.


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


Re: [R] factor, as.factor and levels

2009-04-08 Thread Heinz Tuechler
Jim - you are right, I should have looked before. So there is a 
difference that should also effect the dropping of unused levels.


Thanks,

Heinz

At 15:31 08.04.2009, jim holtman wrote:

It is just a simple version of 'factor'.  The only speed advantage it
might have is that it checks to see if it is a factor first.  Here is
the definition:

)> as.factor
function (x)
if (is.factor(x)) x else factor(x)


You can always list out what the function does to get a better
understanding of how it works.

On Wed, Apr 8, 2009 at 8:16 AM, Heinz Tuechler  wrote:
> Thank you, Jim. I see, the fact that in the documentation you find only
> "as.factor(x)" means that it does not accept more arguments.
> Does as.factor have speed advantages over factor, or is there a different
> cause for it's existence?
>
> Heinz
>
>
>
> At 13:50 08.04.2009, jim holtman wrote:
>>
>> as.factor does not accept levels as an argument.  use the first form
>> that you have
>>
>> factor(ch1, levels=ch1)
>>
>>
>>
>> On Wed, Apr 8, 2009 at 7:36 AM, Heinz Tuechler  wrote:
>> > Dear All,
>> >
>> > to my surprise as.factor does not accept a levels argument. Maybe I did
>> > not
>> > read the documentation well enough. See the example below. I wanted to
>> > use
>> > ch1 as factor in the newdata argument of survfit, so I assumed that I
>> > could
>> > write as.factor(ch1, levels=ch1), since the order should be kept.
>> >
>> > But as.factor(ch1, levels=ch1) results in the error:
>> >
>> > Error in as.factor(ch1, levels = ch1) :
>> >  unused argument(s) (levels = c("low", "inter", "high"))
>> >
>> > factor(ch1, levels=ch1) works as I expected.
>> > Is it intended that as.factor does not use the levels argument?
>> >
>> > Thanks,
>> >
>> > Heinz
>> >
>> > ch1 <- c('low', 'inter', 'high')
>> > factor(ch1)
>> > factor(ch1, levels=ch1)
>> > as.factor(ch1, levels=ch1)
>> >
>> >> version
>> >   _
>> > platform   i386-pc-mingw32
>> > arch   i386
>> > os mingw32
>> > system i386, mingw32
>> > status Patched
>> > major  2
>> > minor  8.1
>> > year   2009
>> > month  03
>> > day13
>> > svn rev48132
>> > language   R
>> > version.string R version 2.8.1 Patched (2009-03-13 r48132)
>> >> sessionInfo()
>> > R version 2.8.1 Patched (2009-03-13 r48132)
>> > i386-pc-mingw32
>> >
>> > locale:
>> >
>> > 
LC_COLLATE=German_Switzerland.1252;LC_CTYPE=German_Switzerland.1252;LC_MONETARY=German_Switzerland.1252;LC_NUMERIC=C;LC_TIME=German_Switzerland.1252

>> >
>> > attached base packages:
>> > [1] splines   stats graphics  grDevices utils datasets  methods
>> > [8] base
>> >
>> > other attached packages:
>> > [1] survival_2.34-1 car_1.2-12  gmodels_2.14.1  gdata_2.4.2
>> > [5] Hmisc_3.5-2
>> >
>> > loaded via a namespace (and not attached):
>> > [1] cluster_1.11.12 grid_2.8.1  gtools_2.5.0-1  lattice_0.17-20
>> > [5] MASS_7.2-46
>> >>
>> >
>> > __
>> > R-help@r-project.org mailing list
>> > https://stat.ethz.ch/mailman/listinfo/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 that you are trying to solve?
>
>
>



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

What is the problem that 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] sourced plot commands not working

2009-04-08 Thread SHANE MILLER, BLOOMBERG/ 731 LEXIN
I have source a script running with no errors that ends in these lines:
==
for (i in 2:3) win.graph()
dev.set(2)
levelplot(avg ~ procs * size, rrt, drape=T, 
colorkey=T,main="ops/sec",scales=list(x=list(tick.number=15),y=list(log=10)))
dev.set(3)
levelplot(avg ~ procs * size, ort, drape=T, 
colorkey=T,main="ops/sec",scales=list(x=list(tick.number=15),y=list(log=10)))
=
The graphics devices windows appear, however, there is no graph
and the background of each window is gray indicating no active
graph.

However, if I copy and paste these commands from the script and
enter them into the console, they run fine. why?

R 2.8.1 2008-12-22 on windows.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Pulling data into a model

2009-04-08 Thread Luc Villandre

Hi Jacy,

I'll take my chances answering your question.

I'd suggest using the paste() function and then transforming the string 
into a formula object:



my.formula = 
as.formula(paste("y~x1+x2+",paste(colnames(REG)[2:num],collapse="+"), 
sep= "")) ;


aov(my.formula,data=REG) ;


The first line creates a string that then becomes your formula statement.

Is this what you're looking for?

Cheers,

Luc

Crosby, Jacy R wrote:

I'm creating an ANOVA model. Is there a way to pull in consecutive columns of 
variables for the test?

Example:  aov1<-aov(y~x1+x2+REG[,2:num], data=REG)

I'm not looking for interaction effects, I just want to create a model for the 
first few columns of variables (exact number and names will vary) and a few 
other predetermined variables (in the example I named them x1 and x2).

Thanks in advance.
- Jacy


[[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] R File I/O Capability - Writing output to specific lines of existing file

2009-04-08 Thread Jason Rupert

Currently I am using the R "write" command to output results to a *.txt file 
and then copying those results into an initialization file.  In an attempt to 
continue to automate the process I would like to have R write to the location 
in the existing initialization file, instead of me copying the data over.  

By any chance are there any R commands to help? 

Primarily, I will be using Windows, and the initialization file is a simple 
flat file, i.e. not XML or binary. 

I looked at:
(a) http://www.stat.ucl.ac.be/ISdidactique/Rhelp/library/R.io/html/00Index.html

(b) 
http://search.r-project.org/cgi-bin/namazu.cgi?query=File+I%2FO&max=100&result=normal&sort=score&idxname=functions&idxname=Rhelp08

But, this did not appear to provide the functionality to edit an existing file 
by adding information to the middle of the file. 

Thank you again for any help and insight.

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

2009-04-08 Thread Gavin Simpson
On Wed, 2009-04-08 at 10:05 -0400, SHANE MILLER, BLOOMBERG/ 731 LEXIN
wrote:
> I have source a script running with no errors that ends in these lines:
> ==
> for (i in 2:3) win.graph()
> dev.set(2)
> levelplot(avg ~ procs * size, rrt, drape=T, 
> colorkey=T,main="ops/sec",scales=list(x=list(tick.number=15),y=list(log=10)))
> dev.set(3)
> levelplot(avg ~ procs * size, ort, drape=T, 
> colorkey=T,main="ops/sec",scales=list(x=list(tick.number=15),y=list(log=10)))
> =
> The graphics devices windows appear, however, there is no graph
> and the background of each window is gray indicating no active
> graph.
> 
> However, if I copy and paste these commands from the script and
> enter them into the console, they run fine. why?

The plotting commands are lattice functions. These need to be printed to
produce the plotting side effect you want. When entered at the command
line printing is explicit. This doesn't happen when sourced.

This is a FAQ 7.22:


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


[R] default print format for large numbers

2009-04-08 Thread SHANE MILLER, BLOOMBERG/ 731 LEXIN
Numbers like ``1239178547.653775" is inserted into a vector. I print the vector:

> route_9_80_end
 [1] 1239178522 1239178526 1239178524 1239178524 1239178524 1239178523 
1239178524 1239178522 1239178521 1239178565 1239178566 1239178566
[13] 1239178565 1239178566 1239178566 1239178565 1239178566 1239178566

and the decimals are suppressed. While R is wonderful and wonderfully 
documented, I can only find some quasi relavent information on options(digits) 
or some such as might apply here. How can I force R to print some part of the 
decimal i.e. back to 1239178547.653775?

TIA, Shane
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] read.spss, locale and encodings

2009-04-08 Thread Peter Dalgaard

Hans Ekbrand wrote:

On Wed, Apr 08, 2009 at 03:03:06PM +0200, Peter Dalgaard wrote:

Hans Ekbrand wrote:

I must be missing something obvious here:

According to the help page for read.spss, the reencode option is only
active when R is run under a UTF-8 locale.

Not in my version:

reencode: logical: should character strings be re-encoded to the
  current locale.  The default, 'NA', means to do so in a UTF-8
  locale, only.  Alternatively character, specifying an
  encoding to assume.


OK, thanks for that correction, but the problem isn't solved, since
read.spss fails, see below. When read.spss succeeds, the options is
not useful, since then the current locale is iso88591(5).

So, does it help with reencode="Latin1"? Presumably this comes from  
assuming UTF-8 when it isn't.



Sys.getlocale()

[1] 
"LC_CTYPE=sv_SE.UTF-8;LC_NUMERIC=C;LC_TIME=sv_SE.UTF-8;LC_COLLATE=sv_SE.UTF-8;LC_MONETARY=sv_SE.UTF-8;LC_MESSAGES=sv_SE.utf8;LC_PAPER=sv_SE.utf8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=sv_SE.utf8;LC_IDENTIFICATION=C"

test <- read.spss("wo.sav", to.data.frame=TRUE, reencode="Latin1")
Error in read.spss("wo.sav", to.data.frame = TRUE, reencode = "Latin1") : 
  error reading system-file header

In addition: Warning message:
In read.spss("wo.sav", to.data.frame = TRUE, reencode = "Latin1") :
  wo.sav: position 143: Variable name begins with invalid character

Using another version of the dataset, where I have successfully
encoded the names to UTF-8, here is the problematic variable name:

names(Workorientation.2005.Swe)[143]
[1] "KÖN1"


8.34 is used in the current prerelease. AFAIR, some issues with
encodings were fixed recently.


Someone running foreign 8.34 that is willing to test my SPSS-file?


Someone with an SPSS file problem willing to help test the prereleases? :-)

You could start by placing it somewhere accessible...

--
   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
~~ - (p.dalga...@biostat.ku.dk)  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] sourced plot commands not working

2009-04-08 Thread Gavin Simpson
[Ooops, brain/fingers not well connected today, sent prematurely]

On Wed, 2009-04-08 at 10:05 -0400, SHANE MILLER, BLOOMBERG/ 731 LEXIN
wrote:
> I have source a script running with no errors that ends in these lines:
> ==
> for (i in 2:3) win.graph()
> dev.set(2)
> levelplot(avg ~ procs * size, rrt, drape=T, 
> colorkey=T,main="ops/sec",scales=list(x=list(tick.number=15),y=list(log=10)))
> dev.set(3)
> levelplot(avg ~ procs * size, ort, drape=T, 
> colorkey=T,main="ops/sec",scales=list(x=list(tick.number=15),y=list(log=10)))
> =
> The graphics devices windows appear, however, there is no graph
> and the background of each window is gray indicating no active
> graph.
> 
> However, if I copy and paste these commands from the script and
> enter them into the console, they run fine. why?

The plotting commands used here are lattice functions. These need to be printed 
to
produce the plotting side effect you want. When entered at the command
line printing is explicit. This doesn't happen when sourced.

This is a FAQ 7.22:

http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-do-lattice_002ftrellis-graphics-not-work_003f

?source does explain all of this.

Solution; wrap your levelplot(...) in print():

print(levelplot(...))

HTH

G

> 
> R 2.8.1 2008-12-22 on windows.
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] binary version of R 2.8.x

2009-04-08 Thread stephen sefick
./configure works with no errors ?
I have compiled on mac os x and debian so my advice may be
circumspect, but the errors I don't know what they are.

On Tue, Apr 7, 2009 at 10:17 PM,   wrote:
>
>
> Hello,
>
> Is there any binary version of R 2.8.x available for x86 Solaris 10?  I need 
> it so that I can use some R library files.  I actually tried to compile the 
> source myself, but it failed.  I don't know much about how to compile source 
> files on Solaris, and it will be great if there is a binary version of R 
> 2.8.x available.  Thanks.
>
> /***error after running make***/
> util.c: In function `Rf_mbrtowc':
> util.c:1147: parse error before `char'
> util.c:1150: `p' undeclared (first use in this function)
> util.c:1150: (Each undeclared identifier is reported only once
> util.c:1150: for each function it appears in.)
> util.c:1150: `q' undeclared (first use in this function)
> util.c:1150: `err' undeclared (first use in this function)
> make[3]: *** [util.o] Error 1
> make[3]: Leaving directory `/var/tmp/R-2.8.1/src/main'
> make[2]: *** [R] Error 2
> make[2]: Leaving directory `/var/tmp/R-2.8.1/src/main'
> make[1]: *** [R] Error 1
> make[1]: Leaving directory `/var/tmp/R-2.8.1/src'
> make: *** [R] Error 1
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Stephen Sefick

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

-K. Mullis

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


Re: [R] Re ading Excel 5.0 files with RODBC?

2009-04-08 Thread Yuri Volchik

Seems like the place where i get those files from has an error somewhere when
they create the file which doesn't allow ODBC to see sheet with data, i.e
sqlTables returns:
[1] TABLE_CAT   TABLE_SCHEM TABLE_NAME  TABLE_TYPE  REMARKS
<0 rows> (or 0-length row.names)

When i open this file in excel 2003 and try to save it, i get a message that
this file is of Excel 5.0 format (but the original file has more than 16k
rows which is impossible with excel 5.0 format) and information wil be lost.
When i save it on my pc either in excel 5.0 or excel 97 format i can open it
with RODBC with no problems so the problem has to be with the way original
xls files are created.
Thanks a lot for all replies.



Prof Brian Ripley wrote:
> 
> On Wed, 8 Apr 2009, Yuri Volchik wrote:
> 
>>
>> Thanks for reply David,
>>
>> but the problem is that the place i get those files from saves them in
>> the
>> old Excel format (Excel 5.0), not Excel 97-2003, so neither of the
>> packages
>> (RODBC, xlsReadWrite) can read it.
> 
> RODBC supports any format for which an ODBC driver is installed and 
> Microsoft have long supplied ones for Excel 3.0 and later (up to Excel 
> 2007 at present).
> 
> -- 
> Brian D. Ripley,  rip...@stats.ox.ac.uk
> Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
> University of Oxford, Tel:  +44 1865 272861 (self)
> 1 South Parks Road, +44 1865 272866 (PA)
> Oxford OX1 3TG, UKFax:  +44 1865 272595
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Reading-Excel-5.0-files-with-RODBC--tp22929781p22951583.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Genstat into R - Randomisation test

2009-04-08 Thread Mike Lawrence
Looks like that code implements a non-exhaustive variant of the
randomization test, sometimes called a permutation test. Assuming you
have a data frame with columns ID & CD, this should do it:

n.obs = 100
ID=rnorm(n.obs)
CD=rnorm(n.obs)

obs.cor = cor(ID,CD)

num.permutations = 1e4
perm.cor = rep(NA,num.permutations)
start.time=proc.time()[1]
index = 1:n.obs
for(i in 1:num.permutations){
IDorder = sample(index)
CDorder = sample(index)
perm.cor[i] = .Internal(cor(ID[IDorder], CD[CDorder], 4, FALSE))
}
cat('Elapsed time:',start.time-proc.time(1))
sum(perm.cor>obs.cor)/num.permutations


On Wed, Apr 8, 2009 at 10:02 AM, Anne Kempel  wrote:
> Hello everybody,
> I have a question. I would like to get a correlation between constitutive
> and induced plant defence which I messured on 30 plant species. So I have
> table with Species, Induced defence (ID), and constitutive defence (CD).
> Since Induced and constitutive defence are not independant (so called
> spurious correlation) I should do a randomisation test. I have a syntax of
> my supervisor in Genstat, but I would really like to try this in R.
>
>
> "data from trade-off.IDCD"
> list
> variate [nval=1000] slope
> calc ID1=ID
>
> graph ID; CD
> calc b=corr(ID; CD)
> calc slope$[1]=b
>
> "slope$[1] is the correlation before permutating the data"
>
> for i=2...1000
>    randomize ID1
>    calc b=corr(CD1; ID1)
>    calc slope$[i]=b
> endfor
>
> hist slope
> describe slope
> quantile [proportion=!(0.0005,0.005, 0.025, 0.975, 0.995,0.9995)]slope
> print slope$[1]
> corr[p=corr] ID,CD
>
>
> DHISTOGRAM [WINDOW=1; ORIENTATION=vertical; KEY=0; BARCOVERING=1.0] slope;
> PEN=2
>
> Does anybody have done something similar and has any idea how to make the
> randomisation part?
> I would be very grateful for any help!!
> Thanks in advance,
> Anne
>
>
>
>
> --
> Anne Kempel
> Institute of Plant Sciences
> University of Bern
> Altenbergrain 21
> CH-3103 Bern
> kem...@ips.unibe.ch
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Mike Lawrence
Graduate Student
Department of Psychology
Dalhousie University

Looking to arrange a meeting? Check my public calendar:
http://tinyurl.com/mikes-public-calendar

~ Certainty is folly... I think. ~

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

2009-04-08 Thread Mike Lawrence
"Assuming you have a data frame with columns ID & CD, this should do it"

Oops, the code I sent doesn't assume this. It assumes that you have
two vectors, ID & CD, as generated in the first 3 lines.

On Wed, Apr 8, 2009 at 11:31 AM, Mike Lawrence  wrote:
> Looks like that code implements a non-exhaustive variant of the
> randomization test, sometimes called a permutation test. Assuming you
> have a data frame with columns ID & CD, this should do it:
>
> n.obs = 100
> ID=rnorm(n.obs)
> CD=rnorm(n.obs)
>
> obs.cor = cor(ID,CD)
>
> num.permutations = 1e4
> perm.cor = rep(NA,num.permutations)
> start.time=proc.time()[1]
> index = 1:n.obs
> for(i in 1:num.permutations){
>        IDorder = sample(index)
>        CDorder = sample(index)
>        perm.cor[i] = .Internal(cor(ID[IDorder], CD[CDorder], 4, FALSE))
> }
> cat('Elapsed time:',start.time-proc.time(1))
> sum(perm.cor>obs.cor)/num.permutations
>
>
> On Wed, Apr 8, 2009 at 10:02 AM, Anne Kempel  wrote:
>> Hello everybody,
>> I have a question. I would like to get a correlation between constitutive
>> and induced plant defence which I messured on 30 plant species. So I have
>> table with Species, Induced defence (ID), and constitutive defence (CD).
>> Since Induced and constitutive defence are not independant (so called
>> spurious correlation) I should do a randomisation test. I have a syntax of
>> my supervisor in Genstat, but I would really like to try this in R.
>>
>>
>> "data from trade-off.IDCD"
>> list
>> variate [nval=1000] slope
>> calc ID1=ID
>>
>> graph ID; CD
>> calc b=corr(ID; CD)
>> calc slope$[1]=b
>>
>> "slope$[1] is the correlation before permutating the data"
>>
>> for i=2...1000
>>    randomize ID1
>>    calc b=corr(CD1; ID1)
>>    calc slope$[i]=b
>> endfor
>>
>> hist slope
>> describe slope
>> quantile [proportion=!(0.0005,0.005, 0.025, 0.975, 0.995,0.9995)]slope
>> print slope$[1]
>> corr[p=corr] ID,CD
>>
>>
>> DHISTOGRAM [WINDOW=1; ORIENTATION=vertical; KEY=0; BARCOVERING=1.0] slope;
>> PEN=2
>>
>> Does anybody have done something similar and has any idea how to make the
>> randomisation part?
>> I would be very grateful for any help!!
>> Thanks in advance,
>> Anne
>>
>>
>>
>>
>> --
>> Anne Kempel
>> Institute of Plant Sciences
>> University of Bern
>> Altenbergrain 21
>> CH-3103 Bern
>> kem...@ips.unibe.ch
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>
>
> --
> Mike Lawrence
> Graduate Student
> Department of Psychology
> Dalhousie University
>
> Looking to arrange a meeting? Check my public calendar:
> http://tinyurl.com/mikes-public-calendar
>
> ~ Certainty is folly... I think. ~
>



-- 
Mike Lawrence
Graduate Student
Department of Psychology
Dalhousie University

Looking to arrange a meeting? Check my public calendar:
http://tinyurl.com/mikes-public-calendar

~ Certainty is folly... I think. ~

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

2009-04-08 Thread Mike Lawrence
*Hits head*
Of course, the approach taken by your Genstat code of only shuffling
one variable is sufficient and faster:

n.obs = 100
ID=rnorm(n.obs)
CD=rnorm(n.obs)

obs.cor = cor(ID,CD)

num.permutations = 1e4
perm.cor = rep(NA,num.permutations)
start.time=proc.time()[1]
index = 1:n.obs
for(i in 1:num.permutations){
IDorder = sample(index)
perm.cor[i] = .Internal(cor(ID[IDorder], CD, 4, FALSE))
}
cat('Elapsed time:',start.time-proc.time(1))
sum(perm.cor>obs.cor)/num.permutations


On Wed, Apr 8, 2009 at 11:33 AM, Mike Lawrence  wrote:
> "Assuming you have a data frame with columns ID & CD, this should do it"
>
> Oops, the code I sent doesn't assume this. It assumes that you have
> two vectors, ID & CD, as generated in the first 3 lines.
>
> On Wed, Apr 8, 2009 at 11:31 AM, Mike Lawrence  wrote:
>> Looks like that code implements a non-exhaustive variant of the
>> randomization test, sometimes called a permutation test. Assuming you
>> have a data frame with columns ID & CD, this should do it:
>>
>> n.obs = 100
>> ID=rnorm(n.obs)
>> CD=rnorm(n.obs)
>>
>> obs.cor = cor(ID,CD)
>>
>> num.permutations = 1e4
>> perm.cor = rep(NA,num.permutations)
>> start.time=proc.time()[1]
>> index = 1:n.obs
>> for(i in 1:num.permutations){
>>        IDorder = sample(index)
>>        CDorder = sample(index)
>>        perm.cor[i] = .Internal(cor(ID[IDorder], CD[CDorder], 4, FALSE))
>> }
>> cat('Elapsed time:',start.time-proc.time(1))
>> sum(perm.cor>obs.cor)/num.permutations
>>
>>
>> On Wed, Apr 8, 2009 at 10:02 AM, Anne Kempel  wrote:
>>> Hello everybody,
>>> I have a question. I would like to get a correlation between constitutive
>>> and induced plant defence which I messured on 30 plant species. So I have
>>> table with Species, Induced defence (ID), and constitutive defence (CD).
>>> Since Induced and constitutive defence are not independant (so called
>>> spurious correlation) I should do a randomisation test. I have a syntax of
>>> my supervisor in Genstat, but I would really like to try this in R.
>>>
>>>
>>> "data from trade-off.IDCD"
>>> list
>>> variate [nval=1000] slope
>>> calc ID1=ID
>>>
>>> graph ID; CD
>>> calc b=corr(ID; CD)
>>> calc slope$[1]=b
>>>
>>> "slope$[1] is the correlation before permutating the data"
>>>
>>> for i=2...1000
>>>    randomize ID1
>>>    calc b=corr(CD1; ID1)
>>>    calc slope$[i]=b
>>> endfor
>>>
>>> hist slope
>>> describe slope
>>> quantile [proportion=!(0.0005,0.005, 0.025, 0.975, 0.995,0.9995)]slope
>>> print slope$[1]
>>> corr[p=corr] ID,CD
>>>
>>>
>>> DHISTOGRAM [WINDOW=1; ORIENTATION=vertical; KEY=0; BARCOVERING=1.0] slope;
>>> PEN=2
>>>
>>> Does anybody have done something similar and has any idea how to make the
>>> randomisation part?
>>> I would be very grateful for any help!!
>>> Thanks in advance,
>>> Anne
>>>
>>>
>>>
>>>
>>> --
>>> Anne Kempel
>>> Institute of Plant Sciences
>>> University of Bern
>>> Altenbergrain 21
>>> CH-3103 Bern
>>> kem...@ips.unibe.ch
>>>
>>> __
>>> R-help@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>
>>
>>
>> --
>> Mike Lawrence
>> Graduate Student
>> Department of Psychology
>> Dalhousie University
>>
>> Looking to arrange a meeting? Check my public calendar:
>> http://tinyurl.com/mikes-public-calendar
>>
>> ~ Certainty is folly... I think. ~
>>
>
>
>
> --
> Mike Lawrence
> Graduate Student
> Department of Psychology
> Dalhousie University
>
> Looking to arrange a meeting? Check my public calendar:
> http://tinyurl.com/mikes-public-calendar
>
> ~ Certainty is folly... I think. ~
>



-- 
Mike Lawrence
Graduate Student
Department of Psychology
Dalhousie University

Looking to arrange a meeting? Check my public calendar:
http://tinyurl.com/mikes-public-calendar

~ Certainty is folly... I think. ~

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

2009-04-08 Thread Richard . Cotton
> Numbers like ``1239178547.653775" is inserted into a vector. I print
> the vector:
> 
> > route_9_80_end
>  [1] 1239178522 1239178526 1239178524 1239178524 1239178524 
> 1239178523 1239178524 1239178522 1239178521 1239178565 1239178566 
1239178566
> [13] 1239178565 1239178566 1239178566 1239178565 1239178566 1239178566
> 
> and the decimals are suppressed. While R is wonderful and 
> wonderfully documented, I can only find some quasi relavent 
> information on options(digits) or some such as might apply here. How
> can I force R to print some part of the decimal i.e. back to 
> 1239178547.653775?

When you create the vector, each number is stored as a double-precision 
floating point number.  When you type the name of the variable the print 
function is called, which displays the numbers on the console.

You can also manually call the print function, and set the digits argument 
to a high number to show all digits.

If you want to see all the digits every time any number is displayed, use 
options(digits).

For example:
x <- 1239178547.653775
x
# [1] 1239178548
print(x)
# [1] 1239178548
print(x, digits=20)
# [1] 1239178547.653775
options(digits=20)
x
# [1] 1239178547.653775

Note that the accuracy of the floating point numbers is limited to 
.Machine$double.eps, which is typically 2.2e-16.

Regards,
Richie.

Mathematical Sciences Unit
HSL




ATTENTION:

This message contains privileged and confidential inform...{{dropped:20}}

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

2009-04-08 Thread Mike Lawrence
*sigh*

and the elapsed time line should be:

cat('Elapsed time:',proc.time()[1]-start.time)


On Wed, Apr 8, 2009 at 11:35 AM, Mike Lawrence  wrote:
> *Hits head*
> Of course, the approach taken by your Genstat code of only shuffling
> one variable is sufficient and faster:
>
> n.obs = 100
> ID=rnorm(n.obs)
> CD=rnorm(n.obs)
>
> obs.cor = cor(ID,CD)
>
> num.permutations = 1e4
> perm.cor = rep(NA,num.permutations)
> start.time=proc.time()[1]
> index = 1:n.obs
> for(i in 1:num.permutations){
>        IDorder = sample(index)
>        perm.cor[i] = .Internal(cor(ID[IDorder], CD, 4, FALSE))
> }
> cat('Elapsed time:',start.time-proc.time(1))
> sum(perm.cor>obs.cor)/num.permutations
>
>
> On Wed, Apr 8, 2009 at 11:33 AM, Mike Lawrence  wrote:
>> "Assuming you have a data frame with columns ID & CD, this should do it"
>>
>> Oops, the code I sent doesn't assume this. It assumes that you have
>> two vectors, ID & CD, as generated in the first 3 lines.
>>
>> On Wed, Apr 8, 2009 at 11:31 AM, Mike Lawrence  wrote:
>>> Looks like that code implements a non-exhaustive variant of the
>>> randomization test, sometimes called a permutation test. Assuming you
>>> have a data frame with columns ID & CD, this should do it:
>>>
>>> n.obs = 100
>>> ID=rnorm(n.obs)
>>> CD=rnorm(n.obs)
>>>
>>> obs.cor = cor(ID,CD)
>>>
>>> num.permutations = 1e4
>>> perm.cor = rep(NA,num.permutations)
>>> start.time=proc.time()[1]
>>> index = 1:n.obs
>>> for(i in 1:num.permutations){
>>>        IDorder = sample(index)
>>>        CDorder = sample(index)
>>>        perm.cor[i] = .Internal(cor(ID[IDorder], CD[CDorder], 4, FALSE))
>>> }
>>> cat('Elapsed time:',start.time-proc.time(1))
>>> sum(perm.cor>obs.cor)/num.permutations
>>>
>>>
>>> On Wed, Apr 8, 2009 at 10:02 AM, Anne Kempel  wrote:
 Hello everybody,
 I have a question. I would like to get a correlation between constitutive
 and induced plant defence which I messured on 30 plant species. So I have
 table with Species, Induced defence (ID), and constitutive defence (CD).
 Since Induced and constitutive defence are not independant (so called
 spurious correlation) I should do a randomisation test. I have a syntax of
 my supervisor in Genstat, but I would really like to try this in R.


 "data from trade-off.IDCD"
 list
 variate [nval=1000] slope
 calc ID1=ID

 graph ID; CD
 calc b=corr(ID; CD)
 calc slope$[1]=b

 "slope$[1] is the correlation before permutating the data"

 for i=2...1000
    randomize ID1
    calc b=corr(CD1; ID1)
    calc slope$[i]=b
 endfor

 hist slope
 describe slope
 quantile [proportion=!(0.0005,0.005, 0.025, 0.975, 0.995,0.9995)]slope
 print slope$[1]
 corr[p=corr] ID,CD


 DHISTOGRAM [WINDOW=1; ORIENTATION=vertical; KEY=0; BARCOVERING=1.0] slope;
 PEN=2

 Does anybody have done something similar and has any idea how to make the
 randomisation part?
 I would be very grateful for any help!!
 Thanks in advance,
 Anne




 --
 Anne Kempel
 Institute of Plant Sciences
 University of Bern
 Altenbergrain 21
 CH-3103 Bern
 kem...@ips.unibe.ch

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

>>>
>>>
>>>
>>> --
>>> Mike Lawrence
>>> Graduate Student
>>> Department of Psychology
>>> Dalhousie University
>>>
>>> Looking to arrange a meeting? Check my public calendar:
>>> http://tinyurl.com/mikes-public-calendar
>>>
>>> ~ Certainty is folly... I think. ~
>>>
>>
>>
>>
>> --
>> Mike Lawrence
>> Graduate Student
>> Department of Psychology
>> Dalhousie University
>>
>> Looking to arrange a meeting? Check my public calendar:
>> http://tinyurl.com/mikes-public-calendar
>>
>> ~ Certainty is folly... I think. ~
>>
>
>
>
> --
> Mike Lawrence
> Graduate Student
> Department of Psychology
> Dalhousie University
>
> Looking to arrange a meeting? Check my public calendar:
> http://tinyurl.com/mikes-public-calendar
>
> ~ Certainty is folly... I think. ~
>



-- 
Mike Lawrence
Graduate Student
Department of Psychology
Dalhousie University

Looking to arrange a meeting? Check my public calendar:
http://tinyurl.com/mikes-public-calendar

~ Certainty is folly... I think. ~

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] persp3d and rgl.viewpoint for rotating 3D plots

2009-04-08 Thread Camarda, Carlo Giovanni
Dear R-users,

within the rgl-package, I would have a question about the usage of persp3d 
in combination of rgl.viewpoint. 
I am not able to figure out how to let a 3D plot rotating around likewise the 
example in ?rgl.viewpoint. It seems that when I use persp3d(...) I see 
something on my screen, which is different from what I get when it's rotating. 
Is there any different behavior between shade3d and persp3d?
Please find below a simple example.

Actually, my final aim is to save each of the rotating graphs for creating a 
"clip". I commented below what I would use later on, but is there any way to do 
it better?

Thanks a lot for your help,
Carlo Giovanni Camarda


library(rgl)
# simplified version from help(rgl.viewpoint)
shade3d(oh3d())
coo <- 1:360
for(i in 1:length(coo)) {
rgl.viewpoint(coo[i])
#filename <- paste("pic", formatC(i,digits=1,flag="00"), ".png", sep="")
#rgl.snapshot(filename)
}

# simple persp3d adaption
f <- function(x,y) { r <- sqrt(x^2+y^2); 10 * sin(r)/r }
x <- seq(-10, 10, length= 30); y <- x
z <- outer(x, y, f)
persp3d(x, y, z)
coo <- 1:360
for(i in 1:length(coo)) {
rgl.viewpoint(coo[i])
#filename <- paste("pic", formatC(i,digits=1,flag="00"), ".png", sep="")
#rgl.snapshot(filename)
}



-
Dr. Carlo Giovanni Camarda
Research Scientist
Max Planck Institute for Demographic Research
Laboratory of Statistical Demography
Konrad-Zuse-Straße 1
18057 Rostock - Germany
Phone: +49 (0)381 2081 172
Fax: +49 (0)381 2081 472
cama...@demogr.mpg.de
http://www.demogr.mpg.de/en/staff/camarda/default.htm
-


--
This mail has been sent through the MPI for Demographic ...{{dropped:10}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] read.spss, locale and encodings

2009-04-08 Thread Hans Ekbrand
On Wed, Apr 08, 2009 at 04:17:51PM +0200, Peter Dalgaard wrote:
> Hans Ekbrand wrote:
>> Someone running foreign 8.34 that is willing to test my SPSS-file?
>
> Someone with an SPSS file problem willing to help test the prereleases? :-)

http://sociologi.cjb.net/temp/test.sav

-- 
Hans Ekbrand (http://sociologi.cjb.net) 
GPG Fingerprint: 1408 C8D5 1E7D 4C9C C27E 014F 7C2C 872A 7050 614E


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


Re: [R] persp3d and rgl.viewpoint for rotating 3D plots

2009-04-08 Thread Duncan Murdoch

On 4/8/2009 11:01 AM, Camarda, Carlo Giovanni wrote:

Dear R-users,

within the rgl-package, I would have a question about the usage of persp3d in combination of rgl.viewpoint. 
I am not able to figure out how to let a 3D plot rotating around likewise the example in ?rgl.viewpoint. It seems that when I use persp3d(...) I see something on my screen, which is different from what I get when it's rotating. Is there any different behavior between shade3d and persp3d?

Please find below a simple example.

Actually, my final aim is to save each of the rotating graphs for creating a 
"clip". I commented below what I would use later on, but is there any way to do 
it better?


Take a look at ?movie3d.  I think it does what you want.

Duncan Murdoch




Thanks a lot for your help,
Carlo Giovanni Camarda


library(rgl)
# simplified version from help(rgl.viewpoint)
shade3d(oh3d())
coo <- 1:360
for(i in 1:length(coo)) {
rgl.viewpoint(coo[i])
#filename <- paste("pic", formatC(i,digits=1,flag="00"), ".png", sep="")
#rgl.snapshot(filename)
}

# simple persp3d adaption
f <- function(x,y) { r <- sqrt(x^2+y^2); 10 * sin(r)/r }
x <- seq(-10, 10, length= 30); y <- x
z <- outer(x, y, f)
persp3d(x, y, z)
coo <- 1:360
for(i in 1:length(coo)) {
rgl.viewpoint(coo[i])
#filename <- paste("pic", formatC(i,digits=1,flag="00"), ".png", sep="")
#rgl.snapshot(filename)
}



-
Dr. Carlo Giovanni Camarda
Research Scientist
Max Planck Institute for Demographic Research
Laboratory of Statistical Demography
Konrad-Zuse-Straße 1
18057 Rostock - Germany
Phone: +49 (0)381 2081 172
Fax: +49 (0)381 2081 472
cama...@demogr.mpg.de
http://www.demogr.mpg.de/en/staff/camarda/default.htm
-


--
This mail has been sent through the MPI for Demographic ...{{dropped:10}}





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

2009-04-08 Thread Alain Guillet

Hi,

I drew an ellipse with the package ellipse. Now I would like to know  if 
a point is inside the ellipse. Is any R functions to do it without 
computing the equation of the ellipse manually? Thanks.


For example, if I do "plot(ellipse(0.8), type = 'l')", I would like to 
know if (0,1) belongs to the drawn ellipse.



Regards,
Alain

--
Alain Guillet
Statistician and Computer Scientist

SMCS - Institut de statistique - Université catholique de Louvain
Bureau d.126
Voie du Roman Pays, 20
B-1348 Louvain-la-Neuve
Belgium

tel: +32 10 47 30 50

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


[R] predict "interval" for lmRob?

2009-04-08 Thread Galkowski, Jan
lm's "predict" function offers an "interval" parameter to choose between 
'confidence' and 'prediction' bands. In the package "robust" and for "lmRob", 
there is also a "predict" but it lacks such a parameter, and the documented 
"type" parameter has only "response" offerred.  Is there some way of obtaining 
prediction bands from lmRob?  Is there an alternative robust (linear) 
regression package that offers such a capability?

Thanks for any and all help.

  - Jan Galkowski, Akamai Technologies, Cambridge, MA.

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


Re: [R] [OT ?] rant (was : Re: Conversions From standard to metric units)

2009-04-08 Thread Michael Dewey

At 00:48 04/04/2009, Duncan Murdoch wrote:

On 03/04/2009 5:37 PM, Emmanuel Charpentier wrote:

Le vendredi 03 avril 2009 à 14:17 -0400, stephen sefick a écrit :

I am starting to use R for almost any sort of calculation that I need.
 I am a biologist that works in the states, and there is often a need
to convert from standard units to metric units.


US/Imperial units are *not* standard units.


But they are fun:  you should see the arguments 
you can have about whether imperial fluid ounces 
are the same volume as US fluid ounces. (They're 
not: US ounces are bigger.  But not big enough so that their gallons catch up!)


Even late in the day I cannot resist sharing the 
astonishment of a colleague from the United 
States when I told him I had been taught as a child the rhyme

A pint of pure water
Weighs a pound and a quarter

whereas he had been taught
A pint's a pound
The world around




Duncan Murdoch


The former "metric system"

is now called "Système International" (International System) for a
reason, which is *not* gallocentrism of a "few" 6e7 frogs, but rather
laziness of about 5.6e9 losers who refuse to load their memories with
meaningless conversion factors...

Emmanuel Charpentier
who has served his time with
pounds per cubic feet, furlongs
per fortnight, BTU and other
figments of British/American
sadistic imagination, thank you
very much...
 # Again, didn't work the first time...


 Is there a package in
R for this already?  If not I believe that I am going to write some of
the most often used in function form.  My question is should I include
this in my StreamMetabolism package.  It is not along the same theme
lines, but could loosely fit.  The reason that I ask is that I don't
want to clutter CRAN with a small package containing some conversion
functions because I am to lazy to source them into R every time that I
use them, but I also don't want the StreamMetabolism package to turn
into StephenMisc Fuctions.  Thoughts, comments, or suggestions would
be appreciated.

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





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

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


[R] vectors on top of contours, and lattice

2009-04-08 Thread Cable, Samuel B Civ USAF AFMC AFRL/RVBXI
OK, I needed to plot a set of vectors on top of a contour plot.  I
figured out a way to do this.  I create a panel function that calls
"larrows()" with arguments constructed from my vector data.  Then, when
I go to do the contour plot, I call contourplot() with the "panel"
argument set to point to my newly created panel function.

 

So far, so good.

 

Now, I need to do a series of contour plots, each overlaid with a
different set of vectors.  I can call contourplot(z~x*y,...)  but now
I'm stuck, because each contour plot will be overlaid with the *same*
vector plot.  This won't work because each set of contoured data has its
own particular set of associated vector data.  (BTW, I am not doing
gradients here.  The vector data is its own entity, not derivable from
the contoured data.)  Can I somehow define a whole series of panel
functions and coax contourplot() to choose the right one for each of its
plots?  Or do I have to revise my entire approach here?

 

Thanks!

 

--Sam

 


[[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] Howto Plot With Transparent Background

2009-04-08 Thread Christof Winter

Eik Vettorazzi wrote, On 08.04.2009 15:08:
By default pdfs have a transparent background, see ?pdf and there the bg 
part,

which can be proven by a minimal R+ LaTeX example

#R code
pdf("test.pdf")
plot(1,1)
dev.off()

#minimal tex example
\documentclass[a4paper,12pt]{article}
\usepackage[svgnames]{xcolor}
\usepackage{graphicx}
\begin{document}
\pagecolor{green}


I really like those bizarre green pages. Thanks for sharing.
:-)

Christof


--
Christof Winter
Bioinformatics Group
Biotechnologisches Zentrum
Technische Universität Dresden
Tatzberg 47-51
01307 Dresden
Germany

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] persp3d and rgl.viewpoint for rotating 3D plots

2009-04-08 Thread Camarda, Carlo Giovanni
Dear Duncan,

thanks for your prompt reply. 
I was tempted to use movie3d, but below I copied what I get on my PC. Then, I 
have ImageMagick installed and, though I set convert equal to FALSE, I was not 
able to find where the function writes the .png files.
Maybe I lack experience in managing such complex functions, but I must confess 
that I have quite some hard time to grasp info from help(movie3d). 

Thanks in advance for any help,
Carlo Giovanni


> library(rgl)
> # set data
> f <- function(x,y) { r <- sqrt(x^2+y^2); 10 * sin(r)/r }
> x <- seq(-10, 10, length= 30); y <- x
> z <- outer(x, y, f)
> # set working directory
> setwd("U:\\movie")
> dir() # check
character(0)
> # plot
> persp3d(x, y, z)
> movie3d(spin3d(), duration=5, convert=TRUE)
Writing movie000.png 
[...]
Writing movie050.png 

Error in movie3d(spin3d(), duration = 5, convert = TRUE) : 
  ImageMagick not found
> dir() # check again
character(0)
> movie3d(spin3d(), duration=5, convert=FALSE)
Writing movie000.png 
[...]
Writing movie050.png 

> dir() # check again ??
character(0)
> 

> version
   _   
platform   i386-pc-mingw32 
arch   i386
os mingw32 
system i386, mingw32   
status 
major  2   
minor  8.1 
year   2008
month  12  
day22  
svn rev47281   
language   R   
version.string R version 2.8.1 (2008-12-22)


-Original Message-
From: Duncan Murdoch [mailto:murd...@stats.uwo.ca] 
Sent: Wednesday, April 08, 2009 5:13 PM
To: Camarda, Carlo Giovanni
Cc: r-h...@stat.math.ethz.ch
Subject: Re: [R] persp3d and rgl.viewpoint for rotating 3D plots

On 4/8/2009 11:01 AM, Camarda, Carlo Giovanni wrote:
> Dear R-users,
> 
> within the rgl-package, I would have a question about the usage of 
> persp3d in combination of rgl.viewpoint. 
> I am not able to figure out how to let a 3D plot rotating around likewise the 
> example in ?rgl.viewpoint. It seems that when I use persp3d(...) I see 
> something on my screen, which is different from what I get when it's 
> rotating. Is there any different behavior between shade3d and persp3d?
> Please find below a simple example.
> 
> Actually, my final aim is to save each of the rotating graphs for creating a 
> "clip". I commented below what I would use later on, but is there any way to 
> do it better?

Take a look at ?movie3d.  I think it does what you want.

Duncan Murdoch


> 
> Thanks a lot for your help,
> Carlo Giovanni Camarda
> 
> 
> library(rgl)
> # simplified version from help(rgl.viewpoint)
> shade3d(oh3d())
> coo <- 1:360
> for(i in 1:length(coo)) {
> rgl.viewpoint(coo[i])
> #filename <- paste("pic", formatC(i,digits=1,flag="00"), ".png", sep="")
> #rgl.snapshot(filename)
> }
> 
> # simple persp3d adaption
> f <- function(x,y) { r <- sqrt(x^2+y^2); 10 * sin(r)/r }
> x <- seq(-10, 10, length= 30); y <- x
> z <- outer(x, y, f)
> persp3d(x, y, z)
> coo <- 1:360
> for(i in 1:length(coo)) {
> rgl.viewpoint(coo[i])
> #filename <- paste("pic", formatC(i,digits=1,flag="00"), ".png", sep="")
> #rgl.snapshot(filename)
> }
> 
> 
> 
> -
> Dr. Carlo Giovanni Camarda
> Research Scientist
> Max Planck Institute for Demographic Research
> Laboratory of Statistical Demography
> Konrad-Zuse-Straße 1
> 18057 Rostock - Germany
> Phone: +49 (0)381 2081 172
> Fax: +49 (0)381 2081 472
> cama...@demogr.mpg.de
> http://www.demogr.mpg.de/en/staff/camarda/default.htm
> -
> 
> 
> --
> This mail has been sent through the MPI for Demographic ...{{dropped:10}}
> 
> 
> 
> 
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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 mail has been sent through the MPI for Demographic Research.  Should you 
receive a mail that is apparently from a MPI user without this text displayed, 
then the address has most likely been faked. If you are uncertain about the 
validity of this message, please check the mail header or ask your system 
administrator for assistance.

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


Re: [R] Convert data frame containing time stamps to time series

2009-04-08 Thread amvds
Converting dates is getting stranger still. I am coercing a data frame
into a ts as follows:


tst1<-as.POSIXct("1/21/09 5:01",format="%m/%d/%y %H:%M")
tst2<-as.POSIXct("1/28/09 3:40",format="%m/%d/%y %H:%M")
tsdat<-as.ts(dat,start=tst1,end=tst2,frequency=1)

This generates a ts object. But strangely enough the first column of that
matrix starts at the numeric value of 841 counts up to 1139 and then
starts at 1 again, only to count up from there. The restart at 1 occurs at
the first day "1/21/09" at 10:00:00.

What is so special about that time? This phenomenon happens several times
in the long file. But the restart count is always a different number.
This creates a ramp with some bumps.

Can anybody explain this?
Thanks in advance,
Alex van der Spek


> I read records using scan:
>
> dat<-data.frame(scan(file="KDA.csv",what=list(t="%m/%d/%y
> %H:%M",f=0,p=0,d=0,o=0,s=0,a=0,l=0,c=0),skip=2,sep=",",nmax=np,flush=TRUE,na.strings=c("I/OTimeout","ArcOff-line")))
>
> which results in:
>
>> dat[1:5,]
>  t fp  d  o   sa  l c
> 1 1/21/09 5:01 16151  8.2 76 30 282 1060 53 7
> 2 1/21/09 5:02 16256  8.3 76 23 282 1059 54 7
> 3 1/21/09 5:03 16150  8.4 76 26 282 1059 55 7
> 4 1/21/09 5:04 16150  9.0 76 25 282 1051 57 6
> 5 1/21/09 5:05 15543 10.4 76  7 282 1024 58 6
>
> I have been unable to find a way to convert this into a time series. I did
> read the manuals and came across a way to coerce a data frame to a ts
> object: as.ts()
>
> Trouble is I do not know how to keep the timestamps in column t in the
> data frame above. The t column is not strings. If I do:
>
> plot.ts(dat)
>
> I can see how the first graphics panel is indeed numbers not text. So I
> think scan converted the text correctly per the format string I put in.
>
> Much more difficult still. The datafiles I have contain invalid data,
> missing values and other none relevant information. I filter this out
> using subset which works brilliantly. However, how can I filter using
> subset and convert to a time series afterwards. Since after subsetting
> there will be 'holes' i.e. missing records. Can a ts object deal with
> missing records? If so, how? Just point me to a document. I can and will
> put in the work to figure it out myself.
>
> Thank you!
> Alex van der Spek
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] persp3d and rgl.viewpoint for rotating 3D plots

2009-04-08 Thread Duncan Murdoch

On 4/8/2009 11:47 AM, Camarda, Carlo Giovanni wrote:

Dear Duncan,

	thanks for your prompt reply. 
I was tempted to use movie3d, but below I copied what I get on my PC. Then, I have ImageMagick installed and, though I set convert equal to FALSE, I was not able to find where the function writes the .png files.
Maybe I lack experience in managing such complex functions, but I must confess that I have quite some hard time to grasp info from help(movie3d). 


Presumably ImageMagick is not on your PATH, which is why movie3d() 
failed to find it.  It writes the image files to the directory given by 
the dir parameter, which defaults to tempdir().  tempdir() returns a 
session-specific temporary directory, which R will try to clear at the 
end of a session.


Duncan Murdoch



Thanks in advance for any help,
Carlo Giovanni



library(rgl)
# set data
f <- function(x,y) { r <- sqrt(x^2+y^2); 10 * sin(r)/r }
x <- seq(-10, 10, length= 30); y <- x
z <- outer(x, y, f)
# set working directory
setwd("U:\\movie")
dir() # check

character(0)

# plot
persp3d(x, y, z)
movie3d(spin3d(), duration=5, convert=TRUE)
Writing movie000.png 
[...]
Writing movie050.png 

Error in movie3d(spin3d(), duration = 5, convert = TRUE) : 
  ImageMagick not found

dir() # check again

character(0)

movie3d(spin3d(), duration=5, convert=FALSE)
Writing movie000.png 
[...]
Writing movie050.png 


dir() # check again ??

character(0)





version
   _   
platform   i386-pc-mingw32 
arch   i386
os mingw32 
system i386, mingw32   
status 
major  2   
minor  8.1 
year   2008
month  12  
day22  
svn rev47281   
language   R   
version.string R version 2.8.1 (2008-12-22)



-Original Message-
From: Duncan Murdoch [mailto:murd...@stats.uwo.ca] 
Sent: Wednesday, April 08, 2009 5:13 PM

To: Camarda, Carlo Giovanni
Cc: r-h...@stat.math.ethz.ch
Subject: Re: [R] persp3d and rgl.viewpoint for rotating 3D plots

On 4/8/2009 11:01 AM, Camarda, Carlo Giovanni wrote:

Dear R-users,

within the rgl-package, I would have a question about the usage of persp3d in combination of rgl.viewpoint. 
I am not able to figure out how to let a 3D plot rotating around likewise the example in ?rgl.viewpoint. It seems that when I use persp3d(...) I see something on my screen, which is different from what I get when it's rotating. Is there any different behavior between shade3d and persp3d?

Please find below a simple example.

Actually, my final aim is to save each of the rotating graphs for creating a 
"clip". I commented below what I would use later on, but is there any way to do 
it better?


Take a look at ?movie3d.  I think it does what you want.

Duncan Murdoch




Thanks a lot for your help,
Carlo Giovanni Camarda


library(rgl)
# simplified version from help(rgl.viewpoint)
shade3d(oh3d())
coo <- 1:360
for(i in 1:length(coo)) {
rgl.viewpoint(coo[i])
#filename <- paste("pic", formatC(i,digits=1,flag="00"), ".png", sep="")
#rgl.snapshot(filename)
}

# simple persp3d adaption
f <- function(x,y) { r <- sqrt(x^2+y^2); 10 * sin(r)/r }
x <- seq(-10, 10, length= 30); y <- x
z <- outer(x, y, f)
persp3d(x, y, z)
coo <- 1:360
for(i in 1:length(coo)) {
rgl.viewpoint(coo[i])
#filename <- paste("pic", formatC(i,digits=1,flag="00"), ".png", sep="")
#rgl.snapshot(filename)
}



-
Dr. Carlo Giovanni Camarda
Research Scientist
Max Planck Institute for Demographic Research
Laboratory of Statistical Demography
Konrad-Zuse-Straße 1
18057 Rostock - Germany
Phone: +49 (0)381 2081 172
Fax: +49 (0)381 2081 472
cama...@demogr.mpg.de
http://www.demogr.mpg.de/en/staff/camarda/default.htm
-


--
This mail has been sent through the MPI for Demographic ...{{dropped:10}}





__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 mail has been sent through the MPI for Demographic Research.  Should you 
receive a mail that is apparently from a MPI user without this text displayed, 
then the address has most likely been faked. If you are uncertain about the 
validity of this message, please check the mail header or ask your system 
administrator for assistance.



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

[R] Col Names

2009-04-08 Thread livia

Hello,

I am working with S-plus TimeSeries Object. I wonder how can I change the
column names of the variable instead of using the one default?

i.e to change "DEV.MSCI" to other name
  PositionsDEV.MSCI 
 04/30/1980 00:00:00.000 -0.0150328542
 05/31/1980 00:00:00.000  0.0005087752
 06/30/1980 00:00:00.000  0.0586794492
 07/31/1980 00:00:00.000  0.0458505592
 08/31/1980 00:00:00.000  0.0350926728

-- 
View this message in context: 
http://www.nabble.com/Col-Names-tp22952055p22952055.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] problem with creating a netcdf file under script sh

2009-04-08 Thread tuatu

Hi everyone, 
I try to make a netcdf file which disposes a difference between 2 variables
of 2netcdf files the same dimension 
When I programmed under R, everything is ok but when I put the code under
EOF of a sh script, an error occurs: 
"Error, passed variable has a dim that is NOT of class dim.ncdf!". My
programme is: 

x1<-open.ncdf("file1.nc") 
x2<-open.ncdf("file2.nc") 
y1<-get.var.ncdf(x1,"a") 
y2<-get.var.ncdf(x2,"a") 
y<- y1-y2 
t<-var.def.ncdf("t",units="c",dim=x1$dim,-1) 
nc<-create.ncdf("test.nc",vars=t) 
put.var.ncdf(nc,t,y) 
close.ncdf(nc) 

Thanks in advance, 
T.A 

-- 
View this message in context: 
http://www.nabble.com/problem-with-creating-a-netcdf-file-under-script-sh-tp22952125p22952125.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] Reshape - strange outputs

2009-04-08 Thread Steve Murray

Dear R Users,

I am using the reshape package to reformat gridded data into column format 
using the code shown below. However, when I display the resulting object, a 
single column is fomed (instead of three) and all the latitude values (which 
should be in either column one or two) are collected at the bottom. Also, the 
NA values aren't removed, despite this being requested in the code.

Code:


# NetCDF file has been read in and is being processed...

arunoff_1986_temp <- get.var.ncdf(netcdf_1036_temp, "arunoff")


# Assign row and column names

columnnames <- sprintf("%.2f", seq(from = -89.75, to = 89.75, length = 360))
rnames <- sprintf("%.2f", seq(from = -179.75, to = 179.75, length = 720))

colnames(arunoff_1986_temp) <- columnnames
rownames(arunoff_1986_temp) <- rnames


# Melt into columnar format

arunoff_1986$Longitude <- rownames(arunoff_1986)
# Note: If I do: arunoff_1986$Latitude <- rownames(arunoff_1986)  (i.e. 
change it to 'Latitude', I get the following: Warning message: In 
arunoff_1986$Latitude <- rownames(arunoff_1986) : Coercing LHS to a list ), 
thus proceed using 'Longitude' where no warning is apparent.


arunoff_long_1986 <- melt(arunoff_1986, id.var="Longitude", na.rm=TRUE)


> dim(arunoff_long_1986)
[1] 259560  2

>head(arunoff_long_1986, n=10)  # This displays what looks like one single 
>column, but is in fact two: column entitled "L1" is empty until the end of the 
>file, as shown by the 'tail' command below.
   value L1
1  
2  
3  
4  
5  
6  
7  
8  
9  
10 

> tail(arunoff_long_1986, n=10)
 value   L1
Latitude.351 85.25 Latitude
Latitude.352 85.75 Latitude
Latitude.353 86.25 Latitude
Latitude.354 86.75 Latitude
Latitude.355 87.25 Latitude
Latitude.356 87.75 Latitude
Latitude.357 88.25 Latitude
Latitude.358 88.75 Latitude
Latitude.359 89.25 Latitude
Latitude.360 89.75 Latitude



I'd be very grateful indeed if anyone is able to offer assistance by way of 
pointing out what I've done wrong. I've spent a long time working on this and 
trying various options, but am srill none the wiser! I'm aiming for three 
columns: Latitude, Longitude, 'value'. 

Many thanks for any help offered,

Steve

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

2009-04-08 Thread Duncan Murdoch

On 4/8/2009 11:17 AM, Alain Guillet wrote:

Hi,

I drew an ellipse with the package ellipse. Now I would like to know  if 
a point is inside the ellipse. Is any R functions to do it without 
computing the equation of the ellipse manually? Thanks.


For example, if I do "plot(ellipse(0.8), type = 'l')", I would like to 
know if (0,1) belongs to the drawn ellipse.


It's probably too late by then, but if you saved the result of the call 
to ellipse(0.8), and treat it as a polygon, there is the function 
point.in.polygon in the sp package, or pip in splancs, or inside in 
RFOC, or inside in GEOmap, etc.


Duncan Murdoch

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


[R] Sweave problem, with multicolumn tables from R to LaTeX

2009-04-08 Thread Christian Salas

Hi there,

I have been using the example provided bellow for a while, and It was 
working without any problem. Nevertheless, just since 2-3 days is not 
working, probably because I did update.packages(). I have tried to 
re-install the older versions of the packages Hmisc() and xtable(), but 
still does not work. Can you run this example, and tell me if you got 
the same problems?


I use linux-ubuntu, and R 2.8.1

Here is my .Rnw file

%%%
\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{Sweave}
\SweaveOpts{echo=TRUE}

\title{Why is not working this? a table from R having multi columns
names}
\author{Myself}
\date{\today}

\begin{document}
\maketitle

<>=
#Calling some packages
library(Hmisc)
library(xtable)

#version of the packages
packageDescription('Hmisc')$Version #version of Hmisc
packageDescription('xtable')$Version  #version of xtable

#version and features of my PC and R
R.version$platform
R.version$version.string
@

\section{The table ready to be exported}
An R table as an example.
<<>>=
tab.coef.allmodels <-
structure(c(246.8809, 153.6952, 43.6259, 1823.686, -4.0138, -53.8741,
-13.9552, -699.7154, 0, -3.0084, -0.5188, -41.7249, 4.0898,
2.0342, 0.2798, 25.636, 235.5128, 160.0244, 30.0147, 1523.0723,
3.7601, -53.9238, -3.9789, -597.1446, 0, -3.2745, -0.0025, -28.7418,
4.4203, 2.1606, 0.0124, 17.9259), .Dim = c(4L, 8L), .Dimnames = list(
c("NHA", "GHA", "Hdom", "VHA"), c("Intercept", "stand2",
"band3", "band7", "Intercept", "stand2", "band3", "band7"
)))
tab.coef.allmodels
@

\section{Producing the \LaTeX\ table}
\subsection{Showing a simple output table, but not being
  the aimed one}

The following syntax produce Table \ref{tab:coefAllmod1}, which is not
what I want.
<>=
l <- latex(tab.coef.allmodels, file="tab.coefAllmod1.tex",
rowlabel="Model for",
  first.hline.double=FALSE,
  rowlabel.just="l",
caption="MLR and LME parameter estimates by stand variables",
  caption.loc="top", label="tab:coefAllmod1",where="!h")
@

\input{tab.coefAllmod1}


\subsection{What I want, but not getting it right}
The following syntax produce Table \ref{tab:coefAllmod2}, which
contains all the information that i want, but is not giving me
the correct format.
<>=
l <- latex(tab.coef.allmodels, file="tab.coefAllmod2.tex",
rowlabel="Model for",
  first.hline.double=FALSE,
  rowlabel.just="l",
 cgroup=c("MLR","LME"),
 n.cgroup=c(4,4),
caption="MLR and LME parameter estimates by stand variables",
  caption.loc="top", label="tab:coefAllmod2",where="!h")
@

\input{tab.coefAllmod2}

I have been using this
syntax for a while, and was working without any problem.
 Nevertheless, just since 2-3 days is not working, probably
  because I did {\tt update.packages()}.
 I have tried to re-install the older versions of the packages
 {\tt Hmisc()} and {\tt xtable()}, but still does not work.

\vspace{1in}
{\Large   {\bf What Am I missing here?}}

\end{document}

%%%

The the main .tex file, tables, the ouput pdf, and the .Rnw files are in 
the following url, if you want to check them


http://environment.yale.edu/salas/questions/shortTable/multcolTable_short.tex
http://environment.yale.edu/salas/questions/shortTable/tab.coefAllmod1.tex
http://environment.yale.edu/salas/questions/shortTable/tab.coefAllmod2.tex
http://environment.yale.edu/salas/questions/shortTable/multcolTable_short.pdf
http://environment.yale.edu/salas/questions/shortTable/multcolTable_short.Rnw

thanks in advance for your help

--
---
Christian Salas E-mail:christian.sa...@yale.edu
PhD candidate   http://environment.yale.edu/salas
School of Forestry and Environmental Studies
Yale University Tel: +1-(203)-432 5126
360 Prospect St Fax:+1-(203)-432 3809
New Haven, CT 06511-2189Office: Room 35, Marsh Hall
USA

Yale Biometrics Lab  http://environment.yale.edu/biometrics

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

2009-04-08 Thread jim holtman
Is this what you are looking for:

> x
  Positions  DEV.MSCI
04/30/1980 00:00:00.000 -0.0150328542
05/31/1980 00:00:00.000  0.0005087752
06/30/1980 00:00:00.000  0.0586794492
07/31/1980 00:00:00.000  0.0458505592
08/31/1980 00:00:00.000  0.0350926728
> colnames(x)[2] <- "NewName"
> x
  Positions   NewName
04/30/1980 00:00:00.000 -0.0150328542
05/31/1980 00:00:00.000  0.0005087752
06/30/1980 00:00:00.000  0.0586794492
07/31/1980 00:00:00.000  0.0458505592
08/31/1980 00:00:00.000  0.0350926728


On Wed, Apr 8, 2009 at 10:45 AM, livia  wrote:
>
> Hello,
>
> I am working with S-plus TimeSeries Object. I wonder how can I change the
> column names of the variable instead of using the one default?
>
> i.e to change "DEV.MSCI" to other name
>              Positions            DEV.MSCI
>  04/30/1980 00:00:00.000 -0.0150328542
>  05/31/1980 00:00:00.000  0.0005087752
>  06/30/1980 00:00:00.000  0.0586794492
>  07/31/1980 00:00:00.000  0.0458505592
>  08/31/1980 00:00:00.000  0.0350926728
>
> --
> View this message in context: 
> http://www.nabble.com/Col-Names-tp22952055p22952055.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.
>



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

What is the problem that 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] Colour each letter of a text string in a plot

2009-04-08 Thread Daren Tan
I am inserting a DNA sequence into a plot, and hope to colourize each
of the four nucleotide of the DNA sequence with a unique colour i.e.,
A ("red"), C ("green"), G ("blue", and T ("yellow"). I use the
following codes, but the DNA sequence only shows as "red"


DNA <- "ACGT"

plot(1, xlim = c(0,1), ylim = c(0,1), axes=F, xlab="", ylab="",
main="", xaxs="i", yaxs="i")

text(x=0.5, y=0.5, labels=DNA, col=c("red", "green", "blue", "yellow"))

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

2009-04-08 Thread Peter Dalgaard

Mike Lawrence wrote:

Looks like that code implements a non-exhaustive variant of the
randomization test, sometimes called a permutation test. 


Isn't it the other way around? (Permutation tests can be exhaustive by 
looking at all permutations, if a randomization test did that, then it 
wouldn't be random.)



--
   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
~~ - (p.dalga...@biostat.ku.dk)  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] Tinn-R pdf()

2009-04-08 Thread Deepayan Sarkar
On 4/8/09, Tobias Verbeke  wrote:
> Hi Henning,
>
>
> > thanks for your help, with solved the problem, although i don't why,
> because when using the R editor accessible via the R console i created many
> many lattice plots with the code i posted, i.e. without the print() command.
> >
>
>  At the command line, R objects (including lattice plots which are
>  objects) get auto-printed, i.e. the print method is invoked automatically
> on these objects.
>
>  This is not the case when you write to a pdf file.

That claim is not accurate. Auto-printing should not be affected by
whether a pdf device is open at the moment.

I'm not familiar with TINN-R, but it's possible it executes R commands
through some sort of wrapper function, and that is failing to emulate
auto-printing correctly.

-Deepayan

>
>  Best,
>  Tobias
>
>
>
> >
> > >  Original-Nachricht 
> > > Datum: Wed, 8 Apr 2009 12:29:58 +0200
> > > Von: "ONKELINX, Thierry" 
> > > An: "Henning Wildhagen" , r-help@r-project.org
> > > Betreff: RE: [R] Tinn-R pdf()
> > >
> > >Dear Henning,
> > >
> > > You need to print() lattice plots when using a device:
> > >  library(lattice)
> > >
> > > pdf("plot1.pdf")
> > > PLOT<-(xyplot, ...)
> > > print(PLOT)
> > > dev.off()
> > >
> > > So this is not due to TINN-R.
> > >
> > > 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
> > > thierry.onkel...@inbo.be www.inbo.be
> > > To call in the statistician after the experiment is done may be no more
> > > than asking him to perform a post-mortem examination: he may be able to
> > > say what the experiment died of.
> > > ~ Sir Ronald Aylmer Fisher
> > >
> > > The plural of anecdote is not data.
> > > ~ Roger Brinner
> > >
> > > The combination of some data and an aching desire for an answer does not
> > > ensure that a reasonable answer can be extracted from a given body of
> > > data.
> > > ~ John Tukey
> > >
> > > -Oorspronkelijk bericht-
> > > Van: r-help-boun...@r-project.org
> [mailto:r-help-boun...@r-project.org]
> > > Namens Henning Wildhagen
> > > Verzonden: woensdag 8 april 2009 11:25
> > > Aan: r-help@r-project.org
> > > Onderwerp: [R] Tinn-R pdf()
> > >
> > > Dear R and Tinn-R users,
> > >
> > > i recently switched to Tinn-R and sending code to R works fine (R 2.8.1,
> > >
> > > Tinn-R 2.2.0.2, OS Windows XP). However, i encountered a problem when
> trying to send plots to pdf files like this:
> > >
> > > library(lattice)
> > >
> > > pdf("plot1.pdf")
> > > PLOT<-(xyplot, ...)
> > > PLOT
> > > dev.off()
> > >
> > > The file "plot1.pdf" is created, but it is empty.
> > > If i paste the code above directly into the R console and run it, the
> > > file "plot1.pdf" is created and in this case contains "PLOT".
> > >
> > > I guess that some settings in Tinn-R are wrong, but i have no idea
> > > which. Maybe someone has a suggestion?
> > >
> > > Thanks,
> > >
> > > Henning
> > > --

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Colour each letter of a text string in a plot

2009-04-08 Thread jim holtman
Use 'text' to write out each one:

plot(0, type='n', xlim=c(0,1), ylim=c(0,1))
text(seq(0,1,length=10), rep(0.5,10), LETTERS[1:10], col=1:10)



On Wed, Apr 8, 2009 at 12:15 PM, Daren Tan  wrote:
> I am inserting a DNA sequence into a plot, and hope to colourize each
> of the four nucleotide of the DNA sequence with a unique colour i.e.,
> A ("red"), C ("green"), G ("blue", and T ("yellow"). I use the
> following codes, but the DNA sequence only shows as "red"
>
>
> DNA <- "ACGT"
>
> plot(1, xlim = c(0,1), ylim = c(0,1), axes=F, xlab="", ylab="",
> main="", xaxs="i", yaxs="i")
>
> text(x=0.5, y=0.5, labels=DNA, col=c("red", "green", "blue", "yellow"))
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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 that 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.


Re: [R] vectors on top of contours, and lattice

2009-04-08 Thread Deepayan Sarkar
On 4/8/09, Cable, Samuel B Civ USAF AFMC AFRL/RVBXI
 wrote:
> OK, I needed to plot a set of vectors on top of a contour plot.  I
>  figured out a way to do this.  I create a panel function that calls
>  "larrows()" with arguments constructed from my vector data.  Then, when
>  I go to do the contour plot, I call contourplot() with the "panel"
>  argument set to point to my newly created panel function.
>
>
>
>  So far, so good.
>
>
>
>  Now, I need to do a series of contour plots, each overlaid with a
>  different set of vectors.  I can call contourplot(z~x*y,...)  but now
>  I'm stuck, because each contour plot will be overlaid with the *same*
>  vector plot.  This won't work because each set of contoured data has its
>  own particular set of associated vector data.  (BTW, I am not doing
>  gradients here.  The vector data is its own entity, not derivable from
>  the contoured data.)  Can I somehow define a whole series of panel
>  functions and coax contourplot() to choose the right one for each of its
>  plots?  Or do I have to revise my entire approach here?

See ?packet.number for one approach. This should allow you to extract
the correct component of the vector data inside the panel function.

-Deepayan

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


[R] Comparing Proportions Among Groups

2009-04-08 Thread Isabella Ghement
Hi everyone,

I am trying to compare proportions among groups using the logistic
regression
approach as follows:

1) Fit the model log(p_i/(1-p_i)) = M + G_i, where p_i is the probability
   of success in group i and G_i is the effect of group i, i=1,..,I.
2) Test the hypotheses:
   Ho: G_1 = G_2 = ... = G_I (the probability of success is the same for all
groups)
   versus
   Ha: at least two G_i's are different (at least two groups have different
probabilities of success)

I am wondering if there any R functions available for accomplishing these
tasks.
Using dummy variables is one option, but is it possible to solve this
problem in R
without resorting to the use of dummy variables?

Many thanks and kind regards,

Isabella

Isabella R. Ghement, Ph.D.
Ghement Statistical Consulting Company
301-7031 Blundell Road, Richmond, B.C., Canada, V6Y 1J5
Tel: 604-767-1250
Fax: 604-270-3922
E-mail: isabe...@ghement.ca
Web: www.ghement.ca

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


Re: [R] axis values on lattice log-scale plot

2009-04-08 Thread Deepayan Sarkar
On 4/7/09, Don McKenzie  wrote:
> I'm plotting the following (stripped of inessentials)
>
>  xyplot(sd ~ distance |
> wshed,data=sdvar.df,scales=list(x=list(log=TRUE),y=list(log=TRUE)))
>
>  sdvar.df  is a data frame, sd and distance are numeric, wshed is an ordered
> factor
>
>  trying to replicate the action of  log="xy" in plot()
>
>  The plot works fine but the axis values at the ticks are in scientific
> notation,
>  e.g. 10^1.5, 10^2.0, ... on the X axis and 10^-.5, 10^-.4, ... on the Y
> axis.
>
>  I've searched the lattice help (and I know it must be in there:-()  and
> the archive but can't seem to find a way to make
>  the axis values display as simply numeric  (i.e., 10,100,1000, ... on the X
> axis and proportions on the Y axis).
>
>  Suggestions much appreciated.

You need to provide your own axis annotation function.
?xscale.components.default gives you details and an example. Also, see
Figure 8.4 and 8.5 in

http://lmdvr.r-forge.r-project.org/

-Deepayan

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


Re: [R] Constrained, multiple response statistics

2009-04-08 Thread Gene Leynes
This sounds very similar to what I've been working on, but I'm not sure
without an example.

My solution has been to use an optimization that normalizes inside the
objective function.  The betas that are provided by optim are not
normalized, however since they were normalized inside the objective
function, normalizing them after the fact mirrors the internal workings of
the objective function.

see this example:
http://markmail.org/message/ze5237m6gbgvvvyf

Still, after looking at several statistical packages, and considering the
thoughtful responses from my post, I think that there must be a better way
using existing models, so I've been looking at other packages / models.

On Tue, Apr 7, 2009 at 6:10 PM, Jonathan Greenberg wrote:

> R'ers:
>
>   I was hoping I could get some direction on this.  I have a dataset of the
> form:
>
> Y1,Y2,...,YM = f(X1,X2,...,XN), where N is >>> M
>
> The response data (Y1,Y2,...,YM) is frequency data, such that the sum of
> all Yi = 1.0.  Both Xj and Yi are continuous variables.
>
> I'm trying to figure out the best approach(es) to solving for the model f()
> -- any ideas?  I could solve each Y one at a time, but the lack of
> constraint worries me, and I'm pretty sure that normalizing the data
> afterwards to sum to 1.0 is not going to work out properly.  Thoughts?  I've
> never worked with multiple response statistics before, so I'm mostly trying
> to get some pointers on where to begin investigating...
>
> --j
>
> --
>
> Jonathan A. Greenberg, PhD
> Postdoctoral Scholar
> Center for Spatial Technologies and Remote Sensing (CSTARS)
> University of California, Davis
> One Shields Avenue
> The Barn, Room 250N
> Davis, CA 95616
> Cell: 415-794-5043
> AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] binary version of R 2.8.x

2009-04-08 Thread tomkur2006-takehome

Yes, ./configure works with no error.
I guess it's a problem of my environment setup.  It's my first attempt to build 
it myself, and I have downloaded the binaries and installed it previously.


--- On Wed, 4/8/09, stephen sefick  wrote:

> From: stephen sefick 
> Subject: Re: [R] binary version of R 2.8.x
> To: tomkur2006-takeh...@yahoo.com
> Cc: r-help@r-project.org
> Date: Wednesday, April 8, 2009, 7:35 AM
> ./configure works with no errors ?
> I have compiled on mac os x and debian so my advice may be
> circumspect, but the errors I don't know what they are.
> 
> On Tue, Apr 7, 2009 at 10:17 PM, 
>  wrote:
> >
> >
> > Hello,
> >
> > Is there any binary version of R 2.8.x available for
> x86 Solaris 10?  I need it so that I can use some R library
> files.  I actually tried to compile the source myself, but
> it failed.  I don't know much about how to compile
> source files on Solaris, and it will be great if there is a
> binary version of R 2.8.x available.  Thanks.
> >
> > /***error after running make***/
> > util.c: In function `Rf_mbrtowc':
> > util.c:1147: parse error before `char'
> > util.c:1150: `p' undeclared (first use in this
> function)
> > util.c:1150: (Each undeclared identifier is reported
> only once
> > util.c:1150: for each function it appears in.)
> > util.c:1150: `q' undeclared (first use in this
> function)
> > util.c:1150: `err' undeclared (first use in this
> function)
> > make[3]: *** [util.o] Error 1
> > make[3]: Leaving directory
> `/var/tmp/R-2.8.1/src/main'
> > make[2]: *** [R] Error 2
> > make[2]: Leaving directory
> `/var/tmp/R-2.8.1/src/main'
> > make[1]: *** [R] Error 1
> > make[1]: Leaving directory `/var/tmp/R-2.8.1/src'
> > make: *** [R] Error 1
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained,
> reproducible code.
> >
> 
> 
> 
> -- 
> Stephen Sefick
> 
> Let's not spend our time and resources thinking about
> things that are
> so little or so large that all they really do for us is
> puff us up and
> make us feel like gods.  We are mammals, and have not
> exhausted the
> annoying little problems of being mammals.
> 
>   -K. Mullis

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


[R] subscript out of bounds in eqscplot problem

2009-04-08 Thread Pierre Moffard
Dear R users,

I have the following problem. Suppose I have the following toy data set:
> data
 m1 m2 m3 m4 m5 state
[1,]  1  0  1 13 23   2
[2,]  0  1  0 23 94   2
[3,]  1  0  0 45 56   1
[4,]  0  1  0 35 84   2
[5,]  1  1  0 98 37   1
[6,]  1  1  0 68  1   2

where the last column is a categorical variable representing the outcome, 
columns m1 to m3 are binary and columns m4 and m5 are continuous. I wish to 
perform lda and then plot the results so I do:

sc.dat<-scale(data[,-6])
sc.dat<-cbind(sc.dat,data[,6])
try<-lda(sc.dat[,1:5],sc..dat[,6])
tr.pred<-predict(try)
eqscplot(tr.pred$x)

and then I get the following error (I also have collinearity which I ignore 
because it doesnt matter):

> eqscplot(tr.pred$x)
Error in eqscplot(tr.pred$x) : subscript out of bounds

Why am I getting this error?  What does it mean?

Any insight is highly appreciated.

Thanks in advance,
Pierre


  
[[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] MLE for bimodal distribution

2009-04-08 Thread _nico_

Hello everyone,

I'm trying to use mle from package stats4 to fit a bi/multi-modal
distribution to some data, but I have some problems with it.
Here's what I'm doing (for a bimodal distribution):

# Build some fake binormally distributed data, the procedure fails also with
real data, so the problem isn't here
data = c(rnorm(1000, 3, 0.5), rnorm(500, 5, 0.3))
# Just to check it's bimodal
plot(density(data))
f = function(m, s, m2, s2, w)
{
-log( sum(w*dnorm(data, mean=m, sd=s)) + sum((1-w)*dnorm(data, mean=m2,
sd=s2)) )
}

res = mle(f, start=list("m"=3, "s"=0.5, "m2"=5, "s2"=0.35, "w"=0.6))

This gives an error:
Error in optim(start, f, method = method, hessian = TRUE, ...) : 
  non-finite finite-difference value [2]
In addition: There were 50 or more warnings (use warnings() to see the first
50)
And the warnings are about dnorm producing NaNs

So, my questions are:
1) What does "non-finite finite-difference value" mean? My guess would be
that an Inf was passed somewhere where a finite number was expected...? I'm
not sure how optim works though...
2) Is the log likelihood function I wrote correct? Can I use the same type
of function for 3 modes?
3) What should I do to avoid function failure? I tried by changing the
parameters, but it did not work.
4) Can I put constraints to the parameters? In particular, I would like w to
be between 0 and 1.
5) Is there a way to get the log-likelihood value, so that I can compare
different extimations?
6) Do you have any (possibly a bit "pratically oriented") readings about MLE
to suggest?

Thanks in advance
Nico
-- 
View this message in context: 
http://www.nabble.com/MLE-for-bimodal-distribution-tp22954970p22954970.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Minimum Spanning Tree

2009-04-08 Thread jpearl01


>I am not sure what you mean. Of course you can plot it using different
>layouts, e.g. with layout.reingold.tilford (after choosing the root
>vertex in some way) and then it looks like a usual tree plot, but why
>would that be any better?

I'd like to be able to distinguish between the nodes better.  For example
the image that I get looks like:
http://www.nabble.com/file/p22954099/mst.gif mst.gif 

The tree nodes are just too close together to be able to read.  I think the
problem might be that some distances between the nodes are *much* smaller
than other edges.The graph does not need to be directed, since the
distance metric does not imply a direction. The most important part is just
being able to see and differentiate between the nodes, and right now they
seem to be all lumped together.  How can I make it more readable?

Thanks,
~josh


-- 
View this message in context: 
http://www.nabble.com/Minimum-Spanning-Tree-tp22934813p22954099.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Genstat into R - Randomisation test

2009-04-08 Thread Mike Lawrence
I was taught that Fisher proposed the F-test as a computationally
simpler approximation to what he called a "Randomization test",
consisting of exhaustive permutations. I never looked at the original
Fisher reference myself, so this may be false.

However, I haven't observed a consistent nomenclature when I have seen
these tests discussed, so I typically ensure to mention whether what
I'm doing is exhaustive or non-exhaustive.

I do see the value in your interpretation, and think it makes sense to
drop "randomization"  as a name (despite it's possible historical
significance) and start using "exhaustive permutation test" (to
contrast with "non-exhaustive permutation test").


On Wed, Apr 8, 2009 at 1:18 PM, Peter Dalgaard  wrote:
> Mike Lawrence wrote:
>>
>> Looks like that code implements a non-exhaustive variant of the
>> randomization test, sometimes called a permutation test.
>
> Isn't it the other way around? (Permutation tests can be exhaustive by
> looking at all permutations, if a randomization test did that, then it
> wouldn't be random.)
>
>
> --
>   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
> ~~ - (p.dalga...@biostat.ku.dk)              FAX: (+45) 35327907
>



-- 
Mike Lawrence
Graduate Student
Department of Psychology
Dalhousie University

Looking to arrange a meeting? Check my public calendar:
http://tinyurl.com/mikes-public-calendar

~ Certainty is folly... I think. ~

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

2009-04-08 Thread stephen sefick
Does solaris have a package managment system?  And do you have all of
the packages for building?  It looks like you do, but I am not sure.

On Wed, Apr 8, 2009 at 12:42 PM,   wrote:
>
> Yes, ./configure works with no error.
> I guess it's a problem of my environment setup.  It's my first attempt to 
> build it myself, and I have downloaded the binaries and installed it 
> previously.
>
>
> --- On Wed, 4/8/09, stephen sefick  wrote:
>
>> From: stephen sefick 
>> Subject: Re: [R] binary version of R 2.8.x
>> To: tomkur2006-takeh...@yahoo.com
>> Cc: r-help@r-project.org
>> Date: Wednesday, April 8, 2009, 7:35 AM
>> ./configure works with no errors ?
>> I have compiled on mac os x and debian so my advice may be
>> circumspect, but the errors I don't know what they are.
>>
>> On Tue, Apr 7, 2009 at 10:17 PM,
>>  wrote:
>> >
>> >
>> > Hello,
>> >
>> > Is there any binary version of R 2.8.x available for
>> x86 Solaris 10?  I need it so that I can use some R library
>> files.  I actually tried to compile the source myself, but
>> it failed.  I don't know much about how to compile
>> source files on Solaris, and it will be great if there is a
>> binary version of R 2.8.x available.  Thanks.
>> >
>> > /***error after running make***/
>> > util.c: In function `Rf_mbrtowc':
>> > util.c:1147: parse error before `char'
>> > util.c:1150: `p' undeclared (first use in this
>> function)
>> > util.c:1150: (Each undeclared identifier is reported
>> only once
>> > util.c:1150: for each function it appears in.)
>> > util.c:1150: `q' undeclared (first use in this
>> function)
>> > util.c:1150: `err' undeclared (first use in this
>> function)
>> > make[3]: *** [util.o] Error 1
>> > make[3]: Leaving directory
>> `/var/tmp/R-2.8.1/src/main'
>> > make[2]: *** [R] Error 2
>> > make[2]: Leaving directory
>> `/var/tmp/R-2.8.1/src/main'
>> > make[1]: *** [R] Error 1
>> > make[1]: Leaving directory `/var/tmp/R-2.8.1/src'
>> > make: *** [R] Error 1
>> >
>> > __
>> > R-help@r-project.org mailing list
>> > https://stat.ethz.ch/mailman/listinfo/r-help
>> > PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> > and provide commented, minimal, self-contained,
>> reproducible code.
>> >
>>
>>
>>
>> --
>> Stephen Sefick
>>
>> Let's not spend our time and resources thinking about
>> things that are
>> so little or so large that all they really do for us is
>> puff us up and
>> make us feel like gods.  We are mammals, and have not
>> exhausted the
>> annoying little problems of being mammals.
>>
>>                                                               -K. Mullis
>



-- 
Stephen Sefick

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

-K. Mullis

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


Re: [R] Convert data frame containing time stamps to time series

2009-04-08 Thread stephen sefick
have you tried using zoo and then using the function as.ts()

On Wed, Apr 8, 2009 at 11:56 AM,   wrote:
> Converting dates is getting stranger still. I am coercing a data frame
> into a ts as follows:
>
>
> tst1<-as.POSIXct("1/21/09 5:01",format="%m/%d/%y %H:%M")
> tst2<-as.POSIXct("1/28/09 3:40",format="%m/%d/%y %H:%M")
> tsdat<-as.ts(dat,start=tst1,end=tst2,frequency=1)
>
> This generates a ts object. But strangely enough the first column of that
> matrix starts at the numeric value of 841 counts up to 1139 and then
> starts at 1 again, only to count up from there. The restart at 1 occurs at
> the first day "1/21/09" at 10:00:00.
>
> What is so special about that time? This phenomenon happens several times
> in the long file. But the restart count is always a different number.
> This creates a ramp with some bumps.
>
> Can anybody explain this?
> Thanks in advance,
> Alex van der Spek
>
>
>> I read records using scan:
>>
>> dat<-data.frame(scan(file="KDA.csv",what=list(t="%m/%d/%y
>> %H:%M",f=0,p=0,d=0,o=0,s=0,a=0,l=0,c=0),skip=2,sep=",",nmax=np,flush=TRUE,na.strings=c("I/OTimeout","ArcOff-line")))
>>
>> which results in:
>>
>>> dat[1:5,]
>>              t     f    p  d  o   s    a  l c
>> 1 1/21/09 5:01 16151  8.2 76 30 282 1060 53 7
>> 2 1/21/09 5:02 16256  8.3 76 23 282 1059 54 7
>> 3 1/21/09 5:03 16150  8.4 76 26 282 1059 55 7
>> 4 1/21/09 5:04 16150  9.0 76 25 282 1051 57 6
>> 5 1/21/09 5:05 15543 10.4 76  7 282 1024 58 6
>>
>> I have been unable to find a way to convert this into a time series. I did
>> read the manuals and came across a way to coerce a data frame to a ts
>> object: as.ts()
>>
>> Trouble is I do not know how to keep the timestamps in column t in the
>> data frame above. The t column is not strings. If I do:
>>
>> plot.ts(dat)
>>
>> I can see how the first graphics panel is indeed numbers not text. So I
>> think scan converted the text correctly per the format string I put in.
>>
>> Much more difficult still. The datafiles I have contain invalid data,
>> missing values and other none relevant information. I filter this out
>> using subset which works brilliantly. However, how can I filter using
>> subset and convert to a time series afterwards. Since after subsetting
>> there will be 'holes' i.e. missing records. Can a ts object deal with
>> missing records? If so, how? Just point me to a document. I can and will
>> put in the work to figure it out myself.
>>
>> Thank you!
>> Alex van der Spek
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/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.
>



-- 
Stephen Sefick

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

-K. Mullis

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


Re: [R] Reshape - strange outputs

2009-04-08 Thread stephen sefick
can you provide a reproducible example?

On Wed, Apr 8, 2009 at 11:59 AM, Steve Murray  wrote:
>
> Dear R Users,
>
> I am using the reshape package to reformat gridded data into column format 
> using the code shown below. However, when I display the resulting object, a 
> single column is fomed (instead of three) and all the latitude values (which 
> should be in either column one or two) are collected at the bottom. Also, the 
> NA values aren't removed, despite this being requested in the code.
>
> Code:
>
>
> # NetCDF file has been read in and is being processed...
>
> arunoff_1986_temp <- get.var.ncdf(netcdf_1036_temp, "arunoff")
>
>
> # Assign row and column names
>
> columnnames <- sprintf("%.2f", seq(from = -89.75, to = 89.75, length = 360))
> rnames <- sprintf("%.2f", seq(from = -179.75, to = 179.75, length = 720))
>
> colnames(arunoff_1986_temp) <- columnnames
> rownames(arunoff_1986_temp) <- rnames
>
>
> # Melt into columnar format
>
> arunoff_1986$Longitude <- rownames(arunoff_1986)
>    # Note: If I do: arunoff_1986$Latitude <- rownames(arunoff_1986)  (i.e. 
> change it to 'Latitude', I get the following: Warning message: In 
> arunoff_1986$Latitude <- rownames(arunoff_1986) : Coercing LHS to a list ), 
> thus proceed using 'Longitude' where no warning is apparent.
>
>
> arunoff_long_1986 <- melt(arunoff_1986, id.var="Longitude", na.rm=TRUE)
>
>
>> dim(arunoff_long_1986)
> [1] 259560      2
>
>>head(arunoff_long_1986, n=10)  # This displays what looks like one single 
>>column, but is in fact two: column entitled "L1" is empty until the end of 
>>the file, as shown by the 'tail' command below.
>   value L1
> 1
> 2
> 3
> 4
> 5
> 6
> 7
> 8
> 9
> 10
>
>> tail(arunoff_long_1986, n=10)
>             value       L1
> Latitude.351 85.25 Latitude
> Latitude.352 85.75 Latitude
> Latitude.353 86.25 Latitude
> Latitude.354 86.75 Latitude
> Latitude.355 87.25 Latitude
> Latitude.356 87.75 Latitude
> Latitude.357 88.25 Latitude
> Latitude.358 88.75 Latitude
> Latitude.359 89.25 Latitude
> Latitude.360 89.75 Latitude
>
>
>
> I'd be very grateful indeed if anyone is able to offer assistance by way of 
> pointing out what I've done wrong. I've spent a long time working on this and 
> trying various options, but am srill none the wiser! I'm aiming for three 
> columns: Latitude, Longitude, 'value'.
>
> Many thanks for any help offered,
>
> Steve
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Stephen Sefick

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

-K. Mullis

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


Re: [R] read.spss, locale and encodings

2009-04-08 Thread Peter Dalgaard

Hans Ekbrand wrote:

On Wed, Apr 08, 2009 at 04:17:51PM +0200, Peter Dalgaard wrote:

Hans Ekbrand wrote:

Someone running foreign 8.34 that is willing to test my SPSS-file?

Someone with an SPSS file problem willing to help test the prereleases? :-)


http://sociologi.cjb.net/temp/test.sav


No joy.

> read.spss("~/Desktop/downloads/test.sav", reencode = "latin1")
Error in read.spss("~/Desktop/downloads/test.sav", reencode = "latin1") :
  error reading system-file header
In addition: Warning message:
In read.spss("~/Desktop/downloads/test.sav", reencode = "latin1") :
  ~/Desktop/downloads/test.sav: position 143: Variable name begins with 
invalid character


(I suppose the actual culprit could be number 144 which does indeed 
start with an A-ring ("ÅLDKAT"))


Apparently, you can work around it like this

lc <- Sys.setlocale("LC_CTYPE")
Sys.setlocale("LC_CTYPE", "da_DK")
x <- read.spss("~/Desktop/downloads/test.sav", reencode = "latin1")
Sys.setlocale("LC_CTYPE", lc)

-- which doesn't strike me as particularly logical, but whatever works

--
   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
~~ - (p.dalga...@biostat.ku.dk)  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] predict "interval" for lmRob?

2009-04-08 Thread Greg Snow
Your problem is related to the theory underlying linear models (and is an 
example as to why it is important to understand the theory, not just know how 
to plug numbers into a computer).

The lm function is based on theory that assumes the y variable in normally 
distributed with the mean of that normal based on the model and the x values.  
This allows the predict function for lm to create prediction intervals based on 
the normal distribution, the predicted mean of that distribution, the estimated 
standard deviation, and the uncertainty in the predicted mean.  Note that if 
your y variable is not normally distributed, but the sample size is large 
enough for the Central Limit Theorem to hold, then the confidence intervals 
will be approximately correct, but the prediction intervals will probably not 
be.

When you switch to a robust regression approach, the assumption is that the y 
variable is not normal, so a prediction interval based on the normal 
distribution does not make sense.  To get an appropriate prediction interval 
you need some information on what the distribution of the y values is 
(conditional on the model), but most robust techniques are not based on a 
specific distribution, just some properties of the distribution.  Without some 
information (or at least an assumption) on that distribution, the predict 
method cannot create prediction intervals.

I know that this does not answer your question, but hopefully helps you to 
understand what is happening.  Think about what your actual scientific question 
is, it may be that you can answer the question without prediction intervals.

If you feel that you really need the prediction intervals, then you will need 
to do some additional background research into what distribution you think the 
data comes from, then you can proceed from there.  Some options include fitting 
a model based on that distribution, simulating data from the distribution given 
the model estimates and the uncertainty in those estimates, quantile 
regression, mixture of regressions, and others.

Hope this helps,

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
> project.org] On Behalf Of Galkowski, Jan
> Sent: Wednesday, April 08, 2009 9:32 AM
> To: r-help@r-project.org
> Subject: [R] predict "interval" for lmRob?
> 
> lm's "predict" function offers an "interval" parameter to choose
> between 'confidence' and 'prediction' bands. In the package "robust"
> and for "lmRob", there is also a "predict" but it lacks such a
> parameter, and the documented "type" parameter has only "response"
> offerred.  Is there some way of obtaining prediction bands from lmRob?
> Is there an alternative robust (linear) regression package that offers
> such a capability?
> 
> Thanks for any and all help.
> 
>   - Jan Galkowski, Akamai Technologies, Cambridge, MA.
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Minimum Spanning Tree

2009-04-08 Thread Gábor Csárdi
On Wed, Apr 8, 2009 at 6:12 PM, jpearl01  wrote:
>
>
>>I am not sure what you mean. Of course you can plot it using different
>>layouts, e.g. with layout.reingold.tilford (after choosing the root
>>vertex in some way) and then it looks like a usual tree plot, but why
>>would that be any better?
>
> I'd like to be able to distinguish between the nodes better.  For example
> the image that I get looks like:
> http://www.nabble.com/file/p22954099/mst.gif mst.gif
>
> The tree nodes are just too close together to be able to read.  I think the
> problem might be that some distances between the nodes are *much* smaller
> than other edges.    The graph does not need to be directed, since the
> distance metric does not imply a direction. The most important part is just
> being able to see and differentiate between the nodes, and right now they
> seem to be all lumped together.  How can I make it more readable?

Make the graph undirected first and then choose the right plotting
parameters. E.g. the following works fine for me:

set.seed(2)
g <- erdos.renyi.game(100, 300, type="gnm", directed=TRUE)
E(g)$weight <- runif(ecount(g))
mst <- minimum.spanning.tree(g)

mst <- simplify(as.undirected(mst))
lay <- layout.reingold.tilford(mst, root=which.max(degree(mst))-1)
plot(mst, layout=lay, vertex.size=5, asp=FALSE, vertex.color=NA,
   vertex.frame.color=NA)

G.

> Thanks,
> ~josh
>
>
> --
> View this message in context: 
> http://www.nabble.com/Minimum-Spanning-Tree-tp22934813p22954099.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.
>



-- 
Gabor Csardi  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] Lattice Groups

2009-04-08 Thread Lyman, Mark
I don't understand your first question, but, since no one else has
responded I can answer your second question. panel.bwplot, unlike
panel.xyplot doesn't use panel.superpose when groups is not NULL. In
order to get an analogous result you need to specify that you want to
use panel.superpose.

cols <- c("Sepal.Width", "Petal.Length", "Petal.Width")
stackedData <- stack(iris[, cols])
df <- data.frame(y = stackedData$values, x = rep(iris$Species, 3), which
= gl(3, nrow(iris)))

bwplot(y ~ x:which, data = df, groups = which, panel=panel.superpose,
panel.groups = panel.bwplot)

If you don't like the default colors, you can set the fill colors with
par.settings like:

bwplot(y ~ x:which, data = df, groups = which, panel=panel.superpose,
panel.groups = panel.bwplot,
par.settings=list(superpose.symbol=list(fill=2:4)))

Without the groups, the fill colors are controlled like this
bwplot(y~x:which, data = df,
par.settings=list(box.rectangle=list(fill=2:4)))

Although if you have groups, using the groups argument is probably
better.

Mark Lyman


Message: 41
Date: Tue, 7 Apr 2009 10:50:33 +0100
From: Richard Weeks 
Subject: [R] Lattice Groups
To: 
Message-ID: 
Content-Type: text/plain


Hi all,

 

I'm trying to achieve a few things using the lattice package but am
failing miserably.

I am plotting side by side box plots and using a grouping variable, e.g.

 

cols <- c("Sepal.Width", "Petal.Length", "Petal.Width")
stackedData <- stack(iris[, cols])
df <- data.frame(y = stackedData$values, x = rep(iris$Species, 3), which
= gl(3, nrow(iris)))

bwplot(y ~ x:which, data = df, group = which, panel.groups =
panel.bwplot)

 

My questions are 

1) How am I able to retain the median spot in the boxes?

2) How can I change the fill using the par.settings argument rather than
fill =1:3 say?

 

Best wishes,

 

Biff

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] read.spss, locale and encodings

2009-04-08 Thread Hans Ekbrand
On Wed, Apr 08, 2009 at 07:12:23PM +0200, Peter Dalgaard wrote:
> Apparently, you can work around it like this
>
> lc <- Sys.setlocale("LC_CTYPE")
> Sys.setlocale("LC_CTYPE", "da_DK")
> x <- read.spss("~/Desktop/downloads/test.sav", reencode = "latin1")
> Sys.setlocale("LC_CTYPE", lc)
>
> -- which doesn't strike me as particularly logical, but whatever works

THANKS a lot Peter! This works perfectly! I had been struggling with
this problem way too long...

-- 
Hans Ekbrand (http://sociologi.cjb.net) 
GnuPG key: 1024D/7050614E
Fingerprint: 1408 C8D5 1E7D 4C9C C27E 014F 7C2C 872A 7050 614E
Learn about secure email at http://www.gnupg.org


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


Re: [R] predict "interval" for lmRob?

2009-04-08 Thread Galkowski, Jan
Hi Greg,

Thanks for your guidance. 

In this case, the evidence is that the primary subpopulation of the data, 
accounting for  observes the standard statistical model in the sense that Rice 
uses the term.  It may by all accounts be normally distributed, and a Q-Q shows 
a large portion of the primary subpopulation behaves that way, out to 2 
theoretical quantiles. But, for the measurement ranges of interest, the 
complement of the "normal subpopulation", accounting for some 20% of the total 
two million data points, behaves in other ways, which are, as a matter of fact, 
poorly understood.  That's not likely to change soon.

The choice of a robust regression framework and of "robust" (and possibly 
"quantreg" as Prof Koenker suggested) was simply to automatically fit a line to 
the primary subpopulation, without having to make arbitrary choices as what to 
keep or what to discard. Also, use of any preexisting package was simply 
pursued as a timesaver, worksaver, and to have some conceptual framework within 
to proceed other than just throwing least squares at arbitrarily chosen 
subsets.  

It sounds to me like I might use the robust regression to decide what to 
discard and then apply standard linear "lm" to the remainder, minding the 
diagnostics. Should they prove favorable, I'll proceed with the result of "lm".

Thanks for pointing out the limitations of "robust" and its kin for me. 

BTW, if "robust" does not adopt a normal model for the y variable, what's the 
proper interpretation of the standard errors for slope and intercept it yields? 
 A reference?

 - Jan

-Original Message-
From: Greg Snow [mailto:greg.s...@imail.org] 
Sent: Wednesday, April 08, 2009 1:20 PM
To: Galkowski, Jan; r-help@r-project.org
Subject: RE: predict "interval" for lmRob?

Your problem is related to the theory underlying linear models (and is an 
example as to why it is important to understand the theory, not just know how 
to plug numbers into a computer).

The lm function is based on theory that assumes the y variable in normally 
distributed with the mean of that normal based on the model and the x values.  
This allows the predict function for lm to create prediction intervals based on 
the normal distribution, the predicted mean of that distribution, the estimated 
standard deviation, and the uncertainty in the predicted mean.  Note that if 
your y variable is not normally distributed, but the sample size is large 
enough for the Central Limit Theorem to hold, then the confidence intervals 
will be approximately correct, but the prediction intervals will probably not 
be.

When you switch to a robust regression approach, the assumption is that the y 
variable is not normal, so a prediction interval based on the normal 
distribution does not make sense.  To get an appropriate prediction interval 
you need some information on what the distribution of the y values is 
(conditional on the model), but most robust techniques are not based on a 
specific distribution, just some properties of the distribution.  Without some 
information (or at least an assumption) on that distribution, the predict 
method cannot create prediction intervals.

I know that this does not answer your question, but hopefully helps you to 
understand what is happening.  Think about what your actual scientific question 
is, it may be that you can answer the question without prediction intervals.

If you feel that you really need the prediction intervals, then you will need 
to do some additional background research into what distribution you think the 
data comes from, then you can proceed from there.  Some options include fitting 
a model based on that distribution, simulating data from the distribution given 
the model estimates and the uncertainty in those estimates, quantile 
regression, mixture of regressions, and others.

Hope this helps,

--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
> project.org] On Behalf Of Galkowski, Jan
> Sent: Wednesday, April 08, 2009 9:32 AM
> To: r-help@r-project.org
> Subject: [R] predict "interval" for lmRob?
> 
> lm's "predict" function offers an "interval" parameter to choose
> between 'confidence' and 'prediction' bands. In the package "robust"
> and for "lmRob", there is also a "predict" but it lacks such a
> parameter, and the documented "type" parameter has only "response"
> offerred.  Is there some way of obtaining prediction bands from lmRob?
> Is there an alternative robust (linear) regression package that offers
> such a capability?
> 
> Thanks for any and all help.
> 
>   - Jan Galkowski, Akamai Technologies, Cambridge, MA.
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.htm

[R] Display a very low p-value

2009-04-08 Thread Bhoom Suktitipat
Hello R-Help,

I ran some analysis and were hit with some low Z-score. I tried to convert
it to a p-value, however, it seems like the ceiling is around 1e-16.

> 1-pnorm(8)
[1] 6.661338e-16
> 1-pnorm(9)
[1] 0

Do you have any suggestion how I can display a very low p-value in the form
of scientific number format?

Thank you very much.

Regards,
Bhoom

[[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] xyplot - show values of a series on graph

2009-04-08 Thread taz9

Hi All,

I have a very simple graph:

cars <- c(1, 3, 6, 4, 9)
trucks <- c(2, 5, 4, 5, 12)
year <- c(2004, 2005, 2006, 2007, 2008)
df2<-data.frame(cars,trucks,year)
xyplot(cars+trucks~year, data=df2, type="o")

I need to show the values of "cars" on the graph. How can I do this?

Thanks.

-- 
View this message in context: 
http://www.nabble.com/xyplot---show-values-of-a-series-on-graph-tp22956986p22956986.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] help with random forest package

2009-04-08 Thread Liaw, Andy
The source code of the whole package is available on CRAN.  All packages
are submitted to CRAN is source form.

There's no "rule" per se that gives the final prediction, as the final
prediction is the result of plural vote by all trees in the forest.

You may want to look at the varUsed() and getTree() functions.

Andy 

From:  Chrysanthi A.
> Hello,
> 
> I am a phd student in Bioinformatics and I am using the Random Forest
> package in order to classify my data, but I have some questions.
> Is there a function in order to visualize the trees, so as to 
> get the rules?
> Also, could you please provide me with the code of 
> "randomForest" function,
> as I would like to see how it works. I was wondering if I can get the
> classification having the most votes over all the trees in 
> the forest (the
> final rules that will give me the final classification). 
> Also, is there a
> possibility to get a vector with the attributes that are 
> being selected for
> each node during the construction of each tree? I mean, that 
> I would like to
> know the m< the M input
> attributes.. Are they selected randomly? Is there a 
> possibility to select
> the same variable in subsequent nodes?
> 
> Thanks a lot,
> 
> Chrysanthi.
> 
>   [[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.
> 
Notice:  This e-mail message, together with any attachme...{{dropped:12}}

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

2009-04-08 Thread stephen sefick
?options look at scipen

On Wed, Apr 8, 2009 at 2:38 PM, Bhoom Suktitipat  wrote:
> Hello R-Help,
>
> I ran some analysis and were hit with some low Z-score. I tried to convert
> it to a p-value, however, it seems like the ceiling is around 1e-16.
>
>> 1-pnorm(8)
> [1] 6.661338e-16
>> 1-pnorm(9)
> [1] 0
>
> Do you have any suggestion how I can display a very low p-value in the form
> of scientific number format?
>
> Thank you very much.
>
> Regards,
> Bhoom
>
>        [[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.
>



-- 
Stephen Sefick

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

-K. Mullis

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


Re: [R] Display a very low p-value

2009-04-08 Thread Dimitris Rizopoulos

in this case you need to use the 'lower.tail' argument, e.g.,

pnorm(8:15, lower.tail = FALSE)


I hope it helps.

Best,
Dimitris


Bhoom Suktitipat wrote:

Hello R-Help,

I ran some analysis and were hit with some low Z-score. I tried to convert
it to a p-value, however, it seems like the ceiling is around 1e-16.


1-pnorm(8)

[1] 6.661338e-16

1-pnorm(9)

[1] 0

Do you have any suggestion how I can display a very low p-value in the form
of scientific number format?

Thank you very much.

Regards,
Bhoom

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



--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus University Medical Center

Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014

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


  1   2   >