Re: [R] how to get output from a nested loop

2009-06-10 Thread Linlin Yan
How about like this:
 t1 - data.frame(row.names=c('c1','c2','c3','c4'), mk1=c(1,1,0,0), 
 mk2=c(0,0,0,1), mk3=c(1,1,1,1), mk4=c(0,0,0,0), mk5=c(0,0,0,1), S=c(4,5,3,2))
 t1
   mk1 mk2 mk3 mk4 mk5 S
c1   1   0   1   0   0 4
c2   1   0   1   0   0 5
c3   0   0   1   0   0 3
c4   0   1   1   0   1 2
 apply(combn(1:5, 2), 2, function(x) t1[,c(x[1], 6, x[2])])
[[1]]
   mk1 S mk2
c1   1 4   0
c2   1 5   0
c3   0 3   0
c4   0 2   1
... ...

On Wed, Jun 10, 2009 at 1:10 PM, Scott Hermannsherm...@bses.org.au wrote:
 Dear all,

 I imagine that this is a trival question, but it has perplexed for most of 
 the day.  Any help would be greatly appreciated.

 Below is an example of what I'm trying to do.

 Essentially I want to produce all unique 1 x 1 combinations of certain 
 columns from a dataframe, and join these to other columns from the same 
 dataframe.  I'm having problems with the nested loop as I can only output 
 data from the last cycle of the loop.  I realise that the problem is with 
 the st1[[i]] but I'm not sure how to define it differently.

 ##I want to make a list file of all 1x1 combinations of mk columns, and add 
 clone and S to these combinations.

 clone-c(c1,c2,c3,c4)
 mk1-c(1,1,0,0)
 mk2-c(0,0,0,1)
 mk3-c(1,1,1,1)
 mk4-c(0,0,0,0)
 mk5-c(0,0,0,1)
 S-c(4,5,3,2)
 t1-as.data.frame(cbind(clone,mk1,mk2,mk3,mk4, mk5,S))
 row.names(t1)-t1$clone
 t1-t1[,-1]
 t1

 ###A nested loop.  I'm trying to get all combinations of columns 1:5 and join 
 each of them with column 7.

 st1 - list()
  for(i in 1:4) {
   for(j in (i+1):5){
       st1[[i]] - cbind(t1[,c(i,6)],t1[,j])
       }
       }
  st1

 Thanks for your help,

 Scott
 BSES Limited Disclaimer

 

 This email and any files transmitted with it are confide...{{dropped:13}}

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] R CMD check does not find a mistake

2009-06-10 Thread Martin Maechler
 CG == Christophe Genolini cgeno...@u-paris10.fr
 on Tue, 09 Jun 2009 16:17:15 +0200 writes:

CG Hi the list, I build a package. They was a mistake in
CG it, but R CMD check did not find it. Is that normal ?

CG Here is what Kurt gets (which is right, I did this
CG mistake):

CG --- 8 
CG * checking for code/documentation mismatches ... WARNING
CG S4 class codoc mismatches from documentation object 'LongData-class':
CG Slots for class 'LongData'
CG Code: id other time traj varName
CG Docs: id time traj varName
CG --- 8 

Others have already hinted at the solution:

The problem only shows in  R-devel (2.10.x).

Note that I had sent an explicit message to this list
*exactly* in order to advise all package authors :

 Subject: [Rd] R-devel:codocClasses() now finds more -- R CMD check warnings
 Date: Wed, 3 Jun 2009 11:45:45 +0200

i.e. only 6 days before you saw the problem

yes, I am sometimes too optimistic, assuming that people
actually read what I write 

Regards anyway!
Martin

--
Martin Maechler, ETH Zurich

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Asking for help while using Simplex to solve LP Problem.

2009-06-10 Thread Ren, Shubin
Hello. I am a new user and want to use R to solve Linear Programming problem. I 
met a problem while using function Simplex and I would kindly ask whether 
someone could help to figure it out.

In my problem, there are 47 parameters and all limited to (0,1). M file has 147 
lines and P file has 100 line. Each line in M indicated following inequality: 
V1=V2*X1+V3*X2+V4*X3+...+V48*X47, where the top 47 lines 1=Xi (i=1 to 47) . 
Each line in P indicated inequality: V1=V2*X1+V3*X2+V4*X3+...+V48*X47
The object function is (1,0,0...0) as I want to know the range of first 
parameter.
So I wrote statements as following:

enj-c(1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)
P-as.matrix(read.table(P,header=FALSE,sep=\t));
M-as.matrix(read.table(M,header=FALSE,sep=\t));
simplex(a=enj,A1=M[,2:48],b1=t(M[,1]),A2=P[,2:48],b2=t(P[,1]),maxi=TRUE)

Then I got the error message:
Error in while (!all(obfun  -eps)  (it = n.iter)) { :
  missing value where TRUE/FALSE needed

Is anybody knows how to fix the error? Thank you.

Cheers.
Shubin Ren

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] graphically representing frequency of words in a speech?

2009-06-10 Thread Yihui Xie
Hi,

As Gregor Gorjanc mentioned, it's very inconvenient to let R decide
the fontsize and placement of words in a plot. There have already been
very mature applications of tag cloud; one of them I'm relatively
familiar is the WordPress plugin wp-cumulus, which makes use of a
Flash object to generate tag cloud, and it has fantastic 3D rotation
effect of the cloud. I've spent a couple of hours porting it into R;
see the source code and effect here:

http://yihui.name/en/2009/06/creating-tag-cloud-using-r-and-flash-javascript-swfobject/

HTH.

Regards,
Yihui
--
Yihui Xie xieyi...@gmail.com
Phone: +86-(0)10-82509086 Fax: +86-(0)10-82509086
Mobile: +86-15810805877
Homepage: http://www.yihui.name
School of Statistics, Room 1037, Mingde Main Building,
Renmin University of China, Beijing, 100872, China



On Mon, Jun 8, 2009 at 2:41 AM, Brown, Tony
Nicholastony.n.br...@vanderbilt.edu wrote:
 Dear all,



 I recently saw a graph on television that displayed selected
 words/phrases in a speech scaled in size according to their frequency.
 So words/phrases that were often used appeared large and words that were
 rarely used appeared small. The closest thing I can find on the web to
 approximate what I saw can be found here:
 http://stateoftheunion.onetwothree.net/ The example at that website is
 more complicated but captures the general idea.



 Would someone point me in the right direction in terms of replicating
 such a graph.



 Thanks in advance,

 Tony



 
 -

 Tony N. Brown, Ph.D.

 Editor-Elect, American Sociological Review

 Associate Professor of Sociology and Human and Organizational
 Development (secondary)

 Program Faculty, Effective Health Communication and African American 
 Diaspora Studies

 Faculty Head of Hank Ingram House, The Commons

 Vanderbilt University

 (615) 322-7518

 (615) 322-7505 fax




        [[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] Unable to load package:lme4 [ Ubuntu 9.04 ]

2009-06-10 Thread Martin Maechler
 GAR == Girish A R garam...@gmail.com
 on Tue, 9 Jun 2009 22:00:01 -0700 (PDT) writes:

GAR Hi folks,
GAR When I try to load package 'lme4' on my Linux box (64-bit Ubuntu
GAR 9.04), I get the following error:

GAR -
 library(lme4)
GAR Error in dyn.load(file, DLLpath = DLLpath, ...) :
GAR function 'cholmod_start' not provided by package 'Matrix'
GAR Error: package/namespace load failed for 'lme4'
GAR 

GAR I removed and re-installed both 'Matrix' and 'lme4', but that doesn't
GAR seem to solve the problem. If this is something for the [R-sig-ME]
GAR mailing list, please let me know.

How did you re-install Matrix?
Your version   Matrix_0.999375-17  (indicated below)
is a bit old, and indeed probably too old for the version of
lme4 you've tried.
Can you call
packageDescription(lme4)
without an error {probably not}, or at least

library(help = lme4)

the output of these would show you the version of Matrix you
need at least.

Ideally you'd upgrade your version of R (to 2.9.0) as well,
since the latest couple of versions of Matrix all have 
R = 2.9.0 in their dependency requirements.

Regards,
Martin Maechler

GAR Thanks,

GAR -Girish

GAR 
 sessionInfo()
GAR R version 2.8.1 (2008-12-22)
GAR x86_64-pc-linux-gnu

GAR locale:
GAR 
LC_CTYPE=en_IN;LC_NUMERIC=C;LC_TIME=en_IN;LC_COLLATE=en_IN;LC_MONETARY=C;LC_MESSAGES=en_IN;LC_PAPER=en_IN;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_IN;LC_IDENTIFICATION=C

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

GAR other attached packages:
GAR [1] Matrix_0.999375-17 lattice_0.17-25Design_2.2-0
GAR survival_2.35-4
GAR [5] Hmisc_3.6-0nlme_3.1-92car_1.2-14
GAR MASS_7.2-47

GAR loaded via a namespace (and not attached):
GAR [1] cluster_1.12.0 grid_2.8.1 tools_2.8.1

GAR __
GAR R-help@r-project.org mailing list
GAR https://stat.ethz.ch/mailman/listinfo/r-help
GAR PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
GAR 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] graphically representing frequency of words in a speech?

