Re: [R] Difference between loops and vectorization

2010-12-01 Thread Dieter Menne


Santosh Srinivas wrote:
> 
> A fundamental question ...I'm trying to understand the differences between
> loop and vectorization ... I understand that it should be a natural choice
> to use apply / adply when it is needed to perform the
> same function across all rows of a data frame. Any pointers on why this is
> so? Unable to find the right reading place on the WWW which explains the
> concept.
> 

Strange. "loop vectorization" gives a few hundred of hits, that tell you
that loops are not as bad in R (compared to S) in many cases. "apply" is
probably the least important vectorization method in R, but I admit that
some texts make us believe that it is the point where you show your
R-talents.

"adply" is different: it is a rather complex function from package plyr by
Hadley Wickham. This package provides some elegant orthogonal functions
under a unified concept. I found it appealing at the first look, but I am
less frequently using it nowadays because it can be terribly slow.

Try the chapter in 

http://www.burns-stat.com/pages/Tutor/R_inferno.pdf

Dieter

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Difference-between-loops-and-vectorization-tp3066585p3066788.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] Minor warning about seq

2010-12-01 Thread Dieter Menne


Prof. John C Nash wrote:
> 
> I spent more time than I should have debugging a script because I wanted
>x<-seq(0,100)*0.1
> 
> but typed
>x<-seq(O:100)*0.1
> 
> seq(0:100) yields 1 to 101,
> 

Which leads us to another rule: never use a variable called "O". I remember
this was a no-no even in my first Algol-course in 1967.

In a virginal Rgui:

> x<-seq(O:100)*0.1 
Error in seq(O:100) : object 'O' not found
 
Dieter

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Minor-warning-about-seq-tp3065964p3066791.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] pca analysis: extract rotated scores?

2010-12-01 Thread Mark Difford

Hi Liviu,

>> However, I'm still confused on how to compute the scores when rotations 
>> (such as 'varimax' or other methods in GPArotation) are applied.

PCA does an orthogonal rotation of the coordinate system (axes) and further
rotation is not usually done (in contrast to factor analysis). Neither
prcomp nor princomp do any further rotation and any rotate= argument in the
call is simply being passed through.

You can get what you want from by feeding the scores from prcomp/princomp
(or something else) to GPArotation. This returns rotated scores and the
rotating matrix.

##
library(GPArotation)
.PC <- princomp(~am+carb+cyl+disp+drat+gear+hp+mpg, cor=TRUE, data=mtcars)
.PCs <- .PC$scores
.PCrs <- entropy(.PCs)
.PCs
.PCrs

Regards, Mark.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/pca-analysis-extract-rotated-scores-tp3065061p3066795.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] non-linear fourth-order differential equations

2010-12-01 Thread Thomas Petzoldt

Hi Yanika,

more information about deSolve (books, papers, tutorials) can be found 
on the deSolve homepage:


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

and, of course, in the package documentations. If you need further help 
from the list, please provide a short reproducible example.


Thomas Petzoldt


--
Dr. Thomas Petzoldt
Limnology and Ecological Modelling

Technische Universitaet Dresden
Fakulty of Forest, Geo and Hydro Sciences
Institute of Hydrobiology
01062 Dresden, Germany
E-Mail: thomas.petzo...@tu-dresden.de
http://tu-dresden.de/Members/thomas.petzoldt

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Reordering entries in package manual PDF's

2010-12-01 Thread Aleksi Kallio

Hello,

I have create my own R package and written the documentation in Rd 
format for each of the functions plus the package itself.


However now the functions appear in a random order in the generated PDF 
and the package documentation is placed in between the functions, when I 
would like it to be first, naturally.


Is there an easy way to specify the order of the entries in the 
generated documentation?


Browsing through the R manual and mailing list archives did not find 
anything. Rd is all I need, so I would not like to start using any of 
the more advanced documentation tools.


Thanks for your help!

All the best,
Aleksi

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

2010-12-01 Thread arturs . onzuls
Can you please show code example, how to draw graph with some nodes and
edges, but with weights. I only found here
http://www.bioconductor.org/packages/release/bioc/vignettes/Rgraphviz/inst/doc/Rgraphviz.pdf-
Using edge weights for labels, but...

Here an example:

> library("graph"); library(Rgraphviz)
> myNodes = c("s", "p", "q", "r")
> myEdges = list(
s = list(edges = c("p", "q")),
p = list(edges = c("p", "q")),
q = list(edges = c("p", "r")),
r = list(edges = c("s")))
> g = new("graphNEL", nodes = myNodes,
edgeL = myEdges, edgemode =
"directed")
> plot(g)

but how about weights?


Thanx.

[[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] Error bars in lattice barchart with groups

2010-12-01 Thread Dieter Menne


Henning Wildhagen wrote:
> 
> 
> i want to plot gene regulation data in a lattice barchart. To illustrate 
> the problem i encounter, the following code uses the "barley"dataset:
> 
> 
> #No, i tried to add error bars using the following code:
> ..
> 

As Deepayan noted in

# http://markmail.org/message/oljgimkav2qcdyre

it's not easy without dissection barchart. The omission of bar charts with
error bars is probably by design, because of the bad ink-to-info ratio.
Nevertheless, I had to do it over and over, because big bosses love it
because of the high ink content. ggplot provides a way out:

http://had.co.nz/ggplot2/geom_errorbar.html

Dieter




-- 
View this message in context: 
http://r.789695.n4.nabble.com/Error-bars-in-lattice-barchart-with-groups-tp3065864p3066814.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] missing values

2010-12-01 Thread Iasonas Lamprianou
Dear all,
i have spent a lot of time trying to solve this problem, but I am sure that 
there must be a simple solution. So, as a last resort, I am coming back to you 
again. I have a dataset with some (almost random) values in many variables. 
Lets 
say that the dataset represents the scores of students to test questions. What 
I 
need to do is to sum the scores for each student. However, wherever there is a 
missing (NA) value, I cannot get the total score.  How can I compute the total 
score and the average per question (a) by ignoring the missing responses, (b) 
by 
assuming that a missing response is a zero?
Thank you for the response


 Dr. Iasonas Lamprianou




Assistant Professor (Educational Research and Evaluation)
Department of Education Sciences
European University-Cyprus
P.O. Box 22006
1516 Nicosia
Cyprus 
Tel.: +357-22-713178
Fax: +357-22-590539




Honorary Research Fellow
Department of Education
The University of Manchester
Oxford Road, Manchester M13 9PL, UK
Tel. 0044  161 275 3485
iasonas.lampria...@manchester.ac.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] Save R2HTML as an object instead of file

2010-12-01 Thread Joel

Or is there any kind of File buffer that dossent save a file on the
harddrive?

coz this gives me the thing I want but it still saves the file on the HD 

> .HTML.file=(temp<-file("era.html","w+"))
> HTML("NANALALA")
> HTML(diag(3))


Then I can just use

readLines(temp) to get the result

but as I said I dont want it to save the HTML on the HD just in an object.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Save-R2HTML-as-an-object-instead-of-file-tp3066776p3066845.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] Save R2HTML as an object instead of file

2010-12-01 Thread Gregoire Pau

Hi Joel,

The function hwrite() of the package hwriter does that.
> library(hwriter)
> hwrite(iris[1:10,])

See examples at http://www.embl.de/~gpau/hwriter/

Cheers,

Greg
---
Gregoire Pau
EMBL Research Officer
http://www.embl.de/~gpau/

On 01/12/10 08:53, Joel wrote:


Hi

Is it possible to instead of getting the HTML code written to a file, get it
saved as a string in an object instead?
Or is there any kind of package that can do this?
//Joel


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

2010-12-01 Thread Koray Kaya
Hello,

I tried to use GEOQuery package of BioC. It does not download GSE. 
I investigated problem, understood that the problem was about internal function 
"download".
Reccomendations about it mostly suggest switching any proxy off in R. I did, 
and nothing changed.

I use Ubuntu Lucid 64 bit

Thanks

[[alternative HTML version deleted]]

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


Re: [R] Problem in reading Excel spreadsheets

2010-12-01 Thread Ivan Calandra

Hi,

I don't know much about RODBC, but the package xlsReadWrite works pretty 
well for me for reading and writing xls files (and it doesn't need Perl 
or anything else to run).


Ivan

Le 12/1/2010 08:56, Stephen Liu a écrit :

Hi folks,

Win 7 64bit
R 2.12.0 32bit

Problem in reading Excel spreadsheets

(the text file, research_databaseI.xls, was download on Internet)



data=odbcConnectExcel(file.choose())
sqlTables(data)

  TABLE_CAT TABLE_SCHEM
1  C:\\Users\\satimiswin764\\Documents\\research_databaseI
2  C:\\Users\\satimiswin764\\Documents\\research_databaseI
3  C:\\Users\\satimiswin764\\Documents\\research_databaseI
4  C:\\Users\\satimiswin764\\Documents\\research_databaseI
5  C:\\Users\\satimiswin764\\Documents\\research_databaseI
6  C:\\Users\\satimiswin764\\Documents\\research_databaseI
7  C:\\Users\\satimiswin764\\Documents\\research_databaseI
8  C:\\Users\\satimiswin764\\Documents\\research_databaseI
9  C:\\Users\\satimiswin764\\Documents\\research_databaseI
10 C:\\Users\\satimiswin764\\Documents\\research_databaseI
11 C:\\Users\\satimiswin764\\Documents\\research_databaseI
12 C:\\Users\\satimiswin764\\Documents\\research_databaseI
13 C:\\Users\\satimiswin764\\Documents\\research_databaseI
14 C:\\Users\\satimiswin764\\Documents\\research_databaseI
15 C:\\Users\\satimiswin764\\Documents\\research_databaseI
16 C:\\Users\\satimiswin764\\Documents\\research_databaseI
17 C:\\Users\\satimiswin764\\Documents\\research_databaseI
18 C:\\Users\\satimiswin764\\Documents\\research_databaseI
19 C:\\Users\\satimiswin764\\Documents\\research_databaseI
20 C:\\Users\\satimiswin764\\Documents\\research_databaseI
21 C:\\Users\\satimiswin764\\Documents\\research_databaseI
22 C:\\Users\\satimiswin764\\Documents\\research_databaseI
23 C:\\Users\\satimiswin764\\Documents\\research_databaseI
   TABLE_NAME   TABLE_TYPE REMARKS
1   AGR$ SYSTEM TABLE
2   BMC$ SYSTEM TABLE
3 Dairy$ SYSTEM TABLE
4   GDP$ SYSTEM TABLE
5  HIES$ SYSTEM TABLE
6 Manuf$ SYSTEM TABLE
7Prices$ SYSTEM TABLE
8Sheet1$ SYSTEM TABLE
9   WPI$ SYSTEM TABLE
10 'Approved plans$'TABLE
11  'Emp stats$'TABLE
12   'Ex rates$'TABLE
13'hotel occ rates$'TABLE
14   'Insurance co$'TABLE
15 'Interest rates$'TABLE
16'Motor V$'TABLE
17   'Ostrich Projects$'TABLE
18   'Prop dev$'TABLE
19'tourism est$'TABLE
20 'tourism est'$_FilterDatabaseTABLE
21  'Travel agents$'TABLE
22   'Umempl stats$'TABLE
23 'US CPI$'TABLE


mydata=sqlFetch(data, "AGR")
odbcClose(data)
mydata

The printout doesn't look like the content of Excel spreadsheet.  Many data
disappear.

I read ?RODBC and the pdf file started with "RShowDoc("RODBC",
package="RODBC").  I couldn't figure out the cause of problem.


Is "RODBC" not the way to read Excel spreadsheets on R?  TIA

B.R.
Stephen L


[[alternative HTML version deleted]]

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



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

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

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


Re: [R] How to draw a rect() behind a hist() ?

2010-12-01 Thread Ivan Calandra

Hi,
For your second question, take a look at ?clip. The example explains 
really well what you can do and how.

HTH,
Ivan


Le 12/1/2010 04:42, Peter Ehlers a écrit :

On 2010-11-30 17:27, Jason Edgecombe wrote:

Hi,

I have the following code:

hist(gps$heartpercent, breaks=5)
rect(90, par("usr")[3], 100, par("usr")[4], col = "red")

How do I get the rectangle to appear behind the histogram. Barring that,
how can I make certain bars of the histogram to be a certain color?


Here are a couple of ways:
1. using hist(); just plot the histogram twice.

 x <- rnorm(1000, 100, 5)
 hist(x)
 rect(90, 0, 98, par('usr')[4], col = 'red')
 hist(x, add = TRUE)

For coloured bars, use a colour vector:

 hist(x, breaks = 5, col = c(3,3,4,4,2))

2. using lattice;

 histogram(x,
  panel=function(...){
panel.rect(90,0,98,1000,col='bisque',border=NA)
panel.histogram(...,col='transparent',lwd=2)
  }
 )

Again, you can define bar colours with a colour vector.
Lattice is more customizable albeit a little harder
to learn.

Peter Ehlers


Thanks,
Jason



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

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



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

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

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


Re: [R] Error bars in lattice barchart with groups

2010-12-01 Thread Dieter Menne

This is an interesting discussion on barchart (without error bars)

http://www.decisionsciencenews.com/2010/08/11/which-chart-is-better/

Dieter


-- 
View this message in context: 
http://r.789695.n4.nabble.com/Error-bars-in-lattice-barchart-with-groups-tp3065864p3066860.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] missing values

2010-12-01 Thread Ivan Calandra

Hi,

(a) sum() and mean() have a na.rm argument that should be set to TRUE.

(b) let's try with an example:
x <- c(1:5, NA, NA, 6:10, NA)
x[is.na(x)] <- 0  ## replace NAs by 0

HTH,
Ivan


Le 12/1/2010 10:00, Iasonas Lamprianou a écrit :

Dear all,
i have spent a lot of time trying to solve this problem, but I am sure that
there must be a simple solution. So, as a last resort, I am coming back to you
again. I have a dataset with some (almost random) values in many variables. Lets
say that the dataset represents the scores of students to test questions. What I
need to do is to sum the scores for each student. However, wherever there is a
missing (NA) value, I cannot get the total score.  How can I compute the total
score and the average per question (a) by ignoring the missing responses, (b) by
assuming that a missing response is a zero?
Thank you for the response


  Dr. Iasonas Lamprianou




Assistant Professor (Educational Research and Evaluation)
Department of Education Sciences
European University-Cyprus
P.O. Box 22006
1516 Nicosia
Cyprus
Tel.: +357-22-713178
Fax: +357-22-590539




Honorary Research Fellow
Department of Education
The University of Manchester
Oxford Road, Manchester M13 9PL, UK
Tel. 0044  161 275 3485
iasonas.lampria...@manchester.ac.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.



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

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

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


Re: [R] Problem in reading Excel spreadsheets

2010-12-01 Thread Stephen Liu
Hi Ivan,

Thanks for your advice.

I have problem running xlsReadWrite on 64 bit Win7.

> library(xlsReadWrite)
xlsReadWrite version (cran shlib)
Copyright (C) 2010 Hans-Peter Suter, Treetron, Switzerland.

!! Your installation contains the cran placeholder shlib (dll/so).
Please get the regular shlib (420 KB) by executing the following command:

   xls.getshlib()

Info, forum, issue tracker and manual download at http://www.swissr.org.

BACKGROUND: Our own xlsReadWrite code is free, but we also use proprietary code
(Flexcel, tmssoftware.com) which can only be distributed legally in precompiled,
i.e. binary form. As CRAN 'generally does not accept submissions of precompiled
binaries due to security reasons' we only provide a placeholder and you can
download the binary shlib separately. NO GUARANTEES: We have done thorough tests
initially and there are integrity checks, but we do _not_ give any guarantees.
You can check/clone the source code at http://github.com/swissr/xlsreadwrite,
in case of any issues we are happy to hear about them (bug tracker/forum/email).

> xls.getshlib()
Loading required package: tools
--- xls.getshlib running... --- 
Error in xls.getshlib() : currently only windows (32 bit) supported

xls.getshlib only runs on 32 bit Windows.  I must go back to 32 bit Win 7.


B.R.
Stephen L





From: Ivan Calandra 
To: r-help@r-project.org
Sent: Wed, December 1, 2010 5:05:40 PM
Subject: Re: [R] Problem in reading Excel spreadsheets

Hi,

I don't know much about RODBC, but the package xlsReadWrite works pretty 
well for me for reading and writing xls files (and it doesn't need Perl 
or anything else to run).

Ivan

