[R] functional data object

2013-04-30 Thread dwi Nabila
Dear Mr/ms

My name is dwi nabila. I am a postgraduate student of Statistics Department 
from University of Padjadjaran, Indonesia. Now I am at fourth semester, and I 
will write a thesis to complete my study. My adviser give me advice to write 
about FPCR. I have gcm data(x) , where there are 64 variables. the data is time 
series data. my goal is to reduce gcm data. but im still confused to change my 
data (data.frame) to functional data object.
may you give me the syntax?

 Thank you.
best regards

dwi nabilah
[[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] log returns, error

2013-04-30 Thread Irucka Embry
Hi, I could not open the file.

Can you load the data into R and then use the dput function?

The first link deals with dput. The latter 2 links are for dealing with
NAs in data.

http://www.inside-r.org/r-doc/base/dput
dput {base}

http://r.789695.n4.nabble.com/subset-without-removing-NAs-td3482011.html
R help - subset without removing NAs

http://stackoverflow.com/questions/2613420/handling-missing-incomplete-d
ata-in-r-is-there-function-to-mask-but-not-remove
Handling missing/incomplete data in R--is there function to mask but not
remove NAs? - Stack Overflow

Thank you.

Irucka



<-Original Message-> 
>From: elvina [via R] [ml-node+s789695n4665877...@n4.nabble.com]
>Sent: 4/30/2013 6:55:52 PM
>To: iruc...@mail2world.com
>Subject: Re: log returns, error
>
>Thank you for an advice! I read the answers, but I am still confused
about how to present files 
>The link is the data I use - stock price. Some of the numbers are NA,
so it says log is not meaningful for 
>factors. How can I make him not to count them? 
>http://www.file-upload.net/download-7537530/daily.csv.html
>
> 
>data <- read.csv("daily.csv", sep=",") 
>data 
>#Step 1: Daily Log Returns 
>daily_ret <- NULL 
>for (i in c(2:ncol(data))){ 
> subsample <- data[ ,i] 
> daily_ret_subsample <- diff(log(subsample)) 
> daily_ret <- cbind(daily_ret, daily_ret_subsample) 
>} 
>daily_ret <- cbind(tail(x=data[ ,1], n=nrow(daily_ret)), daily_ret) 
>colnames(daily_ret) <- colnames(data) 
>daily_ret <- as.data.frame(daily_ret) 
>daily_ret 
>  
>
>
>
>
>If you reply to this email, your message will be added to the
discussion below:
>http://r.789695.n4.nabble.com/log-returns-error-tp4665865p4665877.html 
>To unsubscribe from log returns, error, click here.
>NAML 


___Get
 the Free email that has everyone talking at http://www.mail2world.com 
target=new>http://www.mail2world.com  Unlimited 
Email Storage – POP3 – Calendar – SMS – Translator – 
Much More!
[[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] significantly different from one (not zero) using lm

2013-04-30 Thread Thomas Lumley
Or use an offset

lm( y ~ x+offset(x), data = dat)

The offset gives x a coefficient of 1, so the coefficient of x in this
model is the difference between the coefficient of x in the model without
an offset and 1 -- the thing you want.

-thomas

On Wed, May 1, 2013 at 2:54 PM, Paul Johnson  wrote:

> It is easy to construct your own test. I test against null of 0 first so I
> can be sure I match the right result from summary.lm.
>
> ## get the standard error
> seofb <- sqrt(diag(vcov(lm1)))
> ## calculate t. Replace 0 by your null
> myt <- (coef(lm1) - 0)/seofb
> mypval <- 2*pt(abs(myt), lower.tail = FALSE, df = lm1$df.residual)
>
> ## Note you can pass a vector of different nulls for the coefficients
> myt <- (coef(lm1)  - c(0,1))/seofb
>
> We could write this into a function if we wanted to get busy.  Not a bad
> little homework exercise, I think.
>
>
>
>
> > dat <- data.frame(x = rnorm(100), y = rnorm(100))
> > lm1 <- lm(y ~ x, data = dat)
> > summary(lm1)
>
> Call:
> lm(formula = y ~ x, data = dat)
>
> Residuals:
> Min  1Q  Median  3Q Max
> -3.0696 -0.5833  0.1351  0.7162  2.3229
>
> Coefficients:
>  Estimate Std. Error t value Pr(>|t|)
> (Intercept) -0.001499   0.104865  -0.0140.989
> x   -0.039324   0.113486  -0.3470.730
>
> Residual standard error: 1.024 on 98 degrees of freedom
> Multiple R-squared: 0.001224,Adjusted R-squared: -0.008968
> F-statistic: 0.1201 on 1 and 98 DF,  p-value: 0.7297
>
> > seofb <- sqrt(diag(vcov(lm1)))
> > myt <- (coef(lm1) - 0)/seofb
> > mypval <- 2*pt(abs(myt), lower.tail = FALSE, df = lm1$df.residual)
> > myt
> (Intercept)   x
> -0.01429604 -0.34650900
> > mypval
> (Intercept)   x
>   0.9886229   0.7297031
> > myt <- (coef(lm1) - 1)/seofb
> > mypval <- 2*pt(abs(myt), lower.tail = FALSE, df = lm1$df.residual)
> > myt
> (Intercept)   x
>   -9.550359   -9.158166
> > mypval
>  (Intercept)x
> 1.145542e-15 8.126553e-15
>
>
> On Tue, Apr 30, 2013 at 9:07 PM, Elaine Kuo 
> wrote:
>
> > Hello,
> >
> >
> >
> > I am work with a linear regression model:
> >
> > y=ax+b with the function of lm.
> >
> > y= observed migration distance of butterflies
> >
> > x= predicted migration distance of butterflies
> >
> >
> >
> > Usually the result will show
> >
> > if the linear term a is significantly different from zero based on the
> > p-value.
> >
> > Now I would like to test if the linear term is significantly different
> from
> > one.
> >
> > (because I want to know if the regression line (y=ax+b) is significantly
> > from the line with the linear term =1 and the intercept =0)
> >
> >
> >
> > Please kindly advise if it is possible
> >
> > to adjust some default parameters in the function to achieve the goal.
> >
> > Thank you.
> >
> >
> > Elaine
> >
> > [[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.
> >
>
>
>
> --
> Paul E. Johnson
> Professor, Political Science  Assoc. Director
> 1541 Lilac Lane, Room 504  Center for Research Methods
> University of Kansas University of Kansas
> http://pj.freefaculty.org   http://quant.ku.edu
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Thomas Lumley
Professor of Biostatistics
University of Auckland

[[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] significantly different from one (not zero) using lm

2013-04-30 Thread Paul Johnson
It is easy to construct your own test. I test against null of 0 first so I
can be sure I match the right result from summary.lm.

## get the standard error
seofb <- sqrt(diag(vcov(lm1)))
## calculate t. Replace 0 by your null
myt <- (coef(lm1) - 0)/seofb
mypval <- 2*pt(abs(myt), lower.tail = FALSE, df = lm1$df.residual)

## Note you can pass a vector of different nulls for the coefficients
myt <- (coef(lm1)  - c(0,1))/seofb

We could write this into a function if we wanted to get busy.  Not a bad
little homework exercise, I think.




> dat <- data.frame(x = rnorm(100), y = rnorm(100))
> lm1 <- lm(y ~ x, data = dat)
> summary(lm1)

Call:
lm(formula = y ~ x, data = dat)

Residuals:
Min  1Q  Median  3Q Max
-3.0696 -0.5833  0.1351  0.7162  2.3229

Coefficients:
 Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.001499   0.104865  -0.0140.989
x   -0.039324   0.113486  -0.3470.730

Residual standard error: 1.024 on 98 degrees of freedom
Multiple R-squared: 0.001224,Adjusted R-squared: -0.008968
F-statistic: 0.1201 on 1 and 98 DF,  p-value: 0.7297

> seofb <- sqrt(diag(vcov(lm1)))
> myt <- (coef(lm1) - 0)/seofb
> mypval <- 2*pt(abs(myt), lower.tail = FALSE, df = lm1$df.residual)
> myt
(Intercept)   x
-0.01429604 -0.34650900
> mypval
(Intercept)   x
  0.9886229   0.7297031
> myt <- (coef(lm1) - 1)/seofb
> mypval <- 2*pt(abs(myt), lower.tail = FALSE, df = lm1$df.residual)
> myt
(Intercept)   x
  -9.550359   -9.158166
> mypval
 (Intercept)x
1.145542e-15 8.126553e-15


On Tue, Apr 30, 2013 at 9:07 PM, Elaine Kuo  wrote:

> Hello,
>
>
>
> I am work with a linear regression model:
>
> y=ax+b with the function of lm.
>
> y= observed migration distance of butterflies
>
> x= predicted migration distance of butterflies
>
>
>
> Usually the result will show
>
> if the linear term a is significantly different from zero based on the
> p-value.
>
> Now I would like to test if the linear term is significantly different from
> one.
>
> (because I want to know if the regression line (y=ax+b) is significantly
> from the line with the linear term =1 and the intercept =0)
>
>
>
> Please kindly advise if it is possible
>
> to adjust some default parameters in the function to achieve the goal.
>
> Thank you.
>
>
> Elaine
>
> [[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.
>



-- 
Paul E. Johnson
Professor, Political Science  Assoc. Director
1541 Lilac Lane, Room 504  Center for Research Methods
University of Kansas University of Kansas
http://pj.freefaculty.org   http://quant.ku.edu

[[alternative HTML version deleted]]

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


[R] Trouble with methods() after loading gdata package.

2013-04-30 Thread Paul Johnson
Greetings to r-help land.

I've run into some program crashes and I've traced them back to methods()
behavior
after the package gdata is loaded.  I provide now a minimal re-producible
example. This seems bugish to me. How about you?

dat <- data.frame(x = rnorm(100), y = rnorm(100))
lm1 <- lm(y ~ x, data = dat)

methods(class = "lm")

## OK so far

library(gdata)
methods(class = "lm")
## epic fail



## OUTPUT.

> dat <- data.frame(x = rnorm(100), y = rnorm(100))
> lm1 <- lm(y ~ x, data = dat)
>
> methods(class = "lm")
 [1] add1.lm*   alias.lm*  anova.lm   case.names.lm*
 [5] confint.lm*cooks.distance.lm* deviance.lm*   dfbeta.lm*
 [9] dfbetas.lm*drop1.lm*  dummy.coef.lm* effects.lm*
[13] extractAIC.lm* family.lm* formula.lm*hatvalues.lm
[17] influence.lm*  kappa.lm   labels.lm* logLik.lm*
[21] model.frame.lm model.matrix.lmnobs.lm*   plot.lm
[25] predict.lm print.lm   proj.lm*   qr.lm*
[29] residuals.lm   rstandard.lm   rstudent.lmsimulate.lm*
[33] summary.lm variable.names.lm* vcov.lm*

   Non-visible functions are asterisked
>
> library(gdata)
gdata: read.xls support for 'XLS' (Excel 97-2004) files ENABLED.

gdata: read.xls support for 'XLSX' (Excel 2007+) files ENABLED.

Attaching package: ‘gdata’

The following object is masked from ‘package:stats’:

nobs

The following object is masked from ‘package:utils’:

object.size

> methods(class = "lm")
Error in data.frame(visible = rep.int(FALSE, n2), from = rep.int(msg,  :
  duplicate row.names: nobs.lm

> sessionInfo()
R version 3.0.0 (2013-04-03)
Platform: x86_64-pc-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=en_US.UTF-8LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=C 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] gdata_2.12.0.2

loaded via a namespace (and not attached):
[1] gtools_2.7.1 tcltk_3.0.0  tools_3.0.0


gdata is one of my favorite packages, its worth the effort to get to the
bottom of this.

--
Paul E. Johnson
Professor, Political Science  Assoc. Director
1541 Lilac Lane, Room 504  Center for Research Methods
University of Kansas University of Kansas
http://pj.freefaculty.org   http://quant.ku.edu

[[alternative HTML version deleted]]

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


[R] significantly different from one (not zero) using lm

2013-04-30 Thread Elaine Kuo
Hello,



I am work with a linear regression model:

y=ax+b with the function of lm.

y= observed migration distance of butterflies

x= predicted migration distance of butterflies



Usually the result will show

if the linear term a is significantly different from zero based on the
p-value.

Now I would like to test if the linear term is significantly different from
one.

(because I want to know if the regression line (y=ax+b) is significantly
from the line with the linear term =1 and the intercept =0)



Please kindly advise if it is possible

to adjust some default parameters in the function to achieve the goal.

Thank you.


Elaine

[[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 understanding hierarchical clustering

2013-04-30 Thread epi
Hi All,

i've problem to understand how to work with R to generate a hierarchical 
clustering
my data are in a csv and looks like :

idcode,count,temp,sal,depth_m,subs
16001,136,4.308,32.828,63.46,47
16001,109,4.31,32.829,63.09,49
16001,107,4.302,32.822,62.54,47
16001,87,4.318,32.834,62.54,48
16002,82,4.312,32.832,63.28,49
16002,77,4.325,32.828,65.65,46
16002,77,4.302,32.821,62.36,47
16002,71,4.299,32.832,65.84,37
16002,70,4.302,32.821,62.54,49

where idcode is a specie identification number
and the other fields are environmental parameters.

library(vegan)
mat<-read.csv("http://epi.whoi.edu/ipython/results/mdistefano/pg_site1.csv",header=T)
dd <- mat[!is.na(mat$idcode) &
  !is.na(mat$temp) &
  !is.na(mat$sal) &
  !is.na(mat$count) &
  !is.na(mat$count) &
  !is.na(mat$subs),]
distmat<-vegdist(dd)
clusa<-hclust(distmat,"average")
print(clusa)
Call:
hclust(d = distmat, method = "average")

Cluster method   : average 
Distance : bray 
Number of objects: 8036 
print(dend1 <- as.dendrogram(clusa))
'dendrogram' with 2 branches and 8036 members total, at height 
0.3194225 
dend2 <- cut(dend1, h=0.07)


a complete run with plots is available here :  

http://nbviewer.ipython.org/5492912

i'm trying try to group together the species (idcode's) that are sharing 
similar environmental parameters

like (looking at the plots) i should be able to retrieve the list of idcode for 
each branch at "cut-level" X

in the example :  


X = 0.07 

branches1 : [idcodeA, .. .. ,idcodeJ]
..
..
branche6 : [idcodeB, .. .. , idcodeK]



Many thanks for your precious help!!!

Massimo.



[[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] Trouble with reading xml in R

2013-04-30 Thread Barry Rowlingson
On Tue, Apr 30, 2013 at 5:12 PM, Dorte Klerke  wrote:
>
>  Hi I have been trying for days now to read the contents of this xml file into
> R. I tried the simpler solution xmlToDataFrame, which worked on another
> file, but somehow it doesn't work for this file.

>
> How is this possible?

 How is this possible without sending us the file? EFORGOTATTACHMENT?

>
> Also an extra question. My filename is called something like (a new file
> every day)
>
> BidAskCurves_DE-AU_20130425_20130424130349.xml
>
> The first part after the "AU" is the current date, this I can generate
> automacticly but I can't generate the last since its the date, time, minute
> and second of the time the data was uploaded from another party to their ftp
> - where I'm getting the data.
>
> Is there anyway to get R to find the right file, when I can only generate
> part of the file?

 The dir() function has a pattern argument, so you can do:

dir("/myfolder",pattern="BidAskCurves_DE-AU_20130425_[0-9]*.xml") # untested

to list all files that match that pattern in that folder.

the pattern is a 'regular expression', so you might have to
backslashify special characters, but - and _ aren't special.

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.


Re: [R] still about biplot for principal componens analysis

2013-04-30 Thread capricy gao
Looks like my post might get some problems, so I re-wrote my question plus some 
new one...



I noticed that the points on the biplot are not exactly the same as the 
predicted values.

Another relevant question: should I expect that all the vector points have the 
same length if  chose parameters of "cor=T ",
for example, pca2=princomp((data), cor=T)?


Could any body give me a  hint about  any of these questions?

Thanks.





To: Jim Lemon  
Cc: "r-help@r-project.org"  
Sent: Tuesday, April 30, 2013 9:51 AM
Subject: Re: [R] biplot for principal componens analysis




very helpful!! Thanks a lot.



From: Jim Lemon 

Cc: "r-help@r-project.org"  
Sent: Monday, April 29, 2013 6:53 PM
Subject: Re: [R] biplot for principal componens analysis


On 04/30/2013 08:24 AM, capricy gao wrote:
>
>
> I did a PCA for my data which has a dimension of 19000X4 using princomp
>> pca2=princomp((data), cor=F)
>
>
>
>
>
> and obtained a biplot with 19000 labels which were very busy. How can I just 
> show 19000 spot w/o labels?
>> biplot(pca2)
>
Hi capricy,
I suppose you could try:

biplot(pca2,xlabs=rep(".",19000))

Jim
    [[alternative HTML version
 deleted]]

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

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


Re: [R] Line similarity

2013-04-30 Thread arun
Hi,
You could also do:
v<- read.table(text="
Name Year_1_value Year_2_value Year_3_value
A 1 2 3
B 2 7 19
C 3 4 2
D 10 7 6
E 4 4 5
F NA 3 6
",sep="",header=TRUE,stringsAsFactors=FALSE)
names(v)[-1]<-gsub("(.*\\d+)_.*$","\\1",names(v)[-1])
v2<- v


v1<-reshape(v,direction="long",varying=2:4,sep="_")
v$Beta<-sapply(split(v1,v1$Name),function(x) coef(lm(Year~time,data=x))[2])

v$Growing<- v$Beta>0
 v
#  Name Year_1 Year_2 Year_3 Beta Growing
#1    A  1  2  3  1.0    TRUE
#2    B  2  7 19  8.5    TRUE
#3    C  3  4  2 -0.5   FALSE
#4    D 10  7  6 -2.0   FALSE
#5    E  4  4  5  0.5    TRUE
#6    F NA  3  6  3.0    TRUE

#or
library(plyr)
v2$Beta<- ldply(dlply(v1,.(Name),lm, formula=Year~time),coef)[,3]
v2$Growing<- v2$Beta>0
 identical(v,v2)
#[1] TRUE


A.K.



- Original Message -
From: "Satsangi, Vivek (GE Capital)" 
To: "r-help@r-project.org" 
Cc: 
Sent: Tuesday, April 30, 2013 3:57 PM
Subject: [R] Line similarity

Folks,

                This is probably a "help me google this properly, please"-type 
of question.

                In TIBCO Spotfire, there is a procedure called "line 
similarity". I use this to determine which observations show a growing, stable 
or declining pattern... sort of like a mini-regression on the time-line for 
each observation.

                So of the input is something like this:

Name Year_1_value Year_2_value Year_3_value
A 1 2 3
B 2 7 19
C 3 4 2
D 10 7 6
E 4 4 5
F NA 3 6

Then the desired output is as follows:
A Growing
B Growing
C Stable
D Declining
E Stable
F Growing (or NA is also fine)

                The data can also be unstacked, i.e. the three years could be 
separate rows if necessary.
                Is there a package for R that implements something like the 
above? I can obviously try do a set of simple regressions to classify the rows, 
but I want to gain from the thoughts and learnings of others who may have taken 
the time to implement a package.
                I tried searching with the words "line similarity" or its 
variants to no avail.

                Thanks in advance for your pointers!

Vivek Satsangi
GE Capital
Americas


    [[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] Line similarity

2013-04-30 Thread Bert Gunter
1. Read "an Introduction to R" or other R tutorial to learn how R works.

2. You apparently wish to apply a function, f, to each row of a data
frame or matrix to classify it as growing, declining, etc. Only you
know what that function should look like. Write it.

3. Apply it using ?apply or perhaps the functionality of the plyR
package. There could be other ways to do it depending on what data
structure you use for your data. That is why you need to do some self
study.

?bert





On Tue, Apr 30, 2013 at 12:57 PM, Satsangi, Vivek (GE Capital)
 wrote:
> Folks,
>
> This is probably a "help me google this properly, 
> please"-type of question.
>
> In TIBCO Spotfire, there is a procedure called "line 
> similarity". I use this to determine which observations show a growing, 
> stable or declining pattern... sort of like a mini-regression on the 
> time-line for each observation.
>
> So of the input is something like this:
>
> Name Year_1_value Year_2_value Year_3_value
> A 1 2 3
> B 2 7 19
> C 3 4 2
> D 10 7 6
> E 4 4 5
> F NA 3 6
>
> Then the desired output is as follows:
> A Growing
> B Growing
> C Stable
> D Declining
> E Stable
> F Growing (or NA is also fine)
>
> The data can also be unstacked, i.e. the three years could be 
> separate rows if necessary.
> Is there a package for R that implements something like the 
> above? I can obviously try do a set of simple regressions to classify the 
> rows, but I want to gain from the thoughts and learnings of others who may 
> have taken the time to implement a package.
> I tried searching with the words "line similarity" or its 
> variants to no avail.
>
> Thanks in advance for your pointers!
>
> Vivek Satsangi
> GE Capital
> Americas
>
>
> [[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.



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

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


Re: [R] Line similarity

2013-04-30 Thread William Dunlap
Here is one way to, for each row in the data.frame v, regress the numbers in
columns 2 through 4 on the numbers 1 through 3, storing only the slopes, and
then creating a column saying if the slope is greater than zero or not.

> v[,"Beta"] <- vapply(seq_len(nrow(v)),
FUN=function(i)coef(lm(value~year, 
data=data.frame(value=as.numeric(v[i,2:4]), year=seq_len(3[2],
FUN.VALUE=0)
> v[,"Growing"] <- v[,"Beta"] > 0
> v
  Name Year_1_value Year_2_value Year_3_value Beta Growing
1A123  1.0TRUE
2B27   19  8.5TRUE
3C342 -0.5   FALSE
4D   1076 -2.0   FALSE
5E445  0.5TRUE
6F   NA36  3.0TRUE

Since you are doing least-squares regression in which the predictors are the
same for all regressions (expect the one with the NA in it) you can also do
> coef(lm(value ~ year, list(value=t(as.matrix(v[1:5,2:4])), 
> year=seq_len(3[2,]
   12345 
 1.0  8.5 -0.5 -2.0  0.5
but you have to then make a special case for each pattern of missing values.

If you always use a 3-consecutive-year period you can use
   Growing <- v[,"Year_1_value"] < v[, "Year_3_value"]

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
> Behalf
> Of Satsangi, Vivek (GE Capital)
> Sent: Tuesday, April 30, 2013 12:57 PM
> To: r-help@r-project.org
> Subject: [R] Line similarity
> 
> Folks,
> 
> This is probably a "help me google this properly, 
> please"-type of question.
> 
> In TIBCO Spotfire, there is a procedure called "line 
> similarity". I use this to
> determine which observations show a growing, stable or declining pattern... 
> sort of like a
> mini-regression on the time-line for each observation.
> 
> So of the input is something like this:
> 
> Name Year_1_value Year_2_value Year_3_value
> A 1 2 3
> B 2 7 19
> C 3 4 2
> D 10 7 6
> E 4 4 5
> F NA 3 6
> 
> Then the desired output is as follows:
> A Growing
> B Growing
> C Stable
> D Declining
> E Stable
> F Growing (or NA is also fine)
> 
> The data can also be unstacked, i.e. the three years could be 
> separate rows if
> necessary.
> Is there a package for R that implements something like the 
> above? I can
> obviously try do a set of simple regressions to classify the rows, but I want 
> to gain from
> the thoughts and learnings of others who may have taken the time to implement 
> a
> package.
> I tried searching with the words "line similarity" or its 
> variants to no avail.
> 
> Thanks in advance for your pointers!
> 
> Vivek Satsangi
> GE Capital
> Americas
> 
> 
>   [[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] Line similarity

2013-04-30 Thread Satsangi, Vivek (GE Capital)
Folks,

This is probably a "help me google this properly, please"-type 
of question.

In TIBCO Spotfire, there is a procedure called "line 
similarity". I use this to determine which observations show a growing, stable 
or declining pattern... sort of like a mini-regression on the time-line for 
each observation.

So of the input is something like this:

Name Year_1_value Year_2_value Year_3_value
A 1 2 3
B 2 7 19
C 3 4 2
D 10 7 6
E 4 4 5
F NA 3 6

Then the desired output is as follows:
A Growing
B Growing
C Stable
D Declining
E Stable
F Growing (or NA is also fine)

The data can also be unstacked, i.e. the three years could be 
separate rows if necessary.
Is there a package for R that implements something like the 
above? I can obviously try do a set of simple regressions to classify the rows, 
but I want to gain from the thoughts and learnings of others who may have taken 
the time to implement a package.
I tried searching with the words "line similarity" or its 
variants to no avail.

Thanks in advance for your pointers!

Vivek Satsangi
GE Capital
Americas


[[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] Quote as element of a vector/list

2013-04-30 Thread Peter Alspach
Tena koe Jie

Try

x <- ' 12"ab"34 '
plot(1:10, xlab=x)

HTH ...

Peter Alspach

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Jie
Sent: Wednesday, 1 May 2013 6:46 a.m.
To: r-help@r-project.org
Subject: [R] Quote as element of a vector/list

Dear All,

I would like to store quote as part of an vector.
For instance, I would like to get an character object as x = " 12"ab"34 "
or
y = c("1", "2", """, "a", "b", """, "3", "4")

Is that possible? Thank you.

Best wishes,
Jie

[[alternative HTML version deleted]]

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

The contents of this e-mail are confidential and may be ...{{dropped:14}}

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


Re: [R] select and do some calculations/manipulations on certain rows based on conditions in R

2013-04-30 Thread arun


Hi,
Try this:
dat1<-read.table(text="
    ID X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15
1   5184    0    0    1    0    0   0   0    0    0    1 0  0  0
  0  0  0
2   6884    0    0    1    0    0   1   0    0    0    0 0  0  0
  0  0  0
3   6884    0    0    1    0    0   0   0    0    0    0 0  0  0
  0  0  0
4   6884    0    0    0    0    0   1   0    0    0    0 0  0  0
  0  0  0
5  11329   0    0    0    0    0   1   0    0    0    0 0  0  0 
 0  0  0
6  11329   0    0    1    0    0   1   0    0    0    0 0  0  0 
 0  0  0
7  11340   0    0    1    0    0   1   0    0    0    0 0  0  0 
 0  0  0 
",sep="",header=TRUE)

 dat1$y<-unsplit(lapply(split(dat1,dat1$ID),function(x) 
sapply(seq_len(nrow(x)),function(i) 
{x1<-na.omit(x[i:(i+1),]);1*any(colSums(x1[,-1])==2)})),dat1$ID)
 dat1
# ID X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 y
#1  5184  0  0  1  0  0  0  0  0  0  1   0   0   0   0   0   0 0
#2  6884  0  0  1  0  0  1  0  0  0  0   0   0   0   0   0   0 1
#3  6884  0  0  1  0  0  0  0  0  0  0   0   0   0   0   0   0 0
#4  6884  0  0  0  0  0  1  0  0  0  0   0   0   0   0   0   0 0
#5 11329  0  0  0  0  0  1  0  0  0  0   0   0   0   0   0   0 1
#6 11329  0  0  1  0  0  1  0  0  0  0   0   0   0   0   0   0 0
#7 11340  0  0  1  0  0  1  0  0  0  0   0   0   0   0   0   0 0

A.K.

From: Thu Pham 
To: arun  
Sent: Tuesday, April 30, 2013 3:13 PM
Subject: Re: select and do some calculations/manipulations on certain rows 
based on conditions in R



Hi,

The column for y would be 
y

0
1
0
0
1
0
0




On Tue, Apr 30, 2013 at 3:10 PM, arun  wrote:


>
>
>HI,
>Just a doubt:
>Suppose the data is this:
>
>
>dat1<-read.table(text="
>    ID X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15
>1   5184    0    0    1    0    0   0   0    0    0    1 0  0  0   
>   0  0  0
>2   6884    0    0    1    0    0   1   0    0    0    0 0  0  0   
>   0  0  0
>3   6884    0    0    1    0    0   0   0    0    0    0 0  0  0   
>   0  0  0
>
>4   6884    0    0    0    0    0   1   0    0    0    0 0  0  0   
>   0  0  0
>5  11329   0    0    0    0    0   1   0    0    0    0 0  0  0
>  0  0  0
>6  11329   0    0    1    0    0   1   0    0    0    0 0  0  0
>  0  0  0
>7  11340   0    0    1    0    0   1   0    0    0    0 0  0  0
>  0  0  0
>",sep="",header=TRUE)
>
>
>Then, could you confirm the y column values for this:
>
>
>
>
>
>From: Thu Pham 
>To: arun 
>Sent: Tuesday, April 30, 2013 2:31 PM
>
>Subject: Re: select and do some calculations/manipulations on certain rows 
>based on conditions in R
>
>
>
>Hello,
>
>Thanks so much for your help. However, I would expect on the second line for 
>ID 6884, y should be 0 because the ID change.
>
>
>For ID 11329, it is shown as I expected: the first observation for Y=1 because 
>one of x's remain 1 going from one observation to the next. Also y=0 for  the 
>last observation of the same ID because no observation follows that.
>
>
>I'm very new to R and I have trouble interpret your code. Perhaps if I 
>understand what you did, I can fix it.
>
>P/S: there is only 0 or 1 value for the X's variables
>
>
>
>
>On Thu, Apr 18, 2013 at 3:09 PM, arun  wrote:
>
>Hi,
>>May be this helps (Assuming that there are only '0's and '1's in the dataset)
>>
>>dat1<-read.table(text="
>>
>>    ID X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15
>>1   5184    0    0    0    0    0   0   0    0    0    1 0  0  0  
>>    0  0  0
>>2   6884    0    0    1    0    0   1   0    0    0    0 0  0  0  
>>    0  0  0
>>3  11329   0    0    0    0    0   1   0    0    0    0 0  0  0   
>>   0  0  0
>>4  11329   0    0    1    0    0   1   0    0    0    0 0  0  0   
>>   0  0  0
>>",sep="",header=TRUE)
>>dat1$y<-sapply(seq_len(nrow(dat1)),function(i) {x1<-na.omit(dat1[i:(i+1),]); 
>>1*any(colSums(x1[,-1])==2)})
>> dat1
>># ID X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 y
>>#1  5184  0  0  0  0  0  0  0  0  0  1   0   0   0   0   0   0 0
>>#2  6884  0  0  1  0  0  1  0  0  0  0   0   0   0   0   0   0 1
>>#3 11329  0  0  0  0  0  1  0  0  0  0   0   0   0   0   0   0 1
>>#4 11329  0  0  1  0  0  1  0  0  0  0   0   0   0   0   0   0 0
>>A.K.
>>
>>
>>
>>
>> From: Thu Pham 
>>To: smartpink...@yahoo.com
>>Sent: Thursday, April 18, 2013 2:57 PM
>>Subject: Re: select and do some calculations/manipulations on certain rows 
>>based on conditions in R
>>
>>
>>
>>
>>Hi,
>>
>>Thank you for the response. You're absolutely right.
>>
>>I'm trying to see if any of the 

Re: [R] Quote as element of a vector/list

2013-04-30 Thread arun
 y = c("1", "2", '"', "a", "b", '"', "3", "4")
 y
#[1] "1"  "2"  "\"" "a"  "b"  "\"" "3"  "4" 




A.K.



- Original Message -
From: Jie 
To: "r-help@r-project.org" 
Cc: 
Sent: Tuesday, April 30, 2013 2:46 PM
Subject: [R]  Quote as element of a vector/list

Dear All,

I would like to store quote as part of an vector.
For instance, I would like to get an character object as
x = " 12"ab"34 "
or
y = c("1", "2", """, "a", "b", """, "3", "4")

Is that possible? Thank you.

Best wishes,
Jie

    [[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] Quote as element of a vector/list

2013-04-30 Thread Jie
Dear All,

I would like to store quote as part of an vector.
For instance, I would like to get an character object as
x = " 12"ab"34 "
or
y = c("1", "2", """, "a", "b", """, "3", "4")

Is that possible? Thank you.

Best wishes,
Jie

[[alternative HTML version deleted]]

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


Re: [R] Error message

2013-04-30 Thread Bert Gunter
Another alternative might be to post the the r-sig-mixed-models list
gls() is part of nlme.

-- Bert

On Tue, Apr 30, 2013 at 11:12 AM, Bert Gunter  wrote:
> Actually, Jeff, it may not be.
>
> The OP has likely overfit -- as a guess,  Depth is essentially
> continuous and as.factor() produces too many levels. I would recommend
> that the OP find a local statistical consultant to help him, as he
> seems out of his depth, statistically. Failing that, he should
> probably post to a statistical list like stats.stackexchange.com and
> ask for statistical counsel there.
>
> -- Bert
>
> On Tue, Apr 30, 2013 at 8:59 AM, Jeff Newmiller
>  wrote:
>> That is unlikely in the absence of a reproducible example [1].
>>
>> [1] 
>> http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
>> ---
>> Jeff NewmillerThe .   .  Go Live...
>> DCN:Basics: ##.#.   ##.#.  Live Go...
>>   Live:   OO#.. Dead: OO#..  Playing
>> Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
>> /Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
>> ---
>> Sent from my phone. Please excuse my brevity.
>>
>> "Havenga, BS, Mnr <15264...@sun.ac.za>" <15264...@sun.ac.za> wrote:
>>
>>>Hi there
>>>
>>>I am a Masters student at the University of Stellenbosch. I have been
>>>using R to analyze the data, using the GLS model, of one of my
>>>experiments.
>>>The problem that I am having is that whenever I run my model using:
>>>fit.glsmodel1<-gls(Number~as.factor(Season)+as.factor(Depth)+as.factor(Orientation),
>>>data=Number, weights=varPower(), method="ML")
>>>
>>>I get the error:
>>>Error in glsEstimate(object, control = control) :computed "gls" fit
>>>is singular, rank 8
>>>
>>>I would like to know if anyone can tell me what is causing this error.
>>>Any advice will be much appreciated.
>>>
>>>Kind regards
>>>Brendan
>>>
>>>   [[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.
>
>
>
> --
>
> Bert Gunter
> Genentech Nonclinical Biostatistics
>
> Internal Contact Info:
> Phone: 467-7374
> Website:
> http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

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

2013-04-30 Thread Bert Gunter
Actually, Jeff, it may not be.

The OP has likely overfit -- as a guess,  Depth is essentially
continuous and as.factor() produces too many levels. I would recommend
that the OP find a local statistical consultant to help him, as he
seems out of his depth, statistically. Failing that, he should
probably post to a statistical list like stats.stackexchange.com and
ask for statistical counsel there.

-- Bert

On Tue, Apr 30, 2013 at 8:59 AM, Jeff Newmiller
 wrote:
> That is unlikely in the absence of a reproducible example [1].
>
> [1] 
> http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
> ---
> Jeff NewmillerThe .   .  Go Live...
> DCN:Basics: ##.#.   ##.#.  Live Go...
>   Live:   OO#.. Dead: OO#..  Playing
> Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
> /Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
> ---
> Sent from my phone. Please excuse my brevity.
>
> "Havenga, BS, Mnr <15264...@sun.ac.za>" <15264...@sun.ac.za> wrote:
>
>>Hi there
>>
>>I am a Masters student at the University of Stellenbosch. I have been
>>using R to analyze the data, using the GLS model, of one of my
>>experiments.
>>The problem that I am having is that whenever I run my model using:
>>fit.glsmodel1<-gls(Number~as.factor(Season)+as.factor(Depth)+as.factor(Orientation),
>>data=Number, weights=varPower(), method="ML")
>>
>>I get the error:
>>Error in glsEstimate(object, control = control) :computed "gls" fit
>>is singular, rank 8
>>
>>I would like to know if anyone can tell me what is causing this error.
>>Any advice will be much appreciated.
>>
>>Kind regards
>>Brendan
>>
>>   [[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.



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

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

2013-04-30 Thread Dorte Klerke

 Hi I have been trying for days now to read the contents of this xml file into
R. I tried the simpler solution xmlToDataFrame, which worked on another
file, but somehow it doesn't work for this file. 
 
I have tried different other solutions, but I just can't seem to get it
quite right. 
 
doc <- xmlRoot(xmlTreeParse(url)) 
art <- doc[[1]] [["DeliveryDay"]] 
fields <- xmlApply(art[[2]]), names) 
 
unique(names(unlist(fields))) 
 
Gives output: 
> "TimeStepID.text" "Purchase.Price" "Purchase.Volume" "Sell.Price"
> "Sell.Volume" 
 
 
So I want the result to be a 2 data.frames which looks like this (of course
for the sell data.fram it would say sell) 
 
 
TimeStepID   Purchase.PricePurchase.Volume 
1  3000  13000 
1  2900  13400 
- 
24   2000   12333 
 
etc. 
 
How is this possible? 
 
 
Also an extra question. My filename is called something like (a new file
every day) 
 
BidAskCurves_DE-AU_20130425_20130424130349.xml 
 
The first part after the "AU" is the current date, this I can generate
automacticly but I can't generate the last since its the date, time, minute
and second of the time the data was uploaded from another party to their ftp
- where I'm getting the data. 
 
Is there anyway to get R to find the right file, when I can only generate
part of the file? 
  __
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Grouped spaghetti plots in multipanel graphs

2013-04-30 Thread Santosh
Dear Rxperts,
Is there a simpler way to generate multipanel grouped individual profile
plots? All individuals of a group within a panel have the same color.  As
of now I am using lattice::xyplot to get the desired effect. Please feel
free to suggest other ideas.

Also, I am trying to create a generalized function which goes on similar
lines like this..

grpPlot <- function(dat, mpgrp=quote(G), grp=quote(interaction(D,a,drop=T))
{
lines for xyplot as shown below...
}


Below is the sample code... for illustration purposes...

q <-
 
data.frame(G=rep(paste("G",1:3,sep=""),each=50),D=rep(paste("D",1:5,sep=""),each=30),a=rep(1:15,each=10),t=rep(seq(10),15),b=round(runif(150,10,20)))
q$grp <- paste(q$D,q$a,sep=":")
q$grp <-  ordered(q$grp, levels=unique(q$grp))
q$dcol  <- unlist(sapply(q$D,function(x)
switch(x,"D1"="orange","D2"="blue","D3"="red", "D4"="seagreen",
"D5"="black")))
q2 <- q[order(q$G,q$D,q$a,q$t),]
ref3 <- subset(q2, !duplicated(a))
xyplot(b~t|G,data=q2,groups=grp,type="l",as.table=T,par.settings=my.theme,
layout=c(3,1), par.strip.text = list(lines = 2),
   scales=list(x=list(rot=90,rela='free',cex=1.3),
y=list(log=F,at=10**c(0:7),labels=10**c(0:7))),
panel=panel.superpose,

panel.groups=function(x=x,y=y,subscripts=subscripts,groups=groups,...,group.number)
{
require(grid)
panel.xyplot(x=x,y=y,subscripts=subscripts,pch=NA,lwd=1,type="l",
col=q2$dcol[subscripts],lty=1,cex=0.7)
 rv0 <-ref3[ref3$G%in%unique(q2$G)[panel.number()],]
 tids<- paste(as.character(unique(rv0$D)))#
as.character(rv0$NMID)
tcols   <- unique(rv0$dcol)
tlty<- 1
draw.key(list(columns=1,between=1,between.col=0.5,

lines=list(lty=tlty,col=tcols,size=3),text=list(lab=tids,col=tcols,cex=0.8),title="Classes",cex.title=1.1
),
draw = T,vp = viewport(x = unit(0.8, "npc"), y = unit(0.9, "npc")))
},

 
strip=strip.custom(strip.names=T,strip.levels=T,par.strip.text=list(cex=1.7,font=2),bg=0,
var.name="School"),
xlab=deparse(substitute(x)),
ylab=deparse(substitute(y)),
main="Overlay of Profiles by Schools and Classes",
)


Thanks so much..
Regards,
Santosh

[[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] still about biplot for principal componens analysis

2013-04-30 Thread capricy gao
I noticed that the points on the biplot are not exactly the same as the 
predicted values.

Could any body give me a  hint about why?

Thanks.





To: Jim Lemon  
Cc: "r-help@r-project.org"  
Sent: Tuesday, April 30, 2013 9:51 AM
Subject: Re: [R] biplot for principal componens analysis




very helpful!! Thanks a lot.



From: Jim Lemon 

Cc: "r-help@r-project.org"  
Sent: Monday, April 29, 2013 6:53 PM
Subject: Re: [R] biplot for principal componens analysis


On 04/30/2013 08:24 AM, capricy gao wrote:
>
>
> I did a PCA for my data which has a dimension of 19000X4 using princomp
>> pca2=princomp((data), cor=F)
>
>
>
>
>
> and obtained a biplot with 19000 labels which were very busy. How can I just 
> show 19000 spot w/o labels?
>> biplot(pca2)
>
Hi capricy,
I suppose you could try:

biplot(pca2,xlabs=rep(".",19000))

Jim
    [[alternative HTML version deleted]]

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

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


Re: [R] Stacked geom_bar with aggregated SE -ggplot2

2013-04-30 Thread John Kane
Hi Olvia, 
Welcome to the R-help list.

Are you seriously proposing to add error bars to a stacked barplot? Why?

 Do you mean a dodged barplot?

My first thought is that there probably are several better ways of presenting 
your data than stacked bar charts--I sometimes think that anything other than 
pie charts beats a stacked bar chart.

It might help to have some idea of what you are trying to do. We really need a 
concise statement of the problem in subject matter terms--probably a bit of an 
expansion on what you provided at the end of your post and then some example 
data and what code you have been working with.  Definately look at ?dput as a 
way to provide the sample data.

Have a look at https://github.com/hadley/devtools/wiki/Reproducibility for some 
suggestions on how to put frame a question for the R-help list.

John Kane
Kingston ON Canada


> -Original Message-
> From: olivia.bu...@gmail.com
> Sent: Wed, 1 May 2013 00:20:59 +1200
> To: r-help@r-project.org
> Subject: [R] Stacked geom_bar with aggregated SE -ggplot2
> 
> Hi there,
> 
> I've been battling with an extension of this in my own data: getting
> appropriate error bars once data is stacked in a bar graph.
> (original question:
> http://r.789695.n4.nabble.com/ggplot2-se-variable-in-geom-errorbar-s-limits-
> td3311176.html). It wouldn't let me reply to that thread.
> 
> A modification of the earlier answer:
> data(diamonds)
> 
>  diamonds_df <- ddply(diamonds, .(cut, color), summarise,
>                         mean_price = mean(price),
>                         se_price = sd(price)/sqrt(length(price))
>                         )
> 
>  limits <- aes(ymax = mean_price + se_price, ymin = mean_price -
> se_price)
> 
> a<-ggplot(diamonds_df, aes(x = cut, y = mean_price, fill=color)) +
>  geom_bar(position=position_stack(width=0.9))
> a
> 
> Then attempting to add error bars:
> a+ geom_errorbar(limits, position=position_stack(width=0.9), width=0.9)
> 
> I have tried:
> r + stat_sum_df("mean_cl_normal", geom = "errorbar"),  using the
> aggregation
> function in http://www.stanford.edu/~paunesku/, using ddplyr but haven't
> managed to work out a way of specifying the error bars to R.  In my case
> I
> would like to use an error bar analogous to each value of "cut" in the
> data
> example.   When I calculate the SEs appropriately ggplot2 won't stack.
> 
> This is first time posting and I've scoured the various forums and
> websites
> for a worked example.
> 
> In case it is relevant, my response variable is fitted germination of an
> lmer model ("germination"), x is a categorical variable (treatment, with
> 3
> levels), and I am using a categorical variable ("species") to stack.
> 
> Kind regards,
> 
> Olivia
> MSc student
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.


FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks & orcas on your 
desktop!

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

2013-04-30 Thread Jeff Newmiller
That is unlikely in the absence of a reproducible example [1].

[1] 
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
---
Jeff NewmillerThe .   .  Go Live...
DCN:Basics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

"Havenga, BS, Mnr <15264...@sun.ac.za>" <15264...@sun.ac.za> wrote:

>Hi there
>
>I am a Masters student at the University of Stellenbosch. I have been
>using R to analyze the data, using the GLS model, of one of my
>experiments.
>The problem that I am having is that whenever I run my model using:
>fit.glsmodel1<-gls(Number~as.factor(Season)+as.factor(Depth)+as.factor(Orientation),
>data=Number, weights=varPower(), method="ML")
>
>I get the error:
>Error in glsEstimate(object, control = control) :computed "gls" fit
>is singular, rank 8
>
>I would like to know if anyone can tell me what is causing this error.
>Any advice will be much appreciated.
>
>Kind regards
>Brendan
>
>   [[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] How to handle errors generated by the package Kendall?

2013-04-30 Thread Kaptue Tchuente, Armel
Hello everyone,

I'm trying to perform some trend analysis using the package "Kendall" and for 
some observations I get the following error "WARNING Error exit, tauk2, IFAULT 
= 12"
Could anyone tell me how to create a logical vector of observations having its 
element equal to TRUE if this error happened and FALSE if not?
I'm thinking about something similar as "inherits" implemented in the "nls" 
function which determines the occurrence of the error in case of failure 
convergence of the algorithm.
Cheers
Armel


[[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 Function to extract columnNames

2013-04-30 Thread David Winsemius

On Apr 30, 2013, at 6:00 AM, arun wrote:

> Hi,
> May be this helps:
> funcName<- function(df1, x){
>  whatCol=df1[[x]]
>  print("Got it")
>  print(whatCol)
>  }
>  
> funcName(df,"ColA")
> #[1] "Got it"
> #[1] 1 2 3 4 5
>   funcName(df,"ColB")
> #[1] "Got it"
> #[1] A B C D E
> #Levels: A B C D E
> 
> 

To ST;

You should now realize that this function has already been built into R and its 
name is "[[".

The "$" function is just variation on "[[" that does not evaluate its argument. 
You effort to parse back to  paste("df",x,sep="$") failed, but might have 
succeeded if you took this route:

eval(parse(text= paste("df",x,sep="$") ) )

I'm not saying you should have done that since obviously "[[" is the proper, 
approved, economical way to do it. I'm just trying to get you to understand the 
language better. You should spend further time with:

help("Extract")# to cement this lesson and extend your understanding.

-- 
David.

> A.K.
> 
> 
>> I am trying to extract the 2nd column from a dataframe using a function 
> called funcName. Note this is an example that I need cos I am using it 
> to >read the values I pass into a function call - these passed values 
> represent dataframe column names. I am trying to use this concept for a 
> vary large >dataframe with 100+ columns. 
>> 
>> ColA <- c(1,2,3,4,5) 
>> ColB <- c("A","B","C","D","E") 
>> df <- data.frame(ColA,ColB) 
>> 
>> funcName <- function(x) { 
>> whatCol = paste("df",x,sep="$") 
>  >print("Got it",whatCol) 
>> } 
>> 
>> funcName("ColA") 
>> 
>> Please advise, since this code is not working. Thanks in advance. 
>> 
>> -ST
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius
Alameda, CA, USA

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

2013-04-30 Thread londonphd
Hi,

I was wondering if there is a package/function for Panel Granger
non-causality tests? I am interested in Toda-Yamamoto procedure in panel
data setting. 

Thank you,



--
View this message in context: 
http://r.789695.n4.nabble.com/Panel-Granger-Causality-Tests-tp4665834.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] vegan -varpart is bigger than 100% in total?

2013-04-30 Thread Ozgul Inceoglu
I am trying to find the percentage of the parameters explaining the bacterial 
community composition. I have one data matrix with relative abundance of OTUs 
and one with environmental parameters. I used varpart in vegan package but the 
values in the venn diagram is bigger than 100% in total.How is it possible? 
What might be the reason? Thank you

library(vegan)
gotud <- decostand(gotu,"hell") 
G.var <- 
varpart(gotud,~Depth,~CH4_oxidation,~d13C_DIC+Temperature+Spec.Conductivity+DO+CH4+N2O+pH,
 data=ge) 
plot(G.var) 


Sample   depth  T   SpCond DO pH Chl CH4CH4oxidationN2O TA  
POC BP  SO4 
Gi25Feb12   25  24.46   11044.428.941.6 40.00174578 
1.1 6.683260809 12.723  41.98069543 0.008282072 150.1168 
Gi27.5Fb12  27.524.42   11054.368.931.2 68.53538846 
1.4 7.431459607 12.711  31.4397919  0.020730967 188.4166 
Gi30Fb1230  23.71   11282.628.811   10.53158545 
0.9 8.415644664 12.817  23.06912467 0.007716205 199.9561 
Gi32.5Fb12  32.523.58   11351.638.791.2 11.77550422 
0   7.069811212 12.916  26.80357225 0.00245392  170.9078 
Gi35Fb1235  23.54   11381.428.78-0.411.57631611 
0   6.976269751 12.978  31.80221025 0.006877572 176.4877 
Gi37.5Fb12  37.523.511381.378.780.6 17.19312361 
0   7.382521684 12.975  19.67401691 0.007159828 164.5442 

OTU matrix 

Group   Otu04518Otu04569Otu04598Otu04636
Otu04671Otu04672Otu04795Otu04821Otu04891
Otu04930Otu05062Otu05118Otu05148Otu05440
Otu05520Otu0Otu05690Otu06033 Otu06037   
Otu06194Otu06354 
Gi25Fb12r   0.0005670   0   0   0.001134
0.0005670.0028340.0005670.0005670   0   
0   0   0.0005670   0   0   0   0   0   
0 
Gi275Fb12r  0   0   0   0   0   0   0   0   
0   0   0   0   0   0   0   0   0   0   
0   0   0 
Gi30Fb12r   0   0   0.0031450   0   0   0   
0   0   0   0   0   0   0   0   0   0   
0   0   0   0 
Gi325Fb12r  0   0   0   0   0   0   0   0   
0   0   0   0   0   0   0.0048  0.0208  0   0   
0   0   0 
Gi35Fb12r   0   0   0   0.0011140   0   0   
0   0   0   0.0011140   0   0   0   0   
0   0   0   0   0 
Gi375Fb12r  0   0.0014470   0   0   0   0   
0   0   0   0   0   0.0014470   0   0   
0   0   0   0   0

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

2013-04-30 Thread Olivia Burge
Hi there, 

I've been battling with an extension of this in my own data: getting
appropriate error bars once data is stacked in a bar graph. 
(original question:
http://r.789695.n4.nabble.com/ggplot2-se-variable-in-geom-errorbar-s-limits-
td3311176.html). It wouldn't let me reply to that thread.

A modification of the earlier answer: 
data(diamonds) 

 diamonds_df <- ddply(diamonds, .(cut, color), summarise, 
                        mean_price = mean(price), 
                        se_price = sd(price)/sqrt(length(price)) 
                        ) 

 limits <- aes(ymax = mean_price + se_price, ymin = mean_price - se_price) 

a<-ggplot(diamonds_df, aes(x = cut, y = mean_price, fill=color)) + 
 geom_bar(position=position_stack(width=0.9)) 
a 

Then attempting to add error bars: 
a+ geom_errorbar(limits, position=position_stack(width=0.9), width=0.9) 

I have tried:   
r + stat_sum_df("mean_cl_normal", geom = "errorbar"),  using the aggregation
function in http://www.stanford.edu/~paunesku/, using ddplyr but haven't
managed to work out a way of specifying the error bars to R.  In my case I
would like to use an error bar analogous to each value of "cut" in the data
example.   When I calculate the SEs appropriately ggplot2 won't stack. 

This is first time posting and I've scoured the various forums and websites
for a worked example.   

In case it is relevant, my response variable is fitted germination of an
lmer model ("germination"), x is a categorical variable (treatment, with 3
levels), and I am using a categorical variable ("species") to stack. 

Kind regards, 

Olivia
MSc student

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

2013-04-30 Thread Mourik-2, M.S.M. van
Dear R users,

For the purpose of validating a prediction model using validate() from the rms 
package, I am running into some trouble with using the fastbw() function 
breaking up natural groups of variables.

Is there any way I can specify to keep certain variable together? In 
particular, if interactions are included I would also like to keep the main 
effects in the model.
Another example is a group of comorbidity variables that I would like to be 
assessed all together and not as separate components as this makes more sense 
from the perspective of interpretation.

The Force = ... option seems to only work for pre-specified variables and does 
not solve my problem. In the case of the comorbidites, the variables are not 
mutually exclusive, so I would be very difficult to recode them as a factor 
variable with multiple levels.

Examples:
fit1 <-lrm(outcome~age + gender + med_a + med_b + med_a:med_b, x = TRUE, y = 
TRUE, data = example)
fastbw(fit1, type = "residual).
--> fastbw may drop med_a and keep the med_a:med_b interaction instead.

fit2 <-lrm(outcome~age + gender +  comorb_a + comorb_b + comorb_c + other 
predictors, x = TRUE, y = TRUE, data = example)
fastbw(fit2, type = "residual).
--> fastbw may drop some of the comorbidities, but  I would like to consider 
them as one group.

Any help is much appreciated!

Maaike


--

De informatie opgenomen in dit bericht kan vertrouwelijk zijn en is
uitsluitend bestemd voor de geadresseerde. Indien u dit bericht onterecht
ontvangt, wordt u verzocht de inhoud niet te gebruiken en de afzender direct
te informeren door het bericht te retourneren. Het Universitair Medisch
Centrum Utrecht is een publiekrechtelijke rechtspersoon in de zin van de W.H.W.
(Wet Hoger Onderwijs en Wetenschappelijk Onderzoek) en staat geregistreerd bij
de Kamer van Koophandel voor Midden-Nederland onder nr. 30244197.

Denk s.v.p aan het milieu voor u deze e-mail afdrukt.

--

This message may contain confidential information and is...{{dropped:14}}

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


[R] Cox model: random effect on a variable with 3 levels

2013-04-30 Thread lmajed
Question about package Coxme:
I develop a cox model that includes a variable "treatment" with 3 levels (A, B, 
C):

 > model_alea_int <- coxme(Surv(delai, status) ~ (1|trt)+ strata(center) , data)

I am surprised that the output given in R is 3 coefficients for random effects 
whereas only 2 dummy variables are created:
> contrasts(data$trt)
   B C   
A  0 0
B  1 0
C  0 1

 > ranef(model_alea_int)
$trt
 A   B  C 
 0.24093054 -0.08332041 -0.15761013 

 I want to compare treatment B /treatment A and Treatment C /treatment A.
Is it possible to consider random effect for this variable "treatment" with 3 
levels?
what is the interpretation of the 3 coefficients?
Thank you.




--
View this message in context: 
http://r.789695.n4.nabble.com/Cox-model-random-effect-on-a-variable-with-3-levels-tp4665815.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.


[R] Error message

2013-04-30 Thread Havenga, BS, Mnr <15264...@sun.ac.za>
Hi there

I am a Masters student at the University of Stellenbosch. I have been using R 
to analyze the data, using the GLS model, of one of my experiments.
The problem that I am having is that whenever I run my model using:
fit.glsmodel1<-gls(Number~as.factor(Season)+as.factor(Depth)+as.factor(Orientation),
 data=Number, weights=varPower(), method="ML")

I get the error:
Error in glsEstimate(object, control = control) :computed "gls" fit is 
singular, rank 8

I would like to know if anyone can tell me what is causing this error. Any 
advice will be much appreciated.

Kind regards
Brendan

[[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] Comparing two different 'survival' events for the same subject using survdiff?

2013-04-30 Thread Terry Therneau

-Original Message-

I have a dataset which for the sake of simplicity has two endpoints. We would like to test 
if two different end-points have the same eventual meaning. To try and take an example 
that people might understand better:


Lets assume we had a group of subjects who all received a treatment. The could stop 
treatment for any reason (side effects, treatment stops working etc). Getting that data is 
very easy. Measuring if treatment stops working is very hard to capture... so we would 
like to test if duration on treatment (easy) is the same as time to treatment failure (hard).


--- End 

The problem you describe is known as "surrogate endpoints" and addressing it is harder 
than you think. You will need to look in the literature to gain an understanding of the 
issues before you proceed. Your question is an important one and lots of folks have 
thought about it more deeply than I.


Cohn JN (2004). "Introduction to Surrogate Markers". Circulation (American Heart 
Association) 109 (25 Suppl 1): IV20–1. doi:10.1161/01.CIR.133441.05780.1d


Fleming T, David D. Surrogate End Points in Clinical Trials: Are We Being Misled? Ann 
Intern Med. 1996 Oct 1;125(7):605-13


Terry T.

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


Re: [R] biplot for principal componens analysis

2013-04-30 Thread capricy gao


very helpful!! Thanks a lot.



 From: Jim Lemon 

Cc: "r-help@r-project.org"  
Sent: Monday, April 29, 2013 6:53 PM
Subject: Re: [R] biplot for principal componens analysis
 

On 04/30/2013 08:24 AM, capricy gao wrote:
>
>
> I did a PCA for my data which has a dimension of 19000X4 using princomp
>> pca2=princomp((data), cor=F)
>
>
>
>
>
> and obtained a biplot with 19000 labels which were very busy. How can I just 
> show 19000 spot w/o labels?
>> biplot(pca2)
>
Hi capricy,
I suppose you could try:

biplot(pca2,xlabs=rep(".",19000))

Jim
[[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 help - bootstrap with survival analysis

2013-04-30 Thread Terry Therneau

This comes up regularly.  Type "?print.survfit" and look at the comments there under 
"value".

Terry T.

-  begin included message 

Hi,

I'm not sure if this is the proper way to ask questions, sorry if not.  But
here's my problem:

I'm trying to do a bootstrap estimate of the mean for some survival data.
Is there a way to specifically call upon the rmean value, in order to store
it in an object? I've used print(...,print.rmean=T) to print the summary of
survfit, but I'm not sure how to access only rmean because it does not show
up under attributes for survfit.

Thanks for any help in advance!

Fayaaz Khatri

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


Re: [R] bigmemory and R 3.0

2013-04-30 Thread Benjamin Caldwell
Thanks to you all for your replies. I didn't realize bigmemory is only
available in Unix environments - when I saw

> install.packages('bigmemory')
Installing package into ‘C:/Users/BenC/Documents/R/win-library/3.0’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
Warning message:
package ‘bigmemory’ is not available (for R version 3.0.0)

I made the ignorant assumption that the issue was the R version, not the
OS. Maybe I'll finally get around to setting up a duel boot because of this!

Best

*Ben Caldwell*




On Mon, Apr 29, 2013 at 10:35 PM, Prof Brian Ripley
wrote:

> On 29/04/2013 23:46, Benjamin Caldwell wrote:
>
>> Dear helpers,
>>
>> Does anyone have information on the status of bigmemory and R3.0? Will it
>> just take time for the devs to re-code for the new environment? Or is
>> there
>> an alternative for this new version?
>>
>
> What are you asking about?  'bigmemory' has been available for R 3.0.0
> (sic) for a long time for all OSes bar Solaris and Windows, where the
> maintainers excluded it a long time ago (not just for R 3.0.0).
>
>
>> Thanks
>>
>> Ben Caldwell
>>
>> [[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.
>>
>>  Please see what it has to say about mis-reading R version numbers and
> HTML mail, and asking maintainers about their packages.
>
>
> --
> 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
>

[[alternative HTML version deleted]]

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


Re: [R] how to add new rows in a dataframe?

2013-04-30 Thread arun
Hi,
Not sure if this is what you meant.
dat1<- read.table(text="
id    t scores  scores2  scores3
2 0    1.2 1.4    1.9
2 2 2.3 2.5   2.2
2 3    3.6  3.2   3.4
2 4    5.6  5.9   5.7
2 6    7.8  7.5   7.6
3 0    1.6  1.8   1.9
3 1 1.2 1.7   1.5
3 4 1.5 1.9   1.6
",sep="",header=TRUE)
library(plyr)
 dat2<- ddply(dat1,.(id),summarize, t=seq(min(t),max(t)))
library(zoo)
 res<-na.locf(join(dat2,dat1,type="full"))
res
#   id t scores scores2 scores3
#1   2 0    1.2 1.4 1.9
#2   2 1    1.2 1.4 1.9
#3   2 2    2.3 2.5 2.2
#4   2 3    3.6 3.2 3.4
#5   2 4    5.6 5.9 5.7
#6   2 5    5.6 5.9 5.7
#7   2 6    7.8 7.5 7.6
#8   3 0    1.6 1.8 1.9
#9   3 1    1.2 1.7 1.5
#10  3 2    1.2 1.7 1.5
#11  3 3    1.2 1.7 1.5
#12  3 4    1.5 1.9 1.6
A.K.







From: GUANGUAN LUO 
To: arun  
Sent: Tuesday, April 30, 2013 9:17 AM
Subject: Re: how to add new rows in a dataframe?



I would replace the rows but not only the variable "scores". In reality , i 
have 105 variables in each row .
thank you so much.

GG


2013/4/29 arun 

Hi,
>dat1<- read.table(text="
>id    t scores
>2 0    1.2
>2 2 2.3
>2 3    3.6
>2 4    5.6
>2 6    7.8
>3 0    1.6
>3 1 1.2
>3 4 1.5
>",sep="",header=TRUE)
>library(zoo)
>res1<-do.call(rbind,lapply(split(dat1,dat1$id),function(x) 
>{t1<-seq(min(x$t),max(x$t));scores1<-na.locf(x$scores[match(t1,x$t)]);data.frame(id=rep(unique(x$id),length(t1)),t1,scores1)}))
> row.names(res1)<- 1:nrow(res1)
>
> res1
>#   id t1 scores1
>#1   2  0 1.2
>#2   2  1 1.2
>#3   2  2 2.3
>#4   2  3 3.6
>#5   2  4 5.6
>#6   2  5 5.6
>#7   2  6 7.8
>#8   3  0 1.6
>#9   3  1 1.2
>#10  3  2 1.2
>#11  3  3 1.2
>#12  3  4 1.5
>libray(plyr)
> dat2<-ddply(dat1,.(id),summarize,t=seq(min(t),max(t)))
>res2<-mutate(join(dat2,dat1,type="full"),scores=na.locf(scores))
>identical(res1,res2)
>#[1] TRUE
> res2
>#   id t scores
>#1   2 0    1.2
>#2   2 1    1.2
>#3   2 2    2.3
>#4   2 3    3.6
>#5   2 4    5.6
>#6   2 5    5.6
>#7   2 6    7.8
>#8   3 0    1.6
>#9   3 1    1.2
>#10  3 2    1.2
>#11  3 3    1.2
>#12  3 4    1.5
>
>A.K.
>
>
>>Hello , dear  experts,
>>I have my data like this:
>>
>>id                t                     scores
>>2                 0                        1.2
>>2                 2                         2.3
>>2                 3                        3.6
>>2                 4                        5.6
>>2                 6                        7.8
>>3                 0                        1.6
>>3                 1                         1.2
>>3                 4                         1.5
>>
>>I want to fullifill the "t", so i want to add the rows with the data of (t-1)
>>
>>just get another dataframe like this:
>>
>>id              t                 scores
>>2               0                 1.2
>>2               1                  1.2
>>2                2                         2.3
>>2                3                        3.6
>>2               4                        5.6            
>>2               5                         5.6
>>2                6                         7.8
>>3                 0                        1.6
>>3                 1                         1.2
>>3                2                         1.2
>>3                4                        1.5
>>
>>How can i get the result like this? In reality, i have 4000 obervations, so 
>>it's difficult to add the lines manuelly.
>>
>>Thank you so much.
>

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


Re: [R] ADF test --time series

2013-04-30 Thread Jeff Newmiller
a) This looks like homework. The Posting Guide clearly indicates that this list 
is not for homework help.

b) This is a statistics theory question that happens to use R, not an R 
question that happens to be about statistics. Also off-topic per the Posting 
Guide... there are other forums for stats questions.
---
Jeff NewmillerThe .   .  Go Live...
DCN:Basics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

Preetam Pal  wrote:

>Hi all,
>
>I was running the adf test in R.
>
>
>CODE 1:
>
>adf.test(data$LOSS)
>
>Augmented Dickey-Fuller Test
>
>data:  data$LOSS
>Dickey-Fuller = -1.9864, Lag order = 2, p-value = 0.5775
>alternative hypothesis: stationary
>
>
>CODE 2:
> adf.test(diff(diff(data$LOSS)))
>
>Augmented Dickey-Fuller Test
>
>data:  diff(diff(data$LOSS))
>Dickey-Fuller = -6.9287, Lag order = 2, p-value = 0.01
>alternative hypothesis: stationary
>
>
>
>Is my interpretation correct:
>
>The original data( in code 1) is not stationary
>
>the twice differenced data (in code 2) is *stationary* and the order of
>the
>corresponding ARMA(p,q) model are *p=2* (as lag order in the output is
>2)
>and *q=0*;.i.e. the *AR coefficients for X(t-1) and X(t-2) are
>significant*,
>while those of X(t-3) onwards are insignificant.
>
>
>Appreciate your help.
>Thanks,
>Preetam

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

2013-04-30 Thread arun
Hi,
May be this helps:
funcName<- function(df1, x){
 whatCol=df1[[x]]
 print("Got it")
 print(whatCol)
 }
 
funcName(df,"ColA")
#[1] "Got it"
#[1] 1 2 3 4 5
  funcName(df,"ColB")
#[1] "Got it"
#[1] A B C D E
#Levels: A B C D E


A.K.


>I am trying to extract the 2nd column from a dataframe using a function 
called funcName. Note this is an example that I need cos I am using it 
to >read the values I pass into a function call - these passed values 
represent dataframe column names. I am trying to use this concept for a 
vary large >dataframe with 100+ columns. 
>
>ColA <- c(1,2,3,4,5) 
>ColB <- c("A","B","C","D","E") 
>df <- data.frame(ColA,ColB) 
>
>funcName <- function(x) { 
> whatCol = paste("df",x,sep="$") 
 >print("Got it",whatCol) 
>} 
>
>funcName("ColA") 
>
>Please advise, since this code is not working. Thanks in advance. 
>
>-ST

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


Re: [R] task percentage completion

2013-04-30 Thread R. Michael Weylandt
On Tue, Apr 30, 2013 at 10:40 AM, Fabio Berzaghi  wrote:
> Dear All,
>
> Is it possible to add a percentage completion bar to R? I find it
> frustrating when running long calculations that I don't know at what point
> the process is. It would be very helpful so I am not guessing if I should
> wait a few minutes or hours.

I believe recent-ish versions of the plyr package include this
feature. Note, however, Prof Ripley's caution: it's not as trivial as
it might seem to do so _accurately_. With a bit of squinting, one
might even see the halting problem...

Obligatory: http://xkcd.com/612/

MW

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


Re: [R] task percentage completion

2013-04-30 Thread Prof Brian Ripley

On 30/04/2013 10:40, Fabio Berzaghi wrote:

Dear All,

Is it possible to add a percentage completion bar to R? I find it
frustrating when running long calculations that I don't know at what
point the process is. It would be very helpful so I am not guessing if I
should wait a few minutes or hours.


Yes.  See ??progressbar

And this does need some knowledge from the programmer: no way can anyone 
know how long a task will take without either


- a pretty complete (and correct) analysis
- trying it.

People inadvertently write loops where step i takes time proportional to 
i, so extrapolation from a pilot study does not suffice.




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



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

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


[R] task percentage completion

2013-04-30 Thread Fabio Berzaghi

Dear All,

Is it possible to add a percentage completion bar to R? I find it 
frustrating when running long calculations that I don't know at what 
point the process is. It would be very helpful so I am not guessing if I 
should wait a few minutes or hours.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Extrafont package: Fonts are not successfully installed

2013-04-30 Thread jpm miao
Hi,

   I am using Extrafont package to install more fonts for my graphs. My
primary graphic tool is ggplot2. I seem to have problem installing the
package, but could not pinpoint where it is.

  I try to follow the instruction here:

https://github.com/wch/extrafont

  I guess (but am not sure) the fonts are successfully installed.

Problem encountered:
1. The following line sometimes yields an error. Sometimes it works.
> pdf("font_plot.pdf", family="Times New Roman", width=4, height=4)
2. The compiler could not find the fonts installed, e.g., Georgia, Impact,
Times New Romans, Arial Black. Error message: "Font family not found in
Windows font database."
3. The plot could not show up at all. I use RStudio. I need to close
RStudio and reopen it in order to see the plots produced by ggplot2 .

  Could someone provide an example of how Extrafont package is used?
Thanks,

Miao



> rm(list=ls())
> library(ggplot2)
> library(extrafont)
> font_import()
Importing fonts may take a few minutes, depending on the number of fonts
and the speed of the system. Continue? [y/n] y
Scanning ttf files in C:\WINDOWS\Fonts ...
Extracting .afm files from .ttf files...
C:\WINDOWS\Fonts\arial.ttf : ArialMT already registered in fonts database.
Skipping.
C:\WINDOWS\Fonts\arialbd.ttf : Arial-BoldMT already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\arialbi.ttf : Arial-BoldItalicMT already registered in
fonts database. Skipping.
C:\WINDOWS\Fonts\ariali.ttf : Arial-ItalicMT already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\ariblk.ttf : Arial-Black already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\Braille.ttf : Braille already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\comic.ttf : ComicSansMS already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\comicbd.ttf : ComicSansMS-Bold already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\cour.ttf : CourierNewPSMT already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\courbd.ttf : CourierNewPS-BoldMT already registered in
fonts database. Skipping.
C:\WINDOWS\Fonts\courbi.ttf : CourierNewPS-BoldItalicMT already registered
in fonts database. Skipping.
C:\WINDOWS\Fonts\couri.ttf : CourierNewPS-ItalicMT already registered in
fonts database. Skipping.
C:\WINDOWS\Fonts\cwfs.ttf : cwTeXFangSong already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\cwheib.ttf : cwTeXHeiBold already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\cwkai.ttf : cwTeXKai already registered in fonts database.
Skipping.
C:\WINDOWS\Fonts\cwming.ttf : cwTeXMing already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\cwyen.ttf : cwTeXYen already registered in fonts database.
Skipping.
C:\WINDOWS\Fonts\Dr.eye phonetic symbol.ttf : Dr-eye-phonetic-symbol
already registered in fonts database. Skipping.
C:\WINDOWS\Fonts\estre.ttf : EstrangeloEdessa already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\framd.ttf : FranklinGothic-Medium already registered in
fonts database. Skipping.
C:\WINDOWS\Fonts\framdit.ttf : FranklinGothic-MediumItalic already
registered in fonts database. Skipping.
C:\WINDOWS\Fonts\gautami.ttf : Gautami already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\georgia.ttf : Georgia already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\georgiab.ttf : Georgia-Bold already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\georgiai.ttf : Georgia-Italic already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\georgiaz.ttf : Georgia-BoldItalic already registered in
fonts database. Skipping.
C:\WINDOWS\Fonts\impact.ttf : Impact already registered in fonts database.
Skipping.
C:\WINDOWS\Fonts\kaiu.ttf : DFKaiShu-SB-Estd-BF already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\kartika.ttf : Kartika already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\l_10646.ttf : LucidaSansUnicode already registered in
fonts database. Skipping.
C:\WINDOWS\Fonts\latha.ttf : Latha already registered in fonts database.
Skipping.
C:\WINDOWS\Fonts\lingoes.ttf : LingoesUnicode already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\liquidcr.ttf : LiquidCrystal already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\lucon.ttf : LucidaConsole already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\mangal.ttf : Mangal-Regular already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\marlett.ttf : Marlett already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\micross.ttf : MicrosoftSansSerif already registered in
fonts database. Skipping.
C:\WINDOWS\Fonts\mvboli.ttf : MVBoli already registered in fonts database.
Skipping.
C:\WINDOWS\Fonts\pala.ttf : PalatinoLinotype-Roman already registered in
fonts database. Skipping.
C:\WINDOWS\Fonts\palab.ttf : PalatinoLinotype-Bold already registered in
fonts database. Skipping.
C:\WINDOWS\Fonts\palabi.ttf : PalatinoLinotype-BoldItalic already
registered in fonts database. Ski

Re: [R] Mixed Modeling in lme4

2013-04-30 Thread Indrajit Sengupta
Thanks a lot Joshua.

Regards,
Indrajit

On Tue, Apr 30, 2013 at 1:13 PM, Joshua Wiley  wrote:
> Hi Indrajit,
>
> In your first SAS code, change to type=un.  cs imposes the (somewhat
> dubious) assumption that the variance of both the intercept and slope are
> equal.  If you are using lme4, all random effects in a single block (e.g.,
> (1 + month | batch) the 1 = intercept and month = random slope) will have an
> unstructured (or freely estimated) variance covariance matrix.
>
> Cheers,
>
> Josh
>
>
>
> On Mon, Apr 29, 2013 at 11:26 PM, Indrajit Sengupta
>  wrote:
>>
>> Hi All,
>>
>> I am trying to shift from running mixed models in SAS using PROC MIXED
>> to using lme4 package in R. In trying to match the coefficients of R
>> output to that of SAS output, I came across this problem.
>>
>> The dataset I am using is this one:
>>
>>
>> http://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_mixed_sect034.htm
>>
>> If I run the following code:
>>
>> proc mixed data=rc method=ML covtest;
>> class Batch;
>> model Y = Month / s;
>> random Int Month / type=cs sub=Batch s;
>> run;
>>
>> The Fixed effect coefficients match with that of R. But the random
>> effect does not. Here is the R code:
>>
>> rc <- read.table('rc.csv', sep = ',', header=T, na.strings=".")
>>
>> m1 <- lmer(formula = Y ~ Month + (Month|Batch), data = rc, REML = F)
>>
>> summary(m1)
>>
>> fixef(m1)
>>
>> ranef(m1)
>>
>> But if I change the SAS code as follows:
>>
>> proc mixed data=rc method=ML covtest;
>> class Batch;
>> model Y = Month / s;
>> random Int / type=cs sub=Batch s;
>> run;
>>
>> and the R code as follows:
>>
>> m2 <- lmer(formula = Y ~ Month + (1|Batch), data = rc, REML = F)
>>
>> summary(m2)
>>
>> fixef(m2)
>>
>> ranef(m2)
>>
>> both fixed and random effect coefficients match. I am unable to
>> understand this discrepancy. Am I wrongly specifying the model in the
>> first case?
>>
>> It would be helpful if someone can throw some light on this.
>>
>> Regards,
>> Indrajit
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/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://joshuawiley.com/
> Senior Analyst - Elkhart Group Ltd.
> http://elkhartgroup.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] ADF test --time series

2013-04-30 Thread Preetam Pal
Hi all,

I was running the adf test in R.


CODE 1:

adf.test(data$LOSS)

Augmented Dickey-Fuller Test

data:  data$LOSS
Dickey-Fuller = -1.9864, Lag order = 2, p-value = 0.5775
alternative hypothesis: stationary


CODE 2:
 adf.test(diff(diff(data$LOSS)))

Augmented Dickey-Fuller Test

data:  diff(diff(data$LOSS))
Dickey-Fuller = -6.9287, Lag order = 2, p-value = 0.01
alternative hypothesis: stationary



Is my interpretation correct:

The original data( in code 1) is not stationary

the twice differenced data (in code 2) is *stationary* and the order of the
corresponding ARMA(p,q) model are *p=2* (as lag order in the output is 2)
and *q=0*;.i.e. the *AR coefficients for X(t-1) and X(t-2) are significant*,
while those of X(t-3) onwards are insignificant.


Appreciate your help.
Thanks,
Preetam


-- 
Preetam Pal
(+91)-9432212774
M-Stat 2nd Year, Room No. N-114
Statistics Division,   C.V.Raman
Hall
Indian Statistical Institute, B.H.O.S.
Kolkata.

[[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] Mixed Modeling in lme4

2013-04-30 Thread Joshua Wiley
Hi Indrajit,

In your first SAS code, change to type=un.  cs imposes the (somewhat
dubious) assumption that the variance of both the intercept and slope are
equal.  If you are using lme4, all random effects in a single block (e.g.,
(1 + month | batch) the 1 = intercept and month = random slope) will have
an unstructured (or freely estimated) variance covariance matrix.

Cheers,

Josh



On Mon, Apr 29, 2013 at 11:26 PM, Indrajit Sengupta <
indrajitsg2...@gmail.com> wrote:

> Hi All,
>
> I am trying to shift from running mixed models in SAS using PROC MIXED
> to using lme4 package in R. In trying to match the coefficients of R
> output to that of SAS output, I came across this problem.
>
> The dataset I am using is this one:
>
>
> http://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_mixed_sect034.htm
>
> If I run the following code:
>
> proc mixed data=rc method=ML covtest;
> class Batch;
> model Y = Month / s;
> random Int Month / type=cs sub=Batch s;
> run;
>
> The Fixed effect coefficients match with that of R. But the random
> effect does not. Here is the R code:
>
> rc <- read.table('rc.csv', sep = ',', header=T, na.strings=".")
>
> m1 <- lmer(formula = Y ~ Month + (Month|Batch), data = rc, REML = F)
>
> summary(m1)
>
> fixef(m1)
>
> ranef(m1)
>
> But if I change the SAS code as follows:
>
> proc mixed data=rc method=ML covtest;
> class Batch;
> model Y = Month / s;
> random Int / type=cs sub=Batch s;
> run;
>
> and the R code as follows:
>
> m2 <- lmer(formula = Y ~ Month + (1|Batch), data = rc, REML = F)
>
> summary(m2)
>
> fixef(m2)
>
> ranef(m2)
>
> both fixed and random effect coefficients match. I am unable to
> understand this discrepancy. Am I wrongly specifying the model in the
> first case?
>
> It would be helpful if someone can throw some light on this.
>
> Regards,
> Indrajit
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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://joshuawiley.com/
Senior Analyst - Elkhart Group Ltd.
http://elkhartgroup.com

[[alternative HTML version deleted]]

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


Re: [R] rbinding some elements from a list and obtain another list

2013-04-30 Thread De Castro Pascual, Montserrat
Hi David,

Sorry if I have explain me wrong!
Mylist<-list(A=data.frame, B=data.frame, C=data.frame, D=data.frame)
I know that this is a malformed command, only was a fast way to descrive
mylist.

Thank you!

-Mensaje original-
De: David Winsemius [mailto:dwinsem...@comcast.net]
Enviado el: lunes, 29 de abril de 2013 17:47
Para: De Castro Pascual, Montserrat
CC: r-help@r-project.org
Asunto: Re: [R] rbinding some elements from a list and obtain another list


On Apr 29, 2013, at 6:54 AM, De Castro Pascual, Montserrat wrote:

> Hi everybody,
>
>
>
> I have a list, where every element of this list is a data frame.
>
>
>
> An example:
>
>
>
> Mylist<-list(A=data.frame, B=data.frame, C=data.frame, D=data.frame)

I'm looking at this apparently malformed command and wondering if that is
the root of all your problems. Do you know how to make a simple successful
example of a list of dataframes?

--
David.

> I want to rbind some elements of this list.
>
> As an example:
>
>
>
> Output<-list(AB=data.frame, CD=data.frame)
>
>
>
> Where
>
> AB=rbind(A,B)
>
> CD=rbind(C,D)
>
>
>
>
>
> I’ve tried:
>
>
>
> f<-function(x){
>
>  for (i in seq(1,length(names(x)),2)){
>
>aa<-do.call(rbind,x[i:i+1])
>
>aa
>
>  }}
>
> bb<-f(mylist)
>
>
>
> or
>
>
>
> f<-function(x){
>
>  for (i in seq(1,length(names(x)),2)){
>
>aa[i]<-do.call(rbind,x[i:i+1])
>
>list(aa[i])
>
>}}
>
> bb<-f (mylist)
>
>
>
> but it doesn’t works
>
>
>
> f<-function(x){
>
> +   for (i in seq(1,length(names(x)),2)){
>
> + aa<-do.call(rbind,x[i:i+1])
>
> + aa
>
> +   }}
>
>> bb<-f(mylist)
>
>> bb
>
> NULL
>
>> f<-function(x){
>
> +   for (i in seq(1,length(names(x)),2)){
>
> + aa<-do.call(rbind,x[i:i+1])
>
> + aa
>
> +   }}
>
>> bb<-f(mylist)
>
>>
>
>> f<-function(x){
>
> +   for (i in seq(1,length(names(x)),2)){
>
> + aa[i]<-do.call(rbind,x[i:i+1])
>
> + list(aa[i])
>
> +   }}
>
>> bb<-f(mylist)
>
> Mensajes de aviso perdidos
>
> 1: In aa[i] <- do.call(rbind, x[i:i + 1]) :
>
>  número de items para para sustituir no es un múltiplo de la longitud
> del reemplazo
>
> 2: In aa[i] <- do.call(rbind, x[i:i + 1]) :
>
>  número de items para para sustituir no es un múltiplo de la longitud
> del reemplazo
>
> 3: In aa[i] <- do.call(rbind, x[i:i + 1]) :
>
>  número de items para para sustituir no es un múltiplo de la longitud
> del reemplazo
>
> 4: In aa[i] <- do.call(rbind, x[i:i + 1]) :
>
>  número de items para para sustituir no es un múltiplo de la longitud
> del reemplazo
>
> 5: In aa[i] <- do.call(rbind, x[i:i + 1]) :
>
>  número de items para para sustituir no es un múltiplo de la longitud
> del reemplazo
>
> 6: In aa[i] <- do.call(rbind, x[i:i + 1]) :
>
>  número de items para para sustituir no es un múltiplo de la longitud
> del reemplazo
>
>
>
>
>
> Thanks!
>
>
>
> Montserrat
>
>
>
>
>   [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius
Alameda, CA, USA

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


Re: [R] rbinding some elements from a list and obtain another list

2013-04-30 Thread De Castro Pascual, Montserrat
Wow! It's true!!!

Many thanks!!!

montserrat

-Mensaje original-
De: MacQueen, Don [mailto:macque...@llnl.gov]
Enviado el: lunes, 29 de abril de 2013 22:39
Para: De Castro Pascual, Montserrat; r-help@r-project.org
Asunto: Re: [R] rbinding some elements from a list and obtain another list

In addition to the other responses, consider this:

> i <- 3
> i:i+1
[1] 4
> i:(i+1)
[1] 3 4

-Don


--
Don MacQueen

Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062





On 4/29/13 6:54 AM, "De Castro Pascual, Montserrat" 
wrote:

>Hi everybody,
>
>
>
>I have a list, where every element of this list is a data frame.
>
>
>
>An example:
>
>
>
>Mylist<-list(A=data.frame, B=data.frame, C=data.frame, D=data.frame)
>
>
>
>I want to rbind some elements of this list.
>
>As an example:
>
>
>
>Output<-list(AB=data.frame, CD=data.frame)
>
>
>
>Where
>
>AB=rbind(A,B)
>
>CD=rbind(C,D)
>
>
>
>
>
>I¹ve tried:
>
>
>
>f<-function(x){
>
>  for (i in seq(1,length(names(x)),2)){
>
>aa<-do.call(rbind,x[i:i+1])
>
>aa
>
>  }}
>
>bb<-f(mylist)
>
>
>
>or
>
>
>
>f<-function(x){
>
>  for (i in seq(1,length(names(x)),2)){
>
>aa[i]<-do.call(rbind,x[i:i+1])
>
>list(aa[i])
>
>}}
>
>bb<-f (mylist)
>
>
>
>but it doesn¹t works
>
>
>
>f<-function(x){
>
>+   for (i in seq(1,length(names(x)),2)){
>
>+ aa<-do.call(rbind,x[i:i+1])
>
>+ aa
>
>+   }}
>
>> bb<-f(mylist)
>
>> bb
>
>NULL
>
>> f<-function(x){
>
>+   for (i in seq(1,length(names(x)),2)){
>
>+ aa<-do.call(rbind,x[i:i+1])
>
>+ aa
>
>+   }}
>
>> bb<-f(mylist)
>
>>
>
>> f<-function(x){
>
>+   for (i in seq(1,length(names(x)),2)){
>
>+ aa[i]<-do.call(rbind,x[i:i+1])
>
>+ list(aa[i])
>
>+   }}
>
>> bb<-f(mylist)
>
>Mensajes de aviso perdidos
>
>1: In aa[i] <- do.call(rbind, x[i:i + 1]) :
>
>  número de items para para sustituir no es un múltiplo de la longitud
>del reemplazo
>
>2: In aa[i] <- do.call(rbind, x[i:i + 1]) :
>
>  número de items para para sustituir no es un múltiplo de la longitud
>del reemplazo
>
>3: In aa[i] <- do.call(rbind, x[i:i + 1]) :
>
>  número de items para para sustituir no es un múltiplo de la longitud
>del reemplazo
>
>4: In aa[i] <- do.call(rbind, x[i:i + 1]) :
>
>  número de items para para sustituir no es un múltiplo de la longitud
>del reemplazo
>
>5: In aa[i] <- do.call(rbind, x[i:i + 1]) :
>
>  número de items para para sustituir no es un múltiplo de la longitud
>del reemplazo
>
>6: In aa[i] <- do.call(rbind, x[i:i + 1]) :
>
>  número de items para para sustituir no es un múltiplo de la longitud
>del reemplazo
>
>
>
>
>
>Thanks!
>
>
>
>Montserrat
>
>
>
>
>   [[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] Mixed Modeling in lme4

2013-04-30 Thread Indrajit Sengupta
Hi All,

I am trying to shift from running mixed models in SAS using PROC MIXED
to using lme4 package in R. In trying to match the coefficients of R
output to that of SAS output, I came across this problem.

The dataset I am using is this one:

http://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_mixed_sect034.htm

If I run the following code:

proc mixed data=rc method=ML covtest;
class Batch;
model Y = Month / s;
random Int Month / type=cs sub=Batch s;
run;

The Fixed effect coefficients match with that of R. But the random
effect does not. Here is the R code:

rc <- read.table('rc.csv', sep = ',', header=T, na.strings=".")

m1 <- lmer(formula = Y ~ Month + (Month|Batch), data = rc, REML = F)

summary(m1)

fixef(m1)

ranef(m1)

But if I change the SAS code as follows:

proc mixed data=rc method=ML covtest;
class Batch;
model Y = Month / s;
random Int / type=cs sub=Batch s;
run;

and the R code as follows:

m2 <- lmer(formula = Y ~ Month + (1|Batch), data = rc, REML = F)

summary(m2)

fixef(m2)

ranef(m2)

both fixed and random effect coefficients match. I am unable to
understand this discrepancy. Am I wrongly specifying the model in the
first case?

It would be helpful if someone can throw some light on this.

Regards,
Indrajit

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


Re: [R] rbinding some elements from a list and obtain another list

2013-04-30 Thread De Castro Pascual, Montserrat
BINGO!!!
Many thanks arun!
You are a genious!!!

montserrat

-Mensaje original-
De: arun [mailto:smartpink...@yahoo.com]
Enviado el: lunes, 29 de abril de 2013 18:33
Para: De Castro Pascual, Montserrat
CC: R help
Asunto: Re: [R] rbinding some elements from a list and obtain another list

Hi,
Try this:
set.seed(24)
 lst1<-lapply(1:4,function(x) 
as.data.frame(matrix(sample(1:20,20,replace=TRUE),ncol=5)))
 names(lst1)<- LETTERS[1:4]

res<-lapply(list(c("A","B"),c("C","D")), function(x) do.call(rbind,lst1[x]))
 res
#[[1]]
 #   V1 V2 V3 V4 V5
#A.1  6 14 17 14  4
#A.2  5 19  6 14  1
#A.3 15  6 13  7 11
#A.4 11 16  8 19  3
#B.1  2  5 13  8 15
#B.2 12 14  1  3 13
#B.3 15  2  7 19 14
#B.4  3 12  5  5 20
#
#[[2]]
 #   V1 V2 V3 V4 V5
#C.1 10  1  6 10 10
#C.2  8  2  7 15  6
#C.3  6  8 10 11  4
#C.4  5  8 18 20  3
#D.1 10 15 15  1 12
#D.2  5  7 10 20 17
#D.3  6 19  3 13  1
#D.4  3 20  5  7 15
A.K.





- Original Message -
From: "De Castro Pascual, Montserrat" 
To: r-help@r-project.org
Cc:
Sent: Monday, April 29, 2013 9:54 AM
Subject: [R] rbinding some elements from a list and obtain another list

Hi everybody,



I have a list, where every element of this list is a data frame.



An example:



Mylist<-list(A=data.frame, B=data.frame, C=data.frame, D=data.frame)



I want to rbind some elements of this list.

As an example:



Output<-list(AB=data.frame, CD=data.frame)



Where

AB=rbind(A,B)

CD=rbind(C,D)





I’ve tried:



f<-function(x){

  for (i in seq(1,length(names(x)),2)){

aa<-do.call(rbind,x[i:i+1])

aa

  }}

bb<-f(mylist)



or



f<-function(x){

  for (i in seq(1,length(names(x)),2)){

aa[i]<-do.call(rbind,x[i:i+1])

list(aa[i])

}}

bb<-f (mylist)



but it doesn’t works



f<-function(x){

+   for (i in seq(1,length(names(x)),2)){

+ aa<-do.call(rbind,x[i:i+1])

+ aa

+   }}

> bb<-f(mylist)

> bb

NULL

> f<-function(x){

+   for (i in seq(1,length(names(x)),2)){

+ aa<-do.call(rbind,x[i:i+1])

+ aa

+   }}

> bb<-f(mylist)

>

> f<-function(x){

+   for (i in seq(1,length(names(x)),2)){

+ aa[i]<-do.call(rbind,x[i:i+1])

+ list(aa[i])

+   }}

> bb<-f(mylist)

Mensajes de aviso perdidos

1: In aa[i] <- do.call(rbind, x[i:i + 1]) :

  número de items para para sustituir no es un múltiplo de la longitud del 
reemplazo

2: In aa[i] <- do.call(rbind, x[i:i + 1]) :

  número de items para para sustituir no es un múltiplo de la longitud del 
reemplazo

3: In aa[i] <- do.call(rbind, x[i:i + 1]) :

  número de items para para sustituir no es un múltiplo de la longitud del 
reemplazo

4: In aa[i] <- do.call(rbind, x[i:i + 1]) :

  número de items para para sustituir no es un múltiplo de la longitud del 
reemplazo

5: In aa[i] <- do.call(rbind, x[i:i + 1]) :

  número de items para para sustituir no es un múltiplo de la longitud del 
reemplazo

6: In aa[i] <- do.call(rbind, x[i:i + 1]) :

  número de items para para sustituir no es un múltiplo de la longitud del 
reemplazo





Thanks!



Montserrat




[[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] Error message after R-3.0.0 upgrade installation

2013-04-30 Thread Prof Brian Ripley

On 30/04/2013 07:44, Anupam Tyagi wrote:

R-3.0.0 prints an error message at startup. I uninstalled a previous
version and installed this on Windows 8. Uninstall of previous version
deleted all previously installed packages and I forgot to keep a list
of them. How do I correct this error?

"
Error: requested primitive type is not consistent with catched value
Error: requested primitive type is not consistent with catched value



Really?  That is not the message from R 3.0.0 (it says 'cached').

So you are not telling us the whole story, and we cannot help until you do.

If you have not already, try starting R with --vanilla.  If that works, 
the issue is a saved workspace file (a .RData file) that needs to be 
moved out of the way.



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