2009-06-10 Thread Ronggui Huang
There is a similar discussion in statalist
(http://n2.nabble.com/st%3A-Tag-clouds-in-Stata--tt2992551.html#none),
I think they make a reasonable argument that tag cloud is not a good
statistical graphic.


2009/6/10 Yihui Xie xieyi...@gmail.com:
 Hi,

 As Gregor Gorjanc mentioned, it's very inconvenient to let R decide
 the fontsize and placement of words in a plot. There have already been
 very mature applications of tag cloud; one of them I'm relatively
 familiar is the WordPress plugin wp-cumulus, which makes use of a
 Flash object to generate tag cloud, and it has fantastic 3D rotation
 effect of the cloud. I've spent a couple of hours porting it into R;
 see the source code and effect here:

 http://yihui.name/en/2009/06/creating-tag-cloud-using-r-and-flash-javascript-swfobject/

 HTH.

 Regards,
 Yihui
 --
 Yihui Xie xieyi...@gmail.com
 Phone: +86-(0)10-82509086 Fax: +86-(0)10-82509086
 Mobile: +86-15810805877
 Homepage: http://www.yihui.name
 School of Statistics, Room 1037, Mingde Main Building,
 Renmin University of China, Beijing, 100872, China



 On Mon, Jun 8, 2009 at 2:41 AM, Brown, Tony
 Nicholastony.n.br...@vanderbilt.edu wrote:
 Dear all,



 I recently saw a graph on television that displayed selected
 words/phrases in a speech scaled in size according to their frequency.
 So words/phrases that were often used appeared large and words that were
 rarely used appeared small. The closest thing I can find on the web to
 approximate what I saw can be found here:
 http://stateoftheunion.onetwothree.net/ The example at that website is
 more complicated but captures the general idea.



 Would someone point me in the right direction in terms of replicating
 such a graph.



 Thanks in advance,

 Tony



 
 -

 Tony N. Brown, Ph.D.

 Editor-Elect, American Sociological Review

 Associate Professor of Sociology and Human and Organizational
 Development (secondary)

 Program Faculty, Effective Health Communication and African American 
 Diaspora Studies

 Faculty Head of Hank Ingram House, The Commons

 Vanderbilt University

 (615) 322-7518

 (615) 322-7505 fax




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




-- 
HUANG Ronggui, Wincent
PhD Candidate
Dept of Public and Social Administration
City University of Hong Kong
Home page: http://asrr.r-forge.r-project.org/rghuang.html

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Unable to load package:lme4 [ Ubuntu 9.04 ]

2009-06-10 Thread Girish A.R.
Hi Martin,

I upgraded to R 2.9.0, but still have the same problem. The error
message, output of packageDescription(lme4), and sessionInfo() are
displayed below.

Thanks,
-Girish

--
 library(lme4)
Loading required package: Matrix
Loading required package: lattice

Attaching package: 'Matrix'

The following object(s) are masked from package:stats :

 xtabs

The following object(s) are masked from package:base :

 rcond

Error in dyn.load(file, DLLpath = DLLpath, ...) :
  function 'cholmod_start' not provided by package 'Matrix'
Error: package/namespace load failed for 'lme4'



 packageDescription(lme4)
Package: lme4
Version: 0.999375-28
Date: 2008-12-13
Title: Linear mixed-effects models using S4 classes
Author: Douglas Bates ba...@stat.wisc.edu, Martin Maechler
maech...@r-project.org and Bin Dai d...@stat.wisc.edu
Maintainer: Douglas Bates ba...@stat.wisc.edu
Description: Fit linear and generalized linear mixed-effects models.
Depends: methods, R(= 2.7.0), Matrix(= 0.999375-11), lattice
LinkingTo: Matrix, stats
Imports: graphics, stats
Suggests: mlmRev, MEMSS
LazyLoad: yes
LazyData: yes
License: GPL (=2)
URL: http://lme4.r-forge.r-project.org/
Packaged: Sat Dec 13 20:07:38 2008; maechler
Built: R 2.8.0; x86_64-pc-linux-gnu; 2008-12-15 13:58:54; unix

-- File: /usr/lib/R/site-library/lme4/Meta/package.rds

 sessionInfo()
R version 2.9.0 (2009-04-17)
x86_64-pc-linux-gnu

locale:
LC_CTYPE=en_IN;LC_NUMERIC=C;LC_TIME=en_IN;LC_COLLATE=en_IN;LC_MONETARY=C;LC_MESSAGES=en_IN;LC_PAPER=en_IN;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_IN;LC_IDENTIFICATION=C

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

other attached packages:
[1] Matrix_0.999375-27 lattice_0.17-25

loaded via a namespace (and not attached):
[1] grid_2.9.0

==

On Jun 10, 1:43 pm, Martin Maechler maech...@stat.math.ethz.ch
wrote:

 How did you re-install Matrix?
 Your version   Matrix_0.999375-17  (indicated below)
 is a bit old, and indeed probably too old for the version of
 lme4 you've tried.
 Can you call
     packageDescription(lme4)
 without an error {probably not}, or at least

     library(help = lme4)

 the output of these would show you the version of Matrix you
 need at least.

 Ideally you'd upgrade your version of R (to 2.9.0) as well,
 since the latest couple of versions of Matrix all have
 R = 2.9.0 in their dependency requirements.

 Regards,
 Martin Maechler

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Unable to load package:lme4 [ Ubuntu 9.04 ]

2009-06-10 Thread Martin Maechler
 GAR == Girish A R garam...@gmail.com
 on Wed, 10 Jun 2009 02:06:57 -0700 (PDT) writes:

GAR Hi Martin,
GAR I upgraded to R 2.9.0, but still have the same problem. The error
GAR message, output of packageDescription(lme4), and sessionInfo() are
GAR displayed below.

GAR Thanks,
GAR -Girish

GAR --
 library(lme4)
GAR Loading required package: Matrix
GAR Loading required package: lattice

GAR Attaching package: 'Matrix'

GAR The following object(s) are masked from package:stats :

GAR xtabs

GAR The following object(s) are masked from package:base :

GAR rcond

GAR Error in dyn.load(file, DLLpath = DLLpath, ...) :
GAR function 'cholmod_start' not provided by package 'Matrix'
GAR Error: package/namespace load failed for 'lme4'

GAR 

 packageDescription(lme4)
GAR Package: lme4
GAR Version: 0.999375-28
GAR Date: 2008-12-13
GAR Title: Linear mixed-effects models using S4 classes
GAR Author: Douglas Bates ba...@stat.wisc.edu, Martin Maechler
GAR maech...@r-project.org and Bin Dai d...@stat.wisc.edu
GAR Maintainer: Douglas Bates ba...@stat.wisc.edu
GAR Description: Fit linear and generalized linear mixed-effects models.
GAR Depends: methods, R(= 2.7.0), Matrix(= 0.999375-11), lattice
GAR LinkingTo: Matrix, stats
GAR Imports: graphics, stats
GAR Suggests: mlmRev, MEMSS
GAR LazyLoad: yes
GAR LazyData: yes
GAR License: GPL (=2)
GAR URL: http://lme4.r-forge.r-project.org/
GAR Packaged: Sat Dec 13 20:07:38 2008; maechler
GAR Built: R 2.8.0; x86_64-pc-linux-gnu; 2008-12-15 13:58:54; unix
 ^^

i.e. installed a while ago, and *not* reinstalled recently

Try to re-install both Matrix and then lme4 using your current R version
2.9.0.

Apart from that, yes, you are indeed using current versions of
Matrix and lme4...

Martin


GAR -- File: /usr/lib/R/site-library/lme4/Meta/package.rds
GAR 

 sessionInfo()
GAR R version 2.9.0 (2009-04-17)
GAR x86_64-pc-linux-gnu


GAR locale:
GAR 
LC_CTYPE=en_IN;LC_NUMERIC=C;LC_TIME=en_IN;LC_COLLATE=en_IN;LC_MONETARY=C;LC_MESSAGES=en_IN;LC_PAPER=en_IN;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_IN;LC_IDENTIFICATION=C

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

GAR other attached packages:
GAR [1] Matrix_0.999375-27 lattice_0.17-25

GAR loaded via a namespace (and not attached):
GAR [1] grid_2.9.0

GAR 
==

GAR On Jun 10, 1:43 pm, Martin Maechler maech...@stat.math.ethz.ch
GAR wrote:

 How did you re-install Matrix?
 Your version   Matrix_0.999375-17  (indicated below)
 is a bit old, and indeed probably too old for the version of
 lme4 you've tried.
 Can you call
     packageDescription(lme4)
 without an error {probably not}, or at least
 
     library(help = lme4)
 
 the output of these would show you the version of Matrix you
 need at least.
 
 Ideally you'd upgrade your version of R (to 2.9.0) as well,
 since the latest couple of versions of Matrix all have
 R = 2.9.0 in their dependency requirements.
 
 Regards,
 Martin Maechler

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

2009-06-10 Thread Muri Soares
Hi,

Is there a way to make the filled.contour() function produce a plot similar to 
the image() function? i.e. not have smooth contours but rather distinct 
squares corresponding to the different cells of the matrix. The reason I ask 
is because since image doesn't have an option to display colour bars it is a 
lot less useful.

Cheers

 Muri Soares
Department of Maths and Applied Maths 
University of Cape Town
South Africa



  
[[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] Unable to load package:lme4 [ Ubuntu 9.04 ]

2009-06-10 Thread Girish A.R.
Hi Martin,

Thanks for your prompt response! As suggested, I re-installed 'lme4'
and am now able to load it without any problem.

best,
-Girish

---
 packageDescription(lme4)
Package: lme4
Version: 0.999375-31
Date: 2009-05-20

Title: Linear mixed-effects models using S4 classes
Author: Douglas Bates ba...@stat.wisc.edu and Martin Maechler
maech...@r-project.org

Maintainer: Douglas Bates ba...@stat.wisc.edu
Description: Fit linear and generalized linear mixed-effects models.
Depends: methods, R(= 2.9.0), Matrix(= 0.999375-24), lattice
LinkingTo: Matrix, stats
Imports: graphics, stats
Suggests: mlmRev, MEMSS
LazyLoad: yes
LazyData: yes
License: GPL (= 2)

URL: http://lme4.r-forge.r-project.org/
Packaged: 2009-05-20 17:41:16 UTC; bates
Repository: CRAN
Date/Publication: 2009-05-24 08:36:20
Built: R 2.9.0; x86_64-pc-linux-gnu; 2009-06-10 09:26:57 UTC; unix
^

-- File: /usr/lib/R/site-library/lme4/Meta/package.rds



On Jun 10, 2:15 pm, Martin Maechler maech...@stat.math.ethz.ch
wrote:

[.part of message truncated.]

      packageDescription(lme4)
     GAR Package: lme4
     GAR Version: 0.999375-28
     GAR Date: 2008-12-13
     GAR Title: Linear mixed-effects models using S4 classes
     GAR Author: Douglas Bates ba...@stat.wisc.edu, Martin Maechler
     GAR maech...@r-project.org and Bin Dai d...@stat.wisc.edu
     GAR Maintainer: Douglas Bates ba...@stat.wisc.edu
     GAR Description: Fit linear and generalized linear mixed-effects models.
     GAR Depends: methods, R(= 2.7.0), Matrix(= 0.999375-11), lattice
     GAR LinkingTo: Matrix, stats
     GAR Imports: graphics, stats
     GAR Suggests: mlmRev, MEMSS
     GAR LazyLoad: yes
     GAR LazyData: yes
     GAR License: GPL (=2)
     GAR URL:http://lme4.r-forge.r-project.org/
     GAR Packaged: Sat Dec 13 20:07:38 2008; maechler
     GAR Built: R 2.8.0; x86_64-pc-linux-gnu; 2008-12-15 13:58:54; unix
          ^^

 i.e. installed a while ago, and *not* reinstalled recently

 Try to re-install both Matrix and then lme4 using your current R version
 2.9.0.

 Apart from that, yes, you are indeed using current versions of
 Matrix and lme4...

 Martin

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


Re: [R] Using ADF.Test

2009-06-10 Thread matifou



ehxpieterse wrote:
 
 Hi,
 
 I am quite new to R and would appreciate some guidance, if possible.
 
 I have imported a csv file: spread - read.csv(Spread.csv)
 
 I get the following error when I try to run adf.test:
 adf.test(spread,alternative = c(stationary, explosive),0)
 Error in embed(y, k) : 'x' is not a vector or matrix
 
 Why is this?
 


What does
class(spread) give?
You should try as.vector(spread) and see what happens
-- 
View this message in context: 
http://www.nabble.com/Using-ADF.Test-tp23940824p23959465.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] Problem : solving a equation with R , fail with uniroot function

2009-06-10 Thread yann lancien
Thanks for your help !
I got another problem with my function :
test - function(x,bb0=-3,bb1=5,c0=2,r0=0) {
  ((exp(c0-r0)*(bb0+x)*(bb1-x))/((bb0+x+1)*(bb1-x-1))-1)}

With this :
curve(test(x),from=-10,to=10)

we can see that there are 2 roots : one in [3,4] and one in [5,10]
 uniroot(test,c(5, 10))$root
[1] 5.243265
 uniroot(test,c(3, 4))$root
[1] 3.069772

Even this works :
 uniroot(test,c(3, 10))$root
[1] 5.243263

but it's unfortunate that :
 uniroot(test3,c(-10, 10))$root
*Erreur dans uniroot(test3, c(-10, 10)) :
  les valeurs de f() aux points extrêmes ne sont pas de signe opposé*
doesn't work, because I have to find the root for c0 in [-10,10] but I can't
change the range at each loop:

I want to do something like this, do you have any ideas ?

 for (i in -10:10) {
+ z - uniroot(test,c(-10, 10), c0=i)$root
+ print(z)}

Yann

On Wed, Jun 10, 2009 at 2:33 AM, Ben Bolker bol...@ufl.edu wrote:




 Peter Alspach wrote:
 
  Tena koe Yann
 
  It may not be the only problem, but you are missing an operator between
  (bb0+x+1) and (bb1-x-1).
 
 

 And fixing that typo and viewing the function shows that it
 is a bit problematic on this interval anyway ...  (diverges
 at x = 1, closer look shows it's pretty nasty -- I haven't stopped
 to think about its behavior very carefully, but it will clearly
 take some effort.  If you're lucky there is a typo and the
 real function is better behaved!)

 test - function(x,bb0=-3,bb1=5,c0=2,r0=0) {
   ((exp(c0-r0)*(bb0+x)*(bb1-x))/((bb0+x+1)*(bb1-x-1))-1)}


 uniroot(test,c(-100,100))$root
 curve(test(x),from=-100,to=100)
 curve(test(x),from=1.1,to=10)
 abline(h=0,col=2)
 --
 View this message in context:
 http://www.nabble.com/Problem-%3A-solving-a-equation-with-R-%2C-fail-with-uniroot-function-tp23953174p23953614.html
 Sent from the R help mailing list archive at Nabble.com.

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


[[alternative HTML version deleted]]

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


Re: [R] poly regression

2009-06-10 Thread Gabor Grothendieck
They have different coefficients because their model matrices
are different but they both lead to the same predictions:

 fitted(lm(y~1+x+I(x^2)))
  1   2   3   4   5   6   7   8   9  10
  1   4   9  16  25  36  49  64  81 100

 fitted(lm(y~poly(x,2)))
  1   2   3   4   5   6   7   8   9  10
  1   4   9  16  25  36  49  64  81 100


On Wed, Jun 10, 2009 at 1:41 AM, Ning Mapnin...@gmail.com wrote:
 hi,

 I want to do a polynomial regression of y on x of degree 2, as following

 x-1:10
 y-x^2
 lm(y~poly(x,2))

 Call:
 lm(formula = y ~ poly(x, 2))

 Coefficients:
 (Intercept)  poly(x, 2)1  poly(x, 2)2
      38.50        99.91        22.98

 Which is not what i had expected.

 If I wrote the expression in an explicit form, y~1+x+I(x^2), I could
 get the expected result:

 lm(y~1+x+I(x^2))

 Call:
 lm(formula = y ~ 1 + x + I(x^2))

 Coefficients:
 (Intercept)            x       I(x^2)
          0            0            1

 What is the diff between them?

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

2009-06-10 Thread Allan Engelhardt
Java on Fedora 8 is a little funny so my guess is that is where the 
problem is (or that you are missing the Java development (*-devel) 
packages).  I am (right now) building an Amazon image with Fedora 11 on 
x86_64 with R (and the Engineering and Scientific group) installed: 
let me know if you want me to share it once it is done even though you'd 
need a 40c/hour instance to run it.


Allan.

Saptarshi Guha wrote:

Hello,
I am using EC2 to launch several instances. On each instance, I
perform the following commands

yum -y install R (installs R-2.6)
R CMD javareconf
sleep 10
wget rpackage.tgz
R CMD INSTALL rpackage.tgz

Now, rpackage.tgz needs to be built with jni libraries. When the
instance is fully up, i log in and check if  rpackage was successfully
installed and find out it wasn't.

Running
R CMD INSTALL rpackage.tgz
again, i get the response that I should run R CMD javareconf, which I
do and then successfully install rpackage (using R CMD...)

Q: Why doesn't it work the first time? I am using a small instance and
Fedora 8 AMI

Regards
Saptarshi

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



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


Re: [R] Using ADF.Test

2009-06-10 Thread Achim Zeileis

On Wed, 10 Jun 2009, matifou wrote:


ehxpieterse wrote:


Hi,

I am quite new to R and would appreciate some guidance, if possible.

I have imported a csv file: spread - read.csv(Spread.csv)

I get the following error when I try to run adf.test:

adf.test(spread,alternative = c(stationary, explosive),0)

Error in embed(y, k) : 'x' is not a vector or matrix

Why is this?


What does class(spread) give?


data.frame, almost certainly, which is not a vector or a matrix. The 
original poster should access the relevant column, e.g. by spread[,1] or 
spread$foo etc. or (even better) turn it into a proper ts object!



You should try as.vector(spread) and see what happens


If spread is a 1-column data.frame, then that won't change anything. 
That's because is.vector(as.vector(...)) is not necessarily TRUE. Consider


  x - cars[, 1, drop=FALSE]
  is.vector(x)
  is.vector(as.vector(x))
  identical(x, as.vector(x))

Z


--
View this message in context: 
http://www.nabble.com/Using-ADF.Test-tp23940824p23959465.html
Sent from the R help mailing list archive at Nabble.com.

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




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


[R] help with package simsalabim

2009-06-10 Thread mauede
I have attached a text file representing the centralized amplitude of a signal, 
 sampled at 30Hz, whose length N = 6922
My goal is to remove the trend. I am using package simsalabim.

I ran command decompSSA  with  L = length(Amps)/5
The reason is that I have SSA/MTM toolkit running in Mac/OS.  SSA/MTM 
documentation, relative to SSA, recommends that  N/10 = L = N/5. 
Documentation of simsalabim package recommens that L=N/2

I ran the command getSignal and felt uncomfortable at picking values for 
parameters C0 and r0.
I would appreciate some suggestion/guidelines because these values seem to 
influence the trend extraction.
I chose  C0=0.0005, r0=0.0005  which are both below the Nyquist frequency 
1/Amps.dc$L = 0.0007223346

As a consequence, getSignal finds two Eigenvectors capturing the trend.
From my experience with toolkit SSA/MTM I know this output can be misleading.
I am trying to figure out whether trend has really been found by 
double-checking the print-out data:

 Amps.signal$trend
k  smoothness explainedVariance
1   10.134495414 26.254096
11 12  0.006693601  1.627475

The above print-out marks EOF_1 and EOF_12 as capturing all the trend in the 
signal.
I canNOT understand the difference between smoothness and  explainedVariance
I tried to compare such values with the leading frequency associated with EOF_1 
and EOF_12.
Unluckily, I am unable to draw any comclusion:

 Amps.dc$freq[1] #EOF_1 LEADING FREQUENCY
[1] 0.0007225434

 Amps.dc$freq[12]   #EOF_12 LEADING FREQUENCY
[1] 0.002890173

getSignal on-line documentation states about Trend smoothness:
The proportion of variance explained by the frequencies =q omega0. 
But nowhere I could find what q is equal to. I guess the above sentence 
indicates a fraction of the nyquist frequency Omega_0 

getSignal on-line documentation states about Trend explainedVariance:
Percentage of the variance explained by the Eigenvalues with  rank k
Does the above variance refer to the signal variance 

I would greatly appreciate your help at using this package properly.
Thank you in advance.
Maura 




e tutti i telefonini TIM!
Vai su 



e tutti i telefonini TIM!
Vai su 



e tutti i telefonini TIM!
Vai su 
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] isolating Hour and minute form date and time

2009-06-10 Thread christiaan pauw
Hi everybody. I have a dataframe that contains a factor with the date
information in the format like in the example below:
2009/05/12 11:22:31 AM

I have been able to convert it to POSIXt using strptime

Now I want to print only the date as one vector and the time in another
vector but they must be real date and time classes so that i can use them in
calculations

to reconstruct my situation:

date=as.factor(2009/05/12 11:22:31 AM)
posix.date=strptime(date, %Y/%m/%d %I:%M:%S %p)

I tried:

time=format(posix.date, %A %H:%M) # For weekday, hour and minute

but the class in character. Now it prints like i want but it cannot be used
in calculations.

I would appreciate any suggestions

Thanks in advance
Christiaan

[[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] isolating Hour and minute form date and time

2009-06-10 Thread Gabor Grothendieck
Try this and see R News 4/1 for more.

 now - Sys.time(); now
[1] 2009-06-10 07:26:23 EDT
 library(chron)
 ch - as.chron(format(now))
 dd - dates(ch); dd; dd+1
day
06/10/09
day
06/11/09
 tt - times(ch) - times(dd); tt; tt+1/24
day
07:26:23
day
08:26:23

On Wed, Jun 10, 2009 at 7:13 AM, christiaan pauwcjp...@gmail.com wrote:
 Hi everybody. I have a dataframe that contains a factor with the date
 information in the format like in the example below:
 2009/05/12 11:22:31 AM

 I have been able to convert it to POSIXt using strptime

 Now I want to print only the date as one vector and the time in another
 vector but they must be real date and time classes so that i can use them in
 calculations

 to reconstruct my situation:

 date=as.factor(2009/05/12 11:22:31 AM)
 posix.date=strptime(date, %Y/%m/%d %I:%M:%S %p)

 I tried:

 time=format(posix.date, %A %H:%M) # For weekday, hour and minute

 but the class in character. Now it prints like i want but it cannot be used
 in calculations.

 I would appreciate any suggestions

 Thanks in advance
 Christiaan

        [[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] Using ADF.Test

2009-06-10 Thread Wacek Kusnierczyk
Achim Zeileis wrote:

[...]

  is.vector(as.vector(...)) is not necessarily TRUE. Consider

   x - cars[, 1, drop=FALSE]
   is.vector(x)
   is.vector(as.vector(x))
   identical(x, as.vector(x))


interesting.  i wonder why as.vector does not give, at the very least, a
warning when the result of its application is not a vector.  the purpose
of as.vector, one might guess, is to obtain a vector from whatever input
-- or have the statement fail if such a conversion is impossible. 

the 'help' page for as.vector does not really explain what as.vector
returns.  the section 'value' talks about vector, exclusively:

Value:

 For 'vector', a vector of the given length and mode.  Logical
 vector elements are initialized to 'FALSE', numeric vector
 elements to '0', character vector elements to '', raw vector
 elements to 'nul' bytes and list elements to 'NULL'.

 All attributes are removed from the answer if it is of an atomic
 mode.

fine, but what about as.vector?  the section 'description' says:

'as.vector', a generic, attempts to coerce its argument into a
 vector of mode 'mode' (the default is to coerce to whichever mode
 is most convenient).

fine, but what if the attempt is unsuccessful?  the following fails:

as.vector(as.vector)
# Error in as.vector(x, mode) :
#  cannot coerce type 'closure' to vector of type 'any'

but as.vector(data.frame()) 'works', even though the result is not a
vector of type 'any' either.

perhaps the 'help' page might be made more helpful?

vQ

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] isolating Hour and minute form date and time

2009-06-10 Thread Allan Engelhardt
There is no class for times only in R.  Your best bet is probably a 
difftime, e.g.


time - difftime(posix.date, as.Date(posix.date), units=secs)

Allan.

christiaan pauw wrote:

Hi everybody. I have a dataframe that contains a factor with the date
information in the format like in the example below:
2009/05/12 11:22:31 AM

I have been able to convert it to POSIXt using strptime

Now I want to print only the date as one vector and the time in another
vector but they must be real date and time classes so that i can use them in
calculations

to reconstruct my situation:

date=as.factor(2009/05/12 11:22:31 AM)
posix.date=strptime(date, %Y/%m/%d %I:%M:%S %p)

I tried:

time=format(posix.date, %A %H:%M) # For weekday, hour and minute

but the class in character. Now it prints like i want but it cannot be used
in calculations.

I would appreciate any suggestions

Thanks in advance
Christiaan

[[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] ggplot, qplot: alpha channel for colors corresponding to factor

2009-06-10 Thread Marianne Promberger
Hi,

I have a qplot like the one in the minimal example below, except I
also have faceting like this:

qplot(jitter(Goodall),jitter(Better.adapt),colour=Second.adapt,facets=~Pol,data=d1)

and with the real data I get quite a lot of overplotting, so I would
like to add an alpha channel.

In addition, I would like to be able to control which colors are used
for each value of Second.adapt (which takes 7 different values). With
my original data, qplot by default uses a range from blue to red,
which is quite suitable, but I probably need to change this to shades
of grey for publication. 

I tried
qplot(jitter(Goodall),jitter(Better.adapt),colour=I(alpha(Second.adapt,1/5)),facets=~Pol,data=d1)
but that does not give me what I want (There is no legend and I don't
think anything corresponds to the seven values of Second.adapt).

Minimal example:

Goodall - c(rep(1:3,5))
Better.adapt - c(rep(1,7),rep(2,8))
Second.adapt - c(rep(1:5,3))
d1 - 
data.frame(Goodall=c(Goodall),Better.adapt=c(Better.adapt),Second.adapt=c(Second.adapt))
library(ggplot2)
qplot(jitter(Goodall),jitter(Better.adapt),colour=Second.adapt,data=d1)
# follwoing doesn't work:
qplot(jitter(Goodall),jitter(Better.adapt),colour=I(alpha(Second.adapt,1/5)),data=d1)

Thanks for any pointers,

Marianne





-- 
Marianne Promberger PhD
http://www.psych.upenn.edu/~mpromber
PGP/GnuPG public key ID 80AD9916

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

2009-06-10 Thread Jim Lemon

Muri Soares wrote:

Hi,

Is there a way to make the filled.contour() function produce a plot similar to the 
image() function? i.e. not have smooth contours but rather distinct squares 
corresponding to the different cells of the matrix. The reason I ask is because since 
image doesn't have an option to display colour bars it is a lot less useful.

  

Hi Muri,
Have a look at color2D.matplot in the plotrix package.

Jim

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


[R] plot two variograms on a same graph

2009-06-10 Thread damien landais
Hi,
I would know how to plot two variograms on a same graph. I can plot one by one 
but I would draw both on the same one.
Is it possible? Do i need any special package?

Thanks!

Cordialement
Damien Landais

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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, qplot: alpha channel for colors corresponding to factor

2009-06-10 Thread ONKELINX, Thierry
Dear Marianne,

If find that a bit easier with ggplot() instead of qplot()

d1 - data.frame(Goodall=c(rep(1:3,5)), Better.adapt =
c(rep(1,7),rep(2,8)),Second.adapt=c(rep(1:5,3)))
library(ggplot2) 
ggplot(d1, aes(x= Goodall, y = Better.adapt, colour=Second.adapt)) +
geom_jitter(alpha = 0.2) + scale_colour_gradient(low = white, high =
black)

Another option would be to convert Second.adapt to a factor and use
scale_colour_manual

d1$Second - factor(d1$Second.adapt)
ggplot(d1, aes(x= Goodall, y = Better.adapt, colour=Second)) +
geom_jitter(alpha = 0.9) + scale_colour_manual(values = c(white,
grey, black, green, red))

HTH,

Thierry




ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of
data.
~ John Tukey

-Oorspronkelijk bericht-
Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens Marianne Promberger
Verzonden: woensdag 10 juni 2009 13:37
Aan: R-help
Onderwerp: [R] ggplot, qplot: alpha channel for colors corresponding to
factor

Hi,

I have a qplot like the one in the minimal example below, except I also
have faceting like this:

qplot(jitter(Goodall),jitter(Better.adapt),colour=Second.adapt,facets=~P
ol,data=d1)

and with the real data I get quite a lot of overplotting, so I would
like to add an alpha channel.

In addition, I would like to be able to control which colors are used
for each value of Second.adapt (which takes 7 different values). With my
original data, qplot by default uses a range from blue to red, which is
quite suitable, but I probably need to change this to shades of grey for
publication. 

I tried
qplot(jitter(Goodall),jitter(Better.adapt),colour=I(alpha(Second.adapt,1
/5)),facets=~Pol,data=d1)
but that does not give me what I want (There is no legend and I don't
think anything corresponds to the seven values of Second.adapt).

Minimal example:

Goodall - c(rep(1:3,5))
Better.adapt - c(rep(1,7),rep(2,8))
Second.adapt - c(rep(1:5,3))
d1 -
data.frame(Goodall=c(Goodall),Better.adapt=c(Better.adapt),Second.adapt=
c(Second.adapt))
library(ggplot2)
qplot(jitter(Goodall),jitter(Better.adapt),colour=Second.adapt,data=d1)
# follwoing doesn't work:
qplot(jitter(Goodall),jitter(Better.adapt),colour=I(alpha(Second.adapt,1
/5)),data=d1)

Thanks for any pointers,

Marianne





--
Marianne Promberger PhD
http://www.psych.upenn.edu/~mpromber
PGP/GnuPG public key ID 80AD9916

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

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 CMD check does not find a mistake

2009-06-10 Thread Martin Maechler
 MM == Martin Maechler maech...@stat.math.ethz.ch
 on Wed, 10 Jun 2009 08:50:46 +0200 writes:

 CG == Christophe Genolini cgeno...@u-paris10.fr
 on Tue, 09 Jun 2009 16:17:15 +0200 writes:

CG Hi the list, I build a package. They was a mistake in
CG it, but R CMD check did not find it. Is that normal ?

CG Here is what Kurt gets (which is right, I did this
CG mistake):

CG --- 8 
CG * checking for code/documentation mismatches ... WARNING
CG S4 class codoc mismatches from documentation object 'LongData-class':
CG Slots for class 'LongData'
CG Code: id other time traj varName
CG Docs: id time traj varName
CG --- 8 

MM Others have already hinted at the solution:

MM The problem only shows in  R-devel (2.10.x).

MM Note that I had sent an explicit message to this list

this list (above) was not quite correct, excuse me. 

I meant the R-devel list,  and I indeed would suggest that active R
package authors *do* subscribe to R-devel  (or read it very
regularly through one of its mirrors/ list-interfaces).

Martin

MM *exactly* in order to advise all package authors :

MM Subject: [Rd] R-devel:codocClasses() now finds more -- R CMD check 
warnings
MM Date: Wed, 3 Jun 2009 11:45:45 +0200

MM i.e. only 6 days before you saw the problem
MM 
MM yes, I am sometimes too optimistic, assuming that people
MM actually read what I write 

MM Regards anyway!
MM Martin

MM --
MM Martin Maechler, ETH Zurich

MM __
MM R-help@r-project.org mailing list
MM https://stat.ethz.ch/mailman/listinfo/r-help
MM PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
MM 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] plot two variograms on a same graph

2009-06-10 Thread ONKELINX, Thierry
Dear Damien,

I tend do use ggplot2 for more advanced plotting. You only have to
create a dataframe with all the data you need. Here are some examples.

library(gstat)
library(ggplot2)
data(meuse)
coordinates(meuse) = ~x+y
g1 - gstat(id = Raw, formula = log(zinc)~1, data = meuse)
g2 - gstat(id = Linear trend, formula = log(zinc)~x+y, data =
meuse)
vg1 - variogram(g1)
vg2 - variogram(g2)
ggplot(rbind(vg1, vg2), aes(x = dist, y = gamma, colour = id)) +
geom_point()

vgm1 - fit.variogram(vg1, vgm(1, Sph, 700, 1))
vgm2 - fit.variogram(vg2, vgm(1, Sph, 700, 1))
vgLine - rbind(
cbind(variogramLine(vgm1, maxdist = max(vg1$dist)), id =
Raw),
cbind(variogramLine(vgm2, maxdist = max(vg2$dist)), id =
Linear trend)
)
ggplot(rbind(vg1, vg2), aes(x = dist, y = gamma, colour = id)) +
geom_line(data = vgLine) + geom_point()
 
HTH,

Thierry



ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of
data.
~ John Tukey

-Oorspronkelijk bericht-
Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens damien landais
Verzonden: woensdag 10 juni 2009 13:55
Aan: R-help@r-project.org
Onderwerp: [R] plot two variograms on a same graph

Hi,
I would know how to plot two variograms on a same graph. I can plot one
by one but I would draw both on the same one.
Is it possible? Do i need any special package?

Thanks!

Cordialement
Damien Landais

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

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

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

2009-06-10 Thread David Winsemius

The image function in package Matrix plots a color legend by default.

Searching on what seemed like the obvious strategy image legend in R  
Site Search would have identified this and a huge number of other  
alternatives, of which Lemon's color2D.matplot is the tenth.


--
David Winsemius


On Jun 10, 2009, at 5:28 AM, Muri Soares wrote:


Hi,

Is there a way to make the filled.contour() function produce a plot  
similar to the image() function? i.e. not have smooth contours but  
rather distinct squares corresponding to the different cells of  
the matrix. The reason I ask is because since image doesn't have an  
option to display colour bars it is a lot less useful.


Cheers

Muri Soares
Department of Maths and Applied Maths
University of Cape Town
South Africa


[[alternative HTML version deleted]]


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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, qplot: alpha channel for colors corresponding to factor

2009-06-10 Thread Marianne Promberger
Many thanks for the quick reply!

 d1 - data.frame(Goodall=c(rep(1:3,5)), Better.adapt =
 c(rep(1,7),rep(2,8)),Second.adapt=c(rep(1:5,3)))
 library(ggplot2) 
 ggplot(d1, aes(x= Goodall, y = Better.adapt, colour=Second.adapt)) +
 geom_jitter(alpha = 0.2) + scale_colour_gradient(low = white, high =
 black)

Great, this is exactly what I was looking for.

In case someone else needs this in the future, for my original data, I
was able to add the faceting using:

ggplot(d1, aes(x= Goodall, y = Better.adapt, colour=Second.adapt)) +
geom_jitter(alpha = 0.6) + scale_colour_gradient(low = white, high =
black) + facet_wrap(~ Pol, ncol = 4)

(Pol has length 16, so it is nice to have it wrapped to four columns
using facet_wrap instead of facet_grid)

Thanks again,

Marianne


 Another option would be to convert Second.adapt to a factor and use
 scale_colour_manual
 
 d1$Second - factor(d1$Second.adapt)
 ggplot(d1, aes(x= Goodall, y = Better.adapt, colour=Second)) +
 geom_jitter(alpha = 0.9) + scale_colour_manual(values = c(white,
 grey, black, green, red))
 
 HTH,
 
 Thierry
 
 
 
 
 ir. Thierry Onkelinx
 Instituut voor natuur- en bosonderzoek / Research Institute for Nature
 and Forest
 Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
 methodology and quality assurance
 Gaverstraat 4
 9500 Geraardsbergen
 Belgium
 tel. + 32 54/436 185
 thierry.onkel...@inbo.be
 www.inbo.be
 
 To call in the statistician after the experiment is done may be no more
 than asking him to perform a post-mortem examination: he may be able to
 say what the experiment died of.
 ~ Sir Ronald Aylmer Fisher
 
 The plural of anecdote is not data.
 ~ Roger Brinner
 
 The combination of some data and an aching desire for an answer does not
 ensure that a reasonable answer can be extracted from a given body of
 data.
 ~ John Tukey
  
 -Oorspronkelijk bericht-
 Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 Namens Marianne Promberger
 Verzonden: woensdag 10 juni 2009 13:37
 Aan: R-help
 Onderwerp: [R] ggplot, qplot: alpha channel for colors corresponding to
 factor
 
 Hi,
 
 I have a qplot like the one in the minimal example below, except I also
 have faceting like this:
 
 qplot(jitter(Goodall),jitter(Better.adapt),colour=Second.adapt,facets=~P
 ol,data=d1)
 
 and with the real data I get quite a lot of overplotting, so I would
 like to add an alpha channel.
 
 In addition, I would like to be able to control which colors are used
 for each value of Second.adapt (which takes 7 different values). With my
 original data, qplot by default uses a range from blue to red, which is
 quite suitable, but I probably need to change this to shades of grey for
 publication. 
 
 I tried
 qplot(jitter(Goodall),jitter(Better.adapt),colour=I(alpha(Second.adapt,1
 /5)),facets=~Pol,data=d1)
 but that does not give me what I want (There is no legend and I don't
 think anything corresponds to the seven values of Second.adapt).
 
 Minimal example:
 
 Goodall - c(rep(1:3,5))
 Better.adapt - c(rep(1,7),rep(2,8))
 Second.adapt - c(rep(1:5,3))
 d1 -
 data.frame(Goodall=c(Goodall),Better.adapt=c(Better.adapt),Second.adapt=
 c(Second.adapt))
 library(ggplot2)
 qplot(jitter(Goodall),jitter(Better.adapt),colour=Second.adapt,data=d1)
 # follwoing doesn't work:
 qplot(jitter(Goodall),jitter(Better.adapt),colour=I(alpha(Second.adapt,1
 /5)),data=d1)
 
 Thanks for any pointers,
 
 Marianne
 
 
 
 
 
 --
 Marianne Promberger PhD
 http://www.psych.upenn.edu/~mpromber
 PGP/GnuPG public key ID 80AD9916
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
 en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd 
 is
 door een geldig ondertekend document. The views expressed in  this message 
 and any annex are purely those of the writer and may not be regarded as 
 stating 
 an official position of INBO, as long as the message is not confirmed by a 
 duly 
 signed document.
 

-- 
Marianne Promberger PhD
http://www.psych.upenn.edu/~mpromber
PGP/GnuPG public key ID 80AD9916

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] arima modeling for multiple time series

2009-06-10 Thread Erin Hodgess
Dear R People:

Is there a package for arima modeling of multiple time series, please?

I think that Dr. Paul Gilbert may have one, but I'm drawing a blank on
the package name.

Thanks in advance,
Sincerely,
Erin


-- 
Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences
University of Houston - Downtown
mailto: erinm.hodg...@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] plot two variograms on a same graph