Le 12/1/2010 08:56, Stephen Liu a écrit :
> Hi folks,
>
> Win 7 64bit
> R 2.12.0 32bit
>
> Problem in reading Excel spreadsheets
>
> (the text file, research_databaseI.xls, was download on Internet)
>
>
>> data=odbcConnectExcel(file.choose())
>> sqlTables(data)
>   TABLE_CAT TABLE_SCHEM
> 1  C:\\Users\\satimiswin764\\Documents\\research_databaseI
> 2  C:\\Users\\satimiswin764\\Documents\\research_databaseI
> 3  C:\\Users\\satimiswin764\\Documents\\research_databaseI
> 4  C:\\Users\\satimiswin764\\Documents\\research_databaseI
> 5  C:\\Users\\satimiswin764\\Documents\\research_databaseI
> 6  C:\\Users\\satimiswin764\\Documents\\research_databaseI
> 7  C:\\Users\\satimiswin764\\Documents\\research_databaseI
> 8  C:\\Users\\satimiswin764\\Documents\\research_databaseI
> 9  C:\\Users\\satimiswin764\\Documents\\research_databaseI
> 10 C:\\Users\\satimiswin764\\Documents\\research_databaseI
> 11 C:\\Users\\satimiswin764\\Documents\\research_databaseI
> 12 C:\\Users\\satimiswin764\\Documents\\research_databaseI
> 13 C:\\Users\\satimiswin764\\Documents\\research_databaseI
> 14 C:\\Users\\satimiswin764\\Documents\\research_databaseI
> 15 C:\\Users\\satimiswin764\\Documents\\research_databaseI
> 16 C:\\Users\\satimiswin764\\Documents\\research_databaseI
> 17 C:\\Users\\satimiswin764\\Documents\\research_databaseI
> 18 C:\\Users\\satimiswin764\\Documents\\research_databaseI
> 19 C:\\Users\\satimiswin764\\Documents\\research_databaseI
> 20 C:\\Users\\satimiswin764\\Documents\\research_databaseI
> 21 C:\\Users\\satimiswin764\\Documents\\research_databaseI
> 22 C:\\Users\\satimiswin764\\Documents\\research_databaseI
> 23 C:\\Users\\satimiswin764\\Documents\\research_databaseI
>TABLE_NAME   TABLE_TYPE REMARKS
> 1   AGR$ SYSTEM TABLE
> 2   BMC$ SYSTEM TABLE
> 3 Dairy$ SYSTEM TABLE
> 4   GDP$ SYSTEM TABLE
> 5  HIES$ SYSTEM TABLE
> 6 Manuf$ SYSTEM TABLE
> 7Prices$ SYSTEM TABLE
> 8Sheet1$ SYSTEM TABLE
> 9   WPI$ SYSTEM TABLE
> 10 'Approved plans$'TABLE
> 11  'Emp stats$'TABLE
> 12   'Ex rates$'TABLE
> 13'hotel occ rates$'TABLE
> 14   'Insurance co$'TABLE
> 15 'Interest rates$'TABLE
> 16'Motor V$'TABLE
> 17   'Ostrich Projects$'TABLE
> 18   'Prop dev$'TABLE
> 19'tourism est$'TABLE
> 20 'tourism est'$_FilterDatabaseTABLE
> 21  'Travel agents$'TABLE
> 22   'Umempl stats$'TABLE
> 23 'US CPI$'TABLE
>
>> mydata=sqlFetch(data, "AGR")
>> odbcClose(data)
>> mydata
> The printout doesn't look like the content of Excel spreadsheet.  Many data
> disappear.
>
> I read ?RODBC and the pdf file started with "RShowDoc("RODBC",
> package="RODBC").  I couldn't figure out the cause of problem.
>
>
> Is "RODBC" not the way to read Excel spreadsheets on R?  TIA
>
> B.R.
> Stephen L
>
>
> [[alternative HTML version del

Re: [R] missing values

2010-12-01 Thread Michael Bedward
And just to add to Ivan's comment, if you are using the rowSums or
colSums functions with a matrix or data.frame they also have the na.rm
argument.

Michael

On 1 December 2010 20:16, Ivan Calandra  wrote:
> Hi,
>
> (a) sum() and mean() have a na.rm argument that should be set to TRUE.
>
> (b) let's try with an example:
> x <- c(1:5, NA, NA, 6:10, NA)
> x[is.na(x)] <- 0  ## replace NAs by 0
>
> HTH,
> Ivan
>
>
> Le 12/1/2010 10:00, Iasonas Lamprianou a écrit :
>>
>> Dear all,
>> i have spent a lot of time trying to solve this problem, but I am sure
>> that
>> there must be a simple solution. So, as a last resort, I am coming back to
>> you
>> again. I have a dataset with some (almost random) values in many
>> variables. Lets
>> say that the dataset represents the scores of students to test questions.
>> What I
>> need to do is to sum the scores for each student. However, wherever there
>> is a
>> missing (NA) value, I cannot get the total score.  How can I compute the
>> total
>> score and the average per question (a) by ignoring the missing responses,
>> (b) by
>> assuming that a missing response is a zero?
>> Thank you for the response
>>
>>
>>  Dr. Iasonas Lamprianou
>>
>>
>>
>>
>> Assistant Professor (Educational Research and Evaluation)
>> Department of Education Sciences
>> European University-Cyprus
>> P.O. Box 22006
>> 1516 Nicosia
>> Cyprus
>> Tel.: +357-22-713178
>> Fax: +357-22-590539
>>
>>
>>
>>
>> Honorary Research Fellow
>> Department of Education
>> The University of Manchester
>> Oxford Road, Manchester M13 9PL, UK
>> Tel. 0044  161 275 3485
>> iasonas.lampria...@manchester.ac.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.
>>
>
> --
> Ivan CALANDRA
> PhD Student
> University of Hamburg
> Biozentrum Grindel und Zoologisches Museum
> Abt. Säugetiere
> Martin-Luther-King-Platz 3
> D-20146 Hamburg, GERMANY
> +49(0)40 42838 6231
> ivan.calan...@uni-hamburg.de
>
> **
> http://www.for771.uni-bonn.de
> http://webapp5.rrz.uni-hamburg.de/mammals/eng/1525_8_1.php
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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


Re: [R] How to draw a rect() behind a hist() ?

2010-12-01 Thread Jim Lemon

On 12/01/2010 12:27 PM, Jason Edgecombe wrote:

Hi,

I have the following code:

hist(gps$heartpercent, breaks=5)
rect(90, par("usr")[3], 100, par("usr")[4], col = "red")

How do I get the rectangle to appear behind the histogram. Barring that,
how can I make certain bars of the histogram to be a certain color?


Hi Jason,
Does this do what you want?

heartpercent<-sample(0:100,200,TRUE)
library(plotrix)
barp(hist(heartpercent,breaks=5,plot=FALSE)$counts,
 names.arg=c("0-20","21-40","41-60","61-80","81-100"),
 do.first=rect(5,par("usr")[3],par("usr")[2],par("usr")[4],
 col = "red"))

Jim

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


[R] how to remove grid lines from coplot graphs

2010-12-01 Thread Seth Roberts
coplot() usually puts grid lines in the panels it makes. To see examples,
example(coplot).

How can I remove those grid lines?

Seth Roberts

[[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] missing values

2010-12-01 Thread Iasonas Lamprianou
thank you, I'll have a go and let you know if i have problems
 Dr. Iasonas Lamprianou




Assistant Professor (Educational Research and Evaluation)
Department of Education Sciences
European University-Cyprus
P.O. Box 22006
1516 Nicosia
Cyprus 
Tel.: +357-22-713178
Fax: +357-22-590539




Honorary Research Fellow
Department of Education
The University of Manchester
Oxford Road, Manchester M13 9PL, UK
Tel. 0044  161 275 3485
iasonas.lampria...@manchester.ac.uk



- Original Message 
From: Michael Bedward 
To: ivan.calan...@uni-hamburg.de; lampria...@yahoo.com; Rhelp 

Sent: Wed, 1 December, 2010 11:40:13
Subject: Re: [R] missing values

And just to add to Ivan's comment, if you are using the rowSums or
colSums functions with a matrix or data.frame they also have the na.rm
argument.

Michael

On 1 December 2010 20:16, Ivan Calandra  wrote:
> Hi,
>
> (a) sum() and mean() have a na.rm argument that should be set to TRUE.
>
> (b) let's try with an example:
> x <- c(1:5, NA, NA, 6:10, NA)
> x[is.na(x)] <- 0  ## replace NAs by 0
>
> HTH,
> Ivan
>
>
> Le 12/1/2010 10:00, Iasonas Lamprianou a écrit :
>>
>> Dear all,
>> i have spent a lot of time trying to solve this problem, but I am sure
>> that
>> there must be a simple solution. So, as a last resort, I am coming back to
>> you
>> again. I have a dataset with some (almost random) values in many
>> variables. Lets
>> say that the dataset represents the scores of students to test questions.
>> What I
>> need to do is to sum the scores for each student. However, wherever there
>> is a
>> missing (NA) value, I cannot get the total score.  How can I compute the
>> total
>> score and the average per question (a) by ignoring the missing responses,
>> (b) by
>> assuming that a missing response is a zero?
>> Thank you for the response
>>
>>
>>  Dr. Iasonas Lamprianou
>>
>>
>>
>>
>> Assistant Professor (Educational Research and Evaluation)
>> Department of Education Sciences
>> European University-Cyprus
>> P.O. Box 22006
>> 1516 Nicosia
>> Cyprus
>> Tel.: +357-22-713178
>> Fax: +357-22-590539
>>
>>
>>
>>
>> Honorary Research Fellow
>> Department of Education
>> The University of Manchester
>> Oxford Road, Manchester M13 9PL, UK
>> Tel. 0044  161 275 3485
>> iasonas.lampria...@manchester.ac.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.
>>
>
> --
> Ivan CALANDRA
> PhD Student
> University of Hamburg
> Biozentrum Grindel und Zoologisches Museum
> Abt. Säugetiere
> Martin-Luther-King-Platz 3
> D-20146 Hamburg, GERMANY
> +49(0)40 42838 6231
> ivan.calan...@uni-hamburg.de
>
> **
> http://www.for771.uni-bonn.de
> http://webapp5.rrz.uni-hamburg.de/mammals/eng/1525_8_1.php
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>





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


Re: [R] Save R2HTML as an object instead of file

2010-12-01 Thread Eric Lecoutre
Hi Joel,

You can use:

obj=diag(3)
txt=capture.output(HTML(obj,file=""))

Then you may manipulate elements, paste with collapse argument, replace
parts with gsub and so on.

HTH,

Eric



2010/12/1 Joel 

>
> Hi
>
> Is it possible to instead of getting the HTML code written to a file, get
> it
> saved as a string in an object instead?
> Or is there any kind of package that can do this?
> //Joel
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Save-R2HTML-as-an-object-instead-of-file-tp3066776p3066776.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.
>



-- 
Eric Lecoutre
Consultant - Business & Decision
Business Intelligence & Customer Intelligence

[[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] .Internal(download())

2010-12-01 Thread Koray Kaya
Hello, I tried to use GEOQuery package of BioC. It does not download GSE. I 
investigated problem, understood that the problem was about internal function 
"download". Reccomendations about it mostly suggest switching any proxy off in 
R. I did, and nothing changed. 
I use Ubuntu Lucid 64 bit
Thanks

[[alternative HTML version deleted]]

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


[R] problems formulating arguments to lme()

2010-12-01 Thread Robert Kinley
this is a clearer (I hope) version of an earlier post  -

My problem is formulating the  random = argument to give estimates
of all 9 random components for this kind of setup where there are
(I think) 9  variance/covariance components ...

 Study.1Study.2   ...  Study.5
 Treatment T1: subject:  1  2  3  4  5  6   ...  13 14 15
 
 Treatment T2: subject: 16 17 18   19 20 21   ...  28 29 30 
 
 A variable is measured at the same 2 fixed sites (a and b) on each 
subject

{ Toy example data at end of email }

so fixed effects are :-
 between-Treatments ( T1 and T2 )
 between-sites   ( a and b )
 Treatment*site interaction

and random effects are :-
 study effects at site a 
 study effects at site b
 correlation between site a and site b study effects 

 study*treatment interaction effects at site a 
 study*treatment interaction effects at site b
 correlation between site a and b study*treatment interaction effects 
 
 residual (between-subject) effects at site a 
 residual (between-subject) effects at site b
 correlation between site a and b residuals (between-subject) effects 

I'm having trouble seeing how to formulate this correctly in  lme()

Hope someone can help ...

cheers  Bob Kinley

> Toy
   Study Treatment Subject SiteResult
   1T1   1a  13.901820
   1T1   1b  19.158889
   1T1   2a  16.026299
   1T1   2b  15.545153
   1T1   3a  19.667706
   1T1   3b  21.945156
   1T2  16a   9.822498
   1T2  16b  13.271435
   1T2  17a  18.602909
   1T2  17b  15.679736
   1T2  18a  15.083195
   1T2  18b  18.012834
   2T1   4a  19.394835
   2T1   4b  13.537977
   2T1   5a  17.921014
   2T1   5b  12.070566
   2T1   6a  14.419953
   2T1   6b  16.990585
   2T2  19a  15.489600
   2T2  19b  21.721682
   2T2  20a  18.553789
   2T2  20b  16.628156
   2T2  21a  20.310238
   2T2  21b  18.604716
   3T1   7a  12.458706
   3T1   7b  17.279394
   3T1   8a  14.598512
   3T1   8b  17.024093
   3T1   9a  20.821720
   3T1   9b  22.051680
   3T2  22a  17.923521
   3T2  22b  11.690319
   3T2  23a  12.547144
   3T2  23b  15.051402
   3T2  24a  12.865087
   3T2  24b  13.451004
   4T1  10a  13.819201
   4T1  10b  18.375914
   4T1  11a  18.540972
   4T1  11b  15.741144
   4T1  12a  16.992064
   4T1  12b  16.964870
   4T2  25a  18.583896
   4T2  25b  19.920100
   4T2  26a  18.782343
   4T2  26b  15.095778
   4T2  27a  23.042282
   4T2  27b  19.296852
   5T1  13a  12.425960
   5T1  13b  12.865022
   5T1  14a  16.774604
   5T1  14b  15.540754
   5T1  15a  15.726991
   5T1  15b   8.089564
   5T2  28a  11.694392
   5T2  28b  24.740416
   5T2  29a  14.664904
   5T2  29b  16.348194
   5T2  30a  20.911168
   5T2  30b  15.394160
> 
[[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] Adding text to a multiplot (via mfrow)

2010-12-01 Thread smj_115

Hi Peter

Many thanks. I will have a go with that and see if I have 
any joy.

Your advice is much appreciated.

Sam
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Adding-text-to-a-multiplot-via-mfrow-tp3065850p3067003.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] Problem in reading Excel spreadsheets

2010-12-01 Thread Ivan Calandra

Hi again,

There are also other packages to read and write xls files, including 
gdata (read), dataframe2xls and writeXLS (write), which depend on Perl 
or Python if I'm not mistaken.

I have no idea whether they work on Windows 64 bits.
Visit Crantastic http://crantastic.org/

Ivan

Le 12/1/2010 10:34, Stephen Liu a écrit :

Hi Ivan,

Thanks for your advice.

I have problem running xlsReadWrite on 64 bit Win7.

> library(xlsReadWrite)
xlsReadWrite version (cran shlib)
Copyright (C) 2010 Hans-Peter Suter, Treetron, Switzerland.

!! Your installation contains the cran placeholder shlib (dll/so).
Please get the regular shlib (420 KB) by executing the following command:

   xls.getshlib()

Info, forum, issue tracker and manual download at http://www.swissr.org.

BACKGROUND: Our own xlsReadWrite code is free, but we also use 
proprietary code
(Flexcel, tmssoftware.com) which can only be distributed legally in 
precompiled,
i.e. binary form. As CRAN 'generally does not accept submissions of 
precompiled
binaries due to security reasons' we only provide a placeholder and 
you can
download the binary shlib separately. NO GUARANTEES: We have done 
thorough tests
initially and there are integrity checks, but we do _not_ give any 
guarantees.
You can check/clone the source code at 
http://github.com/swissr/xlsreadwrite,
in case of any issues we are happy to hear about them (bug 
tracker/forum/email).


> xls.getshlib()
Loading required package: tools
--- xls.getshlib running... ---
Error in xls.getshlib() : currently only windows (32 bit) supported

xls.getshlib only runs on 32 bit Windows.  I must go back to 32 bit Win 7.


B.R.
Stephen L


*From:* Ivan Calandra 
*To:* r-help@r-project.org
*Sent:* Wed, December 1, 2010 5:05:40 PM
*Subject:* Re: [R] Problem in reading Excel spreadsheets

Hi,

I don't know much about RODBC, but the package xlsReadWrite works pretty
well for me for reading and writing xls files (and it doesn't need Perl
or anything else to run).

Ivan

Le 12/1/2010 08:56, Stephen Liu a écrit :
> Hi folks,
>
> Win 7 64bit
> R 2.12.0 32bit
>
> Problem in reading Excel spreadsheets
>
> (the text file, research_databaseI.xls, was download on Internet)
>
>
>> data=odbcConnectExcel(file.choose())
>> sqlTables(data)
>  TABLE_CAT TABLE_SCHEM
> 1  C:\\Users\\satimiswin764\\Documents\\research_databaseI
> 2  C:\\Users\\satimiswin764\\Documents\\research_databaseI
> 3  C:\\Users\\satimiswin764\\Documents\\research_databaseI
> 4  C:\\Users\\satimiswin764\\Documents\\research_databaseI
> 5  C:\\Users\\satimiswin764\\Documents\\research_databaseI
> 6  C:\\Users\\satimiswin764\\Documents\\research_databaseI
> 7  C:\\Users\\satimiswin764\\Documents\\research_databaseI
> 8  C:\\Users\\satimiswin764\\Documents\\research_databaseI
> 9  C:\\Users\\satimiswin764\\Documents\\research_databaseI
> 10 C:\\Users\\satimiswin764\\Documents\\research_databaseI
> 11 C:\\Users\\satimiswin764\\Documents\\research_databaseI
> 12 C:\\Users\\satimiswin764\\Documents\\research_databaseI
> 13 C:\\Users\\satimiswin764\\Documents\\research_databaseI
> 14 C:\\Users\\satimiswin764\\Documents\\research_databaseI
> 15 C:\\Users\\satimiswin764\\Documents\\research_databaseI
> 16 C:\\Users\\satimiswin764\\Documents\\research_databaseI
> 17 C:\\Users\\satimiswin764\\Documents\\research_databaseI
> 18 C:\\Users\\satimiswin764\\Documents\\research_databaseI
> 19 C:\\Users\\satimiswin764\\Documents\\research_databaseI
> 20 C:\\Users\\satimiswin764\\Documents\\research_databaseI
> 21 C:\\Users\\satimiswin764\\Documents\\research_databaseI
> 22 C:\\Users\\satimiswin764\\Documents\\research_databaseI
> 23 C:\\Users\\satimiswin764\\Documents\\research_databaseI
>TABLE_NAME  TABLE_TYPE REMARKS
> 1  AGR$ SYSTEM TABLE
> 2  BMC$ SYSTEM TABLE
> 3Dairy$ SYSTEM TABLE
> 4  GDP$ SYSTEM TABLE
> 5  HIES$ SYSTEM TABLE
> 6Manuf$ SYSTEM TABLE
> 7Prices$ SYSTEM TABLE
> 8Sheet1$ SYSTEM TABLE
> 9  WPI$ SYSTEM TABLE
> 10'Approved plans$'TABLE
> 11  'Emp stats$'TABLE
> 12  'Ex rates$'TABLE
> 13'hotel occ rates$'TABLE
> 14  'Insurance co$'TABLE
> 15'Interest rates$'TABLE
> 16'Motor V$'TABLE
> 17  'Ostrich Projects$'TABLE
> 18  'Prop dev$'TABLE
> 19'tourism est$'TABLE
> 20 'tourism est'$_FilterDatabaseTABLE
> 21  'Travel agents$'TABLE
> 22  'Umempl stats$'TABLE
> 23'US CPI$'TABLE
>
>> mydata=sqlFetch(data, "AGR")
>> odbcClose(dat

Re: [R] Difficulty loading packages into R version 2.12.0

2010-12-01 Thread Uwe Ligges

Run

update.packages(checkBuilt=TRUE)

to get package binaries that were compield for your version of R.

Uwe Ligges





On 24.11.2010 04:24, john moran wrote:

Apologies for my previous effort in HTML which apparently was scrubbed

Dear R-users

I wonder if I could get advice on the above problem

I have just installed V 2.12.0 (I chose only the 32-bit version) into a new
directory (C:/R)  on a 64bit Windows 7 machine


sessionInfo()

R version 2.12.0 (2010-10-15)
Platform: i386-pc-mingw32/i386 (32-bit)
locale:
[1] LC_COLLATE=English_Australia.1252  LC_CTYPE=English_Australia.1252
[3] LC_MONETARY=English_Australia.1252 LC_NUMERIC=C
[5] LC_TIME=English_Australia.1252
attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base
loaded via a namespace (and not attached):
[1] tools_2.12.0

I have loaded (from a zip file in my repository, due to an Institutional
fire-wall) the package "forecast":

utils:::menuInstallLocal()

package 'forecast' successfully unpacked and MD5 sums checked

I get the following message when attempting to load the package:


local({pkg<- select.list(sort(.packages(all.available =

TRUE)),graphics=TRUE)
+ if(nchar(pkg)) library(pkg, character.only=TRUE)})
Error: package 'forecast' is not installed for 'arch=i386'

There has been a similar query (November 11th ) on this, but I seem to not
have the suggested problem as:

.libPaths()

[1] "C:/R/R-2.12.0/library" and "forecast" is in the above directory (and no
other)

Directions on this problem would be much appreciated

john moran

john.mo...@adelaide.edu.au

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

2010-12-01 Thread Small Sandy (NHS Greater Glasgow & Clyde)
Thanks Thierry

Using the position_dodge positioning option ought to work but there is 
something wrong with the scaling when the binwidth is not = 1.
You can begin to see this with the example I sent:

If you do
ggplot(data=dafr, aes(x = d1, fill=d2)) + geom_histogram(binwidth = 1, position 
= position_dodge())

You get the interleaved histogram you would expect
Similarly if you do:
ggplot(data=dafr, aes(x = d1, fill=d2)) + geom_histogram(binwidth = 2, position 
= position_dodge())
The histogram produced is reasonable: however

However if you do:
ggplot(data=dafr, aes(x = d1, fill=d2)) + geom_histogram(binwidth = 1, position 
= position_dodge(width=0.99))

The position of first bin which goes from 0-2 appears to start at about 0.2 (I 
accept that there is some "white space" to the left of this) while the position 
of the last bin (16-18) appears to start at about 15.8, so the whole histogram 
seems to be wrongly compressed into the scale. In my real data which has 
potentially 250 bins the problem becomes much more pronounced. Has any one else 
noticed this? Is there a work around?

I could just use a frquency polygon as suffested by Hadley but on a 6 x 3 facet 
grid solid blocks are considerably more eye catching.

Thanks for any help
Sandy

Sandy Small
Clinical Physicist
NHS Forth Valley
(Tel: 01324567002)
and
NHS Greater Glasgow and Clyde
(Tel: 01412114592)

From: ONKELINX, Thierry [thierry.onkel...@inbo.be]
Sent: 30 November 2010 14:57
To: Small Sandy (NHS Greater Glasgow & Clyde); r-help@r-project.org
Subject: RE: [R] ggplot2 histograms

Dear Sandy,

Have a look at the position argument of geom_histogram.

ggplot(data=dafr, aes(x = d1, fill=d2)) + geom_histogram(binwidth = 1,
position = position_dodge())
ggplot(data=dafr, aes(x = d1, fill=d2)) + geom_histogram(binwidth = 1,
position = position_dodge(width = 0.5), alpha = 0.5)

Best regards,

Thierry



ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek
team Biometrie & Kwaliteitszorg
Gaverstraat 4
9500 Geraardsbergen
Belgium

Research Institute for Nature and Forest
team Biometrics & 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 Small Sandy (NHS
> Greater Glasgow & Clyde)
> Verzonden: dinsdag 30 november 2010 15:37
> Aan: r-help@r-project.org
> Onderwerp: [R] ggplot2 histograms
>
> Hi
>
> With ggplot2 I can very easily create beautiful histograms
> but I would like to put two histograms on the same plot. The
> histograms may be over-lapping.
> When they are overlapping the bars are shown on top of each
> other (so that the overall height is the sum of the two). Is
> there any way to get them to display overlapping (with
> smaller value in front, larger value behind) so that the
> overall height is equal to the height of the largest value
>
> The following demonstrates the problem (there is probably a
> simple way to generate the sequence in d1 but I don't know it
> and just threw this together quickly)
> d1<-c(1,2,2,3,3,3,4,4,4,4,5,5,5,5,5,6,6,6,6,7,7,7,8,8,9,6,7,7,
8,8,8,9,9,9,9,10,10,10,10,10,11,11,11,11,12,12,12,13,13,14,15,15,16,16,1
6,17,17,17,17,18,18,18,18,18)
>
> d2<-c(rep("a",25), rep("b",39))
> dafr<-data.frame(d1,d2)
>
> library(ggplot)
> qplot(d1, data=dafr, fill=d2, geom='histogram', binwidth = 1)
>
> Many thanks for any help
> Sandy
>
> Sandy Small
> Clinical Physicist
> NHS Forth Valley
> and
> NHS Greater Glasgow and Clyde
>
>
> **
> **
>
> This message may contain confidential information. If
> yo...{{dropped:24}}
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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 message may contain confidential information. If you are not the intended 
recipient please inform the
sender that you have received the message in error before deleting it.
Please do not disclose, copy or distribute information in this e-mail or take 
any action in reliance on its conte

[R] mailing list subscription

2010-12-01 Thread dondom


[[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] Pass an operator to function

2010-12-01 Thread Duncan Murdoch

On 30/11/2010 9:54 PM, randomcz wrote:


Hi guys,

How to pass an operator to a function. For example,

test<- function(a, ">", b)
{
   return(a>b) #the operator is passed as an argument
}

Thanks,



It's much simpler than the other suggestions.  Just pass the operator, 
and treat it as a function.  (Most examples assume you're passing the 
name of the operator and have to retrieve the function.  No need for 
that.)  The only complication is that operator names are not generally 
seen simply as identifiers by the parser, so they need backquotes when 
you refer to them.


So the function can simply be

test <- function(a, op, b) {
  op(a,b)
}

and then you put the operator in back quotes to pass it:

> test(4, `<`, 5)
[1] TRUE

> test(4, `>`, 5)
[1] FALSE

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] .Internal(download())

2010-12-01 Thread Duncan Murdoch

On 01/12/2010 5:12 AM, Koray Kaya wrote:

Hello, I tried to use GEOQuery package of BioC. It does not download GSE. I investigated 
problem, understood that the problem was about internal function "download". 
Reccomendations about it mostly suggest switching any proxy off in R. I did, and nothing 
changed.
I use Ubuntu Lucid 64 bit
Thanks


You posted this twice, but in neither case did you post anything usable 
to answer the question.  Please read the posting guide.  (But you might 
want to post this question to a Bioconductor list:  it looks like a 
problem with GEOQuery, not a general R problem.  Packages shouldn't 
normally call .Internal() functions.)


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] Lattice dotplots

2010-12-01 Thread barbara . chaves
Dear, 

I have a dataset with 4 subjects (see ID in example), and 4 treatment (see 
TRT in example) which are tested on 2 locations and in 3 blocs. By using 
Lattice dotplot, I made a graph that shows the raw data per location and 
per bloc. In that graph, I would like to have a reference line per bloc 
that refers to the first treatment (T1). However, I can not find how to do 
that. 

I can make a dotplot with a reference line which is the average of all 
treatments (see 2) in example). Under 3), I used the code "panel.abline 
(v=mean(x [y=="E" & TRT =="T1"],na.rm=TRUE),col="green", lty=2)" by which 
I hoped to set the reference line at 'T1', but than I get the error that 
'object TRT is missing'. 

Does anybody know a solution? 

Thanks in advance!
regards,
Barbara


EXAMPLE:



library(lattice)

# 1) example dataset
#-
dataset <- expand.grid (LOC=c("LOC1", "LOC2"),
BLOC=c(1,2,3),
ID=c("A", "B", "C", "D", 
"E"),
TRT=c("T1", "T2", "T3", 
"T4"))
 
dataset$COL <- ifelse(dataset$TRT == "T1", "green",
ifelse(dataset$TRT == "T2", "blue"
,
ifelse(dataset$TRT 
== "T3","orange","red"))) 
 
dataset$ID.TRT <- as.factor(paste(dataset$ID,dataset$TRT,sep="."))

dataset$OUT <- sample(50:60, 120, replace=TRUE)
 
#edit(dataset)

dataset <- dataset[order(dataset$LOC,dataset$BLOC,dataset$ID), ]

# 2) dotplot with reference line that is average of all treatments
#--
dotplot (ID ~ OUT | as.factor(BLOC) * LOC, 
data=dataset,pch=c(19,4,17,15),ylab="",xlab="OUT",
scales=list(alternating=FALSE,cex=0.6), 
fill.color = dataset$COL,
panel = function(x, y, fill.color, ..., subscripts) {
fill <- fill.color [subscripts]
panel.dotplot(x, y,  col = fill, ...)
panel.abline (v=mean(x [y=="E"],na.rm=TRUE),col=
"green", lty=2)
},
main = "Raw OUT Data",
key = list( space ="bottom",
columns=2,
cex=0.8,
pch=19,
border=TRUE,
text= list(c("T1","T2","T3","T4")),
points = list(col=c("green","blue",
"Orange","Red"),pch=c(19,4,17,15

# 3) dotplot with error in reference line because 'TRT is missing'
#
dotplot (ID ~ OUT | as.factor(BLOC) * LOC, 
data=dataset,pch=c(19,4,17,15),ylab="",xlab="OUT",
scales=list(alternating=FALSE,cex=0.6), 
fill.color = dataset$COL,
panel = function(x, y, fill.color,ID.TRT, ..., subscripts) 
{
fill <- fill.color [subscripts]
panel.dotplot(x, y,  col = fill, ...)
panel.abline (v=mean(x [y=="E" & TRT =="T1"]
,na.rm=TRUE),col="green", lty=2)
},
main = "Raw OUT Data",
key = list( space ="bottom",
columns=2,
cex=0.8,
pch=19,
border=TRUE,
text= list(c("T1","T2","T3","T4")),
points = list(col=c("green","blue",
"Orange","Red"),pch=c(19,4,17,15

The information contained in this e-mail is for the excl...{{dropped:14}}

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


Re: [R] reference text variables as column name to plot [SOLVED]

2010-12-01 Thread Graves, Gregory
The following works nicely.  Thank you.

plot(z, sf[[s]], type="l")  #where the dataframe name in my case is "sf"

Sorry - I meant to say there were 24 rows in each column, so z=1:24

Gregory A. Graves, Lead Scientist
Everglades REstoration COoordination and VERification (RECOVER) 
Restoration Sciences Department
South Florida Water Management District
Phones:  DESK: 561 / 682 - 2429 
       CELL:  561 / 719 - 8157


-Original Message-
From: David Winsemius [mailto:dwinsem...@comcast.net] 
Sent: Tuesday, November 30, 2010 11:50 AM
To: Graves, Gregory
Cc: r-help@r-project.org
Subject: Re: [R] reference text variables as column name to plot


On Nov 30, 2010, at 11:40 AM, Graves, Gregory wrote:

> Having given myself carpal tunnel looking for answer to this ...
>
>
>
> I have a dataset

Named what?

> each column of which has 12 rows in it.  I created a
> variable 'z' as follows:
>
>
>
> z=1:24  s


Why did you put twice as many elements in z as there are in a column?

>
>
>
> Since I have a large number of these plots to make, and they are a bit
> complex, I want to want to reference the column I want to plot via a
> variable containing the name of that column.  As follows:
>
>
>
> similar='1978'
>
> s=paste('Y',similar,sep='')
>
>
>
> variable s now contains 'Y1978' which is the name of one of the  
> columns.
>
>
>
> However, when I try to plot
>
>
>
> plot(z,s,type='l')

Try this ... assuming that there really are 12 item length columns in  
a dataframe named, dfm.

plot(1:12, dfm[[s]], type="l")

dataframes are lists that can be accessed by the names of columns  
which are interpreted. Don't assume that you can get such  
interpretation with the $ operator.
>
>
>
> I get a 'x and y lengths differ' error because variable s is being
> recognized as 'Y1978' length=1, rather than the contents of the column
> Y1978 length=12.
>
> I tried all the usual tricks I know like &s.

Huh? "&" is a logical operator.

>  How do you get R to
> reference a variable as a column name?
>
>
>
> Thank you.
>
>
>
> Gregory A. Graves, Lead Scientist
>
> Everglades REstoration COoordination and VERification (RECOVER)
>
> Restoration Sciences Department
>
> South Florida Water Management District
>
> Phones:  DESK: 561 / 682 - 2429
>
>   CELL:  561 / 719 - 8157
>
>
>
>
>   [[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.

David Winsemius, MD
West Hartford, CT

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


Re: [R] Problem in reading Excel spreadsheets

2010-12-01 Thread Gabor Grothendieck
On Wed, Dec 1, 2010 at 2:56 AM, Stephen Liu  wrote:
> Hi folks,
>
> Win 7 64bit
> R 2.12.0 32bit
>
> Problem in reading Excel spreadsheets
>

There are quite a few alternatives for reading Excel spreadsheets.
They are listed here:
http://rwiki.sciviews.org/doku.php?id=tips:data-io:ms_windows


-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.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] Where is gdata?

2010-12-01 Thread Gabor Grothendieck
On Sun, Nov 28, 2010 at 6:44 AM, Stephen Liu  wrote:
> Hi folks,
>
> Win 7 64 bit
> R 32 bit
>
>> install.packages("gregmisc")
> Installing package(s) into 
> ‘C:\Users\satimiswin764\Documents/R/win-library/2.12’
> (as ‘lib’ is unspecified)
> --- Please select a CRAN mirror for use in this session ---
> also installing the dependency ‘gmodels’
>
> trying URL
> 'http://cran.ms.unimelb.edu.au/bin/windows/contrib/2.12/gmodels_2.15.0.zip'
> Content type 'application/zip' length 76016 bytes (74 Kb)
> opened URL
> downloaded 74 Kb
>
> trying URL
> 'http://cran.ms.unimelb.edu.au/bin/windows/contrib/2.12/gregmisc_2.1.1.zip'
> Content type 'application/zip' length 97482 bytes (95 Kb)
> opened URL
> downloaded 95 Kb
>
> package 'gmodels' successfully unpacked and MD5 sums checked
> package 'gregmisc' successfully unpacked and MD5 sums checked
>
> The downloaded packages are in
>        
> C:\Users\satimiswin764\AppData\Local\Temp\RtmpP3dNfa\downloaded_packages
>
> Installation went through without problem.
>
>
>> library(gregmisc)
> Loading required package: gmodels
> Loading required package: gplots
> Loading required package: gtools
> Loading required package: caTools
> Loading required package: bitops
> Loading required package: grid
>
> Attaching package: 'gplots'
>
> The following object(s) are masked from 'package:stats':
>
>    lowess
>
> Warning message:
>
>        The `gregmisc' *package* has converted into a *bundle*
>        containing four sub-packages: gdata, gtools, gmodels, and gplots.
>        Please load these packages directly.
>
>
>> library(gdata)
>> gdata
> Error: object 'gdata' not found
>
>> gdata()
> Error: could not find function "gdata"
>
>
> Please advise what mistake I have committed.  TIA

In the end it appears that there was no problem in accessing the gdata
package or any of its components and that the poster's problem stemmed
from issuing this series of commands:

library(AER)
data()

at which point the poster saw the names of AER data files listed and
assumed that the data() command showed the data set names of the last
loaded library.  Based on this assumption when he issued this series
of commands:

library(gdata)
data()

and saw AER listed again he thought that gdata had not been loaded.
In fact the data() command lists the names of the data sets of *all*
installed packages, and not just the last loaded one, so if AER is the
alphabetically first package that is installed it will always appear
first.  Thus to view gdata's data set names in this list one would
have to scroll down to view the names off the screen.

Things which confused the issue further were that the poster was using
a virtual machine to run R, which might have caused problems in
determining where the library was located but in fact did not, and one
responder somehow assumed that the question related to read.xls (a
function in gdata) and its perl dependency but as indicated the
problem actually had nothing specifically to do with gdata at all much
less read.xls or perl.

-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.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] Welcome to the "R-help" mailing list

2010-12-01 Thread Ista Zahn
Hi Bill,
Please keep the R list copied.

I don't think you've given enough information to pin down your
problem. This works:

dat <- read.table(textConnection("dates  returns
2000-1-4 -0.038344718
2000-1-50.00195
2000-1-60.000955702
2000-1-70.027090384
2000-1-100.011189966
2000-1-11-0.013062569
2000-1-12-0.004386331
2000-1-130.012169663
2000-1-140.010671321
2000-1-18-0.006832065
2000-1-190.000522287
2000-1-20-0.007095268
2000-1-21-0.002912346"), header=TRUE)
closeAllConnections()

attach(dat)

i=1
while(i<14){
if(weekdays(as.Date(dates[i])) == "Monday"){
print ("yes")
}
else {
print("no")

}
i=1+i

}

detach(dat)

Best,
Ista

On Tue, Nov 30, 2010 at 11:22 PM, Bill Yang  wrote:
> Hi Ista,
> I appreciate for your reply.
> I am running into another problem now, the following is my date (example)
> 2000-1-4     -0.038344718
> 2000-1-5    0.00195
> 2000-1-6    0.000955702
> 2000-1-7    0.027090384
> 2000-1-10    0.011189966
> 2000-1-11    -0.013062569
> 2000-1-12    -0.004386331
> 2000-1-13    0.012169663
> 2000-1-14    0.010671321
> 2000-1-18    -0.006832065
> 2000-1-19    0.000522287
> 2000-1-20    -0.007095268
> 2000-1-21    -0.002912346
> Let's focus on the dates, by using weekdays(as.Date('2010-11-30')) ==
> "Monday", im supposed to find the monday return (2nd column)
> i create an array which includes the dates, let's call it dates. then when i
> plug in the dates into the following codes
> i=1
> while(i<14){
> if(weekdays(as.Date(dates[i])) == "Monday"){
> pirnt ("yes")
> }
> else {
> print("no")
> }
> i=1+i
> }
> the programe does not run properly...cuz im expecting to see "yes" been
> returned (there is not any "no" returned, all of them are "yes"..). i
> guess dates[i] returns "2010-1-1", but the as.Date requires '2010-1-1'..
> please help me out. I appreciate.
> Bill
>
>
>> From: iz...@psych.rochester.edu
>> Date: Tue, 30 Nov 2010 21:59:50 -0500
>> Subject: Re: [R] Welcome to the "R-help" mailing list
>> To: gy631...@hotmail.com
>> CC: r-help@r-project.org
>>
>> Hi Bill,
>> You might be working too hard. Consider:
>> > weekdays(as.Date('2010-11-30')) == "Monday"
>> [1] FALSE
>> > weekdays(as.Date('2010-11-29')) == "Monday"
>> [1] TRUE
>> >
>>
>> HTH,
>> Ista
>>
>> On Tue, Nov 30, 2010 at 9:40 PM, Bill Yang  wrote:
>> >
>> > Hi there,
>> > I am having problem of matching string. what i want is when i type a
>> > date such as 2010-11-30, the function will return the day (monday, tuesday,
>> > wednesday, thursday, friday or staturday). then i want another function 
>> > will
>> > return true if the return of the day is monday, return false if the return
>> > of the day is not monday.
>> > I already find the weekdays(as.Date('2010-11-30')) function which will
>> > tell me exactly what day its gonna be. however, i am having problem of
>> > return True or False whether or not the return day has matched.
>> > please help me out. I appreciate.
>> > Bill
>> > P.S the following is the partial
>> > codes.if(match(weekdays(as.Date('2010-11-30'), "Monday")==1){print("yes")}
>> >
>> >
>> >
>> > r-help@r-project.org
>> >> Subject: Welcome to the "R-help" mailing list
>> >> From: r-help-requ...@r-project.org
>> >> To: gy631...@hotmail.com
>> >> Date: Wed, 1 Dec 2010 03:34:01 +0100
>> >>
>> >> Welcome to the R-help@r-project.org mailing list!
>> >>
>> >> To post to this list, send your email to:
>> >>
>> >>   r-help@r-project.org
>> >>
>> >> General information about the mailing list is at:
>> >>
>> >>   https://stat.ethz.ch/mailman/listinfo/r-help
>> >>
>> >> If you ever want to unsubscribe or change your options (eg, switch to
>> >> or from digest mode, change your password, etc.), visit your
>> >> subscription page at:
>> >>
>> >>   https://stat.ethz.ch/mailman/options/r-help/gy631223%40hotmail.com
>> >>
>> >> You can also make such adjustments via email by sending a message to:
>> >>
>> >>   r-help-requ...@r-project.org
>> >>
>> >> with the word `help' in the subject or body (don't include the
>> >> quotes), and you will get back a message with instructions.
>> >>
>> >> You must know your password to change your options (including changing
>> >> the password, itself) or to unsubscribe.  It is:
>> >>
>> >>   8711208752
>> >>
>> >> Normally, Mailman will remind you of your r-project.org mailing list
>> >> passwords once every month, although you can disable this if you
>> >> prefer.  This reminder will also include instructions on how to
>> >> unsubscribe or change your account options.  There is also a button on
>> >> your options page that will email your current password to you.
>> >
>> >        [[alternative HTML version deleted]]
>> >
>> > __
>> > R-help@r-project.org mailing list
>> > https://stat.ethz.ch/mailman/listinfo/r-help
>> > PLEASE do read the posting guide
>> > http://www.R-project.org/posting-guide.html
>> > and provide commented, minimal, self-contained, reproducible code.
>> >
>>
>>
>>

Re: [R] pca analysis: extract rotated scores?

2010-12-01 Thread He Zhang
Hi,

I am also doing PCA.
Is the following right for extracting the scores?

library(psych)
pca<-principal(data,nfactors=,rotate="varimax",scores=T)
pca$loadings
pca$score

Best regards,
He

On Tue, Nov 30, 2010 at 10:22 AM, Liviu Andronic  wrote:
> Dear all
> I'm unable to find an example of extracting the rotated scores of a
> principal components analysis. I can do this easily for the un-rotated
> version.
>
> data(mtcars)
> .PC <- princomp(~am+carb+cyl+disp+drat+gear+hp+mpg, cor=TRUE, data=mtcars)
> unclass(loadings(.PC))  # component loadings
> summary(.PC) # proportions of variance
> mtcars$PC1 <- .PC$scores[,1] # extract un-rotated scores of 1st
> principal component
> mtcars$PC2 <- .PC$scores[,2] # extract un-rotated scores of 2nd
> principal component
> head(mtcars[, c('PC1', 'PC2')])
>
> However, I no longer understand how to do so if I want to use
> ?principal in 'psych' and any of the GPArotation methods. For example,
> require(psych)
> r <- cor(mtcars[,c("am","carb","cyl","disp","drat","gear","hp","mpg")])
> pca <- principal(r, nfactors = 8, residuals = T, rotate="none") # or
> 'varimax' or any other GPArotation supported rotation
> pca
>
> I've turned the 'pca' object and ?principal help page upside down and
> I still cannot find anything that would resemble a 'scores' value. I'm
> pretty sure it's one matrix computation away, but I cannot find which
> one.
>
> Ideas? Thank you
> Liviu
>
>
>
> --
> Do you know how to read?
> http://www.alienetworks.com/srtest.cfm
> http://goodies.xfce.org/projects/applications/xfce4-dict#speed-reader
> Do you know how to write?
> http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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


Re: [R] cluster analysis: predefined clusters

2010-12-01 Thread deriK2000


Peter Langfelder wrote:
> 
> On Fri, Nov 26, 2010 at 6:55 AM, Derik Burgert  wrote:
>> Dear list,
>>
>> running a hierachical cluster analysis I want to define a number of
>> objects that build a cluster already. In other words: I want to force
>> some of the cases to be in the same cluster from the start of the
>> algorithm.
>>
>> Any hints? Thanks in advance!
> 
> The hclust function has an argument 'members' that should allow you to
> do that. You will need to specify the dissimilarity matrix
> accordingly.
> 
> Peter
> 
> 

Thank you! But to "specify the dissimilarity matrix" correctly seems to be
major task. Anyone who has done so sofar? 
-- 
View this message in context: 
http://r.789695.n4.nabble.com/cluster-analysis-predefined-clusters-tp3060433p3067215.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] ggplot2 histograms

2010-12-01 Thread Ista Zahn
Hi Sandy,
I don't have an answer to your question, but wanted to share another
possibility:

ggplot(data=dafr, aes(x = d1, fill=d2)) + geom_histogram(binwidth = 1,
position = position_identity(), alpha=.5)

Best,
Ista

On Wed, Dec 1, 2010 at 6:09 AM, Small Sandy (NHS Greater Glasgow &
Clyde)  wrote:
> Thanks Thierry
>
> Using the position_dodge positioning option ought to work but there is 
> something wrong with the scaling when the binwidth is not = 1.
> You can begin to see this with the example I sent:
>
> If you do
> ggplot(data=dafr, aes(x = d1, fill=d2)) + geom_histogram(binwidth = 1, 
> position = position_dodge())
>
> You get the interleaved histogram you would expect
> Similarly if you do:
> ggplot(data=dafr, aes(x = d1, fill=d2)) + geom_histogram(binwidth = 2, 
> position = position_dodge())
> The histogram produced is reasonable: however
>
> However if you do:
> ggplot(data=dafr, aes(x = d1, fill=d2)) + geom_histogram(binwidth = 1, 
> position = position_dodge(width=0.99))
>
> The position of first bin which goes from 0-2 appears to start at about 0.2 
> (I accept that there is some "white space" to the left of this) while the 
> position of the last bin (16-18) appears to start at about 15.8, so the whole 
> histogram seems to be wrongly compressed into the scale. In my real data 
> which has potentially 250 bins the problem becomes much more pronounced. Has 
> any one else noticed this? Is there a work around?
>
> I could just use a frquency polygon as suffested by Hadley but on a 6 x 3 
> facet grid solid blocks are considerably more eye catching.
>
> Thanks for any help
> Sandy
>
> Sandy Small
> Clinical Physicist
> NHS Forth Valley
> (Tel: 01324567002)
> and
> NHS Greater Glasgow and Clyde
> (Tel: 01412114592)
> 
> From: ONKELINX, Thierry [thierry.onkel...@inbo.be]
> Sent: 30 November 2010 14:57
> To: Small Sandy (NHS Greater Glasgow & Clyde); r-help@r-project.org
> Subject: RE: [R] ggplot2 histograms
>
> Dear Sandy,
>
> Have a look at the position argument of geom_histogram.
>
> ggplot(data=dafr, aes(x = d1, fill=d2)) + geom_histogram(binwidth = 1,
> position = position_dodge())
> ggplot(data=dafr, aes(x = d1, fill=d2)) + geom_histogram(binwidth = 1,
> position = position_dodge(width = 0.5), alpha = 0.5)
>
> Best regards,
>
> Thierry
>
> 
> 
> ir. Thierry Onkelinx
> Instituut voor natuur- en bosonderzoek
> team Biometrie & Kwaliteitszorg
> Gaverstraat 4
> 9500 Geraardsbergen
> Belgium
>
> Research Institute for Nature and Forest
> team Biometrics & 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 Small Sandy (NHS
>> Greater Glasgow & Clyde)
>> Verzonden: dinsdag 30 november 2010 15:37
>> Aan: r-help@r-project.org
>> Onderwerp: [R] ggplot2 histograms
>>
>> Hi
>>
>> With ggplot2 I can very easily create beautiful histograms
>> but I would like to put two histograms on the same plot. The
>> histograms may be over-lapping.
>> When they are overlapping the bars are shown on top of each
>> other (so that the overall height is the sum of the two). Is
>> there any way to get them to display overlapping (with
>> smaller value in front, larger value behind) so that the
>> overall height is equal to the height of the largest value
>>
>> The following demonstrates the problem (there is probably a
>> simple way to generate the sequence in d1 but I don't know it
>> and just threw this together quickly)
>> d1<-c(1,2,2,3,3,3,4,4,4,4,5,5,5,5,5,6,6,6,6,7,7,7,8,8,9,6,7,7,
> 8,8,8,9,9,9,9,10,10,10,10,10,11,11,11,11,12,12,12,13,13,14,15,15,16,16,1
> 6,17,17,17,17,18,18,18,18,18)
>>
>> d2<-c(rep("a",25), rep("b",39))
>> dafr<-data.frame(d1,d2)
>>
>> library(ggplot)
>> qplot(d1, data=dafr, fill=d2, geom='histogram', binwidth = 1)
>>
>> Many thanks for any help
>> Sandy
>>
>> Sandy Small
>> Clinical Physicist
>> NHS Forth Valley
>> and
>> NHS Greater Glasgow and Clyde
>>
>>
>> **
>> **
>>
>> This message may contain confidential information. If
>> yo...{{dropped:24}}
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://w

Re: [R] how to remove grid lines from coplot graphs

2010-12-01 Thread Peter Ehlers

On 2010-12-01 01:51, Seth Roberts wrote:

coplot() usually puts grid lines in the panels it makes. To see examples,
example(coplot).

How can I remove those grid lines?

>
> Seth Roberts
>

That's hard-coded in coplot. But you can easily make a
modified copy of coplot. Here are the steps:

1. make a copy of coplot; call it mycoplot.
2. add this to the argument list of the function:

   col.grid = "lightgray"

3. find this line in the code:

   grid(lty = "solid")

and change it to

   grid(lty = "solid", col = col.grid)

4. source() your new function.

It wouldn't be a bad idea to also do

   environment(mycoplot) <- environment(coplot)

Now just set col.grid = "transparent"
(or col.grid = 0 should also work) when you
want to suppress the grid. This also gives you
the option of using other grid colours.

Peter Ehlers

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


[R] Plot a matrix recursively

2010-12-01 Thread alcesgabbo

Hi,

I have the following matrix (named m):
key
 sensor_date  Laser_1  Laser_2  

Laser_3
  2010-09-30T15:00:12+020063
   
1
  2010-10-31T15:05:07+010054
   
2
  2011-09-30T15:00:12+020063
   
1
  2011-10-31T15:05:07+010054
   
2

I plot the first column with the following function:
plot(m[,1],type="o", xaxt="n",ylim=c(min(m[,1:length(colnames(m))])-1,
max(m[,1:length(colnames(m))])+1))

for the other columns I use there functions:

lines(m[,2],type=\"o\")

lines(m[,3],type=\"o\")

ok, it works.

But is there a way to do this prodcedures recursively??

for example:

for each columns {
 lines(m[,column],type=\"o\")
}

I try with :

lines(m[,2:length(colnames(m))],type=\"o\")

but it doesn't work.

Thanks .
Alberto
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Plot-a-matrix-recursively-tp3067283p3067283.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] parametric estimators for species richness in R

2010-12-01 Thread yangwenjing
Dear everyone,

I am doing some work about species richness estimation. Nonparametric 
estimation (such as Chao1, Jacknife1) can be done just using function 
"specpool()" and "estimateR()" in package "vegan". The problem is that I can 
not found any functions for parametric estimation (such as MMMeans, MMruns, 
Michaelis-Menten). Do you know any function for doing this? Thanks a lot.

Best wishes,

Wenjing

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


Re: [R] Troubles using postscript(family = "ComputerModern")

2010-12-01 Thread Martin Maechler
> David Winsemius 
> on Mon, 29 Nov 2010 09:46:08 -0500 writes:

> On Nov 29, 2010, at 9:00 AM, pilchat wrote:

>> Hi guys,
>> 
>> to make it easier, here is a simple case with the same issues. I use  
>> the short function below to make the attached PS file.
>> 
>> Things to fix:
>> 
>> -) the greek letter "lambda" is not printed, while "mu" is printed  
>> (see the plot command)
>> -) the annotation inside the plot area: the "+-" symbol and "(K)"  
>> overlap with the substitute for tmed and tstd respectively (see the  
>> text command). Also, how can I set the number of decimal digits for  
>> tmed and tstd? (option(digits=4) does not work )

> I would have thought one would do any formatting (of digits) outside  
> the text( ...substitute(...),...) setting.

>> 
>> Moreover, I'd like to make the characters thicker. Is there any way?

> Which characters? There is a bold() option within plotmath.

>> Finally, once I close the R session without saving it (I answer "n"  
>> when quitting), the content of the ps file is erased.

> Now _that_ is weird. A file should have been created in your default  
> directory and closing R should not have made it go away.

>> Do I miss something in writing the function?

> Perhaps. (But you certainly missed something in writing the question.)  
> When I remove the family="ComputerModern" from the postscript call, I  
> start seeing lambda.  And the other spacing weirness also  
> resolves. I am on a Mac and ComputerModern is not one of the  
> pdfFonts() on my machine. The list of available fonts varies widely  
> across various OSes and devices about which you have given us no clues.

Well, but indeed the OP is right: there's a severe problem at
least in some cases, including my own (Linux, Fedora 13)
*iff*  "ComputerModern" is used.

I'm too time-squeezed currently to give much more details
but there *is* bug here, either in R's implementation / usage of
the "ComputerModern" family or outside R in the font (metric?)
files used or possibly even the postscript viewer (but I doubt
the last one).

Martin Maeechler, ETH Zurich


>> plot_example=function()
>> {
>> 
>> setPS()
>> postscript (file='plot_example.ps',width=5,height=5,horizontal =  
>> FALSE, paper = "special",family =  
>> "ComputerModern",encoding="TeXtext.enc")
>> 
>> tmed<-1.23456789
>> tstd<-1.23456789
>> 
>> plot 
>> (c 
>> (0,1 
>> ),c 
>> (0,1 
>> ),xlab=expression(paste(lambda,mu,T)),main="",sub="(a)")#"lambda"  
>> not printed
>> text(.0,.8,substitute( T[disk,med] == tmed %+-% tstd  
>> (K),list(tmed=tmed,tstd=tstd)),pos=4,cex=1.5  )#overlapping symbols  
>> and numbers
>> 
>> dev.off()
>> 
>> }
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.

> David Winsemius, MD
> West Hartford, CT

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

2010-12-01 Thread Jean . Coursol

Just for fun

This small program gives negative Sum of Sq in anova (with R versions  
2.9.2 and 2.10.0) (linux 32 kernel 2.6.29.6-smp slackware 13.0) :


y = c(3.6, 5.0, 5.0, 4.6, 4.5, 4.3, 4.5, 5.1, 4.5, 4.3)
trans = as.factor(c("NT","NT","NT","NT","NT","T","T","T","T","T"))
lc = lm(y ~ trans)
l1 = lm(y ~ 1)

anova(l1,lc)

# Analysis of Variance Table
#
# Model 1: y ~ 1
# Model 2: y ~ trans
#   Res.Df   RSS Df  Sum of Sq F Pr(>F)
# 1  9 1.744
# 2  8 1.744  1 -2.220e-16   # negative Sum of Sq 

anova(lc)  # is OK

# 2.9.2 version
# Analysis of Variance Table
#
# Response: y
#   DfSum Sq   Mean Sq   F value Pr(>F)
# trans  1 8.214e-32 8.214e-32 3.768e-31  1
# Residuals  8 1.744 0.218

# 2.10.0 version
# Analysis of Variance Table
#
# Response: y
#   Df Sum Sq Mean Sq F value Pr(>F)
# trans  1  0.000   0.000   0  1
# Residuals  8  1.744   0.218

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

2010-12-01 Thread nqueralt
Hi everybody,
 
 
 
I am a beginner in the steps of pre-processing and data analysis of 
non-targeted metabolomic profiling experiments. 
Anyone knows if there exists some tool for normalizing this type of data (raw 
data or XCMS matrix data) 
in R repositories? Many thanks in advance.
 
 
 
Best regards,
 
 
 
Núria

 

 

---
Núria Queralt Rosinach, Ph.D

Bioinformatics technician
Bioinformatics Unit 
IDIBAPS
Edifici CEK
C/ Rosselló, 153
08036 Barcelona
TE: +34 93 227 5400 (ext 4523)

Email: nquer...@clinic.ub.es
Web: http://bioinformatics.fcrb.es/bioinformatics/




[[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] Plot a matrix recursively

2010-12-01 Thread Gerrit Eichner

Take a look at

?matplot

HTH,

Gerrit


On Wed, 1 Dec 2010, alcesgabbo wrote:



Hi,

I have the following matrix (named m):
   key
sensor_date  Laser_1  Laser_2
Laser_3
 2010-09-30T15:00:12+020063
1
 2010-10-31T15:05:07+010054
2
 2011-09-30T15:00:12+020063
1
 2011-10-31T15:05:07+010054
2

I plot the first column with the following function:
plot(m[,1],type="o", xaxt="n",ylim=c(min(m[,1:length(colnames(m))])-1,
max(m[,1:length(colnames(m))])+1))

for the other columns I use there functions:

lines(m[,2],type=\"o\")

lines(m[,3],type=\"o\")

ok, it works.

But is there a way to do this prodcedures recursively??

for example:

for each columns {
lines(m[,column],type=\"o\")
}

I try with :

lines(m[,2:length(colnames(m))],type=\"o\")

but it doesn't work.

Thanks .
Alberto
--
View this message in context: 
http://r.789695.n4.nabble.com/Plot-a-matrix-recursively-tp3067283p3067283.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.



-
AOR Dr. Gerrit Eichner   Mathematical Institute, Room 212
gerrit.eich...@math.uni-giessen.de   Justus-Liebig-University Giessen
Tel: +49-(0)641-99-32104  Arndtstr. 2, 35392 Giessen, Germany
Fax: +49-(0)641-99-32109http://www.uni-giessen.de/cms/eichner

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


Re: [R] Plot a matrix recursively

2010-12-01 Thread Roland Rau

On 12/01/2010 02:43 PM, alcesgabbo wrote:


I plot the first column with the following function:
plot(m[,1],type="o", xaxt="n",ylim=c(min(m[,1:length(colnames(m))])-1,
max(m[,1:length(colnames(m))])+1))

for the other columns I use there functions:

lines(m[,2],type=\"o\")

lines(m[,3],type=\"o\")

ok, it works.

But is there a way to do this prodcedures recursively??

for example:

for each columns {
  lines(m[,column],type=\"o\")
}

I try with :

lines(m[,2:length(colnames(m))],type=\"o\")


Is there a special need to do it recursively?

Would the following not do the trick, too?

m <- matrix(c(1,6,3,2,5,4,3,6,3,4,5,4), byrow=TRUE, ncol=3)
matplot(m, type="o", xaxt="n",ylim=c(min(m[,1:length(colnames(m))])-1,
max(m[,1:length(colnames(m))])+1),
lty=1, col="black")

Or simply:
matplot(m, type="o", xaxt="n", lty=1, col="black")

Hope this helps,
Roland

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

2010-12-01 Thread Peter Ehlers

On 2010-12-01 04:02, barbara.cha...@bayer.com wrote:

Dear,

I have a dataset with 4 subjects (see ID in example), and 4 treatment (see
TRT in example) which are tested on 2 locations and in 3 blocs. By using
Lattice dotplot, I made a graph that shows the raw data per location and
per bloc. In that graph, I would like to have a reference line per bloc
that refers to the first treatment (T1). However, I can not find how to do
that.

I can make a dotplot with a reference line which is the average of all
treatments (see 2) in example). Under 3), I used the code "panel.abline
(v=mean(x [y=="E"&  TRT =="T1"],na.rm=TRUE),col="green", lty=2)" by which
I hoped to set the reference line at 'T1', but than I get the error that
'object TRT is missing'.

Does anybody know a solution?


Try this (I've stripped out the unnecessary stuff; what
is it about *minimal* that seems to elude people?):

  p <- dotplot (ID ~ OUT | as.factor(BLOC) * LOC,
 data=dataset,pch=c(19,4,17,15),ylab="",xlab="OUT",
 fill.color = dataset$COL,
 TRT = dataset$TRT,
 panel = function(x, y, fill.color, TRT, ..., subscripts) {
   fill <- fill.color [subscripts]
   panel.dotplot(x, y,  col = fill, ...)
   panel.abline (v=mean(x[y=="A" & TRT =="T1"], na.rm=TRUE),
 col="green", lty=2)
 }
  )
  print(p)

Peter Ehlers



Thanks in advance!
regards,
Barbara


EXAMPLE:



library(lattice)

# 1) example dataset
#-
dataset<- expand.grid (LOC=c("LOC1", "LOC2"),
 BLOC=c(1,2,3),
 ID=c("A", "B", "C", "D",
"E"),
 TRT=c("T1", "T2", "T3",
"T4"))

dataset$COL<- ifelse(dataset$TRT == "T1", "green",
 ifelse(dataset$TRT == "T2", "blue"
,
 ifelse(dataset$TRT
== "T3","orange","red")))

dataset$ID.TRT<- as.factor(paste(dataset$ID,dataset$TRT,sep="."))

dataset$OUT<- sample(50:60, 120, replace=TRUE)

#edit(dataset)

dataset<- dataset[order(dataset$LOC,dataset$BLOC,dataset$ID), ]

# 2) dotplot with reference line that is average of all treatments
#--
dotplot (ID ~ OUT | as.factor(BLOC) * LOC,
 data=dataset,pch=c(19,4,17,15),ylab="",xlab="OUT",
 scales=list(alternating=FALSE,cex=0.6),
 fill.color = dataset$COL,
 panel = function(x, y, fill.color, ..., subscripts) {
 fill<- fill.color [subscripts]
 panel.dotplot(x, y,  col = fill, ...)
 panel.abline (v=mean(x [y=="E"],na.rm=TRUE),col=
"green", lty=2)
 },
 main = "Raw OUT Data",
 key = list( space ="bottom",
 columns=2,
 cex=0.8,
 pch=19,
 border=TRUE,
 text= list(c("T1","T2","T3","T4")),
 points = list(col=c("green","blue",
"Orange","Red"),pch=c(19,4,17,15

# 3) dotplot with error in reference line because 'TRT is missing'
#
dotplot (ID ~ OUT | as.factor(BLOC) * LOC,
 data=dataset,pch=c(19,4,17,15),ylab="",xlab="OUT",
 scales=list(alternating=FALSE,cex=0.6),
 fill.color = dataset$COL,
 panel = function(x, y, fill.color,ID.TRT, ..., subscripts)
{
 fill<- fill.color [subscripts]
 panel.dotplot(x, y,  col = fill, ...)
 panel.abline (v=mean(x [y=="E"&  TRT =="T1"]
,na.rm=TRUE),col="green", lty=2)
 },
 main = "Raw OUT Data",
 key = list( space ="bottom",
 columns=2,
 cex=0.8,
 pch=19,
 border=TRUE,
 text= list(c("T1","T2","T3","T4")),
 points = list(col=c("green","blue",
"Orange","Red"),pch=c(19,4,17,15

The information contained in this e-mail is for the excl...{{dropped:14}}

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

Re: [R] anova error

2010-12-01 Thread Peter Ehlers

It might be a good idea not to use an outdated version of R.
I don't see your "problem" in R 2.12.0.

Peter Ehlers

On 2010-12-01 05:44, jean.cour...@math.u-psud.fr wrote:

Just for fun

This small program gives negative Sum of Sq in anova (with R versions
2.9.2 and 2.10.0) (linux 32 kernel 2.6.29.6-smp slackware 13.0) :

y = c(3.6, 5.0, 5.0, 4.6, 4.5, 4.3, 4.5, 5.1, 4.5, 4.3)
trans = as.factor(c("NT","NT","NT","NT","NT","T","T","T","T","T"))
lc = lm(y ~ trans)
l1 = lm(y ~ 1)

anova(l1,lc)

# Analysis of Variance Table
#
# Model 1: y ~ 1
# Model 2: y ~ trans
#   Res.Df   RSS Df  Sum of Sq F Pr(>F)
# 1  9 1.744
# 2  8 1.744  1 -2.220e-16   # negative Sum of Sq 

anova(lc)  # is OK

# 2.9.2 version
# Analysis of Variance Table
#
# Response: y
#   DfSum Sq   Mean Sq   F value Pr(>F)
# trans  1 8.214e-32 8.214e-32 3.768e-31  1
# Residuals  8 1.744 0.218

# 2.10.0 version
# Analysis of Variance Table
#
# Response: y
#   Df Sum Sq Mean Sq F value Pr(>F)
# trans  1  0.000   0.000   0  1
# Residuals  8  1.744   0.218

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

2010-12-01 Thread Mark Difford

Hi He Zhang,

>> Is the following right for extracting the scores?
>> ...
>> pca$loadings 
>> pca$score

Yes.

But you should be aware that the function principal() in package psych is
standardizing your data internally, which you might not want. That is, the
analysis is being based on the correlation matrix rather than on the
covariance matrix. The two analyses (and the "default" biplots that issue
from them) have somewhat different properties. You should know about these.

Regards, Mark.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/pca-analysis-extract-rotated-scores-tp3065061p3067370.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] Lattice dotplots

2010-12-01 Thread Dieter Menne


barbara.chaves wrote:
> 
> 
> I have a dataset with 4 subjects (see ID in example), and 4 treatment (see 
> TRT in example) which are tested on 2 locations and in 3 blocs. By using 
> Lattice dotplot, I made a graph that shows the raw data per location and 
> per bloc. In that graph, I would like to have a reference line per bloc 
> that refers to the first treatment (T1). However, I can not find how to do 
> that. 
> ...
> 

Thanks a lot for the nice self-contained example which certainly has cost
you some time. A bit of nitpicking: You could have improved it a little by
removing decorative stuff and using a lower degree of indentation to avoid
ugly line breaks in email. 

You were close by, but I believe that you ran into the trap of believing
that the dot in ID.TRT is something special in variable names as it is in c
or Pascal. The dot in names has sometimes a meaning for functions (try
methods("print")) but it is not possible to "get a part of it" in panel.dot. 

The workaround is simple: pass TRT, not ID.TRT. Everything else was fine,
some minor modifications were added.

Dieter

# Begin code
dataset <- expand.grid (
  LOC=c("LOC1", "LOC2"),
  # Better make it a factor immediately to avoid surprises later
  BLOC=as.factor(c(1,2,3)),
  ID=c("A", "B", "C", "D","E"),
  TRT=c("T1", "T2", "T3","T4"))
# replaced nested ifelse
dataset$COL <- factor(dataset$TRT,labels=c("green", "blue","orange","red"))

dataset$ID.TRT <- as.factor(paste(dataset$ID,dataset$TRT,sep="."))
dataset$OUT <- sample(50:60, 120, replace=TRUE)

# removed "as.factor". Corrected TRT
dotplot (ID ~ OUT | BLOC * LOC,
  data=dataset,pch=c(19,4,17,15),
  TRT = dataset$TRT,
  fill.color = dataset$COL,
  panel = function(x, y, TRT, ..., subscripts)
  {
panel.dotplot(x, y,fill=fill.color,  ...)
panel.abline (v=mean(x [y=="E" & TRT =="T1"],na.rm=TRUE),col="green",
lty=2)
  })
   

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Lattice-dotplots-tp3067130p3067382.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] Searching for packages for normalizing Metabolomic data

2010-12-01 Thread Martin Morgan
On 12/01/2010 05:57 AM, nquer...@clinic.ub.es wrote:
> Hi everybody,
>  
>  
>  
> I am a beginner in the steps of pre-processing and data analysis of 
> non-targeted metabolomic profiling experiments. 
> Anyone knows if there exists some tool for normalizing this type of data (raw 
> data or XCMS matrix data) 
> in R repositories? Many thanks in advance.

Bioconductor has several packages that might be appropriate, e.g., xcms.
Starting points;

http://bioconductor.org/help/bioc-views/release/BiocViews.html#___MassSpectrometry

http://bioconductor.org/help/bioc-views/release/bioc/

http://bioconductor.org/help/mailing-list/
(subscription required to post)

http://bioconductor.org/install/

Martin

>  
>  
>  
> Best regards,
>  
>  
>  
> Núria
> 
>  
> 
>  
> 
> ---
> Núria Queralt Rosinach, Ph.D
> 
> Bioinformatics technician
> Bioinformatics Unit 
> IDIBAPS
> Edifici CEK
> C/ Rosselló, 153
> 08036 Barcelona
> TE: +34 93 227 5400 (ext 4523)
> 
> Email: nquer...@clinic.ub.es
> Web: http://bioinformatics.fcrb.es/bioinformatics/
> 
> 
> 
> 
>   [[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.


-- 
Computational Biology
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109

Location: M1-B861
Telephone: 206 667-2793

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


Re: [R] Where is gdata?

2010-12-01 Thread Gavin Simpson
On Wed, 2010-12-01 at 07:32 -0500, Gabor Grothendieck wrote:
> On Sun, Nov 28, 2010 at 6:44 AM, Stephen Liu  wrote:

> 
> In the end it appears that there was no problem in accessing the gdata
> package or any of its components and that the poster's problem stemmed
> from issuing this series of commands:
> 
> library(AER)
> data()
> 
> at which point the poster saw the names of AER data files listed and
> assumed that the data() command showed the data set names of the last
> loaded library.  Based on this assumption when he issued this series
> of commands:

Indeed. And I informed Mr Liu of *this* very point in a separate thread
(How to remove a package?) [1] where he also had failed to look at what
data() was actually outputting.

So we have two long, tedious threads both arising because Mr Liu i)
keeps making assumptions about what is going on rather than bothering to
find out what really is going on, and ii) failed to (or didn't bother
to) or did not comprehend the various ?data or ?library help pages.

This is why people get annoyed with the way certain members of this list
abuse it by resorting to a 'send-email-first' approach to problem
solving.

Mr Liu - please note the above (you seem to have totally disregarded
what I wrote in the previous thread!) and in future use the list
responsibly. People here give of their time freely and you should not
abuse that generosity. The inconvenience of having to delete 30+ emails
I consider an abuse of this list - for those who might argue that I
could just delete Mr Liu's emails if I was not interested in them or his
problems.

Finally - thank you Gabor for persevering with Mr Liu to the extent that
his problem has been solved.

Gavin

[1]
http://article.gmane.org/gmane.comp.lang.r.general/212725/match=simpson

> library(gdata)
> data()
> 
> and saw AER listed again he thought that gdata had not been loaded.
> In fact the data() command lists the names of the data sets of *all*
> installed packages, and not just the last loaded one, so if AER is the
> alphabetically first package that is installed it will always appear
> first.  Thus to view gdata's data set names in this list one would
> have to scroll down to view the names off the screen.
> 
> Things which confused the issue further were that the poster was using
> a virtual machine to run R, which might have caused problems in
> determining where the library was located but in fact did not, and one
> responder somehow assumed that the question related to read.xls (a
> function in gdata) and its perl dependency but as indicated the
> problem actually had nothing specifically to do with gdata at all much
> less read.xls or perl.
> 

-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 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] ggplot2 histograms

2010-12-01 Thread Hadley Wickham
> However if you do:
> ggplot(data=dafr, aes(x = d1, fill=d2)) + geom_histogram(binwidth = 1, 
> position = position_dodge(width=0.99))
>
> The position of first bin which goes from 0-2 appears to start at about 0.2 
> (I accept that there is some "white space" to the left of this) while the 
> position of the last bin (16-18) appears to start at about 15.8, so the whole 
> histogram seems to be wrongly compressed into the scale. In my real data 
> which has potentially 250 bins the problem becomes much more pronounced. Has 
> any one else noticed this? Is there a work around?

What do you expect this to do?  The bars are one unit wide, but you've
told position_dodge to treat them like they're only 0.99 units wide.

Hadley

-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/

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


[R] attempted merge() returns: cannot coerce type 'closure' to vector of type 'any'

2010-12-01 Thread Karl Brand

Hi Dimtris and esteemed useRs,

I don't understand why i get this error message when attempting to use 
merge() -


> temp <- merge(x, y[,17, drop=FALSE], by=rownames, sort=FALSE)
Error in as.vector(x, mode) :
  cannot coerce type 'closure' to vector of type 'any'

It should work because:

> all(rownames(x[order(rownames(x)),]) ==
+ rownames(y[order(rownames(y[,17, drop=FALSE])),17, drop=FALSE])  
[TRUNCATED]

[1] TRUE

also:

> class(x); class(y[,17, drop=FALSE])
[1] "matrix"
[1] "matrix"


Any idea why i cant use merge() in the normal way here? I'm forced to 
add the column using:


temp.b <- cbind(x, y[match(rownames(x), rownames(y)),17])

All insights appreciated for this leaRner,

cheers,

Karl


--
Karl Brand 
Department of Genetics
Erasmus MC
Dr Molewaterplein 50
3015 GE Rotterdam
P +31 (0)10 704 3211 | F +31 (0)10 704 4743 | M +31 (0)642 777 268

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


Re: [R] Plot a matrix recursively

2010-12-01 Thread alcesgabbo

thanks!
very useful
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Plot-a-matrix-recursively-tp3067283p3067443.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] anova error

2010-12-01 Thread Ben Bolker


Peter Ehlers  ucalgary.ca> writes:

> 
> It might be a good idea not to use an outdated version of R.
> I don't see your "problem" in R 2.12.0.
> 
> Peter Ehlers
> 
> On 2010-12-01 05:44, Jean.Coursol  math.u-psud.fr wrote:
> > Just for fun
> >
> > This small program gives negative Sum of Sq in anova (with R versions
> > 2.9.2 and 2.10.0) (linux 32 kernel 2.6.29.6-smp slackware 13.0) :
> >

  These are essentially just round-off error in a problem with zero
noise: there is absolutely no practical difference between 2e-16 and
2e16.  If you really need to do something with these values that will
break if they are negative, see ?zapsmall ...

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] New package Rd2roxygen: Convert Rd to roxygen documentation

2010-12-01 Thread Yihui Xie
Hi,

A new package Rd2roxygen has been released on CRAN:
http://cran.r-project.org/package=Rd2roxygen (source package
available; binaries to come)

This package can be useful for developers who used to document their
functions in the raw Rd files but want to switch to roxygen now using
inline roxygen comments (e.g. me). The main functionality of this
package is to parse the Rd files under the ./pkg/man directory, and
update the R scripts under the ./pkg/R directory accordingly with
roxygen comments. It can deal with most of Rd tags correctly, but
there might be some trivial problems which need adjustment by hand.
This package will not make a backup of the source package first, so it
is recommended to back up the ./pkg/R directory before converting the
Rd files.

Package: Rd2roxygen
Type: Package
Title: Convert Rd to roxygen documentation
Version: 0.1-0
Date: 2010-11-30
aut...@r: c(person("Hadley", "Wickham", email = "h.wick...@gmail.com",
role = "aut"), person("Yihui", "Xie", email = "x...@yihui.name",
role = c("aut", "cre")))
Author: Hadley Wickham and Yihui Xie
Maintainer: Yihui Xie 
Depends: roxygen
Description: Functions to convert Rd to roxygen documentation. It can
parse an Rd file to a list, create the roxygen documentation and
update the original R script (e.g. the one containing the
definition of the function) accordingly.
License: GPL
URL: https://github.com/yihui/Rd2roxygen
Collate: 'rd2roxygen.r' 'utils.r'

I asked the question in r-help a few days ago, and it seems some
developers are in the same situation as me. This is a solution to my
own question, hence Cc'ed to r-help as well.

Regards,
Yihui
--
Yihui Xie 
Phone: 515-294-2465 Web: http://yihui.name
Department of Statistics, Iowa State University
2215 Snedecor Hall, Ames, IA

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

2010-12-01 Thread Robert Quinn
I am having problems trying to get R to graph data input that is log-normal
on the horizontal (x) axis.

The data is log (base 10), and I am more interested in viewing the tails of
the distribution.  The closest I can get with this is log on the vertical
(y) axis and linear on the horizontal axis.  Note that the x-axis is Centile
(0%-100%) and is at this time linear, however I want it to be exponential
0%-50% and reverse exponential from 50%-100%.  Meaning there is the most
spread in the data from 0%-5% and 95%-100%, and very little spread 25%-75%.

 

 

This is what I have so far:

 

plot(x,y,type="l",

 

  log = "y",

 

  xlab="Centile",

 

  ylab="INH MoMs",

 

  xlim=c(1,100),

 

  ylim=c(0.3,5),

 

  col="green" )

 

 I have tried inserting "lognormal = "x"," and other code that might
work that I have found on the "R help", but nothing seems to work.  Thank
you in advance for your help.

 

Respectfully, Bob Quinn

 

 


[[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] Simple question on eval

2010-12-01 Thread Lamke

Thank you so much Joshua.  That's exactly what I am looking for.

What I wanted to do is to pass a parameter to a function and I have to run
the functions 30 times.  Instead of typing them all out, I created a long
string of "f(a);f(b);f(c) ..." using paste() and use eval and parse to
evaluative them all at once.  I am sure there are better ways of doing it
but I just know this.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Simple-question-on-eval-tp3066346p3067508.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] Simple question on eval

2010-12-01 Thread Ivan Calandra

Isn't it what do.call() does?

Ivan

Le 12/1/2010 16:39, Lamke a écrit :

Thank you so much Joshua.  That's exactly what I am looking for.

What I wanted to do is to pass a parameter to a function and I have to run
the functions 30 times.  Instead of typing them all out, I created a long
string of "f(a);f(b);f(c) ..." using paste() and use eval and parse to
evaluative them all at once.  I am sure there are better ways of doing it
but I just know this.


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

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

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


[R] Wiener-Granger Causality Test in R

2010-12-01 Thread CALEF ALEJANDRO RODRIGUEZ CUEVAS
Hello dudes.

I'm developing VAR analysis based on suggestions made by Horváth in its
paper Canonical Correlation Analysis and Wiener-Granger Causality Tests.

That's the reason I'm looking for if there's any R package to develop Wiener
- Granger Causality Test.

Thanks a lot for your unvaluable help.

Regards from Mexico

[[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] anova error

2010-12-01 Thread David Winsemius


On Dec 1, 2010, at 9:18 AM, Peter Ehlers wrote:


It might be a good idea not to use an outdated version of R.
I don't see your "problem" in R 2.12.0.


Furthermore isn't it a bit  to be asking why the sign on a  
number that is effectively  zero happens to be negative? I would think  
that FAQ 7.31 applied even back in the 2.9 and 2.10 era.


(I still get a negative number in R 2.12.0 that is effectively zero,  
-4.4409e-16,  and rounded is exactly the same as the difference  
between sqrt(2)^2 and 2 in the FAQ entry, so if it were supposed to be  
"fixed" (which I'm not saying it should be) then it didn't occur until  
very recently.)


--
David.



Peter Ehlers

On 2010-12-01 05:44, jean.cour...@math.u-psud.fr wrote:

Just for fun

This small program gives negative Sum of Sq in anova (with R versions
2.9.2 and 2.10.0) (linux 32 kernel 2.6.29.6-smp slackware 13.0) :

y = c(3.6, 5.0, 5.0, 4.6, 4.5, 4.3, 4.5, 5.1, 4.5, 4.3)
trans = as.factor(c("NT","NT","NT","NT","NT","T","T","T","T","T"))
lc = lm(y ~ trans)
l1 = lm(y ~ 1)

anova(l1,lc)

# Analysis of Variance Table
#
# Model 1: y ~ 1
# Model 2: y ~ trans
#   Res.Df   RSS Df  Sum of Sq F Pr(>F)
# 1  9 1.744
# 2  8 1.744  1 -2.220e-16   # negative Sum of Sq 

anova(lc)  # is OK

# 2.9.2 version
# Analysis of Variance Table
#
# Response: y
#   DfSum Sq   Mean Sq   F value Pr(>F)
# trans  1 8.214e-32 8.214e-32 3.768e-31  1
# Residuals  8 1.744 0.218

# 2.10.0 version
# Analysis of Variance Table
#
# Response: y
#   Df Sum Sq Mean Sq F value Pr(>F)
# trans  1  0.000   0.000   0  1
# Residuals  8  1.744   0.218

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


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


David Winsemius, MD
West Hartford, CT

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


[R] sem package: optimization did not converge

2010-12-01 Thread Maike Luhmann
In specifying a CFA model using the sem package, I got the following warning
message: 

 

In sem.default(ram = ram, S = S, N = N, param.names = pars, var.names =
vars,  :

  Could not compute QR decomposition of Hessian.

Optimization probably did not converge.

 

This is the complete input (including data import):

 


-

DS =
read.table("http://www.beltz.de/fileadmin/beltz/downloads/OnlinematerialienP
VU/Statistik_und_Forschungsmethoden/Daten_kap23.dat", 

   sep="", header = F)

attach(DS)

 

mycov = cov(DS)

 

my.model <- specify.model()

   eta1 -> V1, NA,1

   eta1 -> V2, lam12, NA

   eta1 -> V3, lam13, NA

   eta1 -> V4, lam14, NA

   eta1 -> V5, lam15, NA

   eta1 -> V6, lam16, NA

   eta2 -> V4, NA,1

   eta2 -> V5, lam52, NA

   eta2 -> V6, lam62, NA

   V1  <-> V1, e1,   NA

   V2  <-> V2, e2,   NA

   V3  <-> V3, e3,   NA

   V4  <-> V4, e4,   NA

   V5  <-> V5, e5,   NA

   V6  <-> V6, e6,   NA

   eta1 <-> eta1, var.eta1, NA

   eta2 <-> eta2, var.eta2, NA

 

my.sem <- sem(my.model, mycov, nrow(DS), debug=TRUE) 

 


-

 

The problem should converge easily and does so in Mplus. Also, it converges
if the correlation matrix instead of the variance-covariance matrix is used
and gives the correct standardized coefficients. Any suggestions why it does
not work with the covariance matrix in my example?

 

 

 


[[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] Sequence for repeated numbers

2010-12-01 Thread Luana Marotta
Hello fellows,

I would like to create a sequence for repeated numbers in a dataset. For
example:

ID <- c(1:20)
grade <- c(4,4,4,5,5,7,7,7,7,8,8,8,9,9,9,9,9,10,10,10)

Data:

ID  Grade
1   4
2   4
3   4
4   5
5   5
6   7
7   7
8   7
9   7
(...)

I would like to create a variable "sequence":

Data:
ID GradeSequence:
1   4  1
2   4  2
3   4  3
4   5  1
5   5  2
6   7  1
7   7  2
8   7  3
9   7  4

Any help is very much appreciate!

Thank you,

Luana Marotta

[[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] ggplot2 histograms

2010-12-01 Thread Small Sandy (NHS Greater Glasgow & Clyde)
Sorry this should have ben to the whole list:

Hadley

I think I've sorted it out in my head but for the record, and just to be sure...
I guess what I was expecting was that the width parameter would be independent 
of binwidth. Thus a width parameter of 0.5 would always indicate an overlap of 
half the bar. In fact the width is determined as a fraction of the binwidth, so 
if width is greater than binwidth the overlap will be with adjacent bins not 
the bin it actually corresponds to.
So in my example you can completely separate the data by putting
ggplot(data=dafr, aes(x = d1, fill=d2)) + geom_histogram(binwidth = 2, position 
= position_dodge(width=7))
Obviously this isn't helpful.
I think the rules are:
1. the width of each bar equals binwidth divided by number of fill factors (in 
my case two)
2. total width of the visible bars would be centred on the centre of the bin
3. overlap of the visible bars is governed by the width parameter of 
position_dodge with 0 being complete overlap and binwidth being complete (but 
touching) separation (More than binwidth would then mean space between the bars 
- and presumably overlap with adjacent bars - I don't think this would ever be 
useful).
Hope this makes sense.
Sandy

Sandy Small
Clinical Physicist
NHS Forth Valley
(Tel: 01324567002)
and
NHS Greater Glasgow and Clyde
(Tel: 01412114592)

From: h.wick...@gmail.com [h.wick...@gmail.com] On Behalf Of Hadley Wickham 
[had...@rice.edu]
Sent: 01 December 2010 14:27
To: Small Sandy (NHS Greater Glasgow & Clyde)
Cc: ONKELINX, Thierry; r-help@r-project.org
Subject: Re: [R] ggplot2 histograms

> However if you do:
> ggplot(data=dafr, aes(x = d1, fill=d2)) + geom_histogram(binwidth = 1, 
> position = position_dodge(width=0.99))
>
> The position of first bin which goes from 0-2 appears to start at about 0.2 
> (I accept that there is some "white space" to the left of this) while the 
> position of the last bin (16-18) appears to start at about 15.8, so the whole 
> histogram seems to be wrongly compressed into the scale. In my real data 
> which has potentially 250 bins the problem becomes much more pronounced. Has 
> any one else noticed this? Is there a work around?

What do you expect this to do?  The bars are one unit wide, but you've
told position_dodge to treat them like they're only 0.99 units wide.

Hadley

--
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/



This message may contain confidential information. If yo...{{dropped:21}}

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


[R] [R-lme] Extract estimated variances from output of lme?

2010-12-01 Thread Tingting Zhan
Hi all,

I have the output of summary() of an lme object called "lme.exp1", for
example

#
> summary(lme.exp1)

Linear mixed-effects model fit by REML
  Data: DATA
  Log-restricted-likelihood: -430.8981
  Fixed: fixed.exp1


Random effects:
 Formula: ~-1 + mu1 + log.sig1 | animID
 Structure: Diagonal
 mu1  log.sig1 Residual
StdDev: 2.605223 0.1013134 3.876431

Correlation Structure: General
 Formula: ~1 | animID/fieldN
 Parameter estimate(s):
 Correlation:
  1
2 0.612
Variance function:
 Structure: Different standard deviations per stratum
 Formula: ~1 | type
 Parameter estimates:
   mu1   log.sig1
1. 0.03722675
Number of Observations: 376
Number of Groups: 32
##

If I want to reuse these estimates, I can use

> summary(lme.exp1)$coefficients$fixed;

to extract fixed effect estimates, and

 > summary(lme.exp1)$sigma

for the common variance parameter sigma.   But if I need the covariance
estimates 0.612 and 0.0372, do I have a function to extract these numbers
too?   I'm looking for something similar to function ranef() [of course
ranef() does not serve my purpose].  Any advice appreciated!

Tingting

[[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] anova error

2010-12-01 Thread Douglas Bates
On Wed, Dec 1, 2010 at 9:02 AM, Ben Bolker  wrote:
>
>
> Peter Ehlers  ucalgary.ca> writes:
>
>>
>> It might be a good idea not to use an outdated version of R.
>> I don't see your "problem" in R 2.12.0.
>>
>> Peter Ehlers
>>
>> On 2010-12-01 05:44, Jean.Coursol  math.u-psud.fr wrote:
>> > Just for fun
>> >
>> > This small program gives negative Sum of Sq in anova (with R versions
>> > 2.9.2 and 2.10.0) (linux 32 kernel 2.6.29.6-smp slackware 13.0) :
>> >
>
>  These are essentially just round-off error in a problem with zero
> noise: there is absolutely no practical difference between 2e-16 and
> 2e16.

Well, actually there is a big difference between 2e-16 and 2e16.  I
think you meant to write 2e-16 and -2e-16

> If you really need to do something with these values that will
> break if they are negative, see ?zapsmall ...
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Font family not found in Windows font database

2010-12-01 Thread Mark Ebbert
Dear R Gurus,

I have a fairly simple problem, but I haven't been able to find the answer on 
'the google' or in the r-help archives.

I am generating plots on both Windows and OS X where I need to guarantee that 
the font used is Arial. In my plot command I specify 'fontfamily="Arial"'. The 
problem is that on Windows I'm getting the following warning: 
Warning message:
In grid.Call.graphics("L_text", as.graphicsAnnot(x$label), x$x,  :
  Font family not found in Windows font database

Here is my plot call. I have not included supporting code, as I don't believe 
it's necessary:
graph<-barchart(3.7,xlim=c(0,10),main="",xlab="",
aspect=.1,

col=rgb(21,101,112,maxColorValue=255),scales=list(x=list(tick.number=10,tck=c(1,0),fontfamily="Arial",fontsize=10)),

panel=scorePnl,par.settings=theme.novpadding,lowCut=pgrLowCut,highCut=pgrHighCut)

In my research I've found that the default for Windows is Arial anyway, but I 
should be able to specify the font without a warning. I further checked the 
available fonts in the windows font database by using 'windowsFonts()' and 
found an entry for 'TT Arial', however, specifying 'TT Arial' produces the same 
error.

Any help is appreciated.

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


[R] Question regarding legend look

2010-12-01 Thread Filoche

Hi everyone.

I have a quick question regarding the look of my legend in my plot. As you
can see in the next figure, I have 3 series.

http://r.789695.n4.nabble.com/file/n3067466/legend.png 


However, I find rather difficult to differentiate the series 1 and 3
according to their line type (lty). I would like to know if it was possible
to make the line type in the legend to appear more clearly. For example, to
give more horizontal space each side of the symbols "square" to have a
better idea of the line type.

With regards,
Phil
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Question-regarding-legend-look-tp3067466p3067466.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] Simple question on eval

2010-12-01 Thread Joshua Wiley
Here are two options that might work for you given the little bit you've said:

## If its the same parameter all 30 times
## say, for example, base = 4.5 to log
for(i in 1:30) {
  print(log(1:10, base = 4.5))
}

## if they are different parameters, you could try
lapply(X = c(1.3, 3, 2.2, 4, 5), FUN = function(x) {
  log(1:10, base = x)})

## the 'X' argument to lapply() is based, one at a time,
## to whatever the function is (the 'FUN' argument)
## so the above is equivalent to
log(1:10, base = 1.3)
log(1:10, base = 3)
log(1:10, base = 2.2)
log(1:10, base = 4)
log(1:10, base = 5)
## but easier to type

Cheers,

Josh

@Ivan do.call() passes a list of arguments, but I am not sure it would
easily adapt to passing 30 different arguments one at a time or even
the same argument 30 times.

On Wed, Dec 1, 2010 at 7:39 AM, Lamke  wrote:
>
> Thank you so much Joshua.  That's exactly what I am looking for.
>
> What I wanted to do is to pass a parameter to a function and I have to run
> the functions 30 times.  Instead of typing them all out, I created a long
> string of "f(a);f(b);f(c) ..." using paste() and use eval and parse to
> evaluative them all at once.  I am sure there are better ways of doing it
> but I just know this.
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/Simple-question-on-eval-tp3066346p3067508.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.
>



-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/

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


Re: [R] Sequence for repeated numbers

2010-12-01 Thread Jonathan P Daily
Try this:

> ord <- order(grade)
> ID <- Id[ord]
> grade <- grade[ord]
> sequence <- unlist(sapply(table(grade), FUN = function(x) 1:x), 
use.names = F)

And as a general tip, it is much easier to work with related values like 
ID and grade if they are in a data frame. Such as:

> dat <- data.frame(ID, grade)
> dat <- dat[order(grade),]

--
Jonathan P. Daily
Technician - USGS Leetown Science Center
11649 Leetown Road
Kearneysville WV, 25430
(304) 724-4480
"Is the room still a room when its empty? Does the room,
 the thing itself have purpose? Or do we, what's the word... imbue it."
 - Jubal Early, Firefly

r-help-boun...@r-project.org wrote on 12/01/2010 11:08:06 AM:

> [image removed] 
> 
> [R] Sequence for repeated numbers
> 
> Luana Marotta 
> 
> to:
> 
> r-help, r-help-request
> 
> 12/01/2010 11:09 AM
> 
> Sent by:
> 
> r-help-boun...@r-project.org
> 
> Hello fellows,
> 
> I would like to create a sequence for repeated numbers in a dataset. For
> example:
> 
> ID <- c(1:20)
> grade <- c(4,4,4,5,5,7,7,7,7,8,8,8,9,9,9,9,9,10,10,10)
> 
> Data:
> 
> ID  Grade
> 1   4
> 2   4
> 3   4
> 4   5
> 5   5
> 6   7
> 7   7
> 8   7
> 9   7
> (...)
> 
> I would like to create a variable "sequence":
> 
> Data:
> ID GradeSequence:
> 1   4  1
> 2   4  2
> 3   4  3
> 4   5  1
> 5   5  2
> 6   7  1
> 7   7  2
> 8   7  3
> 9   7  4
> 
> Any help is very much appreciate!
> 
> Thank you,
> 
> Luana Marotta
> 
>[[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] Poisson GLM warning message

2010-12-01 Thread Anna Berthinussen

Hi,

I receive the following warning message when I run a poisson GLM in R:

  "glm.fit: fitted rates numerically 0 occurred"

The model summary is shown below. The variable 'Species' consists of
counts of different species ranging from 0 to 4. I suspect this may
have something to do with the warning message but I'm not sure. Can
anybody help?

Thank you!

Anna


Call:
glm(formula = Species ~ Dist + Time + Alt + Elev.road + Noise +
 Cloud + Temp + Wind.sp + Water + Hab + Crossing, family = poisson,
 data = bats1)

Deviance Residuals:
   Min 1Q Median 3QMax
-2.131083  -0.734566   0.005422   0.548956   2.186938

Coefficients:
   Estimate Std. Error z value Pr(>|z|)
(Intercept) -7.496e-01  6.642e-01  -1.128  0.25911
Dist 1.993e-04  1.233e-04   1.617  0.10593
Time-4.753e-04  2.114e-03  -0.225  0.82206
Alt  2.042e-04  1.265e-03   0.161  0.87180
Elev.road2.189e-03  1.960e-03   1.117  0.26418
Noise   -8.126e+01  4.528e+01  -1.795  0.07268 .
Cloud   -1.059e-03  2.274e-03  -0.466  0.64150
Temp 6.660e-02  4.051e-02   1.644  0.10017
Wind.sp -7.553e-02  2.420e-02  -3.121  0.00180 **
WaterY  -6.919e-02  1.744e-01  -0.397  0.69162
Hab  1.200e-01  5.051e-02   2.375  0.01755 *
CrossingUnd  9.496e-02  1.214e-01   0.782  0.43420
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for poisson family taken to be 1)

 Null deviance: 253.49  on 239  degrees of freedom
Residual deviance: 206.59  on 228  degrees of freedom
AIC: 681.56

Number of Fisher Scoring iterations: 6

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


Re: [R] missing values

2010-12-01 Thread Doran, Harold
You can also explore the classical() function in the MiscPsycho package that 
does item analysis. 

> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
> Behalf Of Iasonas Lamprianou
> Sent: Wednesday, December 01, 2010 4:52 AM
> To: Michael Bedward; ivan.calan...@uni-hamburg.de; Rhelp
> Subject: Re: [R] missing values
> 
> thank you, I'll have a go and let you know if i have problems
>  Dr. Iasonas Lamprianou
> 
> 
> 
> 
> Assistant Professor (Educational Research and Evaluation)
> Department of Education Sciences
> European University-Cyprus
> P.O. Box 22006
> 1516 Nicosia
> Cyprus
> Tel.: +357-22-713178
> Fax: +357-22-590539
> 
> 
> 
> 
> Honorary Research Fellow
> Department of Education
> The University of Manchester
> Oxford Road, Manchester M13 9PL, UK
> Tel. 0044  161 275 3485
> iasonas.lampria...@manchester.ac.uk
> 
> 
> 
> - Original Message 
> From: Michael Bedward 
> To: ivan.calan...@uni-hamburg.de; lampria...@yahoo.com; Rhelp
> 
> Sent: Wed, 1 December, 2010 11:40:13
> Subject: Re: [R] missing values
> 
> And just to add to Ivan's comment, if you are using the rowSums or
> colSums functions with a matrix or data.frame they also have the na.rm
> argument.
> 
> Michael
> 
> On 1 December 2010 20:16, Ivan Calandra  wrote:
> > Hi,
> >
> > (a) sum() and mean() have a na.rm argument that should be set to TRUE.
> >
> > (b) let's try with an example:
> > x <- c(1:5, NA, NA, 6:10, NA)
> > x[is.na(x)] <- 0  ## replace NAs by 0
> >
> > HTH,
> > Ivan
> >
> >
> > Le 12/1/2010 10:00, Iasonas Lamprianou a écrit :
> >>
> >> Dear all,
> >> i have spent a lot of time trying to solve this problem, but I am sure
> >> that
> >> there must be a simple solution. So, as a last resort, I am coming back to
> >> you
> >> again. I have a dataset with some (almost random) values in many
> >> variables. Lets
> >> say that the dataset represents the scores of students to test questions.
> >> What I
> >> need to do is to sum the scores for each student. However, wherever there
> >> is a
> >> missing (NA) value, I cannot get the total score.  How can I compute the
> >> total
> >> score and the average per question (a) by ignoring the missing responses,
> >> (b) by
> >> assuming that a missing response is a zero?
> >> Thank you for the response
> >>
> >>
> >>  Dr. Iasonas Lamprianou
> >>
> >>
> >>
> >>
> >> Assistant Professor (Educational Research and Evaluation)
> >> Department of Education Sciences
> >> European University-Cyprus
> >> P.O. Box 22006
> >> 1516 Nicosia
> >> Cyprus
> >> Tel.: +357-22-713178
> >> Fax: +357-22-590539
> >>
> >>
> >>
> >>
> >> Honorary Research Fellow
> >> Department of Education
> >> The University of Manchester
> >> Oxford Road, Manchester M13 9PL, UK
> >> Tel. 0044  161 275 3485
> >> iasonas.lampria...@manchester.ac.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.
> >>
> >
> > --
> > Ivan CALANDRA
> > PhD Student
> > University of Hamburg
> > Biozentrum Grindel und Zoologisches Museum
> > Abt. Säugetiere
> > Martin-Luther-King-Platz 3
> > D-20146 Hamburg, GERMANY
> > +49(0)40 42838 6231
> > ivan.calan...@uni-hamburg.de
> >
> > **
> > http://www.for771.uni-bonn.de
> > http://webapp5.rrz.uni-hamburg.de/mammals/eng/1525_8_1.php
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
> 
> 
> 
> 
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Sequence for repeated numbers

2010-12-01 Thread Jorge Ivan Velez
Hi Luana,

Try this:

ID <- 1:20
grade <- c(4, 4, 4, 5, 5, 7, 7, 7, 7, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10)
d <- data.frame(ID, grade)
d$Sequence <- do.call(c, sapply(rle(grade)$lengths, seq))
d

HTH,
Jorge


On Wed, Dec 1, 2010 at 11:08 AM, Luana Marotta <> wrote:

> Hello fellows,
>
> I would like to create a sequence for repeated numbers in a dataset. For
> example:
>
> ID <- c(1:20)
> grade <- c(4,4,4,5,5,7,7,7,7,8,8,8,9,9,9,9,9,10,10,10)
>
> Data:
>
> ID  Grade
> 1   4
> 2   4
> 3   4
> 4   5
> 5   5
> 6   7
> 7   7
> 8   7
> 9   7
> (...)
>
> I would like to create a variable "sequence":
>
> Data:
> ID GradeSequence:
> 1   4  1
> 2   4  2
> 3   4  3
> 4   5  1
> 5   5  2
> 6   7  1
> 7   7  2
> 8   7  3
> 9   7  4
>
> Any help is very much appreciate!
>
> Thank you,
>
> Luana Marotta
>
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] Sequence for repeated numbers

2010-12-01 Thread Phil Spector

Luana -
   It's probably not the most efficient way, but here's
a solution that's not dependent on the grades being sorted:


grade <- c(4,4,4,5,5,7,7,7,7,8,8,8,9,9,9,9,9,10,10,10)
unlist(sapply(rle(grade)$lengths,function(x)seq(1,x)))

 [1] 1 2 3 1 2 1 2 3 4 1 2 3 1 2 3 4 5 1 2 3

- Phil Spector
 Statistical Computing Facility
 Department of Statistics
 UC Berkeley
 spec...@stat.berkeley.edu




On Wed, 1 Dec 2010, Luana Marotta wrote:


Hello fellows,

I would like to create a sequence for repeated numbers in a dataset. For
example:

ID <- c(1:20)
grade <- c(4,4,4,5,5,7,7,7,7,8,8,8,9,9,9,9,9,10,10,10)

Data:

ID  Grade
1   4
2   4
3   4
4   5
5   5
6   7
7   7
8   7
9   7
(...)

I would like to create a variable "sequence":

Data:
ID GradeSequence:
1   4  1
2   4  2
3   4  3
4   5  1
5   5  2
6   7  1
7   7  2
8   7  3
9   7  4

Any help is very much appreciate!

Thank you,

Luana Marotta

[[alternative HTML version deleted]]

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



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


Re: [R] parametric estimators for species richness in R

2010-12-01 Thread Gavin Simpson
On Wed, 2010-12-01 at 21:23 +0800, yangwenjing wrote:
> Dear everyone,
> 
> I am doing some work about species richness estimation. Nonparametric
> estimation (such as Chao1, Jacknife1) can be done just using function
> "specpool()" and "estimateR()" in package "vegan". The problem is that
> I can not found any functions for parametric estimation (such as
> MMMeans, MMruns, Michaelis-Menten). Do you know any function for doing
> this? Thanks a lot.
> 
> Best wishes,
> 
> Wenjing

Dear Wenjing,

You might get more responses if you post to the R SIG Ecology mailing
list:

https://stat.ethz.ch/mailman/listinfo/r-sig-ecology

Good luck,

G

-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 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] Question regarding legend look

2010-12-01 Thread David Winsemius


On Dec 1, 2010, at 10:13 AM, Filoche wrote:



Hi everyone.

I have a quick question regarding the look of my legend in my plot.  
As you

can see in the next figure, I have 3 series.

http://r.789695.n4.nabble.com/file/n3067466/legend.png


However, I find rather difficult to differentiate the series 1 and 3
according to their line type (lty). I would like to know if it was  
possible
to make the line type in the legend to appear more clearly. For  
example, to

give more horizontal space each side of the symbols "square" to have a
better idea of the line type.


The specifics will depend on what plotting function produced the graph  
from which you have given us a bitmap snapshot BUT NOT SHOWN US CODE  
OR SAMPLE DATA. In xyplot you would be working with the key/lines/size  
elements (after showing us which of the several legend options were  
specified):


?xyplot

In base graphics I do not see a "handle" on the line length but  
(perhaps) you could emphasize the line compenent by increasing cex  
which affects all components and at the same time decrease the point  
size. E.g.:


 legend( ..., cex=1.5, pt.cex=0.8, cex=1.5, pt.cex=0.8, ...)

As always>

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

__ ___

David Winsemius, MD
West Hartford, CT

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


Re: [R] Question regarding legend look

2010-12-01 Thread David Winsemius


On Dec 1, 2010, at 11:51 AM, David Winsemius wrote:



On Dec 1, 2010, at 10:13 AM, Filoche wrote:



Hi everyone.

I have a quick question regarding the look of my legend in my plot.  
As you

can see in the next figure, I have 3 series.

http://r.789695.n4.nabble.com/file/n3067466/legend.png


However, I find rather difficult to differentiate the series 1 and 3
according to their line type (lty). I would like to know if it was  
possible
to make the line type in the legend to appear more clearly. For  
example, to
give more horizontal space each side of the symbols "square" to  
have a

better idea of the line type.



snipped
t (perhaps) you could emphasize the line compenent by increasing cex  
which affects all components and at the same time decrease the point  
size. E.g.:


legend( ..., cex=1.5, pt.cex=0.8, cex=1.5, pt.cex=0.8, ...)


At one point that said:
  legend( ..., merge=TRUE, cex=1.5, pt.cex=0.8, ...)



As always>

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

__ ___



David Winsemius, MD
West Hartford, CT

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

2010-12-01 Thread mliugonzal
Hello

Anyone know how can I calculate the value of the beta  parameter when I know
the number of cointegrating relationships between two variables.

I mean, I using the procedure: ca.jo I do the following:

summary (ca.jo (UR [, c (2.52)], type = "trace" ECDET = "trend", K = 2, spec
= "longrun"))

given that there is a cointegration relationship as I can get the values of
B restricted? There is an object "V" for that feature but I can not apply.

Thank  in advance

[[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] confidence interval for logistic joinpoint regression from package ljr

2010-12-01 Thread Vito Muggeo (UniPa)

dear M.,
I do not know how to get the SE for the joinpoint (or breakpoint) from 
your ljr fit. However you can find useful the segmented package which 
works for any GLM (including the logistic one) and it returns 
(approximate) StErr (and Conf Int) also for the joinpoint (breakpoint in 
the segmented package). For some examples, see the R news paper

http://cran.r-project.org/doc/Rnews/Rnews_2008-1.pdf

Also, as regards to the APC, you could find interesting the following note

http://onlinelibrary.wiley.com/doi/10.1002/sim.3850/abstract

hope this helps you,
vito


Il 30/11/2010 23.54, moleps ha scritto:

I´m trying to run a logistic joinpoint regression utilising the ljr package. 
I´ve been using the forward selection technique to get the number of knots for 
the analysis, but I´m uncertain as to my results and the interpretation. The 
documentation is rather brief ( in the package and the stats in medicine 
article is quite technical) and without any good examples. At the moment I´m 
thinking
1)find the number of knots both using forward and backward techniques and see 
if they are close
2)present the annual percent change (APC) for each of the intervals, ie my 
present data (1950-2010 in 5 year intervals) is giving me

Variables  Coef
b0 Intercept -131.20404630
g0 t0.06146463
g1 max(t-tau1,0)   -0.51582466
g2 max(t-tau2,0)0.43429615

Joinpoints:

1 tau1= 1990.5
2 tau2= 1995.5

APC 1950->1990=exp(0.06)=1.06-->6%
1990-1995=exp(0.06-0.51)=exp(-0.45)=0.63-->  -37%
1995-2010=exp(0.06-0.51+0.43)-->-2%

3) Preferably a confidence interval for the APC should be given. However, this 
I havent figured out yet.

//M

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



--

Vito M.R. Muggeo
Dip.to Sc Statist e Matem `Vianelli'
Università di Palermo
viale delle Scienze, edificio 13
90128 Palermo - ITALY
tel: 091 23895240
fax: 091 485726/485612
http://dssm.unipa.it/vmuggeo

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


Re: [R] Sequence for repeated numbers

2010-12-01 Thread Greg Snow
Try this:

id <- 1:20
grade <- c(4,4,4,5,5,7,7,7,7,8,8,8,9,9,9,9,9,10,10,10)

sequence <- ave( id, grade, FUN=seq )

# if grade is not sorted
grade2 <- sample(grade)
sequence2 <- ave( id, grade2, FUN=seq )

cbind( grade2, sequence2 )

-- 
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 Luana Marotta
> Sent: Wednesday, December 01, 2010 9:08 AM
> To: r-help; r-help-request
> Subject: [R] Sequence for repeated numbers
> 
> Hello fellows,
> 
> I would like to create a sequence for repeated numbers in a dataset.
> For
> example:
> 
> ID <- c(1:20)
> grade <- c(4,4,4,5,5,7,7,7,7,8,8,8,9,9,9,9,9,10,10,10)
> 
> Data:
> 
> ID  Grade
> 1   4
> 2   4
> 3   4
> 4   5
> 5   5
> 6   7
> 7   7
> 8   7
> 9   7
> (...)
> 
> I would like to create a variable "sequence":
> 
> Data:
> ID GradeSequence:
> 1   4  1
> 2   4  2
> 3   4  3
> 4   5  1
> 5   5  2
> 6   7  1
> 7   7  2
> 8   7  3
> 9   7  4
> 
> Any help is very much appreciate!
> 
> Thank you,
> 
> Luana Marotta
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Poisson GLM warning message

2010-12-01 Thread Prof Brian Ripley

On Wed, 1 Dec 2010, Anna Berthinussen wrote:


Hi,

I receive the following warning message when I run a poisson GLM in R:

"glm.fit: fitted rates numerically 0 occurred"

The model summary is shown below. The variable 'Species' consists of
counts of different species ranging from 0 to 4. I suspect this may
have something to do with the warning message but I'm not sure. Can
anybody help?


This is a log-linear model, so that is saying that for at least one 
observation the fitted value is very close to zero (and hence the 
linear prediction is near -Inf: a lp around -30 gives small enough 
fitted rates.).


This normally indicates some sort of separation in the data -- see 
below for a suggestion of where to look.




Thank you!

Anna


Call:
glm(formula = Species ~ Dist + Time + Alt + Elev.road + Noise +
   Cloud + Temp + Wind.sp + Water + Hab + Crossing, family = poisson,
   data = bats1)

Deviance Residuals:
 Min 1Q Median 3QMax
-2.131083  -0.734566   0.005422   0.548956   2.186938

Coefficients:
 Estimate Std. Error z value Pr(>|z|)
(Intercept) -7.496e-01  6.642e-01  -1.128  0.25911
Dist 1.993e-04  1.233e-04   1.617  0.10593
Time-4.753e-04  2.114e-03  -0.225  0.82206
Alt  2.042e-04  1.265e-03   0.161  0.87180
Elev.road2.189e-03  1.960e-03   1.117  0.26418
Noise   -8.126e+01  4.528e+01  -1.795  0.07268 .


What is 'Noise'?  Is a coefficient of -81 reasonable?  Do all obs with
non-zero noise have observation = 0?  That's the usual cause.


Cloud   -1.059e-03  2.274e-03  -0.466  0.64150
Temp 6.660e-02  4.051e-02   1.644  0.10017
Wind.sp -7.553e-02  2.420e-02  -3.121  0.00180 **
WaterY  -6.919e-02  1.744e-01  -0.397  0.69162
Hab  1.200e-01  5.051e-02   2.375  0.01755 *
CrossingUnd  9.496e-02  1.214e-01   0.782  0.43420
---
Signif. codes:  0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1

(Dispersion parameter for poisson family taken to be 1)

   Null deviance: 253.49  on 239  degrees of freedom
Residual deviance: 206.59  on 228  degrees of freedom
AIC: 681.56

Number of Fisher Scoring iterations: 6

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


--
Brian D. Ripley,  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] Question regarding legend look

2010-12-01 Thread Duncan Murdoch

On 01/12/2010 10:13 AM, Filoche wrote:

Hi everyone.

I have a quick question regarding the look of my legend in my plot. As you
can see in the next figure, I have 3 series.

http://r.789695.n4.nabble.com/file/n3067466/legend.png


However, I find rather difficult to differentiate the series 1 and 3
according to their line type (lty). I would like to know if it was possible
to make the line type in the legend to appear more clearly. For example, to
give more horizontal space each side of the symbols "square" to have a
better idea of the line type.



There is no parameter to the legend function to control this, but it is 
pure R code, so you could write your own by modifying the legend() function.


If you take a look at legend, you'll see that it draws lines of length 2 
(in some units) when do.lines is TRUE.  Change that to a bigger number, 
and you'll get longer lines.  You'll also need to fiddle with the size 
of the box, or the legend won't fit.  (I think xbox is the variable 
holding its width.)


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] How to pass selection criteria in a function

2010-12-01 Thread CMcCarthy
Hi,
Suppose I have the following data 

name score
Abel    88
Baker  54
Charlie    77

stored a  table called myData.


I want to write a function that will create a table which is a subset of myData 
containing those have a score > 75.

I know I can do this with the following command:
subset(myData, score > 75)

But I would like to do this via a function, something like:

newTable <- function( data,  criteria){ 
    subset( data, criteria) }

and then calling: newTable(myData, score > 75)

But this doesn't work. I am sure there is a simple way to do this,
but I am stuck! Please help. Thanks!


Chris McCarthy, PhD
Department of Mathematics BMCC
Office: N522   Extension: 5235
cmccar...@bmcc.cuny.edu
[[alternative HTML version deleted]]

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


Re: [R] How to pass selection criteria in a function

2010-12-01 Thread Charles C. Berry

On Wed, 1 Dec 2010, cmccar...@bmcc.cuny.edu wrote:


Hi,
Suppose I have the following data

name score
Abel??? 88
Baker? 54
Charlie??? 77

stored a? table called myData.


I want to write a function that will create a table which is a subset of myData 
containing those have a score > 75.

I know I can do this with the following command:
subset(myData, score > 75)

But I would like to do this via a function, something like:

newTable <- function( data,? criteria){
??? subset( data, criteria) }

and then calling: newTable(myData, score > 75)

But this doesn't work. I am sure there is a simple way to do this,
but I am stuck! Please help. Thanks!


Simple? Maybe not so much!

You are trying to pass objects without evaluating them. subset is rather 
special in the way it works. Here is one way:



foo <- function(x,...){

+ mc <- match.call()
+ mc[[1]] <- as.name("subset")
+ eval(mc)
+ }

foo(iris, Petal.Width>2.4 )

Sepal.Length Sepal.Width Petal.Length Petal.Width   Species
101  6.3 3.3  6.0 2.5 virginica
110  7.2 3.6  6.1 2.5 virginica
145  6.7 3.3  5.7 2.5 virginica


Reading the code at the top of lm shows how this kind of strategy can be 
used.


You might look at

?bquote

for another way to skin this cat.


HTH,

Chuck




Chris?McCarthy, PhD
Department?of?Mathematics?BMCC
Office:?N522???Extension:?5235
cmccar...@bmcc.cuny.edu
[[alternative HTML version deleted]]




Charles C. BerryDept of Family/Preventive Medicine
cbe...@tajo.ucsd.eduUC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901

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


Re: [R] How to pass selection criteria in a function

2010-12-01 Thread Henrique Dallazuanna
Try this:

newTable <- function(data, criteria) {
do.call(subset, list(data, substitute(criteria)))
}

On Wed, Dec 1, 2010 at 3:56 PM,  wrote:

> Hi,
> Suppose I have the following data
>
> name score
> Abel88
> Baker  54
> Charlie77
>
> stored a  table called myData.
>
>
> I want to write a function that will create a table which is a subset of
> myData containing those have a score > 75.
>
> I know I can do this with the following command:
> subset(myData, score > 75)
>
> But I would like to do this via a function, something like:
>
> newTable <- function( data,  criteria){
> subset( data, criteria) }
>
> and then calling: newTable(myData, score > 75)
>
> But this doesn't work. I am sure there is a simple way to do this,
> but I am stuck! Please help. Thanks!
>
>
> Chris McCarthy, PhD
> Department of Mathematics BMCC
> Office: N522   Extension: 5235
> cmccar...@bmcc.cuny.edu
>[[alternative HTML version deleted]]
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>


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

[[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] Graph in R with edge weights

2010-12-01 Thread Ivan Alves
Hi Arthur,

I was asking the same thing and came across the following (your need the "sna" 
library).

http://students.washington.edu/mclarkso/documents/gplot%20Ver2.pdf

Take a look at the edge.lwd and vertex.cex examples of the function gplot. You 
can use vectors for the different nodes.

Kind regards,
Ivan
On Dec 1, 2010, at 9:31 AM, arturs.onz...@gmail.com wrote:

> Can you please show code example, how to draw graph with some nodes and
> edges, but with weights. I only found here
> http://www.bioconductor.org/packages/release/bioc/vignettes/Rgraphviz/inst/doc/Rgraphviz.pdf-
> Using edge weights for labels, but...
> 
> Here an example:
> 
>> library("graph"); library(Rgraphviz)
>> myNodes = c("s", "p", "q", "r")
>> myEdges = list(
> s = list(edges = c("p", "q")),
> p = list(edges = c("p", "q")),
> q = list(edges = c("p", "r")),
> r = list(edges = c("s")))
>> g = new("graphNEL", nodes = myNodes,
> edgeL = myEdges, edgemode =
> "directed")
>> plot(g)
> 
> but how about weights?
> 
> 
> Thanx.
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] How to pass selection criteria in a function

2010-12-01 Thread ChrisMath

Thank you all for your very fast replies.

I tried Henrique's method (see one of the above posts) , and it works
perfectly!
Thanks again!
-- 
View this message in context: 
http://r.789695.n4.nabble.com/How-to-pass-selection-criteria-in-a-function-tp3067765p3067829.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] How to pass selection criteria in a function

2010-12-01 Thread David Winsemius


On Dec 1, 2010, at 1:12 PM, Charles C. Berry wrote:


On Wed, 1 Dec 2010, cmccar...@bmcc.cuny.edu wrote:


Hi,
Suppose I have the following data

name score
Abel88
Baker  54
Charlie77

stored a  table called myData.


I want to write a function that will create a table which is a  
subset of myData containing those have a score > 75.


I know I can do this with the following command:
subset(myData, score > 75)

But I would like to do this via a function, something like:

newTable <- function( data,  criteria){
subset( data, criteria) }

and then calling: newTable(myData, score > 75)

But this doesn't work. I am sure there is a simple way to do this,
but I am stuck! Please help. Thanks!


Simple? Maybe not so much!

You are trying to pass objects without evaluating them. subset is  
rather special in the way it works. Here is one way:



foo <- function(x,...){

+ mc <- match.call()
+ mc[[1]] <- as.name("subset")
+ eval(mc)
+ }

foo(iris, Petal.Width>2.4 )

   Sepal.Length Sepal.Width Petal.Length Petal.Width   Species
101  6.3 3.3  6.0 2.5 virginica
110  7.2 3.6  6.1 2.5 virginica
145  6.7 3.3  5.7 2.5 virginica


I've never really understood how to use browser() to develop or  
resolve problems with function definitions. Chuck's comments pointing  
to the subset function offered another opportunity to teach myself  
something new. Here's the console transcript:


> newTable <- function( data, criteria){  crit <-  
substitute(criteria);browser()}

# Obviously not a complete function
> newT <- newTable(myData, score < 75)
Called from: newTable(myData, score < 75) #so far so good
Browse[1]> criteria  # I realize now that this should  
have been "crit"
Error: object 'score' not found  # took another look at subset()  
code
Browse[1]> newTable <- function( data, criteria){  crit <-  
substitute(criteria); logvec <- eval(crit, data, parent.frame());  
browser()}
Browse[1]> criteria  # still didn't catch on that "crit"  
was the local object to examine

Error: object 'score' not found  # just slow I guess.
In addition: Warning message:
restarting interrupted promise evaluation
Browse[1]> c  # was worried the the redefinition might not take  
effect at the top-level


# Try # 2
> newTable <- function( data, criteria){  crit <-  
substitute(criteria); logvec <- eval(crit, data, parent.frame());  
browser()}

> newT <- newTable(myData, score < 75)
Called from: newTable(myData, score < 75)
Browse[1]> logvec
[1] FALSE  TRUE FALSE# now we're getting results
Browse[1]> return(data[logvec, ])# see if the naive next step works
> newT
   name score
2 Baker54# very promising
> newTable <- function( data, criteria){  crit <-  
substitute(criteria); logvec <- eval(crit, data, parent.frame());  
return(data[logvec, ])}

> newT <- newTable(myData, score < 75)
> newT# SUCCESS
   name score
2 Baker54

There is not much in the way of error checking, but it seems to be a  
reasonable start (and looks to offer an example, albeit with a some  
newbie errors, of an extremely useful R tool.)




Reading the code at the top of lm shows how this kind of strategy  
can be used.




Charles C. BerryDept of Family/ 
Preventive Medicine


Thanks, Chuck.

--

David Winsemius, MD
West Hartford, CT

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


Re: [R] Question regarding legend look

2010-12-01 Thread Filoche


David Winsemius wrote:
> 
> 
> ...BUT NOT SHOWN US CODE  
> OR SAMPLE DATA. 
> 

Hi and thank you for your help.

For instance, here's my code:

legend("topleft", inset = .05, title="Water masses", pch = c(22,25,21), lty
= c(4,1,2), lwd = 1, c("North","Central","South"), horiz = F, pt.bg
=c("gray43","gray0","gray86"), cex = 1, bg = "white");


-- 
View this message in context: 
http://r.789695.n4.nabble.com/Question-regarding-legend-look-tp3067466p3067664.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] Question regarding legend look

2010-12-01 Thread Filoche

Thank you sir for your answer. I'll take a look at the original legend
function and modify it for my own purpose.

With regards,
Phil
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Question-regarding-legend-look-tp3067466p3067894.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] default arguments and '...' in a function

2010-12-01 Thread Antonio.Gasparrini
Dear R-users,
 
I'm trying to work out a way to set default values for arguments in a function 
which includes the optional argument '...'.
In practice, I have a 'plot' method for a function which specifies different 
types of plots. Every different plot should have different default arguments 
(for example for 'col', 'ylim' etc), plus the argument '...' to leave further 
optional choices to the user.
My problem is that I need to specify a large number of arguments in the usage 
(losing clarity), or alternatively leaving to the user the specification of an 
high number of argument (adding complexity).
 
An example.
Suppose I want to create a function f with arguments 'a', and '...'.
Two more arguments 'b' and 'c' should be both set to 1 by default if the user 
don't include them in '...'.
 
f <- function(a,...) {
  # set b <- 1 if b is not included in '...'
  # set c <- 1 if c is not included in '...'
  somefunction(a,b,c,...)
}
 
I found that internally the optional arguments are stored in list(...), but I 
haven't found a way to manage them, so the final call to somefunction() will 
include 'b' and 'c' twice if the user have included them in '...', and returns 
an error.
 
Does anyone have some suggestion?
Thanks for your time
 
Antonio Gasparrini
London School of Hygiene & Tropical Medicine
Department of Social and Environmental Health Research
15-17 Tavistock Place, London WC1H 9SH, 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] Font family not found in Windows font database

2010-12-01 Thread Paul Murrell

Hi

On 2/12/2010 4:55 a.m., Mark Ebbert wrote:

Dear R Gurus,

I have a fairly simple problem, but I haven't been able to find the
answer on 'the google' or in the r-help archives.

I am generating plots on both Windows and OS X where I need to
guarantee that the font used is Arial. In my plot command I specify
'fontfamily="Arial"'. The problem is that on Windows I'm getting the
following warning: Warning message: In grid.Call.graphics("L_text",
as.graphicsAnnot(x$label), x$x,  : Font family not found in Windows
font database

Here is my plot call. I have not included supporting code, as I don't
believe it's necessary:
graph<-barchart(3.7,xlim=c(0,10),main="",xlab="", aspect=.1,
col=rgb(21,101,112,maxColorValue=255),scales=list(x=list(tick.number=10,tck=c(1,0),fontfamily="Arial",fontsize=10)),



panel=scorePnl,par.settings=theme.novpadding,lowCut=pgrLowCut,highCut=pgrHighCut)


In my research I've found that the default for Windows is Arial
anyway, but I should be able to specify the font without a warning. I
further checked the available fonts in the windows font database by
using 'windowsFonts()' and found an entry for 'TT Arial', however,
specifying 'TT Arial' produces the same error.

Any help is appreciated.


If you want to be sure of getting Arial, you could specify an explicit 
Windows Font mapping, for example, ...


windowsFonts(Arial=windowsFont("TT Arial"))
barchart(1, scales=list(x=list(fontfamily="Arial")))

Paul


Mark T. W. Ebbert __
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
p...@stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/

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


Re: [R] Wiener-Granger Causality Test in R

2010-12-01 Thread Dennis Murphy
Hi:

On Wed, Dec 1, 2010 at 7:49 AM, CALEF ALEJANDRO RODRIGUEZ CUEVAS <
alejandro.rodriguez.cue...@gmail.com> wrote:

> Hello dudes.
>
> I'm developing VAR analysis based on suggestions made by Horváth in its
> paper Canonical Correlation Analysis and Wiener-Granger Causality Tests.
>

Poor Horvath has been reduced to an it?

>
> That's the reason I'm looking for if there's any R package to develop
> Wiener
> - Granger Causality Test.
>

I don't think you'll find a package to develop the test, but perhaps one
exists that implements it...

For questions of this sort, package sos is an invaluable resource, as in:

library(sos)   # install if necessary
findFn('Wiener Granger causality')

Unfortunately, nothing came up from that search so I tried something
simpler:

findFn('Granger causality')

which produced 10 hits in four packages. Those would seem to be useful
places to start in discovering what exists and doesn't exist to aid in the
solution of your problem.

HTH, dude.

Dennis

>
> Thanks a lot for your unvaluable help.
>
> Regards from Mexico
>
>[[alternative HTML version deleted]]
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>

[[alternative HTML version deleted]]

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


Re: [R] Minor warning about seq

2010-12-01 Thread Ray Brownrigg
I think both responses so far have missed the point, (assuming the O was a typo 
for zero).

That is:
> seq(0:1)
[1] 1 2
when
> seq(0,1)
[1] 0 1
was intended.

Ray Brownrigg

On Wed, 01 Dec 2010, Ista Zahn wrote:
> So you are warning us that you must type zero instead of the letter O
> when we want to enter the value of zero? Seems pretty obvious...
>
> -Ista
>
> On Tue, Nov 30, 2010 at 1:49 PM, Prof. John C Nash  wrote:
> > I spent more time than I should have debugging a script because I wanted
> >   x<-seq(0,100)*0.1
> >
> > but typed
> >   x<-seq(O:100)*0.1
> >
> > seq(0:100) yields 1 to 101,
> > Clearly my own brain to fingers fumble, but possibly one others may want
> > to avoid it.
> >
> > JN
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/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] [R-lme] Extract estimated variances from output of lme?

2010-12-01 Thread Ben Bolker
Tingting Zhan  jefferson.edu> writes:

> 
> Hi all,
> 
> I have the output of summary() of an lme object called "lme.exp1", for
> example
> 
> #
> > summary(lme.exp1)
>

  [snip]

> for the common variance parameter sigma.   But if I need the covariance
> estimates 0.612 and 0.0372, do I have a function to extract these numbers
> too?   I'm looking for something similar to function ranef() [of course
> ranef() does not serve my purpose].  Any advice appreciated!
> 
> Tingting


  ?VarCorr

and

str(VarCorr(lme.exp1))

to figure out how to extract the values you want (it's
a slightly odd object, a matrix of mode 'character' with
labels interspersed with numeric values ...)

  r-sig-mixed-models is probably the best list for this
sort of query ...

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

2010-12-01 Thread Ali S
I have a matrix with 3 years of data (2006, 2009, 2010). I am trying to split 
this matrix by year so that I have 3 separate matrices. My matrix looks like 
this:
    Q16.1 Year Gender Grade1       3 2006      1     52       2 2006      0     
53       3 2006      0     54       3 2006      0     55       3 2006      1    
 56       2 2006      0     57       3 2006      0     58       3 2006      1   
  59       3 2006      0     510      3 2006      0     511      3 2006      0  
   512      2 2006      0     5
Thanks


  
[[alternative HTML version deleted]]

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


[R] draw categorical histogram

2010-12-01 Thread phoebe kong
Hi,

Can someone tell me how to draw a histogram for the following summary?

Richard   Minnie  Albert  Helen  Joe  Kingston
1233   56   6715   66

The summary tell that Richard has occurrence 12, Minnie has occurrence 33,
and so on. I would like to view this summary in a histogram.

I want the X-axis be the person name (Richard, Minnie, ), Y-axis be the
frequency (12, 33).
How can I make the histogram has 6 bars, each bar was named as Richard,
Minnie, ... ,  Kingston?

Thanks,
Phoebe

[[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] draw categorical histogram

2010-12-01 Thread Andrew Miles

Try:

plot (myCatVariable)

Andrew Miles
Department of Sociology
Duke University

On Dec 1, 2010, at 2:51 PM, phoebe kong wrote:


Hi,

Can someone tell me how to draw a histogram for the following summary?

Richard   Minnie  Albert  Helen  Joe  Kingston
   1233   56   6715   66

The summary tell that Richard has occurrence 12, Minnie has  
occurrence 33,

and so on. I would like to view this summary in a histogram.

I want the X-axis be the person name (Richard, Minnie, ), Y-axis  
be the

frequency (12, 33).
How can I make the histogram has 6 bars, each bar was named as  
Richard,

Minnie, ... ,  Kingston?

Thanks,
Phoebe

[[alternative HTML version deleted]]

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


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


Re: [R] Extract specific rows from matrix

2010-12-01 Thread Jorge Ivan Velez
Hi Ali,

Check

?split

HTH,
Jorge


On Wed, Dec 1, 2010 at 2:50 PM, Ali S <> wrote:

> I have a matrix with 3 years of data (2006, 2009, 2010). I am trying to
> split this matrix by year so that I have 3 separate matrices. My matrix
> looks like this:
> Q16.1 Year Gender Grade1   3 2006  1 52   2 2006  0
> 53   3 2006  0 54   3 2006  0 55   3 2006
>1 56   2 2006  0 57   3 2006  0 58   3
> 2006  1 59   3 2006  0 510  3 2006  0 511
>3 2006  0 512  2 2006  0 5
> Thanks
>
>
>
>[[alternative HTML version deleted]]
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>

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


  1   2   >