Re: [R] Combining information from two matrices

2013-09-11 Thread Bert Gunter
Your "solution"  is unnecessarily complicated.  There is no need to convert
to data frames and no need to eval labels -- simple indexing by column and
row names will do. I think the following code is pretty self-explanatory:

(Starting with the same mat1 and mat2)

rnames <- setdiff(rownames(mat2),rownames(mat1))
mat3 <- matrix(0,nr=length(rnames),nc=ncol(mat1)) ## correct size, all 0's
dimnames(mat3)<- list(rnames,colnames(mat1)) ## row and column names as
requested
wh <- intersect(colnames(mat1),colnames(mat2))
mat3[,wh] <- mat2[rnames,wh]

> mat3
Pollinator 1 Pollinator 2 Pollinator 3
Plant 4100
Plant 5010


Cheers,
Bert

Pollinator 1 Pollinator 2 Pollinator 3
Plant 4100
Plant 5010





On Wed, Sep 11, 2013 at 7:10 PM, arun  wrote:

> Hi,
>
> May be this helps:
> mat1<-
> matrix(c(1,1,0,0,0,1,0,1,0),ncol=3,dimnames=list(paste("Plant",1:3),
> paste("Pollinator",1:3)),byrow=TRUE)
>  mat2<-
> matrix(c(1,1,0,1,0,1,0,1,0),ncol=3,dimnames=list(paste("Plant",c(1,4,5)),
> paste("Pollinator",c(1,2,4))),byrow=TRUE)
> dat1<- as.data.frame(mat1)
>  dat2<- as.data.frame(mat2)
> toadddat1<-setdiff(colnames(dat2),colnames(dat1))
> toadddat2<-setdiff(colnames(dat1),colnames(dat2))
> dat2[,evalq(toadddat2)]<-0
> res<- as.matrix(dat2[!row.names(dat1)%in%
> row.names(dat2),!colnames(dat2)%in%evalq(toadddat1)] )
> res
> #Pollinator 1 Pollinator 2 Pollinator 3
> #Plant 4100
> #Plant 5010
> A.K.
>
>
>
>
>
> Hello all
> I have been trying to find a solution for this for a while, and I hope you
> can help me.
> I have two matrices. Both are interaction matrices between plants
> and pollinators, and have plants as rows and pollinators as columns. The
>  matrix is a presence/absence matrix with 1´s for interaction and 0´s
> for no interaction. Here are simplified examples:
>
> Matrix 1:
>  Pollinator 1 Pollinator 2 Pollinator 3
> Plant 1  1   1  0
> Plant 2  0   0  1
> Plant 3  0   1  0
>
> Matrix 2:
>  Pollinator 1 Pollinator 2 Pollinator 4
> Plant 1  1   1  0
> Plant 4  1   0  1
> Plant 5  0   1  0
>
> What I need is to make a new matrix with the columns
> (pollinators) from matrix 1 and the rows (plants) and entries from
> matrix 2, but only with those rows that are not in matrix 1. Like this:
>
> Pollinator 1 Pollinator 2 Pollinator 3
> Plant 4  1   0  0
> Plant 5  0   1  0
>
> Hope you can help. Thanks a lot in advance.
> Daniel
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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

[[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 allocate more memory?

2013-09-11 Thread David Winsemius


On Sep 11, 2013, at 5:05 PM, Ramona Lall wrote:


Hello all,

I am running mixed model on a large dataset and I get the following  
warning messages:

"Reached total allocation of 1535Mb: see help(memory.size)"
and
"Calloc could not allocate memory (705648 of 8 bytes)"

How do I get around this?


You should describe your situation in greater detail. Consult the  
Posting Guide for specifics.


--

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.


Re: [R] sparse PCA using nsprcomp package

2013-09-11 Thread array chip
Hi Christian,

Thank you so much for sharing your thoughts, I was a real pleasure to read and 
learn! Approximately when do you expect the new release of the package?


Best,

John




 From: Christian Sigg 

Cc: "r-help@r-project.org"  
Sent: Monday, September 9, 2013 8:06 AM
Subject: Re: [R] sparse PCA using nsprcomp package
 

Hi John

> 1). Assume now I can calculate these "adjusted" standard deviation from 
> sparse PCA, should the percent variation explained by each sparse PC be 
> calculated using the sum of all these "adjusted" variance (i.e. square of the 
> "adjusted" standard deviation) as the denominator (then these percent 
> variation explained will always add up to 1 if all sparse PCs are counted, or 
> using the sum of the PC variances estimated by REGULAR PCA as the denominator 
> (then, adding up all PCs may not be equal to 1)?

It depends on what you want to do with this percentage, but to me the second 
would be more meaningful. A sparse PCA will usually be truncated (fewer than 
all possible components are computed), and due to the additional constraints on 
the principal axes you will usually explain less variance than with standard 
PCA. I would want to know what I lose in a sparse PCA w.r.t. a standard PCA.

Note that you don't actually have to compute the standard PCA if you are only 
interested in the total variance of the data, i.e. the sum of all variances. 
The total variance 

1/(n-1)*sum(diag(t(X)%*%X)) 

for the zero-mean data matrix X is invariant to a rotation of the coordinate 
system and therefore identical to

Z <- X%*%W
1/(n-1)*sum(diag(t(Z)%*%Z)) 

so you can skip computing the PCA rotation matrix W. The fastest way to compute 
the total variance is probably

1/(n-1)*sum(X^2) 

because all expressions compute the squared Frobenius norm of X. 

If you want to compare variances of individual components, then compute a 
regular PCA.

I also had a look how the spca function computes the "percentage explained 
variation". I don't yet entirely understand what is going on, but the results 
differ from using the "asdev" function I mentioned in my previous reply. Keep 
that in mind if you want to compare nsprcomp to spca.

> 2). How do you choose the 2 important parameters in nsprcomp(), ncomp and k? 
> If for example, my regular PCA showed that I need 20 PCs to account for 80% 
> of the variation in my dataset, does it mean I should set ncomp=20? And then 
> what about any rules setting the value of "k"?

I don't have any hard answers for this question. 

There are a number of heuristics for choosing the number of components in 
regular PCA (e.g. the PCA book by Jolliffe presents several), and some of them 
should translate to sparse PCA. If you think that 20 PCs or 80% explained 
variance works well for regular PCA, I suggest also using 20 components in 
sparse PCA, then measure the explained variance and then increase the number of 
components (if necessary) to again achieve 80% explained variance.

Same for setting the cardinality parameter k. You could use a criterion such as 
BIC to optimize the trade-off between model fidelity and complexity, but I 
don't have any experience how well this works in practice. What I did so far 
was to check for loadings with small magnitudes. I set k such that all loadings 
have "substantial" magnitudes.

In the end what matters is what follows after running the algorithm. Are you 
directly interpreting the sparse PCA result, or is this an intermediate step in 
a complete data processing pipeline with a measurable goal? If the latter, 
choose the algortihm parameters that give you the best results at the end of 
the pipeline.

> 3). Would you recommend nscumcomp() or nsprcomp() in general?

It depends whether you want to perform a sequential or cumulative analysis of 
your data. If you want maximum variance in the first (second, third, ...) PC, 
and specify the precise cardinality of each principal axis, then use nsprcomp. 
If instead you want to only specify the total cardinality of all loadings and 
leave the distribution of non-zero loadings to the algorithm, use nscumcomp.

There will be substantial improvements to nscumcomp in the next release, if you 
want to use it I suggest you wait until then.

Regards
Christian
[[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] Combining information from two matrices

2013-09-11 Thread arun
Hi,

May be this helps:
mat1<- matrix(c(1,1,0,0,0,1,0,1,0),ncol=3,dimnames=list(paste("Plant",1:3), 
paste("Pollinator",1:3)),byrow=TRUE)
 mat2<- 
matrix(c(1,1,0,1,0,1,0,1,0),ncol=3,dimnames=list(paste("Plant",c(1,4,5)), 
paste("Pollinator",c(1,2,4))),byrow=TRUE)
dat1<- as.data.frame(mat1)
 dat2<- as.data.frame(mat2)
toadddat1<-setdiff(colnames(dat2),colnames(dat1))
toadddat2<-setdiff(colnames(dat1),colnames(dat2))
dat2[,evalq(toadddat2)]<-0
res<- as.matrix(dat2[!row.names(dat1)%in% 
row.names(dat2),!colnames(dat2)%in%evalq(toadddat1)] )
res
#    Pollinator 1 Pollinator 2 Pollinator 3
#Plant 4    1    0    0
#Plant 5    0    1    0
A.K.





Hello all 
I have been trying to find a solution for this for a while, and I hope you can 
help me. 
I have two matrices. Both are interaction matrices between plants 
and pollinators, and have plants as rows and pollinators as columns. The
 matrix is a presence/absence matrix with 1´s for interaction and 0´s 
for no interaction. Here are simplified examples: 

Matrix 1: 
             Pollinator 1     Pollinator 2     Pollinator 3 
Plant 1          1                   1                  0 
Plant 2          0                   0                  1 
Plant 3          0                   1                  0 

Matrix 2: 
             Pollinator 1     Pollinator 2     Pollinator 4 
Plant 1          1                   1                  0 
Plant 4          1                   0                  1 
Plant 5          0                   1                  0 

What I need is to make a new matrix with the columns 
(pollinators) from matrix 1 and the rows (plants) and entries from 
matrix 2, but only with those rows that are not in matrix 1. Like this: 

            Pollinator 1     Pollinator 2     Pollinator 3 
Plant 4          1                   0                  0 
Plant 5          0                   1                  0 

Hope you can help. Thanks a lot in advance. 
Daniel

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

2013-09-11 Thread Ramona Lall
Hello all,

I am running mixed model on a large dataset and I get the following warning 
messages:
"Reached total allocation of 1535Mb: see help(memory.size)"
and
"Calloc could not allocate memory (705648 of 8 bytes)"

How do I get around this?

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] Subtracting elements of a vector from each other stepwise

2013-09-11 Thread Jeff Newmiller
It is worth asking for clarification sometimes, but I have to admit that I 
don't have much sympathy in this case because there isn't much code involved 
and typing in the code (or copy/pasting it line-by-line) and experimenting with 
it is crucial to the process of learning R. Picking out one expression at a 
time from each line and looking at the result with the str function is really 
how you have to do it. That is why responders on this list so often ask for 
reproducible examples from the questioner... the answer can be much more 
compact and quick to generate.
---
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.

Ben Harrison  wrote:
>If I were Michael (OP) right now, I think my head would be spinning.
>
>As a newbie myself, I know how hard it is to read R code for the first 
>time, so could it also be part of the newsgroup etiquette to at least 
>partially explain provided code to newbies?
>
>I agree that the interactive help '?' is available and should be 
>consulted, but it would also be helpful if those of you with great 
>experience could add a little guidance for your code.
>
>Excuse me if this is out-of-place.
>
>Ben
>
>
>On 11/09/13 09:48, Ben Bolker wrote:
>> On 13-09-10 06:24 PM, arun wrote:
>>> Hi,
>>> May be this also works:
>>>
>>>   dist(x)
>>> #   1  2  3
>>> #2  2
>>> #3  6  4
>>> #4 12 10  6
>>>
>>> as.matrix(dist(x))
>>> #   1  2 3  4
>>> #1  0  2 6 12
>>> #2  2  0 4 10
>>> #3  6  4 0  6
>>> #4 12 10 6  0
>>> which(dist(x)==min(dist(x)))
>>> #[1] 1
>>> A.K.
>>
>>Yes, but you need to set the diagonal to NA, or something -- the
>OP
>> doesn't want to include self-comparison. It also helps to use
>> arr.ind=TRUE in which().  You're right that dist() would be a hair
>more
>> efficient that outer(...), though
>>
>>>
>>>
>>>
>>> - Original Message -
>>> From: Ben Bolker 
>>> To: r-h...@stat.math.ethz.ch
>>> Cc:
>>> Sent: Tuesday, September 10, 2013 5:39 PM
>>> Subject: Re: [R] Subtracting elements of a vector from each other
>stepwise
>>>
>>> arun  yahoo.com> writes:
>>>

 Hi,
 Not sure this is what you wanted:

   sapply(seq_along(x), function(i) {x1<- x[i]; x2<- x[-i];
>>> x3<-x2[which.min(abs(x1-x2))];c(x1,x3)})
 # [,1] [,2] [,3] [,4]
 #[1,]   17   19   23   29
 #[2,]   19   17   19   23
 A.K.
>>>
>>>
>>>It's a little inefficient (because it constructs
>>> the distances in both directions), but how about:
>>>
>>> x = c(17,19,23,29)
>>> d <- abs(outer(x,x,"-"))
>>> diag(d) <- NA
>>> d[lower.tri(d)] <- NA
>>> which(d==min(d,na.rm=TRUE),arr.ind=TRUE)
>>>
>>>
>>> ?
>>>
 - Original Message -
 From: Michael Budnick  snet.net>
 To: r-help  r-project.org
 Cc:
 Sent: Tuesday, September 10, 2013 4:06 PM
 Subject: [R] Subtracting elements of a vector from each other
>stepwise

 I am trying to figure out how to create a loop that will take the
 difference of each member of a vector from each other and also spit
>out
 which one has the least difference.

 I do not want the vector member to subtract from itself or it must
>be able
 to disregard the 0 obtained from subtracting from itself.

 For example:

 x = c(17,19,23,29)
>>>
>>>
>>> [snip]
>>>
>>> __
>>> R-help@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>
>
>__
>R-help@r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

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


[R] Bar plot help

2013-09-11 Thread Moshiur Rahman
Hi R-helpers,

Can anyone help me giving instructions/package sources to make a simple bar
plot with mean and standard error of variables [Orange colour (which has
four PCs)  and Irid colour (which has two PCs)] that I'd like to plot in
x-axis and the values in y-axis? The diet should be as legend (H & L).

Dataframe:

   Diet Orange colour Irid colour
PC1  PC2  PC3  PC4   PC1  PC2
H  -3.4 -2.4  0.1  0.4  -2.4 -7.0
H  -6.1 -0.7 -0.8 -0.5   5.5 -3.2
L  12.2 -1.1 -0.6  0.4  10.6 -4.6
L  -3.4 -2.2  0.1 -0.1  -0.6 -3.2



I'll highly appretiate your cordial help in this regard.

Cheers,

Moshi

[[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 split a plot into vertical subregions with width proportional to length of a character string?

2013-09-11 Thread Jim Lemon

On 09/12/2013 03:51 AM, isabe...@ghement.ca wrote:



BODY { font-family:Arial, Helvetica, sans-serif;font-size:12px;
}Hello,

I am trying to create a plot whose x-axis is wide enough to
accommodate the following:

a) a character string on the left side (i.e., Text 1);
  b) a known range of values in the middle (i.e., Range);
  c) a character string on the right side (i.e., Label 2)

The plot would start with the range of values in the middle and would
be expanded to the left and right by a width proportional to the
length of Text 1 and Label 2, respectively.  (The width would need to
be expressed in the same units as those of the middle range of
values.)

In R, how can I determine the width of Text 1 and Label 2 and express
it in the same units as those pertaining to Range?  (I know how to
determine the width of these character strings in inches for a given
plot via strwidth(), but for some reason I am not able to connect that
width to the units of Range.)

Here is some R code illustrating what the plot would look like:
  plot(NA, xlim=c(1,10), ylim=c(1,5),type="N")
  abline(v=1,lty=2,col="red")
  abline(v=2,lty=2,col="red")
  abline(v=8,lty=3,col="blue")
  abline(v=10,lty=3,col="blue")
  text(1,3,"Text 1",pos=4)
  text(8,3,"Label 2",pos=4)
  arrows(2,3,8,3,code=3, length=0.1,lwd=2)
  text(5,3,"Range",pos=3)


Hi Isabella,
Your illustration is helpful, but there are a couple of things that I 
will have to guess. The first is that you want the usual margins around 
the plot, and the second is that the outer vertical lines on your 
illustration are the "x" limits {par(usr[1:2])} of the plot. What you 
have is a fairly simple algebra problem.


xrange = stringwidth1 + xlim + stringwidth2

Using the default plotting device on my setup:

xrange = 5.76 in.
stringwidth1 = 0.457 in.
stringwidth2 = 0.551 in.

Therefore xlim must fit into:

5.76 - 1.008 = 4.75 in.

Say your xlim (in user units) is 1 to 10. This means that the xlim 
passed to the plot command must be:


10 * 5.76/4.75 = 12.13

or if you want the default .04 padding on either side:

10.08 * 5.76/4.75 = 12.23

Having discovered this, you can now plot with:

