[R] Factored ARMA models

2013-09-20 Thread Indrajit Sengupta
I am trying to replicate ARIMA models in R from SAS. Specifically -
Factored ARMA models, which I can do very easily in SAS (
http://v8doc.sas.com/sashtml/ets/chap7/sect11.htm).

I would like to know if there is a way to do this in any of the R packages.

Thanks in advance,
Indrajit


[[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] Factored ARMA models

2013-09-20 Thread Pascal Oettli
Hello,

Please have a look at:
http://cran.r-project.org/web/views/TimeSeries.html

Regards,
Pascal



2013/9/20 Indrajit Sengupta indrajitsg2...@gmail.com

 I am trying to replicate ARIMA models in R from SAS. Specifically -
 Factored ARMA models, which I can do very easily in SAS (
 http://v8doc.sas.com/sashtml/ets/chap7/sect11.htm).

 I would like to know if there is a way to do this in any of the R packages.

 Thanks in advance,
 Indrajit


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




-- 
Pascal Oettli
Project Scientist
JAMSTEC
Yokohama, Japan

[[alternative HTML version deleted]]

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


Re: [R] R-3.0.1 g77 errors

2013-09-20 Thread Prof Brian Ripley

On 19/09/2013 15:28, Prigot, Jonathan wrote:

Sadly, I am limited to the Solaris 10 system. I wish that I could use
Linux, the world uses it.


What does that have to do with this?

The CRAN check farm uses gfortran 4.8 on a Solaris 10 system.  g77 is 
not the native compiler there, nor is that used for most binary software.


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

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


[R] [R-pkgs] depmixS4 version 1.3-0 on CRAN

2013-09-20 Thread Ingmar Visser
Package news (see below for general description of functionality)

depmixS4 version 1.3-0 has been released on CRAN. See the NEWS file
for an overview of all changes. The most important user-visible
changes are:

1) more compact pretty-printing of parameters in print/summary of
(dep)mix objects (following lm/glm style of presenting results)

2) some speed improvements in the EM algorithm, most notable in large
data/models

3) EM has an optional argument to use the classification likelihood
instead of the usual likelihood; this can be useful as a means of
starting value generation; use with caution as results are often
unstable.

Best, happy mixing, Ingmar  Maarten



Package general information

depmixS4 is a framework for specifying and fitting dependent mixture
models, otherwise known as hidden or latent Markov models.
Optimization is done with the EM algorithm or optionally with Rdonlp2
when (general linear (in-)equality) constraints on the parameters need
to be incorporated.  Models can be fitted on (multiple) sets of
observations.  The response densities for each state may be chosen
from the GLM family, or a multinomial.  User defined response
densities are easy to add; for the latter an example is given for the
ex-gauss distribution as well as the multivariate normal distribution.

Mixture or latent class (regression) models can also be fitted; these
are the limit case in which the length of observed time series is 1
for all cases.

___
R-packages mailing list
r-packa...@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-packages

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


Re: [R] Need help to find out the name of my columns and rows in a data file

2013-09-20 Thread PIKAL Petr
Hi

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of David Winsemius
 Sent: Friday, September 20, 2013 6:39 AM
 To: ivanc010
 Cc: r-help@r-project.org
 Subject: Re: [R] Need help to find out the name of my columns and rows
 in a data file
 
 
 On Sep 19, 2013, at 3:59 PM, ivanc010 wrote:
 
  I've been assigned homework to analyze a file. The R package is
 car.
  The specific data file is Florida.
 
  So, I did the usual stuff:
  library(car)
  data(Florida)
  summary(Florida)
 
  My specific assignment is to run a t-test between GORE and BUSH.
 (This
  file has information on the 2000 election.)
 
  To run my t-test, my code must be something analogues to:
 
 
 t.test(case0102$Salary[case0102$Sex==Female],case0102$Salary[case010
  2$Sex==Male])
 
  Unfortunately, for my Florida data I can't find the analogues titles
  of the rows and columns (i.e. Sex and Salary).

Well, can not resist. I believe both are Male.

see
?str

Regards
Petr

 
 Please read the Posting Guide. Many of the participants in R-Help are
 academics and they are asking _their_ students not to post howmework
 questions here. The Posting Guide lays out the reasoning. Please read
 it, ... and don't expect replies.
 
  --
  View this message in context:
  http://r.789695.n4.nabble.com/Need-help-to-find-out-the-name-of-my-
 col
  umns-and-rows-in-a-data-file-tp4676534.html
  Sent from the R help mailing list archive at Nabble.com.
 
 
 Nabble is NOT the archive for R-help.
 
 --
 
 David Winsemius
 Alameda, CA, USA
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Hope u have some time for 2 more questions

2013-09-20 Thread Simon Zehnder
Hi,

as far as I know, there is no limitation on data size in regard to foreach. You 
should reserve though enough memory for your application on the cluster (via 
ulimit -s unlimited and ulimit -v unlimited). 

Furthermore I would check the following: 
Check if there are two versions of R on the cluster/your home directory on the 
frontend (LSF loads this frontend environment and uses the R version installed 
there). If you have two R executables (R and R64) make sure you use the 64bit 
version.

Run R and call memory.limit() to see what are the limits of memory in your 
system. 

If this is limited to sizes below your needed sizes, increase it by calling R 
in the LSF script with the options --max-mem-size=YourSize and if you get 
errors of kind  cannot allocate vector of size you should also use 
--max-vsize=YourVSize. 

Then, check if there is a memory leak in your application: If you compiled R 
with the --enable-memory-profiling you can use Rprof to do this otherwise you 
must rely on profiling instruments given by the cluster environment (I think 
you work there as well with modules, so type in the shell 'module avail' for 
listing available modules). 

If you detect a memory leak or if you see, that at certain points in your 
algorithms some objects are not used anymore call rm(ObjectName) and gc() for 
garbage collection. 


To your nested loop using foreach: That is a highly delicate issue in parallel 
computing and for the foreach syntax I refer to the must-read 
http://cran.r-project.org/web/packages/foreach/vignettes/nested.pdf. 

Using nested loops should be considered carefully in regard to organizing the 
nesting. In C++ you have the ability to determine how many cores should work on 
which loop. In the foreach environment using doMC this seems to me not 
possible. 


And, please keep the discussion to the r-help mailing list, so others can learn 
from it and researchers with more experience can also leave comments. 


Best

Simon