2009-06-10 Thread Paul Hiemstra

Hi,

It is possible, but without you specifying in which pacakge you are 
going to fit the variograms it is hard for us to provide an example. And 
what do you mean by variogram, is that the sample variogram or the 
fitted variogram model, or both? Try and keep to the posting guide next 
time to make it possible for us to answer your question. When you use 
gstat for geostatistics you can use somehting along the line of 
(assuming that only the variogram model is different):


library(automap)   # I use automap to fit the variogram, available on CRAN
library(lattice)
data(meuse)
coordinates(meuse) = ~x+y

av1 = autofitVariogram(log(zinc)~dist, meuse, model = Sph)
av2 = autofitVariogram(log(zinc)~dist, meuse, model = Exp)

# Make the plot
xyplot(gamma ~ dist, av1$exp_var,
   panel = function(...) {
  panel.xyplot(...)

  # First model
  vm1 = av1$var_model
  ret = variogramLine(vm1, maxdist = 1600)
  llines(ret$dist, ret$gamma)

  # Second model
  vm2 = av2$var_model
  ret = variogramLine(vm2, maxdist = 1600)
  llines(ret$dist, ret$gamma, col = red)
   }
)

cheers,
Paul

ps There is a mailing list for geographical problems, r-sig-geo. These 
kinds of problems are likely to get more response there.


damien landais wrote:

Hi,
I would know how to plot two variograms on a same graph. I can plot one by one 
but I would draw both on the same one.
Is it possible? Do i need any special package?

Thanks!

Cordialement
Damien Landais

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



--
Drs. Paul Hiemstra
Department of Physical Geography
Faculty of Geosciences
University of Utrecht
Heidelberglaan 2
P.O. Box 80.115
3508 TC Utrecht
Phone:  +3130 274 3113 Mon-Tue
Phone:  +3130 253 5773 Wed-Fri
http://intamap.geo.uu.nl/~paul

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

2009-06-10 Thread Ravi Varadhan
To get the result that you were expecting, use the following (which uses the
raw polynomial a + bx + cx^2 rather than the orthogonal polynomial of degree
2):

lm(y~poly(x,2, raw=TRUE))

Ravi.


---

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: rvarad...@jhmi.edu

Webpage:
http://www.jhsph.edu/agingandhealth/People/Faculty_personal_pages/Varadhan.h
tml







-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Gabor Grothendieck
Sent: Wednesday, June 10, 2009 6:37 AM
To: Ning Ma
Cc: r-help@r-project.org
Subject: Re: [R] poly regression

They have different coefficients because their model matrices are different
but they both lead to the same predictions:

 fitted(lm(y~1+x+I(x^2)))
  1   2   3   4   5   6   7   8   9  10
  1   4   9  16  25  36  49  64  81 100

 fitted(lm(y~poly(x,2)))
  1   2   3   4   5   6   7   8   9  10
  1   4   9  16  25  36  49  64  81 100


On Wed, Jun 10, 2009 at 1:41 AM, Ning Mapnin...@gmail.com wrote:
 hi,

 I want to do a polynomial regression of y on x of degree 2, as 
 following

 x-1:10
 y-x^2
 lm(y~poly(x,2))

 Call:
 lm(formula = y ~ poly(x, 2))

 Coefficients:
 (Intercept)  poly(x, 2)1  poly(x, 2)2
      38.50        99.91        22.98

 Which is not what i had expected.

 If I wrote the expression in an explicit form, y~1+x+I(x^2), I could 
 get the expected result:

 lm(y~1+x+I(x^2))

 Call:
 lm(formula = y ~ 1 + x + I(x^2))

 Coefficients:
 (Intercept)            x       I(x^2)
          0            0            1

 What is the diff between them?

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] arima modeling for multiple time series

2009-06-10 Thread David Winsemius
An R Site Search on the obvious strategy arima Gilbert produces two  
hits of which the first is:

dse-package {dse1}

On Jun 10, 2009, at 9:13 AM, Erin Hodgess wrote:


Dear R People:

Is there a package for arima modeling of multiple time series, please?

I think that Dr. Paul Gilbert may have one, but I'm drawing a blank on
the package name.

Thanks in advance,
Sincerely,
Erin


--
Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences
University of Houston - Downtown
mailto: erinm.hodg...@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.


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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

2009-06-10 Thread Daniel Mail


 



hello,
 
 
i was trying to predict values for a garch, so i did:
 
predict(fitgarch,n.ahead = 20)
 
but this doesn't work. Someone can tell me how to get the 20 values ahead of a 
garch model.
 
 
thanks in advance