xlim<-c(1 - 2.13 * 0.457/1.008,10 + 2.13 * 0.551/1.008)
plot(1:10,1:10,xlim=xlim,xaxt="n")
axis(1,at=1:10)
text(xlim[1],5,"Text 1")
text(xlim[2],5,"Label 2",adj=1)

So in general, plot without the strings with the full x range, then 
adjust for the strings, then plot again.


You will probably want to fiddle with the padding and text adjustments.

Jim

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


Re: [R] Need to learn or get R tutor in Minneapolis

2013-09-11 Thread Ben Harrison

On 10/09/13 06:45, sewal...@umn.edu wrote:

Please advise



Can't help you in Minneapolis, though surely your university has a 
statistics department?


To learn R there are many online tutorials and video guides. The latest 
is a large collection from the Google developers:

http://www.youtube.com/playlist?list=PLOU2XLYxmsIK9qQfztXeybpHvru-TrqAP

It's called Intro to R, and it currently has 21 videos.

Good luck,
Ben.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Subtracting elements of a vector from each other stepwise

2013-09-11 Thread Ben Harrison

If I were Michael (OP) right now, I think my head would be spinning.

As a newbie myself, I know how hard it is to read R code for the first 
time, so could it also be part of the newsgroup etiquette to at least 
partially explain provided code to newbies?


I agree that the interactive help '?' is available and should be 
consulted, but it would also be helpful if those of you with great 
experience could add a little guidance for your code.


Excuse me if this is out-of-place.

Ben


On 11/09/13 09:48, Ben Bolker wrote:

On 13-09-10 06:24 PM, arun wrote:

Hi,
May be this also works:

  dist(x)
#   1  2  3
#2  2
#3  6  4
#4 12 10  6

as.matrix(dist(x))
#   1  2 3  4
#1  0  2 6 12
#2  2  0 4 10
#3  6  4 0  6
#4 12 10 6  0
which(dist(x)==min(dist(x)))
#[1] 1
A.K.


   Yes, but you need to set the diagonal to NA, or something -- the OP
doesn't want to include self-comparison. It also helps to use
arr.ind=TRUE in which().  You're right that dist() would be a hair more
efficient that outer(...), though





- Original Message -
From: Ben Bolker 
To: r-h...@stat.math.ethz.ch
Cc:
Sent: Tuesday, September 10, 2013 5:39 PM
Subject: Re: [R] Subtracting elements of a vector from each other stepwise

arun  yahoo.com> writes:



Hi,
Not sure this is what you wanted:

  sapply(seq_along(x), function(i) {x1<- x[i]; x2<- x[-i];

x3<-x2[which.min(abs(x1-x2))];c(x1,x3)})

# [,1] [,2] [,3] [,4]
#[1,]   17   19   23   29
#[2,]   19   17   19   23
A.K.



   It's a little inefficient (because it constructs
the distances in both directions), but how about:

x = c(17,19,23,29)
d <- abs(outer(x,x,"-"))
diag(d) <- NA
d[lower.tri(d)] <- NA
which(d==min(d,na.rm=TRUE),arr.ind=TRUE)


?


- Original Message -
From: Michael Budnick  snet.net>
To: r-help  r-project.org
Cc:
Sent: Tuesday, September 10, 2013 4:06 PM
Subject: [R] Subtracting elements of a vector from each other stepwise

I am trying to figure out how to create a loop that will take the
difference of each member of a vector from each other and also spit out
which one has the least difference.

I do not want the vector member to subtract from itself or it must be able
to disregard the 0 obtained from subtracting from itself.

For example:

x = c(17,19,23,29)



[snip]

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

2013-09-11 Thread Bert Gunter
I would suggest you post this on the r-sig-ecology or r-sig-geo lists.
These seem both more relevant (r-help is for general R programming
questions, mostly) and more likely to have participants with suitable
expertise.

Cheers,
Bert


On Wed, Sep 11, 2013 at 12:32 PM, Maria Fernanda Bonetti <
fernanda_bone...@hotmail.com> wrote:

