Re: [R] function to reduce resolution of a vector or matrix?

2011-06-08 Thread peter dalgaard

On Jun 3, 2011, at 17:42 , Carl Witthoft wrote:

 Hi,
 I feel dumb even asking, but isn't there an R function somewhere that I can 
 use to reduce the resolution of a vector (or matrix) by summing terms in 
 uniform blocks?  That is, for a vector X, reduce it to some X.short as  
 X.short[1]- sum(X[1:10]);  X.short[2] - sum(X[11:20]), and so on.
 
 I did the following:
 
 X.short-colSums(matrix(X,16,2048/16)) # X is of length 2048
 
 but surely there's already  a function somewhere that does this in a more 
 general case?  And, my approach will get a bit painful for reducing a matrix 
 in both dimensions.

aggregate.ts, but then you need to convert to ts and back. I'd likely go for 

tapply(X, (seq_along(X) - 1) %/% N, sum)

 x
 [1]  1  1  0 -1  1 -1  0  0  1 -2  1  0  0 -1  1
 as.numeric(aggregate(ts(x, frequency=3), 1, sum))
[1]  2 -1  1 -1  0
 tapply(x, (seq_along(x) - 1) %/% 3, sum)
 0  1  2  3  4 
 2 -1  1 -1  0 



-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@gmail.com

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


[R] Can we prepare a questionaire in R

2011-06-08 Thread amrita gs
Is there a way to prepare a questionnaire in R like html forms whose data
can be directly populated into 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.


[R] using stimulate(model) for parametric bootstrapping in lmer repeatabilities

2011-06-08 Thread Jenni Sanderson
Hi all,

I am currently doing a consistency analysis using an lmer model and
trying to use parametric bootstrapping for the confidence intervals.

My model is like this:

model-lmer(y~A+B+(1|C/D)+(1|E),binomial)

where E is the individual level for consistency analysis, A-D are
other fixed and random effects that I have to control for.

Following Nakagawa and Scheilzeth I can work out the repeatability
estimate using the following (as it is a binomial and the residual
variance is fixed at 1).

attr(lme4::VarCorr(model)$E, stddev)^2 /
(1*(pi^2)/3 + attr(lme4::VarCorr(model)$E, stddev)^2  +
attr(lme4::VarCorr(model)$C, stddev)^2  +
attr(lme4::VarCorr(model)$D, stddev)^2  )

My question is can I use stimulate(model) to generate values that I
can then use to do parametric bootstrap analysis and generate the
confidence intervals?

Something like this:

n-length(A)
niter-1000
y-matrix(nrow=n,ncol=niter*2)
for (i in 1:niter) {
y[,I(i*2-1):I(i*2)]-simulate(model)[,1]   }
rvalues-numeric()
for (i in 1:niter) {
yboot-cbind(y[,I(i*2-1)],y[,I(i*2)])
mboot-lmer(y~A+B+(1|C/D)+(1|E),binomial)
rvalues[i]- attr(lme4::VarCorr(mboot)$E, stddev)^2/(1*(pi^2)/3 +
attr(lme4::VarCorr(mboot)$E, stddev)^2  +
attr(lme4::VarCorr(mboot)$C, stddev)^2  +
attr(lme4::VarCorr(mboot)$D, stddev)^2  )}
confidence.intervals-quantile(rvalues,c(0.05,0.95))

In the guide to lme4 it says that stimulate() generate simulations
based on the estimated fitted models (conditional on the estimated
values of both the random and fixed effects), which sounds like
exactly what I would need to generate values for parametric
bootstrapping but I can't find any examples of where anyone has done
this.

Any advice would be very much appreciated! Thank you very much.

Jenni

Jenni Sanderson
PhD student - Conflict and Cooperation in Vertebrate Societies
University of Exeter

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


Re: [R] determine frequencies in a matrix by row

2011-06-08 Thread the_big_kowalski
 here's the code to generate  the matrix 

set.seed(1)
types = c(1,2,3)
n=5
p=1
pop.props = c(0.6,0.2,0.2) 
x=matrix(pop.props,nrow=n,ncol=length(pop.props), byrow=T)
b=10
habs = rMultinom((x),b)
print(habs)

--
View this message in context: 
http://r.789695.n4.nabble.com/determine-frequencies-in-a-matrix-by-row-tp3581733p3581752.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] determine frequencies in a matrix by row

2011-06-08 Thread the_big_kowalski
Hi, 

I have a matrix 
 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,]131131123 2
[2,]131211122 1
[3,]122321112 1
[4,]321113121 2
[5,]112211311 2
and want to determine how many times 1s, 2s, and 3s occur per each row.
I tried using 'table', but end up with frequencies for the whole matrix.
Thanks in advance for your help

--
View this message in context: 
http://r.789695.n4.nabble.com/determine-frequencies-in-a-matrix-by-row-tp3581733p3581733.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] About DCC-garch model...

2011-06-08 Thread windseav
Thank you all guys!!

I have some other questionsFor garch model, for example, we have 10 time
periods, and the function use MLE to get the parameters based on these 10
time periods. Then, the function calculates covariance matrix at each time
period based on the estimated parameters. Is this right??

Moreover, does anyone know that whether the correlation matrix calculated by
GARCH model is semidefinite positive? 

Thanks a lot!!!

--
View this message in context: 
http://r.789695.n4.nabble.com/About-DCC-garch-model-tp3579140p3581851.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] determine frequencies in a matrix by row

2011-06-08 Thread Mohamed Lajnef
Hi,

Try apply function:
apply(matrix,1,table)

Regards
M



