[R] How to obtain restricted estimates from coxph()?

2013-10-15 Thread Y
Hello,

I'm trying to use coxph() function to fit a very simple Cox proportional
hazards regression model (only one covariate) but the parameter space is
restricted to an open set (0, 1). Can I still obtain a valid estimate by
using coxph function in this scenario? If yes, how? Any suggestion would be
greatly appreciated. Thanks!!!

[[alternative HTML version deleted]]

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


Re: [R] some addition in the codes

2013-10-15 Thread arun
Hi Eliza,

Some lines of code in the end didn't look very convincing for me.  (I didn't 
change it anyway). For example:
#
 amata<-data.frame(amata)
aavg<-as.matrix(amata, ncol=1)
b<-aavg
sss<-(max(b)+max(amata))/2



Also, multiple objects of the same name were created through out the code, 
which makes it bit hard.


##solution

  Eliz <- load("/home/arunksa111/Downloads/Elizaaa.RData" )

Dm <- `Dm`
ffr <- `ffr`
 j <- `j`
 m <- `m`

d15<-Dm/mean(Dm) 
dr1<-ffr/mean(ffr) 
t<-as.matrix((d15)+(dr1))
w<-sqrt(t)
mat1<-w
zz<-w  ## multiple objects!!
rlst<- lapply(1:124,function(i) 
matrix(sort(as.matrix(zz)[i,],index.return=TRUE)$ix,ncol=1))