> I need to extract climatic variables of many shapefiles. I managed to do
> it, but doing one at a time (I have to do this for 3000 species).
> Well, I did the following:
> first I downloaded the rasters of BIOCLIM> bios <-getData ("Worldclim" var
> = "bio", res = 2.5, T = download)
> Ok, then I went with shapes (2 species did just to test).> teste_sp1
> <-readShapePoly ("sp1", IDVAR = NULL, proj4string = CRS (as.character
> (NA)), verbose = FALSE, repair = FALSE, FALSE = force_ring, delete_null_obj
> = FALSE, retrieve_ABS_null = FALSE)
> Finally, I used a function to extract the variables of shapes> v <-
> extract (bios, sp1)
>
> THE PROBLEM:The sp1 is a multi part polygon (23 features). I could make
> the average of these 23 lines and everything would be ok right? The problem
> is that some lines appears NA, and I have no idea why, and I can not just
> ignore that.
> Do I need to join these parts into a single polygon? I tried this with
> "unionSpatialPolygons" but another error appears: Error in
> unionSpatialPolygons (sp1, IDS, threshold = NULL,: input lengths differ
> Can anyone help me?
>
> Att,
> Maria Fernanda BonettiDoutoranda do Programa de Pós Graduação em Ecologia
> e Conservação - UFPRMestre em Ecologia e ConservaçãoPesquisadora do
> Instituto de Pesquisas Cananéia - IPeC
> [[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

[[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] rgl snapshot on headless server

2013-09-11 Thread Andreas Maunz
I am running Xvfb now with

-fbdir /some/path and
-extension RANDR

but rgl.snapshot is still not working.

Any other idea? Since I can display the webGL successfully in firefox (so
comes out correct), I assume there should be some way of converting it on
the server side to some (vector) graphic file format?

Thanks
Andreas



On Tue, Sep 10, 2013 at 6:38 PM, Duncan Murdoch wrote:

> On 10/09/2013 10:58 AM, Andreas Maunz wrote:
>
>> Hi all,
>>
>> I have a shiny app, in which I want to use rgl's snapshot function. I am
>> running Xvfb on my server so that rgl works. I start my shiny app as
>> follows:
>>
>> echo "Checking for Xvfb..."
>> pgrep -U username Xvfb > /dev/null 2>&1
>>
>> if [ "$?" -gt 0 ]; then
>>echo "Starting Xvfb..."
>>Xvfb :7 -screen 0 1280x1024x24 &
>>sleep 2
>> fi
>>
>> echo "...starting shiny"
>> export DISPLAY=":7"; R --no-save --no-restore -e "library('shiny');
>> runApp('/path/to/app', port=8101)"
>>
>> In the app, I do plot3d(), generate webGL and send the results to the
>> browser. But the rgl.snapshot or rgl.postscript functionality do not work,
>> i.e. they produce black or empty images. I assume this is due to Xvfb. Any
>> chance I can create snapshots?
>>
>
> rgl.snapshot requires the X server to maintain a frame buffer that it can
> read.   It looks as though something is going wrong with yours.  I don't
> use a system with Xvfb, so I can't really help, but you could try Googling
> to see if that turns anything up.
>
> rgl.postscript shouldn't need the X server, but it is limited in what it
> can display.
>
> Duncan Murdoch
>
>

[[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] list to matrix

2013-09-11 Thread arun
Hi,
Try:
set.seed(48)
lst1<-replicate(3,data.frame(y=rnorm(50),z=runif(50),x=sample(10:15,50,replace=TRUE)),simplify=FALSE)
 t(sapply(lst1,function(u) coef(lm(y~0+x+z,data=u  #change accordingly
#   x  z
#[1,] -0.01020553  0.3852990
#[2,] -0.01157726  0.3986898
#[3,]  0.01788307 -0.5624307

A.K.




- Original Message -
From: eliza botto 
To: "r-help@r-project.org" 
Cc: 
Sent: Wednesday, September 11, 2013 10:22 AM
Subject: [R] list to matrix

Dear useRs,
If i have a list of the following form and i want to convert the coefficient 
section of each element, combined into one matrix of dimension 3*5. How can i 
do that?I hope i am clear
thank in advance

[[1]]
Call:
lm(formula = mm[, i] ~ 0 + (x0 + x + xx + y + yy))
Coefficients:
     x0        x       xx        y       yy  
1.  -0.4250   0.2494   0.1683  -0.7449  

[[2]]
Call:
lm(formula = mm[, i] ~ 0 + (x0 + x + xx + y + yy))
Coefficients:
     x0        x       xx        y       yy  
1.  -0.6355   0.5876   0.2518  -0.7293  

[[3]]
Call:
lm(formula = mm[, i] ~ 0 + (x0 + x + xx + y + yy))
Coefficients:
     x0        x       xx        y       yy  
1.   0.5778   0.3838   0.4207  -0.1354  
                          
    [[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] Fitting Arima Model to Daily Time Series

2013-09-11 Thread Jose Iparraguirre
Paul
Good you ask because as far as I can remember (some people in the forum are 
experts on both time series and how R handles time series), it's not advisable 
to use the ts() function in the base package when dealing with daily 
observations (because of leap years, mostly).

Therefore, you need to use the packages zoo or xts, as explained here:  
http://stackoverflow.com/questions/8437620/analyzing-daily-weekly-data-using-ts-in-r
 
You can also use the package timeSeries. If you need to take into account 
weekdays or weekends (that depends on your research question and modelling, of 
course), R can do it for you as well.

Best,

José




From: Paul Bernal [mailto:paulberna...@gmail.com] 
Sent: 11 September 2013 15:41
To: Jose Iparraguirre
Cc: r-help@r-project.org
Subject: Re: [R] Fitting Arima Model to Daily Time Series

Dear Jose, good morning,

First of all, let me thank you for your extremely valuable help. Now I have a 
question for you:

I have a table containing two fields, the first one is date and the second one 
is number of transits of vessels. This table contains daily observations for 
the past 5 years.

The date field has the following format: -MM-DD

The number of transits field is a regular numeric field.

How can I do to convert this table into a time series object?

Best regards,

Paul



2013/9/11 Jose Iparraguirre 
Hi Paul,

There are different packages in R to fit an ARIMA model. I would use the 
forecast package.
In your case, perhaps you would want to explore SARIMA models to include 
seasonal components?
Anyhow, the first port of call could be the auto.arima() function to select the 
best fitting representation according to AIC, AICc or BIC -but explore other 
representations as well.
To fit the models use the function Arima (note the capital "A"). The 
documentation in the package is very clear and comprehensive; the authors (Rob 
J Hyndman and George Athanasopoulos) published a free on-line book which will 
also help you: http://otexts.com/fpp/.
Hope this helps,

José


Prof. José Iparraguirre
Chief Economist
Age UK



-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Paul Bernal
Sent: 10 September 2013 22:54
To: r-help@r-project.org
Subject: [R] Fitting Arima Model to Daily Time Series

Hello everyone,

Hope everyone is doing great. I would like to know how to use the arima 
function in R to fit arima or arma models to daily data, that is, with period = 
365, this taking into account the fact that I have 5 years worth of daily data 
(so 365 * 5 = my number of observations).

All I want is a very general line of code of I I would do to fit the arima 
model.

Any help will be greatly appreciated,

Have a wonderful day,

Paul
        [[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 Wireless from Age UK | Radio for grown-ups.

www.ageuk.org.uk/thewireless


If you're looking for a radio station that offers real variety, tune in to The 
Wireless from Age UK.
Whether you choose to listen through the website at 
www.ageuk.org.uk/thewireless, on digital radio (currently available in London 
and Yorkshire) or through our TuneIn Radio app, you can look forward to an 
inspiring mix of music, conversation and useful information 24 hours a day.




---
Age UK is a registered charity and company limited by guarantee, (registered 
charity number 1128267, registered company number 6825798).
Registered office: Tavis House, 1-6 Tavistock Square, London WC1H 9NA.

For the purposes of promoting Age UK Insurance, Age UK is an Appointed 
Representative of Age UK Enterprises Limited, Age UK is an Introducer
Appointed Representative of JLT Benefit Solutions Limited and Simplyhealth 
Access for the purposes of introducing potential annuity and health
cash plans customers respectively.  Age UK Enterprises Limited, JLT Benefit 
Solutions Limited and Simplyhealth Access are all authorised and
regulated by the Financial Services Authority.
--

This email and any files transmitted with it are confide...{{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] int vector

2013-09-11 Thread PIKAL Petr
Hi

data, data, data. Use dput(head(data,10)) if the data frame is too big.

zdrz <- structure(list(sklon = c(10, 10, 10, 10, 20, 20, 20, 20, 20, 
40, 40, 40, 40, 95, 95), ot = c(0.8, 1.5, 4, 10, 15, 1.5, 4, 
10, 15, 1.5, 4, 10, 15, 4, 15), doba = c(140, 111, 42.8, 20.3, 
15, 88, 38.25, 17., 12.5, 65.1667, 27, 12.5, 9.16667, 
15.75, 5.88333)), .Names = c("sklon", "ot", "doba"), row.names = c(NA, 
15L), class = "data.frame")


> sapply(zdrz, class)
sklonot  doba 
"integer" "numeric" "numeric" 
> dotchart(zdrz$sklon)
> fix(zdrz)
> sapply(zdrz, class)
sklonot  doba 
"numeric" "numeric" "numeric" 
> dotchart(zdrz$sklon)

fix changes column class to numeric but dotchart looks same to me

Regards
Petr

> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of Giles Crane
> Sent: Wednesday, September 11, 2013 5:21 PM
> To: r-help@r-project.org
> Subject: [R] int vector
> 
> 
> class int seems to interact oddly with fix() and dotchart().
> 
> Reading a .csv file when there are no decimal points in an item,
> results in a data.frame having a column of class int.  The mode,
> however, is numeric.
> 
> fix() does not recognize int "vectors",
> and thus does not spread its sheet.
> 
> dotchart() displays a 1 above the labels on the plot.
> 
> Converting the int column to numeric using as.numeric() cures the
> problems.  However, the behavior of the int class seems inconsistent.
> 
> R Version 3.01 (2013-05-16)
> 
> Thank you for your consideration.
> 
> Cordially,
> Giles
> 
> 
> --
> Giles L Crane, MPH, ASA, NJPHA
> Statistical Consultant and R Instructor
> 621 Lake Drive
> Princeton, NJ  08540
> Phone: 609 924-0971
> Email: gilescr...@verizon.net
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Chi-square values in GLM model comparison

2013-09-11 Thread Rune Haubo
There is no argument 'test' to anova.clm hence the error message.

The likelihood ratio statistic (or, alternatively, G^2 statistic or
Deviance statistic) has an asymptotic chi-square distribution, so it
is the size of that statistic your reviewers are asking for. It is
printed in the anova output under the name 'LR.stat' (1252 on 8 df in
your case it seems).

Cheers,
Rune

On 11 September 2013 18:17, Torvon  wrote:
> José,
>
> I get the following error message:
>
>> m1<-clm(sym_bin ~ phq_index, data=data2)
>> m2<-clm(sym_bin ~ 1, data=data2)
>> anova(m1,m2,test="Chisq")
>
>> Error in anova.clm(m1, m2, test = "Chisq") :
>>  only 'clm' and 'clmm' objects are allowed
>
> My dependent variable is binary, so I don't know what the problem could be.
> See below the model summaries. Thank you! Eiko
>
>> summary(m1)
> formula: sym_bin ~ phq_index
> data:data2
>
>  link  threshold nobs  logLik   AIC niter max.grad cond.H
>  logit flexible  12348 -4846.49 9710.97 7(0)  2.53e-08 1.4e+02
>
> Coefficients:
>Estimate Std. Error z value Pr(>|z|)
> phq_index2 -0.297050.11954  -2.4850.013 *
> phq_index3  0.633820.10262   6.176 6.56e-10 ***
> phq_index4  1.530220.09664  15.834  < 2e-16 ***
> phq_index5  0.907200.09996   9.075  < 2e-16 ***
> phq_index6 -0.038550.11337  -0.3400.734
> phq_index7 -0.064880.11394  -0.5690.569
> phq_index8 -1.156180.15156  -7.628 2.38e-14 ***
> phq_index9 -2.500640.25670  -9.741  < 2e-16 ***
> ---
> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
>
> Threshold coefficients:
> Estimate Std. Error z value
> 0|1  1.877700.07959   23.59
>
>
>> summary(m2)
> formula: sym_bin ~ 1
> data:data2
>
>  link  threshold nobs  logLik   AIC  niter max.grad
>  logit flexible  12348 -5472.48 10946.96 5(0)  1.01e-11
>
> Threshold coefficients:
>   0|1
> 1.642
>
>
>
>
>
>
>
> On 11 September 2013 18:03, Jose Iparraguirre <
> jose.iparragui...@ageuk.org.uk> wrote:
>
>> Hi Eiko,
>>
>> How about this?
>>
>> > anova (m1, m2, test="Chisq")
>>
>> See: ?anova.glm
>>
>> Regards,
>> José
>>
>>
>> Prof. José Iparraguirre
>> Chief Economist
>> Age UK
>>
>>
>>
>> -Original Message-
>> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
>> On Behalf Of Torvon
>> Sent: 11 September 2013 16:48
>> To: r-help@r-project.org
>> Subject: [R] Chi-square values in GLM model comparison
>>
>> Hello --
>> I am comparing two
>> GLMs (binomial dependent variable)
>> , the results are the following:
>> > m1<-glm(symptoms ~ phq_index, data=data2) m2<-glm(symptoms ~ 1,
>> > data=data2)
>>
>> Trying to compare these models using
>> > anova (m1, m2)
>> I do not obtain chi-square values or a chi-square difference test;
>> instead, I get loglikelihood ratios:
>>
>> > Likelihood ratio tests of cumulative link models:
>> > formula: link: threshold:
>> > m2 sym_bin ~ 1 logit flexible
>> > m1 sym_bin ~ phq_index logit flexible
>> >   no.par   AIC   logLik  LR.stat df Pr(>Chisq)
>> > m2  110947   -5472.5
>> > m1  9 9711   -4846.51252  8  < 2.2e-16 ***
>>
>> Since reviewers would like me to report chi-square values: how to I obtain
>> them when comparing GLMs? I'm looking for an output similar to the output
>> of the GLMER function in LME4, e.g.:
>>
>> > anova(m3,m4)
>> ...
>> >   Df   AIC   BIC  logLik Chisq Chi Df Pr(>Chisq)
>> > m3 13 11288 11393 -5630.9
>> > m4 21 11212 11382 -5584.9 92.02  8  < 2.2e-16 ***
>>
>> Thank you!
>>  Eiko
>>
>> [[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 Wireless from Age UK | Radio for grown-ups.
>>
>> www.ageuk.org.uk/thewireless
>>
>>
>> If you’re looking for a radio station that offers real variety, tune in to
>> The Wireless from Age UK.
>> Whether you choose to listen through the website at
>> www.ageuk.org.uk/thewireless, on digital radio (currently available in
>> London and Yorkshire) or through our TuneIn Radio app, you can look forward
>> to an inspiring mix of music, conversation and useful information 24 hours
>> a day.
>>
>>
>>
>>
>> ---
>> Age UK is a registered charity and company limited by guarantee,
>> (registered charity number 1128267, registered company number 6825798).
>> Registered office: Tavis House, 1-6 Tavistock Square, London WC1H 9NA.
>>
>> For the purposes of promoting Age UK Insurance, Age UK is an Appointed
>> Representative of Age UK Enterprises Limited, Age UK is an Introducer
>> Appointed Representative of JLT Benefit Solutions Limited and Simplyhealth
>> Access for the purposes of introducing potential annuity and health
>> cash plans customers respectively.  Age UK Enterprises Limited, JLT
>> Benefit 

Re: [R] (no subject)

2013-09-11 Thread PIKAL Petr
Hi

By HTML posting dput is scrambled and impossible to use.

Petr


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of eliza botto
> Sent: Wednesday, September 11, 2013 4:44 PM
> To: r-help@r-project.org
> Subject: [R] (no subject)
> 
> Now?>dput(gg)
> list(structure(list(coefficients = structure(c(1, 0.0747202722085956,
> 0.359646782818708, 0.298384925903065, -0.443967849195675), .Names =
> c("x0", "x", "xx", "y", "yy")), residuals = structure(c(-
> 0.302776084510551, 0.183247980798144, -0.337231904223223,
> 0.199348794823859, 0.290269994519382, -0.328261122410049, -
> 0.191844336069409, 0.309937888934371, 0.249963958976373, -
> 0.51656422321523, 0.0255108830245443, 0.418398169351789), .Names =
> c("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12")),
> effects = structure(c(-3.46410161513775, -0.183026540352922, -
> 0.880951105539393, 0.730890815400676, -1.08749469273032, -
> 0.055778138673626, 0.105917713121713, 0.425275592080333,
> 0.0893727217831096, -0.833878847761609, -0.213870821267818,
> 0.405405268871492), .Names = c("x0", "x", "xx", "y", "yy", "", "", "",
> "", "", "", "")), rank = 5L, fitted.values =
> structure(c(1.00923807240423, 0.815143487596117, 1.06126185691564,
> 1.50939808712151, 1.64879363631755, 1.22366465369447,!
>   0.520171981764853, 0.117496714766831, 0.341968291278227,
> 0.961191858709413, 1.4185661613195, 1.37310519811166), .Names = c("1",
> "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12")), assign
> = 1:5, qr = structure(list(qr = structure(c(-3.46410161513775,
> 0.288675134594813, 0.288675134594813, 0.288675134594813,
> 0.288675134594813, 0.288675134594813, 0.288675134594813,
> 0.288675134594813, 0.288675134594813, 0.288675134594813,
> 0.288675134594813, 0.288675134594813, 1.0359551758099e-16, -
> 2.44948974278318, -0.0791992255271195, -0.283323370759051, -
> 0.432752616120393, -0.487447515990983, -0.432752616120393, -
> 0.283323370759051, -0.0791992255271196, 0.124924919704812,
> 0.274354165066154, 0.329049064936743, 1.60326396256294e-16, -
> 4.06575814682064e-17, -2.44948974278318, 0.385357119965326,
> 0.276818123873927, 0.0876608486418726, -0.131430166589936, -
> 0.321749661221222, -0.432301680361632, -0.433463899760863, -
> 0.324924903669464,!
>   -0.13576762843741, 4.07117915768307e-17, 2.16515173845355e-16, 3.
> 30898503042576e-16, 2.44948974278318, -0.1565883283638, -
> 0.28412286470868, -0.0175072160832821, 0.422389924412376,
> 0.61883998250704, 0.369775078419853, -0.108638802574745, -
> 0.389352556693728, -7.42678488152571e-18, 6.07912158112622e-16,
> 4.95615918097436e-17, -1.02240264865383e-16, 2.44948974278318,
> 0.0399663322170986, -0.36906922926158, -0.453581151684979, -
> 0.103155496641535, 0.3733769380139, 0.545626107621939,
> 0.279668949241763), .Dim = c(12L, 5L), .Dimnames = list(c("1", "2",
> "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"), c("x0", "x",
> "xx", "y", "yy")), assign = 1:5), qraux = c(1.28867513459481,
> 1.12492491970481, 1.38419490056609, 1.18149437156933, 1.36122122075101
> ), pivot = 1:5, tol = 1e-07, rank = 5L), .Names = c("qr", "qraux",
> "pivot", "tol", "rank"), class = "qr"), df.residual = 7L, xlevels =
> structure(list(), .Names = character(0)), call = lm(formula = mm[,
> i] ~ 0 + (x0 + x + xx + y + yy)), terms = mm[!
>  , i] ~ 0 + (x0 + x + xx + y + yy), model =
> structure(list(`mm[, i]` = c(0.706461987893674, 0.998391468394261,
> 0.72402995269242, 1.70874688194537, 1.93906363083693,
> 0.89540353128442, 0.328327645695443, 0.427434603701202,
> 0.591932250254601, 0.444627635494183, 1.44407704434405,
> 1.79150336746345), x0 = structure(c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
> 1, 1), .Dim = c(12L, 1L)), x = structure(c(0.866025403784439, 0.5,
> 6.12303176911189e-17, -0.5, -0.866025403784439, -1, -
> 0.866025403784439, -0.5, -1.83690953073357e-16, 0.5, 0.866025403784438,
> 1), .Dim = c(12L, 1L)), xx = structure(c(0.5, 0.866025403784439, 1,
> 0.866025403784439, 0.5, 1.22460635382238e-16, -0.5, -0.866025403784438,
> -1, -0.866025403784439, -0.5, -2.44921270764475e-16), .Dim = c(12L,
> 1L)), y = structure(c(0.5, -0.5, -1, -0.5, 0.5, 1, 0.5, -
> 0.499, -1, -0.5, 0.499, 1), .Dim = c(12L,
> 1L)), yy = structure(c(0.866025403784439, 0.866025403784439,
> 1.2246!
>  0635382238e-16, -0.866025403784438, -0.866025403784439, -2.4492127
> 0764475e-16, 0.866025403784439, 0.866025403784439,
> 3.67381906146713e-16, -0.866025403784439, -0.866025403784439, -
> 4.89842541528951e-16), .Dim = c(12L, 1L))), .Names = c("mm[, i]",
> "x0", "x", "xx", "y", "yy"), terms = mm[, i] ~ 0 + (x0 + x + xx
> + y + yy), row.names = c(NA, 12L), class = "data.frame")), .Names =
> c("coefficients", "residuals", "effects", "rank", "fitted.values",
> "assign", "qr", "df.residual", "xlevels", "call", "terms", "model"),
> class = "l

Re: [R] Chi-square values in GLM model comparison

2013-09-11 Thread Marc Schwartz
Torvon,

There is some confusion in your postings, as in your first posting the models 
were GLM's but with the default gaussian family (not binomial) since the 
'family' argument was not present in the glm() call and in the second post you 
have references to clm() which is for ordinal response cumulative link models 
in the 'ordinal' CRAN package.

If you want binomial logistic regression models, you need to use:

  m1 <- glm(sym_bin ~ phq_index, data = data2, family = binomial)


As an example, using the ?infert dataset with a single IV:

MOD <- glm(case ~ education, data = infert, family = binomial)

> summary(MOD)

Call:
glm(formula = case ~ education, family = binomial, data = infert)

Deviance Residuals: 
Min   1Q   Median   3Q  Max  
-0.9053  -0.9053  -0.9005   1.4765   1.4823  

Coefficients:
   Estimate Std. Error z value Pr(>|z|)
(Intercept)  -6.931e-01  6.124e-01  -1.1320.258
education6-11yrs  4.477e-15  6.423e-01   0.0001.000
education12+ yrs  1.290e-02  6.431e-01   0.0200.984

(Dispersion parameter for binomial family taken to be 1)

Null deviance: 316.17  on 247  degrees of freedom
Residual deviance: 316.17  on 245  degrees of freedom
AIC: 322.17

Number of Fisher Scoring iterations: 4


> anova(MOD, test = "Chisq")
Analysis of Deviance Table

Model: binomial, link: logit

Response: case

Terms added sequentially (first to last)


  Df  Deviance Resid. Df Resid. Dev Pr(>Chi)
NULL 247 316.17 
education  2 0.0022894   245 316.17   0.9989


Regards,

Marc Schwartz


On Sep 11, 2013, at 11:17 AM, Torvon  wrote:

> José,
> 
> I get the following error message:
> 
>> m1<-clm(sym_bin ~ phq_index, data=data2)
>> m2<-clm(sym_bin ~ 1, data=data2)
>> anova(m1,m2,test="Chisq")
> 
>> Error in anova.clm(m1, m2, test = "Chisq") :
>> only 'clm' and 'clmm' objects are allowed
> 
> My dependent variable is binary, so I don't know what the problem could be.
> See below the model summaries. Thank you! Eiko
> 
>> summary(m1)
> formula: sym_bin ~ phq_index
> data:data2
> 
> link  threshold nobs  logLik   AIC niter max.grad cond.H
> logit flexible  12348 -4846.49 9710.97 7(0)  2.53e-08 1.4e+02
> 
> Coefficients:
>   Estimate Std. Error z value Pr(>|z|)
> phq_index2 -0.297050.11954  -2.4850.013 *
> phq_index3  0.633820.10262   6.176 6.56e-10 ***
> phq_index4  1.530220.09664  15.834  < 2e-16 ***
> phq_index5  0.907200.09996   9.075  < 2e-16 ***
> phq_index6 -0.038550.11337  -0.3400.734
> phq_index7 -0.064880.11394  -0.5690.569
> phq_index8 -1.156180.15156  -7.628 2.38e-14 ***
> phq_index9 -2.500640.25670  -9.741  < 2e-16 ***
> ---
> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> 
> Threshold coefficients:
>Estimate Std. Error z value
> 0|1  1.877700.07959   23.59
> 
> 
>> summary(m2)
> formula: sym_bin ~ 1
> data:data2
> 
> link  threshold nobs  logLik   AIC  niter max.grad
> logit flexible  12348 -5472.48 10946.96 5(0)  1.01e-11
> 
> Threshold coefficients:
>  0|1
> 1.642
> 
> 
> 
> 
> 
> 
> 
> On 11 September 2013 18:03, Jose Iparraguirre <
> jose.iparragui...@ageuk.org.uk> wrote:
> 
>> Hi Eiko,
>> 
>> How about this?
>> 
>>> anova (m1, m2, test="Chisq")
>> 
>> See: ?anova.glm
>> 
>> Regards,
>> José
>> 
>> 
>> Prof. José Iparraguirre
>> Chief Economist
>> Age UK
>> 
>> 
>> 
>> -Original Message-
>> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
>> On Behalf Of Torvon
>> Sent: 11 September 2013 16:48
>> To: r-help@r-project.org
>> Subject: [R] Chi-square values in GLM model comparison
>> 
>> Hello --
>> I am comparing two
>> GLMs (binomial dependent variable)
>> , the results are the following:
>>> m1<-glm(symptoms ~ phq_index, data=data2) m2<-glm(symptoms ~ 1,
>>> data=data2)
>> 
>> Trying to compare these models using
>>> anova (m1, m2)
>> I do not obtain chi-square values or a chi-square difference test;
>> instead, I get loglikelihood ratios:
>> 
>>> Likelihood ratio tests of cumulative link models:
>>> formula: link: threshold:
>>> m2 sym_bin ~ 1 logit flexible
>>> m1 sym_bin ~ phq_index logit flexible
>>>  no.par   AIC   logLik  LR.stat df Pr(>Chisq)
>>> m2  110947   -5472.5
>>> m1  9 9711   -4846.51252  8  < 2.2e-16 ***
>> 
>> Since reviewers would like me to report chi-square values: how to I obtain
>> them when comparing GLMs? I'm looking for an output similar to the output
>> of the GLMER function in LME4, e.g.:
>> 
>>> anova(m3,m4)
>> ...
>>>  Df   AIC   BIC  logLik Chisq Chi Df Pr(>Chisq)
>>> m3 13 11288 11393 -5630.9
>>> m4 21 11212 11382 -5584.9 92.02  8  < 2.2e-16 ***
>> 
>> Thank you!
>> Eiko

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

[R] Chi-square values in GLM model comparison

2013-09-11 Thread Torvon
Hello --
I am comparing two
GLMs (binomial dependent variable)
, the results are the following:
> m1<-glm(symptoms ~ phq_index, data=data2)
> m2<-glm(symptoms ~ 1, data=data2)

Trying to compare these models using
> anova (m1, m2)
I do not obtain chi-square values or a chi-square difference test; instead,
I get loglikelihood ratios:

> Likelihood ratio tests of cumulative link models:
> formula: link: threshold:
> m2 sym_bin ~ 1 logit flexible
> m1 sym_bin ~ phq_index logit flexible
>   no.par   AIC   logLik  LR.stat df Pr(>Chisq)
> m2  110947   -5472.5
> m1  9 9711   -4846.51252  8  < 2.2e-16 ***

Since reviewers would like me to report chi-square values: how to I obtain
them when comparing GLMs? I'm looking for an output similar to the output
of the GLMER function in LME4, e.g.:

> anova(m3,m4)
...
>   Df   AIC   BIC  logLik Chisq Chi Df Pr(>Chisq)
> m3 13 11288 11393 -5630.9
> m4 21 11212 11382 -5584.9 92.02  8  < 2.2e-16 ***

Thank you!
 Eiko

[[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/S-PLUS Course schedule in US - XLSolutions Corp

2013-09-11 Thread Sue Turner
XLSolutions is working our October-November-December course schedule and
now seeking your input for your prefered location and courses.

September 2013 R/S-PLUS courses are available online
http://www.xlsolutions-corp.com/courselistlisting.aspx
 
(1) R-PLUS: A Point-and-Click Approach to R
(2) S-PLUS / R : Programming Essentials.
(3) R/S+ Fundamentals and Programming Techniques
(4) R/S-PLUS Functions by Example.
(5) S/R-PLUS Programming 3: Advanced Techniques and Efficiencies.
(6) R/S+ System: Advanced Programming.
(7) R/S-PLUS Graphics: Essentials.
(8) R/S-PLUS Graphics for SAS Users
(9) R/S-PLUS Graphical Techniques for Marketing Research.
(10) Multivariate Statistical Methods in R/S-PLUS: Practical Research
Applications
(11) Introduction to Applied Econometrics with R/S-PLUS
(12) Exploratory Analysis for Large and Complex Problems in R/S-PLUS
(13) Determining Power and Sample Size Using R/S-PLUS.
(14) R/S-PLUS: Data Preparation for Data Mining
(15) Data Cleaning Techniques in R/S-PLUS
(16) R/S-PLUS: Applied Clustering Techniques


More on website

http://www.xlsolutions-corp.com/courselistlisting.aspx

Ask for group discount and reserve your seat Now - Earlybird Rates.
Payment due after the class! Email Sue Turner: sue at
xlsolutions-corp.com

Phone: 206-686-1578


Please let us know if you and your colleagues are interested in this
class to take advantage of group discount. Register now to secure your
seat.

Cheers,
Elvis Miller, PhD
Manager Training.
XLSolutions Corporation
206 686 1578
www.xlsolutions-corp.com
elvis at xlsolutions-corp.com

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


Re: [R] how to read data from MSExcel into R

2013-09-11 Thread Ista Zahn
I don't think you need admin rights to install R packages. Did you try it?

Best,
Ista

On Wed, Sep 11, 2013 at 9:01 AM, Charles Thuo  wrote:
> how can one read data from MSEXcel into R especially in a case where one
> does not have administrator rights to install additional packages. In short
> how to read data from MSExcel into R with base packages only.
>
> [[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] ggplot interactions

2013-09-11 Thread Robert Lynch
> I am sorry to ask what I am sure is a simple question but I am stuck
> trying to figure out how different parts of ggplot2 calls interact
>
> I am plotting using the following code
>
> ggplot(Chem.comp, aes(Course, GRADE)) + geom_boxplot(notch = TRUE,aes(fill
> = COHORT))+
>   labs(y ="Grade Points in class",
>x = "Chemistry 2 quarter") +
>   ggtitle(expression(atop("Comparison between ISE cohorts and Peers",
> atop(italic("in Chem 2 classes"), ""
>   ylim(0,4.)+
>   scale_fill_manual(name = "ISE Cohorts &\nComparison groups",
> values =
> c("blue","red","blue3","red3","blue4","red4")) +
>   theme(plot.title = element_text(size = 25, face = "bold", colour =
> "black", vjust = -1))+
>   guides(fill = guide_legend(nrow = 3),byrow = TRUE)
>
> which gives me a plot [available as a jpeg, not attached due to size
> limits]  which is has the appropriate title, but the colors and the legend
> are wrong. The colors cycle through R's standard colors, and the legend is
> 1 column.
>
> if I comment out the ggtitle() and theme(), or just ggtitle() I get a plot
> [available, but not attached ue to size limits] which has the right colors
> and mostly right legend, but no title and subtitle.  The legend is out of
> order.  the first row should read ISE07 CMP07 with 08 on the second row and
> 09 the third with a red column and a blue column.  Changing byrow = TRUE to
> bycol = TRUE does not change the plotting of the legend nor does byrow=FALSE
>
> I am asking for help with getting the title and sub-title to both show up
> at the same time as the appropriate colors for the different factor levels.
> And to get the legend to render so that the legend looks sort of like
> ISE07[red box][blue box   ]CMP07
> ISE08 [red3 box] [blue3 box]CMP08
> ISE09 [red4 box] [blue4 box]CMP09
> the exact colors are not important but the the vertical
> and horizontal alignment is.
>
> Thanks!
> Robert
>

[[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] meta-analysis of annualized event rate

2013-09-11 Thread petretta

 r-help@r-project.org

Dear all,

I use R 2.15.2 for Windows 8

I ask if it is possible perform a meta-analysis of annualized event  
rate from several studies reporting


1) number of patients enrolled (N)
2) mean lenght of follow-up time (mo)
3) annualized event rate (AER) (expressed as % person-year)

I would like suggestions on package(s) and code.

Many thanks in advance.





--
Mario Petretta
Department of Translational Medical Sciences
Naples University Federico II
Italy

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

2013-09-11 Thread Maria Fernanda Bonetti
I need to extract climatic variables of many shapefiles. I managed to do it, 
but doing one at a time (I have to do this for 3000 species).
Well, I did the following:
first I downloaded the rasters of BIOCLIM> bios <-getData ("Worldclim" var = 
"bio", res = 2.5, T = download)
Ok, then I went with shapes (2 species did just to test).> teste_sp1 
<-readShapePoly ("sp1", IDVAR = NULL, proj4string = CRS (as.character (NA)), 
verbose = FALSE, repair = FALSE, FALSE = force_ring, delete_null_obj = FALSE, 
retrieve_ABS_null = FALSE)
Finally, I used a function to extract the variables of shapes> v <- extract 
(bios, sp1)

THE PROBLEM:The sp1 is a multi part polygon (23 features). I could make the 
average of these 23 lines and everything would be ok right? The problem is that 
some lines appears NA, and I have no idea why, and I can not just ignore that.
Do I need to join these parts into a single polygon? I tried this with 
"unionSpatialPolygons" but another error appears: Error in unionSpatialPolygons 
(sp1, IDS, threshold = NULL,: input lengths differ
Can anyone help me?

Att,
Maria Fernanda BonettiDoutoranda do Programa de Pós Graduação em Ecologia e 
Conservação - UFPRMestre em Ecologia e ConservaçãoPesquisadora do Instituto de 
Pesquisas Cananéia - IPeC  
[[alternative HTML version deleted]]

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


[R] How to split a plot into vertical subregions with width proportional to length of a character string?

2013-09-11 Thread isabella
 

 BODY { font-family:Arial, Helvetica, sans-serif;font-size:12px;
}Hello, 

I am trying to create a plot whose x-axis is wide enough to
accommodate the following: 

a) a character string on the left side (i.e., Text 1);
 b) a known range of values in the middle (i.e., Range);
 c) a character string on the right side (i.e., Label 2) 

The plot would start with the range of values in the middle and would
be expanded to the left and right by a width proportional to the
length of Text 1 and Label 2, respectively.  (The width would need to
be expressed in the same units as those of the middle range of
values.) 

In R, how can I determine the width of Text 1 and Label 2 and express
it in the same units as those pertaining to Range?  (I know how to
determine the width of these character strings in inches for a given
plot via strwidth(), but for some reason I am not able to connect that
width to the units of Range.)

Here is some R code illustrating what the plot would look like:
 plot(NA, xlim=c(1,10), ylim=c(1,5),type="N")
 abline(v=1,lty=2,col="red")
 abline(v=2,lty=2,col="red") 
 abline(v=8,lty=3,col="blue")
 abline(v=10,lty=3,col="blue") 
 text(1,3,"Text 1",pos=4)
 text(8,3,"Label 2",pos=4)
 arrows(2,3,8,3,code=3, length=0.1,lwd=2)
 text(5,3,"Range",pos=3)
Thank you in advance for any ideas you can provide.

Isabella 
 Isabella R. Ghement, Ph.D. 
 Ghement Statistical Consulting Company Ltd. 
 301-7031 Blundell Road, Richmond, B.C., Canada, V6Y 1J5 
 Tel: 604-767-1250 
 Fax: 604-270-3922 
 E-mail: isabe...@ghement.ca 
 Web: www.ghement.ca 
  
[[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] About qmap package

2013-09-11 Thread Jaya Pudashine
Dear all,
I am trying to use qmap package for bias correction in R.  If anybody had
used that before or using it currently, I would like to discuss about a few
matters. I would be thankful for your help


Thanking in advance


-- 
Jaya

[[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] include variable of a dataframe in other dataframe

2013-09-11 Thread ernesto villarino
It works !!! you are super !!! thank you !! :)


On Wed, Sep 11, 2013 at 10:22 AM, Ernesto Villarino <
villarino.erne...@gmail.com> wrote:

> Hello Ian.
> I explained wrong myself.
> summary (data.all.evp)
>   Year  Month LongLat z
>
>  Min.   :1959   Jan:124200   Min.   :-74.0   Min.   :36.0   Min.
> :-5615.00
>  1st Qu.:1970   Feb:124200   1st Qu.:-52.0   1st Qu.:43.0   1st
> Qu.:-3451.25
>  Median :1982   Mar:124200   Median :-29.5   Median :50.5   Median
> :-1393.00
>  Mean   :1982   Apr:124200   Mean   :-29.5   Mean   :50.5   Mean
> :-1706.32
>  3rd Qu.:1993   May:124200   3rd Qu.: -7.0   3rd Qu.:58.0   3rd Qu.:
>  3.25
>  Max.   :2004   Jun:124200   Max.   : 15.0   Max.   :65.0   Max.   :
> 2997.00
> (Other):745200
>
>  > summary (data.fut.evp)
>   LatLong   Month  Year   SST
>  SSS
>  Min.   :36.0   Min.   :-74.0   Jan: 267300   Min.   :2001   Min.
> :-1.9 Min.   : 0.0
>  1st Qu.:43.0   1st Qu.:-52.0   Feb: 267300   1st Qu.:2025   1st Qu.:
> 8.7 1st Qu.:33.8
>  Median :50.5   Median :-29.5   Mar: 267300   Median :2050   Median
> :12.0 Median :34.7
>  Mean   :50.5   Mean   :-29.5   Apr: 267300   Mean   :2050   Mean
> :12.5 Mean   :34.2
>  3rd Qu.:58.0   3rd Qu.: -7.0   May: 267300   3rd Qu.:2075   3rd
> Qu.:16.3 3rd Qu.:35.3
>  Max.   :65.0   Max.   : 15.0   Jun: 267300   Max.   :2099   Max.
> :31.7 Max.   :39.7
> (Other):1603800  NA's
> :803088   NA's   :805464
>
> > 90*30*12*46 (lat*long*month*year, data.all.evp)
> [1] 1490400
> > 90*30*12*100 (lat*long*month*year,data.fut.evp)
> [1] 324
>
> If you look to z (it is unique for the 30*90=2700 lat and long
> combinations every month, but then it is the same for every years or months.
> You got me ?
> I am going to try your code, and let you know,
> Cheers,
> Ernes
>
>
>
> On Wed, Sep 11, 2013 at 6:41 AM, I.Renner [via R] <
> ml-node+s789695n4675835...@n4.nabble.com> wrote:
>
>> Hi Ernesto,
>>
>> I should first convey that I am by no means an expert, so I'm sure
>> someone will have a more elegant solution.
>>
>> One thing that seems strange is that there appear to be fewer depth
>> values (1557192) than rows in the data frame for which you would like to
>> include them (3207600).
>>
>> z.new = rep(NA, dim(data.fut.evp)[1])
>> z.index = match(paste(data.fut.evp$Lat, data.fut.evp$Long),
>> paste(data.all.evp$Lat, data.all.evp$Long))
>> z.new = data.all.evp$z[z.index]
>> data.fut.evp$z = z.new
>>
>> Hope this helps,
>>
>> Ian
>>
>>
>> --
>>  If you reply to this email, your message will be added to the
>> discussion below:
>>
>> http://r.789695.n4.nabble.com/include-variable-of-a-dataframe-in-other-dataframe-tp4675730p4675835.html
>>  To start a new topic under R help, email
>> ml-node+s789695n789696...@n4.nabble.com
>> To unsubscribe from include variable of a dataframe in other dataframe, click
>> here
>> .
>> NAML
>>
>
>




--
View this message in context: 
http://r.789695.n4.nabble.com/include-variable-of-a-dataframe-in-other-dataframe-tp4675730p4675887.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] Running Loops

2013-09-11 Thread jfrei006
I have a data set called yall with 5000 rows, I want to randomly sub sample
100 rows 100 times.
This is what I have so far:

yall<-read.csv("Z:\\SOFTEL\\North Key Largo
project\\Canopy_Height\\random_age_strat\\Young\\Abv2ft_young.csv")

*yall1 <- yall[sample(1:nrow(yall), 100, replace=FALSE),]

write.csv(yall1, file = "yall1.csv")*

I want to run a loop of the bold script above 100 times, but I want to be
able to change the name of the sub sample and name of the csv file each
time. They should be named yall1, yall2,yall3...etc until 100.



--
View this message in context: 
http://r.789695.n4.nabble.com/Running-Loops-tp4675886.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] Chi-square values in GLM model comparison

2013-09-11 Thread Jose Iparraguirre
Hi Eiko,

How about this?

> anova (m1, m2, test="Chisq")

See: ?anova.glm

Regards,
José


Prof. José Iparraguirre
Chief Economist
Age UK



-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Torvon
Sent: 11 September 2013 16:48
To: r-help@r-project.org
Subject: [R] Chi-square values in GLM model comparison

Hello --
I am comparing two
GLMs (binomial dependent variable)
, the results are the following:
> m1<-glm(symptoms ~ phq_index, data=data2) m2<-glm(symptoms ~ 1, 
> data=data2)

Trying to compare these models using
> anova (m1, m2)
I do not obtain chi-square values or a chi-square difference test; instead, I 
get loglikelihood ratios:

> Likelihood ratio tests of cumulative link models:
> formula: link: threshold:
> m2 sym_bin ~ 1 logit flexible
> m1 sym_bin ~ phq_index logit flexible
>   no.par   AIC   logLik  LR.stat df Pr(>Chisq)
> m2  110947   -5472.5
> m1  9 9711   -4846.51252  8  < 2.2e-16 ***

Since reviewers would like me to report chi-square values: how to I obtain them 
when comparing GLMs? I'm looking for an output similar to the output of the 
GLMER function in LME4, e.g.:

> anova(m3,m4)
...
>   Df   AIC   BIC  logLik Chisq Chi Df Pr(>Chisq)
> m3 13 11288 11393 -5630.9
> m4 21 11212 11382 -5584.9 92.02  8  < 2.2e-16 ***

Thank you!
 Eiko

[[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 Wireless from Age UK | Radio for grown-ups.

www.ageuk.org.uk/thewireless


If you’re looking for a radio station that offers real variety, tune in to The 
Wireless from Age UK. 
Whether you choose to listen through the website at 
www.ageuk.org.uk/thewireless, on digital radio (currently available in London 
and Yorkshire) or through our TuneIn Radio app, you can look forward to an 
inspiring mix of music, conversation and useful information 24 hours a day.



 
---
Age UK is a registered charity and company limited by guarantee, (registered 
charity number 1128267, registered company number 6825798). 
Registered office: Tavis House, 1-6 Tavistock Square, London WC1H 9NA.

For the purposes of promoting Age UK Insurance, Age UK is an Appointed 
Representative of Age UK Enterprises Limited, Age UK is an Introducer 
Appointed Representative of JLT Benefit Solutions Limited and Simplyhealth 
Access for the purposes of introducing potential annuity and health 
cash plans customers respectively.  Age UK Enterprises Limited, JLT Benefit 
Solutions Limited and Simplyhealth Access are all authorised and 
regulated by the Financial Services Authority. 
--

This email and any files transmitted with it are confidential and intended 
solely for the use of the individual or entity to whom they are 
addressed. If you receive a message in error, please advise the sender and 
delete immediately.

Except where this email is sent in the usual course of our business, any 
opinions expressed in this email are those of the author and do not 
necessarily reflect the opinions of Age UK or its subsidiaries and associated 
companies. Age UK monitors all e-mail transmissions passing 
through its network and may block or modify mails which are deemed to be 
unsuitable.

Age Concern England (charity number 261794) and Help the Aged (charity number 
272786) and their trading and other associated companies merged 
on 1st April 2009.  Together they have formed the Age UK Group, dedicated to 
improving the lives of people in later life.  The three national 
Age Concerns in Scotland, Northern Ireland and Wales have also merged with Help 
the Aged in these nations to form three registered charities: 
Age Scotland, Age NI, Age Cymru.




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

2013-09-11 Thread Ista Zahn
Hi Robert,

It is really hard to follow this without the data or a reproducible
example. Also your attachments did not come through. Please read the
posting guide and re-formulate your question to make it easier to help
you. Finally, note that there is a separate ggplot2 mailing list at
https://groups.google.com/forum/?fromgroups#!forum/ggplot2

Best,
Ista

On Wed, Sep 11, 2013 at 1:53 PM, Robert Lynch  wrote:
>> I am sorry to ask what I am sure is a simple question but I am stuck
>> trying to figure out how different parts of ggplot2 calls interact
>>
>> I am plotting using the following code
>>
>> ggplot(Chem.comp, aes(Course, GRADE)) + geom_boxplot(notch = TRUE,aes(fill
>> = COHORT))+
>>   labs(y ="Grade Points in class",
>>x = "Chemistry 2 quarter") +
>>   ggtitle(expression(atop("Comparison between ISE cohorts and Peers",
>> atop(italic("in Chem 2 classes"), ""
>>   ylim(0,4.)+
>>   scale_fill_manual(name = "ISE Cohorts &\nComparison groups",
>> values =
>> c("blue","red","blue3","red3","blue4","red4")) +
>>   theme(plot.title = element_text(size = 25, face = "bold", colour =
>> "black", vjust = -1))+
>>   guides(fill = guide_legend(nrow = 3),byrow = TRUE)
>>
>> which gives me a plot [available as a jpeg, not attached due to size
>> limits]  which is has the appropriate title, but the colors and the legend
>> are wrong. The colors cycle through R's standard colors, and the legend is
>> 1 column.
>>
>> if I comment out the ggtitle() and theme(), or just ggtitle() I get a plot
>> [available, but not attached ue to size limits] which has the right colors
>> and mostly right legend, but no title and subtitle.  The legend is out of
>> order.  the first row should read ISE07 CMP07 with 08 on the second row and
>> 09 the third with a red column and a blue column.  Changing byrow = TRUE to
>> bycol = TRUE does not change the plotting of the legend nor does byrow=FALSE
>>
>> I am asking for help with getting the title and sub-title to both show up
>> at the same time as the appropriate colors for the different factor levels.
>> And to get the legend to render so that the legend looks sort of like
>> ISE07[red box][blue box   ]CMP07
>> ISE08 [red3 box] [blue3 box]CMP08
>> ISE09 [red4 box] [blue4 box]CMP09
>> the exact colors are not important but the the vertical
>> and horizontal alignment is.
>>
>> Thanks!
>> Robert
>>
>
> [[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] Matrix mulitplication

2013-09-11 Thread arun
Hi,
Try:


set.seed(445)
A<- matrix(sample(1:20,124*5,replace=TRUE),ncol=5)

set.seed(42)
B<- matrix(sample(1:25,12*5,replace=TRUE),ncol=5)
 res<- sapply(seq_len(nrow(A)),function(i) colSums(A[i,]*t(B)))

 dim(res)
#[1]  12 124

A.K.




From: eliza botto 
To: "smartpink...@yahoo.com"  
Sent: Wednesday, September 11, 2013 11:37 AM
Subject: 




Dear Arun,
Thanks for your previous reply. i have another question. if i have to matrix A 
and matrix B. matrix A is of dimension 124 row * 5 columns and B has a 
dimension of 12*5. 

What i want is to multiply each column of matrix B with each element of 
corresponding column A and then add.
more precisely

For Row 1 of A
A[1,1]*B[,1]+A[1,2]*B[,2]+A[1,3]*B[,3]+A[1,4]*B[,4]+A[1,5]*B[,5]


For Row 2 of A
A[2,1]*B[,1]+A[2,2]*B[,2]+A[2,3]*B[,3]+A[2,4]*B[,4]+A[2,5]*B[,5]

So in the end we should have a matrix of 12 rows and 124 columns.

I hope i m clear. if you feel any problem please tell me.

Eliza

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Chi-square values in GLM model comparison

2013-09-11 Thread Torvon
José,

I get the following error message:

> m1<-clm(sym_bin ~ phq_index, data=data2)
> m2<-clm(sym_bin ~ 1, data=data2)
> anova(m1,m2,test="Chisq")

> Error in anova.clm(m1, m2, test = "Chisq") :
>  only 'clm' and 'clmm' objects are allowed

My dependent variable is binary, so I don't know what the problem could be.
See below the model summaries. Thank you! Eiko

> summary(m1)
formula: sym_bin ~ phq_index
data:data2

 link  threshold nobs  logLik   AIC niter max.grad cond.H
 logit flexible  12348 -4846.49 9710.97 7(0)  2.53e-08 1.4e+02

Coefficients:
   Estimate Std. Error z value Pr(>|z|)
phq_index2 -0.297050.11954  -2.4850.013 *
phq_index3  0.633820.10262   6.176 6.56e-10 ***
phq_index4  1.530220.09664  15.834  < 2e-16 ***
phq_index5  0.907200.09996   9.075  < 2e-16 ***
phq_index6 -0.038550.11337  -0.3400.734
phq_index7 -0.064880.11394  -0.5690.569
phq_index8 -1.156180.15156  -7.628 2.38e-14 ***
phq_index9 -2.500640.25670  -9.741  < 2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Threshold coefficients:
Estimate Std. Error z value
0|1  1.877700.07959   23.59


> summary(m2)
formula: sym_bin ~ 1
data:data2

 link  threshold nobs  logLik   AIC  niter max.grad
 logit flexible  12348 -5472.48 10946.96 5(0)  1.01e-11

Threshold coefficients:
  0|1
1.642







On 11 September 2013 18:03, Jose Iparraguirre <
jose.iparragui...@ageuk.org.uk> wrote:

> Hi Eiko,
>
> How about this?
>
> > anova (m1, m2, test="Chisq")
>
> See: ?anova.glm
>
> Regards,
> José
>
>
> Prof. José Iparraguirre
> Chief Economist
> Age UK
>
>
>
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On Behalf Of Torvon
> Sent: 11 September 2013 16:48
> To: r-help@r-project.org
> Subject: [R] Chi-square values in GLM model comparison
>
> Hello --
> I am comparing two
> GLMs (binomial dependent variable)
> , the results are the following:
> > m1<-glm(symptoms ~ phq_index, data=data2) m2<-glm(symptoms ~ 1,
> > data=data2)
>
> Trying to compare these models using
> > anova (m1, m2)
> I do not obtain chi-square values or a chi-square difference test;
> instead, I get loglikelihood ratios:
>
> > Likelihood ratio tests of cumulative link models:
> > formula: link: threshold:
> > m2 sym_bin ~ 1 logit flexible
> > m1 sym_bin ~ phq_index logit flexible
> >   no.par   AIC   logLik  LR.stat df Pr(>Chisq)
> > m2  110947   -5472.5
> > m1  9 9711   -4846.51252  8  < 2.2e-16 ***
>
> Since reviewers would like me to report chi-square values: how to I obtain
> them when comparing GLMs? I'm looking for an output similar to the output
> of the GLMER function in LME4, e.g.:
>
> > anova(m3,m4)
> ...
> >   Df   AIC   BIC  logLik Chisq Chi Df Pr(>Chisq)
> > m3 13 11288 11393 -5630.9
> > m4 21 11212 11382 -5584.9 92.02  8  < 2.2e-16 ***
>
> Thank you!
>  Eiko
>
> [[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 Wireless from Age UK | Radio for grown-ups.
>
> www.ageuk.org.uk/thewireless
>
>
> If you’re looking for a radio station that offers real variety, tune in to
> The Wireless from Age UK.
> Whether you choose to listen through the website at
> www.ageuk.org.uk/thewireless, on digital radio (currently available in
> London and Yorkshire) or through our TuneIn Radio app, you can look forward
> to an inspiring mix of music, conversation and useful information 24 hours
> a day.
>
>
>
>
> ---
> Age UK is a registered charity and company limited by guarantee,
> (registered charity number 1128267, registered company number 6825798).
> Registered office: Tavis House, 1-6 Tavistock Square, London WC1H 9NA.
>
> For the purposes of promoting Age UK Insurance, Age UK is an Appointed
> Representative of Age UK Enterprises Limited, Age UK is an Introducer
> Appointed Representative of JLT Benefit Solutions Limited and Simplyhealth
> Access for the purposes of introducing potential annuity and health
> cash plans customers respectively.  Age UK Enterprises Limited, JLT
> Benefit Solutions Limited and Simplyhealth Access are all authorised and
> regulated by the Financial Services Authority.
> --
>
> This email and any files transmitted with it are confidential and intended
> solely for the use of the individual or entity to whom they are
> addressed. If you receive a message in error, please advise the sender and
> delete immediately.
>
> Except where this email is sent in the usual course of our business, any
> opinions expressed in this email are those of the author and do not
> necessarily reflect the opinions of Age UK or its subsidiaries an

Re: [R] windowing

2013-09-11 Thread arun
Hi,
Try:
library(plyr)
 ddply(df,.(x1),summarize,x=cumsum(x2))
#   x1  x
#1   1  1
#2   1  3
#3   1  6
#4   1 10
#5   1 15
#6   1 21
#7   1 28
#8   1 36
#9   1 45
#10  1 55
#11  2 11
#12  2 23
#13  2 36
#14  2 50
#15  2 65
#16  2 81
#17  2 98


#or using a1

 df2<- data.frame(x1=rep(a1$x1,sapply(a1$x,length)),x=unlist(a1$x))
row.names(df2)<-1:nrow(df2)


A.K.



- Original Message -
From: "Bond, Stephen" 
To: "'MacQueen, Don'" ; "r-help@r-project.org" 

Cc: 
Sent: Wednesday, September 11, 2013 11:36 AM
Subject: Re: [R] windowing

Very interesting. Does not produce a solution outright, but may be still usable

> df <- data.frame(x1=c(rep(1,10),rep(2,7)),x2=rep(1:17))
> aggregate(df$x2,by=list(x1=df$x1),cumsum)-> a1
> a1
  x1                                   x
1  1 1, 3, 6, 10, 15, 21, 28, 36, 45, 55
2  2          11, 23, 36, 50, 65, 81, 98
> dim(a1)
[1] 2 2
> a1[1,2]
$`0`
[1]  1  3  6 10 15 21 28 36 45 55

> a1[2,2]
$`1`
[1] 11 23 36 50 65 81 98

> class(a1[2,2])
[1] "list"

If anybody can suggest how to create a reshape-able dataframe out of this, 
please speak. 
Ideally I should be able to use 

reshape(a1,dir="long",varying=2:11,idvar="x1",v.names="x")

to get it back in long form.
Thank everybody.

Stephen B
-Original Message-
From: MacQueen, Don [mailto:macque...@llnl.gov] 
Sent: Wednesday, September 11, 2013 10:42 AM
To: Bond, Stephen; r-help@r-project.org
Subject: Re: [R] windowing

>From the help page for the aggregate function:


Compute Summary Statistics of Data Subsets

Description:

     Splits the data into subsets, computes summary statistics for
     each, and returns the result in a convenient form.




You might have to use cumsum() after the aggregation, if
"unbounded preceding" causes a cumulative sum to be calculated.

-Don
-- 
Don MacQueen

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





On 9/9/13 11:58 AM, "Bond, Stephen"  wrote:

>Is there a package or a command that does window aggregation like
>
>select
>sum(col1) over
>(partition by col2, col3 order by col4
>rows between unbounded preceding and current row) as sum1
>from table1 ;
>
>the above is Netezza syntax, but Postgre has same capability.
>
>Stephen B
>
>    [[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-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] rgl snapshot on headless server

2013-09-11 Thread Duncan Murdoch

On 11/09/2013 11:44 AM, Andreas Maunz wrote:

I am running Xvfb now with

-fbdir /some/path and
-extension RANDR

but rgl.snapshot is still not working.

Any other idea? Since I can display the webGL successfully in firefox 
(so comes out correct), I assume there should be some way of 
converting it on the server side to some (vector) graphic file format?


The .html file that writeWebGL produces could be considered to be that, 
but it's really mostly Javascript code, and I don't know anything other 
than a browser that can display it.  If you look at ?writeWebGL, you'll 
see links to various other ?write* files; they are all vector formats, 
but are all more limited than writeWebGL in what they can record.


Duncan Murdoch



Thanks
Andreas



On Tue, Sep 10, 2013 at 6:38 PM, Duncan Murdoch 
mailto:murdoch.dun...@gmail.com>> wrote:


On 10/09/2013 10:58 AM, Andreas Maunz wrote:

Hi all,

I have a shiny app, in which I want to use rgl's snapshot
function. I am
running Xvfb on my server so that rgl works. I start my shiny
app as
follows:

echo "Checking for Xvfb..."
pgrep -U username Xvfb > /dev/null 2>&1

if [ "$?" -gt 0 ]; then
   echo "Starting Xvfb..."
   Xvfb :7 -screen 0 1280x1024x24 &
   sleep 2
fi

echo "...starting shiny"
export DISPLAY=":7"; R --no-save --no-restore -e
"library('shiny');
runApp('/path/to/app', port=8101)"

In the app, I do plot3d(), generate webGL and send the results
to the
browser. But the rgl.snapshot or rgl.postscript functionality
do not work,
i.e. they produce black or empty images. I assume this is due
to Xvfb. Any
chance I can create snapshots?


rgl.snapshot requires the X server to maintain a frame buffer that
it can read.   It looks as though something is going wrong with
yours.  I don't use a system with Xvfb, so I can't really help,
but you could try Googling to see if that turns anything up.

rgl.postscript shouldn't need the X server, but it is limited in
what it can display.

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] Shiny error: connection reset by peer

2013-09-11 Thread Rmh
shiny uses browser features that internet explorer doesn't have.

use either firefox or chrome.
enter
http://localhost:8100

to quit shiny, enter the escspe key in the R gui

Sent from my iPhone

On Sep 11, 2013, at 9:59, Dimitri Liakhovitski  
wrote:

> Hello!
> 
> I am learning Shiny via tutorial (
> http://rstudio.github.io/shiny/tutorial/#hello-shiny)
> 
> I am trying to recreate the first 2 lines:
> 
> library(shiny)
> runExample("01_hello")
> 
> 
> An IE window opens - it has the slider but does not have the histogram.
> And my R is stuck. I am seeing the following at the prompt:
> 
> Listening on port 8100
> ERROR: [uv_write] connection reset by peer
> ERROR: [on_request_read] connection reset by peer
> ERROR: [on_request_read] connection reset by peer
> ERROR: [on_request_read] connection reset by peer
> ERROR: [on_request_read] connection reset by peer
> 
> 
> In order to stop it I have to hit Escape. The same thing happens in R gui
> and in R studio.
> Any advice on what settings I should ask our IT to change in order for it
> to work?
> 
> Thank you very much!
> 
> -- 
> Dimitri Liakhovitski
> 
>   [[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] windowing

2013-09-11 Thread Bond, Stephen
Very interesting. Does not produce a solution outright, but may be still usable

> df <- data.frame(x1=c(rep(1,10),rep(2,7)),x2=rep(1:17))
> aggregate(df$x2,by=list(x1=df$x1),cumsum)-> a1
> a1
  x1   x
1  1 1, 3, 6, 10, 15, 21, 28, 36, 45, 55
2  2  11, 23, 36, 50, 65, 81, 98
> dim(a1)
[1] 2 2
> a1[1,2]
$`0`
 [1]  1  3  6 10 15 21 28 36 45 55

> a1[2,2]
$`1`
[1] 11 23 36 50 65 81 98

> class(a1[2,2])
[1] "list"

If anybody can suggest how to create a reshape-able dataframe out of this, 
please speak. 
Ideally I should be able to use 

reshape(a1,dir="long",varying=2:11,idvar="x1",v.names="x")

to get it back in long form.
Thank everybody.

Stephen B
-Original Message-
From: MacQueen, Don [mailto:macque...@llnl.gov] 
Sent: Wednesday, September 11, 2013 10:42 AM
To: Bond, Stephen; r-help@r-project.org
Subject: Re: [R] windowing

>From the help page for the aggregate function:


Compute Summary Statistics of Data Subsets

Description:

 Splits the data into subsets, computes summary statistics for
 each, and returns the result in a convenient form.




You might have to use cumsum() after the aggregation, if
"unbounded preceding" causes a cumulative sum to be calculated.

-Don
-- 
Don MacQueen

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





On 9/9/13 11:58 AM, "Bond, Stephen"  wrote:

>Is there a package or a command that does window aggregation like
>
>select
>sum(col1) over
>(partition by col2, col3 order by col4
>rows between unbounded preceding and current row) as sum1
>from table1 ;
>
>the above is Netezza syntax, but Postgre has same capability.
>
>Stephen B
>
>   [[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] Running Loops

2013-09-11 Thread arun
Hi,
Try:
set.seed(24)
yall<- as.data.frame(matrix(sample(1:1e5,5000*10,replace=FALSE),ncol=10))
 set.seed(49)
  
lst1<-replicate(100,yall[sample(1:nrow(yall),100,replace=FALSE),],simplify=FALSE)
 names(lst1)<- paste0("yall",1:100)

lapply(seq_along(lst1),function(i) 
write.csv(lst1[[i]],file=paste0("yall",i,".csv"),row.names=FALSE))



A.K.

I have a data set called yall with 5000 rows, I want to randomly sub sample 100 
rows 100 times. 
This is what I have so far: 

yall<-read.csv("Z:\\SOFTEL\\North Key Largo 
project\\Canopy_Height\\random_age_strat\\Young\\Abv2ft_young.csv") 

yall1 <- yall[sample(1:nrow(yall), 100, replace=FALSE),] 

write.csv(yall1, file = "yall1.csv")

I want to run a 
loop of the bold script above 100 times, but I want to be able to change
 the name of the sub sample and name of the csv file each time. They 
should be named yall1, yall2,yall3...etc until 100.

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

2013-09-11 Thread Duncan Murdoch

On 11/09/2013 11:21 AM, Giles Crane wrote:

class int seems to interact oddly with fix() and dotchart().

Reading a .csv file when there are no decimal points
in an item, results in a data.frame having a column
of class int.  The mode, however, is numeric.

fix() does not recognize int "vectors",
and thus does not spread its sheet.

dotchart() displays a 1 above the labels on the plot.

Converting the int column to numeric using as.numeric()
cures the problems.  However, the behavior of the int class
seems inconsistent.

R Version 3.01 (2013-05-16)

Thank you for your consideration.

Cordially,
Giles


Could you please put together an example of this in R-patched?  I don't 
see it at all.  (I don't know if it has already been fixed, or if I am 
just misunderstanding your description.)


What I see is that fix() on a numeric or integer vector gives a text 
editor.  fix() on a dataframe containing either gives me the spreadsheet.


Duncan Murdoch

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


[R] int vector

2013-09-11 Thread Giles Crane


class int seems to interact oddly with fix() and dotchart().

Reading a .csv file when there are no decimal points
in an item, results in a data.frame having a column
of class int.  The mode, however, is numeric.

fix() does not recognize int "vectors",
and thus does not spread its sheet.

dotchart() displays a 1 above the labels on the plot.

Converting the int column to numeric using as.numeric()
cures the problems.  However, the behavior of the int class
seems inconsistent.

R Version 3.01 (2013-05-16)

Thank you for your consideration.

Cordially,
Giles


--
Giles L Crane, MPH, ASA, NJPHA
Statistical Consultant and R Instructor
621 Lake Drive
Princeton, NJ  08540
Phone: 609 924-0971
Email: gilescr...@verizon.net

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

2013-09-11 Thread PIKAL Petr
Hi

Do not post HTML. Why you did not populate your list directly with coefficients 
by let say coef(lm.result)?

Anyway, you can reveal structure of individulal list component by 
str(your.object[[1]]). After that you can extract coefficient component and use 
sapply/lapply probably with rbind.

maybe

sapply(lapply(your.list, coef), rbind)

can do it.

Regards
Petr

> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of eliza botto
> Sent: Wednesday, September 11, 2013 4:23 PM
> To: r-help@r-project.org
> Subject: [R] list to matrix
> 
> Dear useRs,
> If i have a list of the following form and i want to convert the
> coefficient section of each element, combined into one matrix of
> dimension 3*5. How can i do that?I hope i am clear thank in advance
> 
> [[1]]
> Call:
> lm(formula = mm[, i] ~ 0 + (x0 + x + xx + y + yy))
> Coefficients:
>  x0x   xxy   yy
>  1.  -0.4250   0.2494   0.1683  -0.7449
> 
> [[2]]
> Call:
> lm(formula = mm[, i] ~ 0 + (x0 + x + xx + y + yy))
> Coefficients:
>  x0x   xxy   yy
>  1.  -0.6355   0.5876   0.2518  -0.7293
> 
> [[3]]
> Call:
> lm(formula = mm[, i] ~ 0 + (x0 + x + xx + y + yy))
> Coefficients:
>  x0x   xxy   yy
>  1.   0.5778   0.3838   0.4207  -0.1354
> 
>   [[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] (no subject)

2013-09-11 Thread eliza botto
Now?>dput(gg)
list(structure(list(coefficients = structure(c(1, 0.0747202722085956, 
0.359646782818708, 0.298384925903065, -0.443967849195675), .Names = c("x0", 
"x", "xx", "y", "yy")), residuals = structure(c(-0.302776084510551, 
0.183247980798144, -0.337231904223223, 0.199348794823859, 0.290269994519382, 
-0.328261122410049, -0.191844336069409, 0.309937888934371, 0.249963958976373, 
-0.51656422321523, 0.0255108830245443, 0.418398169351789), .Names = c("1", "2", 
"3", "4", "5", "6", "7", "8", "9", "10", "11", "12")), effects = 
structure(c(-3.46410161513775, -0.183026540352922, -0.880951105539393, 
0.730890815400676, -1.08749469273032, -0.055778138673626, 0.105917713121713, 
0.425275592080333, 0.0893727217831096, -0.833878847761609, -0.213870821267818, 
0.405405268871492), .Names = c("x0", "x", "xx", "y", "yy", "", "", "", "", "", 
"", "")), rank = 5L, fitted.values = structure(c(1.00923807240423, 
0.815143487596117, 1.06126185691564, 1.50939808712151, 1.64879363631755, 
1.22366465369447,!
  0.520171981764853, 0.117496714766831, 0.341968291278227, 
0.961191858709413, 1.4185661613195, 1.37310519811166), .Names = c("1", "2", 
"3", "4", "5", "6", "7", "8", "9", "10", "11", "12")), assign = 1:5, qr = 
structure(list(qr = structure(c(-3.46410161513775, 0.288675134594813, 
0.288675134594813, 0.288675134594813, 0.288675134594813, 0.288675134594813, 
0.288675134594813, 0.288675134594813, 0.288675134594813, 0.288675134594813, 
0.288675134594813, 0.288675134594813, 1.0359551758099e-16, 
-2.44948974278318, -0.0791992255271195, -0.283323370759051, 
-0.432752616120393, -0.487447515990983, -0.432752616120393, 
-0.283323370759051, -0.0791992255271196, 0.124924919704812, 
0.274354165066154, 0.329049064936743, 1.60326396256294e-16, 
-4.06575814682064e-17, -2.44948974278318, 0.385357119965326, 
0.276818123873927, 0.0876608486418726, -0.131430166589936, 
-0.321749661221222, -0.432301680361632, -0.433463899760863, 
-0.324924903669464,!
  -0.13576762843741, 4.07117915768307e-17, 2.16515173845355e-16, 3.
30898503042576e-16, 2.44948974278318, -0.1565883283638, -0.28412286470868, 
-0.0175072160832821, 0.422389924412376, 0.61883998250704, 
0.369775078419853, -0.108638802574745, -0.389352556693728, 
-7.42678488152571e-18, 6.07912158112622e-16, 4.95615918097436e-17, 
-1.02240264865383e-16, 2.44948974278318, 0.0399663322170986, 
-0.36906922926158, -0.453581151684979, -0.103155496641535, 0.3733769380139, 
0.545626107621939, 0.279668949241763), .Dim = c(12L, 5L), .Dimnames = 
list(c("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"), 
c("x0", "x", "xx", "y", "yy")), assign = 1:5), qraux = c(1.28867513459481,  
   1.12492491970481, 1.38419490056609, 1.18149437156933, 1.36122122075101), 
pivot = 1:5, tol = 1e-07, rank = 5L), .Names = c("qr", "qraux", "pivot", 
"tol", "rank"), class = "qr"), df.residual = 7L, xlevels = 
structure(list(), .Names = character(0)), call = lm(formula = mm[, i] ~ 
0 + (x0 + x + xx + y + yy)), terms = mm[!
 , i] ~ 0 + (x0 + x + xx + y + yy), model = structure(list(`mm[, i]` = 
c(0.706461987893674, 0.998391468394261, 0.72402995269242, 1.70874688194537, 
1.93906363083693, 0.89540353128442, 0.328327645695443, 0.427434603701202, 
0.591932250254601, 0.444627635494183, 1.44407704434405, 1.79150336746345), 
x0 = structure(c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), .Dim = c(12L, 1L)), x 
= structure(c(0.866025403784439, 0.5, 6.12303176911189e-17, -0.5, 
-0.866025403784439, -1, -0.866025403784439, -0.5, -1.83690953073357e-16, 
0.5, 0.866025403784438, 1), .Dim = c(12L, 1L)), xx = structure(c(0.5, 
0.866025403784439, 1, 0.866025403784439, 0.5, 1.22460635382238e-16, -0.5, 
-0.866025403784438, -1, -0.866025403784439, -0.5, -2.44921270764475e-16), 
.Dim = c(12L, 1L)), y = structure(c(0.5, -0.5, -1, -0.5, 0.5, 1, 0.5, 
-0.499, -1, -0.5, 0.499, 1), .Dim = c(12L, 1L)), yy 
= structure(c(0.866025403784439, 0.866025403784439, 1.2246!
 0635382238e-16, -0.866025403784438, -0.866025403784439, -2.4492127
0764475e-16, 0.866025403784439, 0.866025403784439, 3.67381906146713e-16, 
-0.866025403784439, -0.866025403784439, -4.89842541528951e-16), .Dim = 
c(12L, 1L))), .Names = c("mm[, i]", "x0", "x", "xx", "y", "yy"), terms = 
mm[, i] ~ 0 + (x0 + x + xx + y + yy), row.names = c(NA, 12L), class 
= "data.frame")), .Names = c("coefficients", "residuals", "effects", "rank", 
"fitted.values", "assign", "qr", "df.residual", "xlevels", "call", "terms", 
"model"), class = "lm"), structure(list(coefficients = structure(c(1, 
0.308786314174914, 0.120489287397766, 0.116129002459147, 
-0.283906024106553), .Names = c("x0", "x", "xx", "y", "yy")), residuals = 
structure(c(-0.194600470874542, 0.147793243511181, -0.0596338831684155, 
-0.19669043918067, 0.411977909847386, -0.217327208227307, 
-

Re: [R] windowing

2013-09-11 Thread MacQueen, Don
>From the help page for the aggregate function:


Compute Summary Statistics of Data Subsets

Description:

 Splits the data into subsets, computes summary statistics for
 each, and returns the result in a convenient form.




You might have to use cumsum() after the aggregation, if
"unbounded preceding" causes a cumulative sum to be calculated.

-Don
-- 
Don MacQueen

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





On 9/9/13 11:58 AM, "Bond, Stephen"  wrote:

>Is there a package or a command that does window aggregation like
>
>select
>sum(col1) over
>(partition by col2, col3 order by col4
>rows between unbounded preceding and current row) as sum1
>from table1 ;
>
>the above is Netezza syntax, but Postgre has same capability.
>
>Stephen B
>
>   [[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] Fitting Arima Model to Daily Time Series

2013-09-11 Thread Paul Bernal
Dear Jose, good morning,

First of all, let me thank you for your extremely valuable help. Now I have
a question for you:

I have a table containing two fields, the first one is date and the second
one is number of transits of vessels. This table contains daily
observations for the past 5 years.

The date field has the following format: -MM-DD

The number of transits field is a regular numeric field.

How can I do to convert this table into a time series object?

Best regards,

Paul




2013/9/11 Jose Iparraguirre 

> Hi Paul,
>
> There are different packages in R to fit an ARIMA model. I would use the
> forecast package.
> In your case, perhaps you would want to explore SARIMA models to include
> seasonal components?
> Anyhow, the first port of call could be the auto.arima() function to
> select the best fitting representation according to AIC, AICc or BIC -but
> explore other representations as well.
> To fit the models use the function Arima (note the capital "A"). The
> documentation in the package is very clear and comprehensive; the authors
> (Rob J Hyndman and George Athanasopoulos) published a free on-line book
> which will also help you: http://otexts.com/fpp/.
> Hope this helps,
>
> José
>
>
> Prof. José Iparraguirre
> Chief Economist
> Age UK
>
>
>
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On Behalf Of Paul Bernal
> Sent: 10 September 2013 22:54
> To: r-help@r-project.org
> Subject: [R] Fitting Arima Model to Daily Time Series
>
> Hello everyone,
>
> Hope everyone is doing great. I would like to know how to use the arima
> function in R to fit arima or arma models to daily data, that is, with
> period = 365, this taking into account the fact that I have 5 years worth
> of daily data (so 365 * 5 = my number of observations).
>
> All I want is a very general line of code of I I would do to fit the arima
> model.
>
> Any help will be greatly appreciated,
>
> Have a wonderful day,
>
> Paul
>
> [[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 Wireless from Age UK | Radio for grown-ups.
>
> www.ageuk.org.uk/thewireless
>
>
> If you’re looking for a radio station that offers real variety, tune in to
> The Wireless from Age UK.
> Whether you choose to listen through the website at
> www.ageuk.org.uk/thewireless, on digital radio (currently available in
> London and Yorkshire) or through our TuneIn Radio app, you can look forward
> to an inspiring mix of music, conversation and useful information 24 hours
> a day.
>
>
>
>
> ---
> Age UK is a registered charity and company limited by guarantee,
> (registered charity number 1128267, registered company number 6825798).
> Registered office: Tavis House, 1-6 Tavistock Square, London WC1H 9NA.
>
> For the purposes of promoting Age UK Insurance, Age UK is an Appointed
> Representative of Age UK Enterprises Limited, Age UK is an Introducer
> Appointed Representative of JLT Benefit Solutions Limited and Simplyhealth
> Access for the purposes of introducing potential annuity and health
> cash plans customers respectively.  Age UK Enterprises Limited, JLT
> Benefit Solutions Limited and Simplyhealth Access are all authorised and
> regulated by the Financial Services Authority.
> --
>
> This email and any files transmitted with it are confidential and intended
> solely for the use of the individual or entity to whom they are
> addressed. If you receive a message in error, please advise the sender and
> delete immediately.
>
> Except where this email is sent in the usual course of our business, any
> opinions expressed in this email are those of the author and do not
> necessarily reflect the opinions of Age UK or its subsidiaries and
> associated companies. Age UK monitors all e-mail transmissions passing
> through its network and may block or modify mails which are deemed to be
> unsuitable.
>
> Age Concern England (charity number 261794) and Help the Aged (charity
> number 272786) and their trading and other associated companies merged
> on 1st April 2009.  Together they have formed the Age UK Group, dedicated
> to improving the lives of people in later life.  The three national
> Age Concerns in Scotland, Northern Ireland and Wales have also merged with
> Help the Aged in these nations to form three registered charities:
> Age Scotland, Age NI, Age Cymru.
>
>
>
>
>

[[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, r

[R] list to matrix

2013-09-11 Thread eliza botto
Dear useRs,
If i have a list of the following form and i want to convert the coefficient 
section of each element, combined into one matrix of dimension 3*5. How can i 
do that?I hope i am clear
thank in advance

[[1]]
Call:
lm(formula = mm[, i] ~ 0 + (x0 + x + xx + y + yy))
Coefficients:
 x0x   xxy   yy  
 1.  -0.4250   0.2494   0.1683  -0.7449  

[[2]]
Call:
lm(formula = mm[, i] ~ 0 + (x0 + x + xx + y + yy))
Coefficients:
 x0x   xxy   yy  
 1.  -0.6355   0.5876   0.2518  -0.7293  

[[3]]
Call:
lm(formula = mm[, i] ~ 0 + (x0 + x + xx + y + yy))
Coefficients:
 x0x   xxy   yy  
 1.   0.5778   0.3838   0.4207  -0.1354  
  
[[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] Formula in a model

2013-09-11 Thread Paulito Palmes


Hello Gerrit, 

Thanks for the explanation. Let me give a specific example.

Assume Temp (column 4) is the output and the rest of the columns are input is 
the training features. Note that I only use the air quality data for 
illustration purpose. T input->output mapping may not make sense in the real 
interpretation of this data.

library(e1071)

data(airquality)
mytable=airquality

colnames(mytable)=c('a','b','c','d','e','f')


modelSVM1=svm(mytable[,6] ~ .,data=mytable)
modelSVM2=svm(mytable[,-6],mytable[,6])
modelSVM3=svm(f ~ ., data=mytable)

predSVM1=predict(modelSVM1,newdata=mytable)
predSVM2=predict(modelSVM2,newdata=mytable[,-6])
predSVM3=predict(modelSVM3,newdata=mytable)

Results of predSVM2 is similar with predSVM3  but different from predSVM1.

Question: Which is the correct formulation? Why R doesn't detect 
error/discrepancy in formulation?


If I use the same formulation with rpart using the same data:

library(rpart)

data(airquality)
mytable=airquality

colnames(mytable)=c('a','b','c','d','e','f')

modelRP1=rpart(mytable[,6]~.,data=mytable,method='anova') # this works
modelRP3=rpart(f ~ ., data=mytable,method='anova') # this works

predRP1=predict(modelRP1,newdata=mytable)
predRP3=predict(modelRP3,newdata=mytable)



The results between predRP1 and predRP3 are different while the statements:

predRP2=predict(modelRP2,newdata=mytable[,-6])
modelRP2=rpart(mytable[,-6],mytable[,6],method='anova') 


have errors.



_
From: Gerrit Eichner 
To: Paulito Palmes  
Cc: "r-help@r-project.org"  
Sent: Wednesday, 11 September 2013, 10:48
Subject: Re: [R] Formula in a model


Hello, Paulito,

first, I think you haven't received an answer yet because you did not 
"provide commented, minimal, self-contained, reproducible code" as the 
posting guide does request it from you.

Second, see inline below.

On Wed, 11 Sep 2013, Paulito Palmes wrote:

> Hi,
>
> I have a data.frame with dimension 336x336 called *training*, and 
> another one called *observation* which is 336x1. I combined them as one 
> table using table=data.frame(training, observation). table now has 
> 336x337 dimension with the last column as the observation to learn using 
> the training data of the rest of the column in the table. For 
> prediction, i combined the testing data and observation and pass it like 
> predict(model,testingWTesingObservation)
>
>
> I've used the formula: rpart(table[,337] ~ ., data=table) or 
> svm(table[,337] ~ ., data=table).

I am not familiar with rpart() nor with svm() but "table[,337] ~ ., data = 
table" has the consequence that table[,337] is also in the right hand side 
of the formula, so that your "observations" are also in the "training" 
data. That doesn't seem to make sense to me, and is different from the 
call to svm() below.

  Hth  --  Gerrit

> I recently discovered that this formulation produces different model 
> from the: svm(training, observation) formulation. Which is correct and 
> why one of them is not correct? I thought that syntactically, both are 
> the same. I hope that R should be able to detect the error in one of the 
> formulation to avoid the possibility of using it.
>
> Regards,
> Paul
>     [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] how to read data from MSExcel into R

2013-09-11 Thread Gabor Grothendieck
On Wed, Sep 11, 2013 at 9:06 AM, Charles Determan Jr  wrote:
> If there isn't multiple sheets you can use the 'gdata' package and
> read.xls().
>
> Otherwise you could re-save the file as a csv file and load that file with
> read.csv() assuming not multiple sheets again which a csv cannot contain.
>

read.xls in gdata does support multiple sheets via the sheet= argument
as well as the sheetCount and sheetNames helper functions.

   fn <- "abc.xlsx"
   nms <- sheetNames(fn)
   lapply(nms, read.xls, xls = fn)



-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

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


Re: [R] Shiny error: connection reset by peer

2013-09-11 Thread Dimitri Liakhovitski
Thank you so much, it worked with Chrome!


On Wed, Sep 11, 2013 at 10:15 AM, Rmh  wrote:

> shiny uses browser features that internet explorer doesn't have.
>
> use either firefox or chrome.
> enter
> http://localhost:8100
>
> to quit shiny, enter the escspe key in the R gui
>
> Sent from my iPhone
>
> On Sep 11, 2013, at 9:59, Dimitri Liakhovitski <
> dimitri.liakhovit...@gmail.com> wrote:
>
> > Hello!
> >
> > I am learning Shiny via tutorial (
> > http://rstudio.github.io/shiny/tutorial/#hello-shiny)
> >
> > I am trying to recreate the first 2 lines:
> >
> > library(shiny)
> > runExample("01_hello")
> >
> >
> > An IE window opens - it has the slider but does not have the histogram.
> > And my R is stuck. I am seeing the following at the prompt:
> >
> > Listening on port 8100
> > ERROR: [uv_write] connection reset by peer
> > ERROR: [on_request_read] connection reset by peer
> > ERROR: [on_request_read] connection reset by peer
> > ERROR: [on_request_read] connection reset by peer
> > ERROR: [on_request_read] connection reset by peer
> >
> >
> > In order to stop it I have to hit Escape. The same thing happens in R gui
> > and in R studio.
> > Any advice on what settings I should ask our IT to change in order for it
> > to work?
> >
> > Thank you very much!
> >
> > --
> > Dimitri Liakhovitski
> >
> >   [[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.
>



-- 
Dimitri Liakhovitski

[[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 read data from MSExcel into R

2013-09-11 Thread Jeff Newmiller
The assertion that you need administrator privileges to install packages is 
false. You can install them into a directory under your Documents directory for 
your own use. You only need a administrator privileges to modify the packages 
located in the software installation directory.
---
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.

Charles Determan Jr  wrote:
>If there isn't multiple sheets you can use the 'gdata' package and
>read.xls().
>
>Otherwise you could re-save the file as a csv file and load that file
>with
>read.csv() assuming not multiple sheets again which a csv cannot
>contain.
>
>Regards,
>Charles
>
>
>On Wed, Sep 11, 2013 at 8:01 AM, Charles Thuo 
>wrote:
>
>> how can one read data from MSEXcel into R especially in a case where
>one
>> does not have administrator rights to install additional packages. In
>short
>> how to read data from MSExcel into R with base packages only.
>>
>> [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>

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


Re: [R] how to convert a list into a data frame.

2013-09-11 Thread PIKAL Petr
Well as the original poster asks specifically how to convert imported list to 
data frame I assumed, maybe wrongly, that he/she knows R objects and by some 
tricky conversion managed to stuff Excel data to real list (class list) and not 
data.frame (class data frame).

But you are correct. Code, at least str(object) and detailed description of 
intention is vital here.

Petr


> -Original Message-
> From: Jeff Newmiller [mailto:jdnew...@dcn.davis.ca.us]
> Sent: Wednesday, September 11, 2013 4:03 PM
> To: PIKAL Petr; Charles Thuo; r-help@r-project.org
> Subject: Re: [R] how to convert a list into a data frame.
> 
> But a data.frame is a special type of list, so you could both be right.
> The best way to communicate clearly about these questions is to provide
> reproducible example R code.
> ---
> 
> 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.
> 
> PIKAL Petr  wrote:
> >How did you read it? Normally data from Excel are in data.frame
> >
> >Petr
> >
> >
> >> -Original Message-
> >> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> >> project.org] On Behalf Of Charles Thuo
> >> Sent: Wednesday, September 11, 2013 3:22 PM
> >> To: r-help@r-project.org
> >> Subject: [R] how to convert a list into a data frame.
> >>
> >> After reading a data set from excel into R it is of the type list.
> >How
> >> can such a list be converted into a data frame so as to attach the
> >> columns.
> >>
> >> Charles.
> >>
> >>[[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-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 convert a list into a data frame.

2013-09-11 Thread Jeff Newmiller
But a data.frame is a special type of list, so you could both be right. The 
best way to communicate clearly about these questions is to provide 
reproducible example R code.
---
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.

PIKAL Petr  wrote:
>How did you read it? Normally data from Excel are in data.frame
>
>Petr
>
>
>> -Original Message-
>> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
>> project.org] On Behalf Of Charles Thuo
>> Sent: Wednesday, September 11, 2013 3:22 PM
>> To: r-help@r-project.org
>> Subject: [R] how to convert a list into a data frame.
>> 
>> After reading a data set from excel into R it is of the type list.
>How
>> can such a list be converted into a data frame so as to attach the
>> columns.
>> 
>> Charles.
>> 
>>  [[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-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] superpose violin and boxplot in ggplot

2013-09-11 Thread PIKAL Petr
Hi

> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of Ben Bolker
> Sent: Wednesday, September 11, 2013 3:46 PM
> To: r-h...@stat.math.ethz.ch
> Subject: Re: [R] superpose violin and boxplot in ggplot
> 
> PIKAL Petr  precheza.cz> writes:
> 
> >
> > Dear all
> >
> > I am struggling a bit with tricky violinplot. I found how to
> superpose
> boxplots correctly to violinplots.
> >
> > p<-ggplot(Cars93, aes(x=Origin, y=Price, fill=Type, colour=Type))
> 
>  [snip]
> >
> > How I could change colour of boxplots to single colour but get the
> > boxes at the correct locations e.g. over violins.
> >
> > Thanks
> > Petr
> >
> >
> 
> Use the group() aesthetic:
> 
> p+geom_violin()+
> p+geom_boxplot(aes(fill=NULL,group=interaction(Type,Origin)),
>position=position_dodge(width=.9), width=.5, colour="black")

Thanks. In the meantime I found another solution using scale_colour_manual.

p+geom_violin()+geom_boxplot(aes(fill=NULL),
position=position_dodge(width=.9), 
width=.5)+scale_colour_manual(values=rep("black", 6))

Your solution seems to be better as the legend looks slightly better.

> 
> By the way, it would be useful to remind us that Cars93 is available in
> the MASS package -- I had to hunt around a little bit.

Sorry for that. I forgot to add it to my question together with ggplot2 package.

Regards
Petr



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

2013-09-11 Thread Dimitri Liakhovitski
Hello!

I am learning Shiny via tutorial (
http://rstudio.github.io/shiny/tutorial/#hello-shiny)

I am trying to recreate the first 2 lines:

library(shiny)
runExample("01_hello")


An IE window opens - it has the slider but does not have the histogram.
And my R is stuck. I am seeing the following at the prompt:

Listening on port 8100
ERROR: [uv_write] connection reset by peer
ERROR: [on_request_read] connection reset by peer
ERROR: [on_request_read] connection reset by peer
ERROR: [on_request_read] connection reset by peer
ERROR: [on_request_read] connection reset by peer


In order to stop it I have to hit Escape. The same thing happens in R gui
and in R studio.
Any advice on what settings I should ask our IT to change in order for it
to work?

Thank you very much!

-- 
Dimitri Liakhovitski

[[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] superpose violin and boxplot in ggplot

2013-09-11 Thread Ben Bolker
PIKAL Petr  precheza.cz> writes:

> 
> Dear all
> 
> I am struggling a bit with tricky violinplot. I found how to superpose
boxplots correctly to violinplots.
> 
> p<-ggplot(Cars93, aes(x=Origin, y=Price, fill=Type, colour=Type))

 [snip]
> 
> How I could change colour of boxplots to single colour 
> but get the boxes at the correct locations e.g. over violins.
> 
> Thanks
> Petr
> 
> 

Use the group() aesthetic:

p+geom_violin()+ geom_boxplot(aes(fill=NULL,group=interaction(Type,Origin)),
   position=position_dodge(width=.9), width=.5, colour="black")

By the way, it would be useful to remind us that Cars93 is available in
the MASS package -- I had to hunt around a little bit.

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

2013-09-11 Thread PIKAL Petr
How did you read it? Normally data from Excel are in data.frame

Petr


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of Charles Thuo
> Sent: Wednesday, September 11, 2013 3:22 PM
> To: r-help@r-project.org
> Subject: [R] how to convert a list into a data frame.
> 
> After reading a data set from excel into R it is of the type list. How
> can such a list be converted into a data frame so as to attach the
> columns.
> 
> Charles.
> 
>   [[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 convert a list into a data frame.

2013-09-11 Thread Charles Thuo
After reading a data set from excel into R it is of the type list. How can
such a list be converted into a data frame so as to attach the columns.

Charles.

[[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 Online Workshops October 7-11

2013-09-11 Thread Muenchen, Robert A (Bob)
Learn R and/or data mangement at home October 7 through 11 

http://r4stats.com/2013/09/11/learn-r-andor-data-management-from-home-october-7-11/

==
  Bob Muenchen (pronounced Min'-chen)
  Accredited Professional Statistician(tm)   
  Manager, Research Computing Support
  Voice: (865) 974-5230  
  Email: muenc...@utk.edu
  UT Web Site:   http://oit.utk.edu/research
  Personal Web Site: http://r4stats.com 
  News:  http://itc2.utk.edu/newsletter_monthly/
==

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

2013-09-11 Thread Charles Determan Jr
If there isn't multiple sheets you can use the 'gdata' package and
read.xls().

Otherwise you could re-save the file as a csv file and load that file with
read.csv() assuming not multiple sheets again which a csv cannot contain.

Regards,
Charles


On Wed, Sep 11, 2013 at 8:01 AM, Charles Thuo  wrote:

> how can one read data from MSEXcel into R especially in a case where one
> does not have administrator rights to install additional packages. In short
> how to read data from MSExcel into R with base packages only.
>
> [[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.
>



-- 
Charles Determan
Integrated Biosciences PhD Candidate
University of Minnesota

[[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] resample from data frame: unlinked columns

2013-09-11 Thread arun
Hi,
Using ur code:

dat1<- read.table(text="A  B
5  257  259
10    257  259
10.1  257  259
4  257  259
9  257  259
2  257  259
8  257  259
1  257  259
8.1    257  259
8.2    257  259
7  255  257",sep="",header=TRUE)


set.seed(49)
 res<-sapply(dat1,function(x) 
as.vector(replicate(500,x[sample(seq_along(x),length(x),replace=TRUE)])))
 dim(res)
#[1] 5500    2

A.K.

- Original Message -
From: Rosario Garcia Gil 
To: "r-help@r-project.org" 
Cc: 
Sent: Wednesday, September 11, 2013 6:20 AM
Subject: [R] resample from data frame: unlinked columns

Hello

I am trying to resample from this data set (see below). The function I am using 
so far is doing it by considering A and B columns as linked. I used this 
function.

>NUCh_rep<-replicate(500,data[sample(1:nrow(data),replace=T),],simplify=F)

What I need is to resample (500 times) with replacement but considering A and B 
columns UNLINKED. Any advice it is most appreciated. Thanks.

             A           B
5          257       259
10         257       259
10.1       257       259
4          257       259
9          257       259
2          257       259
8          257       259
1          257       259
8.1        257       259
8.2        257       259
7          255       257


    [[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 read data from MSExcel into R

2013-09-11 Thread Charles Thuo
how can one read data from MSEXcel into R especially in a case where one
does not have administrator rights to install additional packages. In short
how to read data from MSExcel into R with base packages only.

[[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] superpose violin and boxplot in ggplot

2013-09-11 Thread PIKAL Petr
Dear all

I am struggling a bit with tricky violinplot. I found how to superpose boxplots 
correctly to violinplots.

p<-ggplot(Cars93, aes(x=Origin, y=Price, fill=Type, colour=Type))
p+geom_violin()+ geom_boxplot(aes(fill=NULL), 
position=position_dodge(width=.9), width=.3)

but if I wanted to change the boxplot to black colour I am lost

p+geom_violin()+ geom_boxplot(aes(fill=NULL), 
position=position_dodge(width=.9), width=.5, colour="black")

How I could change colour of boxplots to single colour but get the boxes at the 
correct locations e.g. over violins.

Thanks
Petr

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

2013-09-11 Thread arun
Hi,
set.seed(24)
mat1<- 
matrix(sample(0:1,20*100,replace=TRUE),ncol=100,dimnames=list(paste0("Species",1:20),paste0("Species",1:100)))
 which(mat1[1,]==1)
#or
which(!is.na(match(mat1[1,],1)))
A.K.




- Original Message -
From: Elaine Kuo 
To: "r-help@r-project.org" 
Cc: 
Sent: Wednesday, September 11, 2013 3:38 AM
Subject: [R] to retrieve specific data from a matrix

Dear list,

I want to retrieve a specific data from a matrix with 3000 columns.
The matrix has island ID as its rows and species ID as its columns.
There are 20 rows and 3000 columns in the matrix.
(Island ID: Species 1- Species 20/ species ID: Species 1- Species 3000)
The contents of the matrix grids is 1 or 0, for presence and absence.

Now I would like to check in Island 1 which species is 1. (Island 1 as row
2)
Please kindly advise how to code the command and thank you in advance.

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@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] resample from data frame: unlinked columns

2013-09-11 Thread PIKAL Petr
Hi

> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of Rosario Garcia Gil
> Sent: Wednesday, September 11, 2013 12:21 PM
> To: r-help@r-project.org
> Subject: [R] resample from data frame: unlinked columns
> 
> Hello
> 
> I am trying to resample from this data set (see below). The function I
> am using so far is doing it by considering A and B columns as linked. I
> used this function.
> 
> >NUCh_rep<-
> replicate(500,data[sample(1:nrow(data),replace=T),],simplify=F)

Sample rows 1000 times and use two parts of this index

ind<-sample(1:nrow(data), 1000, replace=TRUE)

data[ind[1:500], "A"]
data[ind[501:1000], "B"]

You can organize it to data frame or matrix e.g.

result <- cbind(data[ind[1:500], "A"], data[ind[501:1000], "B"])

Regards
Petr

> 
> What I need is to resample (500 times) with replacement but considering
> A and B columns UNLINKED. Any advice it is most appreciated. Thanks.
> 
>  A   B
> 5  257   259
> 10 257   259
> 10.1   257   259
> 4  257   259
> 9  257   259
> 2  257   259
> 8  257   259
> 1  257   259
> 8.1257   259
> 8.2257   259
> 7  255   257
> 
> 
>   [[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] Imputation for space-time satellite data

2013-09-11 Thread Eddie Smith
Dear list,

I am trying to do a space-time imputation for time series satellite
imageries. Any recommendation for a good package to use. I am new to R.

Thank you.

[[alternative HTML version deleted]]

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


[R] resample from data frame: unlinked columns

2013-09-11 Thread Rosario Garcia Gil
Hello

I am trying to resample from this data set (see below). The function I am using 
so far is doing it by considering A and B columns as linked. I used this 
function.

>NUCh_rep<-replicate(500,data[sample(1:nrow(data),replace=T),],simplify=F)

What I need is to resample (500 times) with replacement but considering A and B 
columns UNLINKED. Any advice it is most appreciated. Thanks.

 A   B
5  257   259
10 257   259
10.1   257   259
4  257   259
9  257   259
2  257   259
8  257   259
1  257   259
8.1257   259
8.2257   259
7  255   257


[[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] ggplot interactions

2013-09-11 Thread Robert Lynch
On Tue, Sep 10, 2013 at 11:33 PM, Robert Lynch wrote:

> I am sorry to ask what I am sure is a simple question but I am stuck
> trying to figure out how different parts of ggplot2 calls interact
>
> I am plotting using the following code
>
> ggplot(Chem.comp, aes(Course, GRADE)) + geom_boxplot(notch = TRUE,aes(fill
> = COHORT))+
>   labs(y ="Grade Points in class",
>x = "Chemistry 2 quarter") +
>   ggtitle(expression(atop("Comparison between ISE cohorts and Peers",
> atop(italic("in Chem 2 classes"), ""
>   ylim(0,4.)+
>   scale_fill_manual(name = "ISE Cohorts &\nComparison groups",
> values =
> c("blue","red","blue3","red3","blue4","red4")) +
>   theme(plot.title = element_text(size = 25, face = "bold", colour =
> "black", vjust = -1))+
>   guides(fill = guide_legend(nrow = 3),byrow = TRUE)
>
> which give Rplot.jpeg  which is has the appropriate title, but the colors
> and the wrong are wrong.
>
> if I comment out the ggtitle() and theme(), or just ggtitle() I get
> Rplot01.jpeg which has the right colors but no title and subtitle.  Also
> the legend is out of order.  the first row should read ISE07 CMP07 with 08
> on the second row and 09 the third with a red column and a blue column.
>  Changing byrow = TRUE to bycol = TRUE does not change the plotting of the
> legend nor does byrow=FALSE
>
> I am asking for help with getting the title and sub-title to both show up
> at the same time as the appropriate colors for the different factor levels.
> And to get the legend to render so that the legend looks sort of like
> ISE07  [redbox  ] [bluebox  ] CMP07
> ISE08  [red3box][blue3box]  CMP08
> ISE09  [red4box] [blue4box] CMP09
>
> the exact colors are not important the the vertical
> and horizontal alignment is.
>
> Thanks!
> Robert
>
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] include variable of a dataframe in other dataframe

2013-09-11 Thread ernesto villarino
Hello Ian.
I explained wrong myself.
summary (data.all.evp)
  Year  Month LongLat z

 Min.   :1959   Jan:124200   Min.   :-74.0   Min.   :36.0   Min.
:-5615.00
 1st Qu.:1970   Feb:124200   1st Qu.:-52.0   1st Qu.:43.0   1st
Qu.:-3451.25
 Median :1982   Mar:124200   Median :-29.5   Median :50.5   Median
:-1393.00
 Mean   :1982   Apr:124200   Mean   :-29.5   Mean   :50.5   Mean
:-1706.32
 3rd Qu.:1993   May:124200   3rd Qu.: -7.0   3rd Qu.:58.0   3rd Qu.:
 3.25
 Max.   :2004   Jun:124200   Max.   : 15.0   Max.   :65.0   Max.   :
2997.00
(Other):745200

> summary (data.fut.evp)
  LatLong   Month  Year   SST
   SSS
 Min.   :36.0   Min.   :-74.0   Jan: 267300   Min.   :2001   Min.
:-1.9 Min.   : 0.0
 1st Qu.:43.0   1st Qu.:-52.0   Feb: 267300   1st Qu.:2025   1st Qu.:
8.7 1st Qu.:33.8
 Median :50.5   Median :-29.5   Mar: 267300   Median :2050   Median
:12.0 Median :34.7
 Mean   :50.5   Mean   :-29.5   Apr: 267300   Mean   :2050   Mean
:12.5 Mean   :34.2
 3rd Qu.:58.0   3rd Qu.: -7.0   May: 267300   3rd Qu.:2075   3rd
Qu.:16.3 3rd Qu.:35.3
 Max.   :65.0   Max.   : 15.0   Jun: 267300   Max.   :2099   Max.
:31.7 Max.   :39.7
(Other):1603800  NA's
:803088   NA's   :805464

> 90*30*12*46 (lat*long*month*year, data.all.evp)
[1] 1490400
> 90*30*12*100 (lat*long*month*year,data.fut.evp)
[1] 324

If you look to z (it is unique for the 30*90=2700 lat and long combinations
every month, but then it is the same for every years or months.
You got me ?
I am going to try your code, and let you know,
Cheers,
Ernes



On Wed, Sep 11, 2013 at 6:41 AM, I.Renner [via R] <
ml-node+s789695n4675835...@n4.nabble.com> wrote:

> Hi Ernesto,
>
> I should first convey that I am by no means an expert, so I'm sure someone
> will have a more elegant solution.
>
> One thing that seems strange is that there appear to be fewer depth values
> (1557192) than rows in the data frame for which you would like to include
> them (3207600).
>
> z.new = rep(NA, dim(data.fut.evp)[1])
> z.index = match(paste(data.fut.evp$Lat, data.fut.evp$Long),
> paste(data.all.evp$Lat, data.all.evp$Long))
> z.new = data.all.evp$z[z.index]
> data.fut.evp$z = z.new
>
> Hope this helps,
>
> Ian
>
>
> --
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://r.789695.n4.nabble.com/include-variable-of-a-dataframe-in-other-dataframe-tp4675730p4675835.html
>  To start a new topic under R help, email
> ml-node+s789695n789696...@n4.nabble.com
> To unsubscribe from include variable of a dataframe in other dataframe, click
> here
> .
> NAML
>




--
View this message in context: 
http://r.789695.n4.nabble.com/include-variable-of-a-dataframe-in-other-dataframe-tp4675730p4675845.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.


Re: [R] RStudio Server init script

2013-09-11 Thread peter dalgaard

On Sep 11, 2013, at 07:53 , Bembi Prima wrote:

> I have seen ?Startup and already update .RProfile in home folder, but as I
> already said it just affected user's Rprofile, not the global one.

So you didn't read the parts about Rprofile.site?

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

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


Re: [R] Fitting Arima Model to Daily Time Series

2013-09-11 Thread Jose Iparraguirre
Hi Paul,

There are different packages in R to fit an ARIMA model. I would use the 
forecast package.
In your case, perhaps you would want to explore SARIMA models to include 
seasonal components? 
Anyhow, the first port of call could be the auto.arima() function to select the 
best fitting representation according to AIC, AICc or BIC -but explore other 
representations as well.
To fit the models use the function Arima (note the capital "A"). The 
documentation in the package is very clear and comprehensive; the authors (Rob 
J Hyndman and George Athanasopoulos) published a free on-line book which will 
also help you: http://otexts.com/fpp/.
Hope this helps,

José


Prof. José Iparraguirre
Chief Economist
Age UK



-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Paul Bernal
Sent: 10 September 2013 22:54
To: r-help@r-project.org
Subject: [R] Fitting Arima Model to Daily Time Series

Hello everyone,

Hope everyone is doing great. I would like to know how to use the arima 
function in R to fit arima or arma models to daily data, that is, with period = 
365, this taking into account the fact that I have 5 years worth of daily data 
(so 365 * 5 = my number of observations).

All I want is a very general line of code of I I would do to fit the arima 
model.

Any help will be greatly appreciated,

Have a wonderful day,

Paul

[[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 Wireless from Age UK | Radio for grown-ups.

www.ageuk.org.uk/thewireless


If you’re looking for a radio station that offers real variety, tune in to The 
Wireless from Age UK. 
Whether you choose to listen through the website at 
www.ageuk.org.uk/thewireless, on digital radio (currently available in London 
and Yorkshire) or through our TuneIn Radio app, you can look forward to an 
inspiring mix of music, conversation and useful information 24 hours a day.



 
---
Age UK is a registered charity and company limited by guarantee, (registered 
charity number 1128267, registered company number 6825798). 
Registered office: Tavis House, 1-6 Tavistock Square, London WC1H 9NA.

For the purposes of promoting Age UK Insurance, Age UK is an Appointed 
Representative of Age UK Enterprises Limited, Age UK is an Introducer 
Appointed Representative of JLT Benefit Solutions Limited and Simplyhealth 
Access for the purposes of introducing potential annuity and health 
cash plans customers respectively.  Age UK Enterprises Limited, JLT Benefit 
Solutions Limited and Simplyhealth Access are all authorised and 
regulated by the Financial Services Authority. 
--

This email and any files transmitted with it are confidential and intended 
solely for the use of the individual or entity to whom they are 
addressed. If you receive a message in error, please advise the sender and 
delete immediately.

Except where this email is sent in the usual course of our business, any 
opinions expressed in this email are those of the author and do not 
necessarily reflect the opinions of Age UK or its subsidiaries and associated 
companies. Age UK monitors all e-mail transmissions passing 
through its network and may block or modify mails which are deemed to be 
unsuitable.

Age Concern England (charity number 261794) and Help the Aged (charity number 
272786) and their trading and other associated companies merged 
on 1st April 2009.  Together they have formed the Age UK Group, dedicated to 
improving the lives of people in later life.  The three national 
Age Concerns in Scotland, Northern Ireland and Wales have also merged with Help 
the Aged in these nations to form three registered charities: 
Age Scotland, Age NI, Age Cymru.




__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] assigning the class of an object

2013-09-11 Thread peter dalgaard

On Sep 10, 2013, at 23:49 , Rolf Turner wrote:
>> 
> Hmmm.  I did:
> 
> x <- 42
> save(x,file="Robject.RData")
> rm(list=ls())
> obj_name <- load("Robject.RData")
> class(get(obj_name)) <- "myClass"
> x
> 
> and got:
> 
> [1] 42
> attr(,"class")
> [1] "myClass"
> 
> (also got the familiar error message).
> 
> When I did it your way --- without the saving and loading bit --- I got
> the same result that you did.  I.e. assigning the class that way did *not*
> work (as one would expect it wouldn't!).
> 
> This is weird, n'est-ce pas?
> 

A bug, I'm pretty sure.

-p

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

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


Re: [R] Formula in a model

2013-09-11 Thread Gerrit Eichner

Hello, Paulito,

first, I think you haven't received an answer yet because you did not 
"provide commented, minimal, self-contained, reproducible code" as the 
posting guide does request it from you.


Second, see inline below.

On Wed, 11 Sep 2013, Paulito Palmes wrote:


Hi,

I have a data.frame with dimension 336x336 called *training*, and 
another one called *observation* which is 336x1. I combined them as one 
table using table=data.frame(training, observation). table now has 
336x337 dimension with the last column as the observation to learn using 
the training data of the rest of the column in the table. For 
prediction, i combined the testing data and observation and pass it like 
predict(model,testingWTesingObservation)



I've used the formula: rpart(table[,337] ~ ., data=table) or 
svm(table[,337] ~ ., data=table).


I am not familiar with rpart() nor with svm() but "table[,337] ~ ., data = 
table" has the consequence that table[,337] is also in the right hand side 
of the formula, so that your "observations" are also in the "training" 
data. That doesn't seem to make sense to me, and is different from the 
call to svm() below.


 Hth  --  Gerrit

I recently discovered that this formulation produces different model 
from the: svm(training, observation) formulation. Which is correct and 
why one of them is not correct? I thought that syntactically, both are 
the same. I hope that R should be able to detect the error in one of the 
formulation to avoid the possibility of using it.


Regards,
Paul
[[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] Problems to show X-labels when plotting small values

2013-09-11 Thread Charles Novaes de Santana
Dear Jim,

Thank you very much for your suggestion! It worked perfectly! Thanks for
clarifying how things work.

Best regards,

Charles


On Wed, Sep 11, 2013 at 3:49 AM, Jim Lemon  wrote:

> On 09/11/2013 09:06 AM, Charles Novaes de Santana wrote:
>
>> Dear all,
>>
>> I am following instructions of FAQ 7.2 (
>> http://cran.r-project.org/doc/**FAQ/R-FAQ.html#How-can-I-**
>> create-rotated-axis-labels_**003f
>> )
>> to create rotated labels in my plots, but I am facing some problems when
>> plotting variables with small values (in my case, values between 0.001 and
>> 0.007).
>>
>> When I try to plot these small values, the X-label of my plot doesn't
>> appear. Please find below the example I am trying to run:
>>
>> #Definition of my variable and of the labels
>> a<-c(0.007,0.0004,0.0001)
>> laba<-c("number1","number2","**number3")
>>
>> #This plot doesn't work fine (label doesn't appear)
>> par(mar = c(7, 4, 4, 2) + 0.1)
>> plot(a,xaxt="n",xlab="",ylab="**Y-Label")
>> axis(1,labels=FALSE,tick=**FALSE)
>> mtext(1,text="X-Label",line=6)
>> text(1:length(a), par("usr")[3] - 0.25, srt = 45, adj = 1,labels = a, xpd
>> =
>> TRUE,cex=0.75)
>>
>> #If I just multiply my variable, the plot works fine (label appears)
>> par(mar = c(7, 4, 4, 2) + 0.1)
>> plot(1000*a,xaxt="n",xlab="",**ylab="Y-Label")
>> axis(1,labels=FALSE,tick=**FALSE)
>> mtext(1,text="X-Label",line=6)
>> text(1:length(a), par("usr")[3] - 0.25, srt = 45, adj = 1,labels = laba,
>> xpd = TRUE,cex=0.75)
>>
>> Do you have any idea about why is it happening? I much appreciate any
>> help!
>>
>>  Hi Charles,
> The problem lies in your specification of the y values for the labels in
> the "text" call. Because you are subtracting a large value relative to the
> range of y values, the labels are displayed way off the bottom of the plot.
> Try this instead:
>
> text(1:length(a),par("usr")[3]**-0.0002,srt=45,adj=1,
>  labels=a,xpd=TRUE,cex=0.75)
>
> If you want to pass explicit values for the positions on the plot, check
> them against the x and y ranges.
>
> Jim
>



-- 
Um axé! :)

--
Charles Novaes de Santana, PhD
http://www.imedea.uib-csic.es/~charles

[[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] to retrieve specific data from a matrix

2013-09-11 Thread Berend Hasselman

On 11-09-2013, at 09:38, Elaine Kuo  wrote:

> Dear list,
> 
> I want to retrieve a specific data from a matrix with 3000 columns.
> The matrix has island ID as its rows and species ID as its columns.
> There are 20 rows and 3000 columns in the matrix.
> (Island ID: Species 1- Species 20/ species ID: Species 1- Species 3000)
> The contents of the matrix grids is 1 or 0, for presence and absence.
> 
> Now I would like to check in Island 1 which species is 1. (Island 1 as row
> 2)
> Please kindly advise how to code the command and thank you in advance.

What have you tried?
Something like this perhaps

which(datamatrix[2,] == 1) or which(datamatrix[2,] == 1L)

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.


[R] to retrieve specific data from a matrix

2013-09-11 Thread Elaine Kuo
Dear list,

I want to retrieve a specific data from a matrix with 3000 columns.
The matrix has island ID as its rows and species ID as its columns.
There are 20 rows and 3000 columns in the matrix.
(Island ID: Species 1- Species 20/ species ID: Species 1- Species 3000)
The contents of the matrix grids is 1 or 0, for presence and absence.

Now I would like to check in Island 1 which species is 1. (Island 1 as row
2)
Please kindly advise how to code the command and thank you in advance.

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.


Re: [R] Formula in a model

2013-09-11 Thread Paulito Palmes
Hi,

I have a data.frame with dimension 336x336 called *training*, and another one 
called *observation* which is 336x1. I combined them as one table using 
table=data.frame(training, observation). table now has 336x337 dimension with 
the last column as the observation to learn using the training data of the rest 
of the column in the table. For prediction, i combined the testing data and 
observation and pass it like predict(model,testingWTesingObservation)


I've used the formula: rpart(table[,337] ~ ., data=table) or svm(table[,337] ~ 
., data=table). I recently discovered that this formulation produces different 
model from the: svm(training, observation) formulation. Which is correct and 
why one of them is not correct? I thought that syntactically, both are the 
same. I hope that R should be able to detect the error in one of the 
formulation to avoid the possibility of using it.

Regards,
Paul
[[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.