_
O Windows Live ajuda-o a manter-se em contacto com todos os seus amigos, num só 
local.
http://www.microsoft.com/portugal/windows/windowslive/products/social-network-connector.aspx
[[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] (sem assunto)

2009-06-10 Thread Daniel Mail

hello,

 

 

i was trying to predict values for a garch, so i did:

 

predict(fitgarch,n.ahead = 20)

 

but this doesn't work. Someone can tell me how to get the 20 values ahead of a 
garch model.

 

 

thanks in advance

_
Obtenha 30 Emoticons grátis para o seu Windows Live Messenger
http://www.livemessenger-emoticons.com/funfamily/pt-pt/
[[alternative HTML version deleted]]

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


Re: [R] Problem : solving a equation with R , fail with uniroot function

2009-06-10 Thread Ben Bolker



yann lancien wrote:
 
 Thanks for your help !
 I got another problem with my function :
 test - function(x,bb0=-3,bb1=5,c0=2,r0=0) {
   ((exp(c0-r0)*(bb0+x)*(bb1-x))/((bb0+x+1)*(bb1-x-1))-1)}
 
 With this :
 curve(test(x),from=-10,to=10)
 
 we can see that there are 2 roots : one in [3,4] and one in [5,10]
 uniroot(test,c(5, 10))$root
 [1] 5.243265
 uniroot(test,c(3, 4))$root
 [1] 3.069772
 
 Even this works :
 uniroot(test,c(3, 10))$root
 [1] 5.243263
 
 but it's unfortunate that :
 uniroot(test3,c(-10, 10))$root
 *Erreur dans uniroot(test3, c(-10, 10)) :
   les valeurs de f() aux points extrêmes ne sont pas de signe opposé*
 doesn't work, because I have to find the root for c0 in [-10,10] but I
 can't
 change the range at each loop:
 
 I want to do something like this, do you have any ideas ?
 
 for (i in -10:10) {
 + z - uniroot(test,c(-10, 10), c0=i)$root
 + print(z)}
 
 Yann
 

This is the point at which somebody's (I forget whose) R-help signature
comes to mind: what is the problem you are trying to solve?
You could develop an elaborate brute-force solution that combined
try() [to catch the function when it doesn't work] and attempts to
find roots in (for example) [-10,-9],[-9,-8],[-8,-7], ... [9,10] -- but
how are you going to decide which root you want when there is
more than one?  I'm afraid this
is no longer an R problem ... you might have to go back and re-think
your approach to the problem ...

  Ben Bolker
-- 
View this message in context: 
http://www.nabble.com/Problem-%3A-solving-a-equation-with-R-%2C-fail-with-uniroot-function-tp23953174p23962342.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] Comparing R and SAS

2009-06-10 Thread Terry Therneau
Satish,
  There are nearly as many opinions as people on this question.  So accept 
these 
as my views only.
  
  1. I have written S packages, SAS procedures and SAS macros over my career.  
S 
was specifically designed for extensibility and it shows.  The ratio of time to 
get a new statistical idea up and running is about 1:5:20 for S:macro:proc, 
using the therneau days metric.  New ideas are the lifeblood for an academic; 
SAS makes no sense in that environment and so will always lag far behind.  For 
simple things like a repetive recoding, a 2-10 line R function say, SAS macro 
will be competive with R in terms of programming effort.  
  
  2. The SAS programming model could be described as mini batch; the block of 
statements including and following a data statment is executed as a unit.  
For 
data manipulation this is turns out to be a very powerful programming paradym 
and many people, myself included, prefer it for data input and manipulation.  
At 
the time I was first using SAS (mid 70s) no other package or system was even 
close to SAS in this arena, and by the late 80s many disciplines with complex, 
large, or messy data had wedded themselves to SAS, e.g., drug company clinical 
trials.  Most are still wedded.  
  
  Terry Therneau

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

2009-06-10 Thread Mike Lawrence
With skewed unimodal distributions, the mode can't equal the mean, so
assuming you want the mean to be around 30, I find that a weibull
function can get close to what you want:

 mean(rweibull(1e5,1.5,33))
[1] 29.77781
 pweibull(60,1.5,33)
[1] 0.9138475

I'm sure you can play with the parameters to try to get even closer to
what you want.

On Wed, Jun 10, 2009 at 2:48 AM, David Arnolddwarnol...@suddenlink.net wrote:
 All,
 Can someone help me create a skewed distribution, mean = 30, with
 probability of selecting a random number from the distribution greater
 than or equal 60 equal to 10%?

 I need the probability density function to equal zero at zero, and
 have  a maximum height at or near 30.

 Is this possible?

 And if it is possible, how can I adjust the distribution so that the
 probability of selecting a random number greater than or equal to 60
 is p.

 Thanks. No idea how to start.

 David



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




-- 
Mike Lawrence
Graduate Student
Department of Psychology
Dalhousie University

Looking to arrange a meeting? Check my public calendar:
http://tr.im/mikes_public_calendar

~ Certainty is folly... I think. ~

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

2009-06-10 Thread Etienne B. Racine

Hi,

With two data sets, one complete and another one partial, I would like to
merge them and keep the unmatched lines. The problem is that merge() dosen't
keep the unmatched lines. Is there another function that I could use to
merge the data frames.

Example:

completedf - expand.grid(alpha=letters[1:3],beta=1:3)
partdf - data.frame(
alpha= c('a','a','c'),
beta = c(1,3,2),
val = c(2,6,4))

mergedf - merge(x=completedf, y=partdf, by=c('alpha','beta'))
# it only kept the common rows
nrow(mergedf)

Thanks, 
Etienne
-- 
View this message in context: 
http://www.nabble.com/Merge-data-frame-and-keep-unmatched-tp23962874p23962874.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] Merge data frame and keep unmatched

2009-06-10 Thread Marc Schwartz


On Jun 10, 2009, at 8:56 AM, Etienne B. Racine wrote:



Hi,

With two data sets, one complete and another one partial, I would  
like to
merge them and keep the unmatched lines. The problem is that merge()  
dosen't
keep the unmatched lines. Is there another function that I could use  
to

merge the data frames.

Example:

completedf - expand.grid(alpha=letters[1:3],beta=1:3)
partdf - data.frame(
alpha= c('a','a','c'),
beta = c(1,3,2),
val = c(2,6,4))

mergedf - merge(x=completedf, y=partdf, by=c('alpha','beta'))
# it only kept the common rows
nrow(mergedf)

Thanks,
Etienne




Is this what you want?

 merge(x=completedf, y=partdf, by=c('alpha','beta'), all = TRUE)
  alpha beta val
1 a1   2
2 a2  NA
3 a3   6
4 b1  NA
5 b2  NA
6 b3  NA
7 c1  NA
8 c2   4
9 c3  NA

Note the 'all', 'all.x' and 'all.y' arguments...

HTH,

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] Merge data frame and keep unmatched

2009-06-10 Thread Gabor Grothendieck
Try:

merge(completedf, partdf, all.x = TRUE)

or

library(sqldf) # see http://sqldf.googlecode.com
sqldf(select * from completedf left join partdf using(beta, alpha))


On Wed, Jun 10, 2009 at 9:56 AM, Etienne B. Racineetienn...@gmail.com wrote:

 Hi,

 With two data sets, one complete and another one partial, I would like to
 merge them and keep the unmatched lines. The problem is that merge() dosen't
 keep the unmatched lines. Is there another function that I could use to
 merge the data frames.

 Example:

 completedf - expand.grid(alpha=letters[1:3],beta=1:3)
 partdf - data.frame(
        alpha= c('a','a','c'),
        beta = c(1,3,2),
        val = c(2,6,4))

 mergedf - merge(x=completedf, y=partdf, by=c('alpha','beta'))
 # it only kept the common rows
 nrow(mergedf)

 Thanks,
 Etienne
 --
 View this message in context: 
 http://www.nabble.com/Merge-data-frame-and-keep-unmatched-tp23962874p23962874.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] Creating a specific skewed distribution

2009-06-10 Thread Etienne B. Racine

You could also make some algebra. e.g. :

?rweibull

gives the formula of the mean and of the cumulative distribution function in
the Details section. So using your known parameters (i.e. mean=30 and
p(10)=.10, i.e. cumulative function(10) =.90), I think it is sufficient to
determine the exact values you want shape and scale to be.

And you can do that with any probability function (some easier the
calculate) as most (if not all) have these equations. Of course, it might be
more pleasing to play with the parameters.

Etienne


Mike Lawrence wrote:
 
 With skewed unimodal distributions, the mode can't equal the mean, so
 assuming you want the mean to be around 30, I find that a weibull
 function can get close to what you want:
 
 mean(rweibull(1e5,1.5,33))
 [1] 29.77781
 pweibull(60,1.5,33)
 [1] 0.9138475
 
 I'm sure you can play with the parameters to try to get even closer to
 what you want.
 
 On Wed, Jun 10, 2009 at 2:48 AM, David Arnolddwarnol...@suddenlink.net
 wrote:
 All,
 Can someone help me create a skewed distribution, mean = 30, with
 probability of selecting a random number from the distribution greater
 than or equal 60 equal to 10%?

 I need the probability density function to equal zero at zero, and
 have  a maximum height at or near 30.

 Is this possible?

 And if it is possible, how can I adjust the distribution so that the
 probability of selecting a random number greater than or equal to 60
 is p.

 Thanks. No idea how to start.

 David



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

 
 
 
 -- 
 Mike Lawrence
 Graduate Student
 Department of Psychology
 Dalhousie University
 
 Looking to arrange a meeting? Check my public calendar:
 http://tr.im/mikes_public_calendar
 
 ~ Certainty is folly... I think. ~
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/Creating-a-specific-skewed-distribution-tp23956114p23963140.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] MCMC validity question

2009-06-10 Thread Thomas Mang

Hello,

I have quite a tough problem, which might be able to be solved by MCMC. 
I am fairly new to MCMC (in the learning process) - so apologize if the 
answer is totally obvious, and any hints, links etc are greatly appreciated.


I'll illustrate the problem in a version cut-down to the essentials - 
the real problem is ways more complex.
Suppose I have a Markovian series of poisson processes, which generate 
(or kill) some objects. At t0, say I have initially x = 3 objects. In 
the next time step, t1, the number of total objects is 
Poisson-distributed, subject to a function of x at t0, covariates, and 
parameters. So x_t1 ~ Pois, with E(x_t1) = f(x_t0, covariates, 
parameters). Let's choose a very simple function for f, say just f = x * 
par1 * Covariate1. Now let this process be repeated for say 6 times, 
always with the number of objects obtained in a previous step as input 
(x) for the next step.
The problem is, at all time steps the total number of objects remains 
unobservable, because they are only detected with a certain, low 
probability (itself subject to covariates and parameters). So if you 
observe say 2 objects, the only thing you know is the figure must be = 
2. Presume however that the detection prob is equal and independent for 
all objects at a time step, and so the observed number of objects is 
also Poisson-distributed. The likelihood-function is then built upon 
that figure.


The main problem is the input to function f: In the first step, I know 
what x is (or even don't know that, might again just be from a 
distribution). From that step on, I have only a Poisson-distribution, 
and lack the concrete realization; all I know is a pure minimum value. 
In general f is not a simply thing, and is quite impracticable to input 
a distribution itself; moreover, because of the inflation of variance, 
the output could not be treated as lambda of a Poisson-distribution any 
more. So the Poisson-distribution is lost, although physical knowledge 
tells you it really is (and would be, were it x was known precisely).


The question is therefore, how can I work around the fact that x is 
always known to be only from a distribution, not knowing the precise 
realization?


Ignoring above issue, and keeping in mind that I have shown only a 
simplified version of the model, MCMC methods seem a reasonable choice. 
I had an idea, which looks so strange, that I have strong doubts if it's 
valid to so: Say I have a present parameter set. Is it then possible to 
estimate the Poisson-lambda for t1 using f, then draw a random number 
from that distribution, and now treat that drawn figure as (fixed) input 
for calculation for t2, and so on, repeating it until t6 ? At the end, 
propose new parameters based on MCMC sampling, and repeat all over again.
Will a long sequence of MCMC iterations homogenize these fake 
(simulated) realizations of the poisson-distributions, and so the chain 
will converge to the posterior distribution of the parameters?



many many thanks for any inputs and thoughts,
cheers,
Thomas

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 get the unique pairs of a set of pairs dataframe ?

2009-06-10 Thread Moumita Das
Hi friends,
Please can anyone help me with an easier solution of doing the  below
mentioned work.
Suppose i have a dataset like this:---

i1 i2  i3   i4 i5
1  7  13  1  2
2  8  14  2  2
3  9  15  3  3
4  10 16  4  4
5  11 17  5  5
6  12 18  6  7


*i1,i2,i3,i4,i5 are my items.I am able to find all possible pairs i.e
Say this dataframe is item_pairs
**i1,i2
**i1,i3
**i1,i4
i1,i5
**i2,i1
**i2,i3
i2,i4
i2,i5
**i3,i1
**i3,i2
**i3,i4
**i3,i5
**i4,i1
**i4,i2
**i4,i3
i4,i5
i5,i1
i5,i2
i5,i3
i5,i4

Pairs like (i1,i1) or (i2,i2) are not required.Now pair (i1,i2) is same as
pair (i2,i1) .How can i chop off the second pair which is identicle to the
first one,only that sequence of item numbers are different ,otherwise my
dataset is same.

I thought of something...like running loops for all rows and columns of
this item_pairs dataframe and check if first item in a pair matches with any
second item of previous pair and similarly  **second item in a pair matches
with any first item of previous pair* and keep entering them in a dataframe
and get the unique pairs.

But is there any other easier way of chopping off the identicle pairs?
*-- *
Thanks in advance
Moumita

[[alternative HTML version deleted]]

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


[R] Using yum to install R-2.9

2009-06-10 Thread Saptarshi Guha
Hello,
On Fedora 8, yum install R , installs R-2.6.
I dont have much experience with yum, how do change the repos(?) to
install R-2.9?

Thank you
Saptarshi

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 get the unique pairs of a set of pairs dataframe ?

2009-06-10 Thread Henrique Dallazuanna
Try this:

do.call(rbind,
  apply(combn(names(x), 2),
  2,
  function(n)expand.grid(x[,n[1]], x[,n[2]])))

On Wed, Jun 10, 2009 at 11:47 AM, Moumita Das
das.moumita.onl...@gmail.comwrote:

 Hi friends,
 Please can anyone help me with an easier solution of doing the  below
 mentioned work.
 Suppose i have a dataset like this:---

 i1 i2  i3   i4 i5
 1  7  13  1  2
 2  8  14  2  2
 3  9  15  3  3
 4  10 16  4  4
 5  11 17  5  5
 6  12 18  6  7


 *i1,i2,i3,i4,i5 are my items.I am able to find all possible pairs i.e
 Say this dataframe is item_pairs
 **i1,i2
 **i1,i3
 **i1,i4
 i1,i5
 **i2,i1
 **i2,i3
 i2,i4
 i2,i5
 **i3,i1
 **i3,i2
 **i3,i4
 **i3,i5
 **i4,i1
 **i4,i2
 **i4,i3
 i4,i5
 i5,i1
 i5,i2
 i5,i3
 i5,i4

 Pairs like (i1,i1) or (i2,i2) are not required.Now pair (i1,i2) is same as
 pair (i2,i1) .How can i chop off the second pair which is identicle to the
 first one,only that sequence of item numbers are different ,otherwise my
 dataset is same.

 I thought of something...like running loops for all rows and columns of
 this item_pairs dataframe and check if first item in a pair matches with
 any
 second item of previous pair and similarly  **second item in a pair matches
 with any first item of previous pair* and keep entering them in a dataframe
 and get the unique pairs.

 But is there any other easier way of chopping off the identicle pairs?
 *-- *
 Thanks in advance
 Moumita

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




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

