[R] lsmeans in R

2009-03-10 Thread suman Duvvuru
I need help with calculating lsmeans (adjusted means) of different terms in
a linear model including the main effect and the interaction effect terms. I
use lm to run the linear models...I previously noted from literature that
that "effects" package can be used to generate lsmeans. But I tried to use
it but could not figure out which option to use to get means. If anyone can
give an example of how to get lsmeans using lm object, that will very
helpful.

Thanks,
SUman

[[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] Converting a dataframe to a matrix

2009-03-10 Thread markleeds
Hi: Below works but it's extremely ugly and overly complicated. i'm sure 
someone else will send you something better  and I'll be waiting also.
Also, the way I named the rows and columns works for below but it won't 
hold in the general case if you don't have nice ordered names like

you do below. So, use it until we something better.

DF <- read.table(textConnection("name color likes
1 sally red 0
2 sally blue 1
3 sally green 1
4 jake red 0
5 jake blue  1
6 jake green 1
7 tom red 1
8 tom blue 0
9 tom green 0"),header=TRUE,stringsAsFactors=FALSE)


mat <- matrix(sapply(1:nrow(DF),function(.row) {
DF[.row,3]

}),nrow=length(unique(DF$name)),byrow=TRUE,dimnames=list(c(unique(DF$name)),c(unique(DF$color

print(mat)





On Wed, Mar 11, 2009 at 12:42 AM, Jennifer Brea wrote:


If I have a dataframe which is organized like this:

  name color likes?
1 sally   red0
2 sally  blue1
3 sally green1
4  jake   red0
5  jake  blue1
6  jake green1
7   tom   red1
8   tom  blue0
9   tom green0


And I want to create a matrix in the form:

 red blue green
sally   01 1
jake01 1
tom 10 0


Are there any built-in commands that might help me do this?  Also, I 
can't assume that there is an observation for every person-color.  In 
other words, in the original dataset, there might be some colors for 
which sally offered no opinion.  In some cases, this may be 
represented by NA, in others, it may mean that no row exists for sally 
for that color.


Thank you!

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

2009-03-10 Thread Simon Blomberg
xtabs is your friend:

xtabs(likes ~ color + name, data=dat)

   color
nameblue green red
  jake 1 1   0
  sally1 1   0
  tom  0 0   1

See ?xtabs for more info. Note that I changed the "likes?" column to
just "likes". It is a bad idea to have question marks in variable names.

Simon.

On Wed, 2009-03-11 at 01:42 -0400, Jennifer Brea wrote:
> If I have a dataframe which is organized like this:
> 
>name color likes?
> 1 sally   red0
> 2 sally  blue1
> 3 sally green1
> 4  jake   red0
> 5  jake  blue1
> 6  jake green1
> 7   tom   red1
> 8   tom  blue0
> 9   tom green0
> 
> 
> And I want to create a matrix in the form:
> 
>   red blue green
> sally   01 1
> jake01 1
> tom 10 0
> 
> 
> Are there any built-in commands that might help me do this?  Also, I 
> can't assume that there is an observation for every person-color.  In 
> other words, in the original dataset, there might be some colors for 
> which sally offered no opinion.  In some cases, this may be represented 
> by NA, in others, it may mean that no row exists for sally for that color.
> 
> Thank you!
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
School of Biological Sciences
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

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

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

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


[R] prediction error for test set-cross validation

2009-03-10 Thread Mehmet U Ayvaci
Hi, 

 

I have a database of 2211 rows with 31 entries each and I manually split my
data into 10 folds for cross validation. I build logistic regression model
as:  

 

>model <- glm(qual ~ AgGr + FaHx + PrHx + PrSr + PaLp + SvD + IndExam + 

Rad +BrDn + BRDS + PrinFin+ SkRtr + NpRtr + SkThck +TrThkc +
SkLes + AxAdnp + ArcDst + MaDen + CaDt + MaMG + 

MaMrp + MaSh + SCTub + SCFoc + MaSz,
family=binomial(link=logit));

 

Where the  variables are taken from the trainSet of size 1989x31. The test
set is sized 222x31. Now my question is when I try to predict on the test
set it gives me the error:

 

> predict.glm(model, testSet, type ="response")

"Error in drop(X[, piv, drop = FALSE] %*% beta[piv]) : 

  subscript out of bounds"

 

It does fine on trainSet. so it is something about the testSet. On the other
hand, I realized that some independent variables say "MaSz" takes 3
different values in the trainset vs. 4 different ones in the testSet. I am
not sure if this is the cause.If so, what would be the remedy?

 

Since I can retrieve the coefficients of the logistic regression, I could
manually calculate response for each entry in the testSet. This could solve
my problem although burdensome. But, I don't know an easy way of doing it as
my logistic regression have 80+ coefficients.

 

 

Could somebody advise?

 

 

Thanks, 

M


[[alternative HTML version deleted]]

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


Re: [R] North Arrow (.png file) on a Map

2009-03-10 Thread Yihui Xie
Is this "arrow" satisfactory for you?

north.arrow = function(x, y, h) {
polygon(c(x, x, x + h/2), c(y - h, y, y - (1 + sqrt(3)/2) * h),
col = "black", border = NA)
polygon(c(x, x + h/2, x, x - h/2), c(y - h, y - (1 + sqrt(3)/2) *
h, y, y - (1 + sqrt(3)/2) * h))
text(x, y, "N", adj = c(0.5, 0), cex = 4)
}
plot(1, type = "n", ylim = c(0, 1))
north.arrow(1, 0.8, 0.3)

Regards,
Yihui
--
Yihui Xie 
Phone: +86-(0)10-82509086 Fax: +86-(0)10-82509086
Mobile: +86-15810805877
Homepage: http://www.yihui.name
School of Statistics, Room 1037, Mingde Main Building,
Renmin University of China, Beijing, 100872, China



On Tue, Mar 10, 2009 at 7:21 PM, Rodrigo Aluizio  wrote:
> Hi list.
>
> I would like to know how do I insert a North arrow, stored as a png file in
> my computer, in a map? I found lots of post asking similar things, one of
> them mentioned the pixmap package.  The map was done using map() and
> shapefiles (the code is below). I’m using the pixmap () and addlogo()
> functions. Well I can import the png with pixmap() function (I guess, once
> there’s no error message), but I can’t put It on the map, I got an error
> message telling me that:
>
>
>
> “Error at t(x...@index[nrow(x...@index):1, , drop = FALSE]) :
>
>  index out of limits”
>
>
>
> Well I tried changing coordinates but I always got the same result. How do I
> do this correctly? Is there a better way?
>
>
>
> Thanks for the help and attention.
>
>
>
> Here is the complete map script:
>
>
>
> library(RODBC)
>
> library(maps)
>
> library(mapdata)
>
> library(maptools)
>
> library(pixmap)
>
> #Carregar Coordenadas e dados dos Pontos Amostrais
>
> Dados<-odbcConnectExcel('Campos.xls',readOnly=T)
>
> Coord<-sqlFetch(Dados,'CoordMed',colnames=F,rownames='Ponto')
>
> odbcClose(Dados)
>
> N<-pixmap('Norte.png',nrow=166,ncol=113)
>
> # Carregar pontos e shapes
>
> Batimetria<-readShapeSpatial('C:/Users/Rodrigo/Documents/UFPR/Micropaleontol
> ogia/Campos/ShapeFiles/Batimetria_BC.shp')
>
> Estados<-readShapeSpatial('C:/Users/Rodrigo/Documents/UFPR/Micropaleontologi
> a/Campos/ShapeFiles/Estados_Sudeste.shp')
>
> Faciologia<-readShapeSpatial('C:/Users/Rodrigo/Documents/UFPR/Micropaleontol
> ogia/Campos/ShapeFiles/Faciologia_BC.shp')
>
> # Mapa com os Pontos da Bacia
>
> postscript('MapaCampos.eps',paper='special',onefile=F,horizontal=F,width=3.5
> ,height=4.5,bg='white',pointsize=3)
>
> par(mar=c(3,2,2,0))
>
> map('worldHires','brazil',ylim=c(23.9,20.3),xlim=c(42.1,39.2),type='n')
>
> plot(Faciologia,ylab='',xlab='',col=c('lightgreen','lightgreen','lightgreen'
> ,'lightgreen','lightgreen','lightgray','lightgray','lightgray','lightgray','
> lightgray','lightgray','lightgray','lightgray','lightgray','lightgray','ligh
> tgray','lightgray','lightgray','lightgray','lightgray','lightgray','lightyel
> low','lightyellow','lightyellow'),add=T,lwd=0.5,border=0)
>
> plot(Batimetria,ylab='',xlab='',col='darkgray',lty='solid',lwd=0.2,add=T)
>
> plot(Estados,ylab='',xlab='',lty='solid',add=T,lwd=0.8)
>
> text(Coord$Longitude[Coord$Réplicas=='1'],Coord$Latitude[Coord$Réplicas=='1'
> ],rownames(Coord)[Coord$Réplicas=='1'],col='red',cex=0.5,font=2)
>
> text(Coord$Longitude[Coord$Réplicas=='2'],Coord$Latitude[Coord$Réplicas=='2'
> ],rownames(Coord)[Coord$Réplicas=='2'],col='yellow',cex=0.5,font=2)
>
> text(Coord$Longitude[Coord$Réplicas=='3'],Coord$Latitude[Coord$Réplicas=='3'
> ],rownames(Coord)[Coord$Réplicas=='3'],col='blue',cex=0.5,font=2)
>
> points(Coord$Longitude,Coord$Latitude-0.045,pch=20,cex=0.7)
>
> text(c(41.5,41.3),c(21.7,20.6),c('RJ','ES'))
>
> axis(1,xaxp=c(42.1,39.2,2),cex.axis=1)
>
> axis(2,yaxp=c(23.9,20.3,4),cex.axis=1)
>
> title(main='Bacia')
>
> legend(40.2,23.5,c('Uma','Duas','Três'),pch=21,cex=1,pt.bg=c('red','yellow',
> 'blue'),bty='n',pt.cex=2,pt.lwd=0.6,title='Réplicas')
>
> legend(39.8,23.5,c('Areia','Calcário','Lama'),pch=21,cex=1,pt.bg=c('lightyel
> low','lightgray','lightgreen'),bty='n',pt.cex=2,pt.lwd=0.6,title='Faciologia
> ')
>
> addlogo(N,px=c(40,39.8),py=c(21,20.8))
>
> dev.off()
>
> q('no')
>
>
>
> -
>
> MSc. Rodrigo Aluizio 
>
> Centro de Estudos do Mar/UFPR
> Laboratório de Micropaleontologia
>
>
>        [[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] Converting a dataframe to a matrix

2009-03-10 Thread Jennifer Brea

If I have a dataframe which is organized like this:

  name color likes?
1 sally   red0
2 sally  blue1
3 sally green1
4  jake   red0
5  jake  blue1
6  jake green1
7   tom   red1
8   tom  blue0
9   tom green0


And I want to create a matrix in the form:

 red blue green
sally   01 1
jake01 1
tom 10 0


Are there any built-in commands that might help me do this?  Also, I 
can't assume that there is an observation for every person-color.  In 
other words, in the original dataset, there might be some colors for 
which sally offered no opinion.  In some cases, this may be represented 
by NA, in others, it may mean that no row exists for sally for that color.


Thank you!

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

2009-03-10 Thread miya

Hi everyone,
I am currently working with a very large data set. It is data collected a
few times a day, so there are repeated titles in the data set. I want to
assign an id number to each different title and enter this information in a
directory that I can access whenever I am working with the data.

An example of a data I am workin with follows:

1 title A
2 title C
3 title B
1 title A
2 title B
3 title C
1 title D
2 title A
3 title C
1 title B
2 title A
3 title C

What I have tried thus far is for loops.

r<-matrix(x[,1])
t<-matrix(x[,2])
for(i in 1:length(t)) {
for(k in 1:length(r)) {
z = matrix(c(i,t))
A = "Article A"
for(j in 1:length(z)){
if(B=="Article A")

else{enter article in z}
}
}

This is of course giving me a lot of errors. I just have no idea where to go
with this. Does anyone have any ideas on where I can go from here to create
my directory?
I appreciate all your help.
Thank you in advance.

-- 
View this message in context: 
http://www.nabble.com/Creating-a-directory-for-my-data-tp22448335p22448335.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] Cholesky Decomposition in R

2009-03-10 Thread megh

A=matrix(c(1,1,1,1,5,5,1,5,14),nrow=3)
t(eigen(A)$vector) %*% A %*% eigen(A)$vector
mat1 = t(eigen(A)$vector)
mat2 = diag(eigen(A)$values)# this is your diagonal matrix



Manli Yan wrote:
> 
>   Hi everyone:
>   I try to use r to do the Cholesky Decomposition,which is A=LDL',so far I
> only found how to decomposite A in to  LL' by using chol(A),the function
> Cholesky(A) doesnt work,any one know other command to decomposte A in to
> LDL'
> 
>   My r code is:
> library(Matrix)
> A=matrix(c(1,1,1,1,5,5,1,5,14),nrow=3)
> 
>> chol(A)
>  [,1] [,2] [,3]
> [1,]111
> [2,]022
> [3,]003
> 
>> Cholesky(A)
> Error in function (classes, fdef, mtable)  :
>   unable to find an inherited method for function "Cholesky", for
> signature
> "matrix"
> 
> whatz wrong???
> 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.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Cholesky-Decomposition-in-R-tp22444083p22448498.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] Using napredict in prcomp

2009-03-10 Thread Prof Brian Ripley

On Tue, 10 Mar 2009, Alain Paquette wrote:


Hello all,

I wish to compute site scores using PCA (prcomp) on a matrix with missing 
values, for example:


  DrainSlopeOrgL
a41NA
b2.5396
c6845
d3912
e3164
...

Where a,b... are sites.
The command
pca<-prcomp(~ Drain + Slope + OrgL, data = t, center = TRUE, scale = TRUE, 

na.action=na.exclude)
works great, and from

pca$x

I can get site scores, e.g.

 PC1  PC2  PC3
a  NA   NA   NA
b -2.10475208 -2.315128625 -0.885197753
c  5.01177388 -1.778786252 -0.193285051
d  0.28638602  0.298315086  0.386113799
e -0.58861254  0.089498632 -0.434951813
...

Easy enough...
But how do I use the "napredict" argument? Is it intended as an argument to 
be used in the prcomp line (as suggested in ?prcomp), or is it to be used by 
itself, to replace NAs in the above site score matrix (which is what I really 
want to do).


I don't see an 'napredict' argument.  The help says

   x: if 'retx' is true the value of the rotated data (the centred
  (and scaled if requested) data multiplied by the 'rotation'
  matrix) is returned.  Hence, 'cov(x)' is the diagonal matrix
  'diag(sdev^2)'.  For the formula method, 'napredict' is
  applied to handle the treatment of values omitted by the
  'na.action'.

'napredict' is a function (so please look up its help), and it says R 
applies it, not that you need to.  It is napredict which gives you the 
NAs in the correct places.




Thank you,
Alain

--
Alain Paquette, Ph.D.
alain.paque...@gmail.com

Centre d'étude de la forêt (CEF)
Université du Québec à Montréal
www.cef-cfr.ca

Projet TRIADE
www.projettriade.ca
alain.paque...@projettriade.ca

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



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


[R] read.exp?

2009-03-10 Thread Adam D. I. Kramer

Dear Colleagues,

The foreign library, ever-exceptionally useful, does not seem able
to deal with this ancient SPSS ascii portable file I have with extension
'.exp'.

If anybody has familiarity with this filetype and could point me
towards an R function that would allow me to get the data from this file, I
would be much obliged! Or, even knowledge of the specification for these
filetypes would be helpful, and I'll try my own hand at writing the import
function.

Cordially,
Adam Kramer

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


Re: [R] Question about datatypes/plotting issue

2009-03-10 Thread David Winsemius
You need to convert W$Date into a real date variable. At the moment it  
is just a character variable.


> str(W)
'data.frame':   265 obs. of  23 variables:
 $ Date: Factor w/ 265 levels " ","April 1987",..: 1 90  
68 156 2 178 134 ...
 $ AZ.Phoenix  : Factor w/ 236 levels "","100.00","100.43",..:  
236 1 1 1 1 1 1 1 1 1 ...
 $ CA.Los.Angeles  : Factor w/ 260 levels "100.00","100.02",..: 260  
113 114 115 116 ...
 $ CA.San.Diego: Factor w/ 261 levels "100.00","101.07",..: 261  
109 110 111 112 ...
 $ CA.San.Francisco: Factor w/ 256 levels "100.00","102.70",..: 256  
108 109 110 111 ...

.(output trimmed)
.
.
?Date  # not the variable name, the R class name
?format.Date
?strptime

Unfortunately I seem to be at one of the many limits to my knowledge:
This code behaves in the manner I expected:

> format(Sys.time(), "%a %b %d %X %Y %Z")
[1] "Tue Mar 10 22:19:28 2009 EDT"
> strptime(format(Sys.time(), "%a %b %d %X %Y %Z"), format="%a %b %d  
%X %Y %Z")

[1] "2009-03-10 22:20:04"

Whereas this code does not:
> format(Sys.Date(), "%B %Y")
[1] "March 2009"
> as.Date(format(Sys.Date(), "%B %Y"), "%B %Y")
# would have assumed one was the inverse of the other, but ...

[1] NA

For some reason I cannot get the space delimited Month- combo to  
convert. I can getother  space delimited formats to work for input or  
output:

> as.Date("03 1998", "%M %Y")
[1] "1998-03-10"

> format(Sys.Date(), "%B %Y")
[1] "March 2009"

Puzzled;
--
David Winsemius

On Mar 10, 2009, at 9:15 PM, Oscar Bonilla wrote:


Hi,

I am trying to plot the Case-Shiller index found at: 
http://www2.standardandpoors.com/spf/pdf/index/CSHomePrice_History_022445.xls

The way I'm importing it into R is as follows:

library(gdata)
	W <- read.xls("http://www2.standardandpoors.com/spf/pdf/index/CSHomePrice_History_022445.xls 
", header=TRUE)

attach(W)

To give you and idea of what the data looks like:

> head(W)
  Date AZ.Phoenix CA.Los.Angeles CA.San.Diego CA.San.Francisco
1 PHXR   LXXR SDXR  
SFXR
2  January 1987 59.3354.67 
46.61
3 February 1987 59.6554.89 
46.87
4March 1987 59.9955.16 
47.32
5April 1987 60.8155.85 
47.69
6  May 1987 61.6756.35 
48.31
 CO.Denver DC.Washington FL.Miami FL.Tampa GA.Atlanta IL.Chicago  
MA.Boston
1  DNXR  WDXR MIXR TPXR   ATXR
CHXR  BOXR
2 50.20 64.1168.5077.33  
53.55 70.04
3 49.96 64.7768.7677.93  
54.64 70.08
4 50.15 65.7169.2377.76  
54.80 70.00
5 50.55 66.4069.2077.56  
54.88 70.70
6 50.63 67.2769.4677.85  
55.43 71.51
 MI.Detroit MN.Minneapolis NC.Charlotte NV.Las.Vegas NY.New.York  
OH.Cleveland
1   DEXR   MNXR CRXR LVXR 
NYXR CEXR
2  63.3966.36
74.4253.53
3  63.9467.03
75.4353.50
4  64.1767.34
76.2553.68
5  64.8167.88
77.3453.75
6  65.1867.90
79.1654.71

 OR.Portland TX.Dallas WA.Seattle Composite.10 Composite.20
1POXR  DAXR   SEXR CSXR SPCS20R
2   41.05 62.82
3   41.28 63.39
4   41.06 63.87
5   40.96 64.57
6   41.24 65.56


Now on to the problem... if I just run

plot(CA.San.Francisco ~ Date)

I get:


Which I suspect is a problem because the Date column is not really a  
Date, it is a "factor"


> class(Date)
[1] "factor"

If I run:
plot(as.numeric(CA.San.Francisco), type="l")

I get:




which is wrong, as CA.San.Francisco has no such discontinuity.

> CA.San.Francisco
 [1] SFXR   46.61  46.87  47.32  47.69  48.31  48.83  49.49  49.94   
50.69
[11] 51.33  51.80  52.03  52.24  52.64  53.19  54.19  56.09  58.22   
58.70
[21] 59.00  59.50  60.37  61.31  62.20  62.66  63.32  64.64  66.27   
67.77
[31] 69.26  70.27  71.36  72.31  72.95  73.25  73.02  72.87  72.95   
73.50
[41] 74.57  75.12  75.15  74.81  74.45  74.24  73.44  72.58  71.47   
71.17
[51] 70.27  69.56  69.46  70.13  70.83  71.39  71.52  71.55  71.21   
70.69
[61] 70.05  69.67  69.48  69.17  69.26  69.86  70.02  70.00  69.64   
69.51
[71] 69.28  68.85  68.21  67.77  67.44  67.09  67.59  67.90  67.99   
67.65
[81] 67.63  67.50  67.18  66.77  66.27  65.98  65.79  66.37  67.05   
67.70
[91]

Re: [R] Nesting order for mixed models

2009-03-10 Thread Douglas Bates
On Tue, Mar 10, 2009 at 2:47 PM, Jon Zadra  wrote:
> Hello,

> I am confused about the order of nesting in mixed models using functions
> like aov(), lme(), lmer().

> I have the following data:
> n subjects in either condition A or B
> each subject tested at each of 3 numerical values ("distance" = 40,50,60),
> repeated 4 times for each of the 3 numerical values ("trial" = 1,2,3,4)

> Variable summary:
> Condition: 2 level factor
> Distance: numerical (but only 3 values) in the same units as "y"
> Trial: 4 level factor

I don't think Trial is necessary.  If I understand correctly it is not
really an experimental or observational factor in that you don't
expect that trial 1 for one subject/distance combination will be
related to trial 1 for another combination.

> I expect the subjects' data to differ due to condition and distance, and am
> doing repeated measurements to reduce any variability due to measurement
> error.
>
> Currently I'm using this model:
>
> lme(y ~ Condition + Distance, random = ...)
>
> the question is how do I organize the random statement?  Is it:
> random = ~1 | Subject

I think that is all you need.   In lmer the formula would be y ~
Condition + Distance + (1|Subject).

> random = ~1 | Subject/Trial
> random = ~1 | Trial/Subject
> random = ~1 | Condition/Distance/Subject/Trial
> ...etc, or something else entirely?
>
> Mostly I'm unclear about whether the Trials should be grouped under subject
> because I expect the trials to be more similar within a subject than across
> subjects, or whether subjects should be grouped under trials because the
> trials are going to differ depending on the subject.  If trials should be
> grouped under subjects, then do the condition or distance belong as well,
> since the trials will be most similar within each distance within each
> subject?

In some ways of thinking of the model, Trial would be grouped under
the Subject:Distance combination but then it becomes unnecessary
because it is just another way of labeling the observations.  A random
effect for Trial within Subject:Distance is confounded with the
"residual" or per-observation noise term.

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


Re: [R] mean +/- SEM

2009-03-10 Thread David Winsemius

?mean
?sd
?plot

The request to plot mean has no context yet. What sort of problem are  
you working with? You will get better answers if you first read the  
Posting Guide and then provide example data.


--
David Winsemius

On Mar 10, 2009, at 6:39 PM, Stefo Ratino wrote:


Hi all,

I am looking for a R function which unables me to plot mean +/- SEM.  
Is there such a function in R?


Many thanks,
Stefo




[[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
Heritage Laboratories
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] 2 Simple Lattice Plot Questions

2009-03-10 Thread jimdare

Excellent, thank you very much :)




Sundar Dorai-Raj-2 wrote:
> 
> I don't believe Elena's suggestion will work. However, the following will:
> 
> xyplot(..., scales = list(y = list(at = seq(5, 25, 5
> 
> though you may need to extend the limits a little as well:
> 
> xyplot(..., ylim = lattice:::extend.limits(c(0, 30)))
> 
> and add the scales argument from the first example to place explicit
> tick marks rather than let xyplot do so.
> 
> HTH,
> 
> --sundar
> 
> On Tue, Mar 10, 2009 at 7:04 PM, Elena Wilson 
> wrote:
>> Have you tried specifying the levels of y's you want to display, e.g.
>> ylim=c(0,5,10,15,20,30)?
>>
>>  -Original Message-
>> From:   r-help-boun...@r-project.org
>> [mailto:r-help-boun...@r-project.org]  On Behalf Of jimdare
>> Sent:   Wednesday, 11 March 2009 12:50 PM
>> To:     r-help@r-project.org
>> Subject:        Re: [R] 2 Simple Lattice Plot Questions
>>
>>
>> Thanks very much.    One other thing... see how the Y axis begins before
>> 0.
>> At first glance it appears that the 0's are actually worth something.
>>  When
>> I use ylim=c(0,30) I get the graph I want, but the tick marks show only
>> 5,10,15,20,25.  I want them to show 0,5,10,15,20,30.  Does anyone know
>> how
>> to change this setting?
>>
>> Cheers,
>>
>>
>>
>>
>>
>>
>> jimdare wrote:
>>>
>>> Hi,
>>>
>>> I have created the plot below and have a few questions about changes.
>>>
>>> 1) How do I change the "Year" title of each plot so it reads from the
>>> top
>>> "2006","2007","2008","2009".
>>> 2) How do I get rid of those vertical grey bars in the title bar of each
>>> plot?
>>>
>>> I apologise for my ignorance... one of those days :(
>>>
>>> James
>>>
>>>
>>>  http://www.nabble.com/file/p22445242/PLOT.jpg
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/2-Simple-Lattice-Plot-Questions-tp22445242p22447415.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.
>> --
>> Message  protected by MailGuard: e-mail anti-virus, anti-spam and content
>> filtering.
>> http://www.mailguard.com.au/mg
>>
>>
>> https://login.mailguard.com.au/report/1x1TEaABIw/4soNUVnBh04s1coMEHC4LA/7.998
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/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.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/2-Simple-Lattice-Plot-Questions-tp22445242p22447866.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] mean +/- SEM

2009-03-10 Thread Stefo Ratino
Hi all,

I am looking for a R function which unables me to plot mean +/- SEM. Is there 
such a function in R? 

Many thanks,
Stefo



  
[[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] tcltk - insert scrollbar to window

2009-03-10 Thread thoeb

Hello, I hava a problem with inserting a scrollbar into a tcltk toplevel.
The comand is as follows:

require(tcltk)
tt<-tktoplevel()
tkgrid(tklabel(tt,text="Choose path to the meteorology file used for CDM"))
OnOK2 <- function(){
wind.file<<-read.csv2(file.choose(),header=T,sep=";",dec=".")
wind<<-as.double(wind.file[,5])
uH<<-max(wind)
}
OK.but2 <-tkbutton(tt,text="   Search   ",command=OnOK2) 
tkbind(tkgrid, "",OnOK2)
tkgrid(OK.but2)

Because some more tkgrids with requestions to enter other parameters shall
follow within the same window the tcltk-window is to small to show all of
them. Therefore I would need a scrollbar for the whole window. How can I
create this?

Thanks! THoeb

-
Tamara Hoebinger
University of Vienna
-- 
View this message in context: 
http://www.nabble.com/tcltk---insert-scrollbar-to-window-tp22443022p22443022.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] extracting dispersion parameter from quasipoisson lmer model

2009-03-10 Thread liujb

Hello,

I have the exact same question: how to extract dispersion parameter from
lmer() quasipoisson model?

I did a search here and saw this post. However, I do not see answer. Could
somebody please help?

Thank you very much,
Julia


wayne hallstrom wrote:
> 
> Hi,
>   I would like to obtain the dispersion parameter for a quasipoisson model
> for later use in calculating QAIC values for model comparison.Can anyone
> suggest a method of how to go about doing this?
>
>   The idea I have now is that I could use the residual deviance divided by
> the residual degrees of freedom to obtain the dispersion parameter. The
> residual deviance is available in the summary output for the lmer model.
> The problem with this idea is that the residual degrees of freedom is not
> directly available. I have been assuming that the estimated/approximate DF
> can be obtained through the formula listed below, and then subsequently
> used to obtain the dispersion parameter as described above. Is this
> correct?
>
>   samp.m4 <- mcmcsamp(m4, n = 1000)
> print(summary(samp.m4))
> (eDF <- mean(samp.m4[,"deviance"]) - deviance(m4, REML=FALSE)) 
>   # potentially useful approximate DF?
> 
>
>   However, rather than going through this roundabout, there appears to be
> an easier way to obtain the dispersion parameter. I have noted that the
> 'quasibinomial' produces a dispersion parameter in the model output, but
> the 'quasipoisson' output does not contain this useful number. Given that
> each of my models is fit by lmer with a quasipoisson distribution, the
> program must be internally calculating the dispersion parameter as it
> runs. Perhaps there is a way to obtain this number directly since I assume
> it has already been calculated? Can somone who has experience with this
> code provide some advice on whether this is possible and how I might
> manage to do this?
>
>
>   Thank you for your time,
>
>   Wayne Hallstrom
>   403-370-3832
>
>
> 
>
> -
> 
>   [[alternative HTML version deleted]]
> 
> __
> r-h...@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/extracting-dispersion-parameter-from-quasipoisson-lmer-model-tp11992221p22441798.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] 2 dimension convolve

2009-03-10 Thread GreenBrower

Anybody know how to do a fast 2 dimension convolve in R? I used a traditional
method, but it's very slow, even can not stand it!
-- 
View this message in context: 
http://www.nabble.com/2-dimension-convolve-tp22440837p22440837.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] removing daylight savings in R

2009-03-10 Thread Rhiannon Marchant

   Hello,
   Thanks the Prof. Brian Ripley for his earlier response, however I still have
   a few issues with the times in R.
   I'd like to somehow set up R so it automatically has the timezone set to
   Western Australian standard time when I open up a workspace instead of
   Western Australian daylight savings time. Is this possible? I haven't had
   much luck in trying to find this.
   There are two main issues that I mentioned in my earlier email, in regards
   to the Oracle database I'm using the RODBC package to  extract the data into
   R. I've tried using the newer version of RODBC (1.2-4) and the older version
   (1.2-3) of this package and I still get the NA values for the 2am and 2:30am
   datetime values for the start of daylight savings.  However in R 2.6.2, I
   can use either version of RODBC without getting the error.
   The program is quite large, so I've just pickout the relevant bits of code
   needed to extract the data from Oracle
   >channel  <<-  odbcDriverConnect(paste("DSN=", dbdsn, ";UID=", dbuser,
   ";PWD=", dbpwd, sep=""), case="oracle")
   >total_cnsmptn_summary_vw<-sqlQuery(channel, paste("select
   INTERVAL_START_DATETIME,   TOTAL_SMOOTHED_CNSMPTN_MWH+TOTAL_CHURN_MWH,
   NON_VEST_CNSMPTN_MWH+NON_VEST_CHURN_MWH,
   VEST_ISC_CNSMPTN_MWH+VEST_ISC_CHURN_MWH,
   TOTAL_SMOOTHED_CNSMPTN_MWH-NON_VEST_CNSMPTN_MWH-VEST_ISC_CNSMPTN_MWH+VEST_VC
   _CHURN_MWH from CONSUMPTION_SUMMARY where total_smoothed_cnsmptn_mwh > 0 and
   vest_isc_cnsmptn_mwh > 0 order by INTERVAL_START_DATETIME"))
   >names(total_cnsmptn_summary_vw)<-c('INTERVAL_START_DATETIME','TOTAL_SMOOTHE
   D_CNSMPTN_MWH','NON_VEST_CNSMPTN_MWH',
   'VEST_ISC_CNSMPTN_MWH','VEST_VC_CNSMPTN_MWH')
   >total_cnsmptn_summary_vw[67735:67745,]
INTERVAL_START_DATETIMETOTAL_SMOOTHED_CNSMPTN_MWH
   NON_VEST_CNSMPTN_MWH VEST_ISC_CNSMPTN_MWH VEST_VC_CNSMPTN_MWH
   677352008-10-25  23:30:00  535.437
   105.180   50.304 379.953
   677362008-10-26  00:00:00  514.703
   104.700   50.376 359.627
   677372008-10-26  00:30:00  499.146
   104.007   50.941 344.198
   677382008-10-26  01:00:00  485.834
   102.486   50.479 332.869
   677392008-10-26  01:30:00  474.799
   101.961   50.492 322.346
   67740   469.783
102.070   50.755 316.958
   67741  464.007
100.814   50.816 312.377
   677422008-10-26  03:00:00  463.224
   101.309   50.386 311.529
   677432008-10-26  03:30:00  464.052
   102.049   50.207 311.796
   677442008-10-26  04:00:00  469.753
   103.542   50.204 316.007
   677452008-10-26  04:30:00  475.318
   105.407   49.670 320.241
   The second issue is the 2.8.1 version of R changing the times from a 2.6.2
   workspace - this probably relates to the display setting,  that  mentioned
   (I think if I can set this to always use Western Australian standard time
   the problem will be fixed, but I am unsure as how to do this)
   I create a datetime object in R 2.6.2 and then load that workspace into
   2.8.1 the time changes,
   In R 2.6.2 I've typed:
   >date1<-ISOdatetime(2008,1,1,8,00,00)
   >save.image("C:\\Data\\Profiles\\M063059\\Desktop\\test.RData")
   > date1
   [1] "2008-01-01 08:00:00 W. Australia Standard Time"
   and then in R 2.8.1 I've typed
   > load("C:\\Data\\Profiles\\M063059\\Desktop\\test.RData")
   > date1
   [1] "2008-01-01 09:00:00 WST"
   Kind Regards
   Rhiannon
   Rhiannon Marchant
   Forecasting Analyst
   Wholesale
   Synergy (ABN: 71 743 446 839), 228 Adelaide Tce, Perth, WA, 6000, Australia
   phone:   (08)   6212   1464   |   fax:   (08)   6212   1036  |  email:
   rhiannon.march...@synergy.net.au
   business  enquiries:  131354 | identification no.: 300794  |  website:
   [1]synergy.net.au
   Please consider the environment before printing this email.

   Prof Brian Ripley 

   27/02/2009 03:42 PM

   To

   Rhiannon Marchant 

   cc

   r-help@r-project.org

  Subject

   Re: [R] removing daylight savings in R

   What do you mean by 'standard time'? If you mean UTC, set TZ=UTC.
   For anything else, see ?Sys.timezone (which explains the use of TZ).
   I am guessing that

Re: [R] test two correlation coefficients against each other

2009-03-10 Thread William Revelle

Martin,
  See r.test in the psych package.
This will probably do what you want to do.

Bill

At 1:29 AM +0100 3/11/09, Martin Batholdy wrote:

hi,


is there a function in R that calculates the probability that two 
correlation coefficients are from the same population?



thanks!

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



--
William Revelle http://personality-project.org/revelle.html
Professor   http://personality-project.org/personality.html
Department of Psychology http://www.wcas.northwestern.edu/psych/
Northwestern University http://www.northwestern.edu/
Use R for psychology   http://personality-project.org/r

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


Re: [R] 2 Simple Lattice Plot Questions

2009-03-10 Thread Sundar Dorai-Raj
I don't believe Elena's suggestion will work. However, the following will:

xyplot(..., scales = list(y = list(at = seq(5, 25, 5

though you may need to extend the limits a little as well:

xyplot(..., ylim = lattice:::extend.limits(c(0, 30)))

and add the scales argument from the first example to place explicit
tick marks rather than let xyplot do so.

HTH,

--sundar

On Tue, Mar 10, 2009 at 7:04 PM, Elena Wilson  wrote:
> Have you tried specifying the levels of y's you want to display, e.g. 
> ylim=c(0,5,10,15,20,30)?
>
>  -Original Message-
> From:   r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]  
> On Behalf Of jimdare
> Sent:   Wednesday, 11 March 2009 12:50 PM
> To:     r-help@r-project.org
> Subject:        Re: [R] 2 Simple Lattice Plot Questions
>
>
> Thanks very much.    One other thing... see how the Y axis begins before 0.
> At first glance it appears that the 0's are actually worth something.  When
> I use ylim=c(0,30) I get the graph I want, but the tick marks show only
> 5,10,15,20,25.  I want them to show 0,5,10,15,20,30.  Does anyone know how
> to change this setting?
>
> Cheers,
>
>
>
>
>
>
> jimdare wrote:
>>
>> Hi,
>>
>> I have created the plot below and have a few questions about changes.
>>
>> 1) How do I change the "Year" title of each plot so it reads from the top
>> "2006","2007","2008","2009".
>> 2) How do I get rid of those vertical grey bars in the title bar of each
>> plot?
>>
>> I apologise for my ignorance... one of those days :(
>>
>> James
>>
>>
>>  http://www.nabble.com/file/p22445242/PLOT.jpg
>>
>
> --
> View this message in context: 
> http://www.nabble.com/2-Simple-Lattice-Plot-Questions-tp22445242p22447415.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.
> --
> Message  protected by MailGuard: e-mail anti-virus, anti-spam and content 
> filtering.
> http://www.mailguard.com.au/mg
>
>
> https://login.mailguard.com.au/report/1x1TEaABIw/4soNUVnBh04s1coMEHC4LA/7.998
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] 2 Simple Lattice Plot Questions

2009-03-10 Thread jimdare

Yes, I have tried this.  Unfortunately it doesn't seem to work i.e. it still
shows 5,10,15,20,25.



Elena Wilson-2 wrote:
> 
> Have you tried specifying the levels of y's you want to display, e.g.
> ylim=c(0,5,10,15,20,30)?
> 
>  -Original Message-
> From: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] 
> On Behalf Of jimdare
> Sent: Wednesday, 11 March 2009 12:50 PM
> To:   r-help@r-project.org
> Subject:  Re: [R] 2 Simple Lattice Plot Questions
> 
> 
> Thanks very much.One other thing... see how the Y axis begins before
> 0. 
> At first glance it appears that the 0's are actually worth something. 
> When
> I use ylim=c(0,30) I get the graph I want, but the tick marks show only
> 5,10,15,20,25.  I want them to show 0,5,10,15,20,30.  Does anyone know how
> to change this setting?
> 
> Cheers,
> 
> 
> 
> 
> 
> 
> jimdare wrote:
>> 
>> Hi,
>> 
>> I have created the plot below and have a few questions about changes.
>> 
>> 1) How do I change the "Year" title of each plot so it reads from the top
>> "2006","2007","2008","2009".  
>> 2) How do I get rid of those vertical grey bars in the title bar of each
>> plot?
>> 
>> I apologise for my ignorance... one of those days :(
>> 
>> James
>> 
>> 
>>  http://www.nabble.com/file/p22445242/PLOT.jpg 
>> 
> 
> -- 
> View this message in context:
> http://www.nabble.com/2-Simple-Lattice-Plot-Questions-tp22445242p22447415.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.
> -- 
> Message  protected by MailGuard: e-mail anti-virus, anti-spam and content
> filtering.
> http://www.mailguard.com.au/mg
> 
> 
> https://login.mailguard.com.au/report/1x1TEaABIw/4soNUVnBh04s1coMEHC4LA/7.998
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/2-Simple-Lattice-Plot-Questions-tp22445242p22447626.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] Cholesky Decomposition in R

2009-03-10 Thread Douglas Bates
On Tue, Mar 10, 2009 at 4:33 PM, Manli Yan  wrote:
>  Hi everyone:
>  I try to use r to do the Cholesky Decomposition,which is A=LDL',so far I
> only found how to decomposite A in to  LL' by using chol(A),the function
> Cholesky(A) doesnt work,any one know other command to decomposte A in to
> LDL'
>
>  My r code is:
> library(Matrix)
> A=matrix(c(1,1,1,1,5,5,1,5,14),nrow=3)
>
>> chol(A)
>     [,1] [,2] [,3]
> [1,]    1    1    1
> [2,]    0    2    2
> [3,]    0    0    3
>
>> Cholesky(A)
> Error in function (classes, fdef, mtable)  :
>  unable to find an inherited method for function "Cholesky", for signature
> "matrix"
>
> whatz wrong???

The answer, surprisingly, is in the documentation, accessible as

?Cholesky

which says that the first argument has to be a sparse, symmetric
matrix.  Because the Cholesky function is intended for sparse matrices
it is not the best approach.  The object returned is rather obscure

> Cholesky(as(A, "dsCMatrix"), LDL = TRUE)
'MatrixFactorization' of Formal class 'dCHMsimpl' [package "Matrix"]
with 10 slots
  ..@ x   : num [1:6] 1 1 1 4 1 9
  ..@ p   : int [1:4] 0 3 5 6
  ..@ i   : int [1:6] 0 1 2 1 2 2
  ..@ nz  : int [1:3] 3 2 1
  ..@ nxt : int [1:5] 1 2 3 -1 0
  ..@ prv : int [1:5] 4 0 1 2 -1
  ..@ colcount: int [1:3] 3 2 1
  ..@ perm: int [1:3] 0 1 2
  ..@ type: int [1:4] 2 0 0 1
  ..@ Dim : int [1:2] 3 3

It turns out that the factorization you want is encoded in the 'x'
slot but not in an obvious way.  Even if you ask for an expansion

> expand(Cholesky(as(A, "dsCMatrix"), LDL = TRUE))
$P

[1,] | . .
[2,] . | .
[3,] . . |

$L

[1,] 1 . .
[2,] 1 2 .
[3,] 1 2 3

the result is converted from the LDL' factor to the LL' factor.

A better approach is to consider how the LDL' factorization is related
to the R'R form of the factorization returned by chol()

> ch <- chol(A)
> dd <- diag(ch)
> L <- t(ch/dd)
> DD <- dd^2
> L
 [,1] [,2] [,3]
[1,]100
[2,]110
[3,]111
> DD
[1] 1 4 9

This is all rather backwards in that the whole purpose of the LDL'
form of the factorization is to avoid taking square roots to get the
diagonal elements and to contend with positive semidefinite matrices.
In other words, the LDL' form avoids some of the possible problems of
the LL' form but not if you go through the LL' form to get to it.

I think the underlying reason that an LDL' form is not directly
available in R is because there is no Lapack subroutine for it.

Let me know what our grade on the homework is.

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


Re: [R] 2 Simple Lattice Plot Questions

2009-03-10 Thread Elena Wilson
Have you tried specifying the levels of y's you want to display, e.g. 
ylim=c(0,5,10,15,20,30)?

 -Original Message-
From:   r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]  On 
Behalf Of jimdare
Sent:   Wednesday, 11 March 2009 12:50 PM
To: r-help@r-project.org
Subject:Re: [R] 2 Simple Lattice Plot Questions


Thanks very much.One other thing... see how the Y axis begins before 0. 
At first glance it appears that the 0's are actually worth something.  When
I use ylim=c(0,30) I get the graph I want, but the tick marks show only
5,10,15,20,25.  I want them to show 0,5,10,15,20,30.  Does anyone know how
to change this setting?

Cheers,






jimdare wrote:
> 
> Hi,
> 
> I have created the plot below and have a few questions about changes.
> 
> 1) How do I change the "Year" title of each plot so it reads from the top
> "2006","2007","2008","2009".  
> 2) How do I get rid of those vertical grey bars in the title bar of each
> plot?
> 
> I apologise for my ignorance... one of those days :(
> 
> James
> 
> 
>  http://www.nabble.com/file/p22445242/PLOT.jpg 
> 

-- 
View this message in context: 
http://www.nabble.com/2-Simple-Lattice-Plot-Questions-tp22445242p22447415.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.
-- 
Message  protected by MailGuard: e-mail anti-virus, anti-spam and content 
filtering.
http://www.mailguard.com.au/mg


https://login.mailguard.com.au/report/1x1TEaABIw/4soNUVnBh04s1coMEHC4LA/7.998

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


Re: [R] Question about datatypes/plotting issue

2009-03-10 Thread Gabor Grothendieck
There are two header lines which is confusing it.  Use pattern= to
start at the second one.
See the three vignettes in zoo for info on the rest.

library(gdata)
W <- 
read.xls("http://www2.standardandpoors.com/spf/pdf/index/CSHomePrice_History_022445.xls";,
pattern = "LXXR")

library(zoo)
w <- zooreg(as.matrix(W[-1]), start = as.yearmon("1987-01"), freq = 12)
plot(w[,1:2], col = 1:2, screen = 1, ylab = "")



On Tue, Mar 10, 2009 at 9:15 PM, Oscar Bonilla  wrote:
> Hi,
>
> I am trying to plot the Case-Shiller index found at:
> http://www2.standardandpoors.com/spf/pdf/index/CSHomePrice_History_022445.xls
>
> The way I'm importing it into R is as follows:
>
>        library(gdata)
>        W <-
> read.xls("http://www2.standardandpoors.com/spf/pdf/index/CSHomePrice_History_022445.xls";,
> header=TRUE)
>        attach(W)
>
> To give you and idea of what the data looks like:
>
>> head(W)
>           Date AZ.Phoenix CA.Los.Angeles CA.San.Diego CA.San.Francisco
> 1                     PHXR           LXXR         SDXR             SFXR
> 2  January 1987                     59.33        54.67            46.61
> 3 February 1987                     59.65        54.89            46.87
> 4    March 1987                     59.99        55.16            47.32
> 5    April 1987                     60.81        55.85            47.69
> 6      May 1987                     61.67        56.35            48.31
>  CO.Denver DC.Washington FL.Miami FL.Tampa GA.Atlanta IL.Chicago MA.Boston
> 1      DNXR          WDXR     MIXR     TPXR       ATXR       CHXR      BOXR
> 2     50.20         64.11    68.50    77.33                 53.55     70.04
> 3     49.96         64.77    68.76    77.93                 54.64     70.08
> 4     50.15         65.71    69.23    77.76                 54.80     70.00
> 5     50.55         66.40    69.20    77.56                 54.88     70.70
> 6     50.63         67.27    69.46    77.85                 55.43     71.51
>  MI.Detroit MN.Minneapolis NC.Charlotte NV.Las.Vegas NY.New.York
> OH.Cleveland
> 1       DEXR           MNXR         CRXR         LVXR        NYXR
> CEXR
> 2                                  63.39        66.36       74.42
>  53.53
> 3                                  63.94        67.03       75.43
>  53.50
> 4                                  64.17        67.34       76.25
>  53.68
> 5                                  64.81        67.88       77.34
>  53.75
> 6                                  65.18        67.90       79.16
>  54.71
>  OR.Portland TX.Dallas WA.Seattle Composite.10 Composite.20
> 1        POXR      DAXR       SEXR         CSXR     SPCS20R
> 2       41.05                             62.82
> 3       41.28                             63.39
> 4       41.06                             63.87
> 5       40.96                             64.57
> 6       41.24                             65.56
>
>
> Now on to the problem... if I just run
>
>        plot(CA.San.Francisco ~ Date)
>
> I get:
>
>
>
> Which I suspect is a problem because the Date column is not really a Date,
> it is a "factor"
>
>        > class(Date)
>        [1] "factor"
>
> If I run:
>        plot(as.numeric(CA.San.Francisco), type="l")
>
> I get:
>
>
>
>
>
> which is wrong, as CA.San.Francisco has no such discontinuity.
>
>> CA.San.Francisco
>  [1] SFXR   46.61  46.87  47.32  47.69  48.31  48.83  49.49  49.94  50.69
>  [11] 51.33  51.80  52.03  52.24  52.64  53.19  54.19  56.09  58.22  58.70
>  [21] 59.00  59.50  60.37  61.31  62.20  62.66  63.32  64.64  66.27  67.77
>  [31] 69.26  70.27  71.36  72.31  72.95  73.25  73.02  72.87  72.95  73.50
>  [41] 74.57  75.12  75.15  74.81  74.45  74.24  73.44  72.58  71.47  71.17
>  [51] 70.27  69.56  69.46  70.13  70.83  71.39  71.52  71.55  71.21  70.69
>  [61] 70.05  69.67  69.48  69.17  69.26  69.86  70.02  70.00  69.64  69.51
>  [71] 69.28  68.85  68.21  67.77  67.44  67.09  67.59  67.90  67.99  67.65
>  [81] 67.63  67.50  67.18  66.77  66.27  65.98  65.79  66.37  67.05  67.70
>  [91] 68.15  68.38  68.40  68.21  68.17  68.04  67.93  67.73  67.40  66.79
> [101] 67.08  67.31  67.50  67.72  67.78  67.76  67.30  66.80  66.43  66.15
> [111] 65.97  65.92  66.44  67.05  67.67  68.02  68.35  68.43  68.53  68.72
> [121] 68.69  68.80  68.81  69.78  71.09  72.19  73.12  73.75  74.43  74.76
> [131] 75.22  75.31  75.81  76.19  76.53  77.48  79.08  80.82  82.41  83.52
> [141] 84.41  85.06  85.05  84.66  84.50  85.03  85.93  87.51  89.21  90.82
> [151] 92.52  94.20  95.14  96.15  96.72  97.87  98.90  100.00 102.70 106.56
> [161] 110.97 115.01 118.45 119.48 119.95 120.94 123.08 125.66 128.58 131.16
> [171] 133.27 134.10 134.38 134.09 132.64 130.95 129.15 128.60 128.01 126.99
> [181] 125.47 125.13 126.06 128.79 132.62 136.07 139.35 141.02 141.93 142.29
> [191] 142.74 143.06 142.40 141.90 142.19 143.00 144.69 145.53 146.53 147.75
> [201] 148.72 150.25 151.75 153.36 154.62 155.93 158.11 160.90 164.65 167.76
> [211] 171.51 173.85 175.89 178.15 180.75 183.15 185.72 189.35 193.50 198.30
> [

Re: [R] Matrices in R - Simple question?

2009-03-10 Thread David Winsemius
I suspect you probably need to provide an example that illustrates why  
this seems difficult:


> x <- 1:10
> f1 <- function(x) exp(x)
> g1 <- function (x) log(x)
> h1 <- function (x) x^(1/2)
# any of these functions would return a 10 element vector if given x  
as an argument


> f1(x)*g1(x)*h1(x)
 [1] 0.00e+00 7.243182e+00 3.821981e+01 1.513782e+02 5.34e+02  
1.770607e+03 5.645900e+03 1.753265e+04 5.341289e+04

[10] 1.603838e+05

> sum( f1(x)*g1(x)*h1(x) )
[1] 239476.8

Examples might help 
--
David Winsemius


On Mar 10, 2009, at 7:38 PM, Lars Bishop wrote:


Hi,

I'm a new R user and would appreciate your help regarding the  
following: Can

I create a matrix whose elements are n functions of a vector x? In my
problem I have 3 vectors (a,b,c) with elements a=[f1(x)  
f2(x)fn(x)];

b=[g1(x) g2(x)gn(x)]; c=[h1(x) h2(x)hn(x)].




I need to create a final
function that looks like: f(x)=f1(x)*g1(x)*h1(x)+. 
+fn(x)*gn(x)*hn(x).
(f(x) is my objective function of an optimization problem).Is this  
possible

to create f(x) in the way I described?


Many thanks in advance for your help!

Lars.

[[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
Heritage Laboratories
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] 2 Simple Lattice Plot Questions

2009-03-10 Thread jimdare

Thanks very much.One other thing... see how the Y axis begins before 0. 
At first glance it appears that the 0's are actually worth something.  When
I use ylim=c(0,30) I get the graph I want, but the tick marks show only
5,10,15,20,25.  I want them to show 0,5,10,15,20,30.  Does anyone know how
to change this setting?

Cheers,






jimdare wrote:
> 
> Hi,
> 
> I have created the plot below and have a few questions about changes.
> 
> 1) How do I change the "Year" title of each plot so it reads from the top
> "2006","2007","2008","2009".  
> 2) How do I get rid of those vertical grey bars in the title bar of each
> plot?
> 
> I apologise for my ignorance... one of those days :(
> 
> James
> 
> 
>  http://www.nabble.com/file/p22445242/PLOT.jpg 
> 

-- 
View this message in context: 
http://www.nabble.com/2-Simple-Lattice-Plot-Questions-tp22445242p22447415.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] anyone can help me with Cholesky Decomposition

2009-03-10 Thread Manli Yan
   Hi:
what I want to do is decompose the a symmetric  matrix A into this form
A=LDL'
hence TAT'=D,T is inverse of (L)and T is a lower trangular matrix,and D is
dignoal matrix

for one case
A=1 1 1
1 5 5
1 5 14
T=inverse(L)= 1 0 0
-1 1 0
 0 -1 1
D=(1,4,9)

I tried to use chol(A),but it returns only trangular, anyone know
the function can return both L and D?
thank you very much~

[[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] test two correlation coefficients against each other

2009-03-10 Thread Martin Batholdy

hi,


is there a function in R that calculates the probability that two  
correlation coefficients are from the same population?



thanks!

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


Re: [R] Pseudo-random numbers between two numbers

2009-03-10 Thread Ted Harding
I have modified my example to make it more convincing! See at end.

On 10-Mar-09 23:39:17, Ted Harding wrote:
> On 10-Mar-09 23:01:45, g...@ucalgary.ca wrote:
>> Please forget the last email I sent with the same subject.
>> =
>> I would like to generate pseudo-random numbers between two numbers
>> using R, up to a given distribution, for instance, norm. That is
>> something like
>> rnorm(HowMany,Min,Max,mean,sd)
>> over rnorm(HowMany,mean,sd).
>> I am wondering if
>> 
>> qnorm(runif(HowMany, pnorm(Min,mean,sd), pnorm(Max,mean, sd)),
>>   mean, sd)
>> 
>> is good. Any idea? Thanks.
>> -james
> 
> It would certainly work as intended! For instance:
> 
> truncnorm<-function(HowMany,Min,Max,mean=0,sd=1){
>   qnorm(runif(HowMany, pnorm(Min,mean,sd), pnorm(Max,mean, sd)),
> mean, sd)}
> Sample <- truncnorm(1000,-1,2.5)
> hist(Sample,breaks=100)
> 
> Hoping this helps,
> Ted.

truncnorm<-function(HowMany,Min,Max,mean=0,sd=1){
  qnorm(runif(HowMany, pnorm(Min,mean,sd), pnorm(Max,mean, sd)),
mean, sd)}
Sample <- truncnorm(10,-1,2.5)
hist(Sample,breaks=100)
u0<-(-0.975)+0.05*(0:69)
yy<-dnorm(u0)
du<-min(diff(H$breaks))
Y <- 10*yy*du/(pnorm(2.5)-pnorm(-1.0))
lines(u0,Y)

Ted.


E-Mail: (Ted Harding) 
Fax-to-email: +44 (0)870 094 0861
Date: 11-Mar-09   Time: 00:05:23
-- XFMail --

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


[R] Centering multi-line strip text in lattice

2009-03-10 Thread Mike Lawrence
I'm having trouble centering multi-line strip text in lattice. As the
code below demonstrates bounding box of the text is centered within
the strip, but the first line isn't centered in relation to the longer
second line. The "adj" argument to par.strip.text doesn't seem to do
much. Suggestions?

a=data.frame(
x=rep(1:10,2)
,y=rep(1:10,2)
,z=rep(c('First Line\nLonger Second Line (1)','First Line\nLonger
Second Line (2)'),each=10)
)

xyplot(
y~x|z
,data=a
,par.strip.text = list(cex = .75, lineheight=1, lines = 2, adj=.5),
)



-- 
Mike Lawrence
Graduate Student
Department of Psychology
Dalhousie University

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

~ Certainty is folly... I think. ~

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


[R] Matrices in R - Simple question?

2009-03-10 Thread Lars Bishop
Hi,

I'm a new R user and would appreciate your help regarding the following: Can
I create a matrix whose elements are n functions of a vector x? In my
problem I have 3 vectors (a,b,c) with elements a=[f1(x) f2(x)fn(x)];
b=[g1(x) g2(x)gn(x)]; c=[h1(x) h2(x)hn(x)]. I need to create a final
function that looks like: f(x)=f1(x)*g1(x)*h1(x)+.+fn(x)*gn(x)*hn(x).
(f(x) is my objective function of an optimization problem).Is this possible
to create f(x) in the way I described?

Many thanks in advance for your help!

Lars.

[[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] Pseudo-random numbers between two numbers

2009-03-10 Thread Ted Harding
On 10-Mar-09 23:01:45, g...@ucalgary.ca wrote:
> Please forget the last email I sent with the same subject.
> =
> I would like to generate pseudo-random numbers between two numbers
> using R, up to a given distribution, for instance, norm. That is
> something like
> rnorm(HowMany,Min,Max,mean,sd)
> over rnorm(HowMany,mean,sd).
> I am wondering if
> 
> qnorm(runif(HowMany, pnorm(Min,mean,sd), pnorm(Max,mean, sd)),
>   mean, sd)
> 
> is good. Any idea? Thanks.
> -james

It would certainly work as intended! For instance:

truncnorm<-function(HowMany,Min,Max,mean=0,sd=1){
  qnorm(runif(HowMany, pnorm(Min,mean,sd), pnorm(Max,mean, sd)),
mean, sd)}
Sample <- truncnorm(1000,-1,2.5)
hist(Sample,breaks=100)

Hoping this helps,
Ted.


E-Mail: (Ted Harding) 
Fax-to-email: +44 (0)870 094 0861
Date: 10-Mar-09   Time: 23:39:13
-- XFMail --

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


Re: [R] 2 Simple Lattice Plot Questions

2009-03-10 Thread Bert Gunter
... but in general 
?strip.default   

will explain these matters. In particular, note the style argument.

Cheers,

Bert Gunter
Genentech Nonclinical Biostatistics
650-467-7374

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Elena Wilson
Sent: Tuesday, March 10, 2009 3:56 PM
To: jimdare; r-help@r-project.org
Subject: Re: [R] 2 Simple Lattice Plot Questions

With you first question, I had a similar problem when the year (in my case
it was sample size) variable was numeric. Add as.factor in front of it and
it should show you the actual levels...


 -Original Message-
From:   r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of jimdare
Sent:   Wednesday, 11 March 2009 9:48 AM
To: r-help@r-project.org
Subject:[R]  2 Simple Lattice Plot Questions


Hi,

I have created the plot below and have a few questions about changes.

1) How do I change the "Year" title of each plot so it reads from the top
"2006","2007","2008","2009".  
2) How do I get rid of those vertical grey bars in the title bar of each
plot?

I apologise for my ignorance... one of those days :(

James


http://www.nabble.com/file/p22445242/PLOT.jpg 
-- 
View this message in context:
http://www.nabble.com/2-Simple-Lattice-Plot-Questions-tp22445242p22445242.ht
ml
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.
-- 
Message  protected by MailGuard: e-mail anti-virus, anti-spam and content
filtering.
http://www.mailguard.com.au/mg


https://login.mailguard.com.au/report/1x1QqLdh8M/3sazYwF0XpYQ6RvoZPBdoj/2.39
8

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

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

2009-03-10 Thread guox
Please forget the last email I sent with the same subject.
=
I would like to generate pseudo-random numbers between two numbers using
R, up to a given distribution,
for instance, norm. That is something like rnorm(HowMany,Min,Max,mean,sd)
over rnorm(HowMany,mean,sd).
I am wondering if

qnorm(runif(HowMany, pnorm(Min,mean,sd), pnorm(Max,mean, sd)), mean, sd)

is good. Any idea? Thanks.
-james

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


Re: [R] help structuring mixed model using lmer()

2009-03-10 Thread Ben Bolker
Mark Difford  yahoo.co.uk> writes:

> Briefly, y ~ x1 * x2 expands to y ~ x1 + x2 + x1:x2, where the last term
> (interaction term) amounts to a test of slope. Normally you would read its
> significance from F/chisq/p-value. Many practitioners consider the L.Ratio
> test to be a better option. For the fixed effects part in lmer() do:
> 
> mod1 <- y ~ x1 + x2  == y ~ x1 + x2
> mod2 <- y ~ x1 * x2  == y ~ x1 + x2 + x1:x2
> 
> anova(mod1, mod2)
> 
> This will tell you if you need to worry about interaction or whether slopes
> are parallel.

  ... except that you'd better hope that you have a large number
of random units (years? I forget now), or the LR test will be
unreliable -- see Pinheiro and Bates 2000, and refer further questions
to the r-sig-mixed-models list ...

  cheers
Ben Bolker

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


Re: [R] 2 Simple Lattice Plot Questions

2009-03-10 Thread Elena Wilson
With you first question, I had a similar problem when the year (in my case it 
was sample size) variable was numeric. Add as.factor in front of it and it 
should show you the actual levels...


 -Original Message-
From:   r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]  On 
Behalf Of jimdare
Sent:   Wednesday, 11 March 2009 9:48 AM
To: r-help@r-project.org
Subject:[R]  2 Simple Lattice Plot Questions


Hi,

I have created the plot below and have a few questions about changes.

1) How do I change the "Year" title of each plot so it reads from the top
"2006","2007","2008","2009".  
2) How do I get rid of those vertical grey bars in the title bar of each
plot?

I apologise for my ignorance... one of those days :(

James


http://www.nabble.com/file/p22445242/PLOT.jpg 
-- 
View this message in context: 
http://www.nabble.com/2-Simple-Lattice-Plot-Questions-tp22445242p22445242.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.
-- 
Message  protected by MailGuard: e-mail anti-virus, anti-spam and content 
filtering.
http://www.mailguard.com.au/mg


https://login.mailguard.com.au/report/1x1QqLdh8M/3sazYwF0XpYQ6RvoZPBdoj/2.398

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


Re: [R] 2 Simple Lattice Plot Questions

2009-03-10 Thread Sundar Dorai-Raj
Convert Year to a factor and both problems will be solved.

--sundar

On Tue, Mar 10, 2009 at 3:48 PM, jimdare  wrote:
>
> Hi,
>
> I have created the plot below and have a few questions about changes.
>
> 1) How do I change the "Year" title of each plot so it reads from the top
> "2006","2007","2008","2009".
> 2) How do I get rid of those vertical grey bars in the title bar of each
> plot?
>
> I apologise for my ignorance... one of those days :(
>
> James
>
>
> http://www.nabble.com/file/p22445242/PLOT.jpg
> --
> View this message in context: 
> http://www.nabble.com/2-Simple-Lattice-Plot-Questions-tp22445242p22445242.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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


[R] 2 Simple Lattice Plot Questions

2009-03-10 Thread jimdare

Hi,

I have created the plot below and have a few questions about changes.

1) How do I change the "Year" title of each plot so it reads from the top
"2006","2007","2008","2009".  
2) How do I get rid of those vertical grey bars in the title bar of each
plot?

I apologise for my ignorance... one of those days :(

James


http://www.nabble.com/file/p22445242/PLOT.jpg 
-- 
View this message in context: 
http://www.nabble.com/2-Simple-Lattice-Plot-Questions-tp22445242p22445242.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] Pseudo-random numbers between two numbers

2009-03-10 Thread guox
I would like to generate pseudo-random numbers between two numbers using
R, up to a given distribution,
for instance, rnorm.
That is something like rnorm(HowMany,Min,Max,mean,sd) over
rnorm(HowMany,mean,sd).

I am wondering if

dnorm(runif(HowMany, Min, Max), mean, sd)

is good. Any idea? Thanks.
-james

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


Re: [R] puzzled by math on date-time objects

2009-03-10 Thread Wacek Kusnierczyk
Stavros Macrakis wrote:



> I have documented some of these issues in my email "Semantics of
> sequences in R" (22/02/2009 3:42 PM) and other emails, and I have
> proposed to write code to resolve them, but have not received a warm
> reception.
>   

you said 'it *is* a mess', didn't you?  warm reception?

vQ

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


Re: [R] puzzled by math on date-time objects

2009-03-10 Thread Wacek Kusnierczyk
Stavros Macrakis wrote:
> It does seem sensible that median and quantile would work for the
> POSIXct, Date, and other classes for which they are logically
> well-defined, but strangely enough, they do not (except for odd-length
> input).  The summary function has a special case (summary.POSIXct)
> which does the straightforward, obvious thing here.  I do not
> understand why this is not done by median and quantile themselves.
>
> Conversely, for the complex class, median and quantile do not give an
> error but instead produce meaningless results
>   

median, but not quantile, seems to fail on complex:

median(0i)
# error, needs numeric
quantile(0i)
# fine

the latter is a presumably a bug, because it doesn't follow the
documentation, ?quantile:

"
 quantile(x, ...)

Arguments:

   x: numeric vectors whose sample quantiles are wanted.  Missing
  values are ignored.
"

and complex is not numeric:

is.numeric(0i)
# FALSE


> since the complexes do
> not form an ordered field).

  
well, in r complexes are not comparable, but they can be sorted:

0i < 1i
# no go
sort(c(0i, 1i))
# fine

vQ

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


Re: [R] Cholesky Decomposition in R

2009-03-10 Thread Albyn Jones
try Cholesky() in package Matrix.

albyn

On Tue, Mar 10, 2009 at 02:33:01PM -0700, Manli Yan wrote:
>   Hi everyone:
>   I try to use r to do the Cholesky Decomposition,which is A=LDL',so far I
> only found how to decomposite A in to  LL' by using chol(A),the function
> Cholesky(A) doesnt work,any one know other command to decomposte A in to
> LDL'
> 
>   My r code is:
> library(Matrix)
> A=matrix(c(1,1,1,1,5,5,1,5,14),nrow=3)
> 
> > chol(A)
>  [,1] [,2] [,3]
> [1,]111
> [2,]022
> [3,]003
> 
> > Cholesky(A)
> Error in function (classes, fdef, mtable)  :
>   unable to find an inherited method for function "Cholesky", for signature
> "matrix"
> 
> whatz wrong???
> thanks~
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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


Re: [R] R equivalent to MATLAB's "whos" Command?

2009-03-10 Thread Scillieri, John
Something similar in case anyone is interested, my own 'lls' command:



# This function performs a similar operation to the Unix command 'ls -l' 
# It works like ls() in R except that it will also display object class,
# dimension/length, and object size.  
# It can also take a class filter to view only objects of a certain type.
#
# Usage:
#   lls() # list all objects
#   lls(environmentName) # list all the objects in the specified environment
#   lls(pattern="foo") # list all objects whose name matches pattern specified
#   lls(classFilter="data.frame") # find all data frame objects
#
lls <- function(name, pos=-1, envir=as.environment(pos), all.names=FALSE, 
  pattern, classFilter)
{ 
  if( !missing(name) )
  {
envir = name
  } else
  {
envir = parent.frame()
  }
  
  lsList = ls(name, pos, envir, all.names, pattern)   

  cat("\nName: Class, Length, Size\n")
  cat("-\n")
  for( item in lsList )
  {
realItem = eval(parse(text = item), envir)
itemClass = class(realItem)
itemSize = object.size(realItem)
itemDimension = paste(dim(realItem), collapse="x" )
if( itemDimension == "" )
{
  itemDimension = length(realItem)
}

classFilterMatches = !missing(classFilter) && itemClass == classFilter
if( classFilterMatches || missing(classFilter) )
{
  format(cat(item, ": ", itemClass, ", ", itemDimension, ", ", itemSize, 
"\n", 
sep=""), justify="centre")
} 
  } 
  cat("\n") 
  
  invisible(lsList)
}



# Overload the internal object.size function to return the size in B/KB/MB
#
object.size <-function(x)
{
size = .Internal(object.size(x)) 

if (size<1024)
{
size=paste(size, "B")
}
else if (size>=1024 & size < 1024*1024)
{
size=paste( round(size/1024, 1), "KB")
}
else
{
size=paste( round( size/1024/1024, 1 ),"MB")
}

return(size)
}


Creates output like:

Name: Class, Length, Size
-
calc: function, 1, 4.7 KB
data: data.frame, 175656x76, 100.9 MB
dollar: function, 1, 7.1 KB
file: character, 1, 120 B
fileList: character, 17, 1.9 KB
lls: function, 1, 17.6 KB
object.size: function, 1, 7.8 KB
changes: data.frame, 175656x70, 94.5 MB
columns: integer, 70, 304 B
value: numeric, 1, 32 B

Feel free to clean up & use as appropriate.

HTH,
John

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of andrew
Sent: Tuesday, March 10, 2009 5:46 PM
To: r-help@r-project.org
Subject: Re: [R] R equivalent to MATLAB's "whos" Command?

I saw this in
http://groups.google.com.au/group/r-help-archive/browse_thread/thread/7dca300a7fde5286/718dc5f1405618c9?lnk=gst&q=sort(+sapply(ls()%2Cfunction(x){object.size(get(x))}))#718dc5f1405618c9

The command is something like

sort( sapply(ls(),function(x){object.size(get(x))}))

very useful, so I have added it to my .First function


On Mar 11, 8:29 am, Jason Rupert  wrote:
> Wow.  Thank you for your quick response.  However, I'm looking for an R 
> command that lists what is currently in the R workspace.
>
> Here is a link to a description of the MATLAB "whos" 
> command:http://www.math.carleton.ca/old/help/matlab/MathWorks_R13Doc/techdoc/...
> Essentially, it does the following:
> "who lists the variables currently in the workspace.
>
> whos lists the current variables and their sizes and types. It also reports 
> the totals for sizes.
>
> who('global') and whos('global') list the variables in the global workspace
> "
>
> --- On Tue, 3/10/09, Jorge Ivan Velez  wrote:
>
>
>
> > From: Jorge Ivan Velez 
> > Subject: Re: [R] R equivalent to MATLAB's "whos" Command?
> > To: jasonkrup...@yahoo.com
> > Cc: r-h...@r-project.org
> > Date: Tuesday, March 10, 2009, 4:14 PM
> > Dear Jason,
> > How about this?
>
> > ?ls()
> > ls()
>
> > HTH,
>
> > Jorge
>
> > On Tue, Mar 10, 2009 at 5:05 PM, Jason Rupert
> > wrote:
>
> By any chance is there an R equivalent to MATLAB' "whos" command? I tried 
> searching R and R-seek, but didn't really come up with anything. There are 
> several items I would like to make sure are stored in the workspace and check 
> their values.  Thank you again for your help and any feedback.
>
>
>
> > > > ?workspace
> > > No documentation for 'workspace' in specified
> > packages and libraries:
> > > you could try '??workspace'
> > > > ??workspace
> > > No help files found with alias or concept or title
> > matching using fuzzy matching.
> > > > ??whos
> > > No help files found with alias or concept or title
> > matching using regular expression matching.
> > > > ??whos
> > > No help files found with alias or concept or title
> > matching using regular expression matching.
> > > > ?whos
> > > No documentation for 'whos' in specified
> > packages and libraries:
> > > you could try '??w

Re: [R] R equivalent to MATLAB's "whos" Command?

2009-03-10 Thread David Winsemius

Learn to use R-search.

http://search.r-project.org/nmz.html

The obvious search strategy, ls size, seemed effective.

--  


On Mar 10, 2009, at 5:29 PM, Jason Rupert wrote:



Wow.  Thank you for your quick response.  However, I'm looking for  
an R command that lists what is currently in the R workspace.


Here is a link to a description of the MATLAB "whos" command:
http://www.math.carleton.ca/old/help/matlab/MathWorks_R13Doc/techdoc/ref/who.html
Essentially, it does the following:
"who lists the variables currently in the workspace.

whos lists the current variables and their sizes and types. It also  
reports the totals for sizes.


who('global') and whos('global') list the variables in the global  
workspace

"

--- On Tue, 3/10/09, Jorge Ivan Velez   
wrote:



From: Jorge Ivan Velez 
Subject: Re: [R] R equivalent to MATLAB's "whos" Command?
To: jasonkrup...@yahoo.com
Cc: R-help@r-project.org
Date: Tuesday, March 10, 2009, 4:14 PM
Dear Jason,
How about this?

?ls()
ls()

HTH,

Jorge


On Tue, Mar 10, 2009 at 5:05 PM, Jason Rupert
wrote:


By any chance is there an R equivalent to MATLAB' "whos" command? I  
tried searching R and R-seek, but didn't really come up with  
anything. There are several items I would like to make sure are  
stored in the workspace and check their values.  Thank you again for  
your help and any feedback.




?workspace

No documentation for 'workspace' in specified

packages and libraries:

you could try '??workspace'

??workspace

No help files found with alias or concept or title

matching using fuzzy matching.

??whos

No help files found with alias or concept or title

matching using regular expression matching.

??whos

No help files found with alias or concept or title

matching using regular expression matching.

?whos

No documentation for 'whos' in specified

packages and libraries:

you could try '??whos'





David Winsemius, MD
Heritage Laboratories
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] puzzled by math on date-time objects

2009-03-10 Thread Stavros Macrakis
It does seem sensible that median and quantile would work for the
POSIXct, Date, and other classes for which they are logically
well-defined, but strangely enough, they do not (except for odd-length
input).  The summary function has a special case (summary.POSIXct)
which does the straightforward, obvious thing here.  I do not
understand why this is not done by median and quantile themselves.

Conversely, for the complex class, median and quantile do not give an
error but instead produce meaningless results (since the complexes do
not form an ordered field).

There are other operations as well that don't do the natural, useful
thing on a variety of classes, including POSIXct, Date, and difftime:

> dates <- c(as.Date('2000-01-01'), as.Date('2000-01-05'), 
> as.Date('1990-08-09'), as.Date('2008-02-29'))
> median(dates)
Error in Summary.Date(c(10957, 10961), na.rm = FALSE) :
  sum not defined for Date objects
> quantile(dates,.5)
Error in Ops.Date((1 - h), qs[i]) : * not defined for Date objects
> gaps <- diff(sort(dates))
> gaps
Time differences in days
[1] 34324 2977
> cumsum(gaps)
Error in Math.difftime(gaps) :
  'cumsum' not defined for "difftime" objects
> rle(dates)
Error in rle(dates) : 'x' must be an atomic vector
> rle(gaps)
Error in rle(gaps) : 'x' must be an atomic vector

I have documented some of these issues in my email "Semantics of
sequences in R" (22/02/2009 3:42 PM) and other emails, and I have
proposed to write code to resolve them, but have not received a warm
reception.

All I can suggest at this point is that you write your own versions of
these functions. Or perhaps one of us will write a CRAN package,
though this really seems like core behavior.

-s

On Tue, Mar 10, 2009 at 11:44 AM, Denis Chabot  wrote:
> I don't understand the following. When I create a small artificial set of
> date information in class POSIXct, I can calculate the mean and the median:
> ...But for real data (for this post, a short subset is in object c)  that I
> have converted into a POSIXct object, I cannot calculate the median with
> median(), though I do get it with summary():

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] max-nsize, cons : what do they all mean?

2009-03-10 Thread Saptarshi Guha
Hello R users,
I had recently run an R session where a particular function ran
several thousand times, i think into the hundreds of thousands.
I got this error related to cons cells, which I fixed by starting
(actually Rserve) with the --max-nsize=1G option.

I read the help page, but didn't quite understand it.  What does the
option do and why did I initially run into an error  ?
>From man R
--max-nsize

Set max number of cons cells to N

Why should there be a maximum?

Thanks for your time
Saptarshi Guha

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 equivalent to MATLAB's "whos" Command?

2009-03-10 Thread andrew
I saw this in
http://groups.google.com.au/group/r-help-archive/browse_thread/thread/7dca300a7fde5286/718dc5f1405618c9?lnk=gst&q=sort(+sapply(ls()%2Cfunction(x){object.size(get(x))}))#718dc5f1405618c9

The command is something like

sort( sapply(ls(),function(x){object.size(get(x))}))

very useful, so I have added it to my .First function


On Mar 11, 8:29 am, Jason Rupert  wrote:
> Wow.  Thank you for your quick response.  However, I'm looking for an R 
> command that lists what is currently in the R workspace.
>
> Here is a link to a description of the MATLAB "whos" 
> command:http://www.math.carleton.ca/old/help/matlab/MathWorks_R13Doc/techdoc/...
> Essentially, it does the following:
> "who lists the variables currently in the workspace.
>
> whos lists the current variables and their sizes and types. It also reports 
> the totals for sizes.
>
> who('global') and whos('global') list the variables in the global workspace
> "
>
> --- On Tue, 3/10/09, Jorge Ivan Velez  wrote:
>
>
>
> > From: Jorge Ivan Velez 
> > Subject: Re: [R] R equivalent to MATLAB's "whos" Command?
> > To: jasonkrup...@yahoo.com
> > Cc: r-h...@r-project.org
> > Date: Tuesday, March 10, 2009, 4:14 PM
> > Dear Jason,
> > How about this?
>
> > ?ls()
> > ls()
>
> > HTH,
>
> > Jorge
>
> > On Tue, Mar 10, 2009 at 5:05 PM, Jason Rupert
> > wrote:
>
> By any chance is there an R equivalent to MATLAB' "whos" command? I tried 
> searching R and R-seek, but didn't really come up with anything. There are 
> several items I would like to make sure are stored in the workspace and check 
> their values.  Thank you again for your help and any feedback.
>
>
>
> > > > ?workspace
> > > No documentation for 'workspace' in specified
> > packages and libraries:
> > > you could try '??workspace'
> > > > ??workspace
> > > No help files found with alias or concept or title
> > matching using fuzzy matching.
> > > > ??whos
> > > No help files found with alias or concept or title
> > matching using regular expression matching.
> > > > ??whos
> > > No help files found with alias or concept or title
> > matching using regular expression matching.
> > > > ?whos
> > > No documentation for 'whos' in specified
> > packages and libraries:
> > > you could try '??whos'
>
> > >        [[alternative HTML version deleted]]
>
> > > __
> > > r-h...@r-project.org mailing list
> > >https://stat.ethz.ch/mailman/listinfo/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-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guidehttp://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] Cholesky Decomposition in R

2009-03-10 Thread Ravi Varadhan
You can use singular value decomposition:

?svd

> svd(A)
$d
[1] 16.3405917  2.8996176  0.7597907  # This is your diagonal matrix "D"

$u
   [,1]   [,2][,3]
[1,] 0.08585595 -0.2420411  0.96645997
[2,] 0.40826313 -0.8763116 -0.25573252
[3,] 0.90881790  0.4165261  0.02357989

$v
   [,1]   [,2][,3]
[1,] 0.08585595 -0.2420411  0.96645997
[2,] 0.40826313 -0.8763116 -0.25573252
[3,] 0.90881790  0.4165261  0.02357989

>

Ravi. 



---

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: rvarad...@jhmi.edu

Webpage:  http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html

 





-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Manli Yan
Sent: Tuesday, March 10, 2009 5:33 PM
To: r-help@r-project.org
Subject: [R] Cholesky Decomposition in R

  Hi everyone:
  I try to use r to do the Cholesky Decomposition,which is A=LDL',so far I
only found how to decomposite A in to  LL' by using chol(A),the function
Cholesky(A) doesnt work,any one know other command to decomposte A in to
LDL'

  My r code is:
library(Matrix)
A=matrix(c(1,1,1,1,5,5,1,5,14),nrow=3)

> chol(A)
 [,1] [,2] [,3]
[1,]111
[2,]022
[3,]003

> Cholesky(A)
Error in function (classes, fdef, mtable)  :
  unable to find an inherited method for function "Cholesky", for signature
"matrix"

whatz wrong???
thanks~

[[alternative HTML version deleted]]

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

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


[R] Cholesky Decomposition in R

2009-03-10 Thread Manli Yan
  Hi everyone:
  I try to use r to do the Cholesky Decomposition,which is A=LDL',so far I
only found how to decomposite A in to  LL' by using chol(A),the function
Cholesky(A) doesnt work,any one know other command to decomposte A in to
LDL'

  My r code is:
library(Matrix)
A=matrix(c(1,1,1,1,5,5,1,5,14),nrow=3)

> chol(A)
 [,1] [,2] [,3]
[1,]111
[2,]022
[3,]003

> Cholesky(A)
Error in function (classes, fdef, mtable)  :
  unable to find an inherited method for function "Cholesky", for signature
"matrix"

whatz wrong???
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] R equivalent to MATLAB's "whos" Command?

2009-03-10 Thread Wacek Kusnierczyk
Jason Rupert wrote:
> Â 
> By any chance is there an R equivalent to MATLAB's "whos" command?
>   



whos = function(envir=parent.frame())
   print(sapply(ls(envir=envir), USE.NAMES=TRUE, get, envir=envir))

or simply

whos = ls.str

and

x = 1
y = 2

whos()


vQ

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 equivalent to MATLAB's "whos" Command?

2009-03-10 Thread Jason Rupert

Wow.  Thank you for your quick response.  However, I'm looking for an R command 
that lists what is currently in the R workspace. 

Here is a link to a description of the MATLAB "whos" command:
http://www.math.carleton.ca/old/help/matlab/MathWorks_R13Doc/techdoc/ref/who.html
Essentially, it does the following:
"who lists the variables currently in the workspace.

whos lists the current variables and their sizes and types. It also reports the 
totals for sizes.

who('global') and whos('global') list the variables in the global workspace
"

--- On Tue, 3/10/09, Jorge Ivan Velez  wrote:

> From: Jorge Ivan Velez 
> Subject: Re: [R] R equivalent to MATLAB's "whos" Command?
> To: jasonkrup...@yahoo.com
> Cc: R-help@r-project.org
> Date: Tuesday, March 10, 2009, 4:14 PM
> Dear Jason,
> How about this?
> 
> ?ls()
> ls()
> 
> HTH,
> 
> Jorge
> 
> 
> On Tue, Mar 10, 2009 at 5:05 PM, Jason Rupert
> wrote:
> 
> 
By any chance is there an R equivalent to MATLAB' "whos" command? I tried 
searching R and R-seek, but didn't really come up with anything. There are 
several items I would like to make sure are stored in the workspace and check 
their values.  Thank you again for your help and any feedback.


> > > ?workspace
> > No documentation for 'workspace' in specified
> packages and libraries:
> > you could try '??workspace'
> > > ??workspace
> > No help files found with alias or concept or title
> matching using fuzzy matching.
> > > ??whos
> > No help files found with alias or concept or title
> matching using regular expression matching.
> > > ??whos
> > No help files found with alias or concept or title
> matching using regular expression matching.
> > > ?whos
> > No documentation for 'whos' in specified
> packages and libraries:
> > you could try '??whos'
> >
> >
> >
> >
> >[[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] Using napredict in prcomp

2009-03-10 Thread Alain Paquette

Hello all,

I wish to compute site scores using PCA (prcomp) on a matrix with 
missing values, for example:


   DrainSlopeOrgL
a41NA
b2.5396
c6845
d3912
e3164
...

Where a,b... are sites.
The command
> pca<-prcomp(~ Drain + Slope + OrgL, data = t, center = TRUE, scale = 
TRUE, na.action=na.exclude)

works great, and from
> pca$x
I can get site scores, e.g.

  PC1  PC2  PC3
a  NA   NA   NA
b -2.10475208 -2.315128625 -0.885197753
c  5.01177388 -1.778786252 -0.193285051
d  0.28638602  0.298315086  0.386113799
e -0.58861254  0.089498632 -0.434951813
...

Easy enough...
But how do I use the "napredict" argument? Is it intended as an argument 
to be used in the prcomp line (as suggested in ?prcomp), or is it to be 
used by itself, to replace NAs in the above site score matrix (which is 
what I really want to do).


Thank you,
Alain

--
Alain Paquette, Ph.D.
alain.paque...@gmail.com

Centre d'étude de la forêt (CEF)
Université du Québec à Montréal
www.cef-cfr.ca

Projet TRIADE
www.projettriade.ca
alain.paque...@projettriade.ca

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


Re: [R] R equivalent to MATLAB's "whos" Command?

2009-03-10 Thread Jorge Ivan Velez
Dear Jason,
How about this?

?ls()
ls()

HTH,

Jorge


On Tue, Mar 10, 2009 at 5:05 PM, Jason Rupert wrote:

> Â
> By any chance is there an R equivalent to MATLAB's "whos" command?
> Â
> I tried searching R and R-seek, but didn't really come up with anything.Â
> Â
> There are several items I would like to make sure are stored in the
> workspace and check their values.
> Â
> Thank you again for your help and any feedback.
> Â
> Â
> > ?workspace
> No documentation for 'workspace' in specified packages and libraries:
> you could try '??workspace'
> > ??workspace
> No help files found with alias or concept or title matching ‘workspace’
> using fuzzy matching.
> > ??whos
> No help files found with alias or concept or title matching ‘whos’
> using regular expression matching.
> > ??whos
> No help files found with alias or concept or title matching ‘whos’
> using regular expression matching.
> > ?whos
> No documentation for 'whos' in specified packages and libraries:
> you could try '??whos'
>
>
>
>
>[[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] popular R packages

2009-03-10 Thread Tom Backer Johnsen

s...@xlsolutions-corp.com wrote:

 Hi Spencer,

 XLSolutions is currently analyzing r-help archived questions to rank
packages for the upcoming R-PLUS 3.3 Professional version and we will be
happy to share the outcome with interested parties. Please email
d...@xlsolutions-corp.com


I would expect that the correlation between popularity on the one hand 
and usefulness as well as quality to be relatively low.  If it was 
possible to rate the downloaders in respect to "seriousness" and whether 
they actually use the package for some sensible purpose I would be more 
interested.  Consider a highly specialized and good quality package used 
by a relatively small group of distinguished reseachers.  Would that 
have a high rank?  No.  But important?  Possibly yes.


Tom



 Regards -
 Sue Turner
 Senior Account Manager
 XLSolutions Corporation
 North American Division
 1700 7th Ave
 Suite 2100
 Seattle, WA 98101
 Phone: 206-686-1578
 Email: s...@xlsolutions-corp.com
 web: www.xlsolutions-corp.com



--- On Sat, 3/7/09, Spencer Graves  wrote:


From: Spencer Graves 
Subject: Re: [R] popular R packages
To: "Wacek Kusnierczyk" 
Cc: r-help@r-project.org, "Jeroen Ooms" , "Thomas Adams" 

Date: Saturday, March 7, 2009, 5:22 PM
I just did RSiteSearch("library(xxx)") with xxx =
the names of 6 packages familiar to me, with the following
numbers of hits: 


hits package

169 lme4
165 nlme
  6 fda
  4 maps
  2 FinTS
  2 DierckxSpline

 Software could be written to (1) extract the names of

current packages from CRAN then (2) perform queries similar
to this on all such packages and summarize the results.  I
don't have the time now to write code for this, but
I've written similar code before for step (1);  it can
be found in "scripts/TsayFiles.R" in the
"FinTS" package on CRAN.  For step (2), Sundar
Dorai-Raj wrote code that is is included in the preliminary
"RSiteSearch" package available from R-Forge via
install.'packages("RSiteSearch",repos="http://r-forge.r-project.org";)'.

 Code to do this could probably be written (a) in a
matter of seconds by many of those in the R Core team or (b)
in a matter of hours by virtually any reader of this list
using the examples I just cited.  And it could provide
numbers without a need to convince others to keep download
statistics and make them available later. 
 Hope this helps.  Spencer Graves
Wacek Kusnierczyk wrote:

i have kept r installed on more than ten computers

during the past few

years, some of them running win + more than one linux

distro, all of

them having r, most often installed from a separate

download.

i know of many cases where students download r for the

purpose of a

course in statistics -- often an introductory course

for students who

otherwise have little to do with stats. some of them

do it more than

once during the semester, and many of them never use r

again.

taking into account that basic statistics courses are

taught to most

university students and that r is surely the most

popular free

statistical computing environment, download-based

usage estimates may be

a bit optimistic, unless 'usage' is taken to

include 'learn-pass-forget'.

vQ



Tal Galili wrote:
  

I agree with Thomas, over the years I have

installed R on at least 5

computers.

BTW: does any one knows how the website statistics

of r-project are

being analyzed?
Since I can't see any "google

analytics" or other tracking code in the main

website, I am guessing someone might be running

some log-file analyzer - but

I'd rather hear that then assume.






On Sun, Mar 8, 2009 at 12:45 AM, Thomas Adams

 wrote:
  

I don't think "At least one of the

participants in the 2004 thread

suggested that it would be a "good

thing" to track the numbers of downloads

by package." is reasonable because I

download R packages for 2 home

computers (laptop & desktop) and 2 at work

(1 Linux & 1 Mac). There must be

many such cases…

Tom

  

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



--
++
| Tom Backer Johnsen, Psychometrics Unit,  Faculty of Psychology |
| University of Bergen, Christies gt. 12, N-5015 Bergen,  NORWAY |
| Tel : +

[R] R equivalent to MATLAB's "whos" Command?

2009-03-10 Thread Jason Rupert
 
By any chance is there an R equivalent to MATLAB's "whos" command?
 
I tried searching R and R-seek, but didn't really come up with anything.  
 
There are several items I would like to make sure are stored in the workspace 
and check their values. 
 
Thank you again for your help and any feedback. 
 
 
> ?workspace
No documentation for 'workspace' in specified packages and libraries:
you could try '??workspace'
> ??workspace
No help files found with alias or concept or title matching ‘workspace’ 
using fuzzy matching.
> ??whos
No help files found with alias or concept or title matching ‘whos’ using 
regular expression matching.
> ??whos
No help files found with alias or concept or title matching ‘whos’ using 
regular expression matching.
> ?whos
No documentation for 'whos' in specified packages and libraries:
you could try '??whos'



  
[[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] require() is not giving TRUE / FALSE statements ?

2009-03-10 Thread Wacek Kusnierczyk
Duncan Murdoch wrote:
> On 10/03/2009 4:40 PM, Wacek Kusnierczyk wrote:
>> Duncan Murdoch wrote:
>>> On 10/03/2009 4:15 PM, Wolfgang Raffelsberger wrote:
 Dear list,

 ?require says :
 "... |require| is designed for use inside other functions; it returns
 |FALSE| and gives a warning (rather than an error as |library()| does
 by default) if the package does not exist ..."

 However when I run the following code I don't get any TRUE / FALSE
 statements (but the warning only).
>>> You never printed the value, so you didn't see it.  (It was returned
>>> marked invisible, i.e. not for printing.)
>>>
>>
>> maybe it would help if the man page said 'returns invisibly' instead of
>> 'returns'.
>
> It does.

indeed, though not where wolfgang quotes it above, hence my suggestion. 
sorry, my fault, should have checked.

vQ

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


Re: [R] require() is not giving TRUE / FALSE statements ?

2009-03-10 Thread Duncan Murdoch

On 10/03/2009 4:40 PM, Wacek Kusnierczyk wrote:

Duncan Murdoch wrote:

On 10/03/2009 4:15 PM, Wolfgang Raffelsberger wrote:

Dear list,

?require says :
"... |require| is designed for use inside other functions; it returns
|FALSE| and gives a warning (rather than an error as |library()| does
by default) if the package does not exist ..."

However when I run the following code I don't get any TRUE / FALSE
statements (but the warning only).

You never printed the value, so you didn't see it.  (It was returned
marked invisible, i.e. not for printing.)



maybe it would help if the man page said 'returns invisibly' instead of
'returns'.


It does.

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] system() not accepting strings from cat()

2009-03-10 Thread Rolf Turner


On 11/03/2009, at 9:34 AM, culpritNr1 wrote:



I meant charm, not sharm!

(how embarrasing...)


If you're embarrassed by ***that*** you need to watch more Monty  
Python! :-)


cheers,

Rolf Turner

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

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


Re: [R] require() is not giving TRUE / FALSE statements ?

2009-03-10 Thread Wacek Kusnierczyk
Duncan Murdoch wrote:
> On 10/03/2009 4:15 PM, Wolfgang Raffelsberger wrote:
>> Dear list,
>>
>> ?require says :
>> "... |require| is designed for use inside other functions; it returns
>> |FALSE| and gives a warning (rather than an error as |library()| does
>> by default) if the package does not exist ..."
>>
>> However when I run the following code I don't get any TRUE / FALSE
>> statements (but the warning only).
>
> You never printed the value, so you didn't see it.  (It was returned
> marked invisible, i.e. not for printing.)
>

maybe it would help if the man page said 'returns invisibly' instead of
'returns'.

vQ

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


Re: [R] system() not accepting strings from cat()

2009-03-10 Thread culpritNr1

embarrasSing, not embarrasing.

You see how I became culpritNr1?





culpritNr1 wrote:
> 
> I meant charm, not sharm!
> 
> (how embarrasing...)
> 
> 
> 
> 
> culpritNr1 wrote:
>> 
>> OH! The joy!
>> 
>> It worked like a sharm.
>> 
>> Thank you.
>> 
>> culpritNr1
>> 
>> 
>> 
>> 
>> 
>> baptiste auguie-2 wrote:
>>> 
>>> 
>>> try
>>> ?paste
>>> 
>>> 
>>> baptiste
>>> 
>>> On 10 Mar 2009, at 20:01, ig2ar-s...@yahoo.co.uk wrote:
>>> 

 Hi again R-ists,

 How do you construct a string that you can pass to system()?

 For instance. Say I do

> system("echo Hello!")
 Hello!

 That works. Now the alternative: I need to construct the string like  
 this

> a <- "echo"
> b <- "Hello!"
> c <- "\n"
> cat(a, b, c)
 echo Hello!

 Looks nice... but see what happens when I try to use it

> system(cat(a, b, c))
 echo Hello!
 Error in system(command, intern) : non-empty character argument  
 expected

 I have googled extensively in and out of r-lists but I can't find a  
 solution.

 Can anybody help?




 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
>>> 
>>> _
>>> 
>>> Baptiste Auguié
>>> 
>>> School of Physics
>>> University of Exeter
>>> Stocker Road,
>>> Exeter, Devon,
>>> EX4 4QL, UK
>>> 
>>> Phone: +44 1392 264187
>>> 
>>> http://newton.ex.ac.uk/research/emag
>>> 
>>> __
>>> R-help@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide
>>> http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>> 
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/system%28%29-not-accepting-strings-from-cat%28%29-tp22442414p22443051.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] system() not accepting strings from cat()

2009-03-10 Thread culpritNr1

I meant charm, not sharm!

(how embarrasing...)




culpritNr1 wrote:
> 
> OH! The joy!
> 
> It worked like a sharm.
> 
> Thank you.
> 
> culpritNr1
> 
> 
> 
> 
> 
> baptiste auguie-2 wrote:
>> 
>> 
>> try
>> ?paste
>> 
>> 
>> baptiste
>> 
>> On 10 Mar 2009, at 20:01, ig2ar-s...@yahoo.co.uk wrote:
>> 
>>>
>>> Hi again R-ists,
>>>
>>> How do you construct a string that you can pass to system()?
>>>
>>> For instance. Say I do
>>>
 system("echo Hello!")
>>> Hello!
>>>
>>> That works. Now the alternative: I need to construct the string like  
>>> this
>>>
 a <- "echo"
 b <- "Hello!"
 c <- "\n"
 cat(a, b, c)
>>> echo Hello!
>>>
>>> Looks nice... but see what happens when I try to use it
>>>
 system(cat(a, b, c))
>>> echo Hello!
>>> Error in system(command, intern) : non-empty character argument  
>>> expected
>>>
>>> I have googled extensively in and out of r-lists but I can't find a  
>>> solution.
>>>
>>> Can anybody help?
>>>
>>>
>>>
>>>
>>> __
>>> R-help@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide
>>> http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>> 
>> _
>> 
>> Baptiste Auguié
>> 
>> School of Physics
>> University of Exeter
>> Stocker Road,
>> Exeter, Devon,
>> EX4 4QL, UK
>> 
>> Phone: +44 1392 264187
>> 
>> http://newton.ex.ac.uk/research/emag
>> 
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>> 
>> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/system%28%29-not-accepting-strings-from-cat%28%29-tp22442414p22443015.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] system() not accepting strings from cat()

2009-03-10 Thread culpritNr1

OH! The joy!

It worked like a sharm.

Thank you.

culpritNr1





baptiste auguie-2 wrote:
> 
> 
> try
> ?paste
> 
> 
> baptiste
> 
> On 10 Mar 2009, at 20:01, ig2ar-s...@yahoo.co.uk wrote:
> 
>>
>> Hi again R-ists,
>>
>> How do you construct a string that you can pass to system()?
>>
>> For instance. Say I do
>>
>>> system("echo Hello!")
>> Hello!
>>
>> That works. Now the alternative: I need to construct the string like  
>> this
>>
>>> a <- "echo"
>>> b <- "Hello!"
>>> c <- "\n"
>>> cat(a, b, c)
>> echo Hello!
>>
>> Looks nice... but see what happens when I try to use it
>>
>>> system(cat(a, b, c))
>> echo Hello!
>> Error in system(command, intern) : non-empty character argument  
>> expected
>>
>> I have googled extensively in and out of r-lists but I can't find a  
>> solution.
>>
>> Can anybody help?
>>
>>
>>
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
> 
> _
> 
> Baptiste Auguié
> 
> School of Physics
> University of Exeter
> Stocker Road,
> Exeter, Devon,
> EX4 4QL, UK
> 
> Phone: +44 1392 264187
> 
> http://newton.ex.ac.uk/research/emag
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/system%28%29-not-accepting-strings-from-cat%28%29-tp22442414p22442991.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] require() is not giving TRUE / FALSE statements ?

2009-03-10 Thread Duncan Murdoch

On 10/03/2009 4:15 PM, Wolfgang Raffelsberger wrote:

Dear list,

?require says :
"... |require| is designed for use inside other functions; it returns 
|FALSE| and gives a warning (rather than an error as |library()| does by 
default) if the package does not exist ..."


However when I run the following code I don't get any TRUE / FALSE 
statements (but the warning only).


You never printed the value, so you didn't see it.  (It was returned 
marked invisible, i.e. not for printing.)


Just save the value to a variable, or use it in a test, or explicitly 
print it:

> print(require(stats))
[1] TRUE
> print(require(doesNotExist))
Loading required package: doesNotExist
[1] FALSE
Warning message:
In library(package, lib.loc = lib.loc, character.only = TRUE, 
logical.return = TRUE,  :

  there is no package called 'doesNotExist'

Duncan Murdoch

Since I want to test from inside of a function if a given package is 
installed (and do some specific actions like eg trying to install if the 
answer is negative), I need the FALSE statement for use with if(). I 
found a work-around (see below), but I wanted to bring to your attention 
that require() doesn't give the message(s) it's supposed to return.


Wolfgang

 > require(stats)
 > require(doesNotExist)# example for library that's not 
existing on my system

Loading required package: doesNotExist
Warning message:
In library(package, lib.loc = lib.loc, character.only = TRUE, 
logical.return = TRUE,  :

  there is no package called 'doesNotExist'

 >## After all I found a work-around with :
 >library(doesNotExist,logical.return=T)
[1] FALSE
Warning message:
In library(doesNotExist, logical.return = T) :
  there is no package called 'doesNotExist'


 >## for completeness :
 > sessionInfo()
R version 2.8.1 (2008-12-22)
i386-pc-mingw32

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

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


other attached packages:
[1] RODBC_1.2-4svSocket_0.9-5 svIO_0.9-5 R2HTML_1.59
svMisc_0.9-5   svIDE_0.9-5  


loaded via a namespace (and not attached):
[1] tools_2.8.1


 
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Wolfgang Raffelsberger, PhD
Laboratoire de BioInformatique et Génomique Intégratives
CNRS UMR7104, IGBMC 
1 rue Laurent Fries,  67404 Illkirch  Strasbourg,  France

Tel (+33) 388 65 3300 Fax (+33) 388 65 3276
wolfgang.raffelsberger (at) igbmc.fr

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

2009-03-10 Thread Christos Hatzis
Bioconductor already provides download stats for all packages...

http://bioconductor.org/packages/stats/bioc/affy.html

-Christos 

> -Original Message-
> From: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] On Behalf Of Max Kuhn
> Sent: Tuesday, March 10, 2009 12:25 PM
> To: r-help@r-project.org
> Subject: Re: [R] popular R packages
> 
> If is easy to get the download numbers, we should do it and 
> deal with the interpretation issues. I'd like to know the 
> numbers so I can understand which (of my) packages have the 
> most usage.
> 
> One other compication about # downloads: I suspect that a 
> package being on teh depends/suggests/imports list of another 
> package might be a big driver with respect to how many times 
> that it was downloaded.
> 
> If I remember correctly, about 5 years ago Bioconductor asked 
> for volunteers to review packages to get detailed, specific 
> feedback by people who use the package (and should be fairly 
> R proficient). I think that this is pretty important and 
> something like Crantastic is a good interface. I personally 
> got a lot out of the comments the a JSS reviewer had for a package.
> 
> -- 
> 
> Max
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] require() is not giving TRUE / FALSE statements ?

2009-03-10 Thread Wolfgang Raffelsberger

Dear list,

?require says :
"... |require| is designed for use inside other functions; it returns 
|FALSE| and gives a warning (rather than an error as |library()| does by 
default) if the package does not exist ..."


However when I run the following code I don't get any TRUE / FALSE 
statements (but the warning only).
Since I want to test from inside of a function if a given package is 
installed (and do some specific actions like eg trying to install if the 
answer is negative), I need the FALSE statement for use with if(). I 
found a work-around (see below), but I wanted to bring to your attention 
that require() doesn't give the message(s) it's supposed to return.


Wolfgang

> require(stats)
> require(doesNotExist)# example for library that's not 
existing on my system

Loading required package: doesNotExist
Warning message:
In library(package, lib.loc = lib.loc, character.only = TRUE, 
logical.return = TRUE,  :

 there is no package called 'doesNotExist'

>## After all I found a work-around with :
>library(doesNotExist,logical.return=T)
[1] FALSE
Warning message:
In library(doesNotExist, logical.return = T) :
 there is no package called 'doesNotExist'


>## for completeness :
> sessionInfo()
R version 2.8.1 (2008-12-22)
i386-pc-mingw32

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

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


other attached packages:
[1] RODBC_1.2-4svSocket_0.9-5 svIO_0.9-5 R2HTML_1.59
svMisc_0.9-5   svIDE_0.9-5  


loaded via a namespace (and not attached):
[1] tools_2.8.1



. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Wolfgang Raffelsberger, PhD
Laboratoire de BioInformatique et Génomique Intégratives
CNRS UMR7104, IGBMC 
1 rue Laurent Fries,  67404 Illkirch  Strasbourg,  France

Tel (+33) 388 65 3300 Fax (+33) 388 65 3276
wolfgang.raffelsberger (at) igbmc.fr

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


Re: [R] system() not accepting strings from cat()

2009-03-10 Thread baptiste auguie


try
?paste


baptiste

On 10 Mar 2009, at 20:01, ig2ar-s...@yahoo.co.uk wrote:



Hi again R-ists,

How do you construct a string that you can pass to system()?

For instance. Say I do


system("echo Hello!")

Hello!

That works. Now the alternative: I need to construct the string like  
this



a <- "echo"
b <- "Hello!"
c <- "\n"
cat(a, b, c)

echo Hello!

Looks nice... but see what happens when I try to use it


system(cat(a, b, c))

echo Hello!
Error in system(command, intern) : non-empty character argument  
expected


I have googled extensively in and out of r-lists but I can't find a  
solution.


Can anybody help?




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


_

Baptiste Auguié

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

Phone: +44 1392 264187

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

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


Re: [R] help structuring mixed model using lmer()

2009-03-10 Thread Mark Difford

Hi Simon,

Have a look at Chap. 11 of "An Introduction to R" (one of R's manuals),
which explains the different ways of specifying models using formulae.

Briefly, y ~ x1 * x2 expands to y ~ x1 + x2 + x1:x2, where the last term
(interaction term) amounts to a test of slope. Normally you would read its
significance from F/chisq/p-value. Many practitioners consider the L.Ratio
test to be a better option. For the fixed effects part in lmer() do:

mod1 <- y ~ x1 + x2  == y ~ x1 + x2
mod2 <- y ~ x1 * x2  == y ~ x1 + x2 + x1:x2

anova(mod1, mod2)

This will tell you if you need to worry about interaction or whether slopes
are parallel.

Regards, Mark.


Simon Pickett-4 wrote:
> 
> Cheers,
> 
> Actually I was using quasipoisson for my models, but for the puposes of my 
> example, it doesnt really matter.
> 
> I am trying to work out a way of quantifying whether the slopes (for
> years) 
> are covary with habitat scores.
> 
> The more I think about it, the more I am convinced that it isnt possible
> do 
> to that using a glm approach. I think I have to run separate models for
> each 
> site, calculate the gradient, then do a lm with gradient explained by 
> habitat score
> 
> Thanks, Simon.
> 
> 
> 
> 
>> On Tue, Mar 10, 2009 at 10:15 AM, Simon Pickett  
>> wrote:
>>
>>> This is partly a statistical question as well as a question about R, but 
>>> I am stumped!
>>
>>> I have count data from various sites across years. (Not all of the sites 
>>> in the study appear in all years). Each site has its own habitat score 
>>> "habitat" that remains constant across all years.
>>
>>> I want to know if counts declined faster on sites with high "habitat" 
>>> scores.
>>
>>> I can construct a model that tests for the effect of habitat as a main 
>>> effect, controlling for year
>>
>>> model1<-lmer(count~habitat+yr+(1|site), family=quasibinomial,data=m)
>>> model2<-lmer(count~yr+(1|site), family=quasibinomial,data=m)
>>> anova(model1,model2)
>>
>> I'm curious as to why you use the quasibinomial family for count data.
>> When you say "count data" do you mean just presence/absence or an
>> actual count of the number present?  Generally the binomial and
>> quasibinomial families are used when you have a binary response, and
>> the poisson or quasipoisson family are used for responses that are
>> counts.
>>
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/help-structuring-mixed-model-using-lmer%28%29-tp22436596p22442012.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] help structuring mixed model using lmer()

2009-03-10 Thread Mark Difford

Hi Simon,

Have a look at Chap. 11 of "An Introduction to R" (one of R's manuals),
which explains the different ways of specifying models using formulae.

Briefly, y ~ x1 * x2 expands to y ~ x1 + x2 + x1:x2, where the last term
(interaction term) amounts to a test of slope. Normally you would read its
significance from F/chisq/p-value. Many practitioners consider the L.Ratio
test to be a better option. For the fixed effects part in lmer() do:

mod1 <- y ~ x1 + x2  == y ~ x1 + x2
mod2 <- y ~ x1 * x2  == y ~ x1 + x2 + x1:x2

anova(mod1, mod2)

This will tell you if you need to worry about interaction or whether slopes
are parallel.

Regards, Mark.


Simon Pickett-4 wrote:
> 
> Cheers,
> 
> Actually I was using quasipoisson for my models, but for the puposes of my 
> example, it doesnt really matter.
> 
> I am trying to work out a way of quantifying whether the slopes (for
> years) 
> are covary with habitat scores.
> 
> The more I think about it, the more I am convinced that it isnt possible
> do 
> to that using a glm approach. I think I have to run separate models for
> each 
> site, calculate the gradient, then do a lm with gradient explained by 
> habitat score
> 
> Thanks, Simon.
> 
> 
> 
> 
>> On Tue, Mar 10, 2009 at 10:15 AM, Simon Pickett  
>> wrote:
>>
>>> This is partly a statistical question as well as a question about R, but 
>>> I am stumped!
>>
>>> I have count data from various sites across years. (Not all of the sites 
>>> in the study appear in all years). Each site has its own habitat score 
>>> "habitat" that remains constant across all years.
>>
>>> I want to know if counts declined faster on sites with high "habitat" 
>>> scores.
>>
>>> I can construct a model that tests for the effect of habitat as a main 
>>> effect, controlling for year
>>
>>> model1<-lmer(count~habitat+yr+(1|site), family=quasibinomial,data=m)
>>> model2<-lmer(count~yr+(1|site), family=quasibinomial,data=m)
>>> anova(model1,model2)
>>
>> I'm curious as to why you use the quasibinomial family for count data.
>> When you say "count data" do you mean just presence/absence or an
>> actual count of the number present?  Generally the binomial and
>> quasibinomial families are used when you have a binary response, and
>> the poisson or quasipoisson family are used for responses that are
>> counts.
>>
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/help-structuring-mixed-model-using-lmer%28%29-tp22436596p22441985.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] system() not accepting strings from cat()

2009-03-10 Thread ig2ar-saf1

Hi again R-ists,

How do you construct a string that you can pass to system()?

For instance. Say I do

> system("echo Hello!")
Hello!

That works. Now the alternative: I need to construct the string like this

> a <- "echo"
> b <- "Hello!"
> c <- "\n"
> cat(a, b, c)
echo Hello!

Looks nice... but see what happens when I try to use it

> system(cat(a, b, c))
echo Hello! 
Error in system(command, intern) : non-empty character argument expected

I have googled extensively in and out of r-lists but I can't find a solution.

Can anybody help?




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


Re: [R] Sparse PCA in R

2009-03-10 Thread Christos Hatzis
Take a look at the elasticnet package.

-Christos 

> -Original Message-
> From: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] On Behalf Of joris meys
> Sent: Tuesday, March 10, 2009 3:43 PM
> To: R-help Mailing List
> Subject: [R] Sparse PCA in R
> 
> Dear all,
> 
> I would like to perform a sparse PCA, but I didn't find any 
> library offering me this in R. Is there one available, or do 
> I have to write the functions myself?
> 
> Kind regards
> Joris Meys
> 
>   [[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 color certain area under curve

2009-03-10 Thread Matthieu Dubois

Just a small typo. I forgot a ) in the polygon function. 
The code must be: 
polygon(x = c(qrv[1], drv$x[select], qrv[2]), 
y = c(0, drv$y[select], 0), col='blue')

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

2009-03-10 Thread Jon Zadra

Hello,

I am confused about the order of nesting in mixed models using functions 
like aov(), lme(), lmer().


I have the following data:
n subjects in either condition A or B
each subject tested at each of 3 numerical values ("distance" = 
40,50,60), repeated 4 times for each of the 3 numerical values ("trial" 
= 1,2,3,4)


Variable summary:
Condition: 2 level factor
Distance: numerical (but only 3 values) in the same units as "y"
Trial: 4 level factor

I expect the subjects' data to differ due to condition and distance, and 
am doing repeated measurements to reduce any variability due to 
measurement error.


Currently I'm using this model:

lme(y ~ Condition + Distance, random = ...)

the question is how do I organize the random statement?  Is it:
random = ~1 | Subject
random = ~1 | Subject/Trial
random = ~1 | Trial/Subject
random = ~1 | Condition/Distance/Subject/Trial
...etc, or something else entirely?

Mostly I'm unclear about whether the Trials should be grouped under 
subject because I expect the trials to be more similar within a subject 
than across subjects, or whether subjects should be grouped under trials 
because the trials are going to differ depending on the subject.  If 
trials should be grouped under subjects, then do the condition or 
distance belong as well, since the trials will be most similar within 
each distance within each subject?


Thanks in advance!

- Jon


--
Jon Zadra
Department of Psychology
University of Virginia
P.O. Box 400400
Charlottesville VA 22904
(434) 982-4744
email: za...@virginia.edu


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


Re: [R] ordering

2009-03-10 Thread aaron wells

Thanks Peter, that did the trick.  I'll modify my function so that the numeric 
conversion is done automatically thus saving me the extra step of converting 
later on.

 

  Aaron Wells
 
> Subject: RE: [R] ordering
> Date: Wed, 11 Mar 2009 08:41:50 +1300
> From: palsp...@hortresearch.co.nz
> To: awell...@hotmail.com; r-help@r-project.org
> 
> Kia ora Aaron
> 
> As you have identified, test[,2] is not numeric - it is probably factor.
> Your function must have made the conversion, so you may want to modify
> that. Alternative, try:
> 
> test[order(as.numeric(as.character(test[,2]))),] 
> 
> BTW, str(test) is a good way to find out more about the structure of
> your object.
> 
> HTH 
> 
> Peter Alspach
> 
> 
> 
> 
> > -Original Message-
> > From: r-help-boun...@r-project.org 
> > [mailto:r-help-boun...@r-project.org] On Behalf Of aaron wells
> > Sent: Wednesday, 11 March 2009 8:30 a.m.
> > To: r-help@r-project.org
> > Subject: [R] ordering
> > 
> > 
> > Hello, I would like to order a matrix by a specific column. 
> > For instance:
> > 
> > 
> > 
> > > test
> > [,1] [,2] [,3]
> > [1,] 1 100 21
> > [2,] 2 3 22
> > [3,] 3 100 23
> > [4,] 4 60 24
> > [5,] 5 55 25
> > [6,] 6 45 26
> > [7,] 7 75 27
> > [8,] 8 12 28
> > [9,] 9 10 29
> > [10,] 10 22 30
> > >
> > 
> > test[order(test[,2]),]
> > [,1] [,2] [,3]
> > [1,] 2 3 22
> > [2,] 9 10 29
> > [3,] 8 12 28
> > [4,] 10 22 30
> > [5,] 6 45 26
> > [6,] 5 55 25
> > [7,] 4 60 24
> > [8,] 7 75 27
> > [9,] 1 100 21
> > [10,] 3 100 23
> > 
> > 
> > This works well and good in the above example matrix. 
> > However in the matrix that I actually want to sort (derived 
> > from a function that I wrote) I get something like this:
> > 
> > 
> > 
> > > test[order(as.numeric(test[,2])),] ### First column is row.names
> > 
> > 
> > f con f.1 cov f.2 minimum f.3 maximum f.4 cl
> > asahi * 100 * 1 * 0.1 * 2 * test
> > castet * 100 * 2 * 0.1 * 5 * test
> > clado * 100 * 1 * 0.7 * 2 * test
> > aulac * 33 * 0 * 0.1 * 0.1 * test
> > buell * 33 * 0 * 0.1 * 0.1 * test
> > camlas * 33 * 0 * 0.1 * 0.1 * test
> > carbig * 33 * 1 * 1 * 1 * test
> > poaarc * 67 * 0 * 0.1 * 0.1 * test
> > polviv * 67 * 0 * 0.1 * 0.1 * test
> > 
> > 
> > 
> > 
> > where R interprets 100 to be the lowest value and orders 
> > increasing from there. 
> > 
> > 
> > 
> > > is.numeric(test[,2])
> > [1] FALSE
> > > is.double(test[,2])
> > [1] FALSE
> > > is.integer(test[,2])
> > [1] FALSE
> > > is.real(test[,2])
> > [1] FALSE
> > 
> > 
> > 
> > 
> > My questions are: Why is this happening? and How do I fix it? 
> > 
> > 
> > 
> > Thanks in advance!
> > 
> > 
> > 
> > Aaron Wells
> > 
> > _
> > 
> > 
> > cns!503D1D86EBB2B53C!2285.entry?ocid=TXT_TAGLM_WL_UGC_Contacts_032009
> > [[alternative HTML version deleted]]
> > 
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide 
> > http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> > 
> 
> The contents of this e-mail are confidential and may be subject to legal 
> privilege.
> If you are not the intended recipient you must not use, disseminate, 
> distribute or
> reproduce all or any part of this e-mail or attachments. If you have received 
> this
> e-mail in error, please notify the sender and delete all material pertaining 
> to this
> e-mail. Any opinion or views expressed in this e-mail are those of the 
> individual
> sender and may not represent those of The New Zealand Institute for Plant and
> Food Research Limited.

_



[[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] ordering

2009-03-10 Thread David Winsemius
A) I predict that if you apply the str function to the second test  
that you will find that "con" is not numeric but rather of class  
character or factor. And the second test is probably not a matrix but  
rather a dataframe. Matrices in R need to have all their elements of  
the same class.


B) Read the FAQ ... find the one that tells you how to convert factors  
to numeric.


--
David Winsemius

On Mar 10, 2009, at 3:29 PM, aaron wells wrote:



Hello, I would like to order a matrix by a specific column. For  
instance:





test

 [,1] [,2] [,3]
[1,]1  100   21
[2,]23   22
[3,]3  100   23
[4,]4   60   24
[5,]5   55   25
[6,]6   45   26
[7,]7   75   27
[8,]8   12   28
[9,]9   10   29
[10,]   10   22   30




test[order(test[,2]),]
 [,1] [,2] [,3]
[1,]23   22
[2,]9   10   29
[3,]8   12   28
[4,]   10   22   30
[5,]6   45   26
[6,]5   55   25
[7,]4   60   24
[8,]7   75   27
[9,]1  100   21
[10,]3  100   23


This works well and good in the above example matrix.  However in  
the matrix that I actually want to sort (derived from a function  
that I wrote) I get something like this:





test[order(as.numeric(test[,2])),] ### First column is row.names



f con f.1 cov f.2 minimum f.3 maximum f.4   cl
asahi* 100   *   1   * 0.1   *   2   * test
castet   * 100   *   2   * 0.1   *   5   * test
clado* 100   *   1   * 0.7   *   2   * test
aulac*  33   *   0   * 0.1   * 0.1   * test
buell*  33   *   0   * 0.1   * 0.1   * test
camlas   *  33   *   0   * 0.1   * 0.1   * test
carbig   *  33   *   1   *   1   *   1   * test
poaarc   *  67   *   0   * 0.1   * 0.1   * test
polviv   *  67   *   0   * 0.1   * 0.1   * test




where R interprets 100 to be the lowest value and orders increasing  
from there.





is.numeric(test[,2])

[1] FALSE

is.double(test[,2])

[1] FALSE

is.integer(test[,2])

[1] FALSE

is.real(test[,2])

[1] FALSE




My questions are:  Why is this happening? and How do I fix  it?



Thanks in advance!



 Aaron Wells

_


cns!503D1D86EBB2B53C!2285.entry?ocid=TXT_TAGLM_WL_UGC_Contacts_032009
[[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
Heritage Laboratories
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] How to color certain area under curve

2009-03-10 Thread Matthieu Dubois
  ucalgary.ca> writes:

> 
> For a given random variable rv, for instance, rv = rnorm(1000),
> I plot its density curve and calculate some quantiles:
> plot(density(rv))
> P10P50P90 = = quantile(rv,probs = c(10,50,90)/100)
> I would like to color the area between P10 and P90 and under the curve
> and mark the P50 on the curve.
> 
> > rv = rnorm(1000)
> > plot(density(rv))
> > P10P50P90 = = quantile(rv,probs = c(10,50,90)/100)
> 
> Could you please teach me how to do these using R?
> Thanks,
> -james
> 

see ?polygon

Here after is an example of the use of polygon to solve your problem: 
rv <- rnorm(1000)
drv <- density(rv)
plot(drv)

# further steps: 
# 1. compute quantiles
# 2. determine the x and y of the area that must be drawn
# 3. drawn
# 4. add q.5 info
qrv <- quantile(rv, prob=c(0.1, 0.9))
select <- qrv[1] <= drv$x & drv$x <= qrv[2]
polygon(x = c(qrv[1], drv$x[select], qrv[2]), 
y = c(0, drv$y[select], 0, col='blue')
abline(v= quantile(rv, p=0.5), lty=2)

Hope this will help. 

Matthieu

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

2009-03-10 Thread joris meys
Dear all,

I would like to perform a sparse PCA, but I didn't find any library offering
me this in R. Is there one available, or do I have to write the functions
myself?

Kind regards
Joris Meys

[[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] ordering

2009-03-10 Thread Peter Alspach
Kia ora Aaron

As you have identified, test[,2] is not numeric - it is probably factor.
Your function must have made the conversion, so you may want to modify
that.  Alternative, try:

test[order(as.numeric(as.character(test[,2]))),] 

BTW, str(test) is a good way to find out more about the structure of
your object.

HTH 

Peter Alspach




> -Original Message-
> From: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] On Behalf Of aaron wells
> Sent: Wednesday, 11 March 2009 8:30 a.m.
> To: r-help@r-project.org
> Subject: [R] ordering
> 
> 
> Hello, I would like to order a matrix by a specific column. 
> For instance:
> 
>  
> 
> > test
>   [,1] [,2] [,3]
>  [1,]1  100   21
>  [2,]23   22
>  [3,]3  100   23
>  [4,]4   60   24
>  [5,]5   55   25
>  [6,]6   45   26
>  [7,]7   75   27
>  [8,]8   12   28
>  [9,]9   10   29
> [10,]   10   22   30
> >
> 
>  test[order(test[,2]),]
>   [,1] [,2] [,3]
>  [1,]23   22
>  [2,]9   10   29
>  [3,]8   12   28
>  [4,]   10   22   30
>  [5,]6   45   26
>  [6,]5   55   25
>  [7,]4   60   24
>  [8,]7   75   27
>  [9,]1  100   21
> [10,]3  100   23
> 
> 
> This works well and good in the above example matrix.  
> However in the matrix that I actually want to sort (derived 
> from a function that I wrote) I get something like this:
> 
>  
> 
> > test[order(as.numeric(test[,2])),] ### First column is row.names
> 
> 
>  f con f.1 cov f.2 minimum f.3 maximum f.4   cl
> asahi* 100   *   1   * 0.1   *   2   * test
> castet   * 100   *   2   * 0.1   *   5   * test
> clado* 100   *   1   * 0.7   *   2   * test
> aulac*  33   *   0   * 0.1   * 0.1   * test
> buell*  33   *   0   * 0.1   * 0.1   * test
> camlas   *  33   *   0   * 0.1   * 0.1   * test
> carbig   *  33   *   1   *   1   *   1   * test
> poaarc   *  67   *   0   * 0.1   * 0.1   * test
> polviv   *  67   *   0   * 0.1   * 0.1   * test
> 
> 
>  
> 
> where R interprets 100 to be the lowest value and orders 
> increasing from there.  
> 
>  
> 
> > is.numeric(test[,2])
> [1] FALSE
> > is.double(test[,2])
> [1] FALSE
> > is.integer(test[,2])
> [1] FALSE
> > is.real(test[,2])
> [1] FALSE
> 
> 
>  
> 
> My questions are:  Why is this happening? and How do I fix  it? 
> 
>  
> 
> Thanks in advance!
> 
>  
> 
>   Aaron Wells
> 
> _
> 
> 
> cns!503D1D86EBB2B53C!2285.entry?ocid=TXT_TAGLM_WL_UGC_Contacts_032009
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 

The contents of this e-mail are confidential and may be subject to legal 
privilege.
 If you are not the intended recipient you must not use, disseminate, 
distribute or
 reproduce all or any part of this e-mail or attachments.  If you have received 
this
 e-mail in error, please notify the sender and delete all material pertaining 
to this
 e-mail.  Any opinion or views expressed in this e-mail are those of the 
individual
 sender and may not represent those of The New Zealand Institute for Plant and
 Food Research Limited.

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

2009-03-10 Thread aaron wells

Hello, I would like to order a matrix by a specific column. For instance:

 

> test
  [,1] [,2] [,3]
 [1,]1  100   21
 [2,]23   22
 [3,]3  100   23
 [4,]4   60   24
 [5,]5   55   25
 [6,]6   45   26
 [7,]7   75   27
 [8,]8   12   28
 [9,]9   10   29
[10,]   10   22   30
>

 test[order(test[,2]),]
  [,1] [,2] [,3]
 [1,]23   22
 [2,]9   10   29
 [3,]8   12   28
 [4,]   10   22   30
 [5,]6   45   26
 [6,]5   55   25
 [7,]4   60   24
 [8,]7   75   27
 [9,]1  100   21
[10,]3  100   23


This works well and good in the above example matrix.  However in the matrix 
that I actually want to sort (derived from a function that I wrote) I get 
something like this:

 

> test[order(as.numeric(test[,2])),] ### First column is row.names


 f con f.1 cov f.2 minimum f.3 maximum f.4   cl
asahi* 100   *   1   * 0.1   *   2   * test
castet   * 100   *   2   * 0.1   *   5   * test
clado* 100   *   1   * 0.7   *   2   * test
aulac*  33   *   0   * 0.1   * 0.1   * test
buell*  33   *   0   * 0.1   * 0.1   * test
camlas   *  33   *   0   * 0.1   * 0.1   * test
carbig   *  33   *   1   *   1   *   1   * test
poaarc   *  67   *   0   * 0.1   * 0.1   * test
polviv   *  67   *   0   * 0.1   * 0.1   * test


 

where R interprets 100 to be the lowest value and orders increasing from there. 
 

 

> is.numeric(test[,2])
[1] FALSE
> is.double(test[,2])
[1] FALSE
> is.integer(test[,2])
[1] FALSE
> is.real(test[,2])
[1] FALSE


 

My questions are:  Why is this happening? and How do I fix  it? 

 

Thanks in advance!

 

  Aaron Wells

_


cns!503D1D86EBB2B53C!2285.entry?ocid=TXT_TAGLM_WL_UGC_Contacts_032009
[[alternative HTML version deleted]]

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


Re: [R] help structuring mixed model using lmer()

2009-03-10 Thread Simon Pickett

Cheers,

Actually I was using quasipoisson for my models, but for the puposes of my 
example, it doesnt really matter.


I am trying to work out a way of quantifying whether the slopes (for years) 
are covary with habitat scores.


The more I think about it, the more I am convinced that it isnt possible do 
to that using a glm approach. I think I have to run separate models for each 
site, calculate the gradient, then do a lm with gradient explained by 
habitat score


Thanks, Simon.




On Tue, Mar 10, 2009 at 10:15 AM, Simon Pickett  
wrote:


This is partly a statistical question as well as a question about R, but 
I am stumped!


I have count data from various sites across years. (Not all of the sites 
in the study appear in all years). Each site has its own habitat score 
"habitat" that remains constant across all years.


I want to know if counts declined faster on sites with high "habitat" 
scores.


I can construct a model that tests for the effect of habitat as a main 
effect, controlling for year



model1<-lmer(count~habitat+yr+(1|site), family=quasibinomial,data=m)
model2<-lmer(count~yr+(1|site), family=quasibinomial,data=m)
anova(model1,model2)


I'm curious as to why you use the quasibinomial family for count data.
When you say "count data" do you mean just presence/absence or an
actual count of the number present?  Generally the binomial and
quasibinomial families are used when you have a binary response, and
the poisson or quasipoisson family are used for responses that are
counts.



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


Re: [R] puzzled by math on date-time objects

2009-03-10 Thread William Dunlap
median.default was changed between 2.7.1 and 2.8.1 to
call sum(...)/2 instead of mean(...) and that causes
the problem for POSIXct objects (sum fails but mean
works for them).

Bill Dunlap
TIBCO Software Inc - Spotfire Division
wdunlap tibco.com  

> -Original Message-
> From: William Dunlap 
> Sent: Tuesday, March 10, 2009 11:37 AM
> To: 'r-help@r-project.org'
> Subject: Re: [R] puzzled by math on date-time objects
> 
> Your problem arises in R 2.8.1 (and 2.9.0-devel, but not 2.7.0) when
> length(POSIXct object) is even, because median(POSIXct object)
> passes a POSIXct object to median.default, which calls
> sum() in the even length case.
> 
> >  median( as.POSIXct(Sys.time()))
> [1] "2009-03-10 10:28:46 PDT"
> >  median( as.POSIXct(rep(Sys.time(),2)))
> Error in Summary.POSIXct(c(1236706132.54740, 
> 1236706132.54740), na.rm = FALSE) :
>   'sum' not defined for "POSIXt" objects
> > traceback()
> 4: stop(gettextf("'%s' not defined for \"POSIXt\" objects", .Generic),
>domain = NA)
> 3: Summary.POSIXct(c(1236706132.54740, 1236706132.54740), 
> na.rm = FALSE)
> 2: median.default(as.POSIXct(rep(Sys.time(), 2)))
> 1: median(as.POSIXct(rep(Sys.time(), 2)))
> > version
>_
> platform   i686-pc-linux-gnu
> arch   i686
> os linux-gnu
> system i686, linux-gnu
> status
> major  2
> minor  8.1
> year   2008
> month  12
> day22
> svn rev47281
> language   R
> version.string R version 2.8.1 (2008-12-22)
> 
> Bill Dunlap
> TIBCO Software Inc - Spotfire Division
> wdunlap tibco.com 
> 
> 
> [R] puzzled by math on date-time objects
> 
> Denis Chabot chabotd at globetrotter.net 
> Tue Mar 10 16:44:07 CET 2009
> Previous message: [R] nonmetric clustering
> Next message: [R] perform subgroup meta-analysis and create 
> forest plot   displaying subgroups
> Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
> Hi,
> 
> I don't understand the following. When I create a small 
> artificial set  
> of date information in class POSIXct, I can calculate the 
> mean and the  
> median:
> 
> a = as.POSIXct(Sys.time())
> a = a + 60*0:10; a
> 
>   [1] "2009-03-10 11:30:16 EDT" "2009-03-10 11:31:16 EDT" 
> "2009-03-10  
> 11:32:16 EDT"
>   [4] "2009-03-10 11:33:16 EDT" "2009-03-10 11:34:16 EDT" 
> "2009-03-10  
> 11:35:16 EDT"
>   [7] "2009-03-10 11:36:16 EDT" "2009-03-10 11:37:16 EDT" 
> "2009-03-10  
> 11:38:16 EDT"
> [10] "2009-03-10 11:39:16 EDT" "2009-03-10 11:40:16 EDT"
> 
> median(a)
> [1] "2009-03-10 11:35:16 EDT"
> mean(a)
> [1] "2009-03-10 11:35:16 EDT"
> 
> 
> But for real data (for this post, a short subset is in object 
> c)  that  
> I have converted into a POSIXct object, I cannot calculate 
> the median  
> with median(), though I do get it with summary():
> 
> c
>   [1] "2009-02-24 14:51:18 EST" "2009-02-24 14:51:19 EST" 
> "2009-02-24  
> 14:51:19 EST"
>   [4] "2009-02-24 14:51:20 EST" "2009-02-24 14:51:20 EST" 
> "2009-02-24  
> 14:51:21 EST"
>   [7] "2009-02-24 14:51:21 EST" "2009-02-24 14:51:22 EST" 
> "2009-02-24  
> 14:51:22 EST"
> [10] "2009-02-24 14:51:22 EST"
> 
> class(c)
> [1] "POSIXt"  "POSIXct"
> 
> median(c)
> Erreur dans Summary.POSIXct(c(1235505080.6, 1235505081.1), na.rm =  
> FALSE) :
>'sum' not defined for "POSIXt" objects
> 
> One difference is that in my own date-time series, some events are  
> repeated (the original data contained fractions of seconds). 
> But then,  
> why can I get a median through summary()?
> 
> summary(c)
>   Min.   1st  
> Qu.Median
> "2009-02-24 14:51:18 EST" "2009-02-24 14:51:19 EST" "2009-02-24  
> 14:51:20 EST"
>   Mean   3rd  
> Qu.  Max.
> "2009-02-24 14:51:20 EST" "2009-02-24 14:51:21 EST" "2009-02-24  
> 14:51:22 EST"
> 
> Thanks in advance,
> 
> 
> Denis Chabot
> 
> sessionInfo()
> R version 2.8.1 Patched (2009-01-19 r47650)
> i386-apple-darwin9.6.0
> 
> locale:
> fr_CA.UTF-8/fr_CA.UTF-8/C/C/fr_CA.UTF-8/fr_CA.UTF-8
> 
> attached base packages:
> [1] stats graphics  grDevices utils datasets  methods   base
> 
> other attached packages:
> [1] doBy_3.7 chron_2.3-30
> 
> loaded via a namespace (and not attached):
> [1] Hmisc_3.5-2 cluster_1.11.12 grid_2.8.1  lattice_0.17-20  
> tools_2.8.1
> 

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


Re: [R] puzzled by math on date-time objects

2009-03-10 Thread William Dunlap
Your problem arises in R 2.8.1 (and 2.9.0-devel, but not 2.7.0) when
length(POSIXct object) is even, because median(POSIXct object)
passes a POSIXct object to median.default, which calls
sum() in the even length case.

>  median( as.POSIXct(Sys.time()))
[1] "2009-03-10 10:28:46 PDT"
>  median( as.POSIXct(rep(Sys.time(),2)))
Error in Summary.POSIXct(c(1236706132.54740, 1236706132.54740), na.rm =
FALSE) :
  'sum' not defined for "POSIXt" objects
> traceback()
4: stop(gettextf("'%s' not defined for \"POSIXt\" objects", .Generic),
   domain = NA)
3: Summary.POSIXct(c(1236706132.54740, 1236706132.54740), na.rm = FALSE)
2: median.default(as.POSIXct(rep(Sys.time(), 2)))
1: median(as.POSIXct(rep(Sys.time(), 2)))
> version
   _
platform   i686-pc-linux-gnu
arch   i686
os linux-gnu
system i686, linux-gnu
status
major  2
minor  8.1
year   2008
month  12
day22
svn rev47281
language   R
version.string R version 2.8.1 (2008-12-22)

Bill Dunlap
TIBCO Software Inc - Spotfire Division
wdunlap tibco.com 


[R] puzzled by math on date-time objects

Denis Chabot chabotd at globetrotter.net 
Tue Mar 10 16:44:07 CET 2009
Previous message: [R] nonmetric clustering
Next message: [R] perform subgroup meta-analysis and create forest plot
displaying subgroups
Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi,

I don't understand the following. When I create a small artificial set  
of date information in class POSIXct, I can calculate the mean and the  
median:

a = as.POSIXct(Sys.time())
a = a + 60*0:10; a

  [1] "2009-03-10 11:30:16 EDT" "2009-03-10 11:31:16 EDT" "2009-03-10  
11:32:16 EDT"
  [4] "2009-03-10 11:33:16 EDT" "2009-03-10 11:34:16 EDT" "2009-03-10  
11:35:16 EDT"
  [7] "2009-03-10 11:36:16 EDT" "2009-03-10 11:37:16 EDT" "2009-03-10  
11:38:16 EDT"
[10] "2009-03-10 11:39:16 EDT" "2009-03-10 11:40:16 EDT"

median(a)
[1] "2009-03-10 11:35:16 EDT"
mean(a)
[1] "2009-03-10 11:35:16 EDT"


But for real data (for this post, a short subset is in object c)  that  
I have converted into a POSIXct object, I cannot calculate the median  
with median(), though I do get it with summary():

c
  [1] "2009-02-24 14:51:18 EST" "2009-02-24 14:51:19 EST" "2009-02-24  
14:51:19 EST"
  [4] "2009-02-24 14:51:20 EST" "2009-02-24 14:51:20 EST" "2009-02-24  
14:51:21 EST"
  [7] "2009-02-24 14:51:21 EST" "2009-02-24 14:51:22 EST" "2009-02-24  
14:51:22 EST"
[10] "2009-02-24 14:51:22 EST"

class(c)
[1] "POSIXt"  "POSIXct"

median(c)
Erreur dans Summary.POSIXct(c(1235505080.6, 1235505081.1), na.rm =  
FALSE) :
   'sum' not defined for "POSIXt" objects

One difference is that in my own date-time series, some events are  
repeated (the original data contained fractions of seconds). But then,  
why can I get a median through summary()?

summary(c)
  Min.   1st  
Qu.Median
"2009-02-24 14:51:18 EST" "2009-02-24 14:51:19 EST" "2009-02-24  
14:51:20 EST"
  Mean   3rd  
Qu.  Max.
"2009-02-24 14:51:20 EST" "2009-02-24 14:51:21 EST" "2009-02-24  
14:51:22 EST"

Thanks in advance,


Denis Chabot

sessionInfo()
R version 2.8.1 Patched (2009-01-19 r47650)
i386-apple-darwin9.6.0

locale:
fr_CA.UTF-8/fr_CA.UTF-8/C/C/fr_CA.UTF-8/fr_CA.UTF-8

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

other attached packages:
[1] doBy_3.7 chron_2.3-30

loaded via a namespace (and not attached):
[1] Hmisc_3.5-2 cluster_1.11.12 grid_2.8.1  lattice_0.17-20  
tools_2.8.1

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


Re: [R] a general question

2009-03-10 Thread culpritNr1

Hello Bogdan,

Put in those terms, option b looks more defensible. It sounds like a test of
two proportions, sometimes called z-test. The problem is that, for that test
to be used, you must be sampling from large population.

You know that under regular ChIP-seq sequencing we are lucky if we get 10
reads in a particuar region of interest. So, we get a population and that
population itself is small. So, z-test does not look applicable. Google for
z-test and you'll see the conditions.

What to do then?

Well, forget comparing signal to backgroung and, instead, compare directly
number of reads in the experiment versus number of reads in the control.
Actually, you simplify your algorithm by not having to define (and defend)
an arbitrary area to call "background".

An example?

Sure! Check out "PeakSeq enables systematic scoring of ChIP-seq experiments
relative to controls", Joel Rozowsky1, Ghia Euskirchen2, Raymond K
Auerbach3, Zhengdong D Zhang1, Theodore Gibson1, Robert Bjornson4, Nicholas
Carriero4, Michael Snyder1,2 & Mark B Gerstein1,3,4. Nature Biotechnology,
2009.

Take a look at it and let us know what you think.

Your culpritNr1

PS: next time, please go for a more descriptive subject such as ChIP-seq.
That would help in the future when we need to over old messages. Don't you
think?




Bogdan Tanasa wrote:
> 
> Hi everyone,
> 
> Although this question is more related to ChIP and ChIP-seq, it could be
> probably anchored in a more general statistical context.
> 
> The question is : what method is better  to assess the significance of the
> change  in a signal (the signal can be DNA binding, for instance) given
> the
> background and 2 conditions.
> 
> <. condition1 (eg no treatment) :  background = 1;
> signal = 5;
> 
> <. condition2 (eg hormonal treatment) : background = 3;
>signal = 6.
> 
> The methods can be :
> 
> a. substract the background : i.e. (signal_treatment -
> background_treatment)
> / (signal_no_treatment - background_no_treatment)
> 
> b. calculate the fold change: i.e. (signal_treatment /
> background_treatment)
> / (signal_no_treatment / background_no_treatment)
> 
> c. any other method ? i.e. (signal_treatment - signal_no_treatment)  / (
> background_treatment - background_no_treatment)
> 
> Thank you very much.
> 
> Bogdan
> 
>   [[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.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/a-general-question-tp22382289p22440722.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] Changing factor to numeric

2009-03-10 Thread Tal Galili
By the way, it could be that one of your numbers has "space" in them. in
which case, R tends to turn the entire vector into a factor. try opening the
file in a spreadsheet like excel, and do "search replace" on " " with "".
and see how many it catches.


Tal





On Tue, Mar 10, 2009 at 7:25 AM, ojal john owino <
ojal.johnow...@googlemail.com> wrote:

> Dear Users,
> I have a variable in my dataset which is of type factor. But it actually
> contains numeric entries which like 5.735  4.759 . This is because the
> data was read from a CSV file into R and this variable contained other
> charaters which were not numeric. I have now dropped the records with the
> characters which are not numeric for this variable and want to change it to
> numeric srotage type.
>
> I have tried using as.numeric() function but it changes the values in the
> variable to what I think are the ranks of the individual values of the
> varible in the dataset. For example if 5.735 is the current content in the
> field, then the new object created by as.numeric will contain a value like
> 680 if the 5.735 was the highest value for the varible and the dataset had
> 680 records.
>
>
> How can I change the storage type without changing the contents of this
> variable in this case?
>
> Thanks for your consideration.
>
>
>
> --
> Ojal John Owino
> P.O Box 230-80108
> Kilifi, Kenya.
> Mobile:+254 728 095 710
>
>[[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.
>



-- 
--


My contact information:
Tal Galili
Phone number: 972-50-3373767
FaceBook: Tal Galili
My Blogs:
www.talgalili.com
www.biostatistics.co.il

[[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] Alternative to interp.surface() offered

2009-03-10 Thread Waichler, Scott R
I wanted a simple function for bilinear interpolation on a 2-D grid, and
interp.surface() in the fields package didn't quite suit my needs.  In
particular, it requires uniform spacing between grid points.  It also
didn't have the "visual" reference frame I was looking for.  Here is an
alternative function, followed by an example.

# A function for  bilinear interpolation on a 2-d grid, based on the
# interp.surface() from the fields package and code by Steve Koehler.
# The points of the grid do not have to be uniformly spaced.  Looking at
the 2-d
# grid in plan view, the origin is at upper left, so y (row) index
increases
# downward.  findInterval() is used to locate the new coordinates on the
grid.
#
# Scott Waichler, scott.waich...@pnl.gov, 03/10/09.  

my.interp.surface <- function (obj, loc) {
  # obj is a surface object like the list for contour or image.
  # loc is a matrix of (x, y) locations 
  x <- obj$x
  y <- obj$y
  x.new <- loc[,1]
  y.new <- loc[,2]
  z <- obj$z

  ind.x <- findInterval(x.new, x, all.inside=T)
  ind.y <- findInterval(y.new, y, all.inside=T)

  ex <- (x.new - x[ind.x]) / (x[ind.x + 1] - x[ind.x])
  ey <- (y.new - y[ind.y]) / (y[ind.y + 1] - y[ind.y])

  # set weights for out-of-bounds locations to NA
  ex[ex < 0 | ex > 1] <- NA
  ey[ey < 0 | ey > 1] <- NA

  return(
  z[cbind(ind.y, ind.x)] * (1 - ex) * (1 - ey) +  # upper
left
  z[cbind(ind.y + 1, ind.x)] * (1 - ex) * ey   +  # lower
left
  z[cbind(ind.y + 1, ind.x + 1)] * ex   * ey   +  # lower
right
  z[cbind(ind.y, ind.x + 1)] * ex   * (1 - ey)# upper
right
)
}

## # An example.
## # z matrix, y index increasing downwards
## #   4 5 6 7 8
## #   3 4 5 6 7
## #   2 3 4 5 6
## #   1 2 3 4 5
## z.vec <- c(4,5,6,7,8,3,4,5,6,7,2,3,4,5,6,1,2,3,4,5) # "read in" the
data for the matrix
## x.mat <- 1:5# x coordinates of the z values
## y.mat <- seq(100, 400, by=100)  # y coordinates of the z values
## obj <- list(x = x.mat, y = y.mat, z = matrix(z.vec, ncol=5, byrow=T))
# grid you want to interpolate on
## x.out <- round(runif(6, min = min(x.mat), max = max(x.mat)), 2)  # x
for points you want interpolate to
## y.out <- round(runif(6, min = min(y.mat), max = max(y.mat)), 2)  # y
for points you want interpolate to
## loc <- cbind(x.out, y.out)
## z.out <- my.interp.surface(obj, loc)
## cat(file="", "x.out = ", loc[,1], "\n", "y.out = ", loc[,2], "\n",
"z.out = ", round(z.out, 2), "\n")

Regards,
Scott Waichler
Pacific Northwest National Laboratory
Richland, WA   99352USA
scott.waich...@pnl.gov

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


[R] (no subject)

2009-03-10 Thread Shuying Yang

Dear Members,

 

I have a question about using R2WinBUGS to obtain the WinBUGS results. 

 

By default, when R2WinBUGS returns summary stats, I got mean, sd, 2.5%, 25%, 
median, 75% and 97.5%.  Could anyone tell me how to modify the code to obtain 
5% and 95% summary results?

 

Many thanks

 

Alice

 

 

_
[[elided Hotmail spam]]

[[alternative HTML version deleted]]

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


Re: [R] help structuring mixed model using lmer()

2009-03-10 Thread Douglas Bates
On Tue, Mar 10, 2009 at 10:15 AM, Simon Pickett  wrote:

> This is partly a statistical question as well as a question about R, but I am 
> stumped!

> I have count data from various sites across years. (Not all of the sites in 
> the study appear in all years). Each site has its own habitat score "habitat" 
> that remains constant across all years.

> I want to know if counts declined faster on sites with high "habitat" scores.

> I can construct a model that tests for the effect of habitat as a main 
> effect, controlling for year

> model1<-lmer(count~habitat+yr+(1|site), family=quasibinomial,data=m)
> model2<-lmer(count~yr+(1|site), family=quasibinomial,data=m)
> anova(model1,model2)

I'm curious as to why you use the quasibinomial family for count data.
 When you say "count data" do you mean just presence/absence or an
actual count of the number present?  Generally the binomial and
quasibinomial families are used when you have a binary response, and
the poisson or quasipoisson family are used for responses that are
counts.

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

2009-03-10 Thread guox
For a given random variable rv, for instance, rv = rnorm(1000),
I plot its density curve and calculate some quantiles:
plot(density(rv))
P10P50P90 = = quantile(rv,probs = c(10,50,90)/100)
I would like to color the area between P10 and P90 and under the curve
and mark the P50 on the curve.

> rv = rnorm(1000)
> plot(density(rv))
> P10P50P90 = = quantile(rv,probs = c(10,50,90)/100)

Could you please teach me how to do these using R?
Thanks,
-james

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


Re: [R] popular R packages

2009-03-10 Thread Ajay ohri
Pricing each download at 99 cents ( the same as a song from I Tunes) can
measure users more accurately.
Thats my 2 cents anyways.

On Tue, Mar 10, 2009 at 9:54 PM, Max Kuhn  wrote:

> If is easy to get the download numbers, we should do it and deal with
> the interpretation issues. I'd like to know the numbers so I can
> understand which (of my) packages have the most usage.
>
> One other compication about # downloads: I suspect that a package
> being on teh depends/suggests/imports list of another package might be
> a big driver with respect to how many times that it was downloaded.
>
> If I remember correctly, about 5 years ago Bioconductor asked for
> volunteers to review packages to get detailed, specific feedback by
> people who use the package (and should be fairly R proficient). I
> think that this is pretty important and something like Crantastic is a
> good interface. I personally got a lot out of the comments the a JSS
> reviewer had for a package.
>
> --
>
> Max
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] popular R packages

2009-03-10 Thread Dylan Beaudette
On Tuesday 10 March 2009, Frank E Harrell Jr wrote:
> Gabor Grothendieck wrote:
> > On Tue, Mar 10, 2009 at 6:14 AM, Jim Lemon  wrote:
> >> Gabor Grothendieck wrote:
> >>> R-Forge already has this but I don't think its used much.  R-Forge
> >>> does allow authors to opt out which seems sensible lest it deter
> >>> potential authors from submitting packages.
> >>>
> >>> I think objective quality metrics are better than ratings, e.g. does
> >>> package
> >>> have a vignette, has package had a release within the last year,
> >>> does package have free software license, etc.  That would have
> >>> the advantage that authors might react to increase their package's
> >>> quality assessment resulting in an overall improvement in quality on
> >>> CRAN that would result in more of a pro-active cycle whereas ratings
> >>> are reactive
> >>> and don't really encourage improvement.
> >>
> >> I beg to offer an alternative assessment of quality. Do users download
> >> the package and find it useful? If so, they are likely to download it
> >> again when it is updated.
> >
> > I was referring to motivating authors, not users, so that CRAN improves.
> >
> >> Much as I appreciate the convenience of vignettes, regular
> >> updates and the absolute latest GPL license, a perfectly dud package can
> >> have all of these things. If a package is downloaded upon first release
> >> and
> >
> > These are nothing but the usual  FUD against quality improvement, i.e.
> > the quality metrics are not measuring what you want but the fact is that
> > quality metrics can work and have had huge successes.  Also I think
> > objective measures would be more accepted by authors than ratings. No one
> > is going to be put off that their package has no vignette when obviously
> > it doesn't and the authors are free to add one and instantly improve
> > their package's rating.
> >
> >> not much thereafter, the maintainer might be motivated to attend to its
> >> shortcomings of utility rather than incrementing the version number
> >> every month or so. Downloads, as many have pointed out, are not a direct
> >> assessment of quality, but if I saw a package that just kept getting
> >> downloaded, version after version, I would be much more likely to check
> >> it out myself and perhaps even write a review for Hadley's neat site.
> >> Which I will try to do tonight.
> >
> > I was arguing for objective metrics rather than ratings. Downloading is
> > not a rating but is objective although there are measurement problems as
> > has been pointed out.  Also, the worst feature is that it does not react
> > to changes in quality very quickly making it anti-motivating.
>
> Gabor I think your approach will have more payoff in the long run.  I
> would suggest one other metric: the number of lines of code in the
> 'examples' section of all the package's help files.
>
> Frank

Absolutely. From the perspective of a user, not an expert, packages with a 
good vignette and lots of examples are by far my favorite and most used.

Dylan

-- 
Dylan Beaudette
Soil Resource Laboratory
http://casoilresource.lawr.ucdavis.edu/
University of California at Davis
530.754.7341

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Plots of different aspect ratios on one page, base aligned(trellis.print)

2009-03-10 Thread Saptarshi Guha
Hello,
I have an example of a 2 paneled plot, with two different aspect
ratios displayed on one page.
An example would help

n=20
x1 <- cumsum(runif(n))
x2 <- cumsum(runif(n))
d <- data.frame(val=c(x1,x2),id=c(1:n,1:n), nt=c(rep("A",n),rep("B",n)))
u1 <- xyplot(val~id | nt, data=d,aspect=1,layout=c(1,2))
u2 <- xyplot(val~id|nt, data=d,aspect=0.5,layout=c(1,2))
postscript("~/k.ps",colormodel="rgb",paper="letter",horiz=T)
print(u1,position=c(0,0,1/3,1),more=T,newpage=T)
print(u2,position=c(1/3,0,1,1),more=F,newpage=F)
dev.off()


The two figures are not base aligned. I would like them share the same
the baseline and same height, if necessary the paper width and height
can be adjusted
( i tried setting the paper width and height to no avail).

Is the way to base align the two figures? Do I have to get down the grid level?

Regards
Saptarshi Guha

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


Re: [R] File permissions

2009-03-10 Thread culpritNr1

Great. I tried chmod (which does not exist) but I didn't know that there was
sys.chmod.

Thank you.



Prof Brian Ripley wrote:
> 
> On Tue, 10 Mar 2009, ig2ar-s...@yahoo.co.uk wrote:
> 
>>
>> Hello fellow R-ists,
>>
>> How do I change file permissions?
>>
>> I know that file.access can display permission information but how 
>> do I SET those permissions?
> 
> Well, file.info is better are displaying permission information, and 
> Sys.chmod set them in the format used by file.info.
> 
>> Thank you
>>
>> Your culpritNr1
> 
> -- 
> Brian D. Ripley,  rip...@stats.ox.ac.uk
> Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
> University of Oxford, Tel:  +44 1865 272861 (self)
> 1 South Parks Road, +44 1865 272866 (PA)
> Oxford OX1 3TG, UKFax:  +44 1865 272595
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/File-permissions-tp22437684p22439004.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] How to stop loop inside status ? ( haplo.stats package )

2009-03-10 Thread Nash
How to stop loop inside status ?

require(haplo.stats)

## normal status
y=rep(c(0,1),each=50)
geno=as.data.frame(matrix(sample(c("A","G","T","C"),600,replace=T),100,6))

hs<- haplo.score(y, geno, trait.type="binomial", offset = NA, x.adj = NA,
min.count=5, 
locus.label=NA, miss.val=c(0,NA), haplo.effect="additive",
eps.svd=1e-5, simulate=TRUE,
 sim.control=score.sim.control(min.sim=200,max.sim=500))

hs$score.global.p.sim

## find loop inside ,and I can't stop it!
geno=as.data.frame(matrix("G",100,6))
hs<- haplo.score(y, geno, trait.type="binomial", offset = NA, x.adj = NA,
min.count=5, 
locus.label=NA, miss.val=c(0,NA), haplo.effect="additive",
eps.svd=1e-5, simulate=TRUE,
 sim.control=score.sim.control(min.sim=200,max.sim=500))

hs$score.global.p.sim

How to stop loop inside status ?

--
Nash - morri...@ibms.sinica.edu.tw

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

2009-03-10 Thread Paul C. Boutros
Yup, that would be my work-around.

I was hoping for a cleaner way of doing this, though, because I am
calculating cex based on other properties of the data-points, so that it
becomes a continuous variable.

-Original Message-
From: Sundar Dorai-Raj [mailto:sdorai...@gmail.com] 
Sent: Tuesday, March 10, 2009 12:01 PM
To: Paul C. Boutros
Cc: r-help@r-project.org
Subject: Re: [R] Lattice: Customizing point-sizes with groups

Sorry, I missed your point the first time. Why not create a group for
each subset then?

xyplot(y ~ x, temp, groups = interaction(cex, groups),
   par.settings = list(
 superpose.symbol = list(
   cex = c(1, 2, 3, 4),
   pch = 19,
   col = c("blue", "red", "green", "purple"


On Tue, Mar 10, 2009 at 8:11 AM, Paul C. Boutros
 wrote:
> Hi Sundar,
>
> Thanks for your help!  Unfortunately your code seems to give the same
> result.  Compare this:
>
> temp <- data.frame(
>   x = 1:10,
>   y = 1:10,
>   cex = rep( c(1,3), 5),
>   col = c( rep("blue", 5), rep("red", 5) ),
>   groups = c( rep("A", 5), rep("B", 5) )
>   );
>
> xyplot(y ~ x, temp, groups = groups,
>   par.settings = list(
> superpose.symbol = list(
>   cex = c(1, 3),
>   pch = 19,
>   col = c("blue", "red"
>
> And this:
> xyplot(y ~ x, temp, cex = temp$cex, col = temp$col, pch = 19);
>
> Once I introduce groups, I lose the ability to customize individual
> data-points and seem only to be able to customize entire groups.
>
> Paul
>
> -Original Message-
> From: Sundar Dorai-Raj [mailto:sdorai...@gmail.com]
> Sent: Tuesday, March 10, 2009 5:49 AM
> To: paul.bout...@utoronto.ca
> Cc: r-help@r-project.org
> Subject: Re: [R] Lattice: Customizing point-sizes with groups
>
> Try this:
>
> xyplot(y ~ x, temp, groups = groups,
>   par.settings = list(
> superpose.symbol = list(
>   cex = c(1, 3),
>   pch = 19,
>   col = c("blue", "red"
>
> See:
>
> str(trellis.par.get())
>
> for other settings you might want to change.
>
> Also, you should drop the ";" from all your scripts.
>
> HTH,
>
> --sundar
>
> On Mon, Mar 9, 2009 at 6:49 PM, Paul Boutros 
> wrote:
>> Hello,
>>
>> I am creating a scatter-plot in lattice, and I would like to customize
the
>> size of each point so that some points are larger and others smaller.
>>  Here's a toy example:
>>
>> library(lattice);
>>
>> temp <- data.frame(
>>x = 1:10,
>>y = 1:10,
>>cex = rep( c(1,3), 5),
>>groups = c( rep("A", 5), rep("B", 5) )
>>);
>>
>> xyplot(y ~ x, temp, cex = temp$cex, pch = 19);
>>
>> This works just fine if I create a straight xy-plot, without groups.
>>  However when I introduce groupings the cex argument specifies the
>> point-size for the entire group.  For example:
>>
>> xyplot(y ~ x, temp, cex = temp$cex, pch = 19, group = groups);
>>
>> Is it possible to combine per-spot sizing with groups in some way?  One
>> work-around is to manually specify all graphical parameters, but I
thought
>> there might be a better way than this:
>>
>> temp$col <- rep("blue", 10);
>> temp$col[temp$groups == "B"] <- "red";
>> xyplot(y ~ x, temp, cex = temp$cex, pch = 19, col = temp$col);
>>
>> Any suggestions/advice is much appreciated!
>> Paul
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>

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


Re: [R] reliability, scale scores in the psych package

2009-03-10 Thread William Revelle

Ista,
  As you figured out, psych reverses items by subtracting from the 
maximimum + minimum possible for each item.  (i.e., for  items going 
from 1 to 4, it reverses items by subtracting from 5).


If all of the items have the same potential range  then you can just 
let it figure out the range by itself.  If they differ in their 
ranges (some items are 0 - 1 items, some are 1-9 items, etc., then 
you need to give it the maximum and minimum vectors to use.


The min and max are figured out from all the items used in an 
inventory, rather than just the items used in a particular scale. 
This makes particular sense when you are scoring multiple scales from 
the same inventory.


In answer to your first question (what packages do I tend to use for 
scale construction?), the answer is that I tend to use the psych 
package for basic analysis, and then the sem package for structural 
equation analysis.


Bill





At 10:45 AM -0400 3/10/09, Ista Zahn wrote:



 Second question: I spent some time with the psych package trying to
 figure out how to use the score.items() function, and it's become
 clear to me that I don't understand what it's doing. I assumed that
 setting a key equal to -1 would result in the item being reverse
 scored, but I get weird results, as shown below. When I try to reverse
 score (by setting a value of -1 in the key), I get scale scores that
 don't add up (e.g., the mean score is reported as being larger than
 the maximum item score). How is the score.items() function intended to
 be used? Do I need to reverse score items before using score.items()?


I did it again--it seems like I always figure out the answer just
after I ask for help. The score.items() function needs to know the
maximum of the scale in order to reverse score. For some reason, the
maximum appears to be calculated from all the scores, not just scores
that have a 1 or a -1 in the key. On a hunch I set the max argument to
a vector of scale maxima, and it worked. I'm still interested in
responses to question 1 though.

Thanks again,
Ista





--
William Revelle http://personality-project.org/revelle.html
Professor   http://personality-project.org/personality.html
Department of Psychology http://www.wcas.northwestern.edu/psych/
Northwestern University http://www.northwestern.edu/
Use R for psychology   http://personality-project.org/r

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

2009-03-10 Thread azege






I am trying to install a package kernlab on Linux machine. After downloading 
and unpacking, installation goes through a number of C code compiles which ends 
with code linking, where error is generated as follows:


g++ -shared -Bdirect,--hash-stype=both,-Wl,-O1 -o kernlab.so brweight.o 
ctable.o cweight.o dbreakpt.o dcauchy.o dgpnrm.o dgpstep.o dprecond.o dprsrch.o 
dspcg.o dtron.o dtrpcg.o dtrqsol.o esa.o expdecayweight.o inductionsort.o 
kspectrumweight.o lcp.o misc.o msufsort.o solvebqp.o stringk.o stringkernel.o 
svm.o wkasailcp.o wmsufsort.o -L/usr/lib64/R/lib -lRblas -lgfortran -lm 
-L/usr/lib64/R/lib -lRlapack  -L/usr/lib64/R/lib -lR


/usr/bin/ld: cannot find -lgfortran
collect2: ld returned 1 exit status

I suppose compiler cannot find libgfortran, which is in /usr/lib64/ in my case. 
Does anyone know where I specify or how I pass this info to R. I suppose
there must be some UNIX environment variable or argument to install.packages

Thanks, 
Andre

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

2009-03-10 Thread Roberta Carabalona
Hi all,
does anybody know where it is possible to find the "Riffle" package?

Thank you
R


  
[[alternative HTML version deleted]]

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


Re: [R] Lattice: Customizing point-sizes with groups

2009-03-10 Thread Paul C. Boutros
Hi Sundar,

Thanks for your help!  Unfortunately your code seems to give the same
result.  Compare this:

temp <- data.frame(
   x = 1:10,
   y = 1:10,
   cex = rep( c(1,3), 5),
   col = c( rep("blue", 5), rep("red", 5) ),
   groups = c( rep("A", 5), rep("B", 5) )
   );

xyplot(y ~ x, temp, groups = groups,
   par.settings = list(
 superpose.symbol = list(
   cex = c(1, 3),
   pch = 19,
   col = c("blue", "red"

And this:
xyplot(y ~ x, temp, cex = temp$cex, col = temp$col, pch = 19);

Once I introduce groups, I lose the ability to customize individual
data-points and seem only to be able to customize entire groups.

Paul

-Original Message-
From: Sundar Dorai-Raj [mailto:sdorai...@gmail.com] 
Sent: Tuesday, March 10, 2009 5:49 AM
To: paul.bout...@utoronto.ca
Cc: r-help@r-project.org
Subject: Re: [R] Lattice: Customizing point-sizes with groups

Try this:

xyplot(y ~ x, temp, groups = groups,
   par.settings = list(
 superpose.symbol = list(
   cex = c(1, 3),
   pch = 19,
   col = c("blue", "red"

See:

str(trellis.par.get())

for other settings you might want to change.

Also, you should drop the ";" from all your scripts.

HTH,

--sundar

On Mon, Mar 9, 2009 at 6:49 PM, Paul Boutros 
wrote:
> Hello,
>
> I am creating a scatter-plot in lattice, and I would like to customize the
> size of each point so that some points are larger and others smaller.
>  Here's a toy example:
>
> library(lattice);
>
> temp <- data.frame(
>        x = 1:10,
>        y = 1:10,
>        cex = rep( c(1,3), 5),
>        groups = c( rep("A", 5), rep("B", 5) )
>        );
>
> xyplot(y ~ x, temp, cex = temp$cex, pch = 19);
>
> This works just fine if I create a straight xy-plot, without groups.
>  However when I introduce groupings the cex argument specifies the
> point-size for the entire group.  For example:
>
> xyplot(y ~ x, temp, cex = temp$cex, pch = 19, group = groups);
>
> Is it possible to combine per-spot sizing with groups in some way?  One
> work-around is to manually specify all graphical parameters, but I thought
> there might be a better way than this:
>
> temp$col <- rep("blue", 10);
> temp$col[temp$groups == "B"] <- "red";
> xyplot(y ~ x, temp, cex = temp$cex, pch = 19, col = temp$col);
>
> Any suggestions/advice is much appreciated!
> Paul
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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

2009-03-10 Thread justin bem
see ?unique

 Justin BEM
BP 1917 Yaoundé
Tél (237) 99597295
(237) 22040246





De : "arnaud_mosn...@uqar.qc.ca" 
À : r-help@r-project.org
Envoyé le : Mardi, 10 Mars 2009, 17h15mn 57s
Objet : [R] (no subject)


Dear R users,

I have a table with the following form

STATION  X   Y
1-7030
1-7030
1-7030
2-7229
2-7229
2-7229
2-7229

How want to extract unique value for those columns ... I am sure it is 
very[[elided Yahoo spam]]

I want to obtain something like

STATIONX Y
1-7030
2-7229

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.


Re: [R] (no subject)

2009-03-10 Thread Usuario R
Hi Arnaud, is very simple:


> unique( datos)


Regards


2009/3/10 

>
> Dear R users,
>
> I have a table with the following form
>
> STATION  X   Y
> 1-7030
> 1-7030
> 1-7030
> 2-7229
> 2-7229
> 2-7229
> 2-7229
>
> How want to extract unique value for those columns ... I am sure it is very
> simple, but I can not achieve to find the correct way !
>
> I want to obtain something like
>
> STATIONX Y
> 1-7030
> 2-7229
>
> 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   >