Le 08/06/11 08:23, the_big_kowalski a écrit :
 Hi,

 I have a matrix
   [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
 [1,]131131123 2
 [2,]131211122 1
 [3,]122321112 1
 [4,]321113121 2
 [5,]112211311 2
 and want to determine how many times 1s, 2s, and 3s occur per each row.
 I tried using 'table', but end up with frequencies for the whole matrix.
 Thanks in advance for your help

 --
 View this message in context: 
 http://r.789695.n4.nabble.com/determine-frequencies-in-a-matrix-by-row-tp3581733p3581733.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.



-- 

Mohamed Lajnef,IE INSERM U955 eq 15#
Pôle de Psychiatrie#
Hôpital CHENEVIER  #
40, rue Mesly  #
94010 CRETEIL Cedex FRANCE #
mohamed.laj...@inserm.fr   #
tel : 01 49 81 32 79   #
Sec : 01 49 81 32 90   #
fax : 01 49 81 30 99   #




[[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] using stimulate(model) for parametric bootstrapping in lmer repeatabilities

2011-06-08 Thread Søren Højsgaard
Dear Jenni,

In the newest version of the doBy package there is a function called PBrefdist 
(and PBrefdist.mer) for calculating the reference distribution of the 
likelihood ratio statistic for comparing nested models. Looking into this 
function may help you. Perhaps the functions PBmodcomp and BCmodcomp (and their 
.mer methods) for calculating p-values based on parametric bootstrap can also 
be of inspiration.

Regards
Søren 


Fra: r-help-boun...@r-project.org [r-help-boun...@r-project.org] P#229; vegne 
af Jenni Sanderson [jennifer.louise.sander...@googlemail.com]
Sendt: 8. juni 2011 09:56
Til: r-help@r-project.org; r-sig-mixed-mod...@r-project.org
Emne: [R] using stimulate(model) for parametric bootstrapping in lmer   
repeatabilities

Hi all,

I am currently doing a consistency analysis using an lmer model and
trying to use parametric bootstrapping for the confidence intervals.

My model is like this:

model-lmer(y~A+B+(1|C/D)+(1|E),binomial)

where E is the individual level for consistency analysis, A-D are
other fixed and random effects that I have to control for.

Following Nakagawa and Scheilzeth I can work out the repeatability
estimate using the following (as it is a binomial and the residual
variance is fixed at 1).

attr(lme4::VarCorr(model)$E, stddev)^2 /
(1*(pi^2)/3 + attr(lme4::VarCorr(model)$E, stddev)^2  +
attr(lme4::VarCorr(model)$C, stddev)^2  +
attr(lme4::VarCorr(model)$D, stddev)^2  )

My question is can I use stimulate(model) to generate values that I
can then use to do parametric bootstrap analysis and generate the
confidence intervals?

Something like this:

n-length(A)
niter-1000
y-matrix(nrow=n,ncol=niter*2)
for (i in 1:niter) {
y[,I(i*2-1):I(i*2)]-simulate(model)[,1]   }
rvalues-numeric()
for (i in 1:niter) {
yboot-cbind(y[,I(i*2-1)],y[,I(i*2)])
mboot-lmer(y~A+B+(1|C/D)+(1|E),binomial)
rvalues[i]- attr(lme4::VarCorr(mboot)$E, stddev)^2/(1*(pi^2)/3 +
attr(lme4::VarCorr(mboot)$E, stddev)^2  +
attr(lme4::VarCorr(mboot)$C, stddev)^2  +
attr(lme4::VarCorr(mboot)$D, stddev)^2  )}
confidence.intervals-quantile(rvalues,c(0.05,0.95))

In the guide to lme4 it says that stimulate() generate simulations
based on the estimated fitted models (conditional on the estimated
values of both the random and fixed effects), which sounds like
exactly what I would need to generate values for parametric
bootstrapping but I can't find any examples of where anyone has done
this.

Any advice would be very much appreciated! Thank you very much.

Jenni

Jenni Sanderson
PhD student - Conflict and Cooperation in Vertebrate Societies
University of Exeter

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

2011-06-08 Thread Grifone
Thanks Sarah for the response; with the command

str(echoknn.train)

the coloumn class is a logi value (i think without any immagination that
is a logical value ).  So, how can I handle this type of data?

Thanks a lot.

P.S. Yes, is a course assignment  and i was hoping to solve this problem
(that i consider just a beginner problem) without asking my teacher .

--
View this message in context: 
http://r.789695.n4.nabble.com/Classifying-boolean-values-tp3579993p3581980.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] library(SenoMineR)- Triangle Test Query

2011-06-08 Thread Meyners, Michael
Vijayan,

I cannot find an error in your code, but I had a look at the code of 
triangle.test -- unless I'm missing something, it contains a bug. If you study 
the way in which the matrix pref is updated, you find that the vector 
preference is compared to 1, 2 and 3 instead of X, Y and Z as it should 
be. That way, some of the non-diagonal entries of pref will always be zero, 
irrespective of the data, which does not make sense. I think it should work if 
you modify the code accordingly. Alternatively, a quick patch (untested!) might 
be to code preferences as 1, 2 and 3 instead of the letters (but I'm not sure 
whether this has any other implications).
I CC the author of the function and maintainer of the package; he should 
correct me if needed or could otherwise update the code for the next release (I 
worked on SensoMineR 1.11).

Hope this helps, 
Michael

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Vijayan Padmanabhan
 Sent: Saturday, June 04, 2011 9:21
 To: r-help@r-project.org
 Subject: [R] library(SenoMineR)- Triangle Test Query
 
 Dear R Group
 I was trying to use the triangle.test function in SensoMineR and
 strangely i
 encounter a error in the output of preference matrix from the analysis.
 To illustrate, pl see the following dataframe of a design with the
 response
 and preference collected as shown below:
 
 design-structure(list(`Product X` = c(3, 1, 4, 2, 4, 2, 1, 3, 4, 2,
 4, 2, 1, 3, 4, 2, 4, 2, 3, 1), `Product Y` = c(1, 1, 4, 4, 4,
 3, 1, 1, 4, 4, 4, 3, 1, 1, 4, 4, 4, 3, 1, 1), `Product Z` = c(3,
 2, 1, 2, 3, 3, 2, 3, 1, 2, 3, 3, 2, 3, 1, 2, 3, 3, 3, 2), Response =
 structure(c(1L,
 2L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L,
 1L, 1L, 2L), .Label = c(X, Z), class = factor), Preference =
 structure(c(1L,
 3L, 1L, 1L, 1L, 2L, 3L, 1L, 1L, 1L, 1L, 2L, 3L, 1L, 1L, 1L, 1L,
 2L, 1L, 2L), .Label = c(X, Y, Z), class = factor)), .Names =
 c(Product X,
 Product Y, Product Z, Response, Preference), class =
 data.frame,
 row.names = c(Panelist1.Test1,
 Panelist1.Test2, Panelist2.Test1, Panelist2.Test2,
 Panelist3.Test1,
 Panelist3.Test2, Panelist4.Test1, Panelist4.Test2,
 Panelist5.Test1,
 Panelist5.Test2, Panelist6.Test1, Panelist6.Test2,
 Panelist7.Test1,
 Panelist7.Test2, Panelist8.Test1, Panelist8.Test2,
 Panelist9.Test1,
 Panelist9.Test2, Panelist10.Test1, Panelist10.Test2))
 
 If you were to investigate the above dataframe, you would find that for
 the
 comparision of Product 2 Vs Product 3, the preference indicates product
 3 is
 preferred over product 2 all the time.
 
 ## Read output from the following script to see what i mean above:
 subset(design,`Product X`==2`Product Y`==3`Product Z`==3)
 
 ##Output of above would be:
 . Product X Product Y Product Z Response Preference
 Panelist3.Test2 2 3 3X  Y
 Panelist6.Test2 2 3 3X  Y
 Panelist9.Test2 2 3 3X  Y
 
 However when I analyse the design with the answers and preferences
 using the
 following script, I get the $pref output which shows that product 2 is
 preferred over 3 all the time. Can somebody explain what is wrong in my
 script?
 
 answer-as.vector(design$Response)
 preference-as.vector(design$Preference)
 triangle.test (design[,1:3], answer,preference)
 
 ##$pref output from the triangle.test function shows as follows:
 
 $pref
   1 2 3 4
 1 0 0 0 0
 2 4 0 3 0
 3 0 0 0 0
 4 0 0 0 0
 
 
 Any help in helping me identify what is going wrong here would be
 highly
 appreciated.
 Regards
 Vijayan Padmanabhan
 
   [[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] MBA the h value?

2011-06-08 Thread Clement LAUZIN

Hello everybody,
 
 
I am trying different ways of interpolating a surface.
Now, I am trying to interpolate these values using the MBA package. In order to 
do it I am using the surface option of the package.
mba.surf(xyz, 20, 20, n = 1, m = 1, h = 8, extend=FALSE,
sp=FALSE, ...)
 
The function is giving me some results but not reliable at all.
Maybe it's due to the n,m and h values which are not corresponding to my data. 
I don't understand what should be the value of h. Even I read the article cited 
in the pdf.
Someone could maybe help me.Also what should be the value of n and m.
My data are pasted below corresponding to xyz. 
 
 
Thank you very much
Regards
 
 
Pierre
 

4.00 45 -83.94753324
4.00 50 -115.8679098
4.00 55 -134.787
4.00 60 -144.6370393
4.00 65 -148.7164562
4.00 70 -149.4758468
4.00 75 -148.641352
4.05 45 -104.1007536
4.05 50 -128.2620683
4.05 55 -141.8810486
4.05 60 -148.3151116
4.05 65 -150.2664062
4.05 70 -149.7559503
4.05 75 -148.1990977
4.10 45 -118.9805984
4.10 50 -136.721655
4.10 55 -146.0525858
4.10 60 -149.7327347
4.10 65 -149.9930389
4.10 70 -148.4927918
4.10 75 -146.3873601
4.15 45 -129.467342
4.15 50 -141.998465
4.15 55 -147.8625806
4.15 60 -149.343257
4.15 65 -148.2761684
4.15 70 -146.0179853
4.15 75 -143.5069876
4.20 45 -136.3899382
4.20 50 -144.6996352
4.20 55 -147.7834847
4.20 60 -147.526368
4.20 65 -145.433249
4.20 70 -142.6081123
4.20 75 -139.8085943  
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Decision Trees /Decision Analysis with R?

2011-06-08 Thread stefan.d...@gmail.com
Hello,

this question is a bit out of the blue.

I am a big R fan and user and in my new job I do some decision
modeling (mostly health economics). For that decision trees are often
used (I guess the most classic example is the investment decision A,
B, and C with different probabilities, what is the expected payoff).
We use a specialized software called TreeAge that some might know.
The basic setup of such simulations is actually very simple and I
guess useful in many fields. So I was wondering whether there is
already a package out there in R that is doing such a thing?

Thanks for any hints!
Best,
Stefan

PS
(By decision tree I don't mean cluster-like analysis of a data set
splitting by identifying decision nods, but the other way around: I
have decision nodes, what is my expected outcome.)

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

2011-06-08 Thread Christian Hennig

Dear Paco,

I tried dbscan on my computer with method=hybrid and a 155000*3 
data matrix and it works. Needs some time though.

(You can track the progress using something like
countmode=c(1:10,100,1000,1,10).)
Note that for some reason I don't exactly understand, it takes *much* 
longer for 1-dimensional data (I need to look into this), so if you tried 
only 1-d data yet, it may be worth a try to do the whole thing with

the full 3-d dataset.

So I'm not sure what goes wrong on your side. Perhaps look at str(sst2) in 
order to make sure that it is what you think it is.


I can't advise you on how precisely to take longitude and latitude into 
account because this depends on your application and would probably 
require professional statistical advisory that is much more than just 
R-help. Note however that dbscan treats all variables equally.


Best wishes,
Christian

On Tue, 7 Jun 2011, Paco Pastor wrote:


Hello Christian

Thanks for answering. Yes, I have tried dbscan from fpc but I'm still stuck 
on the memory problem. Regarding your answer, I'm not sure which memory 
parameter should I look at. Following is the code I tried with dbscan 
parameters, maybe you can see if there is any mistake.


sstdat=read.csv(sst.dat,sep=;,header=F,col.names=c(lon,lat,sst))

library(fpc)
sst1=subset(sstdat, sst50)
sst2=subset(sst1, lon-6)
sst2=subset(sst2, lon40)
sst2=subset(sst2, lat46)

dbscan(sst2$sst, 0.1, MinPts = 5, scale = FALSE, method = c(hybrid), 

seeds = FALSE, showplot = FALSE, countmode = NULL)
Error: no se puede ubicar un vector de tamaño  858.2 Mb

head(sst2)

lon   lat   sst
1257 35.18 24.98 26.78
1258 35.22 24.98 26.78
1259 35.27 24.98 26.78
1260 35.31 24.98 26.78
1261 35.35 24.98 26.78
1262 35.40 24.98 26.85


In this example I only apply dbscan to temperature values, not lon/lat, so 
eps parameter is 0.1. As it is a gridded data set any point is surrounded by 
eight data points, then I thought that at least 5 of the surrounding points 
should be within the reachability distance. But I'm not sure I'm getting the 
right approach by only considering temperature value, maybe then I'm missing 
spatial information. How should I deal with longitude and latitude data?


dimensions of sst2 are: 152243 rows x 3 columns

Thanks again

El 03/06/2011 18:24, Christian Hennig escribió:
Have you considered the dbscan function in library fpc, or was it another 
one?

dbscan in fpc doesn't have a distance parameter but several options, one
of which may resolve your memory problem (look up the documentation of the 
memory parameter).


Using a distance matrix for hundreds of thousands of points is a recipe for 
disaster (memory-wise). I'm not sure whether the function that you used did 
that, but dbscan in fpc can avoid it.


It is true that dbscan requires tuning constants that the user has to 
provide. There is unfortunately no general rule how to do this; it would be 
necessary to understand the method and the meaning of the constants, and 
how this translates into the requirements of your application.


You may try several different choices and do some cluster validation to see 
what works, but I can't explain this in general terms easily via email.


Hope this helps at least a bit.

Best regards,
Christian


On Fri, 3 Jun 2011, Paco Pastor wrote:


Hello everyone,

When looking for information about clustering of spatial data in R I was 
directed towards DBSCAN. I've read some docs about it and theb new 
questions have arisen.


DBSCAN requires some parameters, one of them is distance. As my data are 
three dimensional, longitude, latitude and temperature, which distance 
should I use? which dimension is related to that distance? I suposse it 
should be temperature. How do I find such minimum distance with R?


Another parameter is the minimum number of points neded to form a cluster. 
Is there any method to find that number? Unfortunately I haven't found.


Searching thorugh Google I could not find an R example for using dbscan in 
a dataset similar to mine, do you know any website with such kind of 
examples? So I can read and try to adapt to my case.


The last question is that my first R attempt with DBSCAN (without a proper 
answer to the prior questions) resulted in a memory problem. R says it can 
not allocate vector. I start with a 4 km spaced grid with 779191 points 
that ends in approximately 30 rows x 3 columns (latitude, longitude 
and temperature) when removing not valid SST points. Any hint to address 
this memory problem. Does it depend on my computer or in DBSCAN itself?


Thanks for the patience to read a long and probably boring message and for 
your help.


--
---
Francisco Pastor
Meteorology department, Instituto Universitario CEAM-UMH
http://www.ceam.es
---
mail: p...@ceam.es
skype: paco.pastor.guzman
Researcher ID: http://www.researcherid.com/rid/B-8331-2008
Cosis profile: http://www.cosis.net/profile/francisco.pastor
---
Parque Tecnologico, 

[R] plotting boxplot based on frequency/count data

2011-06-08 Thread Ioannis Filippis
Hi all,

I have a huge dataset of values and I have precalculated outside of R the
frequency/count distribution (as for example counts returned by hist
function or the output of table function). For example,

x-hist(c(1,2,2,2,1,3), breaks=0:3, plot=F)
 x
$breaks
[1] 0 1 2 3

$counts
[1] 2 3 1

Is there any function to calculate boxplot based on the counts?

I guess I could expand the count vector to a values set and run boxplot
but the problem is that I have a lot of data (300,000^2). Another way could
be to calculate median and quartiles myself and custom draw the boxplot but
seems complicated.

Do you happen to know some more automated way, maybe a function in R?

Many thanks for the help.

Best regards,
Ioannis

[[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] 2.13 version doesn't load packages

2011-06-08 Thread Mariana Varela
Hi, I just installed the 2.13 version for Mac (without uninstalling the 
previous versions). I transferred the folder library containing the packages I 
normally use to the 2.13 library folder. When I require any package this is 
what I get:

 require(ape)
Loading required package: ape
Error in dyn.load(file, DLLpath = DLLpath, ...) :
  unable to load shared object 
'/Library/Frameworks/R.framework/Versions/2.13/Resources/library/gee/libs/x86_64/gee.so':
  
dlopen(/Library/Frameworks/R.framework/Versions/2.13/Resources/library/gee/libs/x86_64/gee.so,
 6): Library not loaded: 
/Library/Frameworks/R.framework/Versions/2.12/Resources/lib/libRblas.dylib
  Referenced from: 
/Library/Frameworks/R.framework/Versions/2.13/Resources/library/gee/libs/x86_64/gee.so
  Reason: image not found

However when type library the packages are there.

Any hints?
Many thanks
Mariana

--
   Mariana Varela, DVM, PhD
MRC-University of Glasgow Centre for Virus Research
Institute of Infection, Immunity and Inflammation
College of Medical, Veterinary and Life Sciences
Garscube Estate, 464 Bearsden Road
Henry Wellcome Building, room 436
Glasgow, G61 1QH
Scotland (UK)
Phone: +44 (0) 141 330 2196


[[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] Can we prepare a questionaire in R

2011-06-08 Thread Mike Marchywka







 Date: Wed, 8 Jun 2011 12:37:33 +0530
 From: ammasamri...@gmail.com
 To: r-help@r-project.org
 Subject: [R] Can we prepare a questionaire in R

 Is there a way to prepare a questionnaire in R like html forms whose data
 can be directly populated into R?


I've started to use Rapache although Rserve would also be an option.
When installed on server, your can point your html form to an rhtml
page and get the form variables in R just as with other web languages.
For writing html output, I had been using R2HTML ( see code excerpt below
from rhtml page). I had also found Cairo works ok if you don't
need X-11 for anything. 

For your specific situation however, it may be easier to just
use whatever you already have and just use R for the data analysis.
When a request for a results report is made,  send that to Rapache for
example. I would mention that I have gone to running two versions
of Apache, one with R and one with PHP, to allow for security and
easier development( I can write the php to fail nicely if the R apache
server is not up and no new security issues are exposed). 


library(Cairo)
library(R2HTML)
library(RColorBrewer)


You can of course also generate html from normal R commands, or for that
matter bash scripts etc.

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


Re: [R] determine frequencies in a matrix by row

2011-06-08 Thread jim holtman
If the result is limited to just the counts of 1,2 and 3, you can do
the following:

 habs - matrix(sample(1:3, 50, TRUE, prob=c(.6,.2,.2)),5,10)
 habs
 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,]132113111 2
[2,]123131111 1
[3,]123231211 3
[4,]313122111 2
[5,]112211313 2
 result - apply(habs, 1, function(x){
+ c('1' = sum(x == 1), '2' = sum(x==2), '3' = sum(x == 3))
+ })
 cbind(habs, t(result))
 1 2 3
[1,] 1 3 2 1 1 3 1 1 1 2 6 2 2
[2,] 1 2 3 1 3 1 1 1 1 1 7 1 2
[3,] 1 2 3 2 3 1 2 1 1 3 4 3 3
[4,] 3 1 3 1 2 2 1 1 1 2 5 3 2
[5,] 1 1 2 2 1 1 3 1 3 2 5 3 2


On Wed, Jun 8, 2011 at 2:23 AM, the_big_kowalski bkowal...@csumb.edu wrote:
 Hi,

 I have a matrix
     [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
 [1,]    1    3    1    1    3    1    1    2    3     2
 [2,]    1    3    1    2    1    1    1    2    2     1
 [3,]    1    2    2    3    2    1    1    1    2     1
 [4,]    3    2    1    1    1    3    1    2    1     2
 [5,]    1    1    2    2    1    1    3    1    1     2
 and want to determine how many times 1s, 2s, and 3s occur per each row.
 I tried using 'table', but end up with frequencies for the whole matrix.
 Thanks in advance for your help

 --
 View this message in context: 
 http://r.789695.n4.nabble.com/determine-frequencies-in-a-matrix-by-row-tp3581733p3581733.html
 Sent from the R help mailing list archive at Nabble.com.

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




-- 
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?

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


Re: [R] RgoogleMaps Axes

2011-06-08 Thread Mike Marchywka














 Date: Tue, 7 Jun 2011 09:50:10 -0700
 From: egregory2...@yahoo.com
 To: r-help@r-project.org
 Subject: [R] RgoogleMaps Axes

 R Help,


 I posted a question on StackOverflow yesterday regarding an issue I've been 
 having with the RgoogleMaps packages' displaying of axes. Here is the text of 
 that submission:
 http://stackoverflow.com/questions/6258408/rgooglemaps-axes

 I can't find any documentation of the following problem I'm having with the 
 axis labels in RGoogleMaps:
 library(RgoogleMaps)
 datas -structure(list(LAT =c(37.875,37.925,37.775,37.875,37.875),
 LON =c(-122.225,-122.225,-122.075,-122.075,-122.025)),
 .Names=c(LAT,LON),class=data.frame,
 row.names =c(1418L,1419L,1536L,1538L,1578L))
 # Get bounding box.
 boxt -qbbox(lat =datas$LAT,lon =datas$LON)
 MyMap-GetMap.bbox(boxt$lonR,boxt$latR,destfile =Arvin12Map.png,
 maptype =mobile)
 PlotOnStaticMap(MyMap,lat =datas$LAT,lon =datas$LON,
 axes =TRUE,mar =rep(4,4))


I haven't gotten too far as I had to download and install proj4 and rgdal
but I did get a transofrm related warning. Did you get warnings?


 MyMap-GetMap.bbox(boxt$lonR,boxt$latR,destfile =Arvin12Map.png,maptype =m
obile)
[1] http://maps.google.com/maps/api/staticmap?center=37.85,-122.125zoom=12siz
e=640x640maptype=mobileformat=png32sensor=true
Loading required package: rgdal
Loading required package: sp
Geospatial Data Abstraction Library extensions to R successfully loaded
Loaded GDAL runtime: GDAL 1.8.0, released 2011/01/12
Path to GDAL shared files: /usr/local/share/gdal
Loaded PROJ.4 runtime: Rel. 4.7.1, 23 September 2009
Path to PROJ.4 shared files: (autodetected)
Warning message:
In readGDAL(destfile, silent = TRUE) : GeoTransform values not available



 PlotOnStaticMap(MyMap,lat =datas$LAT,lon =datas$LON,
+  axes =TRUE,mar =rep(4,4))
List of 6
 $ lat.center: num 37.8
 $ lon.center: num -122
 $ zoom  : num 12
 $ myTile: int [1:640, 1:640] 968 853 855 969 1033 888 855 884 888 995 ...
  ..- attr(*, COL)= chr [1:1132] #00 #020201 #020202 #030302 ...
  ..- attr(*, type)= chr rgb
 $ BBOX  :List of 2
  ..$ ll: num [1, 1:2] 37.8 -122.2
  .. ..- attr(*, dimnames)=List of 2
  .. .. ..$ : chr Y
  .. .. ..$ : chr [1:2] lat lon
  ..$ ur: num [1, 1:2] 37.9 -122
  .. ..- attr(*, dimnames)=List of 2
  .. .. ..$ : chr Y
  .. .. ..$ : chr [1:2] lat lon
 $ url   : chr google
NULL
[1] -291.2711  291.2711
[1] -276.5158  276.7972



 When I run this on my computer the horizontal axis ranges from 300W to 60E, 
 but the ticks in between aren't linearly spaced (300W, 200W, 100W, 0, 100E, 
 160W, 60W). Also, the vertical axis moves linearly from 300S to 300N. It 
 seems that no matter what data I supply for datas, the axes are always 
 labeled this way.
 My question is:
 1. Does this problem occur on other machines using this code?
 2. Does anyone have an explanation for it?
 and
 3. Can anybody suggest a way to get the correct axes labels (assuming these 
 are incorrect, but maybe i'm somehow misinterpreting the plot!)?
 Thank you for your time.

 There has been no answer other than that I ought to contact the package 
 maintainer. Since it would be nice to have a publicly displayed solution, I 
 opted to post here first before doing so. Does anyone have any insight to 
 share?
 Thank you very much for your time,

 -Erik Gregory
 CSU Sacramento, Mathematics
 Student Assistant, California Environmental Protection Agency

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

2011-06-08 Thread amrita gs
How can we create HTML forms in 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] Decision Trees /Decision Analysis with R?

2011-06-08 Thread Jonathan Daily
See packages rpart, randomForest, party.

Also, typing R Decision Trees produced good google results.

http://www.google.com/search?aq=fsourceid=chromeie=UTF-8q=R+Decision+Trees

On Wed, Jun 8, 2011 at 7:02 AM, stefan.d...@gmail.com
stefan.d...@gmail.com wrote:
 Hello,

 this question is a bit out of the blue.

 I am a big R fan and user and in my new job I do some decision
 modeling (mostly health economics). For that decision trees are often
 used (I guess the most classic example is the investment decision A,
 B, and C with different probabilities, what is the expected payoff).
 We use a specialized software called TreeAge that some might know.
 The basic setup of such simulations is actually very simple and I
 guess useful in many fields. So I was wondering whether there is
 already a package out there in R that is doing such a thing?

 Thanks for any hints!
 Best,
 Stefan

 PS
 (By decision tree I don't mean cluster-like analysis of a data set
 splitting by identifying decision nods, but the other way around: I
 have decision nodes, what is my expected outcome.)

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




-- 
===
Jon Daily
Technician
===
#!/usr/bin/env outside
# It's great, trust me.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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.13 version doesn't load packages

2011-06-08 Thread Prof Brian Ripley

On Wed, 8 Jun 2011, Mariana Varela wrote:


Hi, I just installed the 2.13 version for Mac (without uninstalling


As the posting guide says, there is no such version of R 

Also, I think you did uninstall a previous version, for it is missing 
and the default behaviour of the Apple installer is to delete previous 
versions.


the previous versions). I transferred the folder library containing 
the packages I normally use to the 2.13 library folder. When I 
require any package this is what I get:


require(ape)
Loading required package: ape
Error in dyn.load(file, DLLpath = DLLpath, ...) :
 unable to load shared object 
'/Library/Frameworks/R.framework/Versions/2.13/Resources/library/gee/libs/x86_64/gee.so':
 
dlopen(/Library/Frameworks/R.framework/Versions/2.13/Resources/library/gee/libs/x86_64/gee.so,
 6): Library not loaded: 
/Library/Frameworks/R.framework/Versions/2.12/Resources/lib/libRblas.dylib
 Referenced from: 
/Library/Frameworks/R.framework/Versions/2.13/Resources/library/gee/libs/x86_64/gee.so
 Reason: image not found

However when type library the packages are there.

Any hints?


Read the documentation: that is not the way to update!  But given that 
you have done so, run


update.packages(checkBuilt = TRUE)

at the R prompt to download and install updated versions of your 
packages.


We do ask that Mac questions are asked on r-sig-mac, at least if this 
is for the CRAN distribution of R (there are others, and it is 
substantially different from building R from the sources for 
yourself).  One of the many things that is non-standard about that 
distribution is that it hardcodes library paths in its DSOs, so any 
package with compiled code is tied to a small range (e.g. 2.12.[012]) 
of R versions.


You will find a lot of discussion about updating in the recent 
r-sig-mac archives.  See also the rw-FAQ at

http://cran.r-project.org/bin/windows/base/rw-FAQ.html#What_0027s-the-best-way-to-upgrade_003f



Many thanks
Mariana

--
  Mariana Varela, DVM, PhD
MRC-University of Glasgow Centre for Virus Research
Institute of Infection, Immunity and Inflammation
College of Medical, Veterinary and Life Sciences
Garscube Estate, 464 Bearsden Road
Henry Wellcome Building, room 436
Glasgow, G61 1QH
Scotland (UK)
Phone: +44 (0) 141 330 2196


[[alternative HTML version deleted]]

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



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

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


Re: [R] Decision Trees /Decision Analysis with R?

2011-06-08 Thread stefan.d...@gmail.com
Thank you so much for reply. But I am looking for the exact opposite.

I do not have a data set which I want to partition. But already a
sequence/tree-like set of decision rules and with which I want to
simulate what is my expected outcome/pay-off given a particular
scenario.
As far as I understand it, those packages could calculate the expected
outcome AFTER having fit them to a particular data set and not
construct a synthetic tree with exogenously defined decision
nods/rules. Or am I wrong?


Thanks and best,
Stefan



On Wed, Jun 8, 2011 at 2:03 PM, Jonathan Daily biomathjda...@gmail.com wrote:
 See packages rpart, randomForest, party.

 Also, typing R Decision Trees produced good google results.

 http://www.google.com/search?aq=fsourceid=chromeie=UTF-8q=R+Decision+Trees

 On Wed, Jun 8, 2011 at 7:02 AM, stefan.d...@gmail.com
 stefan.d...@gmail.com wrote:
 Hello,

 this question is a bit out of the blue.

 I am a big R fan and user and in my new job I do some decision
 modeling (mostly health economics). For that decision trees are often
 used (I guess the most classic example is the investment decision A,
 B, and C with different probabilities, what is the expected payoff).
 We use a specialized software called TreeAge that some might know.
 The basic setup of such simulations is actually very simple and I
 guess useful in many fields. So I was wondering whether there is
 already a package out there in R that is doing such a thing?

 Thanks for any hints!
 Best,
 Stefan

 PS
 (By decision tree I don't mean cluster-like analysis of a data set
 splitting by identifying decision nods, but the other way around: I
 have decision nodes, what is my expected outcome.)

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




 --
 ===
 Jon Daily
 Technician
 ===
 #!/usr/bin/env outside
 # It's great, trust me.


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


Re: [R] library(SenoMineR)- Triangle Test Query

2011-06-08 Thread Meyners, Michael
Unless I missed it, neither the OP nor the list was CC'd on this, so for anyone 
interested, I forward this solution (untested from my side) from the package 
maintainer. Not sure whether the file comes through, so I include the updated 
code in the message's body below. 
Cheers, Michael


** updated code for triangle.test 
triangle.test - function (design,answer,preference=NULL){

answer = gsub((\\w), \\U\\1, as.character(answer), perl=TRUE)
labprod = 
levels(as.factor(c(as.character(design[,1]),as.character(design[,2]),as.character(design[,3]
nbprod = length(labprod)
nb.answer = nb.good = pref = matrix(0,nbprod,nbprod)
for (i in 1:nrow(design)){
  for (j in 1:nbprod){
 if (labprod[j] == design[i,1]) i1 = j
 if (labprod[j] == design[i,2]) i2 = j
 if (labprod[j] == design[i,3]) i3 = j
  }
  if (i1!=i2) nb.answer [i1,i2] = nb.answer[i1,i2]+1
  if (i1==i2) nb.answer [i1,i3] = nb.answer[i1,i3]+1
  if ((i1==i2)(answer[i]==Z)){
nb.good[i1,i3]=nb.good[i1,i3]+1
if (length(preference)0){
  if (preference[i]!=Z) pref[i3,i1] = pref[i3,i1] +1
  if (preference[i]==Z) pref[i1,i3] = pref[i1,i3] +1
}
  }
  if ((i1==i3)(answer[i]==Y)){
nb.good[i1,i2]=nb.good[i1,i2]+1
if (length(preference)0){
  if (preference[i]!=Y) pref[i2,i1] = pref[i2,i1] +1
  if (preference[i]==Y) pref[i1,i2] = pref[i1,i2] +1
}
  }
  if ((i2==i3)(answer[i]==X)){
nb.good[i1,i2]=nb.good[i1,i2]+1
if (length(preference)0){
  if (preference[i]!=X) pref[i1,i2] = pref[i1,i2] +1
  if (preference[i]==X) pref[i2,i1] = pref[i2,i1] +1
}
  }
}
nb.good = nb.good + t(nb.good)
nb.answer = nb.answer + t(nb.answer)

diag(nb.answer)=1
prob = pbinom(nb.good-1,nb.answer,1/3,lower.tail=FALSE)
maxML = recognize = minimum = matrix(NA,nbprod,nbprod)
for (i in 1: (nbprod-1)){
  for (j in (i+1):nbprod){
aux = matrix(0,nb.good[i,j]+1,1)
for (k in 0:nb.good[i,j]) aux[k] = 
dbinom(nb.good[i,j]-k,nb.answer[i,j]-k,1/3)
maxML[i,j] = maxML[j,i] = max(aux)
recognize[i,j] = recognize[j,i] = rev(order(aux))[1]-1
mini = 0
for (k in round(nb.answer[i,j]/3):nb.answer[i,j]) if 
((mini==0)(dbinom(k,nb.answer[i,j],1/3)0.05)) mini=k
minimum[i,j]=minimum[j,i]=mini
  }
}

confusion = (nb.answer-recognize) / nb.answer
diag(nb.answer)=diag(recognize)=0
diag(maxML)=diag(confusion)=1

rownames(nb.answer) = colnames(nb.answer) = rownames(nb.good) = 
colnames(nb.good) = labprod
rownames(prob) = colnames(prob)= rownames(confusion) = colnames(confusion)= 
labprod
rownames(maxML) = colnames(maxML) = rownames(minimum) = colnames(minimum) = 
rownames(recognize) = colnames(recognize) = labprod
if (length(preference)0) rownames(pref) = colnames(pref) = labprod

res = list()
res$nb.comp = nb.answer
res$nb.ident = nb.good
res$p.value = prob
res$nb.recognition = recognize
res$maxML = maxML
res$confusion = confusion
res$minimum = minimum
if (length(preference)0) res$pref = pref
##res$complete = result
return(res)
}

** end updated code for triangle.test 




-Original Message-
From: Francois Husson 
Sent: Wednesday, June 08, 2011 14:43
To: Meyners, Michael
Subject: Re: [R] library(SenoMineR)- Triangle Test Query

  Dear Vijayan, dear Michael,

Indeed there was an error in the function triangle.test. I attach the new 
function.
Thanks Michael for your answer.
Best
Francois


Le 08/06/2011 12:32, Meyners, Michael a écrit :
 Vijayan,

 I cannot find an error in your code, but I had a look at the code of 
 triangle.test -- unless I'm missing something, it contains a bug. If you 
 study the way in which the matrix pref is updated, you find that the vector 
 preference is compared to 1, 2 and 3 instead of X, Y and Z as it should 
 be. That way, some of the non-diagonal entries of pref will always be zero, 
 irrespective of the data, which does not make sense. I think it should work 
 if you modify the code accordingly. Alternatively, a quick patch (untested!) 
 might be to code preferences as 1, 2 and 3 instead of the letters (but I'm 
 not sure whether this has any other implications).
 I CC the author of the function and maintainer of the package; he should 
 correct me if needed or could otherwise update the code for the next release 
 (I worked on SensoMineR 1.11).

 Hope this helps,
 Michael

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Vijayan Padmanabhan
 Sent: Saturday, June 04, 2011 9:21
 To: r-help@r-project.org
 Subject: [R] library(SenoMineR)- Triangle Test Query

 Dear R Group
 I was trying to use the triangle.test function in SensoMineR and
 strangely i
 encounter a error in the output of preference matrix from the analysis.
 To illustrate, pl see the following dataframe of a design with the
 response
 and preference collected as shown below:

 design-structure(list(`Product X` = c(3, 1, 4, 2, 4, 2, 1, 3, 4, 2,
 4, 2, 1, 3, 4, 2, 4, 2, 3, 1), `Product Y` = c(1, 1, 4, 4, 4,
 3, 1, 1, 

Re: [R] Decision Trees /Decision Analysis with R?

2011-06-08 Thread Jonathan Daily
So TreeAge fits models but won't predict from them? That seems like
bizarre behavior. I suppose I would recommend, then, looking at the
source code from the aforementioned packages for how they store their
split data. It sounds like you would have to write code to hack
TreeAge outputs into another packages' format (e.g. look at
?rpart.object).

Sorry I couldn't help more,
Jon

On Wed, Jun 8, 2011 at 9:47 AM, stefan.d...@gmail.com
stefan.d...@gmail.com wrote:
 Thank you so much for reply. But I am looking for the exact opposite.

 I do not have a data set which I want to partition. But already a
 sequence/tree-like set of decision rules and with which I want to
 simulate what is my expected outcome/pay-off given a particular
 scenario.
 As far as I understand it, those packages could calculate the expected
 outcome AFTER having fit them to a particular data set and not
 construct a synthetic tree with exogenously defined decision
 nods/rules. Or am I wrong?


 Thanks and best,
 Stefan



 On Wed, Jun 8, 2011 at 2:03 PM, Jonathan Daily biomathjda...@gmail.com 
 wrote:
 See packages rpart, randomForest, party.

 Also, typing R Decision Trees produced good google results.

 http://www.google.com/search?aq=fsourceid=chromeie=UTF-8q=R+Decision+Trees

 On Wed, Jun 8, 2011 at 7:02 AM, stefan.d...@gmail.com
 stefan.d...@gmail.com wrote:
 Hello,

 this question is a bit out of the blue.

 I am a big R fan and user and in my new job I do some decision
 modeling (mostly health economics). For that decision trees are often
 used (I guess the most classic example is the investment decision A,
 B, and C with different probabilities, what is the expected payoff).
 We use a specialized software called TreeAge that some might know.
 The basic setup of such simulations is actually very simple and I
 guess useful in many fields. So I was wondering whether there is
 already a package out there in R that is doing such a thing?

 Thanks for any hints!
 Best,
 Stefan

 PS
 (By decision tree I don't mean cluster-like analysis of a data set
 splitting by identifying decision nods, but the other way around: I
 have decision nodes, what is my expected outcome.)

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




 --
 ===
 Jon Daily
 Technician
 ===
 #!/usr/bin/env outside
 # It's great, trust me.





-- 
===
Jon Daily
Technician
===
#!/usr/bin/env outside
# It's great, trust me.

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


Re: [R] Cleveland dot plots

2011-06-08 Thread William G. Jacoby

Colin Wahl wrote:
 
 I would rather use cleveland dot plots than bar charts to display my study
 results. I have not been able to find (or figure out) an R package that is
 capable of producing the publication quality dot charts Im looking for. I
 have either not been able to get error bars (lattice), cannot order the
 data display properly (latticeExtra), or cannot make adjustments to axes.
 Does anyone have a quick suggestion for a package that can handle
 cleveland dot plots well?
 

Most of the things you mention can be accomplished within the lattice
package, using panel functions and the scales= argument. The reorder()
function will probably accomplish what you're looking for when you say
order the data display properly. A few years ago, I wrote a short paper on
dotplots that you might find helpful: Jacoby, William G. 2006. The Dotplot:
A Graphical Display for Labeled Quantitative Values. The Political
Methodologist 14(1): 6-14. A longer version of the paper is available 
http://polisci.msu.edu/jacoby/research/dotplots/ here . Both of these papers
provide examples of the things you mention (error bars, reordering data,
etc.). Hope this helps!

--
View this message in context: 
http://r.789695.n4.nabble.com/Cleveland-dot-plots-tp3581122p3582719.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] Can we prepare a questionaire in R

2011-06-08 Thread Matt Shotwell
As Mike had written, there are frameworks for web-development with R.
RApache http://www.rapache.net is one. Also, see the R package Rook:
http://cran.r-project.org/web/packages/Rook/index.html .

On Wed, 2011-06-08 at 17:26 +0530, amrita gs wrote:
 How can we create HTML forms in R

Wouldn't you rather create HTML forms in HTML? See the links above to
use R for server-side scripting, for example, to receive form data from
a web browser.

 
   [[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] residual checking for GAM (mgcv)

2011-06-08 Thread Samuel Turgeon
Dear list,

i'm checking the residuals plots of a gam model after a processus of model
selection. I found the best model, all my terms are significant, the
r-square and the deviance explained are good, but I have strange residuals
plots:

http://dl.dropbox.com/u/1169100/gam.check.png
http://dl.dropbox.com/u/1169100/residuals_vs_fitted.png

The curve is caused by the zeroes in my data.

I've also plotted each explanatory variables included in the model
against residuals
and everything looks fine.

Is this curve does not allow me to accept this model?

Does the use of an other family (eg negbin) would be the solution for fixing
this problem? Currently I use the poisson family  (and quasipoisson). I have
a lot of 0 in my response variable, almost 65 % Should I use a specific
function that allows me to use zero-inflated data??

Kind regards,

Sam

[[alternative HTML version deleted]]

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


Re: [R] Can we prepare a questionaire in R

2011-06-08 Thread Barry Rowlingson
On Wed, Jun 8, 2011 at 12:56 PM, amrita gs ammasamri...@gmail.com wrote:
 How can we create HTML forms in R

 HTML is Just Plain Text, so you can create them using R's text output
'cat' function. E.g.

cat('form First name: input type=text name=firstname /br
/Last name: input type=text name=lastname //form',
file=test.html)

 and job done. Open test.html in your web browser and there it is.

 Other packages may help you construct these things - search CRAN for
html, and also 'brewer' which is a handy package for making templates
which you can render into HTML.

 But to be honest, your question is way too general as stated to get a
decent response here.

Barry

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


[R] install the “impute” package in unix

2011-06-08 Thread Salih Tuna
Hi,

I am trying to install the “impute” package in unix.  but I get the
following error message. I followed the following steps. Do you know what is
causing this and how I can solve this problem?

source(http://www.bioconductor.org/biocLite.R;)
biocLite(impute)

Using R version 2.11.1, biocinstall version 2.6.10.

Installing Bioconductor version 2.6 packages:

[1] impute

Please wait...



Warning in install.packages(pkgs = pkgs, repos = repos, ...) :

  argument 'lib' is missing: using '/nfs/users/nfs_s/st5/R-modules'

trying URL 'http://cran.ma.imperial.ac.uk/src/contrib/impute_1.26.0.tar.gz'

Content type 'application/x-gzip' length 1191531 bytes (1.1 Mb)

opened URL

==

downloaded 1.1 Mb



ERROR: failed to lock directory â/nfs/users/nfs_s/st5/R-modulesâ for
modifying

Try removing â/nfs/users/nfs_s/st5/R-modules/00LOCKâ



The downloaded packages are in

â/tmp/RtmpgJur79/downloaded_packagesâ

Warning message:

In install.packages(pkgs = pkgs, repos = repos, ...) :

  installation of package 'impute' had non-zero exit status





best,

salih

[[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] 3D-plotting a 2D-matrix that contains z-values (3rd dimension)

2011-06-08 Thread Oliver
Hello,

say I have a 2D-matrix (indexed by x and y), which contains
z values, which I want to plot over x-y.

Either dotted, or if possible as a landscape.

I tried around with persp and plot3d (from rgl)
and persp3d (from rgl).

I sometimes get something that looks good and a while later, when
trying some new data I need to worry about that again.

Is there something lika a convenience function that
can be used to feed the data into persp, rgl::plot3d and rgl::persp3d?

At least persp3d is picky about the order of the input data,
and I somehow always start again.

(plot3d seems to be most mathcing how I think).

Isn't that a very common case, where  my  z_x_y = mydata[x,y] ?

Maybe I just don't know the right function that helps me.

Any idea about that?


Ciao,
   Oliver

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


Re: [R] predict with model (rms package)

2011-06-08 Thread Frank Harrell
This is a consequence of predict.ols calling predictrms which relies on
model.frame which re-issues the expression of x.knots.  You would have the
same problem if using update(fit object) in another session.  For that
reason you have to keep an external knots vector available in your
environment.

Frank


Mark Seeto wrote:
 
 Dear R-help,
 
 In the rms package, I have fitted an ols model with a variable
 represented as a restricted cubic spline, with the knot locations
 specified as a previously defined vector. When I save the model object
 and open it in another workspace which does not contain the vector of
 knot locations, I get an error message if I try to predict with that
 model. This also happens if only one workspace is used, but the vector
 of knot locations is removed:
 
 library(rms)
 set.seed(1)
 x - rnorm(100)
 y - 1 + x + x^2 + rnorm(100)
 
 x.knots - quantile(x, c(0.2, 0.5, 0.8))
 ols1 - ols(y ~ rcs(x, x.knots))
 
 predict(ols1, data.frame(x = 0))  # This works
 rm(x.knots)
 predict(ols1, data.frame(x = 0))  # Gives error
 
 The first predict gives
 1
 0.8340293
 
 while the second predict gives
 Error in rcs(x, x.knots) : object 'x.knots' not found
 
 The same error happens if x.knots is simply defined as a vector like
 c(-1, 0, 1) (i.e. not using quantile). Is this the intended behaviour?
 The requirement that x.knots be in the workspace seems strange, given
 that the knot locations are stored in ols1$Design$parms.
 
 Thanks for any help you can give.
 
 Mark Seeto
 National Acoustic Laboratories, Australia
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 


-
Frank Harrell
Department of Biostatistics, Vanderbilt University
--
View this message in context: 
http://r.789695.n4.nabble.com/predict-with-model-rms-package-tp3581229p3582758.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] install the “impute” package in unix

2011-06-08 Thread Salih Tuna
I manage to install the package. But I cant load it now.

It says:



library(CGHcall)

Loading required package: impute

Error in dyn.load(file, DLLpath = DLLpath, ...) :

  unable to load shared library
'/nfs/users/nfs_s/st5/R-modules/impute/libs/impute.so':

  libgfortran.so.1: cannot open shared object file: No such file or
directory

In addition: Warning messages:

1: package 'CGHcall' was built under R version 2.11.1

2: package 'impute' was built under R version 2.11.1

Error: package 'impute' could not be loaded



What is going wrong?



Best,

salih


On Wed, Jun 8, 2011 at 3:52 PM, Salih Tuna saliht...@gmail.com wrote:

 Hi,

 I am trying to install the “impute” package in unix.  but I get the
 following error message. I followed the following steps. Do you know what is
 causing this and how I can solve this problem?

 source(http://www.bioconductor.org/biocLite.R;)
 biocLite(impute)

 Using R version 2.11.1, biocinstall version 2.6.10.

 Installing Bioconductor version 2.6 packages:

 [1] impute

 Please wait...



 Warning in install.packages(pkgs = pkgs, repos = repos, ...) :

   argument 'lib' is missing: using '/nfs/users/nfs_s/st5/R-modules'

 trying URL 'http://cran.ma.imperial.ac.uk/src/contrib/impute_1.26.0.tar.gz
 '

 Content type 'application/x-gzip' length 1191531 bytes (1.1 Mb)

 opened URL

 ==

 downloaded 1.1 Mb



 ERROR: failed to lock directory â/nfs/users/nfs_s/st5/R-modulesâ for
 modifying

 Try removing â/nfs/users/nfs_s/st5/R-modules/00LOCKâ



 The downloaded packages are in

 â/tmp/RtmpgJur79/downloaded_packagesâ

 Warning message:

 In install.packages(pkgs = pkgs, repos = repos, ...) :

   installation of package 'impute' had non-zero exit status





 best,

 salih


[[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] The simplest bar graph with ggplot is difficult to realize

2011-06-08 Thread Juan Carlos Borrás
Dear all,
What is the simplest way of producing a bar graph using ggplot but
avoiding calling qplot?

That is, given:
d - data.frame(x=seq(1,5), y=seq(1,5))

Why does the following line return an error?
ggplot(d, aes(x=x, y=y)) + stat_identity() + geom_bar(bindwidth=1)

Thanks in advance,
jcb!

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


Re: [R] Error Installing or Updating Packages (Maybe because of a proxy)

2011-06-08 Thread Olivier Crouzet
Dear all,

I receive the very same error message on a Debian computer (testing)
with R 2.13.0 also.

 install.packages('emu')
Installing package(s) into
‘/home/olivier/R/i486-pc-linux-gnu-library/2.13’ (as ‘lib’ is
unspecified) 
Error in ret[i, ] - c(pkgs[i], lib, desc) : 
  number of items to replace is not a multiple of replacement length

I have no proxy settings on this computer (neither
in .bashrc / .bash_profile, nor in my desktop environment, and I'm
doing it at home where I'm not using any proxy).

I can download a file on the web from within R (using both download.file
() or download.packages
('emu','/home/olivier/R/i486-pc-linux-gnu-library/2.13')... and finally
I can also use install.packages() on this downloaded file and the
install works flawlessly.

I can't find any old R base package in the various directories
indicated by .libPaths().

 .libPaths()
[1] /home/olivier/R/i486-pc-linux-gnu-library/2.13
[2] /usr/local/lib/R/site-library 
[3] /usr/lib/R/site-library   
[4] /usr/lib/R/library   

The only place where I can think there may be one are the local trees
([1] and [2]) as the 2 others are (should be) updated automatically when
updating R with the Debian pkg mngmt system and there's nothing inside
them. Only [4] contains a base/ subdirectory (a single one) but I
suppose this is the current one for R 2.13.0

I can install a package once it's been downloaded locally (through R CMD
INSTALL pkg) but can't succeed in installing the same package from the
CRAN mirrors using install.packages(). I experience the very same issue
with all related instructions (old.packages(), update.packages()) 

I also could do that several months ago on a different Debian computer
(but with an older R version than the current one).

Any hints (including what kind of information I should give to enhance
the description of this issue)?

Olivier.




On Wed, 20 Apr 2011 10:29:17 +0200 Uwe Ligges
lig...@statistik.tu-dortmund.de wrote:

 If the internet connection from R works, can you please verify that
 you do not have any R base package from an old R version in a current
 R library that you may have in the .libPaths() already?
 
 Uwe Ligges
 
 
 
 On 20.04.2011 09:25, Majid Einian wrote:
  Dear R Helpers,
  (I am using Ubuntu lucid and R 2.13.0
  When I try to update packages I get this error:
 
  update.packages()
  --- Please select a CRAN mirror for use in this session ---
  Loading Tcl/Tk interface ... done
  Error in ret[i, ]- c(pkgs[i], lib, desc) :
 number of items to replace is not a multiple of replacement
  length
 
  I had no problem before (case 1) but now (case 2) I cannot get it
  to work, googleing did not help:
  case 1:
* connecting directly without any proxy setting (at my
  university)
* using R 2.12.2
  case 2:
* connecting through proxy setting (at my workplace)
* using R 2.13.0
 
  I set the proxy in terminal too but it does not help (echo
  $http_proxy gives me http://192.168.0.1:8080/)
 
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html and provide commented,
 minimal, self-contained, reproducible code.


-- 
  Olivier Crouzet, PhD
  Laboratoire de Linguistique -- EA3827
  Département de Sciences du Langage
  UFR Lettres et Langages
  Université de Nantes
  Chemin de la Censive du Tertre - BP 81227
  44312 Nantes cedex 3
  France

 phone:(+33) 02 40 14 14 05 (lab.)
   (+33) 02 40 14 14 36 (office)
 fax:  (+33) 02 40 14 13 27
 e-mail:   olivier.crou...@univ-nantes.fr

  http://www.lling.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] The simplest bar graph with ggplot is difficult to realize

2011-06-08 Thread Ista Zahn
Hi Juan,
Each geom can have it's own stat, so stat_identity() doesn't change
the stat used by geom_bar(). You need

ggplot(d, aes(x=x, y=y)) + geom_bar(stat=identity)

Best,
Ista
2011/6/8 Juan Carlos Borrás jcbor...@gmail.com:
 Dear all,
 What is the simplest way of producing a bar graph using ggplot but
 avoiding calling qplot?

 That is, given:
 d - data.frame(x=seq(1,5), y=seq(1,5))

 Why does the following line return an error?
 ggplot(d, aes(x=x, y=y)) + stat_identity() + geom_bar(bindwidth=1)

 Thanks in advance,
 jcb!

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




-- 
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org

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


[R] CGHcall and normalization

2011-06-08 Thread Salih Tuna
Hi,
i am trying to use the normalization function from CGHcall library.

The command i use is

normal.fullData - normalize(fullData, method = median, cellularity = 1)

and i get the following error message. How can i solve this issue.

Error in function (classes, fdef, mtable)  :
  unable to find an inherited method for function copynumber, for
signature data.frame

best,
salih

[[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] PS to Taking Integral and Optimization using Integrate() and Optim()

2011-06-08 Thread MARYAM ZOLGHADR
Hello again.
Thank you for the comments. I have written these codes.

iy=function(x)
{
res=NULL
ress=0
for (i in (1:2))
{
for (xx in x[i])
{
fy=function(y) 
(exp(-exp(y+log(xx)))*(-exp(y+log(xx)))^2)/(1-exp(-exp(y+log(xx
res=c(res,integrate(fy,-6.907,-1.246)$value)
ress=ress+res
}
}
return(ress)
}
iy(c(1,1))
integrate(fy,-6.907,-1.246)$value

In 1D optimize() works perfectly on iy(). However the problem is in 2D and 
more, optimize() does not work and I need to apply optim(). I could not apply 
optim() on iy().

Beside, I tried to use Ryacas, I faced with this error:
[1] Starting Yacas!
Error in socketConnection(host = 127.0.0.1, port = 9734, server = FALSE, :
cannot open the connection
In addition: Warning message:
In socketConnection(host = 127.0.0.1, port = 9734, server = FALSE, :
127.0.0.1:9734 cannot be opened

Cheers,
Maryam

[[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] Decision Trees /Decision Analysis with R?

2011-06-08 Thread Graham Smith
Jon,

So TreeAge fits models but won't predict from them? That seems like
 bizarre behavior.


Nothing bizarre about TreeAge, just a different tool in a different
disicpline.

http://en.wikipedia.org/wiki/Decision_tree


Graham

[[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] Decision Trees /Decision Analysis with R?

2011-06-08 Thread stefan.d...@gmail.com
TreeAge works just fine. But its commercial, thats all...

On Wed, Jun 8, 2011 at 6:17 PM, Graham Smith myotis...@gmail.com wrote:
 Jon,

 So TreeAge fits models but won't predict from them? That seems like
 bizarre behavior.

 Nothing bizarre about TreeAge, just a different tool in a different
 disicpline.

 http://en.wikipedia.org/wiki/Decision_tree


 Graham


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


Re: [R] XML segfault on some architectures

2011-06-08 Thread Janet Young
Dear Prof Ripley,

Apologies - I've re-sent that to Duncan Temple Lang, along with your note about 
lib versions. 

Version info was included in my original post - I gave full sessionInfo(). It's 
XML_3.4-0.

I only have a very sketchy understanding of libraries and systems 
administration, but it looks like our libxml2 is version 2.6.26.  I'll ask my 
sysadmin people whether they can update that, and try again.

Janet



On Jun 7, 2011, at 10:54 PM, Prof Brian Ripley wrote:

 On Tue, 7 Jun 2011, Janet Young wrote:
 
 Hi,
 
 I found an architecture-specific segfault problem with the XML package. I 
 originally found the problem using the parseKGML2Graph function in the 
 Bioconductor KEGGgraph package, but as far as I can tell the underlying 
 issue seems to be with the xmlTreeParse which is called by parseKGML2Graph.
 
 I'm trying this piece of code, from the xmlTreeParse help page:
 
 library(XML)
 fileName - system.file(exampleData, test.xml, package=XML)
 x - xmlTreeParse(fileName)
 
 On my Mac and on nodes of one of the linux clusters I have access to, this 
 works fine. But on another of the linux clusters I use, I get a segfault 
 every time, on both 32-bit and 64-bit nodes of the cluster.  The unames for 
 those nodes are here:
 
 Linux kong053 2.6.18-194.17.1.el5xen #1 SMP Wed Sep 29 13:30:21 EDT 2010 
 x86_64 x86_64 x86_64 GNU/Linux
 Linux king049 2.6.18-194.26.1.el5xen #1 SMP Tue Nov 9 14:13:46 EST 2010 i686 
 i686 i386 GNU/Linux
 
 I think I've included all the relevant info below, but please let me know if 
 there's anything else you'd like to see.
 
 As the posting guide says, report problems in contributed packages first to 
 the maintainer, giving the 'at a minimum' information required (which 
 includes the package version number).
 
 But note that package XML relies on libxml2, and it is entirely possible the 
 fault is in the latter.  Your kernel looks like RHEL 5 (and is an old 
 version): that is well known for having very old versions of system software. 
  One known issue with libxml2 is a mismatch between it and zlib 1.2.[45] 
 prior to libxml2 2.7.7 (2.7.8 is current): from experience, that causes 
 segfaults in package XML's examples.
 
 
 thanks,
 
 Janet
 
 ---
 
 Dr. Janet Young
 
 Fred Hutchinson Cancer Research Center
 1100 Fairview Avenue N., C3-168,
 P.O. Box 19024, Seattle, WA 98109-1024, USA.
 
 tel: (206) 667 1471 fax: (206) 667 6524
 email: jayoung  ...at...  fhcrc.org
 
 
 ---
 
 
 
 
 
 
  on 64-bit node
 
 library(XML)
 
 fileName - system.file(exampleData, test.xml, package=XML)
 
 fileName
 [1] /home/btrask/traskdata/lib_linux_64/R/library/XML/exampleData/test.xml
 
 sessionInfo()
 R version 2.13.0 (2011-04-13)
 Platform: x86_64-unknown-linux-gnu (64-bit)
 
 locale:
 [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=C  LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=en_US.UTF-8   LC_NAME=C
 [9] LC_ADDRESS=C   LC_TELEPHONE=C
 [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
 
 attached base packages:
 [1] stats graphics  grDevices utils datasets  methods   base
 
 other attached packages:
 [1] XML_3.4-0
 
 
 system(uname -a)
 Linux kong053 2.6.18-194.17.1.el5xen #1 SMP Wed Sep 29 13:30:21 EDT 2010 
 x86_64 x86_64 x86_64 GNU/Linux
 
 x - xmlTreeParse(fileName)
 
 *** caught segfault ***
 address 0x51c4f, cause 'memory not mapped'
 
 Traceback:
 1: .Call(RS_XML_ParseTree, as.character(file), handlers, 
 as.logical(ignoreBlanks), as.logical(replaceEntities), 
 as.logical(asText), as.logical(trim), as.logical(validate), 
 as.logical(getDTD), as.logical(isURL), 
 as.logical(addAttributeNamespaces), as.logical(useInternalNodes), FALSE, 
 as.logical(isSchema), as.logical(fullNamespaceInfo), 
 as.character(encoding), as.logical(useDotNames), xinclude, error, 
 addFinalizer, PACKAGE = XML)
 2: xmlTreeParse(fileName)
 
 Possible actions:
 1: abort (with core dump, if enabled)
 2: normal R exit
 3: exit R without saving workspace
 4: exit R saving workspace
 Selection:
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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 

[R] Help with plotting plsr loadings

2011-06-08 Thread Amit Patel
Hi

I am attempting to do a loadings plot from a plsr object. I have managed to do 
this using the gasoline data that comes with the pls package. However when I 
conduct this on my dataset i get the following error message. 


plot(BHPLS1, loadings, comps = 1:2, legendpos = topleft, labels = 
numbers, 
xlab = nm)

Error in loadingplot.default(x, ...) : 
  Could not convert variable names to numbers.


 str(BHPLS1_Loadings)
 loadings [1:8892, 1:60] -0.00717 0.00414 0.02611 0.00468 -0.00676 ...
 - attr(*, dimnames)=List of 2
  ..$ : chr [1:8892] PCIList1 PCIList2 PCIList3 PCIList4 ...
  ..$ : chr [1:60] Comp 1 Comp 2 Comp 3 Comp 4 ...
 - attr(*, explvar)= Named num [1:60] 2.67 4.14 4.41 3.55 2.59 ...
  ..- attr(*, names)= chr [1:60] Comp 1 Comp 2 Comp 3 Comp 4 ...

Can anyone see the problem??

[[alternative HTML version deleted]]

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


[R] How to suppress factor labels

2011-06-08 Thread James Rome
I am using ggplot2 to make a boxplot that overlays a scatterplot:
pp = qplot(time, error, data=times, size=I(1), geom=jitter, main=title,
ylab=Error (min), xlab=Time before ON (min), alpha=I(1/10),
color=times$runway,
ylim=c(-30,40))
pp2 = pp + with(times, facet_wrap(~ runway, ncol=2))
print(pp2 + geom_boxplot(alpha=.5, color=blue,
outlier.colour=green, outlier.size=1))
The x variable is a factor for every minute from 0:60. My problem is
that ggplot2 labels every factor value on the x axis, and they overlap.
How can I make ggplot2 label only, say every 5th factor value on the x axis?

Thanks,
Jim

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


[R] [R-pkgs] svmpath_0.95 uploaded to CRAN

2011-06-08 Thread Trevor Hastie
This new version includes a plot method for plotting
a particular instance along the path.

 

  Trevor Hastie   has...@stanford.edu  
  Professor, Department of Statistics, Stanford University
  Phone: (650) 725-2231 Fax: (650) 725-8977  
  URL: http://www.stanford.edu/~hastie  
   address: room 104, Department of Statistics, Sequoia Hall
   390 Serra Mall, Stanford University, CA 94305-4065  
 
___
R-packages mailing list
r-packa...@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-packages

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


Re: [R] How to suppress factor labels

2011-06-08 Thread Ista Zahn
Hi Jim,

See ?scale_x_discrete

Best,
Ista

On Wed, Jun 8, 2011 at 3:26 PM, James Rome jamesr...@gmail.com wrote:
 I am using ggplot2 to make a boxplot that overlays a scatterplot:
 pp = qplot(time, error, data=times, size=I(1), geom=jitter, main=title,
        ylab=Error (min), xlab=Time before ON (min), alpha=I(1/10),
 color=times$runway,
        ylim=c(-30,40))
    pp2 = pp + with(times, facet_wrap(~ runway, ncol=2))
    print(pp2 + geom_boxplot(alpha=.5, color=blue,
 outlier.colour=green, outlier.size=1))
 The x variable is a factor for every minute from 0:60. My problem is
 that ggplot2 labels every factor value on the x axis, and they overlap.
 How can I make ggplot2 label only, say every 5th factor value on the x axis?

 Thanks,
 Jim

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




-- 
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org

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


[R] Variable in file name png

2011-06-08 Thread Aaron Coutino
Hi,

I'm having trouble with getting the png function to properly produce multiple 
graphs. RIght now I have:

for (z in data) {
 png(file=z,bg=white)
 thisdf-data[[z]]
 plot(thisdf$rc,thisdf$psi)
 dev.off()
 }

Which should take the data object, a list of data sets and produce a graph of 
each with respect to the two variables rc and psi.
I want the names to change for each graph, but am not sure how to do it, any 
help would be apreciated.
Thanks,
-Acoutino
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Histogram

2011-06-08 Thread nandini_bn

Hello ,
I am trying to create a histogram in order to compare between two groups and
would like it to be similar to the figure attached. How can I generate this
using R ?


Thank you,
Nandini http://r.789695.n4.nabble.com/file/n3582448/5634-15977-1-PB.gif 

--
View this message in context: 
http://r.789695.n4.nabble.com/Histogram-tp3582448p3582448.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] histogram help

2011-06-08 Thread Nandini B


Hello ,
I am trying to create a histogram in order to compare between two groups and 
would like it to be similar to the figure attached. How can I generate this 
using R ?


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


[R] R command window

2011-06-08 Thread Michael Davidsen
Hello.

I'm a visually impaired statistician, working at the National Institute of 
Public Health in Denmark.

I would like to use R for some analysis and have succesfully installed version 
2.13.0 on my Windows XP labtop.
I then would like to run R interactively but unfortunately the textfont of the 
command line in the R window is very hard for me to read. I use a special 
program called Zoomtext that among many other functionalities enables me  to 
invert colurs.

It is possible to change the prompt (using options(...)) but I cannot see that 
it is possible to change the font - eg. and most importantly changing its color 
or size.

I have tried to check the Windows FAQ but couldn't find anything.

Is this possible? And (of course) - if yes, how?

I guess the best solution for me is to run R non-interactively because I can 
use an editor for my programs - but it is cumbersome.
Can I as a DOS command write something like
R input-file output-file?

I'm very new in R so it's exciting for me to see if I have any response.

Best wishes
Michael


Michael Davidsen
National Institute of Public Health
University of Southern Denmark
Øster Farimagsgade 5A, 2.
DK-1353 Copenhagen K
Denmark

E-mail: m...@sdu.dkmailto:m...@sdu.dk
Web: www.si-folkesundhed.dkhttp://www.si-folkesundhed.dk



[[alternative HTML version deleted]]

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


Re: [R] Adding values to the end of a data frame

2011-06-08 Thread Abraham Mathew
I'm trying to develop this function so that I can efficiently generate
all possibile combinations of the strings.

So I have certain roots, prefixes, and sufixes. I also have different
combinations of the data, some with two strings (roots, prefix) and others
with three strings (roots, prefix, suffix)

roots - c(car insurance, auto insurance)
roots2 - c(insurance)
prefix - c(cheap, budget)
prefix2 - c(low cost)
suffix - c(quote, quotes)
suffix2 - c(rate, rates)
suffix3 - c(comparison)

Here are just a few of the combinations I'm trying to generate.

# prefix, roots, suffix
# prefix, roots, suffix2
# prefix, roots, suffix3
# prefix2, roots, suffix
# prefix2, roots, suffix2
# prefix2, roots, suffix3
# prefix, roots2, suffix
# prefix, roots2, suffix2
# prefix, roots2, suffix3
# prefix2, roots2, suffix
# prefix2, roots2, suffix2
# prefix2, roots2, suffix3
# prefix, roots
# prefix2, roots
# prefix, roots2
# prefix2, roots2
# roots, suffix
# roots, suffix2
# roots, suffix3
# roots2, suffix
# roots2, suffix2
# roots2, suffix3
# state, roots
# city, roots
# cityst, roots

So instead of two functions for ones with two vs three parameters, I'm
wondering if it's possible to just develop one function.

one - function(x, y) {
  nu - do.call(paste, expand.grid(x, y))
  mydf - data.frame(nu)
}

two - function(x, y, z){
  mu - do.call(paste, expand.grid(x, y, z))
  mydf2 - data.frame(mu)
}







On Tue, Jun 7, 2011 at 6:54 PM, Dennis Murphy djmu...@gmail.com wrote:

 Alas, you don't have a suffix2 object defined, but try this:

 d1 - one(prefix, roots)
 d2 - one(roots, suffix)
 rbind(d1, d2)

 To see a potential flaw in your function (as least as far as console
 output is concerned), try
 rbind(d1, one(roots, suffix))

 HTH,
 Dennis

 On Tue, Jun 7, 2011 at 3:30 PM, Abraham Mathew abra...@thisorthat.com
 wrote:
  Let's say that I'm trying to write a functions that will allow me to
  automate a process
  where I examine all possible combinations of various string groupings.
 Each
  time I run
  the one function, I want to include the new values to the end of a data
  frame. The data
  frame will basically be one column with a lot of rows.
 
  roots - c(car insurance, auto insurance)
  prefix - c(cheap, budget)
  suffix - c(rate, rates)
 
  one - function(x, y, z=0) {
   nu - do.call(paste, expand.grid(x, y, z))
   mydf - data.frame(nu)
   print(mydf)
  }
 
  one(roots, suffix2)
  one(prefix, roots)
  one(prefix, roots, suffix2)
 
  The code above just replaces each value in the data frame each time I run
  the one function.
 
  How can I add the new values to the end of the data frame?
 
 
  Help!
 
  I'm running R 2.13 on Ubuntu 10.10
  WebRep
  Overall rating
 
 [[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.


[R] how can I??

2011-06-08 Thread 전경욱
 st1=c(5,3)
st2=c(-1,2)
st3=c(1,3)
st4=c(2,6)

st = rbind(st1,st2,st3,st4)
st
dx=round(dist(st), digits=2)
dx  #À¯Å¬¸®µå °Å¸®Çà·Ä
D1=dist(st, method=quot;euclideanquot;)
D1  # À¯Å¬¸®µå°Å¸® ±¸Çϱâ

D2=dist(st, method=quot;manhattanquot;)
D2  # ¸ÇÇÏź °Å¸®Çà·Ä



and I want know 

How can i use   statistical distance   and   Mahalanobis   distance


[[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] package.skeleton() does not create 'data' folder

2011-06-08 Thread Nipesh Bajaj
Hi again, I was using package.skeleton() function to create the
skeleton of my package in windows. Here is my attempt:

rm(list = ls())
setwd(F:/R_PackageBuild)
package.skeleton(trial1, namespace = TRUE, code_files =
F:/R_PackageBuild/trial.r)

In the trial.r file, there are 2 objects, one is a function and
another is data. Here they are:

fn1 - Vectorize(function(x,y,z) {
return(x + y +z)
}, SIMPLIFY = TRUE)
Data - rnorm(20)

However my problem is that package.skeleton() does not create any data
folder in the skeleton tree. However in the man folder there are 3 Rd
files (as expected), naming:
Data, fn1, trial1-package

However on the contrary if my code is like below then,
package.skeleton() creates data folder.
 fn1 - Vectorize(function(x,y,z) {
+ return(x + y +z)
+ }, SIMPLIFY = TRUE)
 Data - rnorm(20)

 setwd(F:/R_PackageBuild)
 package.skeleton(trial2)

So is it that if I use 'code_files ' argument then, R would not create
data folder?

Can somebody help me what I am missing in this process? Till now, I
create manually the data folder and within that folder manually put a
RData file where only object is that 'Data'. However I believe there
must be more elegant way to doing that.

While searching over net to settle this issue, I found this thread
'http://r.789695.n4.nabble.com/How-to-create-rda-file-to-be-used-in-package-building-td828148.html'
however this is answering my question.

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] predict with model (rms package)

2011-06-08 Thread Mark Seeto
Thanks for your reply, Frank. I've noticed that the x.knots object doesn't
actually have to be the vector of knots. Just having x.knots - 0 or even
x.knots - a will allow predict to work.

Mark Seeto


Frank Harrell wrote:
 
 This is a consequence of predict.ols calling predictrms which relies on
 model.frame which re-issues the expression of x.knots.  You would have the
 same problem if using update(fit object) in another session.  For that
 reason you have to keep an external knots vector available in your
 environment.
 
 Frank
 
 
 Mark Seeto wrote:
 
 Dear R-help,
 
 In the rms package, I have fitted an ols model with a variable
 represented as a restricted cubic spline, with the knot locations
 specified as a previously defined vector. When I save the model object
 and open it in another workspace which does not contain the vector of
 knot locations, I get an error message if I try to predict with that
 model. This also happens if only one workspace is used, but the vector
 of knot locations is removed:
 
 library(rms)
 set.seed(1)
 x - rnorm(100)
 y - 1 + x + x^2 + rnorm(100)
 
 x.knots - quantile(x, c(0.2, 0.5, 0.8))
 ols1 - ols(y ~ rcs(x, x.knots))
 
 predict(ols1, data.frame(x = 0))  # This works
 rm(x.knots)
 predict(ols1, data.frame(x = 0))  # Gives error
 
 The first predict gives
 1
 0.8340293
 
 while the second predict gives
 Error in rcs(x, x.knots) : object 'x.knots' not found
 
 The same error happens if x.knots is simply defined as a vector like
 c(-1, 0, 1) (i.e. not using quantile). Is this the intended behaviour?
 The requirement that x.knots be in the workspace seems strange, given
 that the knot locations are stored in ols1$Design$parms.
 
 Thanks for any help you can give.
 
 Mark Seeto
 National Acoustic Laboratories, Australia
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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://r.789695.n4.nabble.com/predict-with-model-rms-package-tp3581229p3583344.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] Decision Trees /Decision Analysis with R?

2011-06-08 Thread Anupam
It is difficult for someone from a statistical frame of mind to understand
what this is about --- you need to think a bit differently. It is mostly a
simulation and decision analysis, with some use of statistical functions to
draw random samples to simulate the fact that outcome of interest can take
any value from a known or unknown distribution. For example, you may be
comparing two interventions and a do-nothing decision to improve some health
outcome of interest. The decision maker is interested in *relative*
effectiveness and costs of the interventions to improve the outcome of
interest. You have results from published literature that you can use as
inputs into a simulation exercise to compare relative costs and
benefits/effectiveness of the three options. A small decision tree can be
easily simulated in a spreadsheet; for long trees with many decision nodes
it is useful to have a specialized software. There are some Excel plugins
that are sold about $100. Others are more expensive.

I think R is not well suited for this kind of work. A decision analysis
package in R may require user to write code like the one used in LaTeX or
related programs (Metapost) to draw graphs of trees (e.g. complicated
organizational trees, or hierarchical trees). However, in such a package
there can be useful outputs, measures and graphs generated by R using code
that may already exist for other packages.

Look up journal Medical Decision Making to know what is being discussed.
This method is used extensively in medicine and public health to study
decisions. It even uses MCMC, though with a different flavor --- it may even
be a different kind of food.

Anupam.
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Jonathan Daily
Sent: Wednesday, June 08, 2011 7:47 PM
To: stefan.d...@gmail.com
Cc: r-help@r-project.org
Subject: Re: [R] Decision Trees /Decision Analysis with R?

So TreeAge fits models but won't predict from them? That seems like bizarre
behavior. I suppose I would recommend, then, looking at the source code from
the aforementioned packages for how they store their split data. It sounds
like you would have to write code to hack TreeAge outputs into another
packages' format (e.g. look at ?rpart.object).

Sorry I couldn't help more,
Jon

On Wed, Jun 8, 2011 at 9:47 AM, stefan.d...@gmail.com
stefan.d...@gmail.com wrote:
 Thank you so much for reply. But I am looking for the exact opposite.

 I do not have a data set which I want to partition. But already a 
 sequence/tree-like set of decision rules and with which I want to 
 simulate what is my expected outcome/pay-off given a particular 
 scenario.
 As far as I understand it, those packages could calculate the expected 
 outcome AFTER having fit them to a particular data set and not 
 construct a synthetic tree with exogenously defined decision 
 nods/rules. Or am I wrong?


 Thanks and best,
 Stefan



 On Wed, Jun 8, 2011 at 2:03 PM, Jonathan Daily biomathjda...@gmail.com
wrote:
 See packages rpart, randomForest, party.

 Also, typing R Decision Trees produced good google results.

 http://www.google.com/search?aq=fsourceid=chromeie=UTF-8q=R+Decisi
 on+Trees

 On Wed, Jun 8, 2011 at 7:02 AM, stefan.d...@gmail.com 
 stefan.d...@gmail.com wrote:
 Hello,

 this question is a bit out of the blue.

 I am a big R fan and user and in my new job I do some decision 
 modeling (mostly health economics). For that decision trees are 
 often used (I guess the most classic example is the investment 
 decision A, B, and C with different probabilities, what is the expected
payoff).
 We use a specialized software called TreeAge that some might know.
 The basic setup of such simulations is actually very simple and I 
 guess useful in many fields. So I was wondering whether there is 
 already a package out there in R that is doing such a thing?

 Thanks for any hints!
 Best,
 Stefan

 PS
 (By decision tree I don't mean cluster-like analysis of a data set 
 splitting by identifying decision nods, but the other way around: I 
 have decision nodes, what is my expected outcome.)

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




 --
 ===
 Jon Daily
 Technician
 ===
 #!/usr/bin/env outside
 # It's great, trust me.





--
===
Jon Daily
Technician
===
#!/usr/bin/env outside
# It's great, trust me.

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

[R] Results of CFA with Lavaan

2011-06-08 Thread R Help
I've just found the lavaan package, and I really appreciate it, as it
seems to succeed with models that were failing in sem::sem.  I need
some clarification, however, in the output, and I was hoping the list
could help me.

I'll go with the standard example from the help documentation, as my
problem is much larger but no more complicated than that.

My question is, why is there one latent estimate that is set to 1 with
no SD for each factor?  Is that normal?  When I've managed to get
sem::sem to fit a model this has not been the case.

Thanks,
Sam Stewart

HS.model - ' visual  =~ x1 + x2 + x3
  textual =~ x4 + x5 + x6
  speed   =~ x7 + x8 + x9 '
fit - sem(HS.model, data=HolzingerSwineford1939)
summary(fit, fit.measures=TRUE)
Lavaan (0.4-8) converged normally after 35 iterations

  Number of observations   301

  Estimator ML
  Minimum Function Chi-square   85.306
  Degrees of freedom24
  P-value0.000

Chi-square test baseline model:

  Minimum Function Chi-square  918.852
  Degrees of freedom36
  P-value0.000

Full model versus baseline model:

  Comparative Fit Index (CFI)0.931
  Tucker-Lewis Index (TLI)   0.896

Loglikelihood and Information Criteria:

  Loglikelihood user model (H0)  -3737.745
  Loglikelihood unrestricted model (H1)  -3695.092

  Number of free parameters 21
  Akaike (AIC)7517.490
  Bayesian (BIC)  7595.339
  Sample-size adjusted Bayesian (BIC) 7528.739

Root Mean Square Error of Approximation:

  RMSEA  0.092
  90 Percent Confidence Interval  0.071  0.114
  P-value RMSEA = 0.05  0.001

Standardized Root Mean Square Residual:

  SRMR   0.065

Parameter estimates:

  Information Expected
  Standard Errors Standard


   Estimate  Std.err  Z-value  P(|z|)
Latent variables:
  visual =~
x11.000
x20.5540.1005.5540.000
x30.7290.1096.6850.000
  textual =~
x41.000
x51.1130.065   17.0140.000
x60.9260.055   16.7030.000
  speed =~
x71.000
x81.1800.1657.1520.000
x91.0820.1517.1550.000

Covariances:
  visual ~~
textual   0.4080.0745.5520.000
speed 0.2620.0564.6600.000
  textual ~~
speed 0.1730.0493.5180.000

Variances:
x10.5490.1144.8330.000
x21.1340.102   11.1460.000
x30.8440.0919.3170.000
x40.3710.0487.7780.000
x50.4460.0587.6420.000
x60.3560.0438.2770.000
x70.7990.0819.8230.000
x80.4880.0746.5730.000
x90.5660.0718.0030.000
visual0.8090.1455.5640.000
textual   0.9790.1128.7370.000
speed 0.3840.0864.4510.000

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


Re: [R] Results of CFA with Lavaan

2011-06-08 Thread Jeremy Miles
What do you mean by latent estimate?

The table of variances has  variances for each factors.

Is there something different in the sem output that you don't see here?

Yes, this looks normal.

Jeremy



On 8 June 2011 13:14, R Help rhelp.st...@gmail.com wrote:
 I've just found the lavaan package, and I really appreciate it, as it
 seems to succeed with models that were failing in sem::sem.  I need
 some clarification, however, in the output, and I was hoping the list
 could help me.

 I'll go with the standard example from the help documentation, as my
 problem is much larger but no more complicated than that.

 My question is, why is there one latent estimate that is set to 1 with
 no SD for each factor?  Is that normal?  When I've managed to get
 sem::sem to fit a model this has not been the case.

 Thanks,
 Sam Stewart

 HS.model - ' visual  =~ x1 + x2 + x3
              textual =~ x4 + x5 + x6
              speed   =~ x7 + x8 + x9 '
 fit - sem(HS.model, data=HolzingerSwineford1939)
 summary(fit, fit.measures=TRUE)
 Lavaan (0.4-8) converged normally after 35 iterations

  Number of observations                           301

  Estimator                                         ML
  Minimum Function Chi-square                   85.306
  Degrees of freedom                                24
  P-value                                        0.000

 Chi-square test baseline model:

  Minimum Function Chi-square                  918.852
  Degrees of freedom                                36
  P-value                                        0.000

 Full model versus baseline model:

  Comparative Fit Index (CFI)                    0.931
  Tucker-Lewis Index (TLI)                       0.896

 Loglikelihood and Information Criteria:

  Loglikelihood user model (H0)              -3737.745
  Loglikelihood unrestricted model (H1)      -3695.092

  Number of free parameters                         21
  Akaike (AIC)                                7517.490
  Bayesian (BIC)                              7595.339
  Sample-size adjusted Bayesian (BIC)         7528.739

 Root Mean Square Error of Approximation:

  RMSEA                                          0.092
  90 Percent Confidence Interval          0.071  0.114
  P-value RMSEA = 0.05                          0.001

 Standardized Root Mean Square Residual:

  SRMR                                           0.065

 Parameter estimates:

  Information                                 Expected
  Standard Errors                             Standard


                   Estimate  Std.err  Z-value  P(|z|)
 Latent variables:
  visual =~
    x1                1.000
    x2                0.554    0.100    5.554    0.000
    x3                0.729    0.109    6.685    0.000
  textual =~
    x4                1.000
    x5                1.113    0.065   17.014    0.000
    x6                0.926    0.055   16.703    0.000
  speed =~
    x7                1.000
    x8                1.180    0.165    7.152    0.000
    x9                1.082    0.151    7.155    0.000

 Covariances:
  visual ~~
    textual           0.408    0.074    5.552    0.000
    speed             0.262    0.056    4.660    0.000
  textual ~~
    speed             0.173    0.049    3.518    0.000

 Variances:
    x1                0.549    0.114    4.833    0.000
    x2                1.134    0.102   11.146    0.000
    x3                0.844    0.091    9.317    0.000
    x4                0.371    0.048    7.778    0.000
    x5                0.446    0.058    7.642    0.000
    x6                0.356    0.043    8.277    0.000
    x7                0.799    0.081    9.823    0.000
    x8                0.488    0.074    6.573    0.000
    x9                0.566    0.071    8.003    0.000
    visual            0.809    0.145    5.564    0.000
    textual           0.979    0.112    8.737    0.000
    speed             0.384    0.086    4.451    0.000

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

2011-06-08 Thread Xia.Li
Hello R users,

I have difficulties when trying to make R packages. I tried to read many
tutorials but still could not find out the right way. Could any one help me
out please? (I'm using Windows xp.)

After running package.skeleton() and edit those RD files, I don't know how
to use Rtools (or CMD shell?) to build the zip file. I installed the Rtools
from Murdoch's link, but it doesn't look like a software...

Anyone could give me a tutorial with more details about Rtools (or CMD
shell)? I've already have MikTex installed. 

Thanks!

--
View this message in context: 
http://r.789695.n4.nabble.com/Questions-about-building-R-packages-tp3583510p3583510.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] Results of CFA with Lavaan

2011-06-08 Thread John Fox
Dear Sam,

In each case, the first observed variable is treated as a reference
indicator with its coefficient fixed to 1 to establish the metric of the
corresponding factor and therefore to identify the model. If you didn't do
the same thing (or something equivalent, such as fixing the factor variances
to 1) in specifying the model to sem::sem(), that might account for the
problems you encountered.

Best,
 John


John Fox
Senator William McMaster
  Professor of Social Statistics
Department of Sociology
McMaster University
Hamilton, Ontario, Canada
http://socserv.mcmaster.ca/jfox

 

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of R Help
 Sent: June-08-11 4:15 PM
 To: r-help
 Subject: [R] Results of CFA with Lavaan
 
 I've just found the lavaan package, and I really appreciate it, as it
 seems to succeed with models that were failing in sem::sem.  I need some
 clarification, however, in the output, and I was hoping the list could
 help me.
 
 I'll go with the standard example from the help documentation, as my
 problem is much larger but no more complicated than that.
 
 My question is, why is there one latent estimate that is set to 1 with
 no SD for each factor?  Is that normal?  When I've managed to get
 sem::sem to fit a model this has not been the case.
 
 Thanks,
 Sam Stewart
 
 HS.model - ' visual  =~ x1 + x2 + x3
   textual =~ x4 + x5 + x6
   speed   =~ x7 + x8 + x9 '
 fit - sem(HS.model, data=HolzingerSwineford1939) summary(fit,
 fit.measures=TRUE) Lavaan (0.4-8) converged normally after 35 iterations
 
   Number of observations   301
 
   Estimator ML
   Minimum Function Chi-square   85.306
   Degrees of freedom24
   P-value0.000
 
 Chi-square test baseline model:
 
   Minimum Function Chi-square  918.852
   Degrees of freedom36
   P-value0.000
 
 Full model versus baseline model:
 
   Comparative Fit Index (CFI)0.931
   Tucker-Lewis Index (TLI)   0.896
 
 Loglikelihood and Information Criteria:
 
   Loglikelihood user model (H0)  -3737.745
   Loglikelihood unrestricted model (H1)  -3695.092
 
   Number of free parameters 21
   Akaike (AIC)7517.490
   Bayesian (BIC)  7595.339
   Sample-size adjusted Bayesian (BIC) 7528.739
 
 Root Mean Square Error of Approximation:
 
   RMSEA  0.092
   90 Percent Confidence Interval  0.071  0.114
   P-value RMSEA = 0.05  0.001
 
 Standardized Root Mean Square Residual:
 
   SRMR   0.065
 
 Parameter estimates:
 
   Information Expected
   Standard Errors Standard
 
 
Estimate  Std.err  Z-value  P(|z|) Latent variables:
   visual =~
 x11.000
 x20.5540.1005.5540.000
 x30.7290.1096.6850.000
   textual =~
 x41.000
 x51.1130.065   17.0140.000
 x60.9260.055   16.7030.000
   speed =~
 x71.000
 x81.1800.1657.1520.000
 x91.0820.1517.1550.000
 
 Covariances:
   visual ~~
 textual   0.4080.0745.5520.000
 speed 0.2620.0564.6600.000
   textual ~~
 speed 0.1730.0493.5180.000
 
 Variances:
 x10.5490.1144.8330.000
 x21.1340.102   11.1460.000
 x30.8440.0919.3170.000
 x40.3710.0487.7780.000
 x50.4460.0587.6420.000
 x60.3560.0438.2770.000
 x70.7990.0819.8230.000
 x80.4880.0746.5730.000
 x90.5660.0718.0030.000
 visual0.8090.1455.5640.000
 textual   0.9790.1128.7370.000
 speed 0.3840.0864.4510.000
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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 

[R] Autocorrelation in R

2011-06-08 Thread Iuri Gavronski
Hi,

I am trying to learn time series, and I am attending a colleague's
course on Econometrics. However, he uses e-views, and I use R. I am
trying to reproduce his examples in R, but I am having problems
specifying a AR(1) model. Would anyone help me with my code?

Thanks in advance!

Reproducible code follows:

download.file(https://sites.google.com/a/proxima.adm.br/main/ex_32.csv
--no-check-certificate, ex_32.csv, method=wget)

ex32=read.csv(ex_32.csv)

lm_ex32=lm(gc ~ yd, data=ex32)

summary(lm_ex32)

# Durbin-Watson (slide 26)
library(lmtest)

dwtest(gc ~ yd, data=ex32)
# or
dwtest(lm_ex32)

# Breusch-Godfrey
bgtest(lm_ex32, order=2)

# AR(1)

# In e-views, the specification was:
# GC = YD AR(1)
# and the output was:

# Dependent Variable: GC
# Method: Least Squares
# Sample: 1970Q2 1995Q2
# Included observations: 101
# Convergence achieved after 6 interations
# =
# Variable    Coefficient   Std.Error t-Statistic Prob.
# C           -56.99706     19.84692  -2.871835   0.0050
# YD          0.937035      0.006520  143.7170    0.
# AR(1)       0.752407      0.066565  11.30338    0.
# =
# R-squared 0.999691 Mean dependent var 2345.867
# Adjusted R-squared 0.999685 S.D. dependent var 1284.675
# S.E. of regression 22.81029 Akaike info criterion 9.121554
# Sum squared resid 50990.32 Schwarz criterion 9.199231
# Log likelihood -457.6385 F-statistic 158548.1
# Durbin-Watson stat 2.350440 Prob(F-statistic) 0.00

# following code based on
http://www.stat.pitt.edu/stoffer/tsa2/R_time_series_quick_fix.htm
# And now for some regression with autocorrelated errors.

# I've tried to follow the example in Pinheiro  Bates (2004), p.
239-244, with no success.

gc_ts = ts(ex32[66:166,gc])
yd_ts = ts(ex32[66:166,yd])

library(nlme)
trend = time(gc_ts)

fit_lm = lm(gc_ts ~ trend + yd_ts)
acf(resid(fit_lm))
pacf(resid(fit_lm))



gls_ex32_ar1 = gls(gc_ts ~ trend + yd_ts, correlation = corAR1(form=
~yd_ts),method=ML)
summary(gls_ex32_ar1)


_
Dr. Iuri Gavronski
Assistant Professor
Programa de Pós-Graduação em Administração
Universidade do Vale do Rio dos Sinos – UNISINOS
Av. Unisinos, 950 – São Leopoldo – RS – Brasil
Sala (Room) 5A 406 D
93022-000
www.unisinos.br

TEL +55-51-3591-1122 ext. 1589
FAX +55-51-3590-8447
Email: igavron...@unisinos.br

CV Lattes: http://lattes.cnpq.br/8843390959025944

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


Re: [R] Decision Trees /Decision Analysis with R?

2011-06-08 Thread Kjetil Halvorsen
see inline below.

On Wed, Jun 8, 2011 at 12:37 PM, Anupam anupa...@gmail.com wrote:
 It is difficult for someone from a statistical frame of mind to understand
 what this is about --- you need to think a bit differently. It is mostly a
 simulation and decision analysis, with some use of statistical functions to
 draw random samples to simulate the fact that outcome of interest can take
 any value from a known or unknown distribution. For example, you may be
 comparing two interventions and a do-nothing decision to improve some health
 outcome of interest. The decision maker is interested in *relative*
 effectiveness and costs of the interventions to improve the outcome of
 interest. You have results from published literature that you can use as
 inputs into a simulation exercise to compare relative costs and
 benefits/effectiveness of the three options. A small decision tree can be
 easily simulated in a spreadsheet; for long trees with many decision nodes
 it is useful to have a specialized software. There are some Excel plugins
 that are sold about $100. Others are more expensive.

 I think R is not well suited for this kind of work. A decision analysis

Not necessarily! A desicion tree model is a kind of graphical model.
See the CRAN task view gR
(graphical models in R) and maybe ask on the special interest mailing
list  R-sig-gR

kjetil

 package in R may require user to write code like the one used in LaTeX or
 related programs (Metapost) to draw graphs of trees (e.g. complicated
 organizational trees, or hierarchical trees). However, in such a package
 there can be useful outputs, measures and graphs generated by R using code
 that may already exist for other packages.

 Look up journal Medical Decision Making to know what is being discussed.
 This method is used extensively in medicine and public health to study
 decisions. It even uses MCMC, though with a different flavor --- it may even
 be a different kind of food.

 Anupam.
 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
 Behalf Of Jonathan Daily
 Sent: Wednesday, June 08, 2011 7:47 PM
 To: stefan.d...@gmail.com
 Cc: r-help@r-project.org
 Subject: Re: [R] Decision Trees /Decision Analysis with R?

 So TreeAge fits models but won't predict from them? That seems like bizarre
 behavior. I suppose I would recommend, then, looking at the source code from
 the aforementioned packages for how they store their split data. It sounds
 like you would have to write code to hack TreeAge outputs into another
 packages' format (e.g. look at ?rpart.object).

 Sorry I couldn't help more,
 Jon

 On Wed, Jun 8, 2011 at 9:47 AM, stefan.d...@gmail.com
 stefan.d...@gmail.com wrote:
 Thank you so much for reply. But I am looking for the exact opposite.

 I do not have a data set which I want to partition. But already a
 sequence/tree-like set of decision rules and with which I want to
 simulate what is my expected outcome/pay-off given a particular
 scenario.
 As far as I understand it, those packages could calculate the expected
 outcome AFTER having fit them to a particular data set and not
 construct a synthetic tree with exogenously defined decision
 nods/rules. Or am I wrong?


 Thanks and best,
 Stefan



 On Wed, Jun 8, 2011 at 2:03 PM, Jonathan Daily biomathjda...@gmail.com
 wrote:
 See packages rpart, randomForest, party.

 Also, typing R Decision Trees produced good google results.

 http://www.google.com/search?aq=fsourceid=chromeie=UTF-8q=R+Decisi
 on+Trees

 On Wed, Jun 8, 2011 at 7:02 AM, stefan.d...@gmail.com
 stefan.d...@gmail.com wrote:
 Hello,

 this question is a bit out of the blue.

 I am a big R fan and user and in my new job I do some decision
 modeling (mostly health economics). For that decision trees are
 often used (I guess the most classic example is the investment
 decision A, B, and C with different probabilities, what is the expected
 payoff).
 We use a specialized software called TreeAge that some might know.
 The basic setup of such simulations is actually very simple and I
 guess useful in many fields. So I was wondering whether there is
 already a package out there in R that is doing such a thing?

 Thanks for any hints!
 Best,
 Stefan

 PS
 (By decision tree I don't mean cluster-like analysis of a data set
 splitting by identifying decision nods, but the other way around: I
 have decision nodes, what is my expected outcome.)

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




 --
 ===
 Jon Daily
 Technician
 ===
 #!/usr/bin/env outside
 # It's great, trust me.





 --
 ===
 Jon Daily
 Technician
 

Re: [R] XML segfault on some architectures

2011-06-08 Thread Janet Young
Hi,

Our sysadmin updated libxml2 to version 2.7.8, and now xmlTreeParse works fine 
with no segfault.

Thank you very much - that was very helpful,

Janet



On Jun 8, 2011, at 11:59 AM, Janet Young wrote:

 Dear Prof Ripley,
 
 Apologies - I've re-sent that to Duncan Temple Lang, along with your note 
 about lib versions. 
 
 Version info was included in my original post - I gave full sessionInfo(). 
 It's XML_3.4-0.
 
 I only have a very sketchy understanding of libraries and systems 
 administration, but it looks like our libxml2 is version 2.6.26.  I'll ask my 
 sysadmin people whether they can update that, and try again.
 
 Janet
 
 
 
 On Jun 7, 2011, at 10:54 PM, Prof Brian Ripley wrote:
 
 On Tue, 7 Jun 2011, Janet Young wrote:
 
 Hi,
 
 I found an architecture-specific segfault problem with the XML package. I 
 originally found the problem using the parseKGML2Graph function in the 
 Bioconductor KEGGgraph package, but as far as I can tell the underlying 
 issue seems to be with the xmlTreeParse which is called by parseKGML2Graph.
 
 I'm trying this piece of code, from the xmlTreeParse help page:
 
 library(XML)
 fileName - system.file(exampleData, test.xml, package=XML)
 x - xmlTreeParse(fileName)
 
 On my Mac and on nodes of one of the linux clusters I have access to, this 
 works fine. But on another of the linux clusters I use, I get a segfault 
 every time, on both 32-bit and 64-bit nodes of the cluster.  The unames for 
 those nodes are here:
 
 Linux kong053 2.6.18-194.17.1.el5xen #1 SMP Wed Sep 29 13:30:21 EDT 2010 
 x86_64 x86_64 x86_64 GNU/Linux
 Linux king049 2.6.18-194.26.1.el5xen #1 SMP Tue Nov 9 14:13:46 EST 2010 
 i686 i686 i386 GNU/Linux
 
 I think I've included all the relevant info below, but please let me know 
 if there's anything else you'd like to see.
 
 As the posting guide says, report problems in contributed packages first to 
 the maintainer, giving the 'at a minimum' information required (which 
 includes the package version number).
 
 But note that package XML relies on libxml2, and it is entirely possible the 
 fault is in the latter.  Your kernel looks like RHEL 5 (and is an old 
 version): that is well known for having very old versions of system 
 software.  One known issue with libxml2 is a mismatch between it and zlib 
 1.2.[45] prior to libxml2 2.7.7 (2.7.8 is current): from experience, that 
 causes segfaults in package XML's examples.
 
 
 thanks,
 
 Janet
 
 ---
 
 Dr. Janet Young
 
 Fred Hutchinson Cancer Research Center
 1100 Fairview Avenue N., C3-168,
 P.O. Box 19024, Seattle, WA 98109-1024, USA.
 
 tel: (206) 667 1471 fax: (206) 667 6524
 email: jayoung  ...at...  fhcrc.org
 
 
 ---
 
 
 
 
 
 
  on 64-bit node
 
 library(XML)
 
 fileName - system.file(exampleData, test.xml, package=XML)
 
 fileName
 [1] /home/btrask/traskdata/lib_linux_64/R/library/XML/exampleData/test.xml
 
 sessionInfo()
 R version 2.13.0 (2011-04-13)
 Platform: x86_64-unknown-linux-gnu (64-bit)
 
 locale:
 [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=C  LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=en_US.UTF-8   LC_NAME=C
 [9] LC_ADDRESS=C   LC_TELEPHONE=C
 [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
 
 attached base packages:
 [1] stats graphics  grDevices utils datasets  methods   base
 
 other attached packages:
 [1] XML_3.4-0
 
 
 system(uname -a)
 Linux kong053 2.6.18-194.17.1.el5xen #1 SMP Wed Sep 29 13:30:21 EDT 2010 
 x86_64 x86_64 x86_64 GNU/Linux
 
 x - xmlTreeParse(fileName)
 
 *** caught segfault ***
 address 0x51c4f, cause 'memory not mapped'
 
 Traceback:
 1: .Call(RS_XML_ParseTree, as.character(file), handlers, 
 as.logical(ignoreBlanks), as.logical(replaceEntities), 
 as.logical(asText), as.logical(trim), as.logical(validate), 
 as.logical(getDTD), as.logical(isURL), 
 as.logical(addAttributeNamespaces), as.logical(useInternalNodes), 
 FALSE, as.logical(isSchema), as.logical(fullNamespaceInfo), 
 as.character(encoding), as.logical(useDotNames), xinclude, error, 
 addFinalizer, PACKAGE = XML)
 2: xmlTreeParse(fileName)
 
 Possible actions:
 1: abort (with core dump, if enabled)
 2: normal R exit
 3: exit R without saving workspace
 4: exit R saving workspace
 Selection:
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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)
 

[R] accessing files from subfolders

2011-06-08 Thread J
Hi,
   There must be an easy way to do this, but I'm not finding it..

I'd just like to know the syntax to move up and down folder levels, without 
necessarily entering a full file path.  Also, how to construct file and folder 
paths using variables.

For example 1, if I wanted to print to the screen the contents of a file called 
myFile.txt using the bash shell, I'd use the following:

cat ../myFile.txt

Also, for example 2, if I want to cd into a folder that contains my files, from 
within a loop, where the counter serves as one of the folders in the path.

In bash:

for i in {1..5} A B C # A, B, and C are also folder names
do
cd ~/${i} # move into (change working directory to?) my folder of interest, 
which is 1,2,3,4,5,A,B,or C
cat myFile.txt # print corresponding file of interest to screen
cd - # move back to the previous folder
done


I wonder if there's an easy corresponding way to accomplish this in R.

Any ideas most welcome!

Jonathan

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

2011-06-08 Thread James Rome
I think the issue is that the x axis is a factor. How would ggplot2 know

which ones to drop? So it labels them all.
If I do the following, the labels get better:
pp = qplot(time, error, data=times, size=I(1), geom=jitter,
main=title,
ylab=Error (min), xlab=Time before ON (min), alpha=I(1/10),
ylim=c(-30,40))
pp2 = pp + with(times, facet_wrap(~ runway, ncol=2))
+ scale_x_discrete(
breaks = c(0, 5, 10,
15,20,25,30,35,40,45,50,55,60),
labels=c(0, 5, 10,
15,20,25,30,35,40,45,50,55,60))
print(pp2 + geom_boxplot(alpha=.5, color=blue,
outlier.colour=green, outlier.size=1))

But this ruins the boxplot--I get one box instead of a box at every minute.


On 6/8/2011 3:59 PM, Ista Zahn wrote:

Hi James,
It's hard for me to see where the problem might be. Please post the
data using dput() or even better, make a simplified example that
illustrates the problem without all the other stuff going on. Chances
are that in the process of making a simplified example you will find
the problem yourself.

Best,
Ista

On Wed, Jun 8, 2011 at 3:41 PM, James Rome jamesr...@passur.com wrote:


 I actually tried that, and get the same plot if I am using it properly:

title=paste(Fitted RETA predictions for , airport,  the week of
 , date, sep=)
pp = qplot(time, error, data=times, size=I(1), geom=jitter,
 main=title,
ylab=Error (min), xlab=Time before ON (min), alpha=I(1/10),
 color=times$runway,
ylim=c(-30,40))
pp2 = pp + with(times, facet_wrap(~ runway, ncol=2))
+ scale_x_discrete(breaks = seq(from=0, to=60, by=5),
 labels=seq(from=0, to=60, by=5))
print(pp2 + geom_boxplot(alpha=.5, color=blue,
 outlier.colour=green, outlier.size=1))

 The x-axis is unchanged.

 Thanks,
 Jim
 On 6/8/2011 3:31 PM, Ista Zahn wrote:

 Hi Jim,

 See ?scale_x_discrete

 Best,
 Ista

 On Wed, Jun 8, 2011 at 3:26 PM, James Rome jamesr...@gmail.com wrote:

 I am using ggplot2 to make a boxplot that overlays a scatterplot:
 pp = qplot(time, error, data=times, size=I(1), geom=jitter, main=title,
ylab=Error (min), xlab=Time before ON (min), alpha=I(1/10),
 color=times$runway,
ylim=c(-30,40))
pp2 = pp + with(times, facet_wrap(~ runway, ncol=2))
print(pp2 + geom_boxplot(alpha=.5, color=blue,
 outlier.colour=green, outlier.size=1))
 The x variable is a factor for every minute from 0:60. My problem is
 that ggplot2 labels every factor value on the x axis, and they overlap.
 How can I make ggplot2 label only, say every 5th factor value on the x axis?

 Thanks,
 Jim

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






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


Re: [R] How to suppress factor labels

2011-06-08 Thread Ista Zahn
On Wed, Jun 8, 2011 at 5:02 PM, James Rome jamesr...@passur.com wrote:
 I think the issue is that the x axis is a factor.

Rather the opposite I think. In the data you sent, time is numeric,
not a factor. This works for me:

qplot(factor(time), error, data=times, size=I(1), geom=boxplot) +
facet_wrap(~ runway, ncol=2) +
scale_x_discrete(breaks = seq(from=0, to=60, by=10))

Best,
Ista


How would ggplot2 know
 which ones to drop? So it labels them all.
 If I do the following, the labels get better:
    pp = qplot(time, error, data=times, size=I(1), geom=jitter,
 main=title,
        ylab=Error (min), xlab=Time before ON (min), alpha=I(1/10),
        ylim=c(-30,40))
    pp2 = pp + with(times, facet_wrap(~ runway, ncol=2))
        + scale_x_discrete(
            breaks = c(0, 5, 10,
 15,20,25,30,35,40,45,50,55,60),
            labels=c(0, 5, 10,
 15,20,25,30,35,40,45,50,55,60))
    print(pp2 + geom_boxplot(alpha=.5, color=blue,
 outlier.colour=green, outlier.size=1))

 But this ruins the boxplot--I get one box instead of a box at every minute.


 On 6/8/2011 3:59 PM, Ista Zahn wrote:

 Hi James,
 It's hard for me to see where the problem might be. Please post the
 data using dput() or even better, make a simplified example that
 illustrates the problem without all the other stuff going on. Chances
 are that in the process of making a simplified example you will find
 the problem yourself.

 Best,
 Ista

 On Wed, Jun 8, 2011 at 3:41 PM, James Rome jamesr...@passur.com wrote:

 I actually tried that, and get the same plot if I am using it properly:

    title=paste(Fitted RETA predictions for , airport,  the week of
 , date, sep=)
    pp = qplot(time, error, data=times, size=I(1), geom=jitter,
 main=title,
        ylab=Error (min), xlab=Time before ON (min), alpha=I(1/10),
 color=times$runway,
        ylim=c(-30,40))
    pp2 = pp + with(times, facet_wrap(~ runway, ncol=2))
        + scale_x_discrete(breaks = seq(from=0, to=60, by=5),
 labels=seq(from=0, to=60, by=5))
    print(pp2 + geom_boxplot(alpha=.5, color=blue,
 outlier.colour=green, outlier.size=1))

 The x-axis is unchanged.

 Thanks,
 Jim
 On 6/8/2011 3:31 PM, Ista Zahn wrote:

 Hi Jim,

 See ?scale_x_discrete

 Best,
 Ista

 On Wed, Jun 8, 2011 at 3:26 PM, James Rome jamesr...@gmail.com wrote:

 I am using ggplot2 to make a boxplot that overlays a scatterplot:
 pp = qplot(time, error, data=times, size=I(1), geom=jitter, main=title,
        ylab=Error (min), xlab=Time before ON (min), alpha=I(1/10),
 color=times$runway,
        ylim=c(-30,40))
    pp2 = pp + with(times, facet_wrap(~ runway, ncol=2))
    print(pp2 + geom_boxplot(alpha=.5, color=blue,
 outlier.colour=green, outlier.size=1))
 The x variable is a factor for every minute from 0:60. My problem is
 that ggplot2 labels every factor value on the x axis, and they overlap.
 How can I make ggplot2 label only, say every 5th factor value on the x axis?

 Thanks,
 Jim

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











-- 
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org

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


Re: [R] accessing files from subfolders

2011-06-08 Thread Duncan Murdoch

On 11-06-08 5:35 PM, J wrote:

Hi,
There must be an easy way to do this, but I'm not finding it..

I'd just like to know the syntax to move up and down folder levels, without 
necessarily entering a full file path.  Also, how to construct file and folder 
paths using variables.

For example 1, if I wanted to print to the screen the contents of a file called 
myFile.txt using the bash shell, I'd use the following:

cat ../myFile.txt

Also, for example 2, if I want to cd into a folder that contains my files, from 
within a loop, where the counter serves as one of the folders in the path.

In bash:

for i in {1..5} A B C # A, B, and C are also folder names
do
cd ~/${i} # move into (change working directory to?) my folder of interest, 
which is 1,2,3,4,5,A,B,or C
cat myFile.txt # print corresponding file of interest to screen
cd - # move back to the previous folder
done


I wonder if there's an easy corresponding way to accomplish this in R.


The .. notation is supported on all platforms, as far as I know.  So to 
go to the parent of the current working dir, just use


setwd(..)

The ~ notation is not supported in all R functions, but setwd() supports 
it on all platforms, as far as I know.


Use file.path() to construct longer paths.

For your second example it would simply be setwd(file.path(~, i)).

Duncan Murdoch



Any ideas most welcome!

Jonathan

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

2011-06-08 Thread R Help
Yes, that is the difference.  For the last SEM I built I fixed the
factor variances to 1, and I think that's what I want to do for the
CFA I'm doing now.  Does that make sense for a CFA?

I'll try figuring out how to do that with lavaan later, but my model
takes so long to fit that I can't try it right now.

Thanks,
Sam

On Wed, Jun 8, 2011 at 5:58 PM, John Fox j...@mcmaster.ca wrote:
 Dear Sam,

 In each case, the first observed variable is treated as a reference
 indicator with its coefficient fixed to 1 to establish the metric of the
 corresponding factor and therefore to identify the model. If you didn't do
 the same thing (or something equivalent, such as fixing the factor variances
 to 1) in specifying the model to sem::sem(), that might account for the
 problems you encountered.

 Best,
  John

 
 John Fox
 Senator William McMaster
  Professor of Social Statistics
 Department of Sociology
 McMaster University
 Hamilton, Ontario, Canada
 http://socserv.mcmaster.ca/jfox



 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of R Help
 Sent: June-08-11 4:15 PM
 To: r-help
 Subject: [R] Results of CFA with Lavaan

 I've just found the lavaan package, and I really appreciate it, as it
 seems to succeed with models that were failing in sem::sem.  I need some
 clarification, however, in the output, and I was hoping the list could
 help me.

 I'll go with the standard example from the help documentation, as my
 problem is much larger but no more complicated than that.

 My question is, why is there one latent estimate that is set to 1 with
 no SD for each factor?  Is that normal?  When I've managed to get
 sem::sem to fit a model this has not been the case.

 Thanks,
 Sam Stewart

 HS.model - ' visual  =~ x1 + x2 + x3
               textual =~ x4 + x5 + x6
               speed   =~ x7 + x8 + x9 '
 fit - sem(HS.model, data=HolzingerSwineford1939) summary(fit,
 fit.measures=TRUE) Lavaan (0.4-8) converged normally after 35 iterations

   Number of observations                           301

   Estimator                                         ML
   Minimum Function Chi-square                   85.306
   Degrees of freedom                                24
   P-value                                        0.000

 Chi-square test baseline model:

   Minimum Function Chi-square                  918.852
   Degrees of freedom                                36
   P-value                                        0.000

 Full model versus baseline model:

   Comparative Fit Index (CFI)                    0.931
   Tucker-Lewis Index (TLI)                       0.896

 Loglikelihood and Information Criteria:

   Loglikelihood user model (H0)              -3737.745
   Loglikelihood unrestricted model (H1)      -3695.092

   Number of free parameters                         21
   Akaike (AIC)                                7517.490
   Bayesian (BIC)                              7595.339
   Sample-size adjusted Bayesian (BIC)         7528.739

 Root Mean Square Error of Approximation:

   RMSEA                                          0.092
   90 Percent Confidence Interval          0.071  0.114
   P-value RMSEA = 0.05                          0.001

 Standardized Root Mean Square Residual:

   SRMR                                           0.065

 Parameter estimates:

   Information                                 Expected
   Standard Errors                             Standard


                    Estimate  Std.err  Z-value  P(|z|) Latent variables:
   visual =~
     x1                1.000
     x2                0.554    0.100    5.554    0.000
     x3                0.729    0.109    6.685    0.000
   textual =~
     x4                1.000
     x5                1.113    0.065   17.014    0.000
     x6                0.926    0.055   16.703    0.000
   speed =~
     x7                1.000
     x8                1.180    0.165    7.152    0.000
     x9                1.082    0.151    7.155    0.000

 Covariances:
   visual ~~
     textual           0.408    0.074    5.552    0.000
     speed             0.262    0.056    4.660    0.000
   textual ~~
     speed             0.173    0.049    3.518    0.000

 Variances:
     x1                0.549    0.114    4.833    0.000
     x2                1.134    0.102   11.146    0.000
     x3                0.844    0.091 9.317 0.000
     x4                0.371    0.048    7.778    0.000
     x5                0.446    0.058    7.642    0.000
     x6                0.356    0.043    8.277    0.000
     x7                0.799    0.081    9.823    0.000
     x8                0.488    0.074    6.573    0.000
     x9                0.566    0.071    8.003    0.000
     visual            0.809    0.145    5.564    0.000
     textual           0.979    0.112    8.737    0.000
     speed             0.384    0.086    4.451    0.000

 __
 

Re: [R] Questions about building R packages

2011-06-08 Thread Duncan Murdoch

On 11-06-08 4:17 PM, Xia.Li wrote:

Hello R users,

I have difficulties when trying to make R packages. I tried to read many
tutorials but still could not find out the right way. Could any one help me
out please? (I'm using Windows xp.)


Read the Writing R Extensions manual, not the many misleading 
tutorials.  (You can read my tutorial, but don't trust any of the rest 
of them :-).


Duncan Murdoch



After running package.skeleton() and edit those RD files, I don't know how
to use Rtools (or CMD shell?) to build the zip file. I installed the Rtools
from Murdoch's link, but it doesn't look like a software...

Anyone could give me a tutorial with more details about Rtools (or CMD
shell)? I've already have MikTex installed.

Thanks!

--
View this message in context: 
http://r.789695.n4.nabble.com/Questions-about-building-R-packages-tp3583510p3583510.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.


Re: [R] accessing files from subfolders

2011-06-08 Thread Henrique Dallazuanna
Try this:

lapply(dir(myPathDir, recursive = TRUE, pattern = myFile.txt$,
full.names = TRUE), readLines, warn = FALSE)

On Wed, Jun 8, 2011 at 6:35 PM, J jonsle...@gmail.com wrote:
 Hi,
   There must be an easy way to do this, but I'm not finding it..

 I'd just like to know the syntax to move up and down folder levels, without 
 necessarily entering a full file path.  Also, how to construct file and 
 folder paths using variables.

 For example 1, if I wanted to print to the screen the contents of a file 
 called myFile.txt using the bash shell, I'd use the following:

 cat ../myFile.txt

 Also, for example 2, if I want to cd into a folder that contains my files, 
 from within a loop, where the counter serves as one of the folders in the 
 path.

 In bash:

 for i in {1..5} A B C # A, B, and C are also folder names
 do
 cd ~/${i} # move into (change working directory to?) my folder of interest, 
 which is 1,2,3,4,5,A,B,or C
 cat myFile.txt # print corresponding file of interest to screen
 cd - # move back to the previous folder
 done


 I wonder if there's an easy corresponding way to accomplish this in R.

 Any ideas most welcome!

 Jonathan

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




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

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


[R] return counts of elements on a table column depending on elements on another column

2011-06-08 Thread ads pit
Hi,
I am given the following table:
 head(hsa_refseq)
   chr   genome regionstart stop nu strand nu.1nu.2
gene_id
1 chr1 hg19_refGeneCDS 6742 6751  0  +0 gene_id
NM_032291
2 chr1 hg19_refGene   exon 66999825 6751  0  +. gene_id
NM_032291
3 chr1 hg19_refGeneCDS 67091530 67091593  0  +2 gene_id
NM_032291
4 chr1 hg19_refGene   exon 67091530 67091593  0  +. gene_id
NM_032291
5 chr1 hg19_refGeneCDS 67098753 67098777  0  +1 gene_id
NM_032291
6 chr2 hg19_refGene   exon 67098753 67098777  0  +. gene_id
NM_032291

What I've done is to find out how many of the elements on 3rd column are
CDS, exon.
sum(hsa_refseq$region==CDS)
sum(hsa_refseq$region==exon)

 But what I would like is to print for each chromosome how many are exons
and how many CDS. For example
chr1  has 5 CDS and 2 exons
chr2  has 10 CDS and 3 exons...

Can you tell what should I add? Or if I am doing this wrong, how should I do
it?

Thank you,
Regards,
Nanami

[[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 command window

2011-06-08 Thread Duncan Murdoch

On 11-06-08 9:28 AM, Michael Davidsen wrote:

Hello.

I'm a visually impaired statistician, working at the National Institute of 
Public Health in Denmark.

I would like to use R for some analysis and have succesfully installed version 
2.13.0 on my Windows XP labtop.
I then would like to run R interactively but unfortunately the textfont of the 
command line in the R window is very hard for me to read. I use a special 
program called Zoomtext that among many other functionalities enables me  to 
invert colurs.


There are two ways to run R in Windows.  One runs Rterm in a CMD window. 
 You'll need to use Windows procedures to change the font and colours 
in that window.


The other way (what is the default on the shortcut) is to run RGui.  It 
has a dialog accessed from File | GUI Preferences  that lets you choose 
fonts and colors.  (The font used in the dialog may be hard to read; if 
so, choose Save.  That will write a text file, default name Rconsole, in 
which you can edit all of the settings.  If you save it into 
RHOME/etc/Rconsole, it will be loaded each time you start R.)


Duncan Murdoch


It is possible to change the prompt (using options(...)) but I cannot see that 
it is possible to change the font - eg. and most importantly changing its color 
or size.

I have tried to check the Windows FAQ but couldn't find anything.

Is this possible? And (of course) - if yes, how?

I guess the best solution for me is to run R non-interactively because I can 
use an editor for my programs - but it is cumbersome.
Can I as a DOS command write something like
Rinput-file  output-file?

I'm very new in R so it's exciting for me to see if I have any response.

Best wishes
Michael


Michael Davidsen
National Institute of Public Health
University of Southern Denmark
Øster Farimagsgade 5A, 2.
DK-1353 Copenhagen K
Denmark

E-mail: m...@sdu.dkmailto:m...@sdu.dk
Web: www.si-folkesundhed.dkhttp://www.si-folkesundhed.dk



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

2011-06-08 Thread R Help
I think the command you want is barplot

x  = rbinom(10,15,0.65)
y = rbinom(10,15,0.25)
barplot(rbind(x,y),beside=TRUE)


Sam

On Wed, Jun 8, 2011 at 10:14 AM, nandini_bn nandini...@hotmail.com wrote:

 Hello ,
 I am trying to create a histogram in order to compare between two groups and
 would like it to be similar to the figure attached. How can I generate this
 using R ?


 Thank you,
 Nandini http://r.789695.n4.nabble.com/file/n3582448/5634-15977-1-PB.gif

 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Histogram-tp3582448p3582448.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.


Re: [R] Histogram

2011-06-08 Thread Steven Kennedy
Have a look at:
http://addictedtor.free.fr/graphiques/thumbs.php

One of the graph examples they have is exactly what you are after.


On Wed, Jun 8, 2011 at 11:14 PM, nandini_bn nandini...@hotmail.com wrote:

 Hello ,
 I am trying to create a histogram in order to compare between two groups and
 would like it to be similar to the figure attached. How can I generate this
 using R ?


 Thank you,
 Nandini http://r.789695.n4.nabble.com/file/n3582448/5634-15977-1-PB.gif

 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Histogram-tp3582448p3582448.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.


Re: [R] error with geomap in googleVis

2011-06-08 Thread Michael Phipps
SNV Krishna krishna at primps.com.sg writes:

 
 Hi All,
 
 I am unable to get the plot geomap in googleVis package. data is as follows
 
  head(index.ret)
 countryytd
 1 Argentina -10.18
 2 Australia  -3.42
 3   Austria  -2.70
 4   Belgium   1.94
 5Brazil  -7.16
 6Canada   0.56
 
  map1 = gvisGeoMap(index.ret,locationvar = 'country', numvar = 'ytd')
  plot(map1)
 
 But it just displays a blank page, showing an error symbol at the right
 bottom corner. I tried demo(googleVis), it also had a similar problem. The
 demo showed all other plots/maps except for those geomaps. Could any one
 please hint me what/where could be the problem? Many thanks for the idea and
 support. 
 
 Regards,
 
 SNV Krishna
 
   [[alternative HTML version deleted]]
 


Hi All,

I have also encountered this problem.  I have tested the problem in Windows XP
with R 2.13.0, Windows 7 with R 2.13.0, Ubuntu 11.04 32bit with R 2.13.0.  I
have latest java and flash and I have tried both Firefox and IE (both latest
versions under Windows 7).  All other plots exceot geomap in googleVis work just
fine.

I too would like to know how to solve this problem.

Kind regards,

Michael Phipps

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


Re: [R] return counts of elements on a table column depending on elements on another column

2011-06-08 Thread Martin Morgan

On 06/08/2011 03:06 PM, ads pit wrote:

Hi,
I am given the following table:

head(hsa_refseq)

chr   genome regionstart stop nu strand nu.1nu.2
gene_id
1 chr1 hg19_refGeneCDS 6742 6751  0  +0 gene_id
NM_032291
2 chr1 hg19_refGene   exon 66999825 6751  0  +. gene_id
NM_032291
3 chr1 hg19_refGeneCDS 67091530 67091593  0  +2 gene_id
NM_032291
4 chr1 hg19_refGene   exon 67091530 67091593  0  +. gene_id
NM_032291
5 chr1 hg19_refGeneCDS 67098753 67098777  0  +1 gene_id
NM_032291
6 chr2 hg19_refGene   exon 67098753 67098777  0  +. gene_id
NM_032291

What I've done is to find out how many of the elements on 3rd column are
CDS, exon.
sum(hsa_refseq$region==CDS)
sum(hsa_refseq$region==exon)

  But what I would like is to print for each chromosome how many are exons
and how many CDS. For example
chr1  has 5 CDS and 2 exons
chr2  has 10 CDS and 3 exons...

Can you tell what should I add? Or if I am doing this wrong, how should I do
it?


Hi Nanami --

xtabs(~chr + region, hsa_refseq)

might do the ticket.

Martin



Thank you,
Regards,
Nanami

[[alternative HTML version deleted]]

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



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

Location: M1-B861
Telephone: 206 667-2793

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


Re: [R] Results of CFA with Lavaan

2011-06-08 Thread John Fox
Dear Sam,

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of R Help
 Sent: June-08-11 5:57 PM
 To: John Fox
 Cc: r-help
 Subject: Re: [R] Results of CFA with Lavaan
 
 Yes, that is the difference.  For the last SEM I built I fixed the
 factor variances to 1, and I think that's what I want to do for the CFA
 I'm doing now.  Does that make sense for a CFA?

Sure -- then the factor covariances are correlations. The point is that you
have to do something to fix the metrics of the factors and identify the
model.

 
 I'll try figuring out how to do that with lavaan later, but my model
 takes so long to fit that I can't try it right now.

Maybe that should tell you something about the conditioning of the problem.

Best,
 John

 
 Thanks,
 Sam
 
 On Wed, Jun 8, 2011 at 5:58 PM, John Fox j...@mcmaster.ca wrote:
  Dear Sam,
 
  In each case, the first observed variable is treated as a reference
  indicator with its coefficient fixed to 1 to establish the metric of
  the corresponding factor and therefore to identify the model. If you
  didn't do the same thing (or something equivalent, such as fixing the
  factor variances to 1) in specifying the model to sem::sem(), that
  might account for the problems you encountered.
 
  Best,
   John
 
  
  John Fox
  Senator William McMaster
   Professor of Social Statistics
  Department of Sociology
  McMaster University
  Hamilton, Ontario, Canada
  http://socserv.mcmaster.ca/jfox
 
 
 
  -Original Message-
  From: r-help-boun...@r-project.org
  [mailto:r-help-boun...@r-project.org]
  On Behalf Of R Help
  Sent: June-08-11 4:15 PM
  To: r-help
  Subject: [R] Results of CFA with Lavaan
 
  I've just found the lavaan package, and I really appreciate it, as it
  seems to succeed with models that were failing in sem::sem.  I need
  some clarification, however, in the output, and I was hoping the list
  could help me.
 
  I'll go with the standard example from the help documentation, as my
  problem is much larger but no more complicated than that.
 
  My question is, why is there one latent estimate that is set to 1
  with no SD for each factor?  Is that normal?  When I've managed to
  get sem::sem to fit a model this has not been the case.
 
  Thanks,
  Sam Stewart
 
  HS.model - ' visual  =~ x1 + x2 + x3
                textual =~ x4 + x5 + x6
                speed   =~ x7 + x8 + x9 '
  fit - sem(HS.model, data=HolzingerSwineford1939) summary(fit,
  fit.measures=TRUE) Lavaan (0.4-8) converged normally after 35
  iterations
 
    Number of observations                           301
 
    Estimator                                         ML
    Minimum Function Chi-square                   85.306
    Degrees of freedom                                24
    P-value                                        0.000
 
  Chi-square test baseline model:
 
    Minimum Function Chi-square                  918.852
    Degrees of freedom                                36
    P-value                                        0.000
 
  Full model versus baseline model:
 
    Comparative Fit Index (CFI)                    0.931
    Tucker-Lewis Index (TLI)                       0.896
 
  Loglikelihood and Information Criteria:
 
    Loglikelihood user model (H0)              -3737.745
    Loglikelihood unrestricted model (H1)      -3695.092
 
    Number of free parameters                         21
    Akaike (AIC)                                7517.490
    Bayesian (BIC)                              7595.339
    Sample-size adjusted Bayesian (BIC)         7528.739
 
  Root Mean Square Error of Approximation:
 
    RMSEA                                          0.092
    90 Percent Confidence Interval          0.071  0.114
    P-value RMSEA = 0.05                          0.001
 
  Standardized Root Mean Square Residual:
 
    SRMR                                           0.065
 
  Parameter estimates:
 
    Information                                 Expected
    Standard Errors                             Standard
 
 
                     Estimate  Std.err  Z-value  P(|z|) Latent
 variables:
    visual =~
      x1                1.000
      x2                0.554    0.100    5.554    0.000
      x3                0.729    0.109    6.685    0.000
    textual =~
      x4                1.000
      x5                1.113    0.065   17.014    0.000
      x6                0.926    0.055   16.703    0.000
    speed =~
      x7                1.000
      x8                1.180    0.165    7.152    0.000
      x9                1.082    0.151    7.155    0.000
 
  Covariances:
    visual ~~
      textual           0.408    0.074    5.552    0.000
      speed             0.262    0.056    4.660    0.000
    textual ~~
      speed             0.173    0.049    3.518    0.000
 
  Variances:
      x1                0.549    0.114    4.833    0.000
      x2                1.134    0.102   11.146    

Re: [R] Autocorrelation in R

2011-06-08 Thread Achim Zeileis

On Wed, 8 Jun 2011, Iuri Gavronski wrote:


Hi,

I am trying to learn time series, and I am attending a colleague's
course on Econometrics. However, he uses e-views, and I use R. I am
trying to reproduce his examples in R, but I am having problems
specifying a AR(1) model. Would anyone help me with my code?

Thanks in advance!

Reproducible code follows:

download.file(https://sites.google.com/a/proxima.adm.br/main/ex_32.csv
--no-check-certificate, ex_32.csv, method=wget)

ex32=read.csv(ex_32.csv)

lm_ex32=lm(gc ~ yd, data=ex32)

summary(lm_ex32)

# Durbin-Watson (slide 26)
library(lmtest)

dwtest(gc ~ yd, data=ex32)
# or
dwtest(lm_ex32)

# Breusch-Godfrey
bgtest(lm_ex32, order=2)

# AR(1)

# In e-views, the specification was:
# GC = YD AR(1)
# and the output was:

# Dependent Variable: GC
# Method: Least Squares
# Sample: 1970Q2 1995Q2
# Included observations: 101
# Convergence achieved after 6 interations
# =
# Variable    Coefficient   Std.Error t-Statistic Prob.
# C           -56.99706     19.84692  -2.871835   0.0050
# YD          0.937035      0.006520  143.7170    0.
# AR(1)       0.752407      0.066565  11.30338    0.
# =
# R-squared 0.999691 Mean dependent var 2345.867
# Adjusted R-squared 0.999685 S.D. dependent var 1284.675
# S.E. of regression 22.81029 Akaike info criterion 9.121554
# Sum squared resid 50990.32 Schwarz criterion 9.199231
# Log likelihood -457.6385 F-statistic 158548.1
# Durbin-Watson stat 2.350440 Prob(F-statistic) 0.00


I'm not sure what exactly E-Views does here, but an ARIMAX(1,0,0) model 
estimated by least squares seems to come rather close.


## create a time series object of your data
ex32ts - ts(ex32[,-1], start = c(1954, 1), freq = 4)

## select relevant subset
ex32ts1 - window(ex32ts, start = c(1970, 2))

## fit ARIMAX(1,0,0) model
m - arima(ex32ts1[,gc], order = c(1, 0, 0),
  xreg = ex32ts1[,yd], method = CSS)

## print output, coefficient tests, etc.
m
coeftest(m)
logLik(m)

It seems to be slightly different but that can well be due to different 
fitting algorithms...


hth,
Z


# following code based on
http://www.stat.pitt.edu/stoffer/tsa2/R_time_series_quick_fix.htm
# And now for some regression with autocorrelated errors.

# I've tried to follow the example in Pinheiro  Bates (2004), p.
239-244, with no success.

gc_ts = ts(ex32[66:166,gc])
yd_ts = ts(ex32[66:166,yd])

library(nlme)
trend = time(gc_ts)

fit_lm = lm(gc_ts ~ trend + yd_ts)
acf(resid(fit_lm))
pacf(resid(fit_lm))



gls_ex32_ar1 = gls(gc_ts ~ trend + yd_ts, correlation = corAR1(form=
~yd_ts),method=ML)
summary(gls_ex32_ar1)


_
Dr. Iuri Gavronski
Assistant Professor
Programa de Pós-Graduação em Administração
Universidade do Vale do Rio dos Sinos ? UNISINOS
Av. Unisinos, 950 ? São Leopoldo ? RS ? Brasil
Sala (Room) 5A 406 D
93022-000
www.unisinos.br

TEL +55-51-3591-1122 ext. 1589
FAX +55-51-3590-8447
Email: igavron...@unisinos.br

CV Lattes: http://lattes.cnpq.br/8843390959025944

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

2011-06-08 Thread Abraham Mathew
I have a series of strings and I am trying to find all combinations and then
assign 1 or 0 to them based
on whether they contain the words car or budged. I want the data to look
like:


car  budget

 cheap car insurance quote10
   budget car insurance quote 11
   cheap auto insurance quote 00
  budget auto insurance quote 01
   cheap car insurance quotes 10
  budget car insurance quotes 10
  cheap auto insurance quotes 00
 budget auto insurance quotes 01

I've created all the possible values using the following commands,
but I wanted to know if I could automate the process whereby it would
create the string combinations and assign binary values appropriately.


roots - c(car insurance, auto insurance)
prefix - c(cheap, budget)
suffix - c(quote, quotes)

d - do.call(paste, expand.grid(prefix, roots, suffix))
df = data.frame(keyword=c(d))
df


I realize that this process can be done in two separate stages with the
stringr package,
but I'm trying to just get the thing done in one.

Do I need to combine both the functions from above and the stringr package
inside
a function? Help!

I'm using R 2.13 on Ubuntu 10.10


Abraham
WebRep
Overall rating

[[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] Error: missing values where TRUE/FALSE needed

2011-06-08 Thread Abraham Mathew
I'm writing a function and keep getting the following error message.

myfunc - function(lst) {
lst - list(roots = c(car insurance, auto insurance),
roots2 = c(insurance), prefix = c(cheap, budget),
prefix2 = c(low cost), suffix = c(quote, quotes),
suffix2 = c(rate, rates), suffix3 = c(comparison))
myone - function(x, y) {
nu - do.call(paste, expand.grid(lst$x, lst$y))
mydf - data.frame(keyword=c(nu))
}
mytwo - function(x, y, z){
mu - do.call(paste, expand.grid(lst$x, lst$y, lst$z))
mydf2 - data.frame(keyword=c(mu))
}
d1 = mytwo(lst$prefix, lst$roots, lst$suffix)
d2 = mytwo(lst$prefix, lst$roots, lst$suffix2)
d3 = mytwo(lst$prefix, lst$roots, lst$suffix3)
d4 = mytwo(lst$prefix2, lst$roots, lst$suffix)
d5 = mytwo(lst$prefix2, lst$roots, lst$suffix2)
d6 = mytwo(prefix2, roots, suffix3)
d7 = mytwo(prefix, roots2, suffix)
d8 = mytwo(prefix, roots2, suffix2)
d9 = mytwo(prefix, roots2, suffix3)
d10 = mytwo(prefix2, roots2, suffix)
d11 = mytwo(prefix2, roots2, suffix2)
d12 = mytwo(prefix2, roots2, suffix3)
d13 = myone(prefix, roots)
d14 = myone(prefix2, roots)
d15 = myone(prefix, roots2)
d16 = myone(prefix2, roots2)
d17 = myone(roots, suffix)
d18 = myone(roots, suffix2)
d19 = myone(roots, suffix3)
d20 = myone(roots2, suffix)
d21 = myone(roots2, suffix2)
d22 = myone(roots2, suffix3)
d23 = myone(state, roots)
d24 = myone(city, roots)
d25 = myone(cityst, roots)
d26 = myone(inscompany, roots)
d27 = myone(state, roots2)
d28 = myone(city, roots2)
d29 = myone(cityst, roots2)
d30 = myone(inscompany, roots2)
d31 = mytwo(state, roots, suffix)
d32 = mytwo(city, roots, suffix)
d33 = mytwo(cityst, roots, suffix)
d34 = mytwo(inscompany, roots, suffix)
d35 = mytwo(state, roots, suffix2)
d36 = mytwo(city, roots, suffix2)
d37 = mytwo(cityst, roots, suffix2)
d38 = mytwo(inscompany, roots, suffix2)
d39 = mytwo(state, roots, suffix3)
d40 = mytwo(city, roots, suffix3)
d41 = mytwo(cityst, roots, suffix3)
d42 = mytwo(inscompany, roots, suffix3)
d43 = mytwo(state, roots2, suffix)
d44 = mytwo(city, roots2, suffix)
d45 = mytwo(cityst, roots2, suffix)
d46 = mytwo(inscompany, roots2, suffix)
d47 = mytwo(state, roots2, suffix2)
d48 = mytwo(city, roots2, suffix2)
d49 = mytwo(cityst, roots2, suffix2)
d50 = mytwo(inscompany, roots2, suffix2)
d51 = mytwo(state, roots2, suffix3)
d52 = mytwo(city, roots2, suffix3)
d53 = mytwo(cityst, roots2, suffix3)
d54 = mytwo(inscompany, roots2, suffix3)
d55 = mytwo(prefix, state, roots)
d56 = mytwo(prefix, city, roots)
d57 = mytwo(prefix, cityst, roots)
d58 = mytwo(prefix, inscompany, roots)
d59 = mytwo(prefix2, state, roots)
d60 = mytwo(prefix2, city, roots)
d61 = mytwo(prefix2, cityst, roots)
d62 = mytwo(prefix2, inscompany, roots)
d63 = mytwo(prefix, state, roots2)
d64 = mytwo(prefix, city, roots2)
d65 = mytwo(prefix, cityst, roots2)
d66 = mytwo(prefix, inscompany, roots2)
d67 = mytwo(prefix2, state, roots2)
d68 = mytwo(prefix2, city, roots2)
d69 = mytwo(prefix2, cityst, roots2)
d70 = mytwo(prefix2, inscompany, roots2)
mydf - rbind(d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12, d13, d14,
d15,
d16, d17, d18, d19, d20, d21, d22, d23, d24, d25, d26, d27, d28, d29,
d30, d31, d32, d33, d34, d35, d36, d37, d38, d39, d40, d41, d42, d43,
d44, d45, d46, d47, d48, d49, d50, d51, d52, d53, d54, d55, d56, d57,
d58, d59, d60, d61, d62, d63, d64, d65, d66, d67, d68, d69, d70)
library(stringr)
inscompany_match - str_c(inscompany, collapse = |)
state_match - str_c(state, collapse = |)
city_match - str_c(city, collapse = |)
mydf$inscompany - as.numeric(str_detect(mydf$keyword, inscompany_match))
mydf$state - as.numeric(str_detect(mydf$keyword, state_match))
mydf$city - as.numeric(str_detect(mydf$keyword, city_match))
for (i in 1:nrow(mydf)) {
Words = strsplit(as.character(mydf[i, 'keyword']),  )[[1]]
if(any(Words == 'Colorado')){
if(Words[which(Words == 'Colorado') + 1] == 'Springs') mydf[i, 'state'] - 0
}
if(any(Words == 'Virginia')){
if(Words[which(Words == 'Virginia') + 1] == 'Beach') mydf[i, 'state'] - 0
}
if(any(Words == 'Oklahoma')){
if(Words[which(Words == 'Oklahoma') + 1] == 'City') mydf[i, 'state'] - 0
}
if(any(Words == 'Kansas')){
if(Words[which(Words == 'Kansas') + 1] == 'City') mydf[i, 'state'] - 0
}
if(any(Words == 'Washington')){
if(Words[which(Words == 'Washington') + 1] == 'DC') mydf[i, 'state'] - 0
}
if(any(Words == 'York')){
if(Words[which(Words == 'York') + 1] == 'City') mydf[i, 'state'] - 0
}
if(any(Words == Indianapolis)){
mydf[i, 'state'] - 0
}
if(any(Words == AARP)){
mydf[i, 'state'] - 0
}
if(any(Words == ANPAC)){
mydf[i, 'state'] - 0
}
if(any(Words == AMICA)){
mydf[i, 'state'] - 0
}
if(any(Words == GMAC)){
mydf[i, 'state'] - 0
}
if(any(Words == USAA)){
mydf[i, 'state'] - 0
}
return(mydf)
}
}


newdf - myfunc(lst)


 newdf - myfunc(lst)
Error in if (any(Words == Colorado)) { :
missing value where TRUE/FALSE needed

What's going on?

[[alternative HTML version deleted]]

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

[R] ANOVA with many IV's

2011-06-08 Thread mandakaye
I'd like to conduct one-way ANOVA's on multiple IV's. Is there a function for
aov (y~all of my IV's)? Thank you!

--
View this message in context: 
http://r.789695.n4.nabble.com/ANOVA-with-many-IV-s-tp3583788p3583788.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] Using a function inside a function

2011-06-08 Thread Abraham Mathew
I'm trying to run a function inside a function but get an error message.

lst - list(roots = c(car insurance, auto insurance),
roots2 = c(insurance), prefix = c(cheap, budget),
prefix2 = c(low cost), suffix = c(quote, quotes),
suffix2 = c(rate, rates), suffix3 = c(comparison))

myfunc - function(lst) {
  myone - function(x, y) {
nu - do.call(paste, expand.grid(x, y))
mydf - data.frame(keyword=c(nu))
}
 mytwo - function(x, y, z){
   mu - do.call(paste, expand.grid(x, y, z))
   mydf2 - data.frame(keyword=c(mu))
   }
 d1 = mytwo(lst$prefix, lst$roots, lst$suffix)
 d2 = mytwo(lst$prefix, lst$roots, lst$suffix2)
 d3 = mytwo(lst$prefix, lst$roots, lst$suffix3)
 d4 = mytwo(lst$prefix2, lst$roots, lst$suffix)
 d5 = mytwo(lst$prefix2, lst$roots, lst$suffix2)
 df = rbind(d1, d2, d3, d4, d5)
}


I get the following error message:

 newdf - myfunc(lst)
Error in expand.grid(x, y) : object 'x' not found


Can anyone help!
I'm running R 2.13 on Ubuntu 10.10


Abraham

[[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] Resources for utilizing multiple processors

2011-06-08 Thread Robin Jeffries
Hello,

I know of some various methods out there to utilize multiple processors but
am not sure what the best solution would be. First some things to note:
I'm running dependent simulations, so direct parallel coding is out
(multicore, doSnow, etc).
I'm on Windows, and don't know C. I don't plan on learning C or any of the
*nix languages.

My main concern deals with Multiple analyses on large data sets. By large I
mean that when I'm done running 2 simulations R is using ~3G of RAM, the
remaining ~3G is chewed up when I try to create the Gelman-Rubin statistic
to compare the two resulting samples, grinding the process to a halt. I'd
like to have separate cores simultaneously run each analysis. That will save
on time and I'll have to ponder the BGR calculation problem another way. Can
R temporarily use HD space to write calculations to instead of RAM?

The second concern boils down to whether or not there is a way to split up
dependent simulations. For example at iteration (t) I feed a(t-2) into FUN1
to generate a(t), then feed a(t), b(t-1) and c(t-1) into FUN2 to simulate
b(t) and c(t). I'd love to have one core run FUN1 and another run FUN2, and
better yet, a third to run all the pre-and post- processing tidbits!


So if anyone has any suggestions as to a direction I can look into, it would
be appreciated.


Robin Jeffries
MS, DrPH Candidate
Department of Biostatistics
UCLA
530-633-STAT(7828)

[[alternative HTML version deleted]]

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


Re: [R] ANOVA with many IV's

2011-06-08 Thread Dennis Murphy
Hi:

You can try something like this: assuming the factor variables of
interest and the response variable are in a data frame named df,

ivset - c(comma separated vector of factor names)
myaovs -  lapply(ivset, function(x) {
 form - as.formula(substitute(yvar ~ foo, list(foo = as.name(x
 aov(form, data = df)
   } )

This should generate a list of aov objects, one per factor in ivset.
From there, R has functions to extract pieces of output as needed.

Since no example data was presented, the above is untested, so caveat emptor.

HTH,
Dennis

On Wed, Jun 8, 2011 at 3:25 PM, mandakaye mandak...@gmail.com wrote:
 I'd like to conduct one-way ANOVA's on multiple IV's. Is there a function for
 aov (y~all of my IV's)? Thank you!

 --
 View this message in context: 
 http://r.789695.n4.nabble.com/ANOVA-with-many-IV-s-tp3583788p3583788.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.


Re: [R] Using a function inside a function

2011-06-08 Thread Joshua Wiley
Hi Abraham,

Your example runs fine for me.  I get this as the newdf object (you
should be able to copy and paste into your console):

newdf - structure(list(keyword = structure(c(7L, 3L, 5L, 1L, 8L, 4L,
6L, 2L, 15L, 11L, 13L, 9L, 16L, 12L, 14L, 10L, 20L, 18L, 19L,
17L, 23L, 21L, 24L, 22L, 27L, 25L, 28L, 26L), .Label = c(budget auto
insurance quote,
budget auto insurance quotes, budget car insurance quote,
budget car insurance quotes, cheap auto insurance quote,
cheap auto insurance quotes, cheap car insurance quote, cheap car
insurance quotes,
budget auto insurance rate, budget auto insurance rates,
budget car insurance rate, budget car insurance rates, cheap auto
insurance rate,
cheap auto insurance rates, cheap car insurance rate, cheap car
insurance rates,
budget auto insurance comparison, budget car insurance comparison,
cheap auto insurance comparison, cheap car insurance comparison,
low cost auto insurance quote, low cost auto insurance quotes,
low cost car insurance quote, low cost car insurance quotes,
low cost auto insurance rate, low cost auto insurance rates,
low cost car insurance rate, low cost car insurance rates
), class = factor)), .Names = keyword, row.names = c(NA,
28L), class = data.frame)

Try re-running the example you gave in your email in a clean R
session, perhaps.  If that does not work, you will need to provide
more information.

Cheers,

Josh

On Wed, Jun 8, 2011 at 5:43 PM, Abraham Mathew abmathe...@gmail.com wrote:
 I'm trying to run a function inside a function but get an error message.

 lst - list(roots = c(car insurance, auto insurance),
 roots2 = c(insurance), prefix = c(cheap, budget),
 prefix2 = c(low cost), suffix = c(quote, quotes),
 suffix2 = c(rate, rates), suffix3 = c(comparison))

 myfunc - function(lst) {
      myone - function(x, y) {
            nu - do.call(paste, expand.grid(x, y))
            mydf - data.frame(keyword=c(nu))
            }
     mytwo - function(x, y, z){
           mu - do.call(paste, expand.grid(x, y, z))
           mydf2 - data.frame(keyword=c(mu))
           }
     d1 = mytwo(lst$prefix, lst$roots, lst$suffix)
     d2 = mytwo(lst$prefix, lst$roots, lst$suffix2)
     d3 = mytwo(lst$prefix, lst$roots, lst$suffix3)
     d4 = mytwo(lst$prefix2, lst$roots, lst$suffix)
     d5 = mytwo(lst$prefix2, lst$roots, lst$suffix2)
     df = rbind(d1, d2, d3, d4, d5)
 }


 I get the following error message:

 newdf - myfunc(lst)
 Error in expand.grid(x, y) : object 'x' not found


 Can anyone help!
 I'm running R 2.13 on Ubuntu 10.10


 Abraham

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




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

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


Re: [R] Error: missing values where TRUE/FALSE needed

2011-06-08 Thread Joshua Wiley
Hi Abraham,

mylist - list(roots = car, prefix = cheap)
myfoo - function(x) {
  print(mylist$x)
}

myfoo(roots) ## fails, but in a sneaky way
## you actually extract variable x from mylist
## but there is no variable x (it is just NULL)
## so while no error is thrown, you get nothing

myfoo - function(x) {
  print(mylist[[x]])
}

myfoo(roots) ## still fails but...
myfoo(roots) ## works

So I would rewrite 'myone' and 'mytwo' to use: lst[[x]] and then put
the quotes around the names
mytwo(prefix, roots2, suffix) etc.

Also look at ?debug to see ways to debug your function so you can more
easily find where the problem starts rather than what the final death
blow was.  The usage is simple, just:

debug(myfunc) ## now next time myfunc() is called, it will be debugged

myfunc(lst) ## and off you go

Hope this helps,

Josh


On Wed, Jun 8, 2011 at 8:45 PM, Abraham Mathew abmathe...@gmail.com wrote:
 I'm writing a function and keep getting the following error message.

 myfunc - function(lst) {
 lst - list(roots = c(car insurance, auto insurance),
 roots2 = c(insurance), prefix = c(cheap, budget),
 prefix2 = c(low cost), suffix = c(quote, quotes),
 suffix2 = c(rate, rates), suffix3 = c(comparison))
 myone - function(x, y) {
 nu - do.call(paste, expand.grid(lst$x, lst$y))
 mydf - data.frame(keyword=c(nu))
 }
 mytwo - function(x, y, z){
 mu - do.call(paste, expand.grid(lst$x, lst$y, lst$z))
 mydf2 - data.frame(keyword=c(mu))
 }
 d1 = mytwo(lst$prefix, lst$roots, lst$suffix)
 d2 = mytwo(lst$prefix, lst$roots, lst$suffix2)
 d3 = mytwo(lst$prefix, lst$roots, lst$suffix3)
 d4 = mytwo(lst$prefix2, lst$roots, lst$suffix)
 d5 = mytwo(lst$prefix2, lst$roots, lst$suffix2)
 d6 = mytwo(prefix2, roots, suffix3)
 d7 = mytwo(prefix, roots2, suffix)
 d8 = mytwo(prefix, roots2, suffix2)
 d9 = mytwo(prefix, roots2, suffix3)
 d10 = mytwo(prefix2, roots2, suffix)
 d11 = mytwo(prefix2, roots2, suffix2)
 d12 = mytwo(prefix2, roots2, suffix3)
 d13 = myone(prefix, roots)
 d14 = myone(prefix2, roots)
 d15 = myone(prefix, roots2)
 d16 = myone(prefix2, roots2)
 d17 = myone(roots, suffix)
 d18 = myone(roots, suffix2)
 d19 = myone(roots, suffix3)
 d20 = myone(roots2, suffix)
 d21 = myone(roots2, suffix2)
 d22 = myone(roots2, suffix3)
 d23 = myone(state, roots)
 d24 = myone(city, roots)
 d25 = myone(cityst, roots)
 d26 = myone(inscompany, roots)
 d27 = myone(state, roots2)
 d28 = myone(city, roots2)
 d29 = myone(cityst, roots2)
 d30 = myone(inscompany, roots2)
 d31 = mytwo(state, roots, suffix)
 d32 = mytwo(city, roots, suffix)
 d33 = mytwo(cityst, roots, suffix)
 d34 = mytwo(inscompany, roots, suffix)
 d35 = mytwo(state, roots, suffix2)
 d36 = mytwo(city, roots, suffix2)
 d37 = mytwo(cityst, roots, suffix2)
 d38 = mytwo(inscompany, roots, suffix2)
 d39 = mytwo(state, roots, suffix3)
 d40 = mytwo(city, roots, suffix3)
 d41 = mytwo(cityst, roots, suffix3)
 d42 = mytwo(inscompany, roots, suffix3)
 d43 = mytwo(state, roots2, suffix)
 d44 = mytwo(city, roots2, suffix)
 d45 = mytwo(cityst, roots2, suffix)
 d46 = mytwo(inscompany, roots2, suffix)
 d47 = mytwo(state, roots2, suffix2)
 d48 = mytwo(city, roots2, suffix2)
 d49 = mytwo(cityst, roots2, suffix2)
 d50 = mytwo(inscompany, roots2, suffix2)
 d51 = mytwo(state, roots2, suffix3)
 d52 = mytwo(city, roots2, suffix3)
 d53 = mytwo(cityst, roots2, suffix3)
 d54 = mytwo(inscompany, roots2, suffix3)
 d55 = mytwo(prefix, state, roots)
 d56 = mytwo(prefix, city, roots)
 d57 = mytwo(prefix, cityst, roots)
 d58 = mytwo(prefix, inscompany, roots)
 d59 = mytwo(prefix2, state, roots)
 d60 = mytwo(prefix2, city, roots)
 d61 = mytwo(prefix2, cityst, roots)
 d62 = mytwo(prefix2, inscompany, roots)
 d63 = mytwo(prefix, state, roots2)
 d64 = mytwo(prefix, city, roots2)
 d65 = mytwo(prefix, cityst, roots2)
 d66 = mytwo(prefix, inscompany, roots2)
 d67 = mytwo(prefix2, state, roots2)
 d68 = mytwo(prefix2, city, roots2)
 d69 = mytwo(prefix2, cityst, roots2)
 d70 = mytwo(prefix2, inscompany, roots2)
 mydf - rbind(d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12, d13, d14,
 d15,
 d16, d17, d18, d19, d20, d21, d22, d23, d24, d25, d26, d27, d28, d29,
 d30, d31, d32, d33, d34, d35, d36, d37, d38, d39, d40, d41, d42, d43,
 d44, d45, d46, d47, d48, d49, d50, d51, d52, d53, d54, d55, d56, d57,
 d58, d59, d60, d61, d62, d63, d64, d65, d66, d67, d68, d69, d70)
 library(stringr)
 inscompany_match - str_c(inscompany, collapse = |)
 state_match - str_c(state, collapse = |)
 city_match - str_c(city, collapse = |)
 mydf$inscompany - as.numeric(str_detect(mydf$keyword, inscompany_match))
 mydf$state - as.numeric(str_detect(mydf$keyword, state_match))
 mydf$city - as.numeric(str_detect(mydf$keyword, city_match))
 for (i in 1:nrow(mydf)) {
 Words = strsplit(as.character(mydf[i, 'keyword']),  )[[1]]
 if(any(Words == 'Colorado')){
 if(Words[which(Words == 'Colorado') + 1] == 'Springs') mydf[i, 'state'] - 0
 }
 if(any(Words == 'Virginia')){
 if(Words[which(Words == 'Virginia') + 1] == 'Beach') mydf[i, 'state'] - 0
 }
 if(any(Words == 

[R] a bug in heatmap.plus?

2011-06-08 Thread Shi, Tao
Hi Allen and list,

See the code below.  I've tried it on R2.13 and R2.8.0 using either 
heatmap.plus 1.3 or the latest.  All gave the same results.  The problem is in 
the last line: when I tried to plot two different color bars, the one 
corresponding to cm.colors(10) is not correct (it starts with one black and 
one red.  Not sure where they're from?)

Any ideas?

Thanks!

...Tao


library(heatmap.plus)
set.seed(1234)

x - matrix(rnorm(400), ncol=10)
heatmap(x, ColSideColors= cm.colors(10), Colv=NA)
heatmap.plus(x, ColSideColors=cbind(cm.colors(10), cm.colors(10)), Colv=NA)
heatmap.plus(x, ColSideColors=cbind(rep(1:2,each=5), cm.colors(10)), Colv=NA)

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

2011-06-08 Thread steven mosher
I'm using package.skeleton()  windows 7, 64 bit.

When I try to specify the code_files

package_skeleton(code_files =   some directory)

I get a warning that that the connection cannot be opened and
I get a Permissions denied error.

I'm running R as admin and I've given everybody full permissions on the
folder.

What am I missing

[[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] Questions about building R packages

2011-06-08 Thread steven mosher
here  i wrote a step by step tutorial.

http://stevemosher.wordpress.com/2011/06/09/making-simple-packages-in-r-on-windows/

On Wed, Jun 8, 2011 at 1:17 PM, Xia.Li oddity...@gmail.com wrote:

 Hello R users,

 I have difficulties when trying to make R packages. I tried to read many
 tutorials but still could not find out the right way. Could any one help me
 out please? (I'm using Windows xp.)

 After running package.skeleton() and edit those RD files, I don't know how
 to use Rtools (or CMD shell?) to build the zip file. I installed the Rtools
 from Murdoch's link, but it doesn't look like a software...

 Anyone could give me a tutorial with more details about Rtools (or CMD
 shell)? I've already have MikTex installed.

 Thanks!

 --
 View this message in context:
 http://r.789695.n4.nabble.com/Questions-about-building-R-packages-tp3583510p3583510.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.


[[alternative HTML version deleted]]

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


Re: [R] ANOVA with many IV's

2011-06-08 Thread Rolf Turner


It is not nearly as complicated as Dennis Murphy makes out.

Just do

aov(y ~ ., data=X)

where X is your data frame with one column (the response) name ``y''
and then any number of other columns which will then form the
predictors (which may be either numeric predictors or factors).

cheers,

Rolf Turner

On 09/06/11 16:14, Dennis Murphy wrote:

Hi:

You can try something like this: assuming the factor variables of
interest and the response variable are in a data frame named df,

ivset- c(comma separated vector of factor names)
myaovs-  lapply(ivset, function(x) {
  form- as.formula(substitute(yvar ~ foo, list(foo = as.name(x
  aov(form, data = df)
} )

This should generate a list of aov objects, one per factor in ivset.
 From there, R has functions to extract pieces of output as needed.

Since no example data was presented, the above is untested, so caveat emptor.

HTH,
Dennis

On Wed, Jun 8, 2011 at 3:25 PM, mandakayemandak...@gmail.com  wrote:

I'd like to conduct one-way ANOVA's on multiple IV's. Is there a function for
aov (y~all of my IV's)? Thank you!

--
View this message in context: 
http://r.789695.n4.nabble.com/ANOVA-with-many-IV-s-tp3583788p3583788.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-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Histogram

2011-06-08 Thread nandini_bn

Hi Sam,This is exactly what I wanted. Could you please explain the code ? what 
does 15, 0.65 and 0.25 stand for ?Nandini


Date: Wed, 8 Jun 2011 15:16:45 -0700
From: ml-node+3583766-897200094-233...@n4.nabble.com
To: nandini...@hotmail.com
Subject: Re: Histogram



I think the command you want is barplot


x  = rbinom(10,15,0.65)

y = rbinom(10,15,0.25)

barplot(rbind(x,y),beside=TRUE)



Sam


On Wed, Jun 8, 2011 at 10:14 AM, nandini_bn [hidden email] wrote:



 Hello ,

 I am trying to create a histogram in order to compare between two groups and

 would like it to be similar to the figure attached. How can I generate this

 using R ?





 Thank you,

 Nandini http://r.789695.n4.nabble.com/file/n3582448/5634-15977-1-PB.gif


 --

 View this message in context: 
 http://r.789695.n4.nabble.com/Histogram-tp3582448p3582448.html
 Sent from the R help mailing list archive at Nabble.com.



 __

 [hidden email] mailing list

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



__

[hidden email] mailing list

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









If you reply to this email, your message will be added to the 
discussion below:
http://r.789695.n4.nabble.com/Histogram-tp3582448p3583766.html



To unsubscribe from Histogram, click here.
  

--
View this message in context: 
http://r.789695.n4.nabble.com/Histogram-tp3582448p3584425.html
Sent from the R help mailing list archive at Nabble.com.
[[alternative HTML version deleted]]

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