rlstN <- lapply(rlst,function(x) {
                u<- x[2:8,1]
                mata <- m[,u]
                 a <- matrix(rowMeans(mata),ncol=1)
                 mat <- cbind(j,a)
                lst1<-lapply(split(mat,col(mat)),function(x){
                            big<- x>0.8*max(x)
                             n<- length(big)
                            startRunOfBigs<- which(c(big[1],!big[-n] & big[-1]))
                            endRunOfBigs<- which(c(big[-n] & !big[-1], big[n]))
                    index<- vapply(seq_along(startRunOfBigs),function(i) 
which.max(x[startRunOfBigs[i]:endRunOfBigs[i]])+startRunOfBigs[i]-1L,0L)        
                 index<-ifelse(sum(is.na(match(index,c(1,12==0 & 
x[index]!=max(x[index]), NA,index)
                    
data.frame(Index=index[!is.na(index)],Value=x[index[!is.na(index)]])  
                    })
         nm <- lapply(lst1,function(x) x$Index)
            max_length<- max(unlist(lapply(nm,length)))
           nm_filled<-lapply(nm,function(x){
                    ans<- rep(NA,length=max_length)
                 ans[1:length(x)]<- x
                    return(ans)
                    })
            xx<-do.call(cbind,nm_filled)  ##didn't see this part being used in 
the end
             mat})


###Using a subset of list elements

srlstN <- rlstN[61:62]
library(hydroGOF)

res <-  lapply(srlstN, function(x) {
                    i<- as.list(fun3(x))
  xx<- do.call(cbind,i)
 xx<- t(xx)
 x1 <- matrix(xx,nrow=1)
 y <- matrix(0,nrow=125,ncol=125)
 y[lower.tri(y)]<- x1
 yy <- as.dist(y)
 list1<- lapply(seq_len(ncol(x)),function(j) 
t(apply(x,1,function(u) u[j]-u)))
 x2<- matrix(unlist(list1),ncol=15625)
 x2<- abs(x2)
 y1 <- colSums(x2,na.rm=FALSE)
                z1 <- matrix(y1,ncol=125)
 zz <- as.dist(z1)
                x3 <- apply(x,2,max)
 xx1 <- dist(x3) 

 xx1[yy==0] <-0
 ff <- zz+yy+xx1
 r <- 
matrix(sort(as.matrix(ff)[125,],index.return=TRUE)$ix,ncol=1)
                u1 <- r[2:8,1]
 mata <- x[,u1]
 amata <- data.frame(rowMeans(mata))
 aavg <- as.matrix(amata, ncol=1)
 sss <- (max(aavg)+max(amata))/2
  aavg[which(aavg==max(aavg))] <- sss
 mat2<- do.call(rbind,lapply(seq_len(ncol(x)), function(j){
                                                                            RRR 
<- rmse(aavg,matrix(x[,j],ncol=1))
    UUU 
<- NSE(aavg,matrix(x[,j],ncol=1))
 cc 
<- sum(abs(aavg - x[,j]))
 
c(RRR,UUU,cc) 

                                                                                
}))
 colnames(mat2) <- c("RRR","UUU","cc")
 mat2 

 })
 head(res[[1]])
#   RRR    UUU    cc
#[1,] 0.3830867  0.5155312  3.617801
#[2,] 0.5149736 -0.6779912  4.194520
#[3,] 1.4246430 -1.3620793 15.116817
#[4,] 1.0875600 -1.4012783 11.170334
#[5,] 1.3309777 -0.8873588 14.078342
#[6,] 0.2056404  0.9170877  1.959848


A.K.









On Tuesday, October 15, 2013 12:08 PM, eliza botto  
wrote:


Dear Arun,
You once helped prepared me following codes for my work. Now i automatically 
want to replace "61" in all the four steps indicated with ">" in the 
beginning, with 1,2,3,4, 124 so that i have three lists in the end each 
for  RRR, UU and cc.
Can it be done? I hope i am clear in my question.
Thanks in advance


Eliza

## d15 and dr1 are  distance matrices of 8*8 dimensions


d15<-Dm/mean(Dm) 
dr1<-ffr/mean(ffr) 
t<-as.matrix((d15)+(dr1))
w<-sqrt(t)
mat1<-w
zz<-w
>r<-matrix(sort(as.matrix(zz)[61,],index.return=TRUE)$ix,ncol=1)
u<-r[c(2,3,4,5,6,7,8),1]
mata<-m[,c(u)]##(shifted)
amata<-apply(mata,1,mean)
amata<-data.frame(amata)
aavg<-as.matrix(amata, ncol=1)
a<-aavg

## j is matrix of 8 rows and 2 columns
m<-cbind(j,a)
mat<-m
 lst1<-lapply(split(mat,col(mat)),function(x){big<- x>0.8*max(x); 

[R] Math notation in a title

2013-10-15 Thread David Arnold
Hi,

I'd like to put the following in a main title of a plot.

 

Can someone show me how to do this?

Thanks.

D.



--
View this message in context: 
http://r.789695.n4.nabble.com/Math-notation-in-a-title-tp4678299.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Gaussian Quadrature for arbitrary PDF

2013-10-15 Thread Spencer Graves
On 10/15/2013 5:37 PM, Marino David wrote:
> Hi Spencer:
>
> Thanks for your interpretation again and again.  Your statement does 
> enable me to have a good understanding of Gaussian quadrature.
>
> This sos package you recommended is greatly powerful. From now on, I 
> will use the sos package to find something helpful before I do some 
> research.
>
> Yes, I want to compute the expection of functions whos variables 
> follow common distriubtions (e.g. F, t, Beta, Gamma, etc.). Via 
> searching referrences, I know that Gaussian quadrature  based 
> on orthogonal polynomials is fast method for integration.


   Often, the most expensive part of any data analysis is the time 
of the person doing it.  For that reason, it's often wise to first try 
the quickest thing available.  Just for fun, I performed the following 
tests on the F distribution:


f. <- Fd(1,1)
sinF <- sin(f.)
E(sinF)
# 0.2093619


   This didn't work for round(sinF).  For that, we can try the 
following:


rf. <- r(sinF)(1)
mean(round(rf.))
# 0.197


   If I were only doing this once, I wouldn't mess with quadrature.  
If the options like "integrate" or the above take too much compute time, 
then I'll consider other options, like numerical integration with 
quadrature.  However, orthogonal polynomials for a continuous 
distribution won't work properly with a discontinuous transformation 
like round ;-)


   Hope this helps.
   Spencer


> David
>
>
> 2013/10/14 Spencer Graves  >
>
> David:
>
>
>   What you have is close, but I perceive some problems:
>
>
> integral{from -Inf to Inf of f(x)t(x)dx} =
> integral{from 0 to Inf of (f(-x)+f(x))t(x)dx}, because Student's t
> distribution is symmetric.
>
>
>   Now do the change of variables x = sqrt(z), so dx =
> 0.5*dz/sqrt(z).  Then t(x)dx = 0.5*t(sqrt(z))dz/sqrt(z).  Play
> with this last expression a bit, and you should get it into the
> form of g(z)dz, where g(z) = the density for the F distribution.
>
>
>   Next transform the F distribution to a beta distribution on
> [0, 1], NOT a beta distribution on [-1, 1].  There are Jacobi
> polynomials on [0, 1] you can use.  Or further transform the
> interval [0, 1] to [-1, 1].
>
>
>   Did you look at the literature search results I sent you
> using findFn{sos}?  When I need to do something new in statistics,
> the first thing I do is a literature search like I described,
> ending with using the installPackages and writeFindFn2xls
> functions, as described in the sos vignette.  That rarely takes
> more than a minute or two.  The writeFindFn2xls function should
> create an Excel file in your working directory, which you can find
> with getwd().  Open that.  The first sheet is a summary of the
> different packages.  This gives you a list of different packages. 
> You can then use that to prioritize your further study.
>
>
>   Two more comments:
>
>
> 1.  It is conceptually quite simple to write an
> algorithm to compute polynomials that are orthonormal relative to
> any distribution.  The Wikipedia article on "Orthogonal
> polynomials" gives a set of linear equations that must be solved
> to create them.
>
>
> 2.  Why do you want orthogonal polynomials? To obtain
> a very fast algorithm for computing the expected values of a
> certain class of functions?  If no, have you considered doing
> without orthogonal polynomials and just computing the expected
> value of whatever function you want using the distr package to
> compute the distribution of f(X) and E{distrEx} to compute the
> expected value?
>
>
>   Best Wishes,
>   Spencer
>
>
> p.s.  Could you please post a summary of this exchange to R-help,
> so someone else with a similar question a year from now can find
> it?  Thanks.
>
>
> On 10/13/2013 10:12 PM, Marino David wrote:
>> Hi Spencer:
>>
>> I still have trouble in understanding your response to email
>> about Gaussian quadrature. I tried to describe it in detail. See
>> attachment.
>>
>> Thank you!
>>
>> David
>
>
> -- 
> Spencer Graves, PE, PhD
> President and Chief Technology Officer
> Structure Inspection and Monitoring, Inc.
> 751 Emerson Ct.
> San José, CA 95126
> ph:408-655-4567  
> web:www.structuremonitoring.com  
>
>


-- 
Spencer Graves, PE, PhD
President and Chief Technology Officer
Structure Inspection and Monitoring, Inc.
751 Emerson Ct.
San José, CA 95126
ph:  408-655-4567
web:  www.structuremonitoring.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/postin

Re: [R] Gaussian Quadrature for arbitrary PDF

2013-10-15 Thread Marino David
Hi Spencer:

Thanks for your interpretation again and again.  Your statement does enable
me to have a good understanding of  Gaussian quadrature.

This sos package you recommended is greatly powerful. From now on, I will
use the sos package to find something helpful before I do some research.

Yes, I want to compute the expection of functions whos variables follow
common distriubtions (e.g. F, t, Beta, Gamma, etc.). Via searching
referrences, I know that Gaussian quadrature  based on orthogonal
polynomials is fast method for integration.

David


2013/10/14 Spencer Graves 

>  David:
>
>
>   What you have is close, but I perceive some problems:
>
>
> integral{from -Inf to Inf of f(x)t(x)dx} = integral{from 0 to
> Inf of (f(-x)+f(x))t(x)dx}, because Student's t distribution is symmetric.
>
>
>   Now do the change of variables x = sqrt(z), so dx = 0.5*dz/sqrt(z).
> Then t(x)dx = 0.5*t(sqrt(z))dz/sqrt(z).  Play with this last expression a
> bit, and you should get it into the form of g(z)dz, where g(z) = the
> density for the F distribution.
>
>
>   Next transform the F distribution to a beta distribution on [0, 1],
> NOT a beta distribution on [-1, 1].  There are Jacobi polynomials on [0, 1]
> you can use.  Or further transform the interval [0, 1] to [-1, 1].
>
>
>   Did you look at the literature search results I sent you using
> findFn{sos}?  When I need to do something new in statistics, the first
> thing I do is a literature search like I described, ending with using the
> installPackages and writeFindFn2xls functions, as described in the sos
> vignette.  That rarely takes more than a minute or two.  The
> writeFindFn2xls function should create an Excel file in your working
> directory, which you can find with getwd().  Open that.  The first sheet is
> a summary of the different packages.  This gives you a list of different
> packages.  You can then use that to prioritize your further study.
>
>
>   Two more comments:
>
>
> 1.  It is conceptually quite simple to write an algorithm to
> compute polynomials that are orthonormal relative to any distribution.  The
> Wikipedia article on "Orthogonal polynomials" gives a set of linear
> equations that must be solved to create them.
>
>
> 2.  Why do you want orthogonal polynomials?  To obtain a very
> fast algorithm for computing the expected values of a certain class of
> functions?  If no, have you considered doing without orthogonal polynomials
> and just computing the expected value of whatever function you want using
> the distr package to compute the distribution of f(X) and E{distrEx} to
> compute the expected value?
>
>
>   Best Wishes,
>   Spencer
>
>
> p.s.  Could you please post a summary of this exchange to R-help, so
> someone else with a similar question a year from now can find it?  Thanks.
>
>
>
> On 10/13/2013 10:12 PM, Marino David wrote:
>
> Hi Spencer:
>
>  I still have trouble in understanding your response to email
> about Gaussian quadrature. I tried to describe it in detail. See attachment.
>
>  Thank you!
>
>  David
>
>
>
> --
> Spencer Graves, PE, PhD
> President and Chief Technology Officer
> Structure Inspection and Monitoring, Inc.
> 751 Emerson Ct.
> San José, CA 95126
> ph:  408-655-4567
> web:  www.structuremonitoring.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] Assign date according to defined time interval

2013-10-15 Thread arun
Hi,

Please use ?dput() to show the dataset.  Also, it is not clear about how you 
store the time interval.
dat <- read.table(text="
GroupID    Date
1  1  10-Dec-12
2  1  11-Dec-12
3  2  13-Dec-12
4  2  15-Dec-12
5  3  06-Dec-12
6  3  19-Dec-12",sep="",header=TRUE,stringsAsFactors=FALSE)



 dat2 <- data.frame(Week=1:2, from= c("9-Dec-12", "16-Dec-12"), 
to=c("15-Dec-12","22-Dec-12"),stringsAsFactors=FALSE)

#Check ?findInterval()

res <- t(sapply(split(dat,dat$GroupID), function(x) {
                            x$Date <-as.Date(x$Date,"%d-%b-%y")
                             unsplit(lapply(split(dat2,dat2$Week),function(y) {
                                        y$from <- as.Date(y$from, "%d-%b-%y")
                                         y$to <- as.Date(y$to, "%d-%b-%y")
                                         sum(x$Date > y$from & x$Date <= 
y$to)}),
                                                    dat2$Week)
                          }))

colnames(res) <- paste0("Week",1:2)
 res
#  Week1 Week2
#1 2 0
#2 2 0
#3 0 1


A.K.










On Tuesday, October 15, 2013 6:24 PM, Weijia Wang  wrote:
Hi, I have something very interesting:

Say I have this:

GroupID         Date
1      1       10-Dec-12
2      1       11-Dec-12
3      2       13-Dec-12
4      2       15-Dec-12
5      3       06-Dec-12
6      3       19-Dec-12

Now, I have time interval,

week 1: from 9-Dec-12 to 15-Dec-12,

week 2: from 16-Dec-12 to 22-Dec-12, and so on.

Obviously, the 1st, 2nd, 3rd, 4th row falls to week 1, 5th rows should not
be counted, 6th row falls into week2.

Therefore, by GroupID, I will have

GroupID=1, Week1=2, Week2=0
GroupID=2, Week1=2, Week2=0
GroupID=3, Week1=0, Week2=1.

I just want to count the valid date that falls into a 7-day week interval,
and I shall have new variables for EACH WEEK, and the counts for dates that
fall into this week interval.

Can anyone please help me on programming this?

W

    [[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] A 'good' way to build a matrix from a sequence of integers?

2013-10-15 Thread arun


Hi,

You could use:
 as.matrix(expand.grid(vec1x3,vec1x3))
#or
as.matrix(expand.grid(rep(list(vec1x3),2)))
#or
library(gtools)
permutations(3, 2, vec1x3, repeats.allowed=TRUE)

A.K.



On Tuesday, October 15, 2013 7:14 PM, Stock Beaver  
wrote:
# I understand that a good way to build a vector from a sequence of integers,
# is to use syntax like this:
myvec = c(1:99)

# Here is the 'short' version of my question:
# I want to understand a 'good' way to build a matrix from a sequence of 
integers.

# If that question is not clear, here is a longer version:

# Here is what I did for a 1D-matrix:

# I pick the sequence 1:3
# I build a vector:
vec1x3 = c(1:3)
vec1x3
# I transform it into a 1 x 3 matrix:
m1x3 = matrix(vec1x3, c(length(vec1x3),1))
m1x3
#  [,1]
# [1,]    1
# [2,]    2
# [3,]    3
# > 

# That was easy.

# Next I want to expand from a 1 x 3 matrix to a 2 x 9 matrix
# which contains all combinations of 1:3

# So the first 4 rows would look like this:
# 1 1
# 1 2
# 1 3 I call this a rowvec
# 2 1

# My first idea is write a loop like this:

for (i in 1:3) {
  for(j in 1:3) {
    rowvec = c(i,j)
    # Place rowvec in matrix
  }
}

# I'm curious if a skilled R-person would do it differently?
    [[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] A 'good' way to build a matrix from a sequence of integers?

2013-10-15 Thread Kevin E. Thorpe

On 10/15/2013 07:11 PM, Stock Beaver wrote:

# I understand that a good way to build a vector from a sequence of integers,
# is to use syntax like this:
myvec = c(1:99)


First, the c() is not needed here.

myvec <- 1:99

works just fine.



# Here is the 'short' version of my question:
# I want to understand a 'good' way to build a matrix from a sequence of 
integers.

# If that question is not clear, here is a longer version:

# Here is what I did for a 1D-matrix:

# I pick the sequence 1:3
# I build a vector:
vec1x3 = c(1:3)
vec1x3
# I transform it into a 1 x 3 matrix:
m1x3 = matrix(vec1x3, c(length(vec1x3),1))
m1x3
#  [,1]
# [1,]1
# [2,]2
# [3,]3
# >

# That was easy.

# Next I want to expand from a 1 x 3 matrix to a 2 x 9 matrix
# which contains all combinations of 1:3


I think you want expand.grid.

expand.grid(x1=1:3, x2=1:3)



# So the first 4 rows would look like this:
# 1 1
# 1 2
# 1 3 I call this a rowvec
# 2 1

# My first idea is write a loop like this:

for (i in 1:3) {
   for(j in 1:3) {
 rowvec = c(i,j)
 # Place rowvec in matrix
   }
}

# I'm curious if a skilled R-person would do it differently?
[[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.




--
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] A 'good' way to build a matrix from a sequence of integers?

2013-10-15 Thread Stock Beaver
# I understand that a good way to build a vector from a sequence of integers,
# is to use syntax like this:
myvec = c(1:99)

# Here is the 'short' version of my question:
# I want to understand a 'good' way to build a matrix from a sequence of 
integers.

# If that question is not clear, here is a longer version:

# Here is what I did for a 1D-matrix:

# I pick the sequence 1:3
# I build a vector:
vec1x3 = c(1:3)
vec1x3
# I transform it into a 1 x 3 matrix:
m1x3 = matrix(vec1x3, c(length(vec1x3),1))
m1x3
#  [,1]
# [1,]    1
# [2,]    2
# [3,]    3
# > 

# That was easy.

# Next I want to expand from a 1 x 3 matrix to a 2 x 9 matrix
# which contains all combinations of 1:3

# So the first 4 rows would look like this:
# 1 1
# 1 2
# 1 3 I call this a rowvec
# 2 1

# My first idea is write a loop like this:

for (i in 1:3) {
  for(j in 1:3) {
    rowvec = c(i,j)
    # Place rowvec in matrix
  }
}

# I'm curious if a skilled R-person would do it differently?
[[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] Math notation in a title

2013-10-15 Thread Peter Lomas
check out:  demo("plotmath")


On Tue, Oct 15, 2013 at 4:30 PM, arun  wrote:

> Hi,
> Try:
> plot(1,main=bquote("Pareto Distribution: " ~ alpha == 2 * ","
> ~italic(y[m]) == 3))
>
>
> A.K.
>
>
> Hi,
>
> I'd like to put the following in a main title of a plot.
>
>
>
> Can someone show me how to do this?
>
> Thanks.
>
> D.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Math notation in a title

2013-10-15 Thread arun
Hi,
Try:
plot(1,main=bquote("Pareto Distribution: " ~ alpha == 2 * "," ~italic(y[m]) == 
3))


A.K.


Hi, 

I'd like to put the following in a main title of a plot. 



Can someone show me how to do this? 

Thanks. 

D.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Assign date according to defined time interval

2013-10-15 Thread Weijia Wang
Hi, I have something very interesting:

Say I have this:

 GroupID Date
1  1   10-Dec-12
2  1   11-Dec-12
3  2   13-Dec-12
4  2   15-Dec-12
5  3   06-Dec-12
6  3   19-Dec-12

Now, I have time interval,

week 1: from 9-Dec-12 to 15-Dec-12,

week 2: from 16-Dec-12 to 22-Dec-12, and so on.

Obviously, the 1st, 2nd, 3rd, 4th row falls to week 1, 5th rows should not
be counted, 6th row falls into week2.

Therefore, by GroupID, I will have

GroupID=1, Week1=2, Week2=0
GroupID=2, Week1=2, Week2=0
GroupID=3, Week1=0, Week2=1.

I just want to count the valid date that falls into a 7-day week interval,
and I shall have new variables for EACH WEEK, and the counts for dates that
fall into this week interval.

Can anyone please help me on programming this?

W

[[alternative HTML version deleted]]

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


Re: [R] Problem with lapply

2013-10-15 Thread arun
Hi,

No problem.
Regarding your code:

#changed name from 'dataset' to "Testcor"
#Your code

  firm.names=colnames(Testcor)[2:length(colnames(Testcor))]
 firm.names
# [1] "PAXN"   "PED"    "PEDP"   "PM" "PRFN"   "PRWN"   "ZG" "ZUBN"  
 #[9] "ZURN"   "ZWM"    "Market" #includes "Market"

#If you look my code:
firm.names <- colnames(Testcor)[!grepl("DATE|Market",colnames(Testcor))]
 firm.names
# [1] "PAXN" "PED"  "PEDP" "PM"   "PRFN" "PRWN" "ZG"   "ZUBN" "ZURN" "ZWM" 

If you wanted to use the "formula" method:
res1 <- sapply(firm.names,function(x) { cor.results <- 
cor.test(as.formula(paste("~", paste(x,"Market", sep="+")) 
),data=Testcor,na.action=na.exclude); cor.results$estimate})
res1
#   PAXN.cor PED.cor    PEDP.cor  PM.cor    PRFN.cor    PRWN.cor 
#-0.31113122 -0.09359550 -0.17056943  0.40025112  0.34385888  0.17935045 
 #    ZG.cor    ZUBN.cor    ZURN.cor ZWM.cor 
 #0.20762797  0.39238270  0.74336028 -0.09166795 
 identical(res,res1)
#[1] TRUE

#or just
res2 <- sapply(firm.names,function(x) { cor.test(~get(x) + 
Market,data=Testcor,na.action=na.exclude)$estimate })
 identical(res,res2)
#[1] TRUE



A.K.






On Tuesday, October 15, 2013 3:15 PM, rissa  wrote:
Thank you! Worked perfectly!

By the way: What was wrong with my original code?



--
View this message in context: 
http://r.789695.n4.nabble.com/Problem-with-lapply-tp4678290p4678305.html

Sent from the R help mailing list archive at Nabble.com.

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


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


Re: [R] bug(?) in str() with strict.width = "cut" when applied to dataframe with numeric component AND factor or character component with longerlevels/strings

2013-10-15 Thread Duncan Murdoch

On 15/10/2013 7:53 AM, Gerrit Eichner wrote:

Dear list subscribers,

here is a small artificial example to demonstrate the problem that I
encountered when looking at the structure of a (larger) data frame that
comprised (among other components)

a numeric component of elements of the order of > 1, and

a factor or character component with longer levels/strings:


k <- 43  # length of levels or character strings
n <- 11  # number of rows of data frame
M <- 1   # order of magnitude of numerical values

set.seed( 47) # to reproduce the following artificial character string
longer.char.string <- paste( sample( letters, k, replace = TRUE),
   collapse = "")

X <- data.frame( A = 1:n * M,
   B = rep( longer.char.string, n))


The following call to str() gives apparently a wrong result

str( X, strict.width = "cut")

'data.frame':   11 obs. of  2 variables:
   $ A: num  1e+04 2e+04 3e+04 4e+04 5e+04 6e+04 7e+04 8e+04 9e+04 1e+..
   $ A: num  1e+04 2e+04 3e+04 4e+04 5e+04 6e+04 7e+04 8e+04 9e+04 1e+..


whereas the correct result appears for str( X) or if you decrease k to 42
(isn't that "the answer"? ;-) ) or n to 10 or M to 1000 (or smaller,
respectively).


I tried to dig into the entrails of str.default(), where the cause may
lie, but got lost pretty soon. So, I am hoping that someone may already
have a work-around or patch (or dares to dig further)? Thank you for any
feedback!


I can't reproduce this.  I don't have a 64 bit copy of 3.0.2 handy, but 
I don't see it in 64 bit 3.0.1, or 64 bit 3.0.2-patched, or various 32 
bit versions.


Is it reproducible for you?  It looks to me as though (if it isn't just 
something weird on your system, e.g. an old copy of str() in your 
workspace), it might be a memory protection problem:  something needed 
to be duplicated but wasn't.  But unless I can see it happen, I can't 
start to fix it.


Duncan Murdoch



   Best regards  --  Gerrit

PS:

> sessionInfo()

R version 3.0.2 (2013-09-25)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=German_Germany.1252  LC_CTYPE=German_Germany.1252
[3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C
[5] LC_TIME=German_Germany.1252

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

other attached packages:
[1] nparcomp_2.0 multcomp_1.2-21  mvtnorm_0.9-9996
[4] car_2.0-19   Hmisc_3.12-2 Formula_1.1-1
[7] survival_2.37-4  fortunes_1.5-0

loaded via a namespace (and not attached):
[1] cluster_1.14.4  grid_3.0.2  lattice_0.20-23 MASS_7.3-29
[5] nnet_7.3-7  rpart_4.1-3 stats4_3.0.2tools_3.0.2

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

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


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 set pch in auto.key for splom

2013-10-15 Thread arun


Hi,
May be this helps:
library(lattice)
splom(~iris[1:4], groups = iris$Species,pch=1:3, 
par.settings=list(superpose.symbol=list(pch=1:3)),auto.key = list(space = 
'top',columns=3))

A.K.



On Tuesday, October 15, 2013 3:01 PM, John Smith  wrote:
Dear All,

I am using most current version of R (3.0.2) and lattice (0.20-24). But can
not set appropriate pch type with the following code. Could anyone help me?



splom(~iris[1:4], groups = iris$Species, pch=1:3, auto.key = list(space =
'top', columns = 3, pch=1:3))


Thanks

John

    [[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] Problem with lapply

2013-10-15 Thread rissa
Thank you! Worked perfectly!

By the way: What was wrong with my original code?



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

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


Re: [R] project parallel help

2013-10-15 Thread Jeff Newmiller
As parameters. For example, if you have 100 simulations, set up a list of 4 
distinct sets of data (1:25, 26:50, etc) and call the single-threaded 
processing function from parLapply iterated four times. Then each instance of 
the processing function won't return until it has completed 25 simulations.
---
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.

Jeffrey Flint  wrote:
>How can I copy distinct blocks of data to each process?
>
>On Mon, Oct 14, 2013 at 10:21 PM, Jeff Newmiller
> wrote:
>> The session info is helpful. To the best of my knowledge there is no
>easy way to share memory between R processes other than forking. You
>can use clusterExport to make "global" copies of large data structures
>in each process and pass index values to your function to reduce copy
>costs at a price of extra data copies in each process that won't be
>used. Or you can copy distinct blocks of data to each process and use
>single threaded processing to loop over the blocks within the workers
>to reduce the number of calls to workers. However I don't claim to be
>an expert with the parallel package, so others may have better advice. 
>However, with two cores I don't usually get better than a 30%
>speedup... the best payoff comes with four or more workers working.
>>
>---
>> 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.
>>
>> Jeffrey Flint  wrote:
>>>Jeff:
>>>
>>>Thank you for your response.  Please let me know how I can
>>>"unhandicap" my question.  I tried my best to be concise.  Maybe this
>>>will help:
>>>
 version
>>>   _
>>>platform   i386-w64-mingw32
>>>arch   i386
>>>os mingw32
>>>system i386, mingw32
>>>status
>>>major  3
>>>minor  0.2
>>>year   2013
>>>month  09
>>>day25
>>>svn rev63987
>>>language   R
>>>version.string R version 3.0.2 (2013-09-25)
>>>nickname   Frisbee Sailing
>>>
>>>
>>>I understand your comment about forking.  You are right that forking
>>>is not available on windows.
>>>
>>>What I am curious about is whether or not I can direct the execution
>>>of the parallel package's functions to diminish the overhead.  My
>>>guess is that there is overhead in copying the function to be
>executed
>>>at each iteration and there is overhead in copying the data to be
>used
>>>at each iteration.  Are there any paradigms in the package parallel
>to
>>>reduce these overheads?  For instance, I could use clusterExport to
>>>establish the function to be called.  But I don't know if there is a
>>>technique whereby I could point to the data to be used by each CPU so
>>>as to prevent a copy.
>>>
>>>Jeff
>>>
>>>
>>>
>>>On Mon, Oct 14, 2013 at 2:35 PM, Jeff Newmiller
>>> wrote:
 Your question misses on several points in the Posting Guide so any
>>>answers are handicapped by you.

 There is an overhead in using parallel processing, and the value of
>>>two cores is marginal at best. In general parallel by forking is more
>>>efficient than parallel by SNOW, but the former is not available on
>all
>>>operating systems. This is discussed in the vignette for the parallel
>>>package.

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

 Jeffrey Flint  wrote:
>I'm running package parallel in R-3.0.2.
>
>Below are the execution times using system.time for when executing
>serially versus in parallel (with 2 cores) using parRapply.
>
>
>Serially:

[R] how to set pch in auto.key for splom

2013-10-15 Thread John Smith
Dear All,

I am using most current version of R (3.0.2) and lattice (0.20-24). But can
not set appropriate pch type with the following code. Could anyone help me?



splom(~iris[1:4], groups = iris$Species, pch=1:3, auto.key = list(space =
'top', columns = 3, pch=1:3))


Thanks

John

[[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] project parallel help

2013-10-15 Thread Jeffrey Flint
How can I copy distinct blocks of data to each process?

On Mon, Oct 14, 2013 at 10:21 PM, Jeff Newmiller
 wrote:
> The session info is helpful. To the best of my knowledge there is no easy way 
> to share memory between R processes other than forking. You can use 
> clusterExport to make "global" copies of large data structures in each 
> process and pass index values to your function to reduce copy costs at a 
> price of extra data copies in each process that won't be used. Or you can 
> copy distinct blocks of data to each process and use single threaded 
> processing to loop over the blocks within the workers to reduce the number of 
> calls to workers. However I don't claim to be an expert with the parallel 
> package, so others may have better advice.  However, with two cores I don't 
> usually get better than a 30% speedup... the best payoff comes with four or 
> more workers working.
> ---
> 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.
>
> Jeffrey Flint  wrote:
>>Jeff:
>>
>>Thank you for your response.  Please let me know how I can
>>"unhandicap" my question.  I tried my best to be concise.  Maybe this
>>will help:
>>
>>> version
>>   _
>>platform   i386-w64-mingw32
>>arch   i386
>>os mingw32
>>system i386, mingw32
>>status
>>major  3
>>minor  0.2
>>year   2013
>>month  09
>>day25
>>svn rev63987
>>language   R
>>version.string R version 3.0.2 (2013-09-25)
>>nickname   Frisbee Sailing
>>
>>
>>I understand your comment about forking.  You are right that forking
>>is not available on windows.
>>
>>What I am curious about is whether or not I can direct the execution
>>of the parallel package's functions to diminish the overhead.  My
>>guess is that there is overhead in copying the function to be executed
>>at each iteration and there is overhead in copying the data to be used
>>at each iteration.  Are there any paradigms in the package parallel to
>>reduce these overheads?  For instance, I could use clusterExport to
>>establish the function to be called.  But I don't know if there is a
>>technique whereby I could point to the data to be used by each CPU so
>>as to prevent a copy.
>>
>>Jeff
>>
>>
>>
>>On Mon, Oct 14, 2013 at 2:35 PM, Jeff Newmiller
>> wrote:
>>> Your question misses on several points in the Posting Guide so any
>>answers are handicapped by you.
>>>
>>> There is an overhead in using parallel processing, and the value of
>>two cores is marginal at best. In general parallel by forking is more
>>efficient than parallel by SNOW, but the former is not available on all
>>operating systems. This is discussed in the vignette for the parallel
>>package.
>>>
>>---
>>> 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.
>>>
>>> Jeffrey Flint  wrote:
I'm running package parallel in R-3.0.2.

Below are the execution times using system.time for when executing
serially versus in parallel (with 2 cores) using parRapply.


Serially:
   user  system elapsed
   4.670.034.71



Using package parallel:
   user  system elapsed
   3.820.126.50



There is evident improvement in the user cpu time, but a big jump in
the elapsed time.

In my code, I am executing a function on a 1000 row matrix 100 times,
with the data different each time of course.

The initial call to makeCluster cost 1.25 seconds in elapsed time.
I'm not concerned about the makeCluster time since that is a fixed
cost.  I am concerned about the additional 1.43 seconds in elapsed
time (6.50=1.43+1.25).

I am wondering if there is a way to structure the code to avoid
largely avoid the 1.43 second overhead.  For instance, perhaps I
>>could
upload the function to both cores manually in order to avoid the
function being uploaded at each of the 100 iterations?Also, I am
wondering if there is

Re: [R] Problem with lapply

2013-10-15 Thread arun


Hi,
Try:
Testcor <- read.table("Testcor.txt",sep="",header=TRUE,stringsAsFactors=FALSE)
Testcor$DATE <- as.Date(Testcor$DATE)
firm.names <- colnames(Testcor)[!grepl("DATE|Market",colnames(Testcor))]
res <- sapply(firm.names, function(x) {cor.results <- 
cor.test(Testcor[,x],Testcor[,"Market"],na.action=na.exclude); 
cor.results$estimate})
#  PAXN.cor PED.cor    PEDP.cor  PM.cor    PRFN.cor    PRWN.cor 
#-0.31113122 -0.09359550 -0.17056943  0.40025112  0.34385888  0.17935045 
 #    ZG.cor    ZUBN.cor    ZURN.cor ZWM.cor 
 #0.20762797  0.39238270  0.74336028 -0.09166795 


A.K.




On Tuesday, October 15, 2013 1:57 PM, rissa  wrote:
Hi together
I'm pretty new to R, so excuse me if it is a basic question.
I have a big dataset (extract of it found in the attachment) of returns from
firms. I'd like to compute the Pearson correlation of each firm with the
"Market" and the corresponding p-Value. So I thought of making a list of
'cor.test's and then extract the needed values with a for loop. What I did
so far...
dataset=Testcor
dataset$DATE<-as.Date(dataset$DATE,"%Y-%m-%d")
firm.names=colnames(dataset)[2:length(colnames(dataset))]
cor.results1=lapply(firm.names,function(x)cor.test(as.formula(paste(firm.names[firm.names==x],Market)),data=dataset,na.action=na.exclude))

But I always get error messages like
Error in paste(firm.names[firm.names == x], Market) : 
  object 'Market' not found

or (when I attach dataset)
Error in parse(text = x) : :1:6: unexpected numeric constant
1: PAXN NA


(Next step would have been something like
for(i in 1:ncol(cor.results1)){
  newmatrix[1,i]= cor.results1 [[i]]$estimate}
etc)
Could you please help me?

Thank you so much!
Rissa


Testcor.txt   



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

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


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


[R] Problem with lapply

2013-10-15 Thread rissa
Hi together
I'm pretty new to R, so excuse me if it is a basic question.
I have a big dataset (extract of it found in the attachment) of returns from
firms. I'd like to compute the Pearson correlation of each firm with the
"Market" and the corresponding p-Value. So I thought of making a list of
'cor.test's and then extract the needed values with a for loop. What I did
so far...
dataset=Testcor
dataset$DATE<-as.Date(dataset$DATE,"%Y-%m-%d")
firm.names=colnames(dataset)[2:length(colnames(dataset))]
cor.results1=lapply(firm.names,function(x)cor.test(as.formula(paste(firm.names[firm.names==x],Market)),data=dataset,na.action=na.exclude))

But I always get error messages like
Error in paste(firm.names[firm.names == x], Market) : 
  object 'Market' not found

or (when I attach dataset)
Error in parse(text = x) : :1:6: unexpected numeric constant
1: PAXN NA


(Next step would have been something like
for(i in 1:ncol(cor.results1)){
  newmatrix[1,i]= cor.results1 [[i]]$estimate}
etc)
Could you please help me?

Thank you so much!
Rissa


Testcor.txt   



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

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


Re: [R] plot: want only dots

2013-10-15 Thread David Carlson
Are you looking for a stripchart?

stripchart(z~Genotype, mydata, vertical=TRUE, pch=1)

For details ?stripchart

-
David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77840-4352

-Original Message-
From: r-help-boun...@r-project.org
[mailto:r-help-boun...@r-project.org] On Behalf Of Sarah Goslee
Sent: Tuesday, October 15, 2013 11:48 AM
To: Hermann Norpois
Cc: r-help
Subject: Re: [R] plot: want only dots

Hi,

Genotype is a factor, and R is giving you the default type for
that data type.

I changed your data frame to mydata because df() is a function,
but see this:

> str(mydata)
'data.frame':20 obs. of  2 variables:
 $ Genotype: Factor w/ 3 levels "0","1","2": 1 1 1 1 1 1 1 1 2 2
...
 $ z   : num  0.0703 2.1574 0.514 0.4873 0.1558 ...

It sounds like you might want:

with(mydata, plot(as.numeric(as.character(Genotype)), z))

but if Genotype is best represented as a factor, that may not be
the
most informative type of plot.

Sarah

On Tue, Oct 15, 2013 at 10:23 AM, Hermann Norpois
 wrote:
> Hello,
>
> I would like to plot some values referring to the genotype
(which is 0,1
> and 2).  My data is organised like this:
>
> head (df)
>   Genotype  z
> 10 0.07029379
> 20 2.15739115
> 30 0.51395897
> 40 0.48733029
> 50 0.15584074
> 60 0.27755294
>
> I tried:
>> plot (df)
> And.
>> plot (z ~ Genotype, data=df)
>
> But it is always the same. As demonstrated in the attachment
there are bars
> with mean etc... But I want dots only. How does this work?
>
> Thanks
> Hermann
>
>> dput (df)
> structure(list(Genotype = structure(c(1L, 1L, 1L, 1L, 1L, 1L,
> 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L),
.Label = c("0",
> "1", "2"), class = "factor"), z = c(0.0702937908415368,
2.15739115226985,
> 0.513958971085714, 0.487330287677455, 0.155840743875606,
0.277552938739661,
> 0.507384510251828, 9.25159831317385e-05, 0.420814150642641,
> 10.628270981371,
> 0.518650521289299, 0.68203670876, 0.133539811585953,
0.248985608185673,
> 0.152636019877717, 0.00964805339859479, 7.57036184259711e-05,
> 0.649435257991169, 0.38951827610564, 75.6011068681301)),
.Names =
> c("Genotype",
> "z"), row.names = c(NA, 20L), class = "data.frame")
>>

-- 
Sarah Goslee
http://www.functionaldiversity.org

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

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


Re: [R] plotting a marginal distribution on the plane behind a persp() plot

2013-10-15 Thread Duncan Murdoch

On 15/10/2013 11:38 AM, Colin Rowat wrote:

R'istas:

I am trying to plot a marginal distribution on the plane behind a persp() plot. 
 My existing code is:

library(MASS)

X <- mvrnorm(1000,mu=c(0,0),Sigma=matrix(c(1,0,0,1),2))

X.kde <- kde2d(X[,1],X[,2],n=25) # X.kde is list: $x 1*n, $y 1*n, $z n*n

persp(X.kde,phi=30,theta=60,xlab="x_b",ylab="x_a",zlab="f") ->res

Any suggestions are very appreciated.


I would suggest not using persp() (use rgl::persp3d instead), but you 
can do it in persp using the same technique as in the 2nd example in the 
?persp help page.   The difficulty with doing this is that persp() uses 
the painter's algorithm for hiding things, so if you want something 
hidden, you need to draw it first.  That's not always easy


rgl::persp3d maintains a depth buffer so the order in which you draw 
things usually doesn't matter.  (The exception is with semi-transparent 
objects.)


Duncan Murdoch

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


Re: [R] Everything You Need for JEdit/R Edit Mode

2013-10-15 Thread Sarah Goslee
Hi,

On Tue, Oct 15, 2013 at 12:15 PM, Norman Guinasso  wrote:
> How can I find the mode files for jedit for R?

This really isn't an R question, but is this what you're looking for?

http://www.stanford.edu/~cengel/cgi-bin/anthrospace/syntax-coloring-for-r-in-jedit

(I googled jedit R mode file - you might try that if the above link
doesn't actually answer your question, since your question didn't make
it clear what exactly you're looking for, at least to me.)

Sarah



-- 
Sarah Goslee
http://www.functionaldiversity.org

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


Re: [R] plot: want only dots

2013-10-15 Thread Sarah Goslee
Hi,

Genotype is a factor, and R is giving you the default type for that data type.

I changed your data frame to mydata because df() is a function, but see this:

> str(mydata)
'data.frame':20 obs. of  2 variables:
 $ Genotype: Factor w/ 3 levels "0","1","2": 1 1 1 1 1 1 1 1 2 2 ...
 $ z   : num  0.0703 2.1574 0.514 0.4873 0.1558 ...

It sounds like you might want:

with(mydata, plot(as.numeric(as.character(Genotype)), z))

but if Genotype is best represented as a factor, that may not be the
most informative type of plot.

Sarah

On Tue, Oct 15, 2013 at 10:23 AM, Hermann Norpois  wrote:
> Hello,
>
> I would like to plot some values referring to the genotype (which is 0,1
> and 2).  My data is organised like this:
>
> head (df)
>   Genotype  z
> 10 0.07029379
> 20 2.15739115
> 30 0.51395897
> 40 0.48733029
> 50 0.15584074
> 60 0.27755294
>
> I tried:
>> plot (df)
> And.
>> plot (z ~ Genotype, data=df)
>
> But it is always the same. As demonstrated in the attachment there are bars
> with mean etc... But I want dots only. How does this work?
>
> Thanks
> Hermann
>
>> dput (df)
> structure(list(Genotype = structure(c(1L, 1L, 1L, 1L, 1L, 1L,
> 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L), .Label = c("0",
> "1", "2"), class = "factor"), z = c(0.0702937908415368, 2.15739115226985,
> 0.513958971085714, 0.487330287677455, 0.155840743875606, 0.277552938739661,
> 0.507384510251828, 9.25159831317385e-05, 0.420814150642641,
> 10.628270981371,
> 0.518650521289299, 0.68203670876, 0.133539811585953, 0.248985608185673,
> 0.152636019877717, 0.00964805339859479, 7.57036184259711e-05,
> 0.649435257991169, 0.38951827610564, 75.6011068681301)), .Names =
> c("Genotype",
> "z"), row.names = c(NA, 20L), class = "data.frame")
>>

-- 
Sarah Goslee
http://www.functionaldiversity.org

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


Re: [R] Data handling

2013-10-15 Thread jim holtman
FYI.

The fractional part is printed as '3204' instead of '3205' since with
POSIXct you only have accuracy to the millisecond for times around
now.

Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.


On Tue, Oct 15, 2013 at 12:45 PM, jim holtman  wrote:
> Try this; your time is converted back to a character string if you
> want to show the fractional part.
>
>> x <- read.table(text = "Date Time Fraction
> +  06/19/13 22:15:39   0.3205
> +  06/19/13 22:15:44   0.3205
> +  06/19/13 22:15:49   0.3205
> +  06/19/13 22:15:54   0.3205
> +  06/19/13 22:15:59   0.3205
> +  06/19/13 22:16:09   0.3205", as.is = TRUE, header = TRUE)
>>  x$newTime <- as.POSIXct(
> + paste0(x$Date, ' ', x$Time , '.', substring(x$Fraction, 3))
> + , format = "%m/%d/%y %H:%M:%OS"
> + )
>>  x$formatted <- format(x$newTime, format = "%m/%d/%y %H:%M:%OS4")
>>
>>
>>
>> x
>   Date Time Fraction newTime  formatted
> 1 06/19/13 22:15:39   0.3205 2013-06-19 22:15:39 06/19/13 22:15:39.3204
> 2 06/19/13 22:15:44   0.3205 2013-06-19 22:15:44 06/19/13 22:15:44.3204
> 3 06/19/13 22:15:49   0.3205 2013-06-19 22:15:49 06/19/13 22:15:49.3204
> 4 06/19/13 22:15:54   0.3205 2013-06-19 22:15:54 06/19/13 22:15:54.3204
> 5 06/19/13 22:15:59   0.3205 2013-06-19 22:15:59 06/19/13 22:15:59.3204
> 6 06/19/13 22:16:09   0.3205 2013-06-19 22:16:09 06/19/13 22:16:09.3204
>>
>
> Jim Holtman
> Data Munger Guru
>
> What is the problem that you are trying to solve?
> Tell me what you want to do, not how you want to do it.
>
>
> On Tue, Oct 15, 2013 at 10:27 AM, Raoni Rodrigues
>  wrote:
>> Hello all,
>>
>> I'm having a problem with data handling. My input data is (dput in the
>> after the signature):
>>
>> Date Time Fraction
>>  06/19/13 22:15:39   0.3205
>>  06/19/13 22:15:44   0.3205
>>  06/19/13 22:15:49   0.3205
>>  06/19/13 22:15:54   0.3205
>>  06/19/13 22:15:59   0.3205
>>  06/19/13 22:16:09   0.3205
>>
>> Date in format month/day/year, Time in HH:MM:SS and fraction represents the
>> fractions of seconds. I need to have a vector in a format year-month-day
>> hh:mm:ss.. Or, in format: format = "%F %H:%M:%OS4", as POSIXct class.
>>
>> I made the the conversion step-by-step to have sure that nothing is missed
>> in the way:
>>
>>> options (digits.sec = 4)
>>> getOption ("digits.sec")
>> [1] 4
>>> teste$Date1 = as.Date (teste$Date, format = "%m/%d/%y")
>>> class (teste$Date1)
>> [1] "Date"
>>> teste$Fraction = sub ("0.", "", teste$Fraction)
>>> teste$TimeC = paste (teste$Time, teste$Fraction, sep = ".")
>>> teste$TimeCC = paste (teste$Date1, teste$TimeC)
>>
>>> head (teste)
>>   Date Time Fraction  Date1TimeC  TimeCC
>> 1 06/19/13 22:15:39 .325 2013-06-19 22:15:39.325 2013-06-19
>> 22:15:39.3205
>> 2 06/19/13 22:15:44 .325 2013-06-19 22:15:44.325 2013-06-19
>> 22:15:44.3205
>> 3 06/19/13 22:15:49 .325 2013-06-19 22:15:49.325 2013-06-19
>> 22:15:49.3205
>> 4 06/19/13 22:15:54 .325 2013-06-19 22:15:54.325 2013-06-19
>> 22:15:54.3205
>> 5 06/19/13 22:15:59 .325 2013-06-19 22:15:59.325 2013-06-19
>> 22:15:59.3205
>> 6 06/19/13 22:16:09 .325 2013-06-19 22:16:09.325 2013-06-19
>> 22:16:09.3205
>>
>> So far so well. The problem is when I tried to convert to POSIXct class. If
>> I use just:
>>
>> teste$TimeCC = format (teste$TimeCC, format = "%F %H:%M:%OS4")
>> teste$TimeCC = as.POSIXct (teste$TimeCC)
>>
>> I lost the fraction of seconds. If I use:
>>
>> teste$TimeCC = as.POSIXct(strptime (teste$TimeCC, format = "%F %H:%M:%OS4"))
>>
>> I lost all information and get just .
>>
>> Thanks in advanced,
>>
>> --
>> Raoni Rosa Rodrigues
>> Research Associate of Fish Transposition Center CTPeixes
>> Universidade Federal de Minas Gerais - UFMG
>> Brasil
>> rodrigues.ra...@gmail.com
>>
>> dput of input data
>>
>> structure(list(Date = c("06/19/13", "06/19/13", "06/19/13", "06/19/13",
>> "06/19/13", "06/19/13"), Time = c("22:15:39", "22:15:44", "22:15:49",
>> "22:15:54", "22:15:59", "22:16:09"), Fraction = c("0.3205", "0.3205",
>> "0.3205", "0.3205", "0.3205", "0.3205")), .Names = c("Date",
>> "Time", "Fraction"), row.names = c(NA, 6L), class = "data.frame")
>>
>> [[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] Data handling

2013-10-15 Thread jim holtman
Try this; your time is converted back to a character string if you
want to show the fractional part.

> x <- read.table(text = "Date Time Fraction
+  06/19/13 22:15:39   0.3205
+  06/19/13 22:15:44   0.3205
+  06/19/13 22:15:49   0.3205
+  06/19/13 22:15:54   0.3205
+  06/19/13 22:15:59   0.3205
+  06/19/13 22:16:09   0.3205", as.is = TRUE, header = TRUE)
>  x$newTime <- as.POSIXct(
+ paste0(x$Date, ' ', x$Time , '.', substring(x$Fraction, 3))
+ , format = "%m/%d/%y %H:%M:%OS"
+ )
>  x$formatted <- format(x$newTime, format = "%m/%d/%y %H:%M:%OS4")
>
>
>
> x
  Date Time Fraction newTime  formatted
1 06/19/13 22:15:39   0.3205 2013-06-19 22:15:39 06/19/13 22:15:39.3204
2 06/19/13 22:15:44   0.3205 2013-06-19 22:15:44 06/19/13 22:15:44.3204
3 06/19/13 22:15:49   0.3205 2013-06-19 22:15:49 06/19/13 22:15:49.3204
4 06/19/13 22:15:54   0.3205 2013-06-19 22:15:54 06/19/13 22:15:54.3204
5 06/19/13 22:15:59   0.3205 2013-06-19 22:15:59 06/19/13 22:15:59.3204
6 06/19/13 22:16:09   0.3205 2013-06-19 22:16:09 06/19/13 22:16:09.3204
>

Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.


On Tue, Oct 15, 2013 at 10:27 AM, Raoni Rodrigues
 wrote:
> Hello all,
>
> I'm having a problem with data handling. My input data is (dput in the
> after the signature):
>
> Date Time Fraction
>  06/19/13 22:15:39   0.3205
>  06/19/13 22:15:44   0.3205
>  06/19/13 22:15:49   0.3205
>  06/19/13 22:15:54   0.3205
>  06/19/13 22:15:59   0.3205
>  06/19/13 22:16:09   0.3205
>
> Date in format month/day/year, Time in HH:MM:SS and fraction represents the
> fractions of seconds. I need to have a vector in a format year-month-day
> hh:mm:ss.. Or, in format: format = "%F %H:%M:%OS4", as POSIXct class.
>
> I made the the conversion step-by-step to have sure that nothing is missed
> in the way:
>
>> options (digits.sec = 4)
>> getOption ("digits.sec")
> [1] 4
>> teste$Date1 = as.Date (teste$Date, format = "%m/%d/%y")
>> class (teste$Date1)
> [1] "Date"
>> teste$Fraction = sub ("0.", "", teste$Fraction)
>> teste$TimeC = paste (teste$Time, teste$Fraction, sep = ".")
>> teste$TimeCC = paste (teste$Date1, teste$TimeC)
>
>> head (teste)
>   Date Time Fraction  Date1TimeC  TimeCC
> 1 06/19/13 22:15:39 .325 2013-06-19 22:15:39.325 2013-06-19
> 22:15:39.3205
> 2 06/19/13 22:15:44 .325 2013-06-19 22:15:44.325 2013-06-19
> 22:15:44.3205
> 3 06/19/13 22:15:49 .325 2013-06-19 22:15:49.325 2013-06-19
> 22:15:49.3205
> 4 06/19/13 22:15:54 .325 2013-06-19 22:15:54.325 2013-06-19
> 22:15:54.3205
> 5 06/19/13 22:15:59 .325 2013-06-19 22:15:59.325 2013-06-19
> 22:15:59.3205
> 6 06/19/13 22:16:09 .325 2013-06-19 22:16:09.325 2013-06-19
> 22:16:09.3205
>
> So far so well. The problem is when I tried to convert to POSIXct class. If
> I use just:
>
> teste$TimeCC = format (teste$TimeCC, format = "%F %H:%M:%OS4")
> teste$TimeCC = as.POSIXct (teste$TimeCC)
>
> I lost the fraction of seconds. If I use:
>
> teste$TimeCC = as.POSIXct(strptime (teste$TimeCC, format = "%F %H:%M:%OS4"))
>
> I lost all information and get just .
>
> Thanks in advanced,
>
> --
> Raoni Rosa Rodrigues
> Research Associate of Fish Transposition Center CTPeixes
> Universidade Federal de Minas Gerais - UFMG
> Brasil
> rodrigues.ra...@gmail.com
>
> dput of input data
>
> structure(list(Date = c("06/19/13", "06/19/13", "06/19/13", "06/19/13",
> "06/19/13", "06/19/13"), Time = c("22:15:39", "22:15:44", "22:15:49",
> "22:15:54", "22:15:59", "22:16:09"), Fraction = c("0.3205", "0.3205",
> "0.3205", "0.3205", "0.3205", "0.3205")), .Names = c("Date",
> "Time", "Fraction"), row.names = c(NA, 6L), class = "data.frame")
>
> [[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] Everything You Need for JEdit/R Edit Mode

2013-10-15 Thread Norman Guinasso

How can I find the mode files for jedit for R?

--
Norman L. Guinasso, Jr., Deputy Director
Geochemical and Environmental Research Group
College of Geosciences, Texas A&M University, MS3149
833 Graham Road, College Station TX 77845
(979)862-2323 ext. 114 fax: (979)862-2361 Cell: (979) 777-1580

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] plotting a marginal distribution on the plane behind a persp() plot

2013-10-15 Thread Colin Rowat
R'istas:

I am trying to plot a marginal distribution on the plane behind a persp() plot. 
 My existing code is:

library(MASS)

X <- mvrnorm(1000,mu=c(0,0),Sigma=matrix(c(1,0,0,1),2))

X.kde <- kde2d(X[,1],X[,2],n=25) # X.kde is list: $x 1*n, $y 1*n, $z n*n

persp(X.kde,phi=30,theta=60,xlab="x_b",ylab="x_a",zlab="f") ->res

Any suggestions are very appreciated.

Thank you,

Colin


[[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] Data handling

2013-10-15 Thread arun
Try:
 op <- options(digits.secs=4)

  TimeCC <- as.POSIXct(paste0(paste(teste[,1],teste[,2]), 
sub("^0","",teste[,3])),format="%m/%d/%y %H:%M:%OS")
options(op) #reset

A.K.


On Tuesday, October 15, 2013 10:29 AM, Raoni Rodrigues 
 wrote:
Hello all,

I'm having a problem with data handling. My input data is (dput in the
after the signature):

    Date     Time Fraction
06/19/13 22:15:39   0.3205
06/19/13 22:15:44   0.3205
06/19/13 22:15:49   0.3205
06/19/13 22:15:54   0.3205
06/19/13 22:15:59   0.3205
06/19/13 22:16:09   0.3205

Date in format month/day/year, Time in HH:MM:SS and fraction represents the
fractions of seconds. I need to have a vector in a format year-month-day
hh:mm:ss.. Or, in format: format = "%F %H:%M:%OS4", as POSIXct class.

I made the the conversion step-by-step to have sure that nothing is missed
in the way:

> options (digits.sec = 4)
> getOption ("digits.sec")
[1] 4
> teste$Date1 = as.Date (teste$Date, format = "%m/%d/%y")
> class (teste$Date1)
[1] "Date"
> teste$Fraction = sub ("0.", "", teste$Fraction)
> teste$TimeC = paste (teste$Time, teste$Fraction, sep = ".")
> teste$TimeCC = paste (teste$Date1, teste$TimeC)

> head (teste)
      Date     Time Fraction      Date1        TimeC                  TimeCC
1 06/19/13 22:15:39     .325 2013-06-19 22:15:39.325 2013-06-19
22:15:39.3205
2 06/19/13 22:15:44     .325 2013-06-19 22:15:44.325 2013-06-19
22:15:44.3205
3 06/19/13 22:15:49     .325 2013-06-19 22:15:49.325 2013-06-19
22:15:49.3205
4 06/19/13 22:15:54     .325 2013-06-19 22:15:54.325 2013-06-19
22:15:54.3205
5 06/19/13 22:15:59     .325 2013-06-19 22:15:59.325 2013-06-19
22:15:59.3205
6 06/19/13 22:16:09     .325 2013-06-19 22:16:09.325 2013-06-19
22:16:09.3205

So far so well. The problem is when I tried to convert to POSIXct class. If
I use just:

teste$TimeCC = format (teste$TimeCC, format = "%F %H:%M:%OS4")
teste$TimeCC = as.POSIXct (teste$TimeCC)

I lost the fraction of seconds. If I use:

teste$TimeCC = as.POSIXct(strptime (teste$TimeCC, format = "%F %H:%M:%OS4"))

I lost all information and get just .

Thanks in advanced,

-- 
Raoni Rosa Rodrigues
Research Associate of Fish Transposition Center CTPeixes
Universidade Federal de Minas Gerais - UFMG
Brasil
rodrigues.ra...@gmail.com

dput of input data

structure(list(Date = c("06/19/13", "06/19/13", "06/19/13", "06/19/13",
"06/19/13", "06/19/13"), Time = c("22:15:39", "22:15:44", "22:15:49",
"22:15:54", "22:15:59", "22:16:09"), Fraction = c("0.3205", "0.3205",
"0.3205", "0.3205", "0.3205", "0.3205")), .Names = c("Date",
"Time", "Fraction"), row.names = c(NA, 6L), class = "data.frame")

    [[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] plot: want only dots

2013-10-15 Thread Hermann Norpois
Hello,

I would like to plot some values referring to the genotype (which is 0,1
and 2).  My data is organised like this:

head (df)
  Genotype  z
10 0.07029379
20 2.15739115
30 0.51395897
40 0.48733029
50 0.15584074
60 0.27755294

I tried:
> plot (df)
And.
> plot (z ~ Genotype, data=df)

But it is always the same. As demonstrated in the attachment there are bars
with mean etc... But I want dots only. How does this work?

Thanks
Hermann

> dput (df)
structure(list(Genotype = structure(c(1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L), .Label = c("0",
"1", "2"), class = "factor"), z = c(0.0702937908415368, 2.15739115226985,
0.513958971085714, 0.487330287677455, 0.155840743875606, 0.277552938739661,
0.507384510251828, 9.25159831317385e-05, 0.420814150642641,
10.628270981371,
0.518650521289299, 0.68203670876, 0.133539811585953, 0.248985608185673,
0.152636019877717, 0.00964805339859479, 7.57036184259711e-05,
0.649435257991169, 0.38951827610564, 75.6011068681301)), .Names =
c("Genotype",
"z"), row.names = c(NA, 20L), class = "data.frame")
>
<>__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] compute current values in a facet

2013-10-15 Thread rolf . kemper


Hello Experts,

I found this example on web and use it just for explanation.
(  
http://stackoverflow.com/questions/15867263/ggplot2-geom-text-with-facet-grid  )
   
 library(ggplot2)  
 x <-runif(9, 0, 125)  
 data <- as.data.frame(x)  
 data$y <--runif(9, 0, 125)
 data$yy <- factor(c("a","b","c")) 
   
 ggplot(data, aes(x, y)) + geom_point(shape = 2) + facet_grid(~yy) + 
 geom_text(aes(x, y, label=lab), 
 data=data.frame(x=60,y=Inf,lab=c("this","is","the way"),
 yy=letters[1:3]), vjust=1)
   
   
 Running it you will see the text "this","is","the way" distributed in each 
facet.
   
 In my case I would like to show a e.g the max(y) .
 I modified the ggplot statement like this:
   
   
 ggplot(data, aes(x, y )) + geom_point(shape = 2 ) + facet_grid(~yy) +
 geom_text(aes(x, y, , yy , label=lab),  
  
data=data.frame(x=60,y=Inf,lab=c(as.character(max(x)),"is","the way"),
 yy=letters[1:3]),   
  vjust=1 ) 
  
   
 BUT, the result is the max(x) of ALL rows in the data frame.  
 What I need is to find the max value just for the points in each of the facets.
 AND I need it with facet_wrap if possible.
   
 I did not find any way to get access to the current yy value. 
   
 Hope someone can help 
   
 R. Kemper 
   
   
   
   
   




Rolf  Kemper, Manager, Mixed Signal Design, Networking, Renesas Electronics 
Europe GmbH, , Arcadiastr. 10, 40472, Duesseldorf, Germany,  Phone:+49 211
6503-1475, Fax:+49 211 6503-1540, mailto:rolf.kem...@renesas.com, 
http://www.renesas.eu

This message is intended only for the use of the address...{{dropped:24}}

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


Re: [R] Finding solution for non-linear equations

2013-10-15 Thread Berend Hasselman

On 15-10-2013, at 15:24, Ron Michael  wrote:

> Hi,
> 
> I need to solve following simultaneous equations for A, B, Y1, Y2:
> 
> B * Phi(Y1 - A) + (1-B) * Phi(Y1 + A) = 0.05
> B * Phi(Y2 - A) + (1-B) * Phi(Y2 + A) = 0.01
> 
> Y1 <= -1.65
> Y2 >= -2.33
> 
> 0 <= B <=1 
> 
> Phi is CDF for standard normal
> 
> If there is no unique solution, then I should be able to get some feassible 
> solution(s)
> 
> Is there any way that using R I can achieve that?


You cannot solve a system of 2 equations with 4 unknowns (variables).
You can only try to find  4 values that get as close as possible (in whatever 
sense) to solving the system.

In other words you must define a function that returns some scalar measure of 
closeness to a solution.

Assuming this is homework I'll only give you a hint.

Have a look at the functions optim and constrOptim.
Both can do what you want and both are able to solve your problem.

good luck,

Berend

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


Re: [R] matrix of mean values

2013-10-15 Thread arun



Hi Nico,
Try:

setAs("character", "num.commas", 
    function(from) as.numeric(gsub(",", "", from) ) )
d1 <- 
read.csv("cont.txt",header=TRUE,sep="\t",colClasses=c("numeric","character","num.commas"))
colnames(d1)[-3] <- c("loc","variables")
library(reshape2)
 res <- dcast(d1,loc~variables,value.var="value",mean)

row.names(res) <- res[,1]
 res1 <- as.matrix(res[,-1])
 dim(res1)
#[1] 129 190

A.K.

On Tuesday, October 15, 2013 8:07 AM, Nico Met  wrote:

Hi Arun, many thanks. Here I attached the data.

Regards

Nico

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


Re: [R] Finding solution for non-linear equations

2013-10-15 Thread Bert Gunter
Homework?

We don't do homework here.

Otherwise, the answer is yes, R can be used to do this.

Cheers,
Bert

On Tue, Oct 15, 2013 at 6:24 AM, Ron Michael  wrote:
> Hi,
>
> I need to solve following simultaneous equations for A, B, Y1, Y2:
>
> B * Phi(Y1 - A) + (1-B) * Phi(Y1 + A) = 0.05
> B * Phi(Y2 - A) + (1-B) * Phi(Y2 + A) = 0.01
>
> Y1 <= -1.65
> Y2 >= -2.33
>
> 0 <= B <=1
>
> Phi is CDF for standard normal
>
> If there is no unique solution, then I should be able to get some feassible 
> solution(s)
>
> Is there any way that using R I can achieve that?
>
> Thanks for your time
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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

(650) 467-7374

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

2013-10-15 Thread Raoni Rodrigues
Hello all,

I'm having a problem with data handling. My input data is (dput in the
after the signature):

Date Time Fraction
 06/19/13 22:15:39   0.3205
 06/19/13 22:15:44   0.3205
 06/19/13 22:15:49   0.3205
 06/19/13 22:15:54   0.3205
 06/19/13 22:15:59   0.3205
 06/19/13 22:16:09   0.3205

Date in format month/day/year, Time in HH:MM:SS and fraction represents the
fractions of seconds. I need to have a vector in a format year-month-day
hh:mm:ss.. Or, in format: format = "%F %H:%M:%OS4", as POSIXct class.

I made the the conversion step-by-step to have sure that nothing is missed
in the way:

> options (digits.sec = 4)
> getOption ("digits.sec")
[1] 4
> teste$Date1 = as.Date (teste$Date, format = "%m/%d/%y")
> class (teste$Date1)
[1] "Date"
> teste$Fraction = sub ("0.", "", teste$Fraction)
> teste$TimeC = paste (teste$Time, teste$Fraction, sep = ".")
> teste$TimeCC = paste (teste$Date1, teste$TimeC)

> head (teste)
  Date Time Fraction  Date1TimeC  TimeCC
1 06/19/13 22:15:39 .325 2013-06-19 22:15:39.325 2013-06-19
22:15:39.3205
2 06/19/13 22:15:44 .325 2013-06-19 22:15:44.325 2013-06-19
22:15:44.3205
3 06/19/13 22:15:49 .325 2013-06-19 22:15:49.325 2013-06-19
22:15:49.3205
4 06/19/13 22:15:54 .325 2013-06-19 22:15:54.325 2013-06-19
22:15:54.3205
5 06/19/13 22:15:59 .325 2013-06-19 22:15:59.325 2013-06-19
22:15:59.3205
6 06/19/13 22:16:09 .325 2013-06-19 22:16:09.325 2013-06-19
22:16:09.3205

So far so well. The problem is when I tried to convert to POSIXct class. If
I use just:

teste$TimeCC = format (teste$TimeCC, format = "%F %H:%M:%OS4")
teste$TimeCC = as.POSIXct (teste$TimeCC)

I lost the fraction of seconds. If I use:

teste$TimeCC = as.POSIXct(strptime (teste$TimeCC, format = "%F %H:%M:%OS4"))

I lost all information and get just .

Thanks in advanced,

-- 
Raoni Rosa Rodrigues
Research Associate of Fish Transposition Center CTPeixes
Universidade Federal de Minas Gerais - UFMG
Brasil
rodrigues.ra...@gmail.com

dput of input data

structure(list(Date = c("06/19/13", "06/19/13", "06/19/13", "06/19/13",
"06/19/13", "06/19/13"), Time = c("22:15:39", "22:15:44", "22:15:49",
"22:15:54", "22:15:59", "22:16:09"), Fraction = c("0.3205", "0.3205",
"0.3205", "0.3205", "0.3205", "0.3205")), .Names = c("Date",
"Time", "Fraction"), row.names = c(NA, 6L), class = "data.frame")

[[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] cluster option in stata for random intercept model in the R language?

2013-10-15 Thread David Winsemius


On Oct 15, 2013, at 3:32 AM, Martin Batholdy wrote:


Dear R-list,

I am currently working on a dataset with a colleague who uses stata.
We fit a random intercept model to the data (decisions clustered in  
participants) and get closely the same results in stata (using xtreg  
re) and R (using the lme4 or multilevel package).



Now in stata, there is an additional option for the regression to  
control for clustering; the vce(cluster clustvar) option, which  
changes the standard errors quite a bit.
(see http://www.stata.com/support/faqs/statistics/standard-errors-and-vce-cluster-option/ 
 or http://www.stata.com/manuals13/xtxtreg.pdf).


Unfortunately I don't understand what this 'correction' does and why  
it yields different results.
First I thought it would control for autocorrelations over time  
(decisions), but if I model this directly with a random-intercept  
random-slope model, I don't get nearly the same results.


Can someone help me understand what stata is doing here?
And what would be the equivalent in R to get similar results?


http://www.stata.com/statalist/



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


David Winsemius, MD
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] Finding solution for non-linear equations

2013-10-15 Thread Ron Michael
Hi,

I need to solve following simultaneous equations for A, B, Y1, Y2:

B * Phi(Y1 - A) + (1-B) * Phi(Y1 + A) = 0.05
B * Phi(Y2 - A) + (1-B) * Phi(Y2 + A) = 0.01

Y1 <= -1.65
Y2 >= -2.33

0 <= B <=1 

Phi is CDF for standard normal

If there is no unique solution, then I should be able to get some feassible 
solution(s)

Is there any way that using R I can achieve that?

Thanks for your time

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

2013-10-15 Thread Duncan Murdoch

On 13-10-15 6:51 AM, Stefan Petersson wrote:

Hi,

I use a regular web hosting service to build a web site under windows .NET.
Now I need statistical functionality on the site, and I would really like
to use R for that. However, I'm not allowed to install anything (e.g. R) on
the host. Are there any implementations/workarounds of R that doesn't need
to be installed, just 'copied' to the server host?



I suspect that your host will consider copying executables onto it to be 
equivalent to installing them, so I'd recommend asking them to install 
it for you.


The likely reason for the restriction is so that you can't create 
security holes; you'll need to be careful to run R in a way that allows 
you to ask it to do the things you want without allowing users to ask it 
to do whatever they want.


Duncan Murdoch

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


Re: [R] extract regression coefficients

2013-10-15 Thread Gerrit Eichner

Hello, Catalin,

fist: keep the reply on-list so that others can follow.

second: (see below)

On Tue, 15 Oct 2013, catalin roibu wrote:


Hello!
I try that! But I want to use them forward in the equation and I don't want
to write every time when I change the values.


This way to unspecific to give you any hint. So, "PLEASE do read the 
posting guide http://www.R-project.org/posting-guide.html and provide 
commented, minimal, self-contained, reproducible code."


 Regards  --  Gerrit



On 15 October 2013 14:59, Gerrit Eichner 
wrote:



Hello, Catalin,

check out

?coef

 Regards -- Gerrit



On Tue, 15 Oct 2013, catalin roibu wrote:

 Hello all!

I have a problem with R. I want to extract regression coefficients from
summary and use it for compute the theoretical values.

How can I do that in R?

thank you!

best regards,

--
---
Catalin-Constantin ROIBU
Lecturer PhD, Forestry engineer
Forestry Faculty of Suceava
Str. Universitatii no. 13, Suceava, 720229, Romania
office phone +4 0230 52 29 78, ext. 531
mobile phone   +4 0745 53 18 01
  +4 0766 71 76 58
FAX:+4 0230 52 16 64
silvic.usv.ro

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






--
---
Catalin-Constantin ROIBU
Lecturer PhD, Forestry engineer
Forestry Faculty of Suceava
Str. Universitatii no. 13, Suceava, 720229, Romania
office phone +4 0230 52 29 78, ext. 531
mobile phone   +4 0745 53 18 01
  +4 0766 71 76 58
FAX:+4 0230 52 16 64
silvic.usv.ro


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

2013-10-15 Thread Prof Brian Ripley

On 15/10/2013 11:51, Stefan Petersson wrote:

Hi,

I use a regular web hosting service to build a web site under windows .NET.
Now I need statistical functionality on the site, and I would really like
to use R for that. However, I'm not allowed to install anything (e.g. R) on
the host. Are there any implementations/workarounds of R that doesn't need
to be installed, just 'copied' to the server host?



Since this seems to be Windows, see the FAQ:
http://cran.r-project.org/bin/windows/base/rw-FAQ.html#Can-I-run-R-from-a-CD-or-USB-drive_003f


TIA

   //  s

[[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 do: it points out to you the documentations already written.

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

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


Re: [R] Writing an R fn to produce random sequences of binaries XXXX

2013-10-15 Thread Duncan Murdoch

On 13-10-15 7:55 AM, Dan Abner wrote:

Hi all,

I am attempting to write an R fn to produce a random sequence of 8 binaries
(4 ordered pairs). I would like to parmeterize the fn so that it takes 2
arguments: 1 that is an overall probability of a 1 vs. 0 and the other
which controls the likelihood of 1s on the 1st vs. the 2nd element of the 4
ordered pairs.

Here are some examples:


*Voiced Probability Parm* *1st Element Probability Parm* *Average N of 1s
* *Average N 1st Element 1s* * * *1* *1.5* *2* *2.5* *3* *3.5* *4*
*4.5*
0.5 1 4 4 1 0 1 0 1 0 1 0  0.5 0 4 0 0 1 0 1 0 1 0 1  0.5 0.75 4 3 1 0 0 1 1
0 1 0  0.5 0.25 4 1 0 1 0 1 1 0 0 1  1 1 8 4 1 1 1 1 1 1 1 1  0 0 0 0 0 0 0
0 0 0 0 0  0.5 0.5 4 2 1 0 0 1 1 0 0 1


Can anyone suggest an algorithm for this? I have a 1st draft of the fn
definition, but my algorithm is not correct as I am not getting the average
number of 1s (averaged over 10,000 sequences) correct.


A simple algorithm is to sample the 1st bit using rbinom(), then sample 
the second bit, again using rbinom, but with probability conditional on 
the value of the first bit.  But that requires a joint distribution, and 
you haven't given us enough information to construct one.


For example, here's a model where bit 2 is either independent of bit 1 
or forced to be equal to it, with theta being the probability of being 
forced to be equal.  This probably isn't the model you want, but you 
would just modify the bit2 line to give the correct conditional 
distribution based on what you do want.


p <- 0.7 # marginal prob of a 1
theta <- 0.5 # ratio of times bit 2 is equal to bit 1, versus
 # independent
bit1 <- rbinom(4, size=1, p)
bit2 <- rbinom(4, size=1, theta*bit1 + (1-theta)*p)
cbind(bit1, bit2)

Duncan Murdoch



Thanks,

Dan

[[alternative HTML version deleted]]

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



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


Re: [R] extract regression coefficients

2013-10-15 Thread Gerrit Eichner

Hello, Catalin,

check out

?coef

 Regards -- Gerrit


On Tue, 15 Oct 2013, catalin roibu wrote:


Hello all!
I have a problem with R. I want to extract regression coefficients from
summary and use it for compute the theoretical values.

How can I do that in R?

thank you!

best regards,

--
---
Catalin-Constantin ROIBU
Lecturer PhD, Forestry engineer
Forestry Faculty of Suceava
Str. Universitatii no. 13, Suceava, 720229, Romania
office phone +4 0230 52 29 78, ext. 531
mobile phone   +4 0745 53 18 01
  +4 0766 71 76 58
FAX:+4 0230 52 16 64
silvic.usv.ro

[[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] Writing an R fn to produce random sequences of binaries XXXX

2013-10-15 Thread Dan Abner
Hi all,

I am attempting to write an R fn to produce a random sequence of 8 binaries
(4 ordered pairs). I would like to parmeterize the fn so that it takes 2
arguments: 1 that is an overall probability of a 1 vs. 0 and the other
which controls the likelihood of 1s on the 1st vs. the 2nd element of the 4
ordered pairs.

Here are some examples:


   *Voiced Probability Parm* *1st Element Probability Parm* *Average N of 1s
* *Average N 1st Element 1s* * * *1* *1.5* *2* *2.5* *3* *3.5* *4*
*4.5*
0.5 1 4 4 1 0 1 0 1 0 1 0  0.5 0 4 0 0 1 0 1 0 1 0 1  0.5 0.75 4 3 1 0 0 1 1
0 1 0  0.5 0.25 4 1 0 1 0 1 1 0 0 1  1 1 8 4 1 1 1 1 1 1 1 1  0 0 0 0 0 0 0
0 0 0 0 0  0.5 0.5 4 2 1 0 0 1 1 0 0 1


Can anyone suggest an algorithm for this? I have a 1st draft of the fn
definition, but my algorithm is not correct as I am not getting the average
number of 1s (averaged over 10,000 sequences) correct.

Thanks,

Dan

[[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] bug(?) in str() with strict.width = "cut" when applied to dataframe with numeric component AND factor or character component with longerlevels/strings

2013-10-15 Thread Gerrit Eichner

Dear list subscribers,

here is a small artificial example to demonstrate the problem that I 
encountered when looking at the structure of a (larger) data frame that 
comprised (among other components)


a numeric component of elements of the order of > 1, and

a factor or character component with longer levels/strings:


k <- 43  # length of levels or character strings
n <- 11  # number of rows of data frame
M <- 1   # order of magnitude of numerical values

set.seed( 47) # to reproduce the following artificial character string
longer.char.string <- paste( sample( letters, k, replace = TRUE),
 collapse = "")

X <- data.frame( A = 1:n * M,
 B = rep( longer.char.string, n))


The following call to str() gives apparently a wrong result

str( X, strict.width = "cut")

'data.frame':   11 obs. of  2 variables:
 $ A: num  1e+04 2e+04 3e+04 4e+04 5e+04 6e+04 7e+04 8e+04 9e+04 1e+..
 $ A: num  1e+04 2e+04 3e+04 4e+04 5e+04 6e+04 7e+04 8e+04 9e+04 1e+..


whereas the correct result appears for str( X) or if you decrease k to 42 
(isn't that "the answer"? ;-) ) or n to 10 or M to 1000 (or smaller, 
respectively).



I tried to dig into the entrails of str.default(), where the cause may 
lie, but got lost pretty soon. So, I am hoping that someone may already 
have a work-around or patch (or dares to dig further)? Thank you for any 
feedback!


 Best regards  --  Gerrit

PS:


sessionInfo()


R version 3.0.2 (2013-09-25)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=German_Germany.1252  LC_CTYPE=German_Germany.1252
[3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C
[5] LC_TIME=German_Germany.1252

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

other attached packages:
[1] nparcomp_2.0 multcomp_1.2-21  mvtnorm_0.9-9996
[4] car_2.0-19   Hmisc_3.12-2 Formula_1.1-1
[7] survival_2.37-4  fortunes_1.5-0

loaded via a namespace (and not attached):
[1] cluster_1.14.4  grid_3.0.2  lattice_0.20-23 MASS_7.3-29
[5] nnet_7.3-7  rpart_4.1-3 stats4_3.0.2tools_3.0.2

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

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


[R] extract regression coefficients

2013-10-15 Thread catalin roibu
Hello all!
I have a problem with R. I want to extract regression coefficients from
summary and use it for compute the theoretical values.

How can I do that in R?

thank you!

best regards,

-- 
---
Catalin-Constantin ROIBU
Lecturer PhD, Forestry engineer
Forestry Faculty of Suceava
Str. Universitatii no. 13, Suceava, 720229, Romania
office phone +4 0230 52 29 78, ext. 531
mobile phone   +4 0745 53 18 01
   +4 0766 71 76 58
FAX:+4 0230 52 16 64
silvic.usv.ro

[[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] R on Server without installation

2013-10-15 Thread Stefan Petersson
Hi,

I use a regular web hosting service to build a web site under windows .NET.
Now I need statistical functionality on the site, and I would really like
to use R for that. However, I'm not allowed to install anything (e.g. R) on
the host. Are there any implementations/workarounds of R that doesn't need
to be installed, just 'copied' to the server host?

TIA

  //  s

[[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] cluster option in stata for random intercept model in the R language?

2013-10-15 Thread Martin Batholdy
Dear R-list,

I am currently working on a dataset with a colleague who uses stata.
We fit a random intercept model to the data (decisions clustered in 
participants) and get closely the same results in stata (using xtreg re) and R 
(using the lme4 or multilevel package).


Now in stata, there is an additional option for the regression to control for 
clustering; the vce(cluster clustvar) option, which changes the standard errors 
quite a bit.
(see 
http://www.stata.com/support/faqs/statistics/standard-errors-and-vce-cluster-option/
 or http://www.stata.com/manuals13/xtxtreg.pdf).

Unfortunately I don't understand what this 'correction' does and why it yields 
different results.
First I thought it would control for autocorrelations over time (decisions), 
but if I model this directly with a random-intercept random-slope model, I 
don't get nearly the same results.

Can someone help me understand what stata is doing here?
And what would be the equivalent in R to get similar results?


thanks!

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


[R] Contract Work

2013-10-15 Thread Raghuraman Ramachandran
Dear R-users

I am looking for a very experienced R developer for a derivatives project
in Bangalore. The developer should preferably be well versed in GUI etc.
The contract is for 4 to 6 months.

Please contact me in this email.

Thanks
Raghu

[[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] RStudio with Revolution-R

2013-10-15 Thread Suzen, Mehmet
On 15 October 2013 01:27, Maxim Linchits  wrote:
> Hello,
> Is it possible to use Revolution-R's multithreading capability with
> RStudio as the IDE? Apparently, RevoR is available for Ubuntu,

Wrong list!

But for reference:
http://stackoverflow.com/questions/10835122/multithreading-with-r

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