[[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 get the unique pairs of a set of pairs dataframe ?

2009-06-10 Thread jim holtman
?combn

 x
[1] i1 i2 i3 i4 i5
 combn(x,2)
 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,] i1 i1 i1 i1 i2 i2 i2 i3 i3 i4
[2,] i2 i3 i4 i5 i3 i4 i5 i4 i5 i5



On Wed, Jun 10, 2009 at 10:47 AM, Moumita Das
das.moumita.onl...@gmail.comwrote:

 Hi friends,
 Please can anyone help me with an easier solution of doing the  below
 mentioned work.
 Suppose i have a dataset like this:---

 i1 i2  i3   i4 i5
 1  7  13  1  2
 2  8  14  2  2
 3  9  15  3  3
 4  10 16  4  4
 5  11 17  5  5
 6  12 18  6  7


 *i1,i2,i3,i4,i5 are my items.I am able to find all possible pairs i.e
 Say this dataframe is item_pairs
 **i1,i2
 **i1,i3
 **i1,i4
 i1,i5
 **i2,i1
 **i2,i3
 i2,i4
 i2,i5
 **i3,i1
 **i3,i2
 **i3,i4
 **i3,i5
 **i4,i1
 **i4,i2
 **i4,i3
 i4,i5
 i5,i1
 i5,i2
 i5,i3
 i5,i4

 Pairs like (i1,i1) or (i2,i2) are not required.Now pair (i1,i2) is same as
 pair (i2,i1) .How can i chop off the second pair which is identicle to the
 first one,only that sequence of item numbers are different ,otherwise my
 dataset is same.

 I thought of something...like running loops for all rows and columns of
 this item_pairs dataframe and check if first item in a pair matches with
 any
 second item of previous pair and similarly  **second item in a pair matches
 with any first item of previous pair* and keep entering them in a dataframe
 and get the unique pairs.

 But is there any other easier way of chopping off the identicle pairs?
 *-- *
 Thanks in advance
 Moumita

[[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.htmlhttp://www.r-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?

[[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] checking and building ROracle on OS X

2009-06-10 Thread Rajarshi Guha
Hi, I'm running R 2.9.0 (from the DMG) on OS X 10.5 and am trying to get
ROracle 0.5-9 to check and build.  I have installed the full Oracle
installation (10.2.0.4.0). The problem I'm facing is that I need to compile
ROracle.so as 32 bit, but my environment needs to point to the 64 bit Oracle
libs for the compilatin process to work (since the Pro*C compiler is 64 bit
and needs the 64 bit libs). So my DYLD_LIBRARY_PATH poins to the 64 bit
libs, but the package should be built with the 32 bit libs

Looking at the configure.in file, I see that I can specify configure
arguments to indicate a 32 bit build - but I can't see how I can specify
these args via R CMD CHECK or R CMD BUILD.

Any pointers would be appreciated.

-- 
Rajarshi Guha

[[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] Best way to plot a Matrix of all possible pair combinations

2009-06-10 Thread suparna mitra
Hallo R Users,
 I have some distance matrix data like
 M[1:10,]
   [,1]  [,2]  [,3]  [,4]  [,5]   [,6]
 [1,] 0.875 0.500 0.500 0.375 0.625 0.
 [2,] 0.8928571 1.000 0.000 0.8928571 0.1071429 0.
 [3,] 0.8928571 1.000 0.000 0.8928571 0.1071429 0.
 [4,] 0.8928571 1.000 0.000 0.8928571 0.1071429 0.
 [5,] 1.000 0.1304348 0.8695652 0.1304348 0.8695652 0.
 [6,] 1.000 0.1304348 0.8695652 0.1304348 0.8695652 0.
 [7,] 1.000 0.1304348 0.8695652 0.1304348 0.8695652 0.
 [8,] 0.9497743 0.7605977 0.2394023 0.7103720 0.2896280 0.
 [9,] 0.0754717 0.7169811 0.000 0.3584906 0.9245283 0.28301887
[10,] 0.3870968 0.9354839 0.000 0.4516129 0.6129032 0.06451613

where all the columns (1 to 6) are representing all possible pair-wise
combination from four datasets,
like
 cmbn
 [,1] [,2] [,3] [,4] [,5] [,6]
[1,]111223
[2,]234344

and all the rows represent different species

so;
 M[1,1]
[1] 0.875## is the distance value for species 1 for combination data
pair 1 2.

Can any body please suggest me what will be the best way to represent these
results in plot?
Thanks a lot in advance,
With best regard,
Suparna
---

[[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] GeoXp package

2009-06-10 Thread Poizot Emmanuel

Dear all,

I would like to use GeoXp package under Ubuntu Jaunty.
I did install the required package GeoXp, for which I had to install 
before rgdal package.
So when done, I want to load the library (library(GepXp), I got the 
error when GeoXP want to load rgdal package:


 library(sp)
 library(rgdal)
Error in fun(...) :
   GDAL Error 1: libgrass_I.so: Ne peut ouvrir le fichier d'objet 
partagé: Aucun fichier ou dossier de ce type  (sorry  for the french :) )


I check on my system and libgrass_I.so is located at 
/usr/lib/grass/lib/libgrass_I.so.

So how to specify the path of that file to allows rgdal loading ?

Regards

--



Emmanuel Poizot
Cnam/Intechmer
B.P. 324
50103 Cherbourg Cedex

Phone (Direct) : (00 33)(0)233887342
Fax : (00 33)(0)233887339


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

2009-06-10 Thread koj

Hi all,

I have time data in the following format:

2009-03-09 12:00:00
2009-03-09 13:30:00

Now I want to compute the delta between the two time points, which results
in this example in 1,5 h. I tried this via ts and the related functions
but so far without sucess. Can anybody help me?

Thank you very much in advance.



-- 
View this message in context: 
http://www.nabble.com/Delta-in-time-series-tp23957835p23957835.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] R: Best way to plot a Matrix of all possible pair combinations

2009-06-10 Thread suparna mitra
Hallo R Users,
Please help
 I have some distance matrix data like
 M[1:10,]
   [,1]  [,2]  [,3]  [,4]  [,5]   [,6]
 [1,] 0.875 0.500 0.500 0.375 0.625 0.
 [2,] 0.8928571 1.000 0.000 0.8928571 0.1071429 0.
 [3,] 0.8928571 1.000 0.000 0.8928571 0.1071429 0.
 [4,] 0.8928571 1.000 0.000 0.8928571 0.1071429 0.
 [5,] 1.000 0.1304348 0.8695652 0.1304348 0.8695652 0.
 [6,] 1.000 0.1304348 0.8695652 0.1304348 0.8695652 0.
 [7,] 1.000 0.1304348 0.8695652 0.1304348 0.8695652 0.
 [8,] 0.9497743 0.7605977 0.2394023 0.7103720 0.2896280 0.
 [9,] 0.0754717 0.7169811 0.000 0.3584906 0.9245283 0.28301887
[10,] 0.3870968 0.9354839 0.000 0.4516129 0.6129032 0.06451613

where all the columns (1 to 6) are representing all possible pair-wise
combination from four datasets,
like
 cmbn
 [,1] [,2] [,3] [,4] [,5] [,6]
[1,]111223
[2,]234344

and all the rows represent different species

so;
 M[1,1]
[1] 0.875## is the distance value for species 1 for combination data
pair 1 2.

Can any body please suggest me what will be the best way to represent these
results in plot?
Thanks a lot in advance,
With best regard,
Suparna

[[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] Delta in time series

2009-06-10 Thread koj



koj wrote:
 
 Hi all,
 
 I have time data in the following format:
 
 2009-03-09 12:00:00
 2009-03-09 13:30:00
 
 Now I want to compute the delta between the two time points, which results
 in this example in 1,5 h. I tried this via ts and the related functions
 but so far without sucess. Can anybody help me?
 
 Thank you very much in advance.
 
 
 
 

Probably this is of interest for another users: I`ve found a solution, which
computes the delta:

(test-strptime(c(jens1$Z_Zeit[1], jens1$Z_Zeit[2]),%Y-%m-%d %H:%M:%S,
tz=EST5EDT))
class(test)
difftime(test[2],test[1],units=hours,tz=EST5EDT)

-- 
View this message in context: 
http://www.nabble.com/Delta-in-time-series-tp23957835p23959207.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] graphically representing frequency of words in a speech?

2009-06-10 Thread Brown, Tony Nicholas
Yihui,

This is quite impressive, thanks for helping me think about how to make tag 
clouds in R.

Tony

-Original Message-
From: Yihui Xie [mailto:xieyi...@gmail.com] 
Sent: Wednesday, June 10, 2009 3:15 AM
To: Brown, Tony Nicholas
Cc: r-help@r-project.org
Subject: Re: [R] graphically representing frequency of words in a speech?

Hi,

As Gregor Gorjanc mentioned, it's very inconvenient to let R decide
the fontsize and placement of words in a plot. There have already been
very mature applications of tag cloud; one of them I'm relatively
familiar is the WordPress plugin wp-cumulus, which makes use of a
Flash object to generate tag cloud, and it has fantastic 3D rotation
effect of the cloud. I've spent a couple of hours porting it into R;
see the source code and effect here:

http://yihui.name/en/2009/06/creating-tag-cloud-using-r-and-flash-javascript-swfobject/

HTH.

Regards,
Yihui
--
Yihui Xie xieyi...@gmail.com
Phone: +86-(0)10-82509086 Fax: +86-(0)10-82509086
Mobile: +86-15810805877
Homepage: http://www.yihui.name
School of Statistics, Room 1037, Mingde Main Building,
Renmin University of China, Beijing, 100872, China



On Mon, Jun 8, 2009 at 2:41 AM, Brown, Tony
Nicholastony.n.br...@vanderbilt.edu wrote:
 Dear all,



 I recently saw a graph on television that displayed selected
 words/phrases in a speech scaled in size according to their frequency.
 So words/phrases that were often used appeared large and words that were
 rarely used appeared small. The closest thing I can find on the web to
 approximate what I saw can be found here:
 http://stateoftheunion.onetwothree.net/ The example at that website is
 more complicated but captures the general idea.



 Would someone point me in the right direction in terms of replicating
 such a graph.



 Thanks in advance,

 Tony



 
 -

 Tony N. Brown, Ph.D.

 Editor-Elect, American Sociological Review

 Associate Professor of Sociology and Human and Organizational
 Development (secondary)

 Program Faculty, Effective Health Communication and African American 
 Diaspora Studies

 Faculty Head of Hank Ingram House, The Commons

 Vanderbilt University

 (615) 322-7518

 (615) 322-7505 fax




        [[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] Delta in time series

2009-06-10 Thread Gabor Grothendieck
Try this:

 library(zoo)
 Lines - 2009-03-09 12:00:00,1
+ 2009-03-09 13:30:00,2
 z - read.zoo(textConnection(Lines), sep = ,, tz = )
 1/frequency(as.zooreg(z))
[1] 5400

noting that 5400 seconds is 1.5 hours.

On Wed, Jun 10, 2009 at 5:04 AM, kojjens.k...@gmx.li wrote:

 Hi all,

 I have time data in the following format:

 2009-03-09 12:00:00
 2009-03-09 13:30:00

 Now I want to compute the delta between the two time points, which results
 in this example in 1,5 h. I tried this via ts and the related functions
 but so far without sucess. Can anybody help me?

 Thank you very much in advance.



 --
 View this message in context: 
 http://www.nabble.com/Delta-in-time-series-tp23957835p23957835.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] SSOAP failing

2009-06-10 Thread Olivier Cailloux

Duncan Temple Lang a écrit :



Olivier Cailloux wrote:

Duncan Temple Lang a écrit :



Olivier Cailloux wrote:

Dear list,

Sorry about that, my e-mail has been sent too soon by mistake (also 
from an incorrect exp. address). I was planning to add further details.


So I'm running Debian Lenny. sessionInfo() gives:
R version 2.7.1 (2008-06-23)
i486-pc-linux-gnu

locale:
C

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   
base   Package:   SSOAP

Version:   0.5-0
Date:  2009/05/04
Package:  XML
Version:  2.3-0
Date: 2009/03/04
Package:  RCurl
Version:  0.97-3
Package:   XMLSchema
Version:   0.1-0

I must be stupid but I can't find XMLSchema on the omegahat website. 
(I just installed the 0.1-0 version a few days ago when trying to use 
SSOAP.) Google gives nothing useful for XMLSchema site:omegahat.org.


 http://www.omegahat.org/XMLSchema/XMLSchema_0.1-1.tar.gz

or from a link in
   http://www.omegahat.org/XMLSchema/

or via the repository using

  install.packages(XMLSchema, repos = http://www.omegahat.org/R;)
Thanks a lot: with the new version, calling my SOAP services work like a 
charm!


It would be nice to add a link to XMLSchema from the main page, to make 
it easier to find for users... And for Google! (So that it will index 
the page.)


Calling with the normal SOAP call works without trouble. However I 
can't use the genSOAPClientInterface way... See example hereunder.

---
 smg8Echo - SOAPServer(smg8.ulb.ac.be, 
axis2/services/EchoService, 8080)
 .SOAP(smg8Echo, doEchoOp, action=, 
xmlns=http://smg8.ulb.ac.be/echoSvc/;, toEchoInt=32)

[1] 32
 defEcho - 
processWSDL(http://smg8.ulb.ac.be:8080/axis2/services/EchoService?wsdl;)

 genSOAPClientInterface(def = defEcho)
[1] TheString
[1] TheInt
Error in d...@operations[[1]] : subscript out of bounds
 length(defe...@operations)
[1] 0
---

I can use the normal interface to my SOAP service anyway, so it is not 
*that* important if I can't make the genSOAPClientInterface call work. I 
just wanted to let you know, and also that way might reveal simpler for 
my user... Please tell me if I can try something else, if you have some 
time to look at it...

Olivier





I'm beginner in both web services and R programming (my knowledge is 
more in desktop  CORBA Java programming). I am simply trying to make 
Java and R communicate (call Java code from R remotely), for use by 
someone else who works in R. I'd like to provide him with a fully 
functional example. I must recognize that having to step through 
SSOAP code to find where the problem lies might be too difficult 
considering my current knowledge (knowing I don't intend to become an 
expert R programmer). Please don't take it as rude or implying that 
I'm simply expecting someone to solve the problem for me: I am ready 
to investigate but I'd simply like to have an idea of how difficult 
it will be. If I have to patch part of SSOAP or if you think that the 
functions I need are not implemented yet, then I'd better not insist 
and try to communicate from R to Java using an other way. If on the 
other hand you think it should be working and is simply a matter of 
using the right version of the right package, or using an other web 
services platform on the Java side, or configuring something 
differently, etc., then I'll happily dig into it.




Either of Simon Urbanek's rJava  or Rserve packages are worth 
investigating.


More generally, if someone has a suggestion on what to use to call 
Java over TCP/IP from R, I'd be interested. I am currently 
considering OSS as well as SSOAP. I'd prefer learning an approach 
that I can reuse for other languages, so possibly a standard like 
SOAP or CORBA would be best.


Thanks for any pointer.
Olivier



 D.




I tried different action values, because I don't know what I 
should put there. But I always get the same error.


Also, FYI, the following command produces the following output:
   smg8Def -  
processWSDL(http://smg8.ulb.ac.be:8080/axis2/services/Version?wsdl;, 
verbose=TRUE)

processing (sub) schema http://axisversion.sample
1 ) Exception
2 ) Exception
3 ) getVersionResponse
Warning message:
In 
processWSDL(http://smg8.ulb.ac.be:8080/axis2/services/Version?wsdl;,  
:

 Ignoring additional serviceport ... elements

and then

I also tried a simpler service (WSDL manually created myself, but I 
am not sure it is correct although it validates):
   smg8EchoDef - 
processWSDL(http://smg8.ulb.ac.be:8080/axis2/services/EchoService?wsdl;, 
verbose=TRUE)

processing (sub) schema http://smg8.ulb.ac.be/echoSvc/
1 ) TheString
   genSOAPClientInterface(def = smg8EchoDef)
Error in d...@operations[[1]] : subscript out of bounds
Indeed:
   length(smg8echo...@operations)
[1] 0

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide 

Re: [R] Using yum to install R-2.9

2009-06-10 Thread Marc Schwartz

On Jun 10, 2009, at 9:53 AM, Saptarshi Guha wrote:


Hello,
On Fedora 8, yum install R , installs R-2.6.
I dont have much experience with yum, how do change the repos(?) to
install R-2.9?

Thank you
Saptarshi




Upgrade to a still supported version of Fedora. Fedora 8 went EOL back  
in January, which means that you have been without *any* updates (bug  
fixes, kernel updates, security patches, etc.) since then.


With the release of Fedora 11 this week, Fedora 9 will go EOL in about  
a month, at which point, only Fedora 10 and 11 will be actively  
supported. If you are going to ride the Fedora train, you need to be  
willing to update your Fedora distribution relatively frequently. The  
current Fedora release and support schedule will generally allow you  
to skip one release, but not two. So if you are going to upgrade, you  
will want to move to at least Fedora 10.


You could try to download and install the appropriate 32 or 64 bit F9  
RPMs that Martyn prepares here:


  http://cran.r-project.org/bin/linux/redhat/fedora9/

But it may have F9 dependencies that can put you on a slippery slope  
of satisfying certain dependencies. I have not looked at the spec file.


BTW, there is a Fedora specific R e-mail list:

   https://stat.ethz.ch/mailman/listinfo/r-sig-fedora

which you might want to subscribe to and then post future Fedora/RH  
specific queries there.


HTH,

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] Creating a specific skewed distribution

2009-06-10 Thread David Arnold

Etienne et al,

This is exactly what I need. So I gave it an algebraic try and set:

Mean=30=b*gamma(1+1/a),

solve for b and substitute into F(60)=0.10. After a little algebra,  
this left me with


[ 2*gamma(1+1/a) ]^a = -ln(0.10)

Now, I don't think this has a closed form solution, at least not one I  
have the skill to find. So, how would I solve this using R?


David.

On Jun 10, 2009, at 7:09 AM, Etienne B. Racine wrote:



You could also make some algebra. e.g. :

?rweibull

gives the formula of the mean and of the cumulative distribution  
function in

the Details section. So using your known parameters (i.e. mean=30 and
p(10)=.10, i.e. cumulative function(10) =.90), I think it is  
sufficient to

determine the exact values you want shape and scale to be.

And you can do that with any probability function (some easier the
calculate) as most (if not all) have these equations. Of course, it  
might be

more pleasing to play with the parameters.

Etienne


Mike Lawrence wrote:


With skewed unimodal distributions, the mode can't equal the mean, so
assuming you want the mean to be around 30, I find that a weibull
function can get close to what you want:


mean(rweibull(1e5,1.5,33))

[1] 29.77781

pweibull(60,1.5,33)

[1] 0.9138475

I'm sure you can play with the parameters to try to get even closer  
to

what you want.

On Wed, Jun 10, 2009 at 2:48 AM, David Arnolddwarnol...@suddenlink.net 


wrote:

All,
Can someone help me create a skewed distribution, mean = 30, with
probability of selecting a random number from the distribution  
greater

than or equal 60 equal to 10%?

I need the probability density function to equal zero at zero, and
have  a maximum height at or near 30.

Is this possible?

And if it is possible, how can I adjust the distribution so that the
probability of selecting a random number greater than or equal to 60
is p.

Thanks. No idea how to start.

David



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





--
Mike Lawrence
Graduate Student
Department of Psychology
Dalhousie University

Looking to arrange a meeting? Check my public calendar:
http://tr.im/mikes_public_calendar

~ Certainty is folly... I think. ~

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




--
View this message in context: 
http://www.nabble.com/Creating-a-specific-skewed-distribution-tp23956114p23963140.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] Creating a specific skewed distribution

2009-06-10 Thread Ravi Varadhan
Here is one way to solve the equation:

require(BB)

f - function(x) (2*gamma(1+1/x))^x + log (0.10)
 
ans - dfsane(par=1, fn=f)
 
ans

Ravi.
 



---

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: rvarad...@jhmi.edu

Webpage:
http://www.jhsph.edu/agingandhealth/People/Faculty_personal_pages/Varadhan.h
tml

 





-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of David Arnold
Sent: Wednesday, June 10, 2009 11:25 AM
To: Etienne B. Racine
Cc: r-help@r-project.org
Subject: Re: [R] Creating a specific skewed distribution

Etienne et al,

This is exactly what I need. So I gave it an algebraic try and set:

Mean=30=b*gamma(1+1/a),

solve for b and substitute into F(60)=0.10. After a little algebra, this
left me with

[ 2*gamma(1+1/a) ]^a = -ln(0.10)

Now, I don't think this has a closed form solution, at least not one I have
the skill to find. So, how would I solve this using R?

David.

On Jun 10, 2009, at 7:09 AM, Etienne B. Racine wrote:


 You could also make some algebra. e.g. :

 ?rweibull

 gives the formula of the mean and of the cumulative distribution 
 function in the Details section. So using your known parameters (i.e. 
 mean=30 and p(10)=.10, i.e. cumulative function(10) =.90), I think it 
 is sufficient to determine the exact values you want shape and scale 
 to be.

 And you can do that with any probability function (some easier the
 calculate) as most (if not all) have these equations. Of course, it 
 might be more pleasing to play with the parameters.

 Etienne


 Mike Lawrence wrote:

 With skewed unimodal distributions, the mode can't equal the mean, so 
 assuming you want the mean to be around 30, I find that a weibull 
 function can get close to what you want:

 mean(rweibull(1e5,1.5,33))
 [1] 29.77781
 pweibull(60,1.5,33)
 [1] 0.9138475

 I'm sure you can play with the parameters to try to get even closer 
 to what you want.

 On Wed, Jun 10, 2009 at 2:48 AM, David 
 Arnolddwarnol...@suddenlink.net
 
 wrote:
 All,
 Can someone help me create a skewed distribution, mean = 30, with 
 probability of selecting a random number from the distribution 
 greater than or equal 60 equal to 10%?

 I need the probability density function to equal zero at zero, and 
 have  a maximum height at or near 30.

 Is this possible?

 And if it is possible, how can I adjust the distribution so that the 
 probability of selecting a random number greater than or equal to 60 
 is p.

 Thanks. No idea how to start.

 David



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




 --
 Mike Lawrence
 Graduate Student
 Department of Psychology
 Dalhousie University

 Looking to arrange a meeting? Check my public calendar:
 http://tr.im/mikes_public_calendar

 ~ Certainty is folly... I think. ~

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



 --
 View this message in context: 
 http://www.nabble.com/Creating-a-specific-skewed-distribution-tp239561
 14p23963140.html Sent from the R help mailing list archive at 
 Nabble.com.

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

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

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


[R] Two-sided log axis

2009-06-10 Thread John Wiedenhoeft
Hi,

I have two curves that are best displayed using a logarithmic y-axis. I want 
to plot the difference of these curves, which means I would need a log scaling 
on both the negative and the positive side (i.e. the y-axis should be -100 -10 
-1 0 1 10 100). Zero values should not be discarded.

Is there an easy way to do that?

Thanks,
John

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

2009-06-10 Thread David Winsemius
I would not have called such an axis logarithmic since the logarithm  
function is bounded below at 0, but I think that what you seek will be  
found among the examples that accompany Sarkar's book, chapter 8,  
figures 8.3 - 8.5:


http://lmdvr.r-forge.r-project.org/figures/figures.html


On Jun 10, 2009, at 12:05 PM, John Wiedenhoeft wrote:


Hi,

I have two curves that are best displayed using a logarithmic y- 
axis. I want
to plot the difference of these curves, which means I would need a  
log scaling
on both the negative and the positive side (i.e. the y-axis should  
be -100 -10

-1 0 1 10 100). Zero values should not be discarded.

Is there an easy way to do that?

Thanks,
John




David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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

2009-06-10 Thread David Winsemius


On Jun 10, 2009, at 12:23 PM, David Winsemius wrote:

I would not have called such an axis logarithmic since the  
logarithm function is bounded below at 0,


(I meant to say that arguments to log are bounded at zero.)

but I think that what you seek will be found among the examples that  
accompany Sarkar's book, chapter 8, figures 8.3 - 8.5:


http://lmdvr.r-forge.r-project.org/figures/figures.html


On Jun 10, 2009, at 12:05 PM, John Wiedenhoeft wrote:


Hi,

I have two curves that are best displayed using a logarithmic y- 
axis. I want
to plot the difference of these curves, which means I would need a  
log scaling
on both the negative and the positive side (i.e. the y-axis should  
be -100 -10

-1 0 1 10 100). Zero values should not be discarded.

Is there an easy way to do that?

Thanks,
John




David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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

2009-06-10 Thread José Ignacio Bustos Melo
Dear R-list,

Hi everyone, Im trying to make an analysis of multidimensional contingency
tables using R. I' working with the Agresti example where you have the
data from 3 categories. The thing is how can I do the analisys using the
G2 statistics. Somebody can send me an Idea?

I attach the program where you can find the data.
Best Regards,


 prob1- data.frame(victim=c(rep('white',4),rep('black',4)),
+ perp=c(rep('white',2),rep('black',2),rep('white',2),rep('black',2)),
+ death=rep(c('yes','no'),4), count=c(19,132,11,52,0,9,6,97))
 prob1
  victim  perp death count
1  white white   yes19
2  white whiteno   132
3  white black   yes11
4  white blackno52
5  black white   yes 0
6  black whiteno 9
7  black black   yes 6
8  black blackno97
 ftable(xtabs(count ~ victim + perp + death, data = prob1))
 death  no yes
victim perp
black  black97   6
   white 9   0
white  black52  11
   white   132  19




   O__   José Bustos Melo.
  c/ /'_ --- Master in Applied Statistics
 (*) \(*) -- B.S. in Marine Biology
-Science Faculty
-Catholic University of Concepcion
-Alonso de Ribera 2850 – Concepción, Casilla 297
-Cell phone: +56 9 9 5939144

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


Re: [R] Predict GARCH

2009-06-10 Thread bogaso.christofer
Suppose the GARCH(1,1) equation is :

Sigma[t]^2 = w + a* Sigma[t-1]^2 + b*r[t-1]^2

One step ahead forecast :
Sigma[t+1]^2 = w + a* Sigma[t]^2 + b*r[t]^2  All informations are available
here

Two step ahead forecast :
Sigma[t+2]^2 = w + a* Sigma[t+1]^2 + b*r[t+1]^2  
Here r[t+1] is not known at time t therefore is a r.v. Replacing this with
it's expected value as r[t+1]^2  = E[r[t+1]^2]  = sigma[t+1]^2, assuming
E[r[t+1]] = 0

Therefore Sigma[t+2]^2 = w + a* Sigma[t+1]^2 + b*r[t+1]^2  
   = w + a* Sigma[t+1]^2 + b* Sigma[t+1]^2
   = w + (a+b)* Sigma[t+1]^2

Carry on same procedure for next period forecast.
Hope this helps.


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Daniel Mail
Sent: 10 June 2009 18:55
To: r-help@r-project.org
Subject: [R] Predict GARCH



 



hello,
 
 
i was trying to predict values for a garch, so i did:
 
predict(fitgarch,n.ahead = 20)
 
but this doesn't work. Someone can tell me how to get the 20 values ahead of
a garch model.
 
 
thanks in advance


_
O Windows Live ajuda-o a manter-se em contacto com todos os seus amigos, num
ss local.
http://www.microsoft.com/portugal/windows/windowslive/products/social-networ
k-connector.aspx
[[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] is it possible to combine multiple barplots?

2009-06-10 Thread Philipp Schmidt
Thank you for the helpful reply! I am relatively new to R (the
software and the community) and was not aware of the example galler.
Now I am. The example you found looks very close to what I am trying
to do and I should be able to modify it.

Best - P

On Tue, Jun 9, 2009 at 4:45 PM, Titus von der
Malsburgmalsb...@gmail.com wrote:
 On Tue, Jun 09, 2009 at 04:39:29PM +0200, Titus von der Malsburg wrote:
  is there a way to plot both of them in one plot, so that the bars for
  value 1 (dataA: 3, dataB: 5) would appear side by side, followed by
  the bars for value 2 etc.?

 Oh, I see you want something different.  I should've read your message
 more closely.

 I found this example in the gallery:

    http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=54

 Maybe it's close enough to what you want to do.

  Titus





-- 
Sharing Nicely at www.bokaap.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] Analisys in Multidimensional contingency tables

2009-06-10 Thread Tobias Verbeke

Hi José,


Hi everyone, Im trying to make an analysis of multidimensional contingency
tables using R. I' working with the Agresti example where you have the
data from 3 categories. The thing is how can I do the analisys using the
G2 statistics. Somebody can send me an Idea?


Please find below a link to an R companion for Agresti by Laura Thompson

https://home.comcast.net/~lthompson221/Splusdiscrete2.pdf

There are chances you find the example you would like
to reproduce in there.

HTH,
Tobias

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 it possible to combine multiple barplots?

2009-06-10 Thread Ben Bolker



philipp schmidt-3 wrote:
 
 i am working with two sets of likert scale type (4 distinct values) data:
 
 dataA - rep(1:4, c(3,2,2,4))
 dataB - rep(1:4, c(5,4,3,2))
 
 i can now (bar)plot both of these separately and compare the
 distributions.
 
 plot(table(dataA), type='h')
 plot(table(dataB), type='h')
 
 is there a way to plot both of them in one plot, so that the bars for
 value 1 (dataA: 3, dataB: 5) would appear side by side, followed by
 the bars for value 2 etc.?
 
 

barplot(rbind(table(dataA),table(dataB)),beside=TRUE)

or see plotrix::multhist

-- 
View this message in context: 
http://www.nabble.com/is-it-possible-to-combine-multiple-barplots--tp23943970p23966848.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] Creating a specific skewed distribution

2009-06-10 Thread Ravi Varadhan

There are actually two roots to your equation: 0.329 and 1.385.

f - function(x) (2*gamma(1+1/x))^x + log (0.10)

x - seq(0.1, 5, length=500)

plot(x, fn(x), type=l)

abline(h = 0, lty=2, col=2)

Ravi.


---

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: rvarad...@jhmi.edu

Webpage:
http://www.jhsph.edu/agingandhealth/People/Faculty_personal_pages/Varadhan.h
tml

 





-Original Message-
From: Ravi Varadhan [mailto:rvarad...@jhmi.edu] 
Sent: Wednesday, June 10, 2009 11:53 AM
To: 'David Arnold'; 'Etienne B. Racine'
Cc: 'r-help@r-project.org'
Subject: RE: [R] Creating a specific skewed distribution

Here is one way to solve the equation:

require(BB)

f - function(x) (2*gamma(1+1/x))^x + log (0.10)
 
ans - dfsane(par=1, fn=f)
 
ans

Ravi.
 



---

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: rvarad...@jhmi.edu

Webpage:
http://www.jhsph.edu/agingandhealth/People/Faculty_personal_pages/Varadhan.h
tml

 





-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of David Arnold
Sent: Wednesday, June 10, 2009 11:25 AM
To: Etienne B. Racine
Cc: r-help@r-project.org
Subject: Re: [R] Creating a specific skewed distribution

Etienne et al,

This is exactly what I need. So I gave it an algebraic try and set:

Mean=30=b*gamma(1+1/a),

solve for b and substitute into F(60)=0.10. After a little algebra, this
left me with

[ 2*gamma(1+1/a) ]^a = -ln(0.10)

Now, I don't think this has a closed form solution, at least not one I have
the skill to find. So, how would I solve this using R?

David.

On Jun 10, 2009, at 7:09 AM, Etienne B. Racine wrote:


 You could also make some algebra. e.g. :

 ?rweibull

 gives the formula of the mean and of the cumulative distribution 
 function in the Details section. So using your known parameters (i.e.
 mean=30 and p(10)=.10, i.e. cumulative function(10) =.90), I think it 
 is sufficient to determine the exact values you want shape and scale 
 to be.

 And you can do that with any probability function (some easier the
 calculate) as most (if not all) have these equations. Of course, it 
 might be more pleasing to play with the parameters.

 Etienne


 Mike Lawrence wrote:

 With skewed unimodal distributions, the mode can't equal the mean, so 
 assuming you want the mean to be around 30, I find that a weibull 
 function can get close to what you want:

 mean(rweibull(1e5,1.5,33))
 [1] 29.77781
 pweibull(60,1.5,33)
 [1] 0.9138475

 I'm sure you can play with the parameters to try to get even closer 
 to what you want.

 On Wed, Jun 10, 2009 at 2:48 AM, David 
 Arnolddwarnol...@suddenlink.net
 
 wrote:
 All,
 Can someone help me create a skewed distribution, mean = 30, with 
 probability of selecting a random number from the distribution 
 greater than or equal 60 equal to 10%?

 I need the probability density function to equal zero at zero, and 
 have  a maximum height at or near 30.

 Is this possible?

 And if it is possible, how can I adjust the distribution so that the 
 probability of selecting a random number greater than or equal to 60 
 is p.

 Thanks. No idea how to start.

 David



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




 --
 Mike Lawrence
 Graduate Student
 Department of Psychology
 Dalhousie University

 Looking to arrange a meeting? Check my public calendar:
 http://tr.im/mikes_public_calendar

 ~ Certainty is folly... I think. ~

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



 --
 View this message in context: 
 http://www.nabble.com/Creating-a-specific-skewed-distribution-tp239561
 14p23963140.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 

[R] Extracting Sequence Data from a Vector

2009-06-10 Thread Eric Vander Wal

Thanks in advance.
I have a vector of numbers which contain sections that are sequences 
which increase by a value of 1 followed by a gap in the data and then 
another sequence occurs, etc:


x-c(1:3, 6: 7, 10:13)

From the vector I need to extract 2 items of information A) the first 
number in the sequence (e.g., 1, 6, 10) and B) how many observations 
were in each  sequence section (e.g., 3, 2, 4).


v1   v2
1  3
6  2
104

It seems simple, but my R skills are still in their infancy so I very 
much appreciate the help.

Eric

--
Eric Vander Wal
Ph.D. Candidate
University of Saskatchewan, Department of Biology,
112 Science Place, Saskatoon, SK., S7N 5E2

Pluralitas non est ponenda sine neccesitate

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

2009-06-10 Thread jim holtman
try this:

 x
[1]  1  2  3  6  7 10 11 12 13
 # find breaks
 breaks - c(FALSE, diff(x) != 1)
 # now create matrix with groupings (just for visual)
 z - data.frame(x, cumsum(breaks))
 # create list with first element of each seq and the length
 t(sapply(split(z, z[,2]), function(b) c(b[1,1], nrow(b
  [,1] [,2]
013
162
2   104


On Wed, Jun 10, 2009 at 1:28 PM, Eric Vander Wal eric.vander...@usask.cawrote:

 Thanks in advance.
 I have a vector of numbers which contain sections that are sequences which
 increase by a value of 1 followed by a gap in the data and then another
 sequence occurs, etc:

 x-c(1:3, 6: 7, 10:13)

 From the vector I need to extract 2 items of information A) the first
 number in the sequence (e.g., 1, 6, 10) and B) how many observations were in
 each  sequence section (e.g., 3, 2, 4).

 v1   v2
 1  3
 6  2
 104

 It seems simple, but my R skills are still in their infancy so I very much
 appreciate the help.
 Eric

 --
 Eric Vander Wal
 Ph.D. Candidate
 University of Saskatchewan, Department of Biology,
 112 Science Place, Saskatoon, SK., S7N 5E2

 Pluralitas non est ponenda sine neccesitate

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




-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?

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

2009-06-10 Thread Duncan Murdoch

On 6/10/2009 1:44 PM, kapo coulibaly wrote:

I'm trying to make sense of the following example in the package rgl:

 vertices - c(
 -1.0, -1.0, 0, 1.0,
  1.0, -1.0, 0, 1.0,
  1.0,  1.0, 0, 1.0,
 -1.0,  1.0, 0, 1.0
  )
  indices - c( 1, 2, 3, 4 )

  open3d()
  wire3d( qmesh3d(vertices,indices) )
One would think that each vertex would have 3 coordinates (x,y,z) what
does the fourth one in the definition of the variable vertices stand
for.


By default qmesh3d uses 4-coordinate homogeneous coordinates, because 
that's the coordinate system used by OpenGL.  See the ?rgl::matrices 
help topic for a description of how they work.


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] Extracting Sequence Data from a Vector

2009-06-10 Thread David Winsemius


On Jun 10, 2009, at 1:28 PM, Eric Vander Wal wrote:


Thanks in advance.
I have a vector of numbers which contain sections that are sequences  
which increase by a value of 1 followed by a gap in the data and  
then another sequence occurs, etc:


x-c(1:3, 6: 7, 10:13)

From the vector I need to extract 2 items of information A) the  
first number in the sequence (e.g., 1, 6, 10) and B) how many  
observations were in each  sequence section (e.g., 3, 2, 4).


v1   v2
1  3
6  2
104

It seems simple, but my R skills are still in their infancy so I  
very much appreciate the help.

Eric



Yet another solution:

 x[which(c(-Inf, diff(x)) != 1)]
[1]  1  6 10

 diff(c(which(c(-Inf, diff(x)) != 1), length(x)+1) )
[1] 3 2 4


--

David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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

2009-06-10 Thread baptiste auguie

jim holtman wrote:

try this:

  


Oh well, i spent the time writing this so i might as well post my 
(almost identical) solution,


x-c(1:3, 6: 7, 10:13)

breaks = c(TRUE, diff(x) != 1)

data.frame(start = x[breaks], length = tabulate(cumsum(breaks)))

Hoping this works,

baptiste



x


[1]  1  2  3  6  7 10 11 12 13
  

# find breaks
breaks - c(FALSE, diff(x) != 1)
# now create matrix with groupings (just for visual)
z - data.frame(x, cumsum(breaks))
# create list with first element of each seq and the length
t(sapply(split(z, z[,2]), function(b) c(b[1,1], nrow(b


  [,1] [,2]
013
162
2   104


On Wed, Jun 10, 2009 at 1:28 PM, Eric Vander Wal eric.vander...@usask.cawrote:

  

Thanks in advance.
I have a vector of numbers which contain sections that are sequences which
increase by a value of 1 followed by a gap in the data and then another
sequence occurs, etc:

x-c(1:3, 6: 7, 10:13)

From the vector I need to extract 2 items of information A) the first
number in the sequence (e.g., 1, 6, 10) and B) how many observations were in
each  sequence section (e.g., 3, 2, 4).

v1   v2
1  3
6  2
104

It seems simple, but my R skills are still in their infancy so I very much
appreciate the help.
Eric

--
Eric Vander Wal
Ph.D. Candidate
University of Saskatchewan, Department of Biology,
112 Science Place, Saskatoon, SK., S7N 5E2

Pluralitas non est ponenda sine neccesitate

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.htmlhttp://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] rgl vertices

2009-06-10 Thread kapo coulibaly
I'm trying to make sense of the following example in the package rgl:

 vertices - c(
 -1.0, -1.0, 0, 1.0,
  1.0, -1.0, 0, 1.0,
  1.0,  1.0, 0, 1.0,
 -1.0,  1.0, 0, 1.0
  )
  indices - c( 1, 2, 3, 4 )

  open3d()
  wire3d( qmesh3d(vertices,indices) )
One would think that each vertex would have 3 coordinates (x,y,z) what
does the fourth one in the definition of the variable vertices stand
for.

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.


[R] tracking progress of loading large dataset into R for updating progress bar

2009-06-10 Thread Harsh
Hello UseRs,

I am creating a GUI application in R using the RGtk2 library. I have
incorporated a progress bar which I want to refresh periodically in
keeping with the progress/completion of the read.csv function.
I would like to show the progress bar in animation (pulsing of the
bar) for as long as the read.csv function completes its task. I am not
sure how I can track the progress of the read.csv function.

As of now I just initialise the progress bar before the read.csv
function and show the completed bar after the read.csv function has
been executed.
Is there a way to access the data.frame object and check for its completeness?

Thank you for your feedback.

Cheers
Harsh Singhal
Bangalore, India

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] by and by: using two indices in by() or tapply()

2009-06-10 Thread christiaan pauw
Hi everyone
I want to apply a function by two indices.

I have a number of surveyors submitting questionnaires. I want to check the
time of the first submission for the day for each surveyor  and also see a
NA is no submission was done on a particular day.

This generates a sample of the data:

starttime=c(11:07:32,14:07:28,11:32:21,13:27:49,11:45:05,
12:30:06,10:27:07,10:18:07,15:29:36,16:29:23,13:46:45,10:45:26
,09:21:14,10:29:51,12:32:56,11:06:02,12:41:36,11:03:47,
10:58:12,10:05:54)

submitdate=c(2009-05-21,2009-06-02, 2009-05-12 ,2009-05-21,
2009-05-21, 2009-05-07, 2009-05-19 ,2009-05-13 ,2009-06-05,

2009-05-13, 2009-06-05, 2009-05-28, 2009-05-15, 2009-05-28,
2009-06-05, 2009-05-28, 2009-05-12, 2009-05-28,

2009-05-07, 2009-05-20)

surveyor=rep(LETTERS[1:4],5)

data=data.frame(surveyor, submitdate,starttime)


I can generate a list of the earliest submission per day:

tapply(starttime,submitdate,min)

or of the earliest submission per surveyor:

tapply(starttime,surveyor,min)

or of the number of submissions per surveyor day:

table(submitdate,surveyor)


But what I want is the time of the earliest submission per surveyor per day
(and NA's where applicable)


Can anyone offer some advice

Thanks

Christiaan

[[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] by and by: using two indices in by() or tapply()

2009-06-10 Thread Henrique Dallazuanna
Try this:

tapply(starttime,list(submitdate, surveyor),min)

On Wed, Jun 10, 2009 at 4:20 PM, christiaan pauw cjp...@gmail.com wrote:

 Hi everyone
 I want to apply a function by two indices.

 I have a number of surveyors submitting questionnaires. I want to check the
 time of the first submission for the day for each surveyor  and also see a
 NA is no submission was done on a particular day.

 This generates a sample of the data:

 starttime=c(11:07:32,14:07:28,11:32:21,13:27:49,11:45:05,

 12:30:06,10:27:07,10:18:07,15:29:36,16:29:23,13:46:45,10:45:26
 ,09:21:14,10:29:51,12:32:56,11:06:02,12:41:36,11:03:47,
 10:58:12,10:05:54)

 submitdate=c(2009-05-21,2009-06-02, 2009-05-12 ,2009-05-21,
 2009-05-21, 2009-05-07, 2009-05-19 ,2009-05-13 ,2009-06-05,

 2009-05-13, 2009-06-05, 2009-05-28, 2009-05-15, 2009-05-28,
 2009-06-05, 2009-05-28, 2009-05-12, 2009-05-28,

 2009-05-07, 2009-05-20)

 surveyor=rep(LETTERS[1:4],5)

 data=data.frame(surveyor, submitdate,starttime)


 I can generate a list of the earliest submission per day:

 tapply(starttime,submitdate,min)

 or of the earliest submission per surveyor:

 tapply(starttime,surveyor,min)

 or of the number of submissions per surveyor day:

 table(submitdate,surveyor)


 But what I want is the time of the earliest submission per surveyor per day
 (and NA's where applicable)


 Can anyone offer some advice

 Thanks

 Christiaan

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




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

[[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] Delta in time series

2009-06-10 Thread christiaan pauw
Or

x=c(2009-03-09 12:00:00,2009-03-09 13:30:00)

y=data.frame(x)

attach(y)

x=as.POSIXlt(x)

x[1]-x[2]

On Wed, Jun 10, 2009 at 5:04 AM, kojjens.k...@gmx.li wrote:
 
 
  I have time data in the following format:
 
  2009-03-09 12:00:00
  2009-03-09 13:30:00
 
 


[[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] GeoXp package

2009-06-10 Thread Zeljko Vrba
On Wed, Jun 10, 2009 at 08:21:06AM +0200, Poizot Emmanuel wrote:
 Error in fun(...) :
GDAL Error 1: libgrass_I.so: Ne peut ouvrir le fichier d'objet 
 partagé: Aucun fichier ou dossier de ce type  (sorry  for the french :) )
 

It would have been far more useful had you translated the error message to
english than to have apologized.

Try doing

export LD_LIBRARY_PATH=/path/to/dir/where/so/is/located

before starting R from the shell.

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

2009-06-10 Thread Derek Lacoursiere

I have a list of polygons generated by the contourLines() command (each
object of the list is a list in itself with two objects: a vector of x
values, and a vector of y values for each vertex).  I wish to convert that
list into a gpc.poly object of multiple contours.  How do I do this?  gpclib
apparently has no method of coercing lists into the gpc.poly object type.  
As well, when I have a gpc.poly object, I can view the points using the
get.pts() command, but cannot find a way of only extracting the x values of
a polygon (or the y values, for that matter).  How do I do this?
Any help would be greatly appreciated
-- 
View this message in context: 
http://www.nabble.com/gpc.poly-datatype-tp23967664p23967664.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] Predict GARCH

2009-06-10 Thread Liviu Andronic
Hello,

On 6/10/09, Daniel Mail d20...@live.com.pt wrote:
  i was trying to predict values for a garch, so i did:

  predict(fitgarch,n.ahead = 20)

  but this doesn't work. Someone can tell me how to get the 20 values ahead of 
 a garch model.

You didn't specify what function you used to obtain the GARCH model.
If you use rgarch [1], it provides functions for forecasting
step-ahead values.
Liviu


[1] http://rgarch.r-forge.r-project.org/index.html

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

2009-06-10 Thread Stefo Ratino

Hi,
Are there any nonparametric test for ordinal categorical data for row of a 
matrix?
 
Thank you very much,
Stefo


  
[[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] Difficulties with the simpest table

2009-06-10 Thread Dmitry Gospodaryov

I have the data arranged in table (in Excel, or Notepad):

x   y

0   100
2   100
4   80
6   40
8   0

I need to transfer these data in R file and then going to
operate with x and y as with variables. I should note, that I have
2.8.1 version. Thank you for advance.

  With regard, Dmitry.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 extract from a matrix based on indices in a vector?

2009-06-10 Thread Logickle

Sorry, there may be some lingo for describing the extraction problem I have,
but I don't know it. 

I have a matrix of 2 rows and N columns, and a vector of N 1s and 2s. 

Matrix M: 

  1 2 3  4   ...  N 
1A C D  G  ... 
2B D F  H   ... 

Vector v: 

1  2  2  1  2  1  1 ... N 

I'd like to apply v to M to get 

Vector w: 

A  D  F  G ... 

I.e. each element of v is interpreted as a row-index used to extract that
row's value from the corresponding column in M into the corresponding column
of w.   

Also eventually nrow(M)  2, in which case the value of the elements of v
would range over 1:nrow(M). 

Seems it should be simple, but maybe not? 

Thanks! 

Doug

PS : I originally posted this on R devel, then realized my mistake. Move
thread didn't work when I tried it, though.
-- 
View this message in context: 
http://www.nabble.com/How-to-extract-from-a-matrix-based-on-indices-in-a-vector--tp23967316p23967316.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] problem with PCA loading plot

2009-06-10 Thread Fireblast

Hi,

I am a beginner with R. I would like to get a loading plot of PC 3 vs PC 1.

For PC 1 vs PC 2 I use 

library(pls)
loadingplot(pca.result, comps = 1:2, scatter = TRUE, labels=names)


if I try

loadingplot(pca.result, comps = 1:3, scatter = TRUE, labels=names)

I get the loading plots of PC 1 vs PC 2, PC 1 vs PC 3 and PC 2 vs PC 3. What
do I have to do to get just a single loading plot of PC 3 vs PC 1.

Thanks for your help in advance !
-- 
View this message in context: 
http://www.nabble.com/problem-with-PCA-loading-plot-tp23967169p23967169.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] Vista + R = *!!?@

2009-06-10 Thread John Townsend-Mehler

Hello People of R,

Is there any way that I can get R to function properly using 
Vista.  I get very strange output using lmer, as in no p-values.  Is 
there ANY way I can fix this.


Thank you for your time,

John Townsend-Mehler
PhD Candidate
Department of Zoology
Michigan State University

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Vista + R = *!!?@

2009-06-10 Thread Marc Schwartz


On Jun 10, 2009, at 1:57 PM, John Townsend-Mehler wrote:


Hello People of R,

Is there any way that I can get R to function properly using Vista.   
I get very strange output using lmer, as in no p-values.  Is there  
ANY way I can fix this.




That's not a Vista issue, it is a statistical theory issue. See the  
following R FAQ:


http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-are-p_002dvalues-not-displayed-when-using-lmer_0028_0029_003f

HTH,

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] Difficulties with the simpest table

2009-06-10 Thread Liviu Andronic
Hello Dmitry,

On 6/10/09, Dmitry Gospodaryov gospodar...@rambler.ru wrote:
 I have the data arranged in table (in Excel, or Notepad):

 x   y

 0   100
 2   100
 4   80
 6   40
 8   0

  I need to transfer these data in R file and then going to
  operate with x and y as with variables. I should note, that I have
  2.8.1 version. Thank you for advance.

To beginners I often suggest to try Rcmdr, which is a graphical
interface to R that smooths the transition to R. In your specific case
I would export the data from Excel to a .csv file, and then import it
using the Data  Import data  from text file menu in Rcmdr.
Afterwards, you can manipulate the data either using the command line
or Rcmdr's statistical menus.
Liviu

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Preventing .Call from printing a blank line to the R console on Windows

2009-06-10 Thread Joel
Hello everyone,

I am using the CVODES integrator in the Rsundials package.  Every time
I call the integrator, a blank line is printed in the console.  Using
debug, I was able to isolate the problem to this line in the function
cvodes(...):

solutions = .Call(cvodes, PACKAGE = Rsundials, as.double(y), ...

Since I am running the integrator thousands of times, I wind up with
thousands of blank lines.  This makes it hard to print out periodic
updates from a for loop; they are lost among all the blank lines!

Is it somehow possible to stop this .Call command from printing a
blank line?

Thank you for your help.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Difficulties with the simpest table

2009-06-10 Thread Marc Schwartz

On Jun 10, 2009, at 11:27 AM, Dmitry Gospodaryov wrote:


I have the data arranged in table (in Excel, or Notepad):

x   y

0   100
2   100
4   80
6   40
8   0

I need to transfer these data in R file and then going to
operate with x and y as with variables. I should note, that I have
2.8.1 version. Thank you for advance.



Dmitry,

There is a complete R manual that describes how to get data into and  
out of R, called R Data Import/Export. It is available within your R  
distribution (if on Windows, via the R menus) or on the R web site at:


  http://cran.r-project.org/manuals.html

There is also a page on the R Wiki at:

  http://wiki.r-project.org/rwiki/doku.php?id=tips:data-io:ms_windows

which specifically covers R and Windows/Excel data exchange.

A quick example, if the above is in Notepad, but with NO BLANK LINE  
between the x and y labels and the data. You can highlight the text,  
press CTRL-C to copy it to the clipboard and then use the following in  
R (see ?read.table):


  DF - read.table(clipboard, header = TRUE)

That will give you a 'data frame' in R that contains the two columns,  
which can then be addressed as DF$x and DF$y. Further information is  
available in the R manual An Introduction to R.


HTH,

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.


[R] Performance Data Analysis Class using R

2009-06-10 Thread Red Roo

  GUERRILLA DATA ANALYSIS TECHNIQUES (GDAT)
   http://www.perfdynamics.com/Classes/Outlines/gdata.html
 with an emphasis on R and PDQ-R modeling tools
   http://www.perfdynamics.com/Tools/PDQ-R.html
  
   August 10-14

   Instructors: Prof. David Lilja, Mr. Jim Holtman and Dr. Neil Gunther
  ==

LOCATION

 PLACE: Larkspur Landing, Pleasanton, in sunny California
 http://www.larkspurlanding.com/hotels/pleasanton/index.html
 RATES: See the schedule page for the special hotel room
 rates. http://www.perfdynamics.com/Classes/schedule.html

 *IMPORTANT   *
 You must make your own hotel reservations online at the special 
 group page set up the Larkspur Landing hotel. See our Schedule page 
 http://www.perfdynamics.com/Classes/schedule.html for the links.
 Since this is a new hotel, if you run into difficulties, please call
 them at 925-463-1212 and identify yourself as a Performance Dynamics 
enrollee.
  ==
 FOOD: Breakfast, lunch, and coffee breaks are included in the price.
[[elided Yahoo spam]]

ONLINE REGISTRATION
===
 Register http://www.perfdynamics.com/regofax.html
 Contact  http://www.perfdynamics.com/contact.html
  
 FON: 530-873-0575  FAX: 530-873-6697  EMAIL: clas...@perfdynamics.com
 
 We accept AMEX, VISA and MASTERCARD. Corporate discounts are available for
 enrollments of 3 or more. Registration processing may take up to 24
 hours. All emails, faxes and phone calls will be acknowledged.
 Thanks for your patience.
___

PERFORMANCE DYNAMICS COMPANY(sm)  http://www.perfdynamics.com/
___

Consulting Services   Educational Services
4061 East Castro Valley Blvd. P.O. Box 1238, Magalia
Suite 110, Castro Valley  California 95954, USA
California 94552, USA Bookings and registrations
FON: +1-510-537-5758  FON: +1-530-873-0575
FAX: Dial FON (Handshakes automagically)  FAX: +1-530-873-6697
NET: i...@perfdynamics.comNET: clas...@perfdynamics.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] Comparing R and SAs

2009-06-10 Thread jude.ryan
Satish,

 

For a comparison of SAS and S, see the document An Introduction to S
and the Hmisc and Design Libraries by Carlos Alzola and Frank E.
Harrell. Frank Harrell is an expert in both SAS and R. You can download
this document from http://www.r-project.org/, then click on manuals, and
then contributed documentation. You can also look at the document
written by Bob Muenchen (at http://RforSASandSPSSusers.com
http://rforsasandspssusers.com/  (also a book published by Springer
Verlag) for a comparison of SAS and R (and SPSS).

 

I have been using both SAS and R. While my primary expertise is mainly
in SAS, I have been using R more and more relative to SAS as my
familiarity with it grows. From my point of view, cutting edge
methodologies will always be implemented first in R (as you pointed out
as well). SAS will follow several years later with some of these
methodologies. Also, SAS has different products and users may not have
all SAS products. Many firms have SAS/STAT but not other SAS products
like SAS/ETS (economic time series), SAS/Enterpriser Miner or SAS/GRAPH.
So in these situations R may be your only option. Even if you have these
other SAS products you can do things more rapidly in R, if you take the
time to learn it well, than you can with SAS. I have SAS/Enterprise
Miner but still prefer R for neural networks, splines, decision trees,
etc., as I can program R to produce several neural networks, etc. using
for loops. SAS/Enterprise Miner cannot be programmed. R graphs are
definitely superior to SAS graphics, and can be programmed very easily.
I also use R for EDA (exploratory data analysis) prior to building
predictive models/data mining.

 

One area where SAS still excels is in processing huge files (over 30 GB
in size - online data from vendors like double click with literally
billions of records). But for statistical analysis you generally don't
need to work with such large volumes of data. A much smaller random
sample should suffice. If you have R running on Unix or Linux 64-bit
operating systems (or Windows Vista?) and huge amounts of RAM handling
large datasets in R is less of an issue. Also, if your data resides on
mainframes, SAS is probably your only choice if you cannot download the
mainframe data to your PC. I use R on a 32-bit Windows operating system
with 3 GB of RAM, and I have not had any problem doing statistical
analysis/data mining with R on around 25,000 or so records with anywhere
from 25 to 50 variables.

 

Hope this helps.

 

Jude

 

Satish wrote:

 

Hi:

For those of you who are adept at both SAS and R, I have the following
questions:

 

a) What are some reasons / tasks for which you would use R over SAS and
vice versa?

b) What are some things for which R is a must have that SAS cannot
fulfill the requirements?

 

I am on the ramp up on both of them. The general feeling that I am
getting by following this group is that R updates to the product are at
a much faster pace and therefore, this would be better for someone who
wants the bleeding edge (correct me if I am wrong). But I am also
interested in what is inherently better in R that SAS cannot offer
perhaps because of the design.

 

Thanks.

Satish

 

 

___
Jude Ryan
Director, Client Analytical Services
Strategy  Business Development
UBS Financial Services Inc.
1200 Harbor Boulevard, 4th Floor
Weehawken, NJ 07086-6791
Tel. 201-352-1935
Fax 201-272-2914
Email: jude.r...@ubs.com



Please do not transmit orders or instructions regarding a UBS 
account electronically, including but not limited to e-mail, 
fax, text or instant messaging. The information provided in 
this e-mail or any attachments is not an official transaction 
confirmation or account statement. For your protection, do not 
include account numbers, Social Security numbers, credit card 
numbers, passwords or other non-public information in your e-mail. 
Because the information contained in this message may be privileged, 
confidential, proprietary or otherwise protected from disclosure, 
please notify us immediately by replying to this message and 
deleting it from your computer if you have received this 
communication in error. Thank you. 

UBS Financial Services Inc. 
UBS International Inc. 
UBS Financial Services Incorporated of Puerto Rico 
UBS AG

 
UBS reserves the right to retain all messages. Messages are protected
and accessed only in legally justified cases.__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] gpc.poly datatype

2009-06-10 Thread Duncan Murdoch

On 10/06/2009 1:53 PM, Derek Lacoursiere wrote:

I have a list of polygons generated by the contourLines() command (each
object of the list is a list in itself with two objects: a vector of x
values, and a vector of y values for each vertex).  I wish to convert that
list into a gpc.poly object of multiple contours.  How do I do this?  gpclib
apparently has no method of coercing lists into the gpc.poly object type.  
As well, when I have a gpc.poly object, I can view the points using the

get.pts() command, but cannot find a way of only extracting the x values of
a polygon (or the y values, for that matter).  How do I do this?
Any help would be greatly appreciated


After running example(contourLines), this comes close:

lines - contourLines(x,y,volcano)
pts - lapply(lines, function(line) list(x=line$x, y=line$y, hole=F))
gp - new(gpc.poly, pts=pts)

It is not quite right because some of the contours are incomplete, and 
this joins them up, but it should give you the idea.  I don't know how 
gpc.poly handles partial polygons.


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] Preventing .Call from printing a blank line to the R console on Windows

2009-06-10 Thread Duncan Murdoch

On 10/06/2009 5:16 PM, Joel wrote:

Hello everyone,

I am using the CVODES integrator in the Rsundials package.  Every time
I call the integrator, a blank line is printed in the console.  Using
debug, I was able to isolate the problem to this line in the function
cvodes(...):

solutions = .Call(cvodes, PACKAGE = Rsundials, as.double(y), ...

Since I am running the integrator thousands of times, I wind up with
thousands of blank lines.  This makes it hard to print out periodic
updates from a for loop; they are lost among all the blank lines!

Is it somehow possible to stop this .Call command from printing a
blank line?


The best way is to fix the package so it doesn't do that, but a 
workaround using capture.output() or sink() is probably possible.


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] How to extract from a matrix based on indices in a vector?

2009-06-10 Thread Marc Schwartz


On Jun 10, 2009, at 12:36 PM, Logickle wrote:



Sorry, there may be some lingo for describing the extraction problem  
I have,

but I don't know it.

I have a matrix of 2 rows and N columns, and a vector of N 1s and 2s.

Matrix M:

 1 2 3  4   ...  N
1A C D  G  ...
2B D F  H   ...

Vector v:

1  2  2  1  2  1  1 ... N

I'd like to apply v to M to get

Vector w:

A  D  F  G ...

I.e. each element of v is interpreted as a row-index used to extract  
that
row's value from the corresponding column in M into the  
corresponding column

of w.

Also eventually nrow(M)  2, in which case the value of the elements  
of v

would range over 1:nrow(M).

Seems it should be simple, but maybe not?

Thanks!

Doug


Doug,

Try this:

# M is a character matrix
 M
  1   2   3   4
1 A C D G
2 B D F H

# v is a vector, equal in length to the number of columns in M
 v
[1] 1 2 2 1

# Get the diagonal of the matrix that results from the combinations of  
indices

 diag(M[v, 1:ncol(M)])
[1] A D F G


I created a larger 2 row matrix to test further:

set.seed(1)
M - matrix(sample(LETTERS, 40, replace = TRUE), 2, 20)

 M
 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
[1,] G  O  F  Y  Q  F  R  U  S  J   Y   Q
[2,] J  X  X  R  B  E  J  M  Z  U   F   D
 [,13] [,14] [,15] [,16] [,17] [,18] [,19] [,20]
[1,] G   A   W   M   M   V   U   S
[2,] K   J   I   P   E   R   C   K


and 'v':

set.seed(2)
v - sample(2, 20, replace = TRUE)

 v
 [1] 1 2 2 1 2 2 1 2 1 2 2 1 2 1 1 2 2 1 1 1


Then:

 diag(M[v, 1:ncol(M)])
 [1] G X X Y B E R M S U F Q K A W P  
E

[18] V U S


Looks like it might work.

HTH,

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] How to extract from a matrix based on indices in a vector?

2009-06-10 Thread Marc Schwartz


On Jun 10, 2009, at 6:26 PM, Marc Schwartz wrote:



On Jun 10, 2009, at 12:36 PM, Logickle wrote:



Sorry, there may be some lingo for describing the extraction  
problem I have,

but I don't know it.

I have a matrix of 2 rows and N columns, and a vector of N 1s and 2s.

Matrix M:

1 2 3  4   ...  N
1A C D  G  ...
2B D F  H   ...

Vector v:

1  2  2  1  2  1  1 ... N

I'd like to apply v to M to get

Vector w:

A  D  F  G ...

I.e. each element of v is interpreted as a row-index used to  
extract that
row's value from the corresponding column in M into the  
corresponding column

of w.

Also eventually nrow(M)  2, in which case the value of the  
elements of v

would range over 1:nrow(M).

Seems it should be simple, but maybe not?

Thanks!

Doug


Doug,

Try this:

# M is a character matrix
 M
 1   2   3   4
1 A C D G
2 B D F H

# v is a vector, equal in length to the number of columns in M
 v
[1] 1 2 2 1

# Get the diagonal of the matrix that results from the combinations  
of indices

 diag(M[v, 1:ncol(M)])
[1] A D F G


I created a larger 2 row matrix to test further:

set.seed(1)
M - matrix(sample(LETTERS, 40, replace = TRUE), 2, 20)

 M
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
[1,] G  O  F  Y  Q  F  R  U  S  J   Y   Q
[2,] J  X  X  R  B  E  J  M  Z  U   F   D
[,13] [,14] [,15] [,16] [,17] [,18] [,19] [,20]
[1,] G   A   W   M   M   V   U   S
[2,] K   J   I   P   E   R   C   K


and 'v':

set.seed(2)
v - sample(2, 20, replace = TRUE)

 v
[1] 1 2 2 1 2 2 1 2 1 2 2 1 2 1 1 2 2 1 1 1


Then:

 diag(M[v, 1:ncol(M)])
[1] G X X Y B E R M S U F Q K A W P  
E

[18] V U S


Looks like it might work.




Actually, the solution can be simplified further:

# Using the second 'M':

 diag(M[v, ])
[1] G X X Y B E R M S U F Q K A W P E
[18] V U S

Marc

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] smooth.spline() fucntion

2009-06-10 Thread array chip

Hi, all, I found that the smooth.spline() function produces different results 
between R and S-Plus. I was trying to play different parameters of the function 
without any success. The script of the function contains Fortran code, so it 
seems impossible to port the code from S-Plus to R (or I may be wrong). Can 
anyone suggest anything so that I can produce the same result in R as in 
S-plus? 

Thanks

John

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 extract from a matrix based on indices in a vector?

2009-06-10 Thread William Dunlap
Subscripting by a 2-column matrix 
   M[cbind(v, seq_len(ncol(M)))]
uses much less space (hence time) than making
the ncol(M) by ncol(M) intermediate matrix just
to extract its diagonal.  E.g.

test - function(n, seed) {
   if (!missing(seed))
  set.seed(seed)
   M - matrix(sample(LETTERS, 2*n, replace = TRUE), 2)
   v - sample(2, n, replace=T)
   t1-system.time(r1-M[cbind(v,seq_len(ncol(M)))])
   t2-system.time(r2-diag(M[v, 1:ncol(M)]))
   list(identical=identical(r1,r2), time(matrix subscript)=t1,
time(diag(big matrix))=t2)
}

  test(100)
$identical
[1] TRUE

$`time(matrix subscript)`
   user  system elapsed
  0.000   0.000   0.001

$`time(diag(big matrix))`
   user  system elapsed
  0.001   0.000   0.001

 test(1000)
$identical
[1] TRUE

$`time(matrix subscript)`
   user  system elapsed
  0.000   0.000   0.001

$`time(diag(big matrix))`
   user  system elapsed
  0.082   0.021   0.103

 test(5000)
$identical
[1] TRUE

$`time(matrix subscript)`
   user  system elapsed
  0.001   0.000   0.001

$`time(diag(big matrix))`
   user  system elapsed
  3.379   0.552   3.932


Bill Dunlap
TIBCO Software Inc - Spotfire Division
wdunlap tibco.com  

 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of Marc Schwartz
 Sent: Wednesday, June 10, 2009 4:42 PM
 To: Logickle
 Cc: rhelp help
 Subject: Re: [R] How to extract from a matrix based on 
 indices in a vector?
 
 
 On Jun 10, 2009, at 6:26 PM, Marc Schwartz wrote:
 
 
  On Jun 10, 2009, at 12:36 PM, Logickle wrote:
 
 
  Sorry, there may be some lingo for describing the extraction  
  problem I have,
  but I don't know it.
 
  I have a matrix of 2 rows and N columns, and a vector of N 
 1s and 2s.
 
  Matrix M:
 
  1 2 3  4   ...  N
  1A C D  G  ...
  2B D F  H   ...
 
  Vector v:
 
  1  2  2  1  2  1  1 ... N
 
  I'd like to apply v to M to get
 
  Vector w:
 
  A  D  F  G ...
 
  I.e. each element of v is interpreted as a row-index used to  
  extract that
  row's value from the corresponding column in M into the  
  corresponding column
  of w.
 
  Also eventually nrow(M)  2, in which case the value of the  
  elements of v
  would range over 1:nrow(M).
 
  Seems it should be simple, but maybe not?
 
  Thanks!
 
  Doug
 
  Doug,
 
  Try this:
 
  # M is a character matrix
   M
   1   2   3   4
  1 A C D G
  2 B D F H
 
  # v is a vector, equal in length to the number of columns in M
   v
  [1] 1 2 2 1
 
  # Get the diagonal of the matrix that results from the 
 combinations  
  of indices
   diag(M[v, 1:ncol(M)])
  [1] A D F G
 
 
  I created a larger 2 row matrix to test further:
 
  set.seed(1)
  M - matrix(sample(LETTERS, 40, replace = TRUE), 2, 20)
 
   M
  [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
  [1,] G  O  F  Y  Q  F  R  U  S  J   Y   Q
  [2,] J  X  X  R  B  E  J  M  Z  U   F   D
  [,13] [,14] [,15] [,16] [,17] [,18] [,19] [,20]
  [1,] G   A   W   M   M   V   U   S
  [2,] K   J   I   P   E   R   C   K
 
 
  and 'v':
 
  set.seed(2)
  v - sample(2, 20, replace = TRUE)
 
   v
  [1] 1 2 2 1 2 2 1 2 1 2 2 1 2 1 1 2 2 1 1 1
 
 
  Then:
 
   diag(M[v, 1:ncol(M)])
  [1] G X X Y B E R M S U F Q K A 
 W P  
  E
  [18] V U S
 
 
  Looks like it might work.
 
 
 
 Actually, the solution can be simplified further:
 
 # Using the second 'M':
 
   diag(M[v, ])
 [1] G X X Y B E R M S U F Q K A 
 W P E
 [18] V U S
 
 Marc
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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 extract from a matrix based on indices in a vector?

2009-06-10 Thread Marc Schwartz

On Jun 10, 2009, at 7:05 PM, William Dunlap wrote:


Subscripting by a 2-column matrix
  M[cbind(v, seq_len(ncol(M)))]
uses much less space (hence time) than making
the ncol(M) by ncol(M) intermediate matrix just
to extract its diagonal.  E.g.

test - function(n, seed) {
  if (!missing(seed))
 set.seed(seed)
  M - matrix(sample(LETTERS, 2*n, replace = TRUE), 2)
  v - sample(2, n, replace=T)
  t1-system.time(r1-M[cbind(v,seq_len(ncol(M)))])
  t2-system.time(r2-diag(M[v, 1:ncol(M)]))
  list(identical=identical(r1,r2), time(matrix subscript)=t1,
time(diag(big matrix))=t2)
}


test(100)

$identical
[1] TRUE

$`time(matrix subscript)`
  user  system elapsed
 0.000   0.000   0.001

$`time(diag(big matrix))`
  user  system elapsed
 0.001   0.000   0.001


test(1000)

$identical
[1] TRUE

$`time(matrix subscript)`
  user  system elapsed
 0.000   0.000   0.001

$`time(diag(big matrix))`
  user  system elapsed
 0.082   0.021   0.103


test(5000)

$identical
[1] TRUE

$`time(matrix subscript)`
  user  system elapsed
 0.001   0.000   0.001

$`time(diag(big matrix))`
  user  system elapsed
 3.379   0.552   3.932




Nicely done comparison Bill.

Thanks,

Marc

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 extract from a matrix based on indices in a vector?

2009-06-10 Thread David Winsemius


On Jun 10, 2009, at 1:36 PM, Logickle wrote:



Sorry, there may be some lingo for describing the extraction problem  
I have,

but I don't know it.

I have a matrix of 2 rows and N columns, and a vector of N 1s and 2s.

Matrix M:

 1 2 3  4   ...  N
1A C D  G  ...
2B D F  H   ...

Vector v:

1  2  2  1  2  1  1 ... N

I'd like to apply v to M to get

Vector w:

A  D  F  G ...


Using length 10 M and v

 w - apply(cbind(v, 1:length(v) ), 1, function(x) M[x[1], x[2] ])
 [1] A D F G I K N P R S

 M - matrix(LETTERS[1:20], nrow=2)
 M
 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,] A  C  E  G  I  K  M  O  Q  S
[2,] B  D  F  H  J  L  N  P  R  T
 v - c(1,2,2,1, sample(1:2, 6, replace=TRUE) )
 v
 [1] 1 2 2 1 1 1 2 2 2 1

The number of rows in M should not be a problem.



I.e. each element of v is interpreted as a row-index used to extract  
that
row's value from the corresponding column in M into the  
corresponding column

of w.

Also eventually nrow(M)  2, in which case the value of the elements  
of v

would range over 1:nrow(M).

Seems it should be simple, but maybe not?


Seems reasonably simple.

David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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

2009-06-10 Thread Caroline Gideon-Adeniyi
Hi

I don't know if you can help. I am a 2nd year Bsc Cosmetic Science student and 
in R I need some help in drawing stars.

The problem that I have is I want to recreate a radar diagram similar to the 
one in excel.

I have put in these commands in a script window:

 stars(shampoo1[, 1:6], locations = c(0,0), radius = TRUE,
  key.loc=c(0,0),
  main = Ranked Results for the Sensory Evaluation of the Shampoo ,
  frame.plot = TRUE,
  key.labels = c(Foam Texture, Skin Feel, Rinisability, Wet 
Combability, Wet Feel, Odour),
  lty = 2,
)

This gives me a black and white radar which is fine.

Now according to the reference manual to colour the stars i need to add:

col.stars = rainbow (30)

Which colours in each star segment. The problem I have with this is that the 
segments are filled with colour and the segments overlap each other and each 
segment is not visible.

So I desperately need the command that only colours the outline of the segments 
or stars instead of  filling it.

Can u help?

Thank  You

Caroline

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


  1   2   >