Re: [R] re ading tokens

2009-11-03 Thread Dieter Menne



j daniel wrote:
 
 I am not familiar with processing text in R.  Can someone tell me how to
 read each line of words as separate elements in a list?
 
 FE, I would like to turn:
 
 word1 word2 word3
 word2 word4
 
 into a list of length two with three character elements in the first list
 and two elements in the second.  I know that this should be easy, but I am
 a little confused by the text functions.
 

You could use scan. Have a look at package gsubfn, where there is a demo,
that show additional features you are going to use

library(gsubfn)
demo(gsubfn-gries)


The example code is a bit overnested, but to better understand what is going
on, unwrap it:

So 
 tail(sort(table(unlist(strapply(Lines1, \\w+, perl = TRUE)

is:

x1 = strapply(Lines1, \\w+, perl = TRUE)
x1
x2 = ulist(x2)
x2
x3 = table(x2)
x3
x4 = sort(x3)
x4
tail(x4)



Dieter




-- 
View this message in context: 
http://old.nabble.com/reading-tokens-tp26159931p26160018.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] fill map with gradient: package?

2009-11-03 Thread Thomas Steiner
Hi,
I'd like to fill an existing svg (or png) map with gradient colors.
In detail: The file
http://commons.wikimedia.org/wiki/File:Karte_%C3%96sterreich_Bundesl%C3%A4nder.svg
should be filled with the population density data from this table:
http://de.wikipedia.org/wiki/%C3%96sterreich#Verwaltungsgliederung
choosing the right color saturation (or whatever). The final result
should be something like this map:
http://commons.wikimedia.org/wiki/Image:Bevoelkerungsdichte_-_Oesterreich.svg
Is there a package or so for these two tasks (filling and color
density ploting)?
Thanks for your help,
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] Graph to show very few classes has maximum best performers

2009-11-03 Thread Sunita22

Hello

I need help for the following:

my data is
class no.   best performers
101 10
102 21
103 1
104 3
105 5
106 190
... ...
... ...
... ...
... ...
... ...

I want to plot a graph using R, to show that very few classes has maximum
best performers. can someone guide me for this? I tried using cumulative
frequencies and then plotting a graph but it does not serve the purpose. 

Thank you in advance

Regards,
Sunita
-- 
View this message in context: 
http://old.nabble.com/Graph-to-show-very-few-classes-has-maximum-best-performers-tp26160026p26160026.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] R2WinBUGS and R-2.10.0: The school example not running

2009-11-03 Thread Luwis Tapiwa Diya
Dear R users

I have been encountering an error (in the Winbugs window: Blackbox - index
out of range . ). So to me it seems R2WinBUGS is not linking up well
with the new R version since the same model runs well under r-2.9.2. So is
my assumption correct or am I doing something wrong. The data I used and the
code are in the help of R2WinBUGS (?bugs).


Regards,

-- 
Luwis Diya,
Leuven Biostatistics and Statistical Bioinformatics Centre (L-BioStat),
Kapucijnenvoer 35 blok d - bus 7001,
3000 Leuven,
Belgium

Tel: +32 16 336886 or +32 16 336892
Fax: +32 16 337015

[[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] why is adnonis function called adonis {packageveg an}

2009-11-03 Thread Jari Oksanen
stvienna wiener stvienna at gmail.com writes:

 
 I used google and looked at the documentation to find out why the
 ADONIS function
 is called adonis (in the vegan package).
 
Because it is ANOSIM resurrected?

The background is that vegan already had function anosim() which should come
from ANOSIM = Analysis of Similarities. However, like all R stuff, it actually
used dissimilarities and so should be called anodis() to be linguistically
correct. When Hank Stevens started to write current adonis(), the first working
versions were called anodis(), but that was that was confusing when anosim()
alreaded handled dissimilarities. So there was a nifty swap of letters to give
us adonis(), and that stuck.

By the way, Peter Solymos wrote a metafunction using adonis(), and he called
that function persephone(). We haven't released that (yet).

Cheap thrills, but thrills anyway (and I can't afford expensive thrills). 

 I am writing a document and would like to include a
 abbreviation list (similar to ANOSIM = Analysis of Similarities).
 
Just go on. However, the name of the function is not necessarily the acronym of
the method.

Cheers, Jari Oksanen

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

2009-11-03 Thread eduardo san miguel
Hello Iuri,

Code sent is a sample with basic functionality from the package I´m
due to send to CRAN. Final package allows inteactivity (dragging and
selecting points, zooming in/out fisheye effect, ...) and full
exploration of the hyperbolic-alike space simulated.

Example sent just give you a taste of the visual methaphor
implemented, as described in
http://www.antsearch.univ-tours.fr/publi/DacVenADMA2006.pdf

Plot generated with sample code allows you to analize the way kmeans
have worked. You are plotting every point in the sample and six groups
appear clearly (groups in the sample are so intragroup homogeneus that
in most cases you will see six points plotted).

Regards,

Eduardo San Miguel Martin
BI Consultant


2009/11/2 Iuri Gavronski i...@ufrgs.br:
 David, Eduardo,

 Thanks for the code. I have run it and I'm not sure what to do with the
 graph when it comes up. Can I interact with it, such as an RGL graph? I've
 tried clicking or dragging with the mouse and nothing happens. My system is
 a Windows Vista and R2.9.

 Best,

 Iuri.

 On Mon, Nov 2, 2009 at 7:35 PM, David Winsemius dwinsem...@comcast.net
 wrote:

 The attached file did not come through to the list. I think you have some
 non-standard characters (or at least non-standard in my locale). I was able
 to get the code to run after using the Zap Gremlins function in
 TextWrangler. Prior to that treatment pretty much every line threw an
 error of this sort:

  setClass(Class = 'POI',
 +        representation(matrizSim = 'matrix',cos.query.docs = 'vector',
 Error: unexpected input in:
 setClass(Class = 'POI',
 ¬
       wordsInQuery = 'ANY',docs = 'matrix', objeto = 'matrix', objetoC
 Error: unexpected input in ¬
  = 'matrix',
 Error: unexpected '=' in =
       Pcoords = 'matrix', PcoordsFI = 'matrix', newPcoords = 'matrix',
 Error: unexpected input in ¬
  newcoords = 'numeric' ,
 Error: unexpected ',' in newcoords = 'numeric' ,
       newcoords_1 = 'numeric',  M = 'numeric', poisTextCol =
 Error: unexpected input in ¬

 I also needed to remove a couple of spaces between function names and
 parentheses when these occurred at ends-of-lines. Attached is a working
 version as a .txt file (which should make it through the list-serv:





 -- David.
  sessionInfo()
 R version 2.10.0 Patched (2009-10-29 r50258)
 x86_64-apple-darwin9.8.0

 locale:
 [1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8

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

 other attached packages:
 [1] rms_2.1-0       Hmisc_3.7-0     survival_2.35-7

 loaded via a namespace (and not attached):
 [1] cluster_1.12.1  grid_2.10.0     lattice_0.17-26




 On Nov 2, 2009, at 3:43 PM, eduardo san miguel wrote:

 I send r-code in an attached file.

 2009/11/2 Iuri Gavronski i...@proxima.adm.br:

 Eduardo,

 Would you mind sending me the R code in an attached file. Your code
 didn't
 work here and I am not sure it is because of line breaks from the email
 program.

 Iuri.

 On Mon, Nov 2, 2009 at 10:53 AM, eduardo san miguel 

 eduardosa...@gmail.com

 wrote:

 Hello all,

 I have almost finished the development of a new package where ideas
 from Tamara Munzner, George Furnas and Costa and Venturini are
 implemented.

 1.- Da Costa, David  Venturini, Gilles (2006). An Interactive
 Visualization Environment for Data Exploration Using Points of
 Interest. adma 2006: 416-423

 2.- Furnas, George (1986). Generalized Fisheye Views. Human Factors in
 computing systems, CHI '86 conference proceedings, ACM, New York, pp.
 16-23.

 3.- Heidi Lam, Ronald A. Rensink, and Tamara Munzner (2006). Effects
 of 2D Geometric Transformations on Visual Memory. Proc. Applied
 Perception in Graphics and Visualization (APGV 2006), 119-126, 2006.

 4.- Keith Lau, Ron Rensink, and Tamara Munzner (2004). Perceptual
 Invariance of Nonlinear Focus+Context Transformations. Proc. First
 Symposium on Applied Perception in Graphics and Visualization (APGV
 04) 2004, pp 65-72.

 This is a sample with some basic functionality and a VERY BASIC
 example with kmeans plotting.

 Comments will be greatly appreciated.

 Regards

 -- R CODE
 require(methods)

 setClass(Class = 'POI',
      representation(matrizSim = 'matrix',cos.query.docs = 'vector',
    wordsInQuery = 'ANY',docs = 'matrix', objeto = 'matrix', objetoC
 = 'matrix',
    Pcoords = 'matrix', PcoordsFI = 'matrix', newPcoords = 'matrix',
 newcoords = 'numeric' ,
    newcoords_1 = 'numeric',  M = 'numeric', poisTextCol =
 'character' , colores = 'vector' ,
    poisCircleCol = 'character' , linesCol = 'character', itemsCol =
 'character',
    LABELS =  'logical',  vscale = 'numeric',  hscale = 'numeric',
 circleCol = 'character',
    plotCol = 'character',  itemsFamily = 'character',  lenteDefault
 = 'numeric',
    zoomDefault = 'numeric' ,  rateDefault = 'numeric' ,
 topKDefault = 'numeric'  ,
    pal = 'character',  selected = 'numeric' ,  circRadio =
 'numeric' , IncVscale = 'numeric',
    

Re: [R] RMySQL and Stored procedures

2009-11-03 Thread Dieter Menne



Orvalho Augusto wrote:
 
 Can someone provide me a good way to circumvent the lack of calling
 Stored Procedures from RMySQL?
 
 I can not rewrite those stored procedures on R because there a lot
 more folks here that only understands SQL.
 
 The stored procedure returns a resultset.
 

Use RODBC instead.

Assuming two stored procedures : 

CREATE PROCEDURE getusers (in userid INT)
BEGIN
  SELECT name from jos_users where id  userid;
END;

CREATE PROCEDURE getusers0() 
BEGIN
  SELECT name from jos_users;
END;

The following works
#
library(RODBC)
con = odbcConnect(mysql,uid=xxx,pwd=yyy)
users0 = sqlQuery(con,CALL getusers0)
users0
users = sqlQuery(con,CALL getusers(20))
users
close(con)
#
Dieter
-- 
View this message in context: 
http://old.nabble.com/RMySQL-and-Stored-procedures-tp26159085p26160033.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] bargraph.ci - CI and color question.

2009-11-03 Thread Michael Just
Hello,
When using bargraph.CI in package sciplot can the bars for each group
be different colors?  How do I select the color for each group?

When I use this instead of the default (SD vs SE):

bargraph.CI(x.factor = dose, response = len, data = ToothGrowth,

   ci.fun= function(x) c(mean(x)-sd(x), mean(x) + sd(x)) )


Am I getting 95% CI bars?

Thank you kindly,
Michael Just

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 exclude certain columns by column names?

2009-11-03 Thread Paul Hiemstra

Linlin Yan wrote:

Try this:
  

x[, colnames(x) != 'a']


And more general:

x[, !colnames(x) %in% c('a','b')]

Paul

[1] 3 4

On Tue, Nov 3, 2009 at 9:31 AM, Peng Yu pengyu...@gmail.com wrote:
  

I can exclude columns by column number using '-'. But I wondering if
there is an easy way to exclude some columns by column names.



x=cbind(c(1,2),c(3,4))
x
  

[,1] [,2]
[1,]13
[2,]24


colnames(x)=c('a','b')
x
  

a b
[1,] 1 3
[2,] 2 4


x[,-'a']
  

Error in -a : invalid argument to unary operator


x[,-1]
  

[1] 3 4

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



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


[R] D'agostino-Pearson K2 omnibus test.

2009-11-03 Thread James Allsopp
Hi,
Is there an implementation of the D'agostino K2 omnibus test in an R
package. I've found the D test in the fBasics package, but this doesn't
give the same answer as my algorithm. I've already coded a version of
the K2 and need to check the results.

I have a set of spectra with gaussian distributed noise and I want a 
statistical test to separate those with no signal (so the data should be 
distributed normally) from those spectra with a line. Has anyone any experience 
of this?

Any help would be greatly appreciated.
James

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

2009-11-03 Thread Park-Ng, Zaneta
Hi everyone,

I'm using lmer and estimable (from packages lme4 and gmodels respectively) and 
have the disconcerting happening that when I run exactly the same code, I get 
different results!  In checking this out by running the code 50x, it seems to 
be that answers may be randomly deviating around those which I get from another 
stats package (GenStat, using the linear mixed models functionality in this).  
As such, my guess is that perhaps there is a random seed involved somewhere in 
the estimable function, and that the answer is simply converging to a slightly 
different place each time, based on a slightly different starting place.  But 
this is only a guess - if anyone could either confirm or otherwise explain this 
unexpected-to-me happening, that'd be fantastic!!

The code that I'm running is:

design.1 = rbind(c(0,0,0,1,0,0,0,0,0,0,0,0))

lme1 - lmer(var_x~AGE*GENDER*DAM_DIET + (1|CHIP) + (1|LITTER),x_temp)

 est - estimable(lme1,design.1)
 print(est)
 est - estimable(lme1,design.1)  # Repeat of code
 print(est)
 est - estimable(lme1,design.1)  # Another repeat of code
 print(est)

And this is the output - you can see in this that the results vary each time 
the code is run...

print(est)
Estimate Std. Error p value
(0 0 0 1 0 0 0 0 0 0 0 0) 0.02241752  0.2185279   0.902
est - estimable(lme1,design.1)
print(est)
 Estimate Std. Error p value
(0 0 0 1 0 0 0 0 0 0 0 0) 0.001824573  0.2106973   0.974
est - estimable(lme1,design.1)
print(est)
Estimate Std. Error p value
(0 0 0 1 0 0 0 0 0 0 0 0) 0.01276941  0.2154196   0.938

My SessionInfo is as follows:

R version 2.9.2 (2009-08-24)
i386-pc-mingw32

locale:
LC_COLLATE=English_New Zealand.1252;LC_CTYPE=English_New 
Zealand.1252;LC_MONETARY=English_New 
Zealand.1252;LC_NUMERIC=C;LC_TIME=English_New Zealand.1252

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

other attached packages:
[1] lme4_0.999375-32   Matrix_0.999375-31 lattice_0.17-25multcomp_1.1-2 
survival_2.35-7mvtnorm_0.9-7  gmodels_2.15.0 svIDE_0.9-5

loaded via a namespace (and not attached):
[1] gdata_2.4.2  grid_2.9.2   gtools_2.6.1 MASS_7.2-48  svMisc_0.9-5

Many thanks for any help or advice that anyone can provide :)

Cheers,
Zaneta


Zaneta Park
Biometrician
T +64 6 351 8008
E zaneta.park...@agresearch.co.nz
AgResearch Limited
Grasslands Research Centre
Tennent Drive, Private Bag 11008, Palmerston North, New Zealand
T  +64 6 356 8019   F  +64 6 351 8032  www.agresearch.co.nz
Farming Food and Health. First
Te Ahuwhenua Te Kai me te Whai Ora. Tuatahi


===
Attention: The information contained in this message and...{{dropped:15}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 exclude certain columns by column names?

2009-11-03 Thread Henrique Dallazuanna
Try this;

x[,setdiff(colnames(x), 'a')]


On Mon, Nov 2, 2009 at 11:31 PM, Peng Yu pengyu...@gmail.com wrote:
 I can exclude columns by column number using '-'. But I wondering if
 there is an easy way to exclude some columns by column names.

 x=cbind(c(1,2),c(3,4))
 x
     [,1] [,2]
 [1,]    1    3
 [2,]    2    4
 colnames(x)=c('a','b')
 x
     a b
 [1,] 1 3
 [2,] 2 4
 x[,-'a']
 Error in -a : invalid argument to unary operator
 x[,-1]
 [1] 3 4

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

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Run R code by Vim-R-plugin (How do I to run two or more programs at the same time)?

2009-11-03 Thread Jakson A. Aquino
On Tue, Nov 03, 2009 at 04:59:30PM +0800, Pan, Jia-chiun/潘家群 wrote:
 I use R on Ubuntu 9.04 by Vim editor with vim-R-plugin. I want to use
 Vim to run two R programs A.R and B.R. At beginning, I sent A.R to R
 prompt by pressing \rf and F5 on my keyboard, and it works well.
 Meanwhile, I want to sent another file B.R to another R window.  When I
 press \rf, the R window shows up and still runs A.R.
 
 How could I run B.R in another R window by using vim-R-plugin?

You may put the following line in your vimrc:

let g:vimrplugin_nosingler = 1

Then, each Vim buffer will start its own R process.

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

2009-11-03 Thread Uwe Ligges



Sander Timmer wrote:

It's a bit strange:

  sub(/pc, '\\%', x)
[1] %
 
  sub(/pc, '%', x)
[1] \\%

Also with fixed I'm not able to get a single \ as return value.



Well, you get the printed representation (i.e. the quoted backslash - 
quoted with anotern backslash).

Use cat(sub(/pc, '%', x)) to see the raw characters.

Uwe Ligges





Sander

On 2 nov 2009, at 12:36, Roberto Brunelli wrote:


I would like to replace all occurences of

   /pc

with

  \%

using something like

sub(/pc, \%, x)

but I am unable to make the '\' pass through.

Any hint?

Thanks,

Roberto

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] R2WinBUGS and R-2.10.0: The school example not running

2009-11-03 Thread Uwe Ligges

Hi,

I got another report about and will investigate shortly.

uwe





Luwis Tapiwa Diya wrote:

Dear R users

I have been encountering an error (in the Winbugs window: Blackbox - index
out of range . ). So to me it seems R2WinBUGS is not linking up well
with the new R version since the same model runs well under r-2.9.2. So is
my assumption correct or am I doing something wrong. The data I used and the
code are in the help of R2WinBUGS (?bugs).


Regards,



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


Re: [R] [R-SIG-Finance] Additive decomposition method

2009-11-03 Thread FMH
Hi, 

Thank you for the function.

I was trying to use the decompose function, but the program cannot run as 
there were several missing values in my data frame. 

Could someone advice me the way to handle on this matter?

Thanks

F





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

2009-11-03 Thread Gabor Grothendieck
On Tue, Nov 3, 2009 at 3:02 AM, Dieter Menne
dieter.me...@menne-biomed.de wrote:



 j daniel wrote:

 I am not familiar with processing text in R.  Can someone tell me how to
 read each line of words as separate elements in a list?

 FE, I would like to turn:

 word1 word2 word3
 word2 word4

 into a list of length two with three character elements in the first list
 and two elements in the second.  I know that this should be easy, but I am
 a little confused by the text functions.


 You could use scan. Have a look at package gsubfn, where there is a demo,
 that show additional features you are going to use

 library(gsubfn)
 demo(gsubfn-gries)
 

 The example code is a bit overnested, but to better understand what is going
 on, unwrap it:

 So
  tail(sort(table(unlist(strapply(Lines1, \\w+, perl = TRUE)

 is:

 x1 = strapply(Lines1, \\w+, perl = TRUE)
 x1
 x2 = ulist(x2)
 x2
 x3 = table(x2)
 x3
 x4 = sort(x3)
 x4
 tail(x4)


Just one small optimization. You don't actually need perl = TRUE here.
  By default, strapply uses tcl and the regex engine in tcl which does
support \w and which can process the input faster although with the
input of the above size it won't be material.   If you do specify perl
= TRUE (or engine = R) then it will use R and R's perl engine.
There is a link to the tcl regex page on the gsubfn home page in the
links box:
http://gsubfn.googlecode.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] package(vars) and generalized impulse response functions

2009-11-03 Thread Vimal B
Hi,

I was wondering whether the package(vars) can estimate generalized impulse
response functions for VARs / VECMs.

The general option on package(vars) available is:-

suppose I want to give a shock to 'a' and observe the response of 'b', then

irf(x, impulse=a, response=b, n.ahead=10,
boot=TRUE,ci=0.95,runs=100,seed=NULL...)

The vignettes and manuals says that the default is 'ortho=TRUE' (and the
other option is cumulative=NULL).

Or is there any other package one would suggest?

Thanks,

Regards,
Vimal

[[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] Plotting an interaction with error bars

2009-11-03 Thread Dror D Lev
Hello.

I need to plot a two-way interaction (5 levels X 3) with error bars.
The x.factor will be the five-levels var and the trace.factor will be
the three level var.

I was able to find functions that draw error bars, but still couldn't
find a way to draw an interaction plot that looks like what is common
in psychological (and related) journals: the lines (three in my need)
are plotted in parallel and to avoid overlapping of the error bars a
small jitter is added.

I was able to make plotmeans() {from gplots} draw the interaction but
with the lines plotted side by side (not parallel), resulting in three
panes of one line each. When I tried manually super-imposing (looping
a draw of one line for each level in the trace.factor) I got the
overall look, but the error bars overlap and are hard to distinguish.

Another attempt I made was with ci.plot() {from pda}. Inputting an
aov() model resulted in a perfect plot of interaction but which is
very limited to handle - I was unable to add a legend, change symbols
etc.

Does anybody knows if there is a way to manipulate either of the above
functions more then what I was able to?
Is there another function to draw interaction plots with error bars?

Thanks for any help or comment.
dror

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

2009-11-03 Thread Marc Schwartz

On Nov 2, 2009, at 10:10 PM, Kenneth Roy Cabrera Torres wrote:


Hi R users:

I am using RODBC to create some new .xls files each with
several sheets (about 100) with sqlSave() from a data.frame
inside R  without any problem, but on windows XP platform.

I would like to know if it is posible to make a similar
solution on linux with openoffice?

RODBC work only (for the moment) with .xls on windows,
via the ODBC driver.

Is it posible to make the same thing on openoffice?
I mean, an .odt file with several sheets each, generated from
a data.frame in R?

Thank you for your help.

Kenneth



See this post from late 2007:

  http://tolstoy.newcastle.edu.au/R/e3/help/07/12/6478.html

As far as I know, nothing has changed vis-a-via ODBC connectivity TO  
OpenOffice files. You can use ODBC FROM OpenOffice to connect to  
external data sources.


A search of CRAN does not reveal any packages/functions to would  
appear to provide a facility to directly write data frames to a Calc  
file. However, you can always write to a XLS file, open it in Calc and  
re-save it as a native Calc file. Of course, anyone with Calc can open  
an XLS file, so you are not losing much in terms of portability by  
saving to an XLS file and distributing that. You also make it easier  
for folks who may be using other 'office' applications that do not  
have import filters for OO.org file formats.


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] tapply function

2009-11-03 Thread FMH
Hi,

I tried to use tapply function to find the mean of the data in each group as 
the following command, but the result are NA, as there are several missing 
values in each group.

tapply(data,group,mean)

Could someone please advice me the way to  ignore the missing data in order for 
the fucntion to run successfully?

Thanks

Fir




__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] hierarchical clustering with Jaccard index

2009-11-03 Thread Don McKenzie

Try Jaccard.   :-)

karuna m wrote:

hi,
I want to do hierarchical clustering with Jaccord index. I tried to do with vegan package 
for finding index and hierarchical clustering with hclust function. While doing 
clustering it is showing an error message as invalid distance method. I would 
be grateful if anyone tells how to rectify the error.
Thanks in advance,
 
kind regards,


Ms.Karunambigai M
PhD Scholar
Dept. of Biostatistics
NIMHANS
Bangalore
India


  Keep up with people you care about with Yahoo! India Mail. Learn how. 
http://in.overview.mail.yahoo.com/connectmore
[[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.


--
Don McKenzie
Research Ecologist
Pacific Wildland Fire Sciences Lab
US Forest Service

Affiliate Professor
College of Forest Resources and CSES Climate Impacts Group
University of Washington

phone: 206-732-7824
cell: 206-321-5966
d...@u.washington.edu

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

2009-11-03 Thread Sundar Dorai-Raj
you must have missing values in data. Try

tapply(data, group, mean, na.rm = TRUE)

If that's not the case, read the bottom of this email about the posting guide.

HTH,

--sundar

On Tue, Nov 3, 2009 at 5:28 AM, FMH kagba2...@yahoo.com wrote:
 Hi,

 I tried to use tapply function to find the mean of the data in each group as 
 the following command, but the result are NA, as there are several missing 
 values in each group.

 tapply(data,group,mean)

 Could someone please advice me the way to  ignore the missing data in order 
 for the fucntion to run successfully?

 Thanks

 Fir




 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] fitting a confined mixture model

2009-11-03 Thread Giovanni Luca Ciampaglia

Hello all,
I would like to fit a mixture model whose components are normal 
distributions confined in a closed interval. Since there are already 
several packages for EM, I would like to extend one of these instead of 
writing a new script from scratch. What would be the best way to 
customize such an existing package for doing that? Which one is the best 
in terms of extensibility? (e.g mixtools, flexmix ..)


--
Giovanni L. Ciampaglia
PhD Student
University of Lugano, MACS Lab

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

2009-11-03 Thread bamsel

Dear R users:
Here's a barebones example of what I can't make work. 
As you can see, regexpr() does not perform an exact string match, which only
occurs in row 1 of these data frames. Instead, as it's supposed to do, it
finds b in bb and c in cc. Does anybody know what function I can use
such that only the first rows would be matched (ie, exact string match?)
I've also tried simply using the == operator, in which case i get the
error:level sets of factors are different

Thank you in advance, 
B

 ## two toy data frames, containing character arrays
 D1=as.data.frame(c(a,b,c))
 D2=as.data.frame(c(a,bb,cc))
 
 ## loop through each comparing the strings in each row
 i=1 #counter
 while (regexpr(D1[i,1], D2[i,1]) == TRUE) {
+cat(identical match on row #, i, \n)
+i=i+1 
+ if (i3) break 
+ }
identical match on row # 1 
identical match on row # 2 
identical match on row # 3 
-- 
View this message in context: 
http://old.nabble.com/Exact-String-Compare-in-R--tp26160122p26160122.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] fixed color scale for a series of contour plots

2009-11-03 Thread Marion Dumas

Hello,
I am having trouble figuring out how to create a color scale that will  
be consistent across multiple contour plots. What I would like is to  
plot a series of contour or image plots for different subsets of a  
data set but make sure that the color key stays fixed so that the  
plots are easily comparable. That is I need a map from the range of  
values of the entire data set to the color scale and keep then use  
this color scale for all plots + be able to display the color bar as a  
legend next to the plot. This sounds trivial, but I can't find useful  
hints in the documentation of the color arguments of the different  
plots.

Thanks so much for any help
Best
Marion

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

2009-11-03 Thread Paul Heinrich Dietrich

This weekend I noticed that my R2WinBUGS connection was no longer working on
my Windows computer at work AND my Ubuntu linux computer at home.  As soon
as WinBUGS opens, the message reads Index Out Of Range.  I have un-installed
and re-installed R on both computers and the problem remains the same.  At
first I thought it was the new version of R, but I was able to overcome the
problem (on Windows only) with the use of

program=openbugs

in R2WinBUGS.  But that doesn't work on Linux.

PS
The smallest WinBUGS program I have, essentially a t-test, still works.  But
anything larger than that gets the error.

Help.  Thanks.
-- 
View this message in context: 
http://old.nabble.com/R2WinBUGS-not-working--tp26160111p26160111.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] Re trieve scores using a cov matrix in factanal

2009-11-03 Thread apointet

Hi

My goal is to do a weighted (by population) factor analysis (of votes) using
R.

For that I prepared the weigthed cov matrix, which matrix I pass in the
factanal function.
I'm facing troubles in calculating the scores of a factor analysis using as
entry a cov matrix as Factanal is not able to get the scores (normal in the
case of absence of any x).

I'm looking for a method to calculate the scores manually afterward. Does
anybody has the way I can retrieve that?

Abram
MFSA.ch


-- 
View this message in context: 
http://old.nabble.com/Retrieve-scores-using-a-cov-matrix-in-factanal-tp26160114p26160114.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] random text added to names (bug with 2.10.0?)

2009-11-03 Thread Johann Hibschman
I'm using 2.10.0 on Linux (64 bit), and I just noticed that random
numbers are occasionally added to the text of names in vectors. It's
happened to me in two separate, long-running R sessions, but I can't
find a way to reproduce it in a smaller setting.

The code I'm using is

 diag.gam.2 - mdl.run.diag(fit.gam.2, ds.valid)
 diag.gam.2
rmse mdae.1413751 mnae   cv   r2
 0.023171639  0.007206221  0.012374469  1.259498479  0.385234756
 mdl.run.diag
function (fit, ds) {
  run.diagnostics(mdl.run(fit, ds))
}
 run.diagnostics
function (ds) {
  c(rmse=root.mean.squared.error(ds),
mdae=median.absolute.error(ds),
mnae=mean.absolute.error(ds),
cv=coefficient.of.variation(ds),
r2=coefficient.of.determination(ds))
}

The problem is that extra .1413751 that's mysteriously being added
to the mdae name.

Am I doing something obviously wrong, or is this a bug? I still have
the two sessions running, if there are any diagnostics would help.

Cheers,
Johann

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

2009-11-03 Thread Gábor Csárdi
On Tue, Nov 3, 2009 at 2:41 PM, bamsel benam...@gmail.com wrote:

 Dear R users:
 Here's a barebones example of what I can't make work.
 As you can see, regexpr() does not perform an exact string match, which only
 occurs in row 1 of these data frames. Instead, as it's supposed to do, it
 finds b in bb and c in cc. Does anybody know what function I can use
 such that only the first rows would be matched (ie, exact string match?)
 I've also tried simply using the == operator, in which case i get the
 error:level sets of factors are different

Because they are not strings, but factors. Convert them to strings
with as.character and use ==.

Best,
Gabor

 Thank you in advance,
 B

 ## two toy data frames, containing character arrays
 D1=as.data.frame(c(a,b,c))
 D2=as.data.frame(c(a,bb,cc))

 ## loop through each comparing the strings in each row
 i=1 #counter
 while (regexpr(D1[i,1], D2[i,1]) == TRUE) {
 +        cat(identical match on row #, i, \n)
 +        i=i+1
 +         if (i3) break
 + }
 identical match on row # 1
 identical match on row # 2
 identical match on row # 3
 --
 View this message in context: 
 http://old.nabble.com/Exact-String-Compare-in-R--tp26160122p26160122.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.




-- 
Gabor Csardi gabor.csa...@unil.ch UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] fixed color scale for a series of contour plots

2009-11-03 Thread Meyners, Michael, LAUSANNE, AppliedMathematics
You don't tell us which function you use, but fixing the zlim argument
in image or related functions should do the trick.
M.

 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of Marion Dumas
 Sent: Dienstag, 3. November 2009 14:38
 To: r-help@r-project.org
 Subject: [R] fixed color scale for a series of contour plots
 
 Hello,
 I am having trouble figuring out how to create a color scale 
 that will be consistent across multiple contour plots. What I 
 would like is to plot a series of contour or image plots for 
 different subsets of a data set but make sure that the color 
 key stays fixed so that the plots are easily comparable. That 
 is I need a map from the range of values of the entire data 
 set to the color scale and keep then use this color scale for 
 all plots + be able to display the color bar as a legend next 
 to the plot. This sounds trivial, but I can't find useful 
 hints in the documentation of the color arguments of the 
 different plots.
 Thanks so much for any help
 Best
 Marion
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Odp: Exact String Compare in R?

2009-11-03 Thread Petr PIKAL
Hi

what about

D2[,1] %in% D1[,1]

Regards
Petr

r-help-boun...@r-project.org napsal dne 03.11.2009 14:41:02:

 
 Dear R users:
 Here's a barebones example of what I can't make work. 
 As you can see, regexpr() does not perform an exact string match, which 
only
 occurs in row 1 of these data frames. Instead, as it's supposed to do, 
it
 finds b in bb and c in cc. Does anybody know what function I can 
use
 such that only the first rows would be matched (ie, exact string match?)
 I've also tried simply using the == operator, in which case i get the
 error:level sets of factors are different
 
 Thank you in advance, 
 B
 
  ## two toy data frames, containing character arrays
  D1=as.data.frame(c(a,b,c))
  D2=as.data.frame(c(a,bb,cc))
  
  ## loop through each comparing the strings in each row
  i=1 #counter
  while (regexpr(D1[i,1], D2[i,1]) == TRUE) {
 +cat(identical match on row #, i, \n)
 +i=i+1 
 + if (i3) break 
 + }
 identical match on row # 1 
 identical match on row # 2 
 identical match on row # 3 
 -- 
 View this message in context: 
http://old.nabble.com/Exact-String-Compare-in-
 R--tp26160122p26160122.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] bargraph.ci - CI and color question.

2009-11-03 Thread David Winsemius


On Nov 3, 2009, at 4:51 AM, Michael Just wrote:


Hello,
When using bargraph.CI in package sciplot can the bars for each group
be different colors?


Yes.

?bargraph.CI


How do I select the color for each group?



Read the help page. Fifth argument down.


When I use this instead of the default (SD vs SE):

bargraph.CI(x.factor = dose, response = len, data = ToothGrowth,

  ci.fun= function(x) c(mean(x)-sd(x), mean(x) + sd(x)) )


Am I getting 95% CI bars?


Something +/- one SD(something will almost never be a 95% CI. But  
this raises the question:  CI bars for what parameter or statistic?   
(And raises the question: Have you read the help page entry regarding  
that parameter?)


I do think it's good that you are considering plotting standard  
deviations rather than std errors of the mean, because the more common  
practice of plotting sem's obscures the degree of variability in the  
population. It's just that you appear to be aiming for what might be  
called a prediction interval and for it to be a 95% one, would need to  
be +/- 2 SD's. And if the numbers in each group are small, the 2  
would get replaced with a t-statistic.


If on the other hand you want to know what would be the right label  
for mean +/- sd, then given that +/- 1.96 SD would be a 95% prediction  
interval (for large samples) then you can see from


 1-2*pnorm(-1.96)
[1] 0.9500042
 1-2*pnorm(-1)
[1] 0.6826895

... that +/- one SD would be a 68% prediction interval.



Thank you kindly,
Michael Just

--

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] package lme4

2009-11-03 Thread wenjun zheng
Thanks,Douglas,
It really helps me a lot, but is there any other way if I want to show
whether a random effect is significant in text file, like P value or other
 index.
Thanks very much again.
Wenjun.

2009/11/2 Douglas Bates ba...@stat.wisc.edu

 On Sun, Nov 1, 2009 at 9:01 AM, wenjun zheng wjzhen...@gmail.com wrote:
  Hi R Users,
  When I use package lme4 for mixed model analysis, I can't distinguish
  the significant and insignificant variables from all random independent
  variables.
  Here is my data and result:
  Data:
 
 
  
 Rice-data.frame(Yield=c(8,7,4,9,7,6,9,8,8,8,7,5,9,9,5,7,7,8,8,8,4,8,6,4,8,8,9),
  Variety=rep(rep(c(A1,A2,A3),each=3),3),
  Stand=rep(c(B1,B2,B3),9),
  Block=rep(1:3,each=9))
 Rice.lmer-lmer(Yield ~ (1|Variety) + (1|Stand) + (1|Block) +
  (1|Variety:Stand), data = Rice)
 
  Result:
 
  Linear mixed model fit by REML
  Formula: Yield ~ (1 | Variety) + (1 | Stand) + (1 | Block) + (1 |
  Variety:Stand)
Data: Rice
AIC   BIC logLik deviance REMLdev
   96.25 104.0 -42.1285.33   84.25
  Random effects:
   GroupsNameVariance Std.Dev.
   Variety:Stand (Intercept) 1.345679 1.16003
   Block (Intercept) 0.00 0.0
   Stand (Intercept) 0.89 0.94281
   Variety   (Intercept) 0.024691 0.15714
   Residual  0.67 0.81650
  Number of obs: 27, groups: Variety:Stand, 9; Block, 3; Stand, 3; Variety,
 3

  Fixed effects:
 Estimate Std. Error t value
  (Intercept)   7.1852 0.6919   10.38

  Can you give me some advice for recognizing the significant variables
 among
  random effects above without other  calculating.

 Well, since the estimate of the variance due to Block is zero, that's
 probably not one of the significant random effects.

 Why do you want to do this without other calculations?  In olden days
 when each model fit involved substantial calculations by hand one did
 try to avoid fitting multiple models but now that is not a problem.
 You can get a hint of which random effects will be significant by
 looking at their precision in a caterpillar plot and then fit the
 reduced model and use anova to compare models.  See the enclosed

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


[[alternative HTML version deleted]]

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


[R] Scanning grep through huge files

2009-11-03 Thread Johannes Graumann
Hi,

I'm dealing which huge files I would like to index. On a linux system grep 
-buo PATTERN FILENAME hands me the byte offsets for PATTERN very 
quickly and I am looking to emulate that speed and ease with native R tools 
- for portability and elegance. gregexpr should be able to do that but I 
fail to combine it with scan or an equivalent to parse the whole file 
without having to read it all into memory.

I'd be grateful for any hints on how to do this without a pipe(grep -buo 
PATTERN FILENAME).

Thanks, Joh

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] 1 dimensional optimization with local minima

2009-11-03 Thread Ravi Varadhan
Hi,

One approach is to use the `multiStart' function in my BB package.  You have 
to provide a matrix of starting values for this. 

Here is a simple, one-dimensional optimization problem with multiple peaks and 
valleys.  I show how to find all the peaks in the bounded interval [0, 1].

myfn - function(x) {
exp(-k1 * x) * sin(2*pi*k2*x)
}

k1 - 0.5

k2 - 5

x - seq(0, 1, length=1000)

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

require(BB)

p0mat - matrix(runif(100), 100, 1)  # random starting values

ans - multiStart(par=p0mat, fn=myfn, lower=0, upper=1, action=optimize, 
control=list(maximize=TRUE))

pconv - ans$par[ans$conv]  # converged solutions

rp - !duplicated(round(pconv, 3))  # unique, converged solutions

sort(pconv[rp])  # lists all the local maxima


Hope this helps,
Ravi.



Ravi Varadhan, Ph.D.
Assistant Professor,
Division of Geriatric Medicine and Gerontology
School of Medicine
Johns Hopkins University

Ph. (410) 502-2619
email: rvarad...@jhmi.edu


- Original Message -
From: Jeroen Ooms jeroen.o...@stat.ucla.edu
Date: Tuesday, November 3, 2009 2:27 am
Subject: [R]  1 dimensional optimization with local minima
To: r-help@r-project.org


 I am using numerical optimization to fit a 1 parameter model, in which 
 the
 input parameter is bounded. I am currently using optimize(), however, 
 the
 problem turns out to have local minima, and optimize does not always 
 seem to
 find the global minimum. I could to write a wrapping function that tries
 multiple intervals or starting values, but I would prefer a package 
 that has
 built-in methods to make it more robust against local minima.
 
 I checked the CRAN Task View for Optimization, however there seem to 
 be a
 lot of alternatives, and not being an optimization expert, I could use 
 some
 advice. What could be an appropriate package or function for one-dimensional
 bounded optimization, that includes some protection against local 
 minima? 
 
 
 
 -
 Jeroen Ooms * Dept. of Methodology and Statistics * Utrecht University 
 
 
 Visit   www.jeroenooms.com  to explore some of my
 current projects.
 
 
 
 
 
  
 -- 
 View this message in context: 
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list
 
 PLEASE do read the posting guide 
 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] 1 dimensional optimization with local minima

2009-11-03 Thread Prof. John C Nash
Most methods for optimization in R seek local minima, though there are
some -- mainly for 1 dimensions, that attempt to find the global
minimum stochastically (optim method SANN, DEoptim). SANN does, I
believe, handle 1 dimension, but does not have a convergence test, but
runs a fixed number of function evaluations (I got bitten by this
unusual behaviour, as it returns a converged flag after the specified
number of evaluations).

While there are some techniques that can generate global minima given
conditions on the function, I would anticipate you will do better
graphing your function(s) to learn if they have just a few (++) or very
many (-- = very bad for you) optima. You should apply bounds to your
domain -- a lot of computational time is wasted when routines take a
wild excursion away from a region of interest. That may be enough. Or
you may need to segment the domain to isolate the minima then select the
best. That is, find a local minimum, choose a new interval that does not
include this and apply optimize() again. Messy, but unless you have lots
of local minima, should work OK. If you do have lots, it is likely you
need to re-pose your problem.

JN





 Message: 114
 Date: Mon, 2 Nov 2009 23:00:40 -0800 (PST)
 From: Jeroen Ooms jeroen.o...@stat.ucla.edu
 Subject: [R]  1 dimensional optimization with local minima
 To: r-help@r-project.org
 Message-ID: 26160001.p...@talk.nabble.com
 Content-Type: text/plain; charset=us-ascii
 
 
 I am using numerical optimization to fit a 1 parameter model, in which the
 input parameter is bounded. I am currently using optimize(), however, the
 problem turns out to have local minima, and optimize does not always seem to
 find the global minimum. I could to write a wrapping function that tries
 multiple intervals or starting values, but I would prefer a package that has
 built-in methods to make it more robust against local minima.
 
 I checked the CRAN Task View for Optimization, however there seem to be a
 lot of alternatives, and not being an optimization expert, I could use some
 advice. What could be an appropriate package or function for one-dimensional
 bounded optimization, that includes some protection against local minima? 
 
 
 
 -
 Jeroen Ooms * Dept. of Methodology and Statistics * Utrecht University 
 
 Visit  http://www.jeroenooms.com www.jeroenooms.com  to explore some of my
 current projects.
 
 
 
 
 
  
 -- View this message in context: 
 http://old.nabble.com/1-dimensional-optimization-with-local-minima-tp26160001p26160001.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] how to display a string containing greek chrs and variables

2009-11-03 Thread J . delasHeras


I'm trying something that I thought would be pretty simple, but it's  
proving quite frustrating...


I want to display, for instance, the correlation coefficient rho in a graph.

I can do something like:

text(x, y, paste(rho =, cor))

where cor would be my previously calculated correlation coefficient,  
and x and y the coordinates.

Obviously that displays rho, not the greek letter rho.

I can do also this:

text(x, y, paste(\\*r =,cor), vfont = c(sans serif,bold))

that works, but that doesn't look very pretty.
What looks good is doing something like:

text(x, y, expression(rho))

But I haven't managed to make it do what I need.

I can get this:
text(x, y, expression(rho == 0.8))

that looks good, but how can I substitute the 0.8 for teh name of a  
numeric variable whose value is 0.8?


I'm going slightly mad... it can't be that hard.

Thanks for any help!

Jose


--
Dr. Jose I. de las Heras  Email: j.delashe...@ed.ac.uk
The Wellcome Trust Centre for Cell BiologyPhone: +44 (0)131 6513374
Institute for Cell  Molecular BiologyFax:   +44 (0)131 6507360
Swann Building, Mayfield Road
University of Edinburgh
Edinburgh EH9 3JR
UK
*
NEW EMAIL from July'09: nach.mcn...@gmail.com
*

--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Scanning grep through huge files

2009-11-03 Thread Duncan Murdoch

On 11/3/2009 9:29 AM, Johannes Graumann wrote:

Hi,

I'm dealing which huge files I would like to index. On a linux system grep 
-buo PATTERN FILENAME hands me the byte offsets for PATTERN very 
quickly and I am looking to emulate that speed and ease with native R tools 
- for portability and elegance. gregexpr should be able to do that but I 
fail to combine it with scan or an equivalent to parse the whole file 
without having to read it all into memory.


I think you are going to have to write this yourself.  R doesn't have 
very many stream oriented functions:  almost everything is aimed at 
having the whole thing in memory.


You will also have trouble with the byte offsets.  The semantics of the 
-u option to grep are quite strange (at least according to the man page 
on Cygwin).


What I'd do given your problem is use readLines to read the file, then 
post-process the result of gregexpr to give line and byte offset pairs 
for each match; those are more useful in R than the rather bizarre byte 
offsets that grep -buo will give.  But for a huge file you'll probably 
have to do this in blocks, as the whole file may be too big.


Duncan Murdoch




I'd be grateful for any hints on how to do this without a pipe(grep -buo 
PATTERN FILENAME).


Thanks, Joh

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

2009-11-03 Thread Manuel Morales
On Tue, 2009-11-03 at 03:51 -0600, Michael Just wrote:
 Hello,
 When using bargraph.CI in package sciplot can the bars for each group
 be different colors?  How do I select the color for each group?

With the option err.col

bargraph.CI(dose, len, group = supp, data =ToothGrowth,
err.col=c(gray,black))

 When I use this instead of the default (SD vs SE):
 
 bargraph.CI(x.factor = dose, response = len, data = ToothGrowth,
 
ci.fun= function(x) c(mean(x)-sd(x), mean(x) + sd(x)) )
 
 
 Am I getting 95% CI bars?

No. You're plotting +/- 1 SD.
 
 Thank you kindly,
 Michael Just
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


-- 
http://mutualism.williams.edu

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 display a string containing greek chrs and variables

2009-11-03 Thread baptiste auguie
Hi,

try this,

plot.new()
x=0.8
text(0.5, 0.5, bquote(rho == .(x)))


HTH,

baptiste
2009/11/3  j.delashe...@ed.ac.uk:

 I'm trying something that I thought would be pretty simple, but it's proving
 quite frustrating...

 I want to display, for instance, the correlation coefficient rho in a
 graph.

 I can do something like:

 text(x, y, paste(rho =, cor))

 where cor would be my previously calculated correlation coefficient, and x
 and y the coordinates.
 Obviously that displays rho, not the greek letter rho.

 I can do also this:

 text(x, y, paste(\\*r =,cor), vfont = c(sans serif,bold))

 that works, but that doesn't look very pretty.
 What looks good is doing something like:

 text(x, y, expression(rho))

 But I haven't managed to make it do what I need.

 I can get this:
 text(x, y, expression(rho == 0.8))

 that looks good, but how can I substitute the 0.8 for teh name of a
 numeric variable whose value is 0.8?

 I'm going slightly mad... it can't be that hard.

 Thanks for any help!

 Jose


 --
 Dr. Jose I. de las Heras                      Email: j.delashe...@ed.ac.uk
 The Wellcome Trust Centre for Cell Biology    Phone: +44 (0)131 6513374
 Institute for Cell  Molecular Biology        Fax:   +44 (0)131 6507360
 Swann Building, Mayfield Road
 University of Edinburgh
 Edinburgh EH9 3JR
 UK
 *
 NEW EMAIL from July'09: nach.mcn...@gmail.com
 *

 --
 The University of Edinburgh is a charitable body, registered in
 Scotland, with registration number SC005336.

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

2009-11-03 Thread Joel Fürstenberg-Hägg

Hi all,

 

I'm trying to write a script that changes all negative values in a data frame 
column to a small positive value, based on the the minimum value of the column.

However, I get the following error:

 

Error in if (x[i]  0) { : argument is of length zero

 

 

As well, I would minimum to be the smallest of the non-negative values...

 

 

Aa_non_neg=(fieldTrial0809$Aa) # Copy column from data frame to manipulate

 

nonNegative = function(x)
{
   minimum=min(x) # Should only use positive minimum!
   for (i in x)
   {

  if(x[i]0) # Found a negative value
  {
 x[i]=minimum/10 # Change to a new non-negative value
  }
   }
}

 

nonNegative(Aa_non_neg) # Apply function on column
  
_
Lagra alla dina foton på Skydrive. Det är enkelt och säkert!
http://www.skydrive.live.com
[[alternative HTML version deleted]]

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


Re: [R] package lme4

2009-11-03 Thread wenjun zheng
May be I can calculate p value by t testing approximately:
 1-qnorm(Variance/Std.Dev.)
But which function can help me to extract Variance and Std.Dev values from
the results below:

print(fm2 - lmer(Yield ~ 1 + (1|Stand) + (1|Variety) +
(1|Variety:Stand),Rice))

Linear mixed model fit by REML
Formula: Yield ~ 1 + (1 | Stand) + (1 | Variety) + (1 | Variety:Stand)
   Data: Rice
   AIC   BIC logLik deviance REMLdev
 94.25 100.7 -42.1285.33   84.25
Random effects:
 GroupsNameVariance Std.Dev.
 Variety:Stand (Intercept) 1.345679 1.16003
 Variety   (Intercept) 0.024692 0.15714
 Stand (Intercept) 0.88 0.94281
 Residual  0.67 0.81650
Number of obs: 27, groups: Variety:Stand, 9; Variety, 3; Stand, 3

Fixed effects:
Estimate Std. Error t value
(Intercept)   7.1852 0.6919   10.38


2009/11/2 Douglas Bates ba...@stat.wisc.edu

 On Sun, Nov 1, 2009 at 9:01 AM, wenjun zheng wjzhen...@gmail.com wrote:
  Hi R Users,
  When I use package lme4 for mixed model analysis, I can't distinguish
  the significant and insignificant variables from all random independent
  variables.
  Here is my data and result:
  Data:
 
 
  
 Rice-data.frame(Yield=c(8,7,4,9,7,6,9,8,8,8,7,5,9,9,5,7,7,8,8,8,4,8,6,4,8,8,9),
  Variety=rep(rep(c(A1,A2,A3),each=3),3),
  Stand=rep(c(B1,B2,B3),9),
  Block=rep(1:3,each=9))
 Rice.lmer-lmer(Yield ~ (1|Variety) + (1|Stand) + (1|Block) +
  (1|Variety:Stand), data = Rice)
 
  Result:
 
  Linear mixed model fit by REML
  Formula: Yield ~ (1 | Variety) + (1 | Stand) + (1 | Block) + (1 |
  Variety:Stand)
Data: Rice
AIC   BIC logLik deviance REMLdev
   96.25 104.0 -42.1285.33   84.25
  Random effects:
   GroupsNameVariance Std.Dev.
   Variety:Stand (Intercept) 1.345679 1.16003
   Block (Intercept) 0.00 0.0
   Stand (Intercept) 0.89 0.94281
   Variety   (Intercept) 0.024691 0.15714
   Residual  0.67 0.81650
  Number of obs: 27, groups: Variety:Stand, 9; Block, 3; Stand, 3; Variety,
 3

  Fixed effects:
 Estimate Std. Error t value
  (Intercept)   7.1852 0.6919   10.38

  Can you give me some advice for recognizing the significant variables
 among
  random effects above without other  calculating.

 Well, since the estimate of the variance due to Block is zero, that's
 probably not one of the significant random effects.

 Why do you want to do this without other calculations?  In olden days
 when each model fit involved substantial calculations by hand one did
 try to avoid fitting multiple models but now that is not a problem.
 You can get a hint of which random effects will be significant by
 looking at their precision in a caterpillar plot and then fit the
 reduced model and use anova to compare models.  See the enclosed

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


[[alternative HTML version deleted]]

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


Re: [R] mac question

2009-11-03 Thread Steve Lianoglou

Hi,

On Nov 3, 2009, at 2:41 AM, Antje wrote:


Hi there,

currently, I've updated R on my Mac (OS X) to version 2.10. I was  
wondering if I have to install all additional packages again???
In Windows, I just needed to copy the library folder of the old  
installation but how does it work with Mac?


This isn't really a mac or windows thing, actually. Although this  
method may have worked for you in the past, it's generally not  
recommended to use libraries compiled from one R version in another.  
Using the same libraries between 2.9.X to 2.9.X+n is fine, but doing  
the same when going from 2.9 to 2.10 is not a good idea.


So, in short, you should updated/reinstall your packages now that  
you've updated R.


An easy way to do that would have been to save a file of all packages  
installed from 2.9, then use that file to reinstall those packages  
from within 2.10. Here's a recipe to do that now (assuming R 2.9 is  
still installed on your system).


You can use RSwitch to switch which version of R is active at a  
time, available here:

http://r.research.att.com/RSwitch-1.1.dmg

1. Fire up RSwitch and pick R 2.9
1.5. I have these two functions I use when I want to be lazy:

installedPackages - function(to=~/R.packages.dump.txt) {
  writeLines(installed.packages()[,1], con=to)
}

reloadPackages - function(from=~/R.packages.dump.txt) {
  source(http://bioconductor.org/biocLite.R;)
  packages - readLines(from)
  biocLite(packages)
}

2. Call installedPackages() from within R 2.9 and quit
3. Use rswitch to make R 2.10 active
4. Open R 2.10 and run reloadPackages()

biocLite is a function to install bioconductor packages, but it also  
installs normal cran packages. You can likely replace the call to  
biocLite with a call to install.packages(packages) if you don't have  
any bioc packages to install, if you like, although it shouldn't be  
necessary.


It might take a while to d/l all your packages again, but it should  
just work


-steve

--
Steve Lianoglou
Graduate Student: Computational Systems Biology
  |  Memorial Sloan-Kettering Cancer Center
  |  Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

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

2009-11-03 Thread NCS
I cannot seem to write a randomforest model in PMML - either through calling 
PMML(model) or through Rattle.  It appears that it is not yet supported.  
Randomsurvivalforest is, but not randomforest.  Any ideas on possible 
workarounds for this?

Thanks
ncs

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

2009-11-03 Thread Yihui Xie
coef(summary(fit_cox)) should give you what you wanted.

Regards,
Yihui
--
Yihui Xie xieyi...@gmail.com
Phone: 515-294-6609 Web: http://yihui.name
Department of Statistics, Iowa State University
3211 Snedecor Hall, Ames, IA



On Tue, Nov 3, 2009 at 12:31 AM, 孟欣 lm_meng...@163.com wrote:
 Hi all:
 I finished cox analysis like this:
 fit_cox-coxph(Surv(dat$Time, dat$death) ~ dat$CD4 + 
 strata(dat$gender),data=dat);
 fit_cox
 Call:
 coxph(formula = Surv(data_ori$Time, data_ori$death) ~ data_ori$drug +
    strata(data_ori$gender), data = data_ori)

                  coef exp(coef) se(coef)    z    p
 data_ori$drugddI 0.216      1.24    0.146 1.47 0.14
 Likelihood ratio test=2.17  on 1 df, p=0.140  n= 467

 I wanna extract the result:
 0.216      1.24    0.146 1.47 0.14 and the corresponding name coef exp(coef) 
 se(coef)    z    p
 from fit_cox.

 I use the command:
 str(fit_cox),but I can only find 0.216 of the result,but the other four 
 results( 1.24    0.146 1.47 0.14) can't be found.


 Anyone can help me?
 Thanks a lot!

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

2009-11-03 Thread Sunita22

Hello

I have time data which is in hh:mm:ss format and I need to calculate
averages for this data. I tried converting the data as integer so that I
could calculate the average, but it doesn't serve the purpose. I tried using
Chron package also. But I am stuck up as to how to deal with the time data.
Please guide me as to how to deal with Time data in R.

Thank you in advance

Regards
Sunita
-- 
View this message in context: 
http://old.nabble.com/Calculate-Averages-for-time-data-tp26160202p26160202.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] Calculate Averages for time data

2009-11-03 Thread Gabor Grothendieck
Next time please provide sample input.

library(chron)

# input
ch - c(02:24:00, 04:48:00, 07:12:00, 09:36:00, 12:00:00,
14:24:00, 16:48:00, 19:12:00, 21:36:00)

# convert to times
tt - times(ch)

# calculate mean
mean(tt)


On Tue, Nov 3, 2009 at 10:35 AM, Sunita22 sunita...@gmail.com wrote:

 Hello

 I have time data which is in hh:mm:ss format and I need to calculate
 averages for this data. I tried converting the data as integer so that I
 could calculate the average, but it doesn't serve the purpose. I tried using
 Chron package also. But I am stuck up as to how to deal with the time data.
 Please guide me as to how to deal with Time data in R.

 Thank you in advance

 Regards
 Sunita
 --
 View this message in context: 
 http://old.nabble.com/Calculate-Averages-for-time-data-tp26160202p26160202.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] Change negative values in column

2009-11-03 Thread Steve Lianoglou

Hi,

On Nov 3, 2009, at 9:56 AM, Joel Fürstenberg-Hägg wrote:


Hi all,

I'm trying to write a script that changes all negative values in a  
data frame column to a small positive value, based on the the  
minimum value of the column.


However, I get the following error:

Error in if (x[i]  0) { : argument is of length zero


This is telling you that x[i] is a zero length object, so you're  
indexing is wrong


As well, I would minimum to be the smallest of the non-negative  
values...


Aa_non_neg=(fieldTrial0809$Aa) # Copy column from data frame to  
manipulate


nonNegative = function(x)
{
  minimum=min(x) # Should only use positive minimum!


You have to tell R to only use positive numbers, min(x[x  0]) would  
have worked.


I'm not really sure what you're looping over below.


  for (i in x)
  {

 if(x[i]0) # Found a negative value
 {
x[i]=minimum/10 # Change to a new non-negative value
 }
  }
}


This will work over each column of an orig.df data.frame (assumes  
all cols are numeric) and generate the new data.frame you're looking  
for:


new.df - as.data.frame(apply(orig.df, 2, function(col) {
  min.val - min(col[col  0])
  col[col  0] - min.val
  col
}))

-steve

--
Steve Lianoglou
Graduate Student: Computational Systems Biology
  |  Memorial Sloan-Kettering Cancer Center
  |  Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

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

2009-11-03 Thread Uwe Ligges



Paul Heinrich Dietrich wrote:

This weekend I noticed that my R2WinBUGS connection was no longer working on
my Windows computer at work AND my Ubuntu linux computer at home.  As soon
as WinBUGS opens, the message reads Index Out Of Range.  I have un-installed


Yes, thanks, problem known for R-2.10.0 and under investigation.



and re-installed R on both computers and the problem remains the same.  At
first I thought it was the new version of R, but I was able to overcome the
problem (on Windows only) with the use of

program=openbugs

in R2WinBUGS.  But that doesn't work on Linux.



That works because it just uses a wrapper for BRugs and the real is done 
be BRugs.


Best,
Uwe Ligges



PS
The smallest WinBUGS program I have, essentially a t-test, still works.  But
anything larger than that gets the error.

Help.  Thanks.


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


Re: [R] Calculate Averages for time data

2009-11-03 Thread Sunita Patil
Thank you so much it did solve my purpose.

Regards

Our Thoughts have the Power to Change our Destiny.
Sunita


On Tue, Nov 3, 2009 at 9:15 PM, Gabor Grothendieck
ggrothendi...@gmail.comwrote:

 Next time please provide sample input.

 library(chron)

 # input
 ch - c(02:24:00, 04:48:00, 07:12:00, 09:36:00, 12:00:00,
 14:24:00, 16:48:00, 19:12:00, 21:36:00)

 # convert to times
 tt - times(ch)

 # calculate mean
 mean(tt)


 On Tue, Nov 3, 2009 at 10:35 AM, Sunita22 sunita...@gmail.com wrote:
 
  Hello
 
  I have time data which is in hh:mm:ss format and I need to calculate
  averages for this data. I tried converting the data as integer so that I
  could calculate the average, but it doesn't serve the purpose. I tried
 using
  Chron package also. But I am stuck up as to how to deal with the time
 data.
  Please guide me as to how to deal with Time data in R.
 
  Thank you in advance
 
  Regards
  Sunita
  --
  View this message in context:
 http://old.nabble.com/Calculate-Averages-for-time-data-tp26160202p26160202.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.


[R] How to display full name for the coefficients/factors in summary()?

2009-11-03 Thread Jen-Chien Chang

Hi,

I am wondering if there is a way to display the full anme of the 
regression coeffients/factors in the summary?


Suppose I have a bogus data set using weekday as factor which has 7 levels 
such as:


mydata - sample(364)
wk - rep(1:7, 52)
weekday - 
factor(wk,1:7,c(Mon,Tue,Wed,Thu,Fri,Sat,Sun),ordered=T)

test - data.frame(mydata,weekday)
lm.test - lm(mydata ~ weekday, test)
summary(lm.test)
Call:
lm(formula = mydata ~ weekday)

Residuals:
 Min   1Q   Median   3Q  Max
-205.615  -93.486   -2.212   88.851  199.423

Coefficients:
Estimate Std. Error t value Pr(|t|)
(Intercept) 182.5000 5.5137  33.100   2e-16 ***
weekday.L   -27.042614.5878  -1.854   0.0646 .
weekday.Q-0.921114.5878  -0.063   0.9497
weekday.C-1.656514.5878  -0.114   0.9097
weekday^4   -16.644914.5878  -1.141   0.2546
weekday^5 9.943614.5878   0.682   0.4959
weekday^6   -14.397114.5878  -0.987   0.3243
---
Signif. codes:  0 *** 0.001 ** 0.01 * 0.05 . 0.1   1

Residual standard error: 105.2 on 357 degrees of freedom
Multiple R-squared: 0.01705,Adjusted R-squared: 0.0005341
F-statistic: 1.032 on 6 and 357 DF,  p-value: 0.4039 
---


Why is the name for the regression coeffients/factors display as 
weekday.L, weekday.Q, weekday^6 instead of Tue, Wed, and such? Is 
there a simple way of changing options to fix it?


Please advise and many thanks for your help!

Jack Chang

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

2009-11-03 Thread Michael Just
Hello,

Thanks for the responses.  Yes, I did try to use ?bargraph.CI for the
colors. When I said bars,  I meant the main bars on the graph not the
error bars. However, this col=c(color, color) is what I was
needed and while it didn't find in the ?bargraph.ci help, I suspect
its a  more fundamental R thing that I was unaware of.  Regardless,
thank you for the example.

bargraph.CI(dose, len, group = supp, data =ToothGrowth,
+ col=c(gray,black))

Regarding the confidence intervals.  Yes, I am looking for the 95%
confidence interval of the mean.  Using the ci.fun can I get +/- 1.96
SD?

bargraph.CI(x.factor = dose, response = len, data = ToothGrowth,
ci.fun= function(x) c(mean(x)-sd(x), mean(x) + sd(x)) )

I tried variations on this like,

ci.fun= function(x) c(mean(x)-(1.96*sd(x))), mean(x) + (1.96*sd(x))) )

but this didn't work.  Maybe this approach above seems silly, but I
hope I am exhibiting that I do indeed what the 95% CI for the mean,
but that I am unsure how to have the error bars reflect this using the
ci.fun argument.  Can I use this argument or is some pre-processing
necessary?  If this information is located somewhere besides the
?bargraph.ci help I would greatly appreciate an indication of where it
is.

Thank you kindly,
Michael Just

On Tue, Nov 3, 2009 at 8:53 AM, Manuel Morales
manuel.a.mora...@williams.edu wrote:
 On Tue, 2009-11-03 at 03:51 -0600, Michael Just wrote:
 Hello,
 When using bargraph.CI in package sciplot can the bars for each group
 be different colors?  How do I select the color for each group?

 With the option err.col

 bargraph.CI(dose, len, group = supp, data =ToothGrowth,
 err.col=c(gray,black))

 When I use this instead of the default (SD vs SE):

 bargraph.CI(x.factor = dose, response = len, data = ToothGrowth,

                ci.fun= function(x) c(mean(x)-sd(x), mean(x) + sd(x)) )


 Am I getting 95% CI bars?

 No. You're plotting +/- 1 SD.

 Thank you kindly,
 Michael Just

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


 --
 http://mutualism.williams.edu



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 display a string containing greek chrs and variables

2009-11-03 Thread J . delasHeras

Quoting baptiste auguie baptiste.aug...@googlemail.com:


Hi,

try this,

plot.new()
x=0.8
text(0.5, 0.5, bquote(rho == .(x)))


HTH,

baptiste



Aha!

That does exactly what i wanted! Thanks!

Jose

--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

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

2009-11-03 Thread Steve Lianoglou

Hi Joel,

On Nov 3, 2009, at 11:30 AM, Joel Fürstenberg-Hägg wrote:

  However, I get the following error:
 
  Error in if (x[i]  0) { : argument is of length zero

 This is telling you that x[i] is a zero length object, so you're
 indexing is wrong


Doesn't x[i] means index i in vector x?


Yes.


Or could it be that there's a missing value at that index?


Don't think so: NA  0 returns NA, not an error regarding the  
argument's length in your `if` clause.


How do I deal with them in that case? I need to keep the length of  
the vector so I cannot remove NAs if that affects the length...


I'm not sure how to answer this. Just try to learn a bit more about  
how to index using integers, vectors of integers, and vectors of  
logical/boolean values.



 This will work over each column of an orig.df data.frame (assumes
 all cols are numeric) and generate the new data.frame you're looking
 for:

 new.df - as.data.frame(apply(orig.df, 2, function(col) {
 min.val - min(col[col  0])
 col[col  0] - min.val
 col
 }))


Ok, that's exactly what I was aming for! Thanks a lot!!


Great. Don't just use that code though, understand what it's doing ..  
it'll help you to slice and dice your data in the future.


If you have any questions regarding the details of that code snippet  
that you can't figure out after careful inspection, feel free to ask.


-steve

--
Steve Lianoglou
Graduate Student: Computational Systems Biology
  |  Memorial Sloan-Kettering Cancer Center
  |  Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

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

2009-11-03 Thread Konrad Banachewicz
LinkedIn


Konrad Banachewicz requested to add you as a connection on LinkedIn:
--

Arnaud,

I'd like to add you to my professional network on LinkedIn.

- Konrad

Accept invitation from Konrad Banachewicz
http://www.linkedin.com/e/qlt6CtWzi7sEoE_As_C0_wMfEZD2c-gGLFL6LO/blk/I180262_2/pmpxnSRJrSdvj4R5fnhv9ClRsDgZp6lQs6lzoQ5AomZIpn8_cBYOdz8Me3kRdjkNiiZvliRQjQRTdOYOe3oQd3ATcPwLrCBxbOYWrSlI/EML_comm_afe/

View invitation from Konrad Banachewicz
http://www.linkedin.com/e/qlt6CtWzi7sEoE_As_C0_wMfEZD2c-gGLFL6LO/blk/I180262_2/39vczoOc3wRdjkRckALqnpPbOYWrSlI/svi/

--

Why might connecting with Konrad Banachewicz be a good idea?

Have a question? Konrad Banachewicz's network will probably have an answer:
You can use LinkedIn Answers to distribute your professional questions to 
Konrad Banachewicz and your extended network. You can get high-quality answers 
from experienced professionals.

http://www.linkedin.com/e/ash/inv19_ayn/

 
--
(c) 2009, LinkedIn Corporation


[[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 display full name for the coefficients/factors in summary()?

2009-11-03 Thread Kingsford Jones
By default orthogonal polynomial contrasts are used for ordered
factors. Drop the 'ordered = TRUE' and you will get treatment
contrasts.

hth,
Kingsford Jones

On Tue, Nov 3, 2009 at 8:52 AM, Jen-Chien Chang jcch...@andrew.cmu.edu wrote:
 Hi,

 I am wondering if there is a way to display the full anme of the regression
 coeffients/factors in the summary?

 Suppose I have a bogus data set using weekday as factor which has 7 levels
 such as:

 mydata - sample(364)
 wk - rep(1:7, 52)
 weekday -
 factor(wk,1:7,c(Mon,Tue,Wed,Thu,Fri,Sat,Sun),ordered=T)
 test - data.frame(mydata,weekday)
 lm.test - lm(mydata ~ weekday, test)
 summary(lm.test)
 Call:
 lm(formula = mydata ~ weekday)

 Residuals:
     Min       1Q   Median       3Q      Max
 -205.615  -93.486   -2.212   88.851  199.423

 Coefficients:
            Estimate Std. Error t value Pr(|t|)
 (Intercept) 182.5000     5.5137  33.100   2e-16 ***
 weekday.L   -27.0426    14.5878  -1.854   0.0646 .
 weekday.Q    -0.9211    14.5878  -0.063   0.9497
 weekday.C    -1.6565    14.5878  -0.114   0.9097
 weekday^4   -16.6449    14.5878  -1.141   0.2546
 weekday^5     9.9436    14.5878   0.682   0.4959
 weekday^6   -14.3971    14.5878  -0.987   0.3243
 ---
 Signif. codes:  0 *** 0.001 ** 0.01 * 0.05 . 0.1   1

 Residual standard error: 105.2 on 357 degrees of freedom
 Multiple R-squared: 0.01705,    Adjusted R-squared: 0.0005341
 F-statistic: 1.032 on 6 and 357 DF,  p-value: 0.4039
 ---

 Why is the name for the regression coeffients/factors display as weekday.L,
 weekday.Q, weekday^6 instead of Tue, Wed, and such? Is there a simple
 way of changing options to fix it?

 Please advise and many thanks for your help!

 Jack Chang

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

2009-11-03 Thread Terry Therneau
 To extract various portions of the coxph standard printout, look at
summary.coxph
 help('summary.coxph')

fit - coxph(...
sfit - summary(fit)

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] how to display a string containing greek chrs and variables

2009-11-03 Thread Peter Ehlers

j.delashe...@ed.ac.uk wrote:

Quoting baptiste auguie baptiste.aug...@googlemail.com:


Hi,

try this,

plot.new()
x=0.8
text(0.5, 0.5, bquote(rho == .(x)))


HTH,

baptiste



Aha!

That does exactly what i wanted! Thanks!

Jose


But does it do what it should? It's customary to use
rho for a _population_ correlation coefficient. If your
(x,y) values represent a _sample_, then it would probably
be more appropriate to use the more mundane r or
perhaps rho-hat.




--
Peter Ehlers
University of Calgary

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] creating mulptiple new variables from one data.frame according to columns and rows in that frame

2009-11-03 Thread Hayes, Daniel
Dear R-helpers,

I have a data.frame (bcpe.lat.m) containing 13 countries, ages 0-50yrs per 
month, and the corresponding musigma (see below).

*I would like to limit the age range to include all 12 months for the 
1st 5 years and only whole years for all ages thereafter for each of the 
countries present in the data frame.

*I would like to create separate data.frames according to the country 
the data is from (Bolivia.bcpe.lat.m, brazil.bcpe.lat.m, etc)


I have tried using:  c(seq(0,5,1/12),seq(5,50,1) )  to select the desired ages 
but am unsure how to repeat that sequence for consecutive countries.
I have tried using: split(bcpe.lat.m, bcpe.lat.m$country) But end up with a 
string which I am no longer to select the specific ages I want and all the data 
still remains in one  variable
Have also looked a 'by', 'apply' and things like 'for (i in 1:13)'

Help with either or both steps would be greatly appreciated.

Greetings from Formentera,
Daniel

   Age(yrs) country   mu sigma
1   0.   Bolivia 11.42168 0.1014872
2   0.0833   Bolivia 11.33625 0.1053837
3   0.1667   Bolivia 11.28417 0.1070594
4   0.2500   Bolivia 11.21125 0.1083872
5   0.   Bolivia 11.11637 0.1095305
...
602  0.  Brazil 11.54888 0.10839417
603  0.0833  Brazil 11.46345 0.11255592
604  0.1667  Brazil 11.41137 0.11434565
605  0.2500  Brazil 11.33844 0.11576378
606  0.  Brazil 11.24357 0.11698489
...


[[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] Issue with %in% - not matching identical rows in data frames

2009-11-03 Thread Kaushik Krishnan
Hi folks

I have two data frames.  I know that the nth (let's say the 7th) row
in the first data frame (sequence) is there in the second
(today.sequence).  When I try to check that by doing 'sequence[7,]
%in% today.sequence', I get all FALSE when it should be all TRUE.

I'm certain I'm making some trivial mistake.  Any solutions?

The code to recreate the data frames and see for yourself is:

sequence - structure(list(DATE = structure(c(14549, 14549, 14553, 14550,
14557, 14550, 14551, 14550), class = Date), DATASET = c(1L,
2L, 1L, 2L, 2L, 3L, 3L, 4L), REP = c(1L, 0L, 2L, 2L, 3L, 0L,
1L, 0L), WRONGS_ABS = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), WRONGS_RATIO = c(0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L), DONE = c(1L, 1L, 0L, 1L, 0L, 1L,
0L, 0L)), .Names = c(DATE, DATASET, REP, WRONGS_ABS,
WRONGS_RATIO, DONE), class = data.frame, row.names = c(NA,
-8L))

today.sequence - structure(list(DATE = structure(c(14551, 14550),
class = Date),
DATASET = 3:4, REP = c(1L, 0L), WRONGS_ABS = c(0L, 0L),
WRONGS_RATIO = c(0L,
0L), DONE = c(0L, 0L)), .Names = c(DATE, DATASET, REP,
WRONGS_ABS, WRONGS_RATIO, DONE), row.names = 7:8, class = data.frame)

sequence[7,] #You should see '2009-11-03   3   1  0
00'

today.sequence #You can clearly see that sequence [7,] is the first
row in today.sequence

sequence[7,] %in% today.sequence #This should show 'TRUE TRUE TRUE
TRUE TRUE TRUE'.  Instead
# it shows 'FALSE FALSE FALSE FALSE FALSE FALSE'


Thanks

-- 
Kaushik Krishnan
(kaushik.s.krish...@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.


[R] Stacked barplot: specifying individual bar hue/luminance

2009-11-03 Thread chaski01

Hi all,

I'm trying to generate barplots from simple but long (~10-row) data
files, in which each bar will comprise two stacked 'sub-bars'.  All the
upper sub-bars will have the same hue, and all the lower bars will,
likewise, have another uniform hue.  However, I wish to specify the
luminance (aka brightness) of each bar (i.e., each whole bar comprising two
sub-bars) separately, and I wish the plot to render without spaces between
successive bars. 

I've been trying to get this going in ggplot2.  Two problems arise: first,
I'm unable to eliminate the spaces between successive bars.  And second (and
more importantly), while I can vary transparency (i.e., alpha) of bars
singly, I'm not sophisticated enough with the grammar to know how to define
a color palette that lets me vary the luminance singly.  Can anyone suggest
how to do this, either in ggplot or in basic R (or some other package)?

Many thanks,

Nathan Pearson
nathaniel.pear...@gmail.com
-- 
View this message in context: 
http://old.nabble.com/Stacked-barplot%3A-specifying-individual-bar-hue-luminance-tp26160543p26160543.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 2.10.0: Error in gsub/calloc

2009-11-03 Thread richard . liu
I'm running R 2.10.0 under Mac OS X 10.5.8; however, I don't think this
is a Mac-specific problem.

I have a very large (158,908 possible sentences, ca. 58 MB) plain text
document d which I am
trying to tokenize:  t - strapply(d, \\w+, perl = T).  I am
encountering the following error:

Error in base::gsub(pattern, rs, x, ...) :
  Calloc could not allocate (-1398215180 of 1) memory

This happens regardless of whether I run in 32- or 64-bit mode.  The
machine has 8 GB of RAM, so
I can hardly believe that RAM is a problem.

Thanks,
Richard

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


[R] Stacked barplot: specifying individual bar hue/luminance

2009-11-03 Thread chaski01

Hi all,

I'm trying to generate barplots from simple but long (~10-row) data
files, in which each bar will comprise two stacked 'sub-bars'.  All the
upper sub-bars will have the same hue, and all the lower bars will,
likewise, have another uniform hue.  However, I wish to specify the
luminance (aka brightness) of each bar (i.e., each whole bar comprising two
sub-bars) separately, and I wish the plot to render without spaces between
successive bars. 

I've been trying to get this going in ggplot2.  Two problems arise: first,
I'm unable to eliminate the spaces between successive bars.  And second (and
more importantly), while I can vary transparency (i.e., alpha) of bars
singly, I'm not sophisticated enough with the grammar to know how to define
a color palette that lets me vary the luminance singly.  Can anyone suggest
how to do this, either in ggplot or in basic R (or some other package)?

Many thanks,

Nathan Pearson
nathaniel.pear...@gmail.com
-- 
View this message in context: 
http://old.nabble.com/Stacked-barplot%3A-specifying-individual-bar-hue-luminance-tp26160523p26160523.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] Issue with %in% - not matching identical rows in data frames

2009-11-03 Thread Sundar Dorai-Raj
?%in% says x and table must be vectors. You supplied
data.frames. So %in% is coercing your today.sequence to a vector using

as.character(today.sequence)

Perhaps you should paste the columns together first:

x - do.call(paste, c(sequence, sep = ::))
table - do.call(paste, c(today.sequence, sep = ::))
x[7] %in% table

I'm not sure if this is what you want/need, but it does match your example.

HTH,

--sundar

On Tue, Nov 3, 2009 at 7:53 AM, Kaushik Krishnan
kaushik.s.krish...@gmail.com wrote:
 Hi folks

 I have two data frames.  I know that the nth (let's say the 7th) row
 in the first data frame (sequence) is there in the second
 (today.sequence).  When I try to check that by doing 'sequence[7,]
 %in% today.sequence', I get all FALSE when it should be all TRUE.

 I'm certain I'm making some trivial mistake.  Any solutions?

 The code to recreate the data frames and see for yourself is:
 
 sequence - structure(list(DATE = structure(c(14549, 14549, 14553, 14550,
 14557, 14550, 14551, 14550), class = Date), DATASET = c(1L,
 2L, 1L, 2L, 2L, 3L, 3L, 4L), REP = c(1L, 0L, 2L, 2L, 3L, 0L,
 1L, 0L), WRONGS_ABS = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), WRONGS_RATIO = c(0L,
 0L, 0L, 0L, 0L, 0L, 0L, 0L), DONE = c(1L, 1L, 0L, 1L, 0L, 1L,
 0L, 0L)), .Names = c(DATE, DATASET, REP, WRONGS_ABS,
 WRONGS_RATIO, DONE), class = data.frame, row.names = c(NA,
 -8L))

 today.sequence - structure(list(DATE = structure(c(14551, 14550),
 class = Date),
    DATASET = 3:4, REP = c(1L, 0L), WRONGS_ABS = c(0L, 0L),
 WRONGS_RATIO = c(0L,
    0L), DONE = c(0L, 0L)), .Names = c(DATE, DATASET, REP,
 WRONGS_ABS, WRONGS_RATIO, DONE), row.names = 7:8, class = data.frame)

 sequence[7,] #You should see '2009-11-03       3   1          0
    0    0'

 today.sequence #You can clearly see that sequence [7,] is the first
 row in today.sequence

 sequence[7,] %in% today.sequence #This should show 'TRUE TRUE TRUE
 TRUE TRUE TRUE'.  Instead
 # it shows 'FALSE FALSE FALSE FALSE FALSE FALSE'
 

 Thanks

 --
 Kaushik Krishnan
 (kaushik.s.krish...@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.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] AR Simulation with non-normal innovations - Correct

2009-11-03 Thread Ricardo Gonçalves Silva
Thanks Andreas.
This is just the start point I was needing.

Best,

Rick


From: Andreas Hary 
Sent: Tuesday, November 03, 2009 7:19 AM
To: Ricardo Gonçalves Silva 
Subject: Re: [R] AR Simulation with non-normal innovations - Correct


Have a look at function arima.sim. It allows you to specify a random number 
generator, so you could try something like the following:

arModel - list(ar = 0, ma = 0, order = c(0, 1, 0))
tGarchGen - function(a, b, c) {
  # your stuff here, must return a vector of random deviates
}
arima.sim(arModel, n = 100, rand.gen = tGarchGen)

If you would like to generate a bunch of series, say 200, all at once try

mySeries - replicate(200, arima.sim(arModel, n = 100, rand.gen = tGarchGen))


HTH,

Andreas






2009/11/2 Ricardo Gonçalves Silva ricard...@terra.com.br

  Dear Users,

  I would like to simulate an AR(1) (y_t=ct1+y_t-1+e_t) model in R where the 
innovations are supposed to follow a t-GARCH(1,1) proccess.

  By t-GARCH I want to mean that:

  e_t=n_t*sqrt(h_t) and
  h_t=ct2+a*(e_t)^2+b*h_t-1.

  where n_t is a random variable with t-Student distribution.

  If someone could give some guidelines, I can going developing the model.
  I did it in matlab, but the loops are very slowly, so I would like to try R.

  Thanks in advance,

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









No virus found in this incoming message.
Checked by AVG - www.avg.com 

05:51: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] reference on p.adjust()

2009-11-03 Thread Uwe Ligges



Peng Yu wrote:

I'm wondering if there is a textbook that summarize the methods on
adjusting p-values for multiple comparisons. Most of the references on
p.adjust() are over 10 years old. 


Being 10 years old does not mean the calculus behind those methods has 
changed.




I feel it would be better if
somebody could recommend me a textbook on multiple hypothesis
correction, so that I can quickly get a general idea of different
methods.



There are some around just search for your keywords.

Best wishes,
Uwe Ligges



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] reference on p.adjust()

2009-11-03 Thread Peng Yu
2009/11/3 Uwe Ligges lig...@statistik.tu-dortmund.de:


 Peng Yu wrote:

 I'm wondering if there is a textbook that summarize the methods on
 adjusting p-values for multiple comparisons. Most of the references on
 p.adjust() are over 10 years old.

 Being 10 years old does not mean the calculus behind those methods has
 changed.

I never said that the calculus has been changed.

 I feel it would be better if
 somebody could recommend me a textbook on multiple hypothesis
 correction, so that I can quickly get a general idea of different
 methods.


 There are some around just search for your keywords.

I prefer descriptions from books. Most online description are not very
satisfactory, because they are not peer reviewed.

I looked through Testing Statistical Hypotheses by Lehmann. This book
only gives references to the recent works. If you happen to know a
review article or a textbook that summarize all the methods in
multiple hypothesis correction. Please let me know.

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

2009-11-03 Thread Uwe Ligges



richard@pueo-owl.ch wrote:

I'm running R 2.10.0 under Mac OS X 10.5.8; however, I don't think this
is a Mac-specific problem.

I have a very large (158,908 possible sentences, ca. 58 MB) plain text
document d which I am
trying to tokenize:  t - strapply(d, \\w+, perl = T).  I am
encountering the following error:



What is strapply() and what is d?

Uwe Ligges





Error in base::gsub(pattern, rs, x, ...) :
  Calloc could not allocate (-1398215180 of 1) memory

This happens regardless of whether I run in 32- or 64-bit mode.  The
machine has 8 GB of RAM, so
I can hardly believe that RAM is a problem.

Thanks,
Richard

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

2009-11-03 Thread Ravi Chandra
Hello all...
We are trying to use the analytical power of R in a Web based
environment, and are seeking the optimal ways of accomplishing the
same.  We need R to accept requests from clients, perform analysis on
the data as required by the users and return the results ( formatted
text, graphs, etc) to the web browser.  We have a Windows server with
an IIS, Cold fusion app server that we want to talk to R.  Can someone
suggest an optimal way of accomplishing this? (I am a novice at this,
so I hope you ask me for specific details that are necessary)  Some of
the things that we had unsuccessfully tried included playing around
with:
1) CGIwithR package:  This package appeared to be geared for Unix /
Apache systems, so we couldn't get too far in the Windows Environment.
2) Biocep.net : We tried to use the tools from biocep.net to generate
SOAP service definitions for R functions.  We followed the
instructions on biocep.net but we couldn't run the java program to
access the R-soap from java.

It would be great if someone in the group has had success in
implementing R-Soap through biocep packages, that can guide us.  Even
otherwise, what is the best way to access R from the web?  Will
running R under Apache make things easier?
Any help will be greatly appreciated.
Thanks,
Ravi


-- 
The destiny of the river is not its shores but the ocean

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Create Artificial Binary Matrix based on probability

2009-11-03 Thread Erik Iverson
Try 
matrix(rbinom(100, 1, prob = 0.048), nrow = 10)



 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of bikemike42
 Sent: Tuesday, November 03, 2009 11:49 AM
 To: r-help@r-project.org
 Subject: [R] Create Artificial Binary Matrix based on probability
 
 
 Dear All,
 
 I am trying to create an artificial binary matrix such that each cell has
 a
 probability of 0.048 of having a 1.  So far the closest I've come is us by
 using a random poisson distribution with a mean of 0.048, but I can't
 figure
 out how to limit the max value to 1.  Otherwise that would work fine it
 seems.  Any suggestions?
 
 The main code I've got to create said matrix so far is:
 a-replicate(26,rpois(57,0.048))
 
 Thanks in Advance,
 Mike
 --
 View this message in context: http://old.nabble.com/Create-Artificial-
 Binary-Matrix-based-on-probability-tp26160622p26160622.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] Re place only first NA in column

2009-11-03 Thread Erik Iverson
Mike,

Is this what you're trying to do, it avoids the awkward use of a while loop, 
taking advantage of the ability to vectorize R functions. 

fun - function() {
  z - matrix(rbinom(832, 1, prob = 0.048), nrow = 32)
  sum(rowSums(z) == 0)
}

a - as.matrix(replicate(1000, fun()))



 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of bikemike42
 Sent: Tuesday, November 03, 2009 2:58 PM
 To: r-help@r-project.org
 Subject: [R] Re place only first NA in column
 
 
 Dear All,
 
 I am trying to fill in a blank vector (a) with one value at a time, with
 the value of the number of rows in a randomized dataset with rowSums=0.
 Below is the code I've got so far, but what I want to be as the last line
 is
  a[1st NA,]=nz
 such that this will run until all of my NAs are replaced with an integer
 value based on randomizations.
 
 a-matrix(nrow=1000,ncol=1)
 while(sum(is.na(a)0))
   {
   z-matrix(rbinom(832, 1, prob = 0.048), nrow = 32)
   rs-rowSums(z)
   nz-length(rs[rs==0])
   a[,]=nz
 
 }
 
 Thank you for your help!
 Mike
 --
 View this message in context: http://old.nabble.com/Replace-only-first-NA-
 in-column-tp26163589p26163589.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] reference on p.adjust()

2009-11-03 Thread Uwe Ligges



Peng Yu wrote:

2009/11/3 Uwe Ligges lig...@statistik.tu-dortmund.de:


Peng Yu wrote:

I'm wondering if there is a textbook that summarize the methods on
adjusting p-values for multiple comparisons. Most of the references on
p.adjust() are over 10 years old.

Being 10 years old does not mean the calculus behind those methods has
changed.


I never said that the calculus has been changed.


I feel it would be better if
somebody could recommend me a textbook on multiple hypothesis
correction, so that I can quickly get a general idea of different
methods.


There are some around just search for your keywords.


I prefer descriptions from books. Most online description are not very
satisfactory, because they are not peer reviewed.



Sure, I meant to find the books. There is for example focussed on 
Bioinformatics applications:



Dudoit, Sandrine and van der Laan, Mark J (2008):
Multiple Testing Procedures with Applications to Genomics, Springer, New 
York.


But that is just one example - and I tend not to mention books in 
answers to such requests since books are a matter of taste and may 
depend on the audience, community in which to use the method, and the 
application.




I looked through Testing Statistical Hypotheses by Lehmann. This book
only gives references to the recent works. If you happen to know a
review article or a textbook that summarize all the methods in
multiple hypothesis correction. Please let me know.



For the good old methods, I only happen to know German textbooks. Should 
be summarized in any good overview textbook on testing, though.


Best,
Uwe Ligges




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

2009-11-03 Thread Kenneth Roy Cabrera Torres
Try the patch version... 
Maybe is the same problem I had with large
database when using gsub()

HTH

El mar, 03-11-2009 a las 20:31 +0100, Richard R. Liu escribió:
 I apologize for not being clear.  d is a character vector of length  
 158908.  Each element in the vector has been designated by sentDetect  
 (package: openNLP) as a sentence.  Some of these are really  
 sentences.  Others are merely groups of meaningless characters  
 separated by white space.  strapply is a function in the package  
 gosubfn.  It applies to each element of the first argument the regular  
 expression (second argument).  Every match is then sent to the  
 designated function (third argument, in my case missing, hence the  
 identity function).  Thus, with strapply I am simply performing a  
 white-space tokenization of each sentence.  I am doing this in the  
 hope of being able to distinguish true sentences from false ones on  
 the basis of mean length of token, maximum length of token, or similar.
 
 Richard R. Liu
 Dittingerstr. 33
 CH-4053 Basel
 Switzerland
 
 Tel.:  +41 61 331 10 47
 Email:  richard@pueo-owl.ch
 
 
 On Nov 3, 2009, at 18:30 , Uwe Ligges wrote:
 
 
 
  richard@pueo-owl.ch wrote:
  I'm running R 2.10.0 under Mac OS X 10.5.8; however, I don't think  
  this
  is a Mac-specific problem.
  I have a very large (158,908 possible sentences, ca. 58 MB) plain  
  text
  document d which I am
  trying to tokenize:  t - strapply(d, \\w+, perl = T).  I am
  encountering the following error:
 
 
  What is strapply() and what is d?
 
  Uwe Ligges
 
 
 
 
  Error in base::gsub(pattern, rs, x, ...) :
   Calloc could not allocate (-1398215180 of 1) memory
  This happens regardless of whether I run in 32- or 64-bit mode.  The
  machine has 8 GB of RAM, so
  I can hardly believe that RAM is a problem.
  Thanks,
  Richard
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide 
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
 --Apple-Mail-8--203371287--
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Weird operator behaviour

2009-11-03 Thread Erik Iverson
Argument recycling is coming into play here with !=.  I am guessing you want

! fish$Species %in% c(CRA, PHC)

?

Best Regards,
Erik Iverson 
 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of jimdare
 Sent: Tuesday, November 03, 2009 4:02 PM
 To: r-help@r-project.org
 Subject: [R] Weird operator behaviour
 
 
 Hi,
 
 I have a dataset called 'fish'.  fish$Species returns extract 1.  When I
 use
 fish$Species != c(CRA,PHC), i.e. I want all species except CRA and
 PHC, I get extract 2 which is blatantly wrong.  Can anyone see what I'm
 doing wrong?
 
 Regards,
 James
 
 
 EXTRACT 1
 
  fish$Species
   [1] ALB ALB ALB ALB ALB ALB ALB ALB ALB ALB ALB ALB ALB ALB ALB ALB ATO
 ATO
  [19] ATO ATO ATO ATO ATO ATO BIG BIG BIG BIG BIG BIG BIG BIG BIG BIG BIG
 BIG
  [37] BIG BIG BWS BWS BWS BWS BWS BWS BWS BWS BWS BWS BWS BWS BWS BWS BWS
 CRA
  [55] CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA
 CRA
  [73] CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA
 CRA
  [91] CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA
 CRA
 [109] CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA
 CRA
 [127] CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA
 CRA
 [145] CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA
 CRA
 [163] CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA
 CRA
 [181] CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA
 CRA
 [199] CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA
 CRA
 [217] CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA
 CRA
 [235] CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA
 CRA
 [253] CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA
 CRA
 [271] CRA CRA CRA CRA CRA CRA CRA CRA MAK MAK MAK MAK MAK MAK MAK MAK MAK
 MAK
 [289] MAK MAK MAK MAK MAK MOO MOO MOO MOO MOO MOO MOO MOO MOO MOO MOO MOO
 MOO
 [307] MOO MOO PHC PHC PHC PHC PHC PHC PHC PHC PHC PHC PHC PHC PHC PHC PHC
 PHC
 [325] PHC PHC PHC POS POS POS POS POS POS POS POS POS POS POS PTO PTO PTO
 PTO
 [343] PTO PTO PTO PTO PTO PTO PTO PTO PTO PTO PTO RBM RBM RBM RBM RBM RBM
 RBM
 [361] RBM RBM RBM RBM RBM RBM RBM RBM SKJ SKJ SKJ SKJ SKJ SKJ SKJ SKJ SKJ
 SKJ
 [379] SKJ SKJ SKJ SKJ SKJ STM STM STM STM STM STM STM STM STN STN STN STN
 STN
 [397] STN STN STN STN STN STN STN STN STN STN STN STN STN STN STN STN STN
 STN
 [415] SWO SWO SWO SWO SWO SWO SWO SWO SWO SWO SWO SWO SWO SWO SWO SWO TOR
 TOR
 [433] TOR TOR TOR TOR TOR TOR YFN YFN YFN YFN YFN YFN YFN YFN YFN YFN YFN
 YFN
 [451] YFN YFN YFN YFN
 17 Levels: ALB ATO BIG BWS CRA MAK MOO PHC POS PTO RBM SKJ STM STN SWO ...
 YFN
 
 EXTRACT 2
 
  fish$Species != c(CRA,PHC)
   [1]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE
 TRUE
  [13]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE
 TRUE
  [25]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE
 TRUE
  [37]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE
 TRUE
  [49]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE FALSE  TRUE FALSE  TRUE FALSE
 TRUE
  [61] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE
 TRUE
  [73] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE
 TRUE
  [85] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE
 TRUE
  [97] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE
 TRUE
 [109] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE
 TRUE
 [121] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE
 TRUE
 [133] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE
 TRUE
 [145] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE
 TRUE
 [157] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE
 TRUE
 [169] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE
 TRUE
 [181] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE
 TRUE
 [193] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE
 TRUE
 [205] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE
 TRUE
 [217] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE
 TRUE
 [229] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE
 TRUE
 [241] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE
 TRUE
 [253] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE
 TRUE
 [265] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE
 TRUE
 [277] FALSE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE
 TRUE
 [289]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE
 TRUE
 [301]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE FALSE  TRUE
 FALSE
 [313]  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE
 FALSE
 [325]  TRUE FALSE  TRUE  TRUE  TRUE  TRUE  

Re: [R] Weird operator behaviour

2009-11-03 Thread Peter Alspach
Tena koe James

Have you tried something like !fish$Species%in%c('CRA','PHC')?

HTH 

Peter Alspach 

 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of jimdare
 Sent: Wednesday, 4 November 2009 11:02 a.m.
 To: r-help@r-project.org
 Subject: [R] Weird operator behaviour
 
 
 Hi,
 
 I have a dataset called 'fish'.  fish$Species returns extract 
 1.  When I use fish$Species != c(CRA,PHC), i.e. I want 
 all species except CRA and PHC, I get extract 2 which is 
 blatantly wrong.  Can anyone see what I'm doing wrong? 
 
 Regards,
 James 
 
 
 EXTRACT 1
 
  fish$Species
   [1] ALB ALB ALB ALB ALB ALB ALB ALB ALB ALB ALB ALB ALB ALB 
 ALB ALB ATO ATO  [19] ATO ATO ATO ATO ATO ATO BIG BIG BIG BIG 
 BIG BIG BIG BIG BIG BIG BIG BIG  [37] BIG BIG BWS BWS BWS BWS 
 BWS BWS BWS BWS BWS BWS BWS BWS BWS BWS BWS CRA  [55] CRA CRA 
 CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA 
 CRA  [73] CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA 
 CRA CRA CRA CRA CRA  [91] CRA CRA CRA CRA CRA CRA CRA CRA CRA 
 CRA CRA CRA CRA CRA CRA CRA CRA CRA [109] CRA CRA CRA CRA CRA 
 CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA [127] CRA 
 CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA 
 CRA CRA [145] CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA 
 CRA CRA CRA CRA CRA CRA [163] CRA CRA CRA CRA CRA CRA CRA CRA 
 CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA [181] CRA CRA CRA CRA 
 CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA [199] 
 CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA 
 CRA CRA CRA [217] CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA 
 CRA CRA CRA CRA CRA CRA CRA [235] CRA CRA CRA CRA CRA CRA CRA 
 CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA [253] CRA CRA CRA 
 CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA 
 [271] CRA CRA CRA CRA CRA CRA CRA CRA MAK MAK MAK MAK MAK MAK 
 MAK MAK MAK MAK [289] MAK MAK MAK MAK MAK MOO MOO MOO MOO MOO 
 MOO MOO MOO MOO MOO MOO MOO MOO [307] MOO MOO PHC PHC PHC PHC 
 PHC PHC PHC PHC PHC PHC PHC PHC PHC PHC PHC PHC [325] PHC PHC 
 PHC POS POS POS POS POS POS POS POS POS POS POS PTO PTO PTO 
 PTO [343] PTO PTO PTO PTO PTO PTO PTO PTO PTO PTO PTO RBM RBM 
 RBM RBM RBM RBM RBM [361] RBM RBM RBM RBM RBM RBM RBM RBM SKJ 
 SKJ SKJ SKJ SKJ SKJ SKJ SKJ SKJ SKJ [379] SKJ SKJ SKJ SKJ SKJ 
 STM STM STM STM STM STM STM STM STN STN STN STN STN [397] STN 
 STN STN STN STN STN STN STN STN STN STN STN STN STN STN STN 
 STN STN [415] SWO SWO SWO SWO SWO SWO SWO SWO SWO SWO SWO SWO 
 SWO SWO SWO SWO TOR TOR [433] TOR TOR TOR TOR TOR TOR YFN YFN 
 YFN YFN YFN YFN YFN YFN YFN YFN YFN YFN [451] YFN YFN YFN YFN
 17 Levels: ALB ATO BIG BWS CRA MAK MOO PHC POS PTO RBM SKJ 
 STM STN SWO ...
 YFN
 
 EXTRACT 2
 
  fish$Species != c(CRA,PHC)
   [1]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  
 TRUE  TRUE TRUE  [13]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  
 TRUE  TRUE  TRUE  TRUE  TRUE TRUE  [25]  TRUE  TRUE  TRUE  
 TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE TRUE  [37]  
 TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  
 TRUE TRUE  [49]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE FALSE  
 TRUE FALSE  TRUE FALSE TRUE  [61] FALSE  TRUE FALSE  TRUE 
 FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE TRUE  [73] FALSE  
 TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE 
 TRUE  [85] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE 
 FALSE  TRUE FALSE TRUE  [97] FALSE  TRUE FALSE  TRUE FALSE  
 TRUE FALSE  TRUE FALSE  TRUE FALSE TRUE [109] FALSE  TRUE 
 FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE TRUE 
 [121] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  
 TRUE FALSE TRUE [133] FALSE  TRUE FALSE  TRUE FALSE  TRUE 
 FALSE  TRUE FALSE  TRUE FALSE TRUE [145] FALSE  TRUE FALSE  
 TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE TRUE [157] 
 FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE 
 FALSE TRUE [169] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  
 TRUE FALSE  TRUE FALSE TRUE [181] FALSE  TRUE FALSE  TRUE 
 FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE TRUE [193] FALSE  
 TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE 
 TRUE [205] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE 
 FALSE  TRUE FALSE TRUE [217] FALSE  TRUE FALSE  TRUE FALSE  
 TRUE FALSE  TRUE FALSE  TRUE FALSE TRUE [229] FALSE  TRUE 
 FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE TRUE 
 [241] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  
 TRUE FALSE TRUE [253] FALSE  TRUE FALSE  TRUE FALSE  TRUE 
 FALSE  TRUE FALSE  TRUE FALSE TRUE [265] FALSE  TRUE FALSE  
 TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE TRUE [277] 
 FALSE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  
 TRUE TRUE [289]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  
 TRUE  TRUE  TRUE  TRUE TRUE [301]  TRUE  TRUE  TRUE  TRUE  
 TRUE  TRUE  TRUE  TRUE  TRUE FALSE  TRUE FALSE [313]  TRUE 
 FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE 
 FALSE [325]  TRUE FALSE  TRUE  TRUE  TRUE  TRUE  

Re: [R] Re place only first NA in column

2009-11-03 Thread Steve Lianoglou

Hi,

On Nov 3, 2009, at 3:58 PM, bikemike42 wrote:



Dear All,

I am trying to fill in a blank vector (a) with one value at a  
time, with
the value of the number of rows in a randomized dataset with  
rowSums=0.
Below is the code I've got so far, but what I want to be as the last  
line is

 a[1st NA,]=nz
such that this will run until all of my NAs are replaced with an  
integer

value based on randomizations.

a-matrix(nrow=1000,ncol=1)
while(sum(is.na(a)0))
{
z-matrix(rbinom(832, 1, prob = 0.048), nrow = 32)
rs-rowSums(z)
nz-length(rs[rs==0])
a[,]=nz

}

Thank you for your help!


It's not really clear to me what you want to actually replace each NA  
value with. But it sounds like your 'general' question is how to find  
the index of the first value of a vector that is NA.


Let's say your `a` vector has NA values you want to replace, one by one.

any.na - any(is.na(a))
while (any.na) {
  first.na - which(is.na(a))[1]
  a[first.na] - your.NA.replacing.function()
  any.na - any(is.na(a))
}

HTH,
-steve

--
Steve Lianoglou
Graduate Student: Computational Systems Biology
  |  Memorial Sloan-Kettering Cancer Center
  |  Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] help with SSOAP (can't find working examples)

2009-11-03 Thread Steffen Neumann
Hi,

I can confirm this, just today 
I tried to write a web service client.
Affected are both SSOAP-0.5-4 and SSOAP_0.4-6.

I can't access anonymous CVS atm. to check for recent fixes.
I am unable to map the error message to any of the items in 
http://www.omegahat.org/SSOAP/Todo.html , is this already known ?

Yours,
Steffen

library(SSOAP)
Loading required package: XML
Loading required package: RCurl
Loading required package: bitops
 w = processWSDL(http://www.massbank.jp/api/services/MassBankAPI?wsdl;)
Error: Cannot resolve ns:searchPeakDiff in SchemaCollection
In addition: Warning messages:
1: In function (node)  :
  skipping import node with no schemaLocation attribute
2: In processWSDL(http://www.massbank.jp/api/services/MassBankAPI?wsdl;) :
  Ignoring additional serviceport ... elements
 sessionInfo()
R version 2.8.1 (2008-12-22) 
x86_64-pc-linux-gnu 

locale:
LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C

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

other attached packages:
[1] SSOAP_0.4-6RCurl_1.3-0bitops_1.0-4.1 XML_2.5-3   


w = processWSDL(http://www.massbank.jp/api/services/MassBankAPI?wsdl;)
Error: Cannot resolve ns:searchPeakDiff in SchemaCollection
In addition: Warning messages:
1: In function (node)  :
  skipping import node with no schemaLocation attribute
2: In processWSDL(http://www.massbank.jp/api/services/MassBankAPI?wsdl;) :
  Ignoring additional serviceport ... elements

Enter a frame number, or 0 to exit   

 1: processWSDL(http://www.massbank.jp/api/services/MassBankAPI?wsdl;)
 2: lapply(tmp, processWSDLBindings, doc, types)
 3: FUN(X[[1]], ...)
 4: lapply(els, processWSDLOperation, types, doc, namespaceDefinitions, typeDef
 5: FUN(X[[1]], ...)
 6: xmlSApply(msg, function(x) {
 7: xmlSApply.XMLNode(msg, function(x) {
 8: sapply(xmlChildren(X), FUN, ...)
 9: lapply(X, FUN, ...)
10: FUN(X[[1]], ...)
11: resolve(el, typeDefinitions)
12: resolve(el, typeDefinitions)
13: resolveError(Cannot resolve , obj,  in , class(context))




-- 
IPB HalleAG Massenspektrometrie  Bioinformatik
Dr. Steffen Neumann  http://www.IPB-Halle.DE
Weinberg 3   http://msbi.bic-gh.de
06120 Halle  Tel. +49 (0) 345 5582 - 1470
  +49 (0) 345 5582 - 0
sneumann(at)IPB-Halle.DE Fax. +49 (0) 345 5582 - 1409

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Create Artificial Binary Matrix based on probability

2009-11-03 Thread Mike Treglia

Thanks a lot Erik and Tony!
Both of your suggestions accomplish what I need. 
Cheers,

Mike

Erik Iverson wrote:
Try 
matrix(rbinom(100, 1, prob = 0.048), nrow = 10)




  

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of bikemike42
Sent: Tuesday, November 03, 2009 11:49 AM
To: r-help@r-project.org
Subject: [R] Create Artificial Binary Matrix based on probability


Dear All,

I am trying to create an artificial binary matrix such that each cell has
a
probability of 0.048 of having a 1.  So far the closest I've come is us by
using a random poisson distribution with a mean of 0.048, but I can't
figure
out how to limit the max value to 1.  Otherwise that would work fine it
seems.  Any suggestions?

The main code I've got to create said matrix so far is:
a-replicate(26,rpois(57,0.048))

Thanks in Advance,
Mike
--
View this message in context: http://old.nabble.com/Create-Artificial-
Binary-Matrix-based-on-probability-tp26160622p26160622.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.



  


--
Michael L. Treglia
Graduate Student
Wildlife and Fisheries Sciences
Texas AM University
Lab: (979)862-7245
Cell: (917)841-5603
ml...@tamu.edu
http://people.tamu.edu/~mlt35

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Issue with %in% - not matching identical rows in data frames

2009-11-03 Thread Charles C. Berry



Kaushik,

The documentation doesn't quite tell (me, anyway) how the function behaves 
when 'target' is a list (or data.frame). You'll need to dig into match.c 
or experiment with match() or %in% to see what it is actually doing.


But it looks like it is matching whole columns of the data.frame rather 
than elements within each column :



 sequence %in% sequence

[1] TRUE TRUE TRUE TRUE TRUE TRUE

 sequence %in% rev(sequence)

[1] TRUE TRUE TRUE TRUE TRUE TRUE


 sequence[1,] %in% sequence

[1] FALSE FALSE FALSE FALSE FALSE FALSE

 sequence[1,] %in% sequence[1,]

[1] TRUE TRUE TRUE TRUE TRUE TRUE




Maybe you wanted something like

mapply( function(x,y) x%in%y , sequence[7, ], today.sequence )

??

HTH,

Chuck


On Tue, 3 Nov 2009, Kaushik Krishnan wrote:


Hi folks

I have two data frames.  I know that the nth (let's say the 7th) row
in the first data frame (sequence) is there in the second
(today.sequence).  When I try to check that by doing 'sequence[7,]
%in% today.sequence', I get all FALSE when it should be all TRUE.

I'm certain I'm making some trivial mistake.  Any solutions?

The code to recreate the data frames and see for yourself is:

sequence - structure(list(DATE = structure(c(14549, 14549, 14553, 14550,
14557, 14550, 14551, 14550), class = Date), DATASET = c(1L,
2L, 1L, 2L, 2L, 3L, 3L, 4L), REP = c(1L, 0L, 2L, 2L, 3L, 0L,
1L, 0L), WRONGS_ABS = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), WRONGS_RATIO = c(0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L), DONE = c(1L, 1L, 0L, 1L, 0L, 1L,
0L, 0L)), .Names = c(DATE, DATASET, REP, WRONGS_ABS,
WRONGS_RATIO, DONE), class = data.frame, row.names = c(NA,
-8L))

today.sequence - structure(list(DATE = structure(c(14551, 14550),
class = Date),
   DATASET = 3:4, REP = c(1L, 0L), WRONGS_ABS = c(0L, 0L),
WRONGS_RATIO = c(0L,
   0L), DONE = c(0L, 0L)), .Names = c(DATE, DATASET, REP,
WRONGS_ABS, WRONGS_RATIO, DONE), row.names = 7:8, class = data.frame)

sequence[7,] #You should see '2009-11-03   3   1  0
   00'

today.sequence #You can clearly see that sequence [7,] is the first
row in today.sequence

sequence[7,] %in% today.sequence #This should show 'TRUE TRUE TRUE
TRUE TRUE TRUE'.  Instead
# it shows 'FALSE FALSE FALSE FALSE FALSE FALSE'


Thanks

--
Kaushik Krishnan
(kaushik.s.krish...@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.



Charles C. Berry(858) 534-2098
Dept of Family/Preventive Medicine
E mailto:cbe...@tajo.ucsd.edu   UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Create Artificial Binary Matrix based on probability

2009-11-03 Thread bikemike42

Dear All,

I am trying to create an artificial binary matrix such that each cell has a
probability of 0.048 of having a 1.  So far the closest I've come is us by
using a random poisson distribution with a mean of 0.048, but I can't figure
out how to limit the max value to 1.  Otherwise that would work fine it
seems.  Any suggestions?

The main code I've got to create said matrix so far is:
a-replicate(26,rpois(57,0.048))

Thanks in Advance,
Mike
-- 
View this message in context: 
http://old.nabble.com/Create-Artificial-Binary-Matrix-based-on-probability-tp26160620p26160620.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] Create Artificial Binary Matrix based on probability

2009-11-03 Thread bikemike42

Dear All,

I am trying to create an artificial binary matrix such that each cell has a
probability of 0.048 of having a 1.  So far the closest I've come is us by
using a random poisson distribution with a mean of 0.048, but I can't figure
out how to limit the max value to 1.  Otherwise that would work fine it
seems.  Any suggestions?

The main code I've got to create said matrix so far is:
a-replicate(26,rpois(57,0.048))

Thanks in Advance,
Mike
-- 
View this message in context: 
http://old.nabble.com/Create-Artificial-Binary-Matrix-based-on-probability-tp26160622p26160622.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] Passing Command to Optim in factanal

2009-11-03 Thread Ali Torkamani
Hi,

I am currently trying to execute the following command:

f-factanal(factors=k$Components$nparallel,covmat=m,n.obs=2287,rotation=varimax,control=list(opt=list(method=c(BFGS

but keep getting the error: L-BFGS-B needs finite values of 'fn'

I can't figure out what I am doing wrong here, why isn't optim being told to 
use BFGS instead of L-BFGS-B...

Any help would be very muc appreciated.

Thanks,
Ali
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Re place only first NA in column

2009-11-03 Thread bikemike42

Dear All,

I am trying to fill in a blank vector (a) with one value at a time, with
the value of the number of rows in a randomized dataset with rowSums=0. 
Below is the code I've got so far, but what I want to be as the last line is
 a[1st NA,]=nz
such that this will run until all of my NAs are replaced with an integer
value based on randomizations.

a-matrix(nrow=1000,ncol=1)
while(sum(is.na(a)0))
{
z-matrix(rbinom(832, 1, prob = 0.048), nrow = 32)
rs-rowSums(z)
nz-length(rs[rs==0])
a[,]=nz

}

Thank you for your help!
Mike
-- 
View this message in context: 
http://old.nabble.com/Replace-only-first-NA-in-column-tp26163589p26163589.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] ROC

2009-11-03 Thread carol white
My question would be related more to time-dependent ROC (survivalROC package):

I would like to know how true positives (TP) and false positives (FP) are 
related to the order of survival times and diagnostic markers. That is, having 
the a set of TP and FP, each of them is calculated from which diagnostic marker 
and survival times. Let's take mayo data set. How could I match the TP and FP 
generated from survivalROC function to cut.values (output) and Stimes (input)?

Best,

Carol

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] OpenOffice Calc ODBC equivalent (SOLVED)

2009-11-03 Thread Kenneth Roy Cabrera Torres
Thank you Dr. Schwartz:

I did not read this post before,
 See this post from late 2007:
 
http://tolstoy.newcastle.edu.au/R/e3/help/07/12/6478.html
 
 As far as I know, nothing has changed vis-a-via ODBC connectivity TO  
 OpenOffice files. You can use ODBC FROM OpenOffice to connect to  
 external data sources.
Yes, I found that too.
 A search of CRAN does not reveal any packages/functions to would  
 appear to provide a facility to directly write data frames to a Calc  
 file. However, you can always write to a XLS file, 
Yes, I am going to do that.
 open it in Calc and  
 re-save it as a native Calc file. Of course, anyone with Calc can open  
 an XLS file, so you are not losing much in terms of portability by  
 saving to an XLS file and distributing that. You also make it easier  
 for folks who may be using other 'office' applications that do not  
 have import filters for OO.org file formats.

I was looking for xlsReadWrite package, but it seems that
it is removed form the CRAN repository, then I found your WriteXLS
package, which I am going to use.

I see that dataframes2xls is other package that can helps me too.

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] Re place only first NA in column

2009-11-03 Thread Mike Treglia

Erik and Steve,
Thanks again for your help, both solutions do exactly what I need.
Cheers,
Mike

Steve Lianoglou wrote:

Hi,

On Nov 3, 2009, at 3:58 PM, bikemike42 wrote:



Dear All,

I am trying to fill in a blank vector (a) with one value at a time, 
with

the value of the number of rows in a randomized dataset with rowSums=0.
Below is the code I've got so far, but what I want to be as the last 
line is

 a[1st NA,]=nz
such that this will run until all of my NAs are replaced with an integer
value based on randomizations.

a-matrix(nrow=1000,ncol=1)
while(sum(is.na(a)0))
{
z-matrix(rbinom(832, 1, prob = 0.048), nrow = 32)
rs-rowSums(z)
nz-length(rs[rs==0])
a[,]=nz
   
}


Thank you for your help!


It's not really clear to me what you want to actually replace each NA 
value with. But it sounds like your 'general' question is how to find 
the index of the first value of a vector that is NA.


Let's say your `a` vector has NA values you want to replace, one by one.

any.na - any(is.na(a))
while (any.na) {
  first.na - which(is.na(a))[1]
  a[first.na] - your.NA.replacing.function()
  any.na - any(is.na(a))
}

HTH,
-steve

--
Steve Lianoglou
Graduate Student: Computational Systems Biology
  |  Memorial Sloan-Kettering Cancer Center
  |  Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact




--
Michael L. Treglia
Graduate Student
Wildlife and Fisheries Sciences
Texas AM University
Lab: (979)862-7245
Cell: (917)841-5603
ml...@tamu.edu
http://people.tamu.edu/~mlt35

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

2009-11-03 Thread Douglas Bates
On Tue, Nov 3, 2009 at 9:11 AM, wenjun zheng wjzhen...@gmail.com wrote:
 May be I can calculate p value by t testing approximately:
  1-qnorm(Variance/Std.Dev.)

That would be a z test, not a t test, wouldn't it?  And it would only
be meaningful if the distribution of the estimator is approximately
normal, which we know it definitely is not.  Estimates of variances
have distributions like a chi-square, not like a normal.  In
particular, the estimators are not symmetrically distributed about the
parameter value.

 But which function can help me to extract Variance and Std.Dev values from
 the results below:

The VarCorr extractor produces the estimates of the variance.  You
would have to write your own functions to determine an approximate
standard error of those estimates and I would not advise doing so.
Firstly, the code would be rather complicated and secondly the answer
would be of very limited usefulness, for the reasons discussed above.

print(fm2 - lmer(Yield ~ 1 + (1|Stand) + (1|Variety) +
 (1|Variety:Stand),Rice))
 Linear mixed model fit by REML
 Formula: Yield ~ 1 + (1 | Stand) + (1 | Variety) + (1 | Variety:Stand)
    Data: Rice
    AIC   BIC logLik deviance REMLdev
  94.25 100.7 -42.12    85.33   84.25
 Random effects:
  Groups        Name        Variance Std.Dev.
  Variety:Stand (Intercept) 1.345679 1.16003
  Variety       (Intercept) 0.024692 0.15714
  Stand         (Intercept) 0.88 0.94281
  Residual                  0.67 0.81650
 Number of obs: 27, groups: Variety:Stand, 9; Variety, 3; Stand, 3
 Fixed effects:
             Estimate Std. Error t value
 (Intercept)   7.1852     0.6919   10.38

 2009/11/2 Douglas Bates ba...@stat.wisc.edu

 On Sun, Nov 1, 2009 at 9:01 AM, wenjun zheng wjzhen...@gmail.com wrote:
  Hi R Users,
      When I use package lme4 for mixed model analysis, I can't
  distinguish
  the significant and insignificant variables from all random independent
  variables.
      Here is my data and result:
  Data:
 
 
   Rice-data.frame(Yield=c(8,7,4,9,7,6,9,8,8,8,7,5,9,9,5,7,7,8,8,8,4,8,6,4,8,8,9),
                  Variety=rep(rep(c(A1,A2,A3),each=3),3),
                  Stand=rep(c(B1,B2,B3),9),
                  Block=rep(1:3,each=9))
     Rice.lmer-lmer(Yield ~ (1|Variety) + (1|Stand) + (1|Block) +
  (1|Variety:Stand), data = Rice)
 
  Result:
 
  Linear mixed model fit by REML
  Formula: Yield ~ (1 | Variety) + (1 | Stand) + (1 | Block) + (1 |
  Variety:Stand)
    Data: Rice
    AIC   BIC logLik deviance REMLdev
   96.25 104.0 -42.12    85.33   84.25
  Random effects:
   Groups        Name        Variance Std.Dev.
   Variety:Stand (Intercept) 1.345679 1.16003
   Block         (Intercept) 0.00 0.0
   Stand         (Intercept) 0.89 0.94281
   Variety       (Intercept) 0.024691 0.15714
   Residual                  0.67 0.81650
  Number of obs: 27, groups: Variety:Stand, 9; Block, 3; Stand, 3;
  Variety, 3

  Fixed effects:
             Estimate Std. Error t value
  (Intercept)   7.1852     0.6919   10.38

  Can you give me some advice for recognizing the significant variables
  among
  random effects above without other  calculating.

 Well, since the estimate of the variance due to Block is zero, that's
 probably not one of the significant random effects.

 Why do you want to do this without other calculations?  In olden days
 when each model fit involved substantial calculations by hand one did
 try to avoid fitting multiple models but now that is not a problem.
 You can get a hint of which random effects will be significant by
 looking at their precision in a caterpillar plot and then fit the
 reduced model and use anova to compare models.  See the enclosed

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



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


Re: [R] how to display a string containing greek chrs and variables

2009-11-03 Thread J . delasHeras

Quoting Peter Ehlers ehl...@ucalgary.ca:


j.delashe...@ed.ac.uk wrote:

Quoting baptiste auguie baptiste.aug...@googlemail.com:


Hi,

try this,

plot.new()
x=0.8
text(0.5, 0.5, bquote(rho == .(x)))


HTH,

baptiste



Aha!

That does exactly what i wanted! Thanks!

Jose


But does it do what it should? It's customary to use
rho for a _population_ correlation coefficient. If your
(x,y) values represent a _sample_, then it would probably
be more appropriate to use the more mundane r or
perhaps rho-hat.



I'm talking rank correlation, Spearman's rho.

Jose

--
Dr. Jose I. de las Heras  Email: j.delashe...@ed.ac.uk
The Wellcome Trust Centre for Cell BiologyPhone: +44 (0)131 6513374
Institute for Cell  Molecular BiologyFax:   +44 (0)131 6507360
Swann Building, Mayfield Road
University of Edinburgh
Edinburgh EH9 3JR
UK
*
NEW EMAIL from July'09: nach.mcn...@gmail.com
*

--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] one long column of data - three small columns

2009-11-03 Thread Peter Alspach
Tena koe

?matrix 

The exact syntax will depend on the class of your 'column of data'.  If
it is a dataframe, for example, then try

matrix(yourData[,1], 3, 3)

HTH ...

Peter Alspach 

 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of frenchcr
 Sent: Wednesday, 4 November 2009 8:06 a.m.
 To: r-help@r-project.org
 Subject: [R] one long column of data - three small columns
 
 
 say i have a column of data like this...
 
 2
 3
 4
 2
 1
 6
 6
 4
 7
 
 and i want it in three columns like this
 
 226
 314
 467
 
 ...so i can make a contour plot.
 
 
 How do i do this?
 --
 View this message in context: 
 http://old.nabble.com/one-long-column-of-data--%3E-three-small
 -columns-tp26163165p26163165.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] how to display a string containing greek chrs and variables

2009-11-03 Thread Peter Ehlers

j.delashe...@ed.ac.uk wrote:

Quoting Peter Ehlers ehl...@ucalgary.ca:


j.delashe...@ed.ac.uk wrote:

Quoting baptiste auguie baptiste.aug...@googlemail.com:


Hi,

try this,

plot.new()
x=0.8
text(0.5, 0.5, bquote(rho == .(x)))


HTH,

baptiste



Aha!

That does exactly what i wanted! Thanks!

Jose


But does it do what it should? It's customary to use
rho for a _population_ correlation coefficient. If your
(x,y) values represent a _sample_, then it would probably
be more appropriate to use the more mundane r or
perhaps rho-hat.



I'm talking rank correlation, Spearman's rho.

Jose


Rank correlation or not, it's still customary to use r
or r[s] for samples and rho or rho[s] for populations.
But it's up to you, of course.
--
Peter Ehlers
University of Calgary

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] one long column of data - three small columns

2009-11-03 Thread Jorge Ivan Velez
Hi french,

Here is a suggestion:

x - c(2, 3, 4, 2, 1, 6, 6, 4, 7)
 matrix(x, ncol = 3)
#   [,1] [,2] [,3]
# [1,]226
# [2,]314
# [3,]467

with x the column of data you have.

HTH,
Jorge


On Tue, Nov 3, 2009 at 2:05 PM, frenchcr  wrote:


 say i have a column of data like this...

 2
 3
 4
 2
 1
 6
 6
 4
 7

 and i want it in three columns like this

 226
 314
 467

 ...so i can make a contour plot.


 How do i do this?
 --
 View this message in context:
 http://old.nabble.com/one-long-column-of-data--%3E-three-small-columns-tp26163165p26163165.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.


[R] Weird operator behaviour

2009-11-03 Thread jimdare

Hi,

I have a dataset called 'fish'.  fish$Species returns extract 1.  When I use
fish$Species != c(CRA,PHC), i.e. I want all species except CRA and
PHC, I get extract 2 which is blatantly wrong.  Can anyone see what I'm
doing wrong? 

Regards,
James 


EXTRACT 1

 fish$Species
  [1] ALB ALB ALB ALB ALB ALB ALB ALB ALB ALB ALB ALB ALB ALB ALB ALB ATO
ATO
 [19] ATO ATO ATO ATO ATO ATO BIG BIG BIG BIG BIG BIG BIG BIG BIG BIG BIG
BIG
 [37] BIG BIG BWS BWS BWS BWS BWS BWS BWS BWS BWS BWS BWS BWS BWS BWS BWS
CRA
 [55] CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA
CRA
 [73] CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA
CRA
 [91] CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA
CRA
[109] CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA
CRA
[127] CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA
CRA
[145] CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA
CRA
[163] CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA
CRA
[181] CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA
CRA
[199] CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA
CRA
[217] CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA
CRA
[235] CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA
CRA
[253] CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA
CRA
[271] CRA CRA CRA CRA CRA CRA CRA CRA MAK MAK MAK MAK MAK MAK MAK MAK MAK
MAK
[289] MAK MAK MAK MAK MAK MOO MOO MOO MOO MOO MOO MOO MOO MOO MOO MOO MOO
MOO
[307] MOO MOO PHC PHC PHC PHC PHC PHC PHC PHC PHC PHC PHC PHC PHC PHC PHC
PHC
[325] PHC PHC PHC POS POS POS POS POS POS POS POS POS POS POS PTO PTO PTO
PTO
[343] PTO PTO PTO PTO PTO PTO PTO PTO PTO PTO PTO RBM RBM RBM RBM RBM RBM
RBM
[361] RBM RBM RBM RBM RBM RBM RBM RBM SKJ SKJ SKJ SKJ SKJ SKJ SKJ SKJ SKJ
SKJ
[379] SKJ SKJ SKJ SKJ SKJ STM STM STM STM STM STM STM STM STN STN STN STN
STN
[397] STN STN STN STN STN STN STN STN STN STN STN STN STN STN STN STN STN
STN
[415] SWO SWO SWO SWO SWO SWO SWO SWO SWO SWO SWO SWO SWO SWO SWO SWO TOR
TOR
[433] TOR TOR TOR TOR TOR TOR YFN YFN YFN YFN YFN YFN YFN YFN YFN YFN YFN
YFN
[451] YFN YFN YFN YFN
17 Levels: ALB ATO BIG BWS CRA MAK MOO PHC POS PTO RBM SKJ STM STN SWO ...
YFN

EXTRACT 2

 fish$Species != c(CRA,PHC)
  [1]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE 
TRUE
 [13]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE 
TRUE
 [25]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE 
TRUE
 [37]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE 
TRUE
 [49]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE FALSE  TRUE FALSE  TRUE FALSE 
TRUE
 [61] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE 
TRUE
 [73] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE 
TRUE
 [85] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE 
TRUE
 [97] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE 
TRUE
[109] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE 
TRUE
[121] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE 
TRUE
[133] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE 
TRUE
[145] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE 
TRUE
[157] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE 
TRUE
[169] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE 
TRUE
[181] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE 
TRUE
[193] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE 
TRUE
[205] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE 
TRUE
[217] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE 
TRUE
[229] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE 
TRUE
[241] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE 
TRUE
[253] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE 
TRUE
[265] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE 
TRUE
[277] FALSE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE 
TRUE
[289]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE 
TRUE
[301]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE FALSE  TRUE
FALSE
[313]  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE
FALSE
[325]  TRUE FALSE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE 
TRUE
[337]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE 
TRUE
[349]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE 
TRUE
[361]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE 
TRUE
[373]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE 
TRUE
[385]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE 
TRUE
[397]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE 

[R] Setting column widths in heatmap

2009-11-03 Thread Ken Termiso

Hello,

I cannot figure out how to set the column widths (either relative or absolute) 
for the heatmap function - the full manual hints that layout and lcm will 
control this, but I haven't had any luck. 

This is in R 2.9.2 compiled for either FC10 or SUSE11.1 (x86_64)... and am 
sending the output of heatmap to the pdf driver. 

Thanks in advance!
-kt

  
_
Hotmail: Trusted email with Microsoft's powerful SPAM protection.



[[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] reshaping pairs of columns

2009-11-03 Thread jim holtman
Try this:

 require(reshape)
 # melt the data
 x - melt(maps, id='point')
 # split out the labels
 labels - do.call(rbind, strsplit(sub((.*)(.), \\1 \\2, x$variable), ' '))
 x$source - labels[, 2]
 x$variable - labels[, 1]
 cast(x, point + source ~ variable)
   point sourcelat   long
1  1  A  41.68  82.85
2  1  B  41.62  87.67
3  1  C -41.12 -83.03
4  1  D -41.03 -85.10
5  1  E  41.28  82.42
6  1  F  43.13  82.25
7  1  G  42.05  82.88
8  1  H  42.15  81.63
9  1  I  42.03  83.53


On Tue, Nov 3, 2009 at 5:26 PM, Michael Friendly frien...@yorku.ca wrote:
 Given a data frame consisting of a pointID and 12 pairs of (lat, long)
 variables, with names
 latA, longA, latB, longB, ... latL, longL, I want to reshape it into a data
 frame with the structure

 point  source  lat long
  1        A       ...   ...
  1        B      ...    ...

 I've looked at reshape and plyr, but can't figure out how to do this.
  Details of my data frame are below

 dput(head(maps))
 structure(list(point = 1:6, latA = c(41.68, 41.9, 42.25, 42.55,
 44.05, 43.65), longA = c(82.85, 82.52, 81.92, 80.03, 83.03, 83.95
 ), latB = c(41.62, 42.12, 42.07, 42.47, 43.42, 43.12), longB = c(87.67,
 87, 85.97, 84.17, 87.25, 87.92), latC = c(-41.12, 41.88, 42.13,
 42.13, 44.23, 43.25), longC = c(-83.03, 82, 80.78, 79.55, 83.6,
 84.48), latD = c(-41.03, 41.87, 41.98, 42, 44.13, 43.8), longD = c(-85.1,
 85.37, 83.78, 83.18, 86.85, 87.1), latE = c(41.28, 42.08, 42.22,
 42.07, 44.6, 43.72), longE = c(82.42, 81.17, 80.2, 80.27, 83.5,
 83.23), latF = c(43.13, 42.35, 42.62, 42.83, 44.62, 43.62), longF = c(82.25,
 81.77, 81.37, 79.92, 85.5, 85.25), latG = c(42.05, 42.23, 42.37,
 42.37, 44.75, 44.03), longG = c(82.88, 82.35, 81.3, 80.03, 83.57,
 83.47), latH = c(42.15, 42.38, 42.53, 42.87, 44.47, 44.03), longH = c(81.63,
 80.78, 80.35, 78.73, 81.75, 81.72), latI = c(42.03, 42.25, 42.33,
 42.33, 44.75, 44.03), longI = c(83.53, 82.45, 81.98, 80.65, 84.33,
 84.22), latJ = c(42.02, 42.12, 42.5, 42.68, 44.35, 44.07), longJ = c(82.9,
 82.42, 81.87, 80.15, 82.9, 83.6), latK = c(42, 42.08, 42.48,
 42.67, 44.32, 44.03), longK = c(82.9, 82.37, 81.87, 80.18, 82.9,
 83.57), latL = c(-41.12, 42, 42.32, 42.55, 44.27, -44.07), longL = c(-82.12,
 82.08, 81.75, 80.08, 83, -83.12)), .Names = c(point, latA,
 longA, latB, longB, latC, longC, latD, longD, latE,
 longE, latF, longF, latG, longG, latH, longH, latI,
 longI, latJ, longJ, latK, longK, latL, longL), row.names =
 c(NA,
 6L), class = data.frame)

 --
 Michael Friendly     Email: friendly AT yorku DOT ca Professor, Psychology
 Dept.
 York University      Voice: 416 736-5115 x66249 Fax: 416 736-5814
 4700 Keele Street    http://www.math.yorku.ca/SCS/friendly.html
 Toronto, ONT  M3J 1P3 CANADA

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

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] one long column of data - three small columns

2009-11-03 Thread frenchcr



frenchcr wrote:
 
 say i have a column of data like this...
 
 2
 3
 4
 2
 1
 6
 6
 4
 7
 
 and i want it in three columns like this
 
 226
 314
 467
 
 ...so i can make a contour plot.
 
 
 How do i do this?
 

ok, so matrix(x, 3, 3) works.

what if i have 

a
b
c
a
c
a
c

and want

a b c
a   c
a   c

??
-- 
View this message in context: 
http://old.nabble.com/one-long-column-of-data--%3E-three-small-columns-tp26163165p26163570.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] Two questions about cloud().

2009-11-03 Thread Rolf Turner



(1) Is there a (simple) way of getting cloud() to do *both*
type=p and type=h?  I.e. of getting it to plot the points
as points *and* drop a perpendicular line to the underlying plane?

(2) Is there a way of telling cloud() to drop its lines to the
floor of the bounding box, rather than to the plane z=0?
I thought that the zero.scaled argument (for panel.3dscatter())
might be the ticket here, but when I pass this argument to cloud()
I get an error ``Error using packet 1 formal argument zero.scaled
matched by multiple actual arguments.

Ta.

cheers,

Rolf Turner

##
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}

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

2009-11-03 Thread Jorge Ivan Velez
Hi Jim,

Take a look at ?%in%, especially its first example.

HTH,
Jorge


On Tue, Nov 3, 2009 at 5:02 PM, jimdare  wrote:


 Hi,

 I have a dataset called 'fish'.  fish$Species returns extract 1.  When I
 use
 fish$Species != c(CRA,PHC), i.e. I want all species except CRA and
 PHC, I get extract 2 which is blatantly wrong.  Can anyone see what I'm
 doing wrong?

 Regards,
 James


 EXTRACT 1

  fish$Species
  [1] ALB ALB ALB ALB ALB ALB ALB ALB ALB ALB ALB ALB ALB ALB ALB ALB ATO
 ATO
  [19] ATO ATO ATO ATO ATO ATO BIG BIG BIG BIG BIG BIG BIG BIG BIG BIG BIG
 BIG
  [37] BIG BIG BWS BWS BWS BWS BWS BWS BWS BWS BWS BWS BWS BWS BWS BWS BWS
 CRA
  [55] CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA
 CRA
  [73] CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA
 CRA
  [91] CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA
 CRA
 [109] CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA
 CRA
 [127] CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA
 CRA
 [145] CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA
 CRA
 [163] CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA
 CRA
 [181] CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA
 CRA
 [199] CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA
 CRA
 [217] CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA
 CRA
 [235] CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA
 CRA
 [253] CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA CRA
 CRA
 [271] CRA CRA CRA CRA CRA CRA CRA CRA MAK MAK MAK MAK MAK MAK MAK MAK MAK
 MAK
 [289] MAK MAK MAK MAK MAK MOO MOO MOO MOO MOO MOO MOO MOO MOO MOO MOO MOO
 MOO
 [307] MOO MOO PHC PHC PHC PHC PHC PHC PHC PHC PHC PHC PHC PHC PHC PHC PHC
 PHC
 [325] PHC PHC PHC POS POS POS POS POS POS POS POS POS POS POS PTO PTO PTO
 PTO
 [343] PTO PTO PTO PTO PTO PTO PTO PTO PTO PTO PTO RBM RBM RBM RBM RBM RBM
 RBM
 [361] RBM RBM RBM RBM RBM RBM RBM RBM SKJ SKJ SKJ SKJ SKJ SKJ SKJ SKJ SKJ
 SKJ
 [379] SKJ SKJ SKJ SKJ SKJ STM STM STM STM STM STM STM STM STN STN STN STN
 STN
 [397] STN STN STN STN STN STN STN STN STN STN STN STN STN STN STN STN STN
 STN
 [415] SWO SWO SWO SWO SWO SWO SWO SWO SWO SWO SWO SWO SWO SWO SWO SWO TOR
 TOR
 [433] TOR TOR TOR TOR TOR TOR YFN YFN YFN YFN YFN YFN YFN YFN YFN YFN YFN
 YFN
 [451] YFN YFN YFN YFN
 17 Levels: ALB ATO BIG BWS CRA MAK MOO PHC POS PTO RBM SKJ STM STN SWO ...
 YFN

 EXTRACT 2

  fish$Species != c(CRA,PHC)
  [1]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE
 TRUE
  [13]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE
 TRUE
  [25]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE
 TRUE
  [37]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE
 TRUE
  [49]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE FALSE  TRUE FALSE  TRUE FALSE
 TRUE
  [61] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE
 TRUE
  [73] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE
 TRUE
  [85] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE
 TRUE
  [97] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE
 TRUE
 [109] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE
 TRUE
 [121] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE
 TRUE
 [133] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE
 TRUE
 [145] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE
 TRUE
 [157] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE
 TRUE
 [169] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE
 TRUE
 [181] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE
 TRUE
 [193] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE
 TRUE
 [205] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE
 TRUE
 [217] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE
 TRUE
 [229] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE
 TRUE
 [241] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE
 TRUE
 [253] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE
 TRUE
 [265] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE
 TRUE
 [277] FALSE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE
 TRUE
 [289]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE
 TRUE
 [301]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE FALSE  TRUE
 FALSE
 [313]  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE
 FALSE
 [325]  TRUE FALSE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE
 TRUE
 [337]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE
 TRUE
 [349]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE
 TRUE
 [361]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  

Re: [R] Create Artificial Binary Matrix based on probability

2009-11-03 Thread Tony Plate

x - matrix(sample(0:1, 1200, replace=T, prob=c(0.952, 0.048)), ncol=30)
table(x)

x
  01 
1131   69 

x - matrix(sample(0:1, 1200, replace=T, prob=c(0.952, 0.048)), ncol=30)
table(x)

x
  01 
1151   49 





bikemike42 wrote:

Dear All,

I am trying to create an artificial binary matrix such that each cell has a
probability of 0.048 of having a 1.  So far the closest I've come is us by
using a random poisson distribution with a mean of 0.048, but I can't figure
out how to limit the max value to 1.  Otherwise that would work fine it
seems.  Any suggestions?

The main code I've got to create said matrix so far is:
a-replicate(26,rpois(57,0.048))

Thanks in Advance,
Mike


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

2009-11-03 Thread parkbomee


Thanks for your help.


 Date: Mon, 2 Nov 2009 18:50:42 -0500
 Subject: Re: [R] avoiding loop
 From: jholt...@gmail.com
 To: bbom...@hotmail.com
 CC: mtmor...@fhcrc.org; r-help@r-project.org
 
 The first thing I would suggest is convert your dataframes to matrices
 so that you are not having to continually convert them in the calls to
 the functions.  Also I am not sure what the code:
 
   realized_prob = with(DF, {
   ind - (CHOSEN == 1)
   n - tapply(theta_multiple[ind], 
 CS[ind], sum)
   d - tapply(theta_multiple, CS, sum)
   n / d   
   })
 
 is doing.  It looks like 'n' and 'd' might have different lengths
 since they are being created by two different (CS  CS[ind])
 sequences.  I have no idea why you are converting to the DF
 dataframe.  THere is no need for that.  You could just leave the
 vectors (e.g., theta_multiple, CS and ind) as they are and work with
 them.  This is probably where most of your time is being spent.  So if
 you start with matrices and leave the dataframes out of the main loop
 you will probably see an increase in performance.
 
 2009/11/2 parkbomee bbom...@hotmail.com:
  This is the Rprof() report by self time.
  Is it also possible that these routines, which take long self.time, are
  causing the optim() to be slow?
 
 
  $by.self
  self.time self.pct total.time total.pct
  FUN   94.16 16.5  94.16  16.5
  unlist80.46 14.1 120.54  21.1
  lapply76.94 13.5 255.48  44.7
  match 60.76 10.6  60.88  10.7
  as.matrix.data.frame  31.00  5.4  51.12   8.9
  as.character  29.28  5.1  29.28   5.1
  unique.default24.36  4.3  24.40   4.3
  data.frame21.06  3.7  55.78   9.8
  split.default 20.42  3.6  84.38  14.8
  tapply13.84  2.4 414.28  72.5
  structure 11.32  2.0  22.36   3.9
  factor11.08  1.9 127.68  22.3
  attributes-  11.00  1.9  11.00   1.9
  ==10.56  1.8  10.56   1.8
  %*%   10.30  1.8  10.30   1.8
  as.vector 10.22  1.8  10.22   1.8
  as.integer 9.86  1.7   9.86   1.7
  list   9.64  1.7   9.64   1.7
  exp7.12  1.2   7.12   1.2
  as.data.frame.integer  5.98  1.0   8.10   1.4
 
  To: bbom...@hotmail.com
  CC: jholt...@gmail.com; r-help@r-project.org
  Subject: Re: [R] avoiding loop
  From: mtmor...@fhcrc.org
  Date: Sun, 1 Nov 2009 22:14:09 -0800
 
  parkbomee bbom...@hotmail.com writes:
 
   Thank you all.
  
   What Chuck has suggested might not be applicable since the number of
   different times is around 40,000.
  
   The object of optimization in my function is the varying value,
   which is basically data * parameter, of which parameter is the
   object of optimization..
  
   And from the r profiling with a subset of data,
   I got this report..any idea what Anonymous is?
  
  
   $by.total
   total.time total.pct self.time self.pct
   Anonymous 571.56 100.0 0.02 0.0
   optim 571.56 100.0 0.00 0.0
   fn 571.54 100.0 0.98 0.2
 
  You're giving us 'by.total', so these are saying that all the time was
  spent in these functions or the functions they called. Probably all
  are in 'optim' and its arguments; since little self.time is spent
  here, there isn't much to work with
 
   eval 423.74 74.1 0.00 0.0
   with.default 423.74 74.1 0.00 0.0
   with 423.74 74.1 0.00 0.0
 
  These are probably in the internals of optim, where the function
  you're trying to optimize is being set up for evaluation. Again
  there's little self.time, and all these say is that a big piece of the
  time is being spent in code called by this code.
 
   tapply 414.28 72.5 13.84 2.4
   lapply 255.48 44.7 76.94 13.5
   factor 127.68 22.3 11.08 1.9
   unlist 120.54 21.1 80.46 14.1
   FUN 94.16 16.5 94.16 16.5
 
  these look like they are tapply-related calls (looking at the code for
  tapply, it calls lapply, factor, and unlist, and FUN is the function
  argument to tapply), perhaps from the function you're optimizing (did
  you implement this as suggested below? it would really help to have a
  possibly simplified version of the code you're calling).
 
  There is material to work with here, as apparently a fairly large
  amount of self.time is being spent in each of these functions. So
  here's a sample data set
 
  n - 10
  set.seed(123)
  df - data.frame(time=sort(as.integer(ceiling(runif(n)*n/5))),
  value=ceiling(runif(n)*5))

  1   2   >