On Sep 19, 2013, at 9:24 PM, pko...@bgc-jena.mpg.de wrote:

 Hi again,
 
 if you have some time I would like to bother you again with 2 more questions. 
 After your response the parallel code is working perfect but when I implement 
 that to the real case (big matrices) I get an error for not numeric dimension 
 and i guess that again it returns NULL or something. Are you aware if foreach 
 loop can handle only a certain size objects? the equation that I am using 
 includes 3 objects with 2Gb size each. 
 
 The second question has to deal with the cores that foreach uses. Although I 
 am asking to our cluster (LSF) to give me certain number of cpus, and also i 
 am specifing that with
 library(doMC)
 registerDoMC(n) 
 
 it seems from the top command that I am using all the cores. I am using 2 
 foreach as nest  foreach(i in 1:16){
 foreach(j in 1:10)  etc etc..
 maybe i should do something with this kind of nest? I am not aware about that.
 
 I am sorry for the long text , and thank you for your nice solution
 
 _
 Sent from http://r.789695.n4.nabble.com
 

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


[R] Subcripting matrix

2013-09-20 Thread Christofer Bogaso
Hello again,

I have one question on subscripting matrix. Let say I have following matrix:

 Mat - matrix(1:9, 3)
 colnames(Mat) - c(a, b, a)
 Mat
 a b a
[1,] 1 4 7
[2,] 2 5 8
[3,] 3 6 9


Now I want to fetch data for colnames 'a'.I did following:

 Mat[, a]
[1] 1 2 3


However it is not taking second 'a' colume. Basically I expected to
get 1st and 3rd columns

Can somebody tell me how to achieve that?

Thanks and regards,

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

2013-09-20 Thread Berend Hasselman

On 20-09-2013, at 12:52, Christofer Bogaso bogaso.christo...@gmail.com wrote:

 Hello again,
 
 I have one question on subscripting matrix. Let say I have following matrix:
 
 Mat - matrix(1:9, 3)
 colnames(Mat) - c(a, b, a)
 Mat
 a b a
 [1,] 1 4 7
 [2,] 2 5 8
 [3,] 3 6 9
 
 
 Now I want to fetch data for colnames 'a'.I did following:
 
 Mat[, a]
 [1] 1 2 3
 
 
 However it is not taking second 'a' colume. Basically I expected to
 get 1st and 3rd columns
 
 Can somebody tell me how to achieve that?
 

I think this is just silly.

How about

Mat[,which(colnames(Mat)==a)]

Berend

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


Re: [R] Subcripting matrix

2013-09-20 Thread Olivier Crouzet
Hi,

it seems the following works as needed...

Mat[,colnames(Mat)==a]

Olivier.

On Fri, 20 Sep 2013 16:22:37 +0530
Christofer Bogaso bogaso.christo...@gmail.com wrote:

 Hello again,
 
 I have one question on subscripting matrix. Let say I have following
 matrix:
 
  Mat - matrix(1:9, 3)
  colnames(Mat) - c(a, b, a)
  Mat
  a b a
 [1,] 1 4 7
 [2,] 2 5 8
 [3,] 3 6 9
 
 
 Now I want to fetch data for colnames 'a'.I did following:
 
  Mat[, a]
 [1] 1 2 3
 
 
 However it is not taking second 'a' colume. Basically I expected to
 get 1st and 3rd columns
 
 Can somebody tell me how to achieve that?
 
 Thanks and regards,
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html and provide commented,
 minimal, self-contained, reproducible code.


-- 
  Olivier Crouzet, PhD
  Laboratoire de Linguistique -- EA3827
  Université de Nantes
  Chemin de la Censive du Tertre - BP 81227
  44312 Nantes cedex 3
  France

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

  http://www.lling.univ-nantes.fr/

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


Re: [R] Factored ARMA models

2013-09-20 Thread Indrajit Sengupta
Can you point to any function in specific?


On Fri, Sep 20, 2013 at 12:10 PM, Pascal Oettli kri...@ymail.com wrote:

 Hello,

 Please have a look at:
 http://cran.r-project.org/web/views/TimeSeries.html

 Regards,
 Pascal



 2013/9/20 Indrajit Sengupta indrajitsg2...@gmail.com

 I am trying to replicate ARIMA models in R from SAS. Specifically -
 Factored ARMA models, which I can do very easily in SAS (
 http://v8doc.sas.com/sashtml/ets/chap7/sect11.htm).

 I would like to know if there is a way to do this in any of the R
 packages.

 Thanks in advance,
 Indrajit


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




 --
 Pascal Oettli
 Project Scientist
 JAMSTEC
 Yokohama, Japan


[[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] binary symmetric matrix combination

2013-09-20 Thread arun
Hi Elio,
Try this:

library(stringr)

lines1-str_trim(gsub(\t, ,readLines(elio.txt)))
 lst1-lapply(split(lines1,cumsum(lines1==)),function(x) x[x!=])

lst2- lapply(lst1[lapply(lst1,length)0],function(x) 
as.matrix(read.table(text=x,row.names=1)))
names(lst2)- paste0(m,seq_along(lst2))
dat- do.call(rbind,lapply(names(lst2),function(x) {x1- lst2[[x]]; 
cbind(expand.grid(rep(list(colnames(x1)),2),stringsAsFactors=FALSE),value=as.vector(x1))}))
library(reshape2)
res- dcast(dat,Var1~Var2,value.var=value,sum)
 row.names(res)- res[,1]
 res- as.matrix(res[,-1])
 dim(res)
#[1] 14 14


A.K.




From: Elio Shijaku sel...@gmail.com
To: arun smartpink...@yahoo.com 
Sent: Friday, September 20, 2013 3:38 AM
Subject: Re: binary symmetric matrix combination



Hi Arun,

Let me explain my point. With your great help, I was able to create matrices 
such as m1, m2, etc. My initial objective was to combine the binary matrices 
and I succeeded in that again with your help. The only problem I have left is 
that since  I have about 350 matrices to combine for a single giant symmetric 
binary matrix of 470x470 size and I have to repeat this 22 times (got 22 giant 
matrices to build), I was hoping to not have to manually input each matrix but 
to use your list2 command to get them all from Excel. Now the problem is how to 
get the elements from list2 to then apply the commands:


Out1-
as.matrix(read.table(text=y1 g24 c1 c2 l17 h4 s2 s30 e5
l15,sep=,header=TRUE))
names1-unique(c(colnames(m1),colnames(m2),colnames(m3),colnames(m4),colnames(m5)))
 
Out3-matrix(0,length(names1),length(names1),dimnames=list(names1,names1)) 
vecOut-paste0(colnames(Out3)[col(Out3)],rownames(Out3)[row(Out3)]) 
lst1-sapply(paste0(m,1:5),function(x)
{x1- get(x); x2-paste0(colnames(x1)[col(x1)],rownames(x1)[row(x1)]);
match(x2,vecOut)}) 
lst2- list(m1,m2,m3,m4,m5) 
N- length(lst1) 

 fn1- function(N,Out){ 
 i=1 
 while(i=N){ 
 Out[lst1[[i]]]-lst2[[i]] 
 i-i+1 
 } 
Out 
 } 
fn1(N,Out3)

Thanks a lot!!

Best,

Elio

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

2013-09-20 Thread mohan . radhakrishnan
Replying with some code.

input- readLines(textConnection(
  6.2   httpd (18)
  4.0   httpd (11)
  4.0   httpd (11)
  3.3   httpd (9)
  4.2   httpd (12)
  4.2httpd (12)
  4.2   httpd (12)
  4.2   httpd (12)
  4.2   httpd (12)
))

data-input[input!=]

 data
[1]   6.2 httpd (18) 4.0 httpd (11) 4.0 httpd (11) 3.3 
httpd (9) 
[5]   4.2 httpd (12) 4.2   httpd (12)   4.2 httpd (12) 4.2 
httpd (12) 
[9]   4.2 httpd (12) 

m - t(sapply(1:1,function(x) unlist(strsplit(data, +

   [,1] [,2]  [,3][,4]   [,5] [,6]  [,7][,8]   [,9] [,10] [,11] 
[,12]  [,13] [,14]
[1,]6.2 httpd (18)4.0 httpd (11)4.0 
httpd (11) 3.3
 [,15]   [,16] [,17] [,18] [,19]   [,20]  [,21] [,22] [,23]   [,24] 
[,25] [,26] [,27] 
[1,] httpd (9) 4.2 httpd (12) 4.2 httpd (12) 
4.2 httpd
 [,28]  [,29] [,30] [,31]   [,32]  [,33] [,34] [,35]   [,36] 
[1,] (12) 4.2 httpd (12) 4.2 httpd (12)


What I want to do is this ?

  6.2   httpd   18
  4.0   httpd   11
  4.0   httpd   11
  3.3   httpd9)
  4.2   httpd   12
  4.2httpd12
  4.2   httpd   12
  4.2   httpd   12
  4.2   httpd   12


Thanks,
Mohan



From:   mohan.radhakrish...@polarisft.com
To: r-help@r-project.org
Date:   09/20/2013 10:44 AM
Subject:[R] Averate memory usage trend
Sent by:r-help-boun...@r-project.org



Hi,

I would like to understand how to draw a graph to find out the 
average memory used by a single httpd process given these details 
collected over a period of
several days. I code R but this is about a method to find an average 
memory utilization. I believe I have enough data.

How should I statistically calculate this ? 

The figures inside braces are the total httpd processes at that time. Will 

there be an error  margin if I have combined totals like this ?

Sample data :

  Private Shared RAM used   Program 
  4.0 MiB3.3 MiB7.2 MiB httpd (11)
  3.3 MiB3.0 MiB   6.3 MiB  httpd (9)
  4.2 MiB3.3 MiB  7.5 MiB   httpd (12)


Thanks,
Mohan



This e-Mail may contain proprietary and confidential information and is 
sent for the intended recipient(s) only.  If by an addressing or 
transmission error this mail has been misdirected to you, you are 
requested to delete this mail immediately. You are also hereby notified 
that any use, any form of reproduction, dissemination, copying, 
disclosure, modification, distribution and/or publication of this e-mail 
message, contents or its attachment other than by its intended recipient/s 
is strictly prohibited.

Visit us at http://www.polarisFT.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.




This e-Mail may contain proprietary and confidential information and is sent 
for the intended recipient(s) only.  If by an addressing or transmission error 
this mail has been misdirected to you, you are requested to delete this mail 
immediately. You are also hereby notified that any use, any form of 
reproduction, dissemination, copying, disclosure, modification, distribution 
and/or publication of this e-mail message, contents or its attachment other 
than by its intended recipient/s is strictly prohibited.

Visit us at http://www.polarisFT.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] Averate memory usage trend

2013-09-20 Thread arun
library(stringr)


read.table(text=gsub([()],,str_trim(input[input!=])),sep=,header=FALSE,stringsAsFactors=FALSE)
#   V1    V2 V3
#1 6.2 httpd 18
#2 4.0 httpd 11
#3 4.0 httpd 11
#4 3.3 httpd  9
#5 4.2 httpd 12
#6 4.2 httpd 12
#7 4.2 httpd 12
#8 4.2 httpd 12
#9 4.2 httpd 12
A.K. 




- Original Message -
From: mohan.radhakrish...@polarisft.com mohan.radhakrish...@polarisft.com
To: r-help@r-project.org
Cc: 
Sent: Friday, September 20, 2013 9:15 AM
Subject: Re: [R] Averate memory usage trend

Replying with some code.

input- readLines(textConnection(
  6.2   httpd (18)
  4.0   httpd (11)
  4.0   httpd (11)
  3.3   httpd (9)
  4.2   httpd (12)
  4.2        httpd (12)
  4.2   httpd (12)
  4.2   httpd (12)
  4.2   httpd (12)
))

data-input[input!=]

 data
[1]   6.2 httpd (18)     4.0 httpd (11)     4.0 httpd (11)     3.3 
httpd (9) 
[5]   4.2 httpd (12)     4.2   httpd (12)   4.2 httpd (12)     4.2 
httpd (12) 
[9]   4.2 httpd (12) 

m - t(sapply(1:1,function(x) unlist(strsplit(data, +

   [,1] [,2]  [,3]    [,4]   [,5] [,6]  [,7]    [,8]   [,9] [,10] [,11] 
[,12]  [,13] [,14]
[1,]    6.2 httpd (18)    4.0 httpd (11)    4.0 
httpd (11)     3.3
     [,15]   [,16] [,17] [,18] [,19]   [,20]  [,21] [,22] [,23]   [,24] 
[,25] [,26] [,27] 
[1,] httpd (9)     4.2 httpd (12)     4.2 httpd (12) 
    4.2 httpd
     [,28]  [,29] [,30] [,31]   [,32]  [,33] [,34] [,35]   [,36] 
[1,] (12)     4.2 httpd (12)     4.2 httpd (12)


What I want to do is this ?

  6.2   httpd       18
  4.0   httpd       11
  4.0   httpd       11
  3.3   httpd        9)
  4.2   httpd       12
  4.2        httpd        12
  4.2   httpd       12
  4.2   httpd       12
  4.2   httpd       12


Thanks,
Mohan



From:  mohan.radhakrish...@polarisft.com
To:    r-help@r-project.org
Date:   09/20/2013 10:44 AM
Subject:        [R] Averate memory usage trend
Sent by:        r-help-boun...@r-project.org



Hi,

        I would like to understand how to draw a graph to find out the 
average memory used by a single httpd process given these details 
collected over a period of
several days. I code R but this is about a method to find an average 
memory utilization. I believe I have enough data.

How should I statistically calculate this ? 

The figures inside braces are the total httpd processes at that time. Will 

there be an error  margin if I have combined totals like this ?

Sample data :

  Private     Shared     RAM used       Program 
  4.0 MiB    3.3 MiB        7.2 MiB     httpd (11)
  3.3 MiB    3.0 MiB       6.3 MiB      httpd (9)
  4.2 MiB    3.3 MiB      7.5 MiB       httpd (12)


Thanks,
Mohan



This e-Mail may contain proprietary and confidential information and is 
sent for the intended recipient(s) only.  If by an addressing or 
transmission error this mail has been misdirected to you, you are 
requested to delete this mail immediately. You are also hereby notified 
that any use, any form of reproduction, dissemination, copying, 
disclosure, modification, distribution and/or publication of this e-mail 
message, contents or its attachment other than by its intended recipient/s 
is strictly prohibited.

Visit us at http://www.polarisFT.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.




This e-Mail may contain proprietary and confidential information and is sent 
for the intended recipient(s) only.  If by an addressing or transmission error 
this mail has been misdirected to you, you are requested to delete this mail 
immediately. You are also hereby notified that any use, any form of 
reproduction, dissemination, copying, disclosure, modification, distribution 
and/or publication of this e-mail message, contents or its attachment other 
than by its intended recipient/s is strictly prohibited.

Visit us at http://www.polarisFT.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-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Renaming variables

2013-09-20 Thread Preetam Pal
Hi,

I guess this is pretty basic.

I have 25 variables in the data file (name: score), i.e. X1,X2,.,X25.

I dont want to use score$X1, score$X2 everytime I use these variables.

Is there a way I can rename all these variables as simply X1,X2,.X25
 without writing 25 lines of code, one line for renaming each variable (eg:
  X1=score.X1  X2=score.X2  and so on) ?

Thanks for your help.

Regards,
Preetam

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

[[alternative HTML version deleted]]

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


Re: [R] Need help to find out the name of my columns and rows in a data file

2013-09-20 Thread Clint Bowman
You are close--think names, not titles, as in rownames or colnames (no 
reason to completely spell out column).  Summary already gave you the 
column names, so type ?rownames to learn more.


Clint BowmanINTERNET:   cl...@ecy.wa.gov
Air Quality Modeler INTERNET:   cl...@math.utah.edu
Department of Ecology   VOICE:  (360) 407-6815
PO Box 47600FAX:(360) 407-7534
Olympia, WA 98504-7600

USPS:   PO Box 47600, Olympia, WA 98504-7600
Parcels:300 Desmond Drive, Lacey, WA 98503-1274

On Thu, 19 Sep 2013, ivanc010 wrote:


I've been assigned homework to analyze a file. The R package is car. The
specific data file is Florida.

So, I did the usual stuff:
library(car)
data(Florida)
summary(Florida)

My specific assignment is to run a t-test between GORE and BUSH. (This file
has information on the 2000 election.)

To run my t-test, my code must be something analogues to:

t.test(case0102$Salary[case0102$Sex==Female],case0102$Salary[case0102$Sex==Male])

Unfortunately, for my Florida data I can't find the analogues titles of the
rows and columns (i.e. Sex and Salary).

Please help.



--
View this message in context: 
http://r.789695.n4.nabble.com/Need-help-to-find-out-the-name-of-my-columns-and-rows-in-a-data-file-tp4676534.html
Sent from the R help mailing list archive at Nabble.com.

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



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


Re: [R] Renaming variables

2013-09-20 Thread Simon Zehnder
You haven't said yet, what object your 'data file' is. If you mean a data.frame 
I would use colnames(dataName) - c(Col1Name, col2Name, ….)

Best
Simon

On Sep 20, 2013, at 4:10 PM, Preetam Pal lordpree...@gmail.com wrote:

 Hi,
 
 I guess this is pretty basic.
 
 I have 25 variables in the data file (name: score), i.e. X1,X2,.,X25.
 
 I dont want to use score$X1, score$X2 everytime I use these variables.
 
 Is there a way I can rename all these variables as simply X1,X2,.X25
 without writing 25 lines of code, one line for renaming each variable (eg:
 X1=score.X1  X2=score.X2  and so on) ?
 
 Thanks for your help.
 
 Regards,
 Preetam
 
 -- 
 Preetam Pal
 (+91)-9432212774
 M-Stat 2nd Year, Room No. N-114
 Statistics Division,   C.V.Raman
 Hall
 Indian Statistical Institute, B.H.O.S.
 Kolkata.
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Clustering of data set documentation files in package description

2013-09-20 Thread Thiem Alrik
Dear R help list,

I was just wondering whether there is a way to cluster the documentation files 
of data sets in the package documentation index file, so that common prefixes 
such as dat... are not necessary.

Best wishes,
Alrik



Dr. Alrik Thiem
Post-Doctoral Researcher

Department of Humanities, Social and Political Sciences
Swiss Federal Institute of Technology Zurich (ETHZ)
Building IFW, Office C 29.2
Haldeneggsteig 4
CH-8092 Zurich

+41 44 63 20937 (landline)
+41 76 52 78083 (mobile)

http://www.alrik-thiem.net
http://www.compasss.org



Dr. Alrik Thiem
Post-Doctoral Researcher

Department of Humanities, Social and Political Sciences
Swiss Federal Institute of Technology Zurich (ETHZ)
Building IFW, Office C 29.2
Haldeneggsteig 4
CH-8092 Zurich

+41 44 63 20937 (landline)
+41 76 52 78083 (mobile)

http://www.alrik-thiem.net
http://www.compasss.org

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


Re: [R] Renaming variables

2013-09-20 Thread Aaron Mackey
On Fri, Sep 20, 2013 at 10:10 AM, Preetam Pal lordpree...@gmail.com wrote:

 I have 25 variables in the data file (name: score), i.e. X1,X2,.,X25.

 I dont want to use score$X1, score$X2 everytime I use these variables.


attach(score)

plot(X1, X2) # etc. etc.

-Aaron

[[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] Creating dummy vars with contrasts - why does the returned identity matrix contain all levels (and not n-1 levels) ?

2013-09-20 Thread David Winsemius


On Sep 13, 2013, at 11:21 PM, E Joffe wrote:


Hi David,

First I ordered the levels of each factor in a descending order  
based on

frequency.
Then, I used the following code to generate a matrix from the  
dataframe with

dummy variables and  subsequently run the glmnet (coxnet)

## tranform categorical variables into binary variables with dummy for
trainSet
predict_matrix - model.matrix(~ ., data=trainSet,
 contrasts.arg = lapply
(trainSet[,sapply(trainSet, is.factor)], contrasts))

## remove the status/time variables from the predictor matrix (x) for
glmnet
predict_matrix - subset (predict_matrix, select=c(-time,-status))

## create a glmnet cox object using lasso regularization and cross
validation
glmnet.cv - cv.glmnet (predict_matrix, surv_obj, family=cox)


I hope I did not do anything wrong .

Can't thank you enough for your advice and interest.


Thank you for outlining the process that you used. It looks from the  
outside as though it respects the constraints on the first two  
argument imposed by the more constrained input requirements of  
cv.glmnet. I didn't realize that subset could accept a `-`sign as an  
operator inside a c() expression, but if you are getting success then  
I guess it must.


--
David.




Erel



-Original Message-
From: David Winsemius [mailto:dwinsem...@comcast.net]
Sent: Friday, September 13, 2013 8:51 PM
To: E Joffe
Cc: r-help@r-project.org
Subject: Re: [R] Creating dummy vars with contrasts - why does the  
returned

identity matrix contain all levels (and not n-1 levels) ?


On Sep 13, 2013, at 9:33 AM, E Joffe wrote:


Thank you so much for your answer  !
As far as I understand, glmnet doesn't accept categorical variables
only binary factors - so I had to create dummy variables for all
categorical variables.


I was rather puzzled by your question. The conventions used by  
glmnet should
prevent constrasts from being pre-specified. Only matrices are  
accepted as
data objects and one cannot assign contrast attributes to matrix  
columns.



It worked perfectly.
Erel


Erel Joffe MD MSc
School of Biomedical Informatics
University of Texas - Health Science Center in Houston
832.287.0829 (c)

-Original Message-
From: David Winsemius [mailto:dwinsem...@comcast.net]
Sent: Friday, September 13, 2013 3:05 PM
To: E Joffe
Cc: r-help@r-project.org
Subject: Re: [R] Creating dummy vars with contrasts - why does the
returned identity matrix contain all levels (and not n-1 levels) ?


On Sep 13, 2013, at 4:15 AM, E Joffe wrote:


Hello,



I have a problem with creating an identity matrix for glmnet by  
using

the contrasts function.


Why do you want to do this?


I have a factor with 4 levels.

When I create dummy variables I think there should be n-1 variables
(in this case 3) - so that the contrasts would be against the
baseline level.

This is also what is written in the help file for 'contrasts'.

The problem is that the function creates a matrix with n variables
(i.e. the same as the number of levels) and not n-1 (where I would
have a baseline level for comparison).


Only if you specify contrasts=FALSE does it do so and this is
documented in that help file.




My questions are:

1.   How can I create a matrix with n-1 dummy vars ?


See below.


was I supposed to
define explicitly that I want contr.treatment (contrasts) ?


No need to do so.



2.   If it is not possible, how should I interpret the hazard
ratios in
the Cox regression I am generating (I use glmnet for variable
selection and
then generate a Cox regression)  - That is, if I get an HR of 3 for
the
variable 300mg what does it mean ? the hazard is 3 times higher of
what ?



Relative hazards are generally referenced to the baseline hazard,
i.e. the hazard for a group with the omitted level for treatment
constrasts and the mean value for any numeric predictors.


Here is some code to reproduce the issue:

# Create a 4 level example factor

trt - factor( sample( c(PLACEBO, 300 MG, 600 MG, 1200 MG),

 100, replace=TRUE ) )


# If your intent is to use constrasts different than the defaults  
used

by
#  regression functions, these factor contrasts need to be assigned,
either
# within the construction of the factor or after the fact.


contrasts(trt)

300 MG 600 MG PLACEBO
1200 MG  0  0   0
300 MG   1  0   0
600 MG   0  1   0
PLACEBO  0  0   1

# the default value for the contrasts parameter is TRUE and the
default type is treatement

# That did not cause any change to the 'trt'-object:
trt

#To make a change you need to use the `contrasts-` function:

contrasts (trt) - contrasts(trt)
trt



# Use contrasts to get the identity matrix of dummy variables to be
used in
glmnet

trt2 - contrasts (trt,contrasts=FALSE)

Results (as you can see all levels are represented in the identity
matrix):


levels (trt)

[1] 1200 MG 300 MG  600 MG  PLACEBO



print (trt2)


  1200 MG 300 MG 600 MG 

Re: [R] Renaming variables

2013-09-20 Thread Clint Bowman

or

with(score.plot(X1, X2))

Clint BowmanINTERNET:   cl...@ecy.wa.gov
Air Quality Modeler INTERNET:   cl...@math.utah.edu
Department of Ecology   VOICE:  (360) 407-6815
PO Box 47600FAX:(360) 407-7534
Olympia, WA 98504-7600

USPS:   PO Box 47600, Olympia, WA 98504-7600
Parcels:300 Desmond Drive, Lacey, WA 98503-1274

On Fri, 20 Sep 2013, Aaron Mackey wrote:


On Fri, Sep 20, 2013 at 10:10 AM, Preetam Pal lordpree...@gmail.com wrote:


I have 25 variables in the data file (name: score), i.e. X1,X2,.,X25.

I dont want to use score$X1, score$X2 everytime I use these variables.



attach(score)

plot(X1, X2) # etc. etc.

-Aaron

[[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] Is there a way to change x and y axis tick mark inside plot()?

2013-09-20 Thread C W
Dear R community,
I am having trouble changing the tick marks on y-axis to every 5 units?  I
have the following:

x - c(12, 16, 6, 23, 27, 8, 5, 19, 23, 13, 16, 8)

y - c(29, 29, 23, 34, 38, 24, 22, 34, 36, 27, 33, 27)

plot(x, y, pch=19)

Should I change ylim=c(0,40), and then use axis()?

I kept on thinking I can do everything inside plot(), but there is actually
axis(), par(), ..., and so on.
Could someone tell me why is there so many functions outside plot().  I'm
sure there is a reason, but I don't seem to understand why.
Thanks,
Mike

[[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] Rmpfr question

2013-09-20 Thread Michel
Hello everyone,
R beginner, I am confronted with the need to use Rmpf.
In my first scripts I made use of 

X=read.table(file.choose(), header=FALSE, sep=,,dec=.) 
X=as.matrix(X)

to load into a matrix data  from file before matrix use.

How can I do to load the same data in a mpfrMatrix.

Is it possible to use with mpfrMatrix the same as operations

M1%*%M2 
scale(M1,TRUE,FALSE)

Sorry but I'm a newbe

 

Thanks in advance

 

Michel

 


[[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] time zones from longitude, latitude, and date

2013-09-20 Thread carlisle thacker
I have data that provide longitude, latitude, and local date and time but
no information about the corresponding time zone.  How to identify the time
zone so they can be converted to a common date/time?

Thanks,

Carlisle

[[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] Access of odfWeave function to variables that are defined inside a function

2013-09-20 Thread sahar_nokc
Hi everyone!

I have now been using odfWeave() for a while in order to make some word
document reports of my data. I have encountered a problem when I try to
organize my program script into some functions. It seems that if I use the
odfWeave() within a function, then odfWeave() is not able to access the
variables that are defined inside the body of the same function that runs
odfWeave(). Here is a simple example of what I mean:

report.year - function(){
year=2011
odfWeave(sourcefile,outputfile)
}

report.year()

When I run report.year(), I get the error message: object 'year' not found

However, if I define the year out of the body of the function where I run
report.year(), then I don't get such error and I can produce my report.

I am wondering if this is something expected when using odfWeave due to its
nature of being able to only access the variables on the first level, or
should I somehow give access to the variables that are defined in the higher
levels (I mean within the body of my functions)?

I would actually like to report some of the variables that can only be
defined within this function, is there any way of doing it inside the body
of my report.year() function?

I appreciate it a lot if anyone can give me some hint about what I can do in
order to correct for this.

Best regards,
Sahar 




--
View this message in context: 
http://r.789695.n4.nabble.com/Access-of-odfWeave-function-to-variables-that-are-defined-inside-a-function-tp4676562.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] gam and optim

2013-09-20 Thread Greg Dropkin
please ignore this, I see the error.

greg

 hi

 probably a silly mistake, but I expected gam to minimise the penalised
 deviance.

 thanks

 greg

 set.seed(1)
 library(mgcv)
 x-runif(100)
 lp-exp(-2*x)*sin(8*x)
 y-rpois(100,exp(lp))
 plot(x,y)
 m1-gam(y~s(x),poisson)
 points(x,exp(lp),pch=16,col=green3)
 points(x,fitted(m1),pch=16,cex=0.5,col=blue)
 W-diag(fitted(m1))
 X-predict(m1,type=lpmatrix)
 S-m1$smooth[[1]]$S[[1]]
 S-rbind(0,cbind(0,S))
 A-X%*%solve(t(X)%*%W%*%X+m1$sp*S)%*%t(X)%*%W
 sum(diag(A))
 sum(m1$edf)
 fit-fitted(m1)
 b-m1$coef
 range(exp(X%*%b)-fit)
 z-y/fit-1+X%*%b
 range(A%*%z-X%*%b)

 dv-function(t)
 {
 f-exp(X%*%t)
 -2*sum(y*log(f)-f-ifelse(y==0,0,y*log(y))+y)+t%*%S%*%t
 }
 dv(b)
 m1$dev+b%*%S%*%b

 #so far, so good


 t1-optim(rep(0,10),dv)
 t1$p
 b

 #different

 dv(t1$p)
 dv(b)

 #different, and dv(t1$p) is lower!

 fit1-exp(X%*%t1$p)
 points(x,fit1,pch=16,cex=0.5,col=red)

 # different
 # gam found b which does approximate the true curve, but does not minimise
 the penalised deviance, by a long shot.



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

2013-09-20 Thread Greg Dropkin
hi

probably a silly mistake, but I expected gam to minimise the penalised
deviance.

thanks

greg

set.seed(1)
library(mgcv)
x-runif(100)
lp-exp(-2*x)*sin(8*x)
y-rpois(100,exp(lp))
plot(x,y)
m1-gam(y~s(x),poisson)
points(x,exp(lp),pch=16,col=green3)
points(x,fitted(m1),pch=16,cex=0.5,col=blue)
W-diag(fitted(m1))
X-predict(m1,type=lpmatrix)
S-m1$smooth[[1]]$S[[1]]
S-rbind(0,cbind(0,S))
A-X%*%solve(t(X)%*%W%*%X+m1$sp*S)%*%t(X)%*%W
sum(diag(A))
sum(m1$edf)
fit-fitted(m1)
b-m1$coef
range(exp(X%*%b)-fit)
z-y/fit-1+X%*%b
range(A%*%z-X%*%b)

dv-function(t)
{
f-exp(X%*%t)
-2*sum(y*log(f)-f-ifelse(y==0,0,y*log(y))+y)+t%*%S%*%t
}
dv(b)
m1$dev+b%*%S%*%b

#so far, so good


t1-optim(rep(0,10),dv)
t1$p
b

#different

dv(t1$p)
dv(b)

#different, and dv(t1$p) is lower!

fit1-exp(X%*%t1$p)
points(x,fit1,pch=16,cex=0.5,col=red)

# different
# gam found b which does approximate the true curve, but does not minimise
the penalised deviance, by a long shot.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Is there a way to change x and y axis tick mark inside plot()?

2013-09-20 Thread Duncan Murdoch

On 20/09/2013 11:52 AM, C W wrote:

Dear R community,
I am having trouble changing the tick marks on y-axis to every 5 units?  I
have the following:

x - c(12, 16, 6, 23, 27, 8, 5, 19, 23, 13, 16, 8)

y - c(29, 29, 23, 34, 38, 24, 22, 34, 36, 27, 33, 27)

plot(x, y, pch=19)

Should I change ylim=c(0,40), and then use axis()?


Don't use ylim, use yaxt=n, then use axis().


I kept on thinking I can do everything inside plot(), but there is actually
axis(), par(), ..., and so on.
Could someone tell me why is there so many functions outside plot().  I'm
sure there is a reason, but I don't seem to understand why.


R is designed to be flexible.  If you create giant functions that can do 
everything, you end up with a design like SAS, which is extremely 
inflexible.  It's good at what it can do, but it's very hard to get it 
to do something the designers didn't think of.


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] Best way to specify a mixed ANCOVA in R?

2013-09-20 Thread Danielle Smith
I initially posted this question to one of the StackExchange sites, and they 
suggested that I repost my problem here.

After using ezANOVA as my primary way of specifying mixed ANOVAs, I've hit a 
stumbling block when it come to adding a covariate to the model. I am using an 
ANCOVA in order to determine if there is a developmental trajectory in my data; 
namely, I need to be able to see the F-statistic and p-values for interactions 
with the covariate (see p.466 onwards here 
[http://www.psyc.bbk.ac.uk/research/DNL/personalpages/annaz_etal_2009.pdf] if 
you want an example).

Using ezANOVA, I can include covariates but the output does not show the 
F-statistic and p-values for interactions with the covariate - the main effect 
of the covariate is also not tested using this method.

My ezANOVA model is as follows:

aov.model-ezANOVA(
data=textureView.child.outliersRemoved
, dv=.(x)
, wid=.(ID)
, within=.(Texture,View)
, between=.(TNOGroup)
, between_covariates=.(Age)
, type=3
, return_aov=TRUE
)

Another option is to use lm or Anova, but I don't know how to specify the error 
terms properly for either and I'm limited because I want to use Type-III sums 
of squares (drop1 doesn't work in the cases where I've tried to use the aov 
wrapper for lm; it fails while reporting 'Error in formula.default(object, env 
= baseenv()) : invalid formula').

Finally, I've heard about using the nlme package to specify my ANCOVA as a 
mixed model instead, but I don't know where to begin here (despite spending a 
while reading about it).

To give a summary, I'm trying to do a 2 (between; TNOGroup) x 2 (within, 
Texture) x2 (within, View) mixed ANCOVA, with age as a covariate. I want to use 
Type-III sums of squares, and see the F-statistic and p-values for interactions 
with the covariate, as well as for the main effect of the covariate.

Any advice on the best way to do this would be much appreciated.

Thanks,
Danielle
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] saving as TIFF - problem with compression

2013-09-20 Thread Anna Zakrisson Braeunlich
Hi,

I am struggling to save my figures as TIFF files (yes, the yournal only accept 
TIFF and not any other format).
I can manage to save a simple plot as TIFF at the correct dpi (I need at least 
600dpi) and compression works. Only not for my own plot. Everything looks 
distorted. I have read Stack Overflow and tried to change the point size to 6, 
but with no apparent effect. Why is this and what would be the solution? The 
TIFF-stuff is in the end of the script.
thank you for your time!

Ndata - data.frame(
  Ncellpercent = rnorm(400, mean = rep(c(14, 18, 65), each = 40),
   sd = rep(c(1, 3, 6), each = 40)),
  fyear = rep(c('2007', '2008'), each = 100*2),
  Station = sample(c('B1', 'H2', 'H3', 'H4'), 400, replace = TRUE),
  Week = sample(c('19', '21', '23', '25'), 400, replace = TRUE))

Pdata - data.frame(
  Ppercentcell = rnorm(400, mean = rep(c(4, 17, 22), each = 40),
   sd = rep(c(0.1, 0.2, 0.4), each = 40)),
  fyear = rep(c('2007', '2008'), each = 100*2),
  Station = sample(c('B1', 'H2', 'H3', 'H4'), 400, replace = TRUE),
  Week = sample(c('19', '21', '23', '25'), 400, replace = TRUE))

SummNdata - ddply(Ndata, .(Week, fyear, Station), summarise,
   mean = mean(Ncellpercent),
   sd = sd(Ncellpercent))
names(Pdata)
SummPdata - ddply(Pdata, .(Week, fyear, Station), summarise,
   mean = mean(Ppercentcell),
   sd = sd(Ppercentcell))
SummPdata
library(lattice)
library(latticeExtra)
library(HH)

font.settings - list( font = 1, cex = 1.2, fontfamily = serif)

my.theme - list(
  par.xlab.text = font.settings,
  par.ylab.text = font.settings,
  axis.text = font.settings,
  par.sub=font.settings)

plotN - xyplot(mean ~ Week | Station*fyear,
col=black,
pch=1,
cex=1.1,
lty=1,
strip = strip.custom(bg = 'white', style=1), # why can I not 
use fontfamily=serif here ???
key=list(text=list(c(),
   col=c(black)),
 points=list(pch=1, lty=1, cex=1.5,
 col=c(black)),
 columns=1, border=F,
 x = 0.02, y = 0.55, corner = c(2, 2),
 title=, cex.title=1.3),
ylab = (Nc),
xlab=Week,
data= SummNdata,type=o,
par.settings = my.theme)


plotP - xyplot(mean ~ Week | Station*fyear,
col=black,
pch=2,
cex=1.1,
lty=2,
strip = strip.custom(bg = 'white', style=1),
key=list(text=list(c(),
   col=c(black)),
 points=list(pch=1, lty=1, cex=1.5,
 col=c(black)),
 columns=1, border=F,
 x = 0.2, y = 0.2, corner = c(2, 2),
 title=, cex.title=1.3),
ylab = (Pc),
xlab=Week,
data= SummPdata,type=o,
par.settings = my.theme)

tiff(file=myplot.tiff, bg=white, res=800,
 width=13.3, height=9.45, units=cm,  pointsize=6,
 compression = lzw)
doubleYScale(plotN, plotP, add.ylab2 = TRUE)
dev.off()


this works:
tiff(file=myplot8.tiff, bg=white, res=800,
 width=13.3, height=9.45, units=cm,  pointsize=6,
 compression = lzw)
plot(1:100)
dev.off()

Anna Zakrisson Braeunlich
PhD student

Department of Ecology, Environment and Plant Sciences
Stockholm University
Svante Arrheniusv. 21A
SE-106 91 Stockholm
Sweden/Sverige

Lives in Berlin.
For paper mail:
Katzbachstr. 21
D-10965, Berlin - Kreuzberg
Germany/Deutschland

E-mail: anna.zakris...@su.se
Tel work: +49-(0)3091541281
Mobile: +49-(0)15777374888
LinkedIn: http://se.linkedin.com/pub/anna-zakrisson-braeunlich/33/5a2/51b

º`•. . • `•. .• `•. . º`•. . • `•. .• `•. .º`•. . • `•. .• 
`•. .º

[[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] Compare two subsequent rows based on specific values of a string

2013-09-20 Thread arun
Hi,
May be this helps:
dat1- read.table(text=x1    x2    x3   x4  
1 xz   ab    cd    ef
2 ab   fz    cd    ef
3 ab   cd   dy    dx,sep=,header=TRUE,stringsAsFactors=FALSE)
dat1$changes_to_row_above- sapply(seq_len(nrow(dat1)),function(i) 
{x1-dat1[,i]%in% dat1[,i-1];if(any(x1)) sum(x1,na.rm=TRUE) else NA})
 dat1
#  x1 x2 x3 x4 changes_to_row_above
#1 xz ab cd ef   NA
#2 ab fz cd ef    1
#3 ab cd dy dx    2

A.K.



Dear all, 

I would like to compare two rows and check whether something 
changed. The only thing is, it is not always the same column that needs 
to be compared. It is rather a matrix of values. The outcome would be a 
number of changes in these, for instance: of row 2, there are 3 exactly
 same values in row 3. I will make up an example: 

      x1    x2    x3   x4   changes_to_row_above 
1     xz   ab    cd    ef   NA 
2     ab   fz    cd    ef   1 
3     ab   cd   dy    dx   2 
and so forth... 

Do you think that would be possible? Is there an easy function 
to do so? It would be great help guys, thanks a lot in advance, sorry 
for my bad data manipulation knowledge... 

Tobi

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Comparing two GAMs using anova (mgcv)

2013-09-20 Thread Lucas Holland
Hey all,

I've fitted two GAMs to some data using mgcv. The only difference between the 
two models is that one includes an additional smooth term (the smooth terms are 
s(x), s(y) and s(log(y)), the difference being that one model contains s(y) as 
additional term whereas the other one only contains s(x) and s(log(y)) - x and 
y being my explanatory variables). 

I'm now trying to decide between those two models. There's no difference in 
deviance explained or R^2 and the diagnostic plots returned by gam.check() look 
fairly similar although the one of the fuller model looks slightly more 
satisfactory as far as the histogram of the residuals is concerned. 

I'm wondering whether it is appropriate to conduct an approximate F test using 
the anova function. I'm not 100% clear I've understood the documentation on 
that completely. Is it appropriate to conduct such a test if the only 
difference between models is the inclusion/exclusion of a smooth term? 

Conducting the test, I get the result that there's no reason to reject the null 
hypothesis that the simpler model (without s(y)) is correct. 

Thanks!

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


Re: [R] time zones from longitude, latitude, and date

2013-09-20 Thread Jeff Newmiller
If you make no further assumptions then this question is not solvable. For 
example we use standard time in our data collection systems even though legal 
time here applies daylight savings offset in the summer. In some cases I have 
seen data collected from sites in multiple time zones recorded in one data base 
with a single time zone.
Even if you do assume local legal time applies in all cases, the boundaries of 
the time zones have changed over time. There exist time zone maps (e.g. 
http://efele.net/maps/tz/world/) that you could assume apply but I am not aware 
of any in CRAN. Someone on r-sig-geo might be able to help.
---
Jeff NewmillerThe .   .  Go Live...
DCN:jdnew...@dcn.davis.ca.usBasics: ##.#.   ##.#.  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.

carlisle thacker carlisle.thac...@gmail.com wrote:
I have data that provide longitude, latitude, and local date and time
but
no information about the corresponding time zone.  How to identify the
time
zone so they can be converted to a common date/time?

Thanks,

Carlisle

   [[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] Is there a way to change x and y axis tick mark inside plot()?

2013-09-20 Thread Marc Schwartz

On Sep 20, 2013, at 11:17 AM, Duncan Murdoch murdoch.dun...@gmail.com wrote:

 On 20/09/2013 11:52 AM, C W wrote:
 Dear R community,
 I am having trouble changing the tick marks on y-axis to every 5 units?  I
 have the following:
 
 x - c(12, 16, 6, 23, 27, 8, 5, 19, 23, 13, 16, 8)
 
 y - c(29, 29, 23, 34, 38, 24, 22, 34, 36, 27, 33, 27)
 
 plot(x, y, pch=19)
 
 Should I change ylim=c(0,40), and then use axis()?
 
 Don't use ylim, use yaxt=n, then use axis().
 
 I kept on thinking I can do everything inside plot(), but there is actually
 axis(), par(), ..., and so on.
 Could someone tell me why is there so many functions outside plot().  I'm
 sure there is a reason, but I don't seem to understand why.
 


 R is designed to be flexible.  If you create giant functions that can do 
 everything, you end up with a design like SAS, which is extremely inflexible. 
  It's good at what it can do, but it's very hard to get it to do something 
 the designers didn't think of.
 
 Duncan Murdoch


Fortune candidate, with cc: to Z.

Regards,

Marc Schwartz

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Compare two subsequent rows based on specific values of a string

2013-09-20 Thread Michel
Thanks I'm lookin for yur example

-Message d'origine-
De : r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] De
la part de arun
Envoyé : vendredi 20 septembre 2013 18:11
À : R help
Objet : Re: [R] Compare two subsequent rows based on specific values of a
string

Hi,
May be this helps:
dat1- read.table(text=x1    x2    x3   x4
1 xz   ab    cd    ef
2 ab   fz    cd    ef
3 ab   cd   dy    dx,sep=,header=TRUE,stringsAsFactors=FALSE)
dat1$changes_to_row_above- sapply(seq_len(nrow(dat1)),function(i)
{x1-dat1[,i]%in% dat1[,i-1];if(any(x1)) sum(x1,na.rm=TRUE) else NA})
 dat1
#  x1 x2 x3 x4 changes_to_row_above
#1 xz ab cd ef   NA
#2 ab fz cd ef    1
#3 ab cd dy dx    2

A.K.



Dear all, 

I would like to compare two rows and check whether something changed. The
only thing is, it is not always the same column that needs to be compared.
It is rather a matrix of values. The outcome would be a number of changes in
these, for instance: of row 2, there are 3 exactly  same values in row 3.
I will make up an example: 

      x1    x2    x3   x4   changes_to_row_above
1     xz   ab    cd    ef   NA
2     ab   fz    cd    ef   1
3     ab   cd   dy    dx   2
and so forth... 

Do you think that would be possible? Is there an easy function to do so? It
would be great help guys, thanks a lot in advance, sorry for my bad data
manipulation knowledge... 

Tobi

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] SPATIO-TEMPORAL ANALYSIS AND BIG DATA PROCESSING USING FREE AND OPEN SOURCE SW

2013-09-20 Thread Giuseppe Amatulli
HI,
we are pleased to announce   2 weeks intensive training in:

*SPATIO-TEMPORAL ANALYSIS AND BIG DATA PROCESSING USING FREE AND OPEN
SOURCE SOFTWARE*
16-20 December 2013  20-24 January 2014
University of Twente - Enschede - The Netherlands

4 ECTS

Over the few decades there has been an explosion of available data for
environmental spatio-temporal research. This “big data” allows us to
address a number of old and new important questions with unprecedented
rigor and generality. Leveraging these new data streams requires new tools
and increasingly complex workflows. This 2-week course introduces a set of
free and open source software (GRASS, R, Python, AWK, BASH, GDAL) tools to
perform spatio-temporal analysis and modelling of environmental data under
Linux environment. It consists of a set of lectures and practical sessions
where participants use this software packages to perform typical Geographic
Information System (GIS) and Remote Sensing (RS) data analysis tasks. In
this course, attention is paid to the use of command line rather than the
graphical user interface. Yet no programming experience is required to
register for this course as basic principles are introduced.

More info:
 Objectives and program of the course
http://www.spatial-ecology.net/ost4sem_dokuwiki/doku.php?id=wiki:enschede2013
 Registration
 http://www.sense.nl/?module=coursesfunc=displayplannedplanningid=1332

  **Please forward to  interested persons.

Best Regards
*
Staff*

Dr. Raul Zurita-Milla (University of Twente, NL)
Dr. Giuseppe Amatulli (Yale University, USA)
Dr. Stefano Casalegno (University of Exeter, UK)
Dr. Pieter Kempeneers (VITO, BE)


-- 
Giuseppe Amatulli
Web: www.spatial-ecology.net

[[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] time zones from longitude, latitude, and date

2013-09-20 Thread David Winsemius


On Sep 20, 2013, at 8:02 AM, carlisle thacker wrote:

I have data that provide longitude, latitude, and local date and  
time but
no information about the corresponding time zone.  How to identify  
the time

zone so they can be converted to a common date/time?


Perhaps as an approximation you could divide the longitude by 360/24,  
truncate and subtract to get an estimated GMT. It really depends on  
your purposes, the encoding of local time, need for accuracy, and  
perhaps further details regarding the data collection methods, none of  
which you have provided.


--

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] saving as TIFF - problem with compression

2013-09-20 Thread Ranjan Maitra
Hi,

Are you using Linux? If so, you may use ImageMagick and try your luck
using 

convert filename.whatever.format filename.tiff 

There are lots of options in ImageMagick. (Read the manual.)

I have done this in the past, and it has worked. However, your exact
situation may be different, so sorry if this information is not
particularly helpful.

Ranjan

On Fri, 20 Sep 2013 10:55:03 + Anna Zakrisson Braeunlich
anna.zakris...@su.se wrote:

 Hi,
 
 I am struggling to save my figures as TIFF files (yes, the yournal only 
 accept TIFF and not any other format).
 I can manage to save a simple plot as TIFF at the correct dpi (I need at 
 least 600dpi) and compression works. Only not for my own plot. Everything 
 looks distorted. I have read Stack Overflow and tried to change the point 
 size to 6, but with no apparent effect. Why is this and what would be the 
 solution? The TIFF-stuff is in the end of the script.
 thank you for your time!
 
 Ndata - data.frame(
   Ncellpercent = rnorm(400, mean = rep(c(14, 18, 65), each = 40),
sd = rep(c(1, 3, 6), each = 40)),
   fyear = rep(c('2007', '2008'), each = 100*2),
   Station = sample(c('B1', 'H2', 'H3', 'H4'), 400, replace = TRUE),
   Week = sample(c('19', '21', '23', '25'), 400, replace = TRUE))
 
 Pdata - data.frame(
   Ppercentcell = rnorm(400, mean = rep(c(4, 17, 22), each = 40),
sd = rep(c(0.1, 0.2, 0.4), each = 40)),
   fyear = rep(c('2007', '2008'), each = 100*2),
   Station = sample(c('B1', 'H2', 'H3', 'H4'), 400, replace = TRUE),
   Week = sample(c('19', '21', '23', '25'), 400, replace = TRUE))
 
 SummNdata - ddply(Ndata, .(Week, fyear, Station), summarise,
mean = mean(Ncellpercent),
sd = sd(Ncellpercent))
 names(Pdata)
 SummPdata - ddply(Pdata, .(Week, fyear, Station), summarise,
mean = mean(Ppercentcell),
sd = sd(Ppercentcell))
 SummPdata
 library(lattice)
 library(latticeExtra)
 library(HH)
 
 font.settings - list( font = 1, cex = 1.2, fontfamily = serif)
 
 my.theme - list(
   par.xlab.text = font.settings,
   par.ylab.text = font.settings,
   axis.text = font.settings,
   par.sub=font.settings)
 
 plotN - xyplot(mean ~ Week | Station*fyear,
 col=black,
 pch=1,
 cex=1.1,
 lty=1,
 strip = strip.custom(bg = 'white', style=1), # why can I not 
 use fontfamily=serif here ???
 key=list(text=list(c(),
col=c(black)),
  points=list(pch=1, lty=1, cex=1.5,
  col=c(black)),
  columns=1, border=F,
  x = 0.02, y = 0.55, corner = c(2, 2),
  title=, cex.title=1.3),
 ylab = (Nc),
 xlab=Week,
 data= SummNdata,type=o,
 par.settings = my.theme)
 
 
 plotP - xyplot(mean ~ Week | Station*fyear,
 col=black,
 pch=2,
 cex=1.1,
 lty=2,
 strip = strip.custom(bg = 'white', style=1),
 key=list(text=list(c(),
col=c(black)),
  points=list(pch=1, lty=1, cex=1.5,
  col=c(black)),
  columns=1, border=F,
  x = 0.2, y = 0.2, corner = c(2, 2),
  title=, cex.title=1.3),
 ylab = (Pc),
 xlab=Week,
 data= SummPdata,type=o,
 par.settings = my.theme)
 
 tiff(file=myplot.tiff, bg=white, res=800,
  width=13.3, height=9.45, units=cm,  pointsize=6,
  compression = lzw)
 doubleYScale(plotN, plotP, add.ylab2 = TRUE)
 dev.off()
 
 
 this works:
 tiff(file=myplot8.tiff, bg=white, res=800,
  width=13.3, height=9.45, units=cm,  pointsize=6,
  compression = lzw)
 plot(1:100)
 dev.off()
 
 Anna Zakrisson Braeunlich
 PhD student
 
 Department of Ecology, Environment and Plant Sciences
 Stockholm University
 Svante Arrheniusv. 21A
 SE-106 91 Stockholm
 Sweden/Sverige
 
 Lives in Berlin.
 For paper mail:
 Katzbachstr. 21
 D-10965, Berlin - Kreuzberg
 Germany/Deutschland
 
 E-mail: anna.zakris...@su.se
 Tel work: +49-(0)3091541281
 Mobile: +49-(0)15777374888
 LinkedIn: http://se.linkedin.com/pub/anna-zakrisson-braeunlich/33/5a2/51b
 
 _`_. . _ `_. ._ `_. . _`_. . _ `_. ._ `_. ._`_. . _ `_. 
 ._ `_. ._
 
   [[alternative HTML version deleted]]
 


-- 
Important Notice: This mailbox is ignored: e-mails are set to be
deleted on receipt. Please respond to the mailing list if appropriate.
For those needing to send personal or professional e-mail, please use
appropriate addresses.


FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!


Re: [R] Is there a way to change x and y axis tick mark inside plot()?

2013-09-20 Thread C W
Thanks Duncan.  I have no knowledge of SAS, though many in industry use it.
 I hope R would expand its usage to more at the industry level.
Mike


On Fri, Sep 20, 2013 at 12:17 PM, Duncan Murdoch
murdoch.dun...@gmail.comwrote:

 On 20/09/2013 11:52 AM, C W wrote:

 Dear R community,
 I am having trouble changing the tick marks on y-axis to every 5 units?  I
 have the following:

 x - c(12, 16, 6, 23, 27, 8, 5, 19, 23, 13, 16, 8)

 y - c(29, 29, 23, 34, 38, 24, 22, 34, 36, 27, 33, 27)

 plot(x, y, pch=19)

 Should I change ylim=c(0,40), and then use axis()?


 Don't use ylim, use yaxt=n, then use axis().


 I kept on thinking I can do everything inside plot(), but there is
 actually
 axis(), par(), ..., and so on.
 Could someone tell me why is there so many functions outside plot().  I'm
 sure there is a reason, but I don't seem to understand why.


 R is designed to be flexible.  If you create giant functions that can do
 everything, you end up with a design like SAS, which is extremely
 inflexible.  It's good at what it can do, but it's very hard to get it to
 do something the designers didn't think of.

 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.


[R] search species with all absence in a presence-absence matrix

2013-09-20 Thread Elaine Kuo
Dear list



I have a matrix composed of islandID as rows and speciesID as columns.

IslandID: Island A, B, C….O (15 islands in total)

SpeciesID: D0001, D0002, D0003….D0100 (100 species in total)



The cell of the matrix describes presence (1) or absence (0) of the species
in an island.



Now I would like to search the species with absence (0)

in all the islands (Island A to Island O.)



Please kindly advise the R code for the search purpose.

Thank you.



Elaine

[[alternative HTML version deleted]]

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


Re: [R] search species with all absence in a presence-absence matrix

2013-09-20 Thread John Kane
Once you learn to use dput() I am sure someone will be happy to help you.

 
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

John Kane
Kingston ON Canada


 -Original Message-
 From: elaine.kuo...@gmail.com
 Sent: Sat, 21 Sep 2013 07:14:38 +0800
 To: r-help@r-project.org
 Subject: [R] search species with all absence in a presence-absence matrix
 
 Dear list
 
 
 
 I have a matrix composed of islandID as rows and speciesID as columns.
 
 IslandID: Island A, B, C?.O (15 islands in total)
 
 SpeciesID: D0001, D0002, D0003?.D0100 (100 species in total)
 
 
 
 The cell of the matrix describes presence (1) or absence (0) of the
 species
 in an island.
 
 
 
 Now I would like to search the species with absence (0)
 
 in all the islands (Island A to Island O.)
 
 
 
 Please kindly advise the R code for the search purpose.
 
 Thank you.
 
 
 
 Elaine
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!

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


Re: [R] Renaming variables

2013-09-20 Thread John Kane
Depending on what your doing perhaps with()  could help?
Or assuming a data.frame or matrix, score[ , 25] will give you Score$X25

If you would supply a bit more information (and code) about what you are doing 
we probably can help more.

John Kane
Kingston ON Canada


 -Original Message-
 From: lordpree...@gmail.com
 Sent: Fri, 20 Sep 2013 19:40:23 +0530
 To: r-help@r-project.org
 Subject: [R] Renaming variables
 
 Hi,
 
 I guess this is pretty basic.
 
 I have 25 variables in the data file (name: score), i.e. X1,X2,.,X25.
 
 I dont want to use score$X1, score$X2 everytime I use these variables.
 
 Is there a way I can rename all these variables as simply X1,X2,.X25
  without writing 25 lines of code, one line for renaming each variable
 (eg:
   X1=score.X1  X2=score.X2  and so on) ?
 
 Thanks for your help.
 
 Regards,
 Preetam
 
 --
 Preetam Pal
 (+91)-9432212774
 M-Stat 2nd Year, Room No.
 N-114
 Statistics Division,   C.V.Raman
 Hall
 Indian Statistical Institute, B.H.O.S.
 Kolkata.
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


Receive Notifications of Incoming Messages
Easily monitor multiple email accounts  access them with a click.
Visit http://www.inbox.com/notifier and check it out!

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] search species with all absence in a presence-absence matrix

2013-09-20 Thread arun
Hi,
Try this:

 set.seed(248)
 lst1- lapply(1:1000,function(i) matrix( 
sample(0:1,15*100,replace=TRUE),ncol=100,dimnames=list(paste(Island,LETTERS[1:15]),
  paste0(D,sprintf(%04d,1:100)
 lst2-lst1[sapply(lst1,function(x) any(colSums(x)==0))]
##The above steps are just to create some matrices with zeros in all the 
islands
mat1-lst2[[1]]
 mat1[,colSums(mat1)==0,drop=FALSE]
# D0038
#Island A 0
#Island B 0
#Island C 0
#Island D 0
#Island E 0
#Island F 0
#Island G 0
#Island H 0
#Island I 0
#Island J 0
#Island K 0
#Island L 0
#Island M 0
#Island N 0
#Island O 0
colnames(mat1)[colSums(mat1)==0]
#[1] D0038
 mat2-lst2[[3]]
 colnames(mat2)[colSums(mat2)==0]
#[1] D0086

A.K.




- Original Message -
From: Elaine Kuo elaine.kuo...@gmail.com
To: r-help@r-project.org r-help@r-project.org
Cc: 
Sent: Friday, September 20, 2013 7:14 PM
Subject: [R] search species with all absence in a presence-absence matrix

Dear list



I have a matrix composed of islandID as rows and speciesID as columns.

IslandID: Island A, B, C….O (15 islands in total)

SpeciesID: D0001, D0002, D0003….D0100 (100 species in total)



The cell of the matrix describes presence (1) or absence (0) of the species
in an island.



Now I would like to search the species with absence (0)

in all the islands (Island A to Island O.)



Please kindly advise the R code for the search purpose.

Thank you.



Elaine

    [[alternative HTML version deleted]]

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


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Grouping variables by a irregular time interval

2013-09-20 Thread Raoni Rodrigues
Hello all,

I´m have a very large data frame (more than 5 million lines) as below (dput
example at the end of mail):

Station Antenna TagDateTime Power Events
1   1   2 999 22/07/2013 11:00:2117  1
2   1   2 999 22/07/2013 11:33:4731  1
3   1   2 999 22/07/2013 11:34:0019  1
4   1   2 999 22/07/2013 11:34:1653  1
5   1   2 999 22/07/2013 11:43:2015  1
6   1   2 999 22/07/2013 11:43:3517  1

To each Tag, in each Antenna, in each Station, I need to create a 10 min
interval and sum the number of Events and mean of Power in the time
interval, as below (complete wanted output at the end of mail).

Station Antenna Tag   StartDateTime EndDateTime Power Events
1   1   2 999 22/07/2013 11:00:21 22/07/2013 11:00:2117  1
2   1   2 999 22/07/2013 11:34:16 22/07/2013 11:43:3527  5
3   1   2 999 22/07/2013 11:44:35 22/07/2013 11:45:4017 14
4   2   1   1 25/07/2013 14:19:45 25/07/2013 14:20:3965  4
5   2   1   2 25/07/2013 14:20:13 25/07/2013 14:25:1421  3
6   2   1   4 25/07/2013 14:20:46 25/07/2013 14:20:4628  1

Show start and end points of each interval is optional, not necessary. I
put both to show the irregular time interval (look at tag 999)

First I tried a for-loop, without success. After that, I tried this code:

require (plyr)

ddply (data, .(Station, Antenna, Tag, cut(data$DateTime, 10 min)),
summarise, Power = round (mean(Power), 0), Events = sum (Events))

Is almost what I want, because cut() divided in regular time intervals, but
in some cases I do not have this, and it split a unique observation in two.

Any ideas to solve this issue?

R version 3.0.1 (2013-05-16) -- Good Sport
Platform: x86_64-w64-mingw32/x64 (64-bit)
Windows 7 Professional

Thanks in advanced,

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


##complete data dput

structure(list(Station = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), Antenna = c(2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L), Tag = c(999L, 999L, 999L, 999L, 999L, 999L,
999L, 999L, 999L, 999L, 999L, 999L, 999L, 999L, 999L, 999L, 999L,
999L, 999L, 999L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 4L, 18L, 18L, 18L,
21L, 22L, 36L, 36L, 36L, 36L, 36L, 48L, 48L, 48L, 48L, 48L, 48L,
48L, 48L, 48L, 48L, 48L, 48L, 48L, 48L, 48L, 48L, 48L, 48L, 48L,
48L, 48L, 48L, 48L, 48L, 48L, 48L, 48L, 48L, 48L, 48L, 48L, 48L,
48L, 48L, 48L, 48L, 48L, 48L, 48L, 48L, 48L, 48L, 48L, 48L, 48L,
48L, 48L, 48L, 48L, 48L, 48L, 48L, 48L, 48L, 48L, 48L, 48L, 48L,
48L, 48L, 48L, 48L, 48L, 48L, 48L, 48L, 48L, 48L, 48L, 48L, 48L,
48L, 48L, 48L, 48L, 48L, 48L, 48L, 48L, 48L), DateTime = structure(c(3L,
4L, 5L, 5L, 6L, 6L, 7L, 7L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L, 8L,
8L, 8L, 8L, 18L, 19L, 19L, 19L, 19L, 20L, 23L, 19L, 17L, 17L,
17L, 23L, 18L, 1L, 1L, 1L, 2L, 2L, 9L, 9L, 10L, 10L, 10L, 10L,
10L, 11L, 11L, 11L, 11L, 11L, 11L, 12L, 12L, 12L, 12L, 13L, 13L,
13L, 13L, 14L, 14L, 14L, 14L, 14L, 14L, 15L, 15L, 15L, 15L, 15L,
15L, 15L, 16L, 16L, 16L, 16L, 18L, 19L, 21L, 21L, 21L, 21L, 21L,
22L, 22L, 22L, 22L, 22L, 23L, 24L, 24L, 24L, 24L, 24L, 24L, 25L,
25L, 25L, 25L, 25L, 26L, 26L, 26L, 26L, 26L, 26L, 26L, 27L, 27L,
27L, 27L, 27L, 27L, 28L, 28L, 28L, 28L, 28L), .Label = c(19/06/2013
22:15,
19/06/2013 22:16, 22/07/2013 11:00, 22/07/2013 11:33, 22/07/2013
11:34,
22/07/2013 11:43, 22/07/2013 11:44, 22/07/2013 11:45, 25/07/2013
14:10,
25/07/2013 14:11, 25/07/2013 14:12, 25/07/2013 14:13, 25/07/2013
14:14,
25/07/2013 14:15, 25/07/2013 14:16, 25/07/2013 14:17, 25/07/2013
14:18,
25/07/2013 14:19, 25/07/2013 14:20, 25/07/2013 14:21, 25/07/2013
14:23,
25/07/2013 14:24, 25/07/2013 14:25, 25/07/2013 14:26, 25/07/2013
14:27,
25/07/2013 14:28, 25/07/2013 14:29, 25/07/2013 14:30), class =
factor),
Power = c(17L, 31L, 19L, 53L, 15L, 17L, 21L, 12L, 15L, 22L,
19L, 15L, 13L, 14L, 15L, 12L, 23L, 19L, 16L, 20L, 30L, 37L,
25L, 167L, 24L, 14L,