Re: [R] simulated correlated vectors

2009-11-13 Thread Karl Ove Hufthammer
On Thu, 12 Nov 2009 08:10:12 -0800 (PST) carol white wht_...@yahoo.com 
wrote:
 Having a vector x of float type without any assumption of its distribution 
 (mean, variance etc), how to generate another vector that is 
 correlated with x?

Define an arbitrary function 'f', where 'f' may have a random component, 
and calculate f(x).

 Extensibility: how to simulate more than two correlated vectors (again 
 float type and no preference for their distribution and without having 
 vector x)?

Repeat step 1 several times. If you don't have 'x', define an arbitrary 
vector 'x' first ...

HTH. HAND.

-- 
Karl Ove Hufthammer

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

2009-11-13 Thread carol white
Hi,
Is it normal to get intercept in the list of covariates in the output of 
survreg function with standard error, z, p.value etc? Does it mean that 
intercept was fitted with the covariates? Does Value column represent 
coefficients or some thing else?

Regards,

-
 tmp = survreg(Surv(futime, fustat) ~ ecog.ps + rx, ovarian, 
dist='weibull',scale=1)
 summary(tmp)

Call:
survreg(formula = Surv(futime, fustat) ~ ecog.ps + rx, data = ovarian, 
dist = weibull, scale = 1)
 Value Std. Error  zp
(Intercept)  6.962  1.322  5.267 1.39e-07
ecog.ps -0.433  0.587 -0.738 4.61e-01
rx   0.582  0.587  0.991 3.22e-01

Scale fixed at 1 

Weibull distribution
Loglik(model)= -97.2   Loglik(intercept only)= -98
Chisq= 1.67 on 2 degrees of freedom, p= 0.43 
Number of Newton-Raphson Iterations: 4 
n= 26

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


Re: [R] Plotting Histogram using histogram() and for loop and I want to save the histogram individually ... HELP

2009-11-13 Thread Karl Ove Hufthammer
On Thu, 12 Nov 2009 19:10:52 -0800 (PST) ychu066 ychu066
@aucklanduni.ac.nz wrote:
 And I also want to save each histogram in each separate pdf file using the
 following codes ?.
 png(hist.png[i])
 dev.off()

Try png(paste(hist,i,.png,sep=) instead.

-- 
Karl Ove Hufthammer

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


Re: [R] Problem building R 2.10.0 - Matrix package

2009-11-13 Thread Martin Maechler
Thank you, Russ,
but ...

 RPH == R P Herrold herr...@owlriver.com
 on Thu, 12 Nov 2009 14:13:26 -0500 (EST) writes:

 TA == Thomas Adams thomas.ad...@noaa.gov
TA Attached is the output file from building R 2.10.0 on  RedHat Linux. I
TA have never previously experienced any problems when building R from
TA source with new releases. But, now I get a compile error with the Matrix
TA package:

[...]

RPH The Raw Hide packaging of R 2.10.0 has Matrix in it as a 
RPH new addition ...

RPH [herr...@centos-5 monit]$ rpm -qf /usr/lib64/R/library/Matrix
RPH R-core-2.10.0-2orc

RPH ... whose packaging of such a build of R are you using, that 
RPH you need to package /Matrix separately?

No, we were talking about building R from the sources.
That should still be pretty easily possible on any Linux system
{which has compilers/perl/latex/tcltk/  and a couple of libraries}.

Martin

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


Re: [R] XML: Reading transition matrices into R

2009-11-13 Thread stefan.d...@gmail.com
Thank you so much
You really helped me a lot!
Best from R'dam,
Stefan



On Fri, Nov 13, 2009 at 2:14 AM, Duncan Temple Lang
dun...@wald.ucdavis.edu wrote:


 stefan.d...@gmail.com wrote:
 Hello,
 thanks a lot. This is a form which I can work with in R.

 Another question, which I hope is not a bridge too far: Can I write
 the R matrix which your code created back into the xml format (i.e.
 with the same tags and structure) from which it came and hence feed it
 back to the original software?


 trans = apply(xx, 1, function(x) {
                       tr = newXMLNode(transition)
                       mapply(newXMLNode, names(x), x, MoreArgs = list(parent 
 = tr))
                       tr
                     })
 top = newXMLNode(transitionmatrix, .children = trans)
 saveXML(top, newTransition.xml)





 Best,
 Stefan


 On Thu, Nov 12, 2009 at 3:17 PM, Duncan Temple Lang
 dun...@wald.ucdavis.edu wrote:

 stefan.d...@gmail.com wrote:
 Hello,
 from a software I have the following output in xml (see below):
 It is a series of matrices, for each age one. I have 3 categories
 (might vary in the application), hence, 3x3 matrices where each
 element gives the probability of transition from i to j. I would like
 read this data into R (preferably in a list, where each list element
 is one of the age specific matrices) and - after altering the values
 in R - write it back into the file.  I know that there is an xml
 package in R with which I have already struggled, but I have to admit
 my understanding is too limited. Maybe somebody had a similar problem
 or know the code of the top of his or her head.
 Hi Stefan

  There are many approaches for handling this. I assume that the primary
 obstacle you are facing is extracting the values from the XML.  The 
 following
 will do that for you.
 We start with the content in transition.xml (or in a string in R).
 Since the XML is very shallow, i.e. not very hierarchical, and all
 the information is in the transition nodes under the root, we can
 use xmlToList().
 This returns a list with an element for each transition
 element, and such elements are character vectors containing the
 values from age, sex, from, to, and percent.
 So I've put these into a matrix and you are now back entirely
 within R and can group the values by age and arrange them into
 the individual transition matrices.


   doc = xmlParse(transition.xml)
   matrix(as.numeric(unlist(xmlToList(doc))), , 5, byrow = TRUE,
          dimnames = list(NULL, names(xmlRoot(doc)[[1]])))


  D.



 Any help appreciated.

 Thanks and best,
 Stefan





 ?xml version=1.0 encoding=UTF-8 standalone=no?transitionmatrix
 transitionage0/agesex0/sexfrom1/fromto1/topercent99.9/percent/transitiontransitionage0/agesex0/sexfrom1/fromto2/topercent0.0/percent/transitiontransitionage0/agesex0/sexfrom1/fromto3/topercent0.0/percent/transitiontransitionage0/agesex0/sexfrom2/fromto1/topercent0.0/percent/transitiontransitionage0/agesex0/sexfrom2/fromto2/topercent99.85/percent/transitiontransitionage0/agesex0/sexfrom2/fromto3/topercent0.0/percent/transitiontransitionage0/agesex0/sexfrom3/fromto1/topercent0.0/percent/transitiontransitionage0/agesex0/sexfrom3/fromto2/topercent0.0/percent/transitiontransitionage0/agesex0/sexfrom3/fromto3/topercent99.85/percent/transitiontransitionage0/agesex1/sexfrom1/fromto1/topercent100.0/percent/transitiontransitionage
 0
 /!
  agesex1/sexfrom1/fromto2/topercent0.0/percent/transitiontransitionage0/agesex1/sexfrom1/fromto3/topercent0.0/percent/transitiontransitionage0/agesex1/sexfrom2/fromto1/topercent0.0/percent/transitiontransitionage0/agesex1/sexfrom2/fromto2/topercent100.0/percent/transitiontransitionage0/agesex1/sexfrom2/fromto3/topercent0.0/percent/transitiontransitionage0/agesex1/sexfrom3/fromto1/topercent0.0/percent/transitiontransitionage0/agesex1/sexfrom3/fromto2/topercent0.0/percent/transitiontransitionage0/agesex1/sexfrom3/fromto3/topercent100.0/percent/transitiontransitionage1/agesex0/sexfrom1/fromto1/topercent99.9/percent/transitiontransitionage1/agesex0/sexfrom1/fromto2/topercent0.0/percent/transitiontransitionage1/agesex0/sexfrom1/f
 ro
 m!
  to3/topercent0.0/percent/transitiontransitionage1/age
 sex0/sexfrom2/fromto1/topercent0.0/percent/transitiontransitionage1/agesex0/sexfrom2/fromto2/topercent99.85/percent/transitiontransitionage1/agesex0/sexfrom2/fromto3/topercent0.0/percent/transitiontransitionage1/agesex0/sexfrom3/fromto1/topercent0.0/percent/transitiontransitionage1/agesex0/sexfrom3/fromto2/topercent0.0/percent/transitiontransitionage1/agesex0/sexfrom3/fromto3/topercent99.85/percent/transitiontransitionage1/agesex1/sexfrom1/fromto1/topercent100.0/percent/transitiontransitionage1/agesex1/sexfrom1/fromto2/topercent0.0/percent/transitiontransitionage1/agesex1/sexfrom1/fromto3/topercent0.0/percent/transitiontransitionage1/agesex1/sexfrom2/fromto1/topercent0.0/percent/transitiontransitionage1/agesex1/sexfrom2/f
 ro
 m!
  

[R] All combination

2009-11-13 Thread RON70

Please consider the following :

 expand.grid(rep(list(c(1:3)), 3))
   Var1 Var2 Var3
1 111
2 211
3 311
4 121
5 221
6 321
7 131
8 231
9 331
10112
11212
12312
13122
14222
15322
16132
17232
18332
19113
20213
21313
22123
23223
24323
25133
26233
27333


Now I want to remove the rows which has any repetition of number. For
example I want to remove row 1-5 but not 6 and so on

Is there any easy way to do that?

Thanks,
-- 
View this message in context: 
http://old.nabble.com/All-combination-tp2648p2648.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] All combination

2009-11-13 Thread Dimitris Rizopoulos

have a look at function permutations from package 'e1071', e.g.,

library(e1071)
permutations(3)


I hope it helps.

Best,
Dimitris


RON70 wrote:

Please consider the following :


expand.grid(rep(list(c(1:3)), 3))

   Var1 Var2 Var3
1 111
2 211
3 311
4 121
5 221
6 321
7 131
8 231
9 331
10112
11212
12312
13122
14222
15322
16132
17232
18332
19113
20213
21313
22123
23223
24323
25133
26233
27333


Now I want to remove the rows which has any repetition of number. For
example I want to remove row 1-5 but not 6 and so on

Is there any easy way to do that?

Thanks,


--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus University Medical Center

Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014

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

2009-11-13 Thread Peter Dalgaard

alphaace wrote:

Hi, I've looked around but can't find a clear answer to the difference for
these two? Any help?

Thanks!


One is a scaled version of the other, at least for lm objects:

 stats:::dfbetas.lm
function (model, infl = lm.influence(model, do.coef = TRUE),
...)
{
xxi - chol2inv(model$qr$qr, model$qr$rank)
dfbeta(model, infl)/outer(infl$sigma, sqrt(diag(xxi)))
}

so it is essentially dividing by s.e.(beta), except that it uses 
infl$sigma which AFAICS is the leave-one-out residual sd.


--
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - (p.dalga...@biostat.ku.dk)  FAX: (+45) 35327907

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 package for reading / writing 3D file (. PLY)

2009-11-13 Thread kvarpun


Duncan Murdoch-2 wrote:
 
 On 11/12/2009 11:37 AM, kvarpun wrote:
 
 Duncan Murdoch-2 wrote:
 
 On 11/12/2009 4:56 AM, kvarpun wrote:
 Hi,
 
 Is there an R package that reads and writes 3D images having the
 extension
 PLY (PLY images of Stanford University)?
 
 Currently, I installed the package misc3d. This package displays these
 images PLY, but it can neither read nor write PLY images.
 
 This doesn't make sense.  How can it display PLY images if it can't read 
 them?  Could you give an example?
 
 Duncan Murdoch
 
 
 Thank you to tell me the name of a package that will read and write
 such
 images.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 
 
 Thank you for quick answer.
 I have to inform you that the only available functions in the package
 misc3d
 are:
 
 contour3d Draw an Isosurface, a Three Dimension Contour
 Plot
   drawSceneRendering of Triangular Mesh Surface Data
   image3dDraw Points on a 3D Grid
   kde3dCompute a Three Dimension Kernel Density
 Estimate
   makeTriangles   Triangle Mesh Functions
   parametric3d  Draw a 3D Parametric Plot
   perspLighting  Lighting Functions
   phongLighting Lighting Functions
   pointsTetrahedra Create a Set of Tetrahetra Centered at Data Points
   scaleTriangles   Triangle Mesh Functions
   slices3d Interactive Image Slices of 3D or 4D Volume
 Data
   surfaceTriangles Create a Triangle Mesh Representing a Surface
   teapotUtah Teapot
   translateTriangles   Triangle Mesh Functions
   updateTriangles  Triangle Mesh Functions
 
 None of them does read/write a PLY file.
 
 
 You will find below a simple code for drawing a 3D image. The displayed
 image is stored in the package misc3d (not read from a file). 
 
 library(misc3d)
 data(teapot)
 
 haveRGL - suppressWarnings(require(rgl,quietly=TRUE))
 ttri - makeTriangles(teapot$vertices, teapot$edges, color = red,
 color2 =
 green)
 
 ## draw the teapot
 drawScene(ttri,screen=list(y=-30,x=40), scale = FALSE) 
 
 str(teapot)
 #  str(teapot)
 # List of 2
 # $ vertices: num [1:3, 1:1976] -3,00 1,65 0,00 -2,99 1,65 ...
 # $ edges   : int [1:3, 1:3751] 1455 1469 1459 1449 1455 1459 1462 1449
 1459
 1469 ...
 
 # My images (PLY images) have vertices and edges like the teapot image in
 the example. If PLY images are read by R, I will be able to manipulate
 them.
 
 Okay, I understand now.  Yes, R can display 3D images based on lines and 
 polygons using the rgl package or scatterplot3d or grid graphics, but 
 those have nothing to do with PLY files.  As far as I know there is no 
 existing code to read or write a PLY file, but from the look of it, it's 
 a simple format and it wouldn't be hard to write input/output routines. 
   The likely problems are:
 
   - it's an open ended format, with each application allowed to define 
 its own record types.  If your files come from an application that did 
 that you may have trouble working out what was intended and reading it in.
 
   - some of the recommended elements are not supported in rgl or other 
 3D renderers in R.  In particular, polygons with more than 4 vertices 
 need to be decomposed into triangles or quads, and rgl knows nothing 
 about refraction index:  you'd probably need a ray-tracing renderer for 
 that.
 
   - rgl scenes contain text, and as far as I can see, there's no way to 
 include that in a standard PLY file, so you'd need to invent your own 
 record type for it.  Text is always hard to describe graphically, so 
 this wouldn't be easy.
 
 Duncan Murdoch
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 
Thank you for all these precisions.
I guess developping an R package for reading/writing PLY files is required.
Have a nice day.

-- 
View this message in context: 
http://old.nabble.com/R-package-for-reading---writing-3D-file-%28.-PLY%29-tp26315292p26333989.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] starting html help for a package?

2009-11-13 Thread Liviu Andronic
On 11/12/09, Duncan Murdoch murd...@stats.uwo.ca wrote:
   help(package=boot, help_type = html)

  The page displayed there was never an HTML page.  In the future it probably
 should be, but it hasn't been implemented yet.

At the moment is there a way to call the html help for a package, that
is starting in a browser the text displayed by help(package=boot)?


  It's in the tools package, which you probably hadn't attached.  If you
 followed the advice and used ??, you would have got it.

Indeed. I assumed that with 2.10 this was deprecated, but I was wrong.
Liviu

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


Re: [R] why the same values cannot be judged to be the same in R

2009-11-13 Thread jim holtman
I think you want to use '%in%' instead of '=='.  Try debugging (or
understanding) what is happening by evaluating the subexpressions of
the compares you have in your original posting.  Also take a look at
the 'recycling' of arguments and then you may understand what is
happening:

 data2[(data2$x1 %in% data_1$x1)  (data2$y1 %in% data_1$y1)  (data2$tag == 
 0),]
  areaid   x1   y1 tag
2  1 1.53 2.34   0
4  1 1.52 2.35   0



On Thu, Nov 12, 2009 at 10:04 PM, rusers.sh rusers...@gmail.com wrote:
 Hi Rusers,
  I found sometimes that the same values cannot be judged to be the same in
 R. Anybody knows the probelm? I think i ignored some minor detail. Thanks.
 Here is the example.
 
 data1-matrix(data=c(1,1.2,1.3,3/23/2004,1,1.5,2.3,3/22/2004,2,0.2,3.3,4/23/2004,3,1.5,1.3,5/22/2004),nrow=4,ncol=4,byrow=TRUE)
 data1-data.frame(data1);names(data1)-c(areaid,x,y,date)
 data2-matrix(data=c(1,1.22,1.32,1,  1.53,  2.34,1,  1.21,  1.37,1,  1.52,
 2.35,2,  0.21,  3.33,2,  0.23,  3.35,3,  1.57, 1.31,3,  1.59,
 1.33),nrow=8,ncol=3,byrow=TRUE)
 data2-data.frame(data2);names(data2)-c(areaid,x1,y1)
 data2$tag-0
 data1_1-data1[1,]
 data2_1-data2[data2$areaid==data1_1$areaid  data2$tag==0,]
 ran_1-sample(c(1:length(data2_1)),2, replace = FALSE)
 data2_1-data2_1[ran_1,]
 data_1-merge(data1_1,data2_1)
 #data_1
 #       areaid  x   y      date   x1   y1  tag
 #    1      1 1.2 1.3 3/23/2004 1.52 2.35   0
 #    2      1 1.2 1.3 3/23/2004 1.53 2.34   0
 data2[data_1$x1==data2$x1  data_1$y1==data2$y1  data2$tag==0,]
  #data2[c(data_1$x1==data2$x1  data_1$y1==data2$y1  data2$tag==0),]
 #    areaid   x1    y1   tag
 #2      1    1.53  2.34   0
  There should be two same observations between data_1 and data2, but here
 only one was identified.
  Thanks a lot.

 --
 -
 Jane Chang
 Queen's

        [[alternative HTML version deleted]]

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




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


[R] processing log file

2009-11-13 Thread Jabez Wilson
Dear all, I'm trying to process a log file which logs the date, the username 
and the computer number accessed. The table looks like this:
table.users
 Date UserName Machine
1  2008-11-25 John 641
2  2008-11-25    Clive 611
3  2008-11-25   Jeremy 641
4  2008-11-25 Walt 722
5  2008-11-25 Tony 645
6  2008-11-26 Tony 645
7  2008-11-26 Tony 641
8  2008-11-26 Tony 641
9  2008-11-26 Walt 641
10 2008-11-26 Walt 645
11 2008-11-30 John 641
12 2008-11-30    Clive 611
13 2008-11-30 Tony 641
14 2008-11-30 John 641
15 2008-11-30 John 641
..etc
What I want to do is to find out how many unique users logged on each day, and 
how many individual machines where accessed per day. In the above example, 
therefore on 2008-11-25 there were 5 separate users accessing 4 machines, on 
2008-11-26 there were 2 unique users who used 2 machines (although both logged 
on more than once).
I've got as far as apply(table.users, 2, FUN=table) which gives me an output of 
date, or username or machine and how many times they were accessed, but not 
really what I want.
Any help appreciated
 
Jabez


  
[[alternative HTML version deleted]]

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


[R] R, NIH and FDA

2009-11-13 Thread Federico Calboli

Dear All,

I will soon be working with NIH and possibly FDA. Will I be able to  
use R or will I be forced to use SAS?


Cheers,

Federico


--
Federico C. F. Calboli
Department of Epidemiology and Public Health
Imperial College, St. Mary's Campus
Norfolk Place, London W2 1PG

Tel +44 (0)20 75941602   Fax +44 (0)20 75943193

f.calboli [.a.t] imperial.ac.uk
f.calboli [.a.t] 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] z-test with NAs

2009-11-13 Thread ms.com

Dear all
I am learning R
I am doing Z-test with package 'BSDA'
here is my syntax and result:

 sdgr.ztest-z.test(growth[type=='SD' from_treeline=='above'], +   
 growth[type=='SD' from_treeline=='below'],alternative = two.sided, +   mu 
 = 0, sigma.x =(sd(growth[type=='SD' from_treeline=='above'],na.rm = T)), +   
 sigma.y =(sd(growth[type=='SD' from_treeline=='below'],na.rm = T)), 
 conf.level = 0.95) sdgr.ztest # Z-test for Seedling Growth above and below 
 treeline
Two-sample z-Test
data:  growth[type == SD  from_treeline == above] and growth[type == SD 
 from_treeline == below] z = NA, p-value = NAalternative hypothesis: true 
difference in means is not equal to 0 95 percent confidence interval: NA NA 
sample estimates:mean of x mean of yNANA 

I don't understand where my syntax went wrong. Similar syntax works for sapling 
case, but not for seedling case. is it due to the NAs in my data set for 
seedlings?, as the package says, NAs are allowed but will be removed during 
analysis, i don't think it is the problem.
i am attaching the data file too. and one more information, I am using MS 
Windows 2003 OS. 
Please guide me, how can i go ahead.

Thanking you in anticipation 

Warm regard
MS
Madan
 

  
_
Bing brings you maps, menus, and reviews organized in one place.

a=TEXT_MFESRP_Local_MapsMenu_Resturants_1x1id,code,growth,from_treeline,type
1,SD1,1.73,below,SD
2,SD2,1.12,above,SD
3,SD3,1.6,above,SD
4,SD4,1.66,above,SD
5,SD5,1.65,below,SD
6,SD6,1.43,above,SD
7,SD7,,above,SD
9,SD9,1.1,below,SD
10,SD10,1.44,above,SD
11,SD11,1.48,above,SD
12,SD12,2.25,above,SD
13,SD13,,above,SD
14,SD14,1.5,above,SD
15,SD15,,above,SD
16,SD16,1.06,above,SD
17,SD17,1.5,above,SD
18,SD18,4.17,below,SD
19,SD19,2.02,below,SD
20,SD20,1.38,above,SD
21,SD21,2,below,SD
22,SD22,1.41,above,SD
23,SD23,1.9,above,SD
24,SD24,1.7,above,SD
25,SD25,2.08,above,SD
26,SD26,1.92,below,SD
27,SD27,1.55,below,SD
28,SD28,1.48,below,SD
29,SD29,1.33,below,SD
30,SD30,1.5,above,SD
31,SD31,1.6,below,SD
32,SD32,1.24,below,SD
33,SD33,1.56,above,SD
34,SD34,1.58,below,SD
35,SD35,1.43,above,SD
36,SD36,1.3,above,SD
37,SD37,2.12,below,SD
38,SD38,1.63,below,SD
39,SD39,1.3,above,SD
40,SD40,1.16,below,SD
41,SD41,1.13,below,SD
42,SD42,1.43,below,SD
43,SD43,1.07,below,SD
44,SD44,1.25,below,SD
45,SD45,1.18,below,SD
46,SD46,1.17,above,SD
47,SD47,1,below,SD
48,SD48,1.43,above,SD
49,SD49,1.18,above,SD
50,SD50,1.17,below,SD
51,SD51,1.78,below,SD
52,SD52,1.67,above,SD
53,SD53,1,above,SD
54,SD54,1.8,below,SD
55,SD55,0.8,above,SD
56,SD56,0.95,above,SD
57,SD57,1.8,below,SD
58,SD58,,above,SD
59,SD59,,below,SD
60,SD60,,below,SD
61,SD61,,below,SD
62,SD62,,below,SD
63,SD63,,below,SD
64,SD64,,below,SD
65,SD65,0.93,below,SD
66,SD66,1.35,below,SD
67,SD67,1.33,below,SD
68,SD68,1.09,below,SD
69,SD69,1.41,below,SD
70,SD70,1.3,below,SD
71,SD71,1.2,below,SD
72,SD72,1.27,above,SD
73,SD73,0.7,below,SD
74,SD74,1.05,below,SD
75,SD75,1.68,below,SD
76,SD76,1.57,below,SD
77,SD77,1.22,above,SD
78,SD78,1.46,below,SD
79,SD79,2.32,below,SD
80,SD80,2.7,below,SD
81,SD81,1.57,above,SD
82,SD82,1.53,below,SD
83,SD83,1.63,below,SD
84,SD84,1.23,above,SD
85,SD85,1.77,below,SD
86,SD86,1.53,below,SD
87,SD87,1.39,below,SD
88,SD88,1.18,above,SD
89,SD89,1.85,below,SD
90,SD90,1.82,below,SD
91,SD91,,below,SD
92,SD92,1.74,below,SD
93,SD93,1.76,below,SD
94,SD94,1.16,below,SD
95,SD95,,below,SD
96,SD96,1.2,below,SD
97,SD97,1.42,below,SD
98,SD98,0.95,below,SD
99,SD99,2.43,below,SD
100,SD100,,below,SD
101,SD101,1.48,below,SD
102,SD102,1.33,below,SD
103,SD103,,below,SD
104,SD104,0.94,below,SD
105,SD105,,below,SD
106,SD106,1.15,below,SD
107,SD107,,below,SD
108,SD108,1.87,below,SD
109,SD109,1.23,below,SD
110,SD110,1.83,below,SD
111,SD111,1.47,below,SD
112,SD112,,below,SD
113,SD113,1.28,below,SD
114,SD114,,below,SD
115,SD115,1.57,below,SD
116,SD116,,below,SD
117,SD117,1.75,below,SD
118,SD118,1.8,below,SD
119,SD119,1.49,below,SD
120,SD120,1.54,below,SD
1,SPB1,2.19,above,SPB
2,SPB2,1.66,above,SPB
3,SPB3,1.78,above,SPB
4,SPB4,1.73,above,SPB
5,SPB5,8.63,above,SPB
6,SPB6,1.96,below,SPB
7,SPB7,5.17,above,SPB
8,SPB8,3.5,above,SPB
9,SPB9,2.78,above,SPB
10,SPB10,5.5,above,SPB
11,SPB11,2.75,below,SPB
12,SPB12,3,above,SPB
13,SPB13,4.71,above,SPB
14,SPB14,4.86,above,SPB
15,SPB15,4.63,below,SPB
16,SPB16,1.92,below,SPB
17,SPB17,3,below,SPB
18,SPB18,1.48,below,SPB
19,SPB19,2.35,below,SPB
20,SPB20,2.9,below,SPB
21,SPB21,2.35,below,SPB
22,SPB22,2.11,above,SPB
23,SPB23,1.92,below,SPB
24,SPB24,19.38,below,SPB
25,SPB25,2.33,above,SPB
27,SPB27,3.17,below,SPB
28,SPB28,1.73,below,SPB
29,SPB29,2.31,below,SPB
30,SPB30,1.9,below,SPB
31,SPB31,2.23,below,SPB
32,SPB32,2.04,below,SPB
33,SPB33,2.38,above,SPB
34,SPB34,4.9,above,SPB
35,SPB35,5.96,below,SPB
36,SPB36,1.77,below,SPB
37,SPB37,2.64,above,SPB
38,SPB38,4.01,above,SPB
39,SPB39,1.94,below,SPB
40,SPB40,1.8,above,SPB
41,SPB41,14.14,below,SPB
42,SPB42,6.5,above,SPB

Re: [R] starting html help for a package?

2009-11-13 Thread Duncan Murdoch

Liviu Andronic wrote:

On 11/12/09, Duncan Murdoch murd...@stats.uwo.ca wrote:
  

help(package=boot, help_type = html)


 The page displayed there was never an HTML page.  In the future it probably
should be, but it hasn't been implemented yet.



At the moment is there a way to call the html help for a package, that
is starting in a browser the text displayed by help(package=boot)?
  


If you look at the index page, and if the package author created a 
package man page, you'll find it.  That would give you the same thing as 
package?foo, not the same thing you asked for, which always generates 
package info, never looks it up.


At some point in the future the package?info page will be able to be 
generated automatically, and I imagine it will end up containing the 
package info you saw.   It would make sense for


help(package=boot, help_type = html)

to give the same result.

Duncan Murdoch



  

 It's in the tools package, which you probably hadn't attached.  If you
followed the advice and used ??, you would have got it.



Indeed. I assumed that with 2.10 this was deprecated, but I was wrong.
Liviu



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


Re: [R] how to pass matrices from C to R effectively

2009-11-13 Thread Duncan Murdoch

Hao Cen wrote:

Hi Duncan,

Thanks for your reply. I am not sure what you meant by tell your C
function to use the memory that R sent to it. What R can pass to C is a
pointer to an array and the array size, assuming we are taking about the
.C mechanism. Did you mean my C function takes that array pointer and
generate the required matrix along the length of the array? If this is not
what you meant, would you please give me a small example?
  


Yes, that is what I meant.

Duncan Murdoch



Jeff



On Thu, November 12, 2009 6:53 pm, Duncan Murdoch wrote:
  

On 12/11/2009 6:45 PM, Hao Cen wrote:



Hi,


I have C code to produce a lot of matrices to be analyzed. As these
matrices are large ( 1000*1) and are a lot ( 1000), I am thinking
about how to pass them from C to R effectively.

Would you think about the following solution? In R, I create a wrapper
function

passDataFromCToR = function(row, col) { mat = matrix(0, row, col)
.C(passDataFromCToR,mat)[[1]]

  

That .C call doesn't match the header of the function below:  you didn't
pass row and col.



}


It wraps the following C function
void passDataFromCToR (double *m, int *row, int* col){ mymat = f() // my
c function to produce a matrix // then I copy mymat to m element by
element via a loop

}


Then to use these functions, I would write in R
mat = passDataFromCToR(1000, 1)

Two issues with this approach are that 1) I have to copy the data once
and 2)to the worse, in R I have to know the dimension of the matrices to
be passed from C. This information is not always available.
  

Why would you have to copy the data?  Just tell your C function to use
the memory that R sent to it, instead of copying entries into it.  (R may
be doing a copy when you extract the results, though.)

If your C code can't use memory provided to it, then there are no simple
ways to avoid copying.  The complicated way is to use the .Call interface
instead of .C.  There are examples in Writing R Extensions. They *will*
require modifications to your code if it can't take a pointer to the
memory to use.

For the question of the dimensions being unknown in advance:  Just write
two functions.  The first does the calculations up to the point where it
needs the memory, the second works on an appropriately sized array, that
your R code allocated based on the first result.  Or use the .Call()
interface.

Duncan Murdoch




I would appreciate if you share with me your thoughts on how to solve
this problem better.

thanks

Jeff


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

2009-11-13 Thread David Winsemius


On Nov 13, 2009, at 6:03 AM, Jabez Wilson wrote:

Dear all, I'm trying to process a log file which logs the date, the  
username and the computer number accessed. The table looks like this:

table.users

 Date UserName Machine
1  2008-11-25 John 641
2  2008-11-25Clive 611
3  2008-11-25   Jeremy 641
4  2008-11-25 Walt 722
5  2008-11-25 Tony 645
6  2008-11-26 Tony 645
7  2008-11-26 Tony 641
8  2008-11-26 Tony 641
9  2008-11-26 Walt 641
10 2008-11-26 Walt 645
11 2008-11-30 John 641
12 2008-11-30Clive 611
13 2008-11-30 Tony 641
14 2008-11-30 John 641
15 2008-11-30 John 641
..etc
What I want to do is to find out how many unique users logged on  
each day, and how many individual machines where accessed per day.  
In the above example, therefore on 2008-11-25 there were 5 separate  
users accessing 4 machines, on 2008-11-26 there were 2 unique users  
who used 2 machines (although both logged on more than once).
I've got as far as apply(table.users, 2, FUN=table) which gives me  
an output of date, or username or machine and how many times they  
were accessed, but not really what I want.

Any help appreciated


You were almost there. Just use lapply on the list object you produced:

 lapply(apply(table.users, 2, FUN=table), length)
$Date
[1] 3

$UserName
[1] 5

$Machine
[1] 4

Or if you want the individual items that you requested:

 lapply(apply(table.users, 2, FUN=table), length)$UserName
[1] 5
 lapply(apply(table.users, 2, FUN=table), length)$Machine
[1] 4


--

David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


Re: [R] Splus

2009-11-13 Thread Duncan Murdoch

ozgur gultekin wrote:

 I am modelling oil price data in s plus, but I have some problem in
my code, especially while I am estimating my model (ARMA GARCH) and
also I have some question too, anyone can help me about S-plus? I
think it has same  syntax with R


You should call their tech support, or use their mailing list.

Duncan Murdoch

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


Re: [R] data frame subsets?

2009-11-13 Thread David Winsemius


On Nov 12, 2009, at 10:57 PM, Douglas M. Hultstrand wrote:


Hello,

I am trying to create data frame subsets based on binned temperature  
data.  I have code working to create the bins (d.1 and d.2), but it  
takes two steps, I was wondering if I could merge into one step.   
See Below


d
  n year mo da hr   t   td  tw rh   kPa
1   1 1945  3  1  0 1.1  0.0 0.6 92 101.7
2   2 1945  3  1  1 2.8 -1.1 1.1 76 101.8
3   3 1945  3  1  2 2.2 -1.7 0.6 75 101.9
4   4 1945  3  1  3 1.7 -1.1 0.6 82 102.0
5   5 1945  3  1  4 1.7 -2.8 0.0 72 102.1
6   6 1945  3  1  5 1.7 -1.7 0.0 78 102.2
7   7 1945  3  1  6 1.1 -2.8 0.0 75 102.2
8   8 1945  3  1  7 1.1 -1.7 0.0 82 102.4
9   9 1945  3  1  8 1.7 -1.1 0.6 82 102.5
10 10 1945  3  1  9 2.8 -3.3 0.6 64 102.6

d.1 - d[d$t = 1.0,]
d.2 - d.1[d.1$t  2.0,]

How can I make  d.1 and d.2 into one step? I have tried several  
different methods such as example below.

d.1 - d[d$t = 1.0,  d$t  2.0,]


Instead of using  , use . It is the vectorized version of the  
AND operation.  only operated on the first two elements and  
returned a scalar rather than the vector you needed.


--

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] survreg function in survival package

2009-11-13 Thread David Winsemius


On Nov 13, 2009, at 3:17 AM, carol white wrote:


Hi,
Is it normal to get intercept in the list of covariates in the  
output of survreg function with standard error, z, p.value etc? Does  
it mean that intercept was fitted with the covariates? Does Value  
column represent coefficients or some thing else?




Don't you need a baseline scale parameter for the Weibull function?  
You didn't offer the structure of your dataframe, but if it is the  
standard ovarian set, then the rx coef is just the difference  
between the scale parameter of rx=2 from that of rx=1, and similarly  
for ecog.ps. You would not have an estimate for rx=1 and ecog.ps=1 if  
you were not given the Intercept coef.


In the future it would be good manners to indicate what grad school  
you are taking classes at.



--
David


Regards,

-
tmp = survreg(Surv(futime, fustat) ~ ecog.ps + rx, ovarian,  
dist='weibull',scale=1)

summary(tmp)


Call:
survreg(formula = Surv(futime, fustat) ~ ecog.ps + rx, data = ovarian,
   dist = weibull, scale = 1)
Value Std. Error  zp
(Intercept)  6.962  1.322  5.267 1.39e-07
ecog.ps -0.433  0.587 -0.738 4.61e-01
rx   0.582  0.587  0.991 3.22e-01

Scale fixed at 1

Weibull distribution
Loglik(model)= -97.2   Loglik(intercept only)= -98
Chisq= 1.67 on 2 degrees of freedom, p= 0.43
Number of Newton-Raphson Iterations: 4
n= 26

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


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


[R] starting pdf help for a package? (was starting html help for a package?)

2009-11-13 Thread Liviu Andronic
Dear all
A sequel to my previous post.

On Fri, Nov 13, 2009 at 11:33 AM, Duncan Murdoch murd...@stats.uwo.ca wrote:
 At some point in the future the package?info page will be able to be
 generated automatically, and I imagine it will end up containing the package
 info you saw.   It would make sense for

 help(package=boot, help_type = html)

 to give the same result.

Alternatively, I was also experimenting with
help(package=boot, help_type = pdf)

to call a formatted help of a package, but this too fell back to text,
although I would have expected it to pop up [1]. Would it make sense
to make the command do so in the future?
Thank you
Liviu

[1] http://cran.r-project.org/web/packages/boot/boot.pdf

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

2009-11-13 Thread Federico Calboli

On 13 Nov 2009, at 12:25, Barry Rowlingson wrote:

Working with is different to Working for. Assuming they want to
work with you then they want you for your abilities and skills, and if
those skills are with R then you go ahead and use R.

You don't employ a bricklayer to build a wall and then tell them you
want it made from reinforced concrete.



While I agree in principle I am not high enough in the food chain to  
avoid substantial pressure, unless using R is already established.  
Plus I'm working 'with' people who are either working 'for' or are  
just a step removed from doing so.


F


--
Federico C. F. Calboli
Department of Epidemiology and Public Health
Imperial College, St. Mary's Campus
Norfolk Place, London W2 1PG

Tel +44 (0)20 75941602   Fax +44 (0)20 75943193

f.calboli [.a.t] imperial.ac.uk
f.calboli [.a.t] gmail.com

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


Re: [R] processing log file

2009-11-13 Thread Karl Ove Hufthammer
On Fri, 13 Nov 2009 11:03:31 + (GMT) Jabez Wilson 
jabez...@yahoo.co.uk wrote:
 What I want to do is to find out how many unique users logged 
 on each day, and how many individual machines where accessed per day.

Use the 'plyr' package:

library(plyr)
ddply(table.users, .(Date), summarise,
  users=length(unique(Username)),
  machines=length(unique(Machine)))

-- 
Karl Ove Hufthammer

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

2009-11-13 Thread Barry Rowlingson
On Fri, Nov 13, 2009 at 11:21 AM, Federico Calboli
f.calb...@imperial.ac.uk wrote:
 Dear All,

 I will soon be working with NIH and possibly FDA. Will I be able to use R or
 will I be forced to use SAS?

 Working with is different to Working for. Assuming they want to
work with you then they want you for your abilities and skills, and if
those skills are with R then you go ahead and use R.

 You don't employ a bricklayer to build a wall and then tell them you
want it made from reinforced concrete.

Barry

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Rarefaction Curve by Individuals not Sites - vegan (specaccum)

2009-11-13 Thread Rodrigo Aluizio
Hi List,

I’m using  the vegan function specaccum to produce a rarefaction curve. In
the function’s help it says: “Function ‘specaccum’ finds species
accumulation curves or the number of species for a certain number of sampled
sites or individuals”. Well, I would like to finds this curve for
individuals, but when I compute it the function (using the ‘rarefaction’
method) gives me Sites, Richness and Standand Deviation as values. When I
plot it, y axis is the richness (ok with that) and x axis is Sites (here is
the question), how could I make it calculate and plot the accumulating
individuals number?

Well, one problem may be the fact that my data frame has species as columns
and Sites as rows (and abundance data frame)… May you help me?

 

Ps.: The ‘rarefaction’ method option brings this details: “All these methods
are based on sampling sites without replacement. In contrast, the ‘method =
rarefaction’ finds the expected species richness and its standard
deviation by sampling individuals instead of sites”. Exactly what I really
want, but not what I get!

 

Here is the command line used.

plot(specaccum(Spp[,-227],'rarefaction'),col='black',lwd=2,ci.lty=0,ci.type=
'poly',ci.col='lightgray',ylab='Riqueza',ylim=c(0,250),yaxp=c(0,250,10),bty=
'n',main='Fauna Viva - Bacia de Campos - Março 2009')

 

Thank you very much.

Regards.

 

-

MSc.  mailto:r.alui...@gmail.com Rodrigo Aluizio

Centro de Estudos do Mar/UFPR
Laboratório de Micropaleontologia
Avenida Beira Mar s/n - CEP 83255-000




[[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] speech spectogram

2009-11-13 Thread Olivier Crouzet
Le Mon, 19 Oct 2009 12:00:16 +0530, rajesh j a écrit :

 Hi,
 
 I need to plot a spectogram for a speech signal. Is there a package
 that can do this?
 

Late answer, but you should have a look at seewave package on CRAN.

The function spectro() is what you need.

Olivier.


-- 
  Olivier Crouzet, PhD
  Laboratoire de Linguistique -- EA3827
  Département de Sciences du Langage
  UFR Lettres et Langages
  Université de Nantes
  Chemin de la Censive du Tertre - BP 81227
  44312 Nantes cedex 3
  France

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

  http://www.lling.fr/
  

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


[R] p-value 1

2009-11-13 Thread amor Gandhi
Dear all,

I am trying to use SAMr-library(samr), it gives me p-value = 1.001, any idea 
why?

Many thanks,
Amor


__


z gegen Massenmails. 

[[alternative HTML version deleted]]

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


Re: [R] R, NIH and FDA

2009-11-13 Thread Frank E Harrell Jr

Federico Calboli wrote:

Dear All,

I will soon be working with NIH and possibly FDA. Will I be able to use 
R or will I be forced to use SAS?


Cheers,

Federico


There are many R users are FDA, NIH, CDC, and other federal agencies. 
IT support tends to be a problem.  Some agencies are using R 2.7, and 
getting packages installed in a timely manner may be difficult.


Frank




--
Federico C. F. Calboli
Department of Epidemiology and Public Health
Imperial College, St. Mary's Campus
Norfolk Place, London W2 1PG

Tel +44 (0)20 75941602   Fax +44 (0)20 75943193

f.calboli [.a.t] imperial.ac.uk
f.calboli [.a.t] 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.




--
Frank E Harrell Jr   Professor and Chair   School of Medicine
 Department of Biostatistics   Vanderbilt University

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


Re: [R] R, NIH and FDA

2009-11-13 Thread Karl Ove Hufthammer
On Fri, 13 Nov 2009 11:21:30 + Federico Calboli 
f.calb...@imperial.ac.uk wrote:
 I will soon be working with NIH and possibly FDA. Will I be able to  
 use R or will I be forced to use SAS?

You will (hopefully) be able to use R. See this document:
http://www.r-project.org/doc/R-FDA.pdf

-- 
Karl Ove Hufthammer

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


Re: [R] Problem building R 2.10.0 - Matrix package

2009-11-13 Thread Thomas Adams

Martin,

That's exactly right. I'm simply building R from source, downloaded from 
CRAN, and doing exactly what I have easily been able to do previously. I 
think I first encountered this problem with version 2.9.2 (if memory 
serves…).


Tom


Martin Maechler wrote:

Thank you, Russ,
but ...

  

RPH == R P Herrold herr...@owlriver.com
on Thu, 12 Nov 2009 14:13:26 -0500 (EST) writes:



 TA == Thomas Adams thomas.ad...@noaa.gov
TA Attached is the output file from building R 2.10.0 on  RedHat Linux. I
TA have never previously experienced any problems when building R from
TA source with new releases. But, now I get a compile error with the Matrix
TA package:

[...]

RPH The Raw Hide packaging of R 2.10.0 has Matrix in it as a 
RPH new addition ...


RPH [herr...@centos-5 monit]$ rpm -qf /usr/lib64/R/library/Matrix
RPH R-core-2.10.0-2orc

RPH ... whose packaging of such a build of R are you using, that 
RPH you need to package /Matrix separately?


No, we were talking about building R from the sources.
That should still be pretty easily possible on any Linux system
{which has compilers/perl/latex/tcltk/  and a couple of libraries}.

Martin
  



--
Thomas E Adams
National Weather Service
Ohio River Forecast Center
1901 South State Route 134
Wilmington, OH 45177

EMAIL:  thomas.ad...@noaa.gov

VOICE:  937-383-0528
FAX:937-383-0033

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

2009-11-13 Thread Henrique Dallazuanna
Try the fixed argument:

grep(.$^, c(Test.$^, Test), fixed = TRUE)

On Fri, Nov 13, 2009 at 11:33 AM, Hadley Wickham had...@rice.edu wrote:
 Hi all,

 Is there a method for escaping strings to be used regular expressions?
  i.e. if I have a user supplied string that I'd like to use as a fixed
 component is there a method that will turn (e.g.) .$^ into
 \\.\\$\\^ ?

 Thanks,

 Hadley

 --
 http://had.co.nz/

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


[R] Escaping regular expressions

2009-11-13 Thread Hadley Wickham
Hi all,

Is there a method for escaping strings to be used regular expressions?
 i.e. if I have a user supplied string that I'd like to use as a fixed
component is there a method that will turn (e.g.) .$^ into
\\.\\$\\^ ?

Thanks,

Hadley

-- 
http://had.co.nz/

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

2009-11-13 Thread Dennis Fisher

Colleagues,

I am using R (2.9.2, all platforms) to search for a complicated text  
string using regular expressions.  I would appreciate any help you can  
provide.

The string consists of the following elements:
SOMEWORDWITHNOSPACES
any number of spaces and/or tabs
(
any number of spaces and/or tabs
integer
any number of spaces and/or tabs
)

Examples include:
WORD (  123)
WORD(1 )
WORD\t ( 21\t)
WORD \t ( 1 \t   )
etc.

I don't need to substitute anything, only to identify if such a string  
exists.

Any help with regular expressions would be appreciated.
Thanks.

Dennis



Dennis Fisher MD
P  (The P Less Than Company)
Phone: 1-866-PLessThan (1-866-753-7784)
Fax: 1-866-PLessThan (1-866-753-7784)
www.PLessThan.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] Help with complicated regular expression

2009-11-13 Thread Tony Plate

One of these should be a start.  If there can be no extra text at the beginning or end, start with 
^ and end with $.


x - c(WORD (  123), WORD(1 ), WORD\t ( 21\t), WORD \t ( 1 \t   ), 
decoy((2)), more words in front(2))
grep([[:alpha:]]+[ \t]*\\([ \t]*[0-9]+[ \t]*\\), x)

[1] 1 2 3 4 6

grep(^[[:alpha:]]+[ \t]*\\([ \t]*[0-9]+[ \t]*\\), x)

[1] 1 2 3 4




-- Tony Plate

Dennis Fisher wrote:

Colleagues,

I am using R (2.9.2, all platforms) to search for a complicated text 
string using regular expressions.  I would appreciate any help you can 
provide.

The string consists of the following elements:
SOMEWORDWITHNOSPACES
any number of spaces and/or tabs
(
any number of spaces and/or tabs
integer
any number of spaces and/or tabs
)

Examples include:
WORD (  123)
WORD(1 )
WORD\t ( 21\t)
WORD \t ( 1 \t   )
etc.

I don't need to substitute anything, only to identify if such a string 
exists.

Any help with regular expressions would be appreciated.
Thanks.

Dennis

   


Dennis Fisher MD
P  (The P Less Than Company)
Phone: 1-866-PLessThan (1-866-753-7784)
Fax: 1-866-PLessThan (1-866-753-7784)
www.PLessThan.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] Help with complicated regular expression

2009-11-13 Thread Marc Schwartz

On Nov 13, 2009, at 8:12 AM, Dennis Fisher wrote:


Colleagues,

I am using R (2.9.2, all platforms) to search for a complicated text  
string using regular expressions.  I would appreciate any help you  
can provide.

The string consists of the following elements:
SOMEWORDWITHNOSPACES
any number of spaces and/or tabs
(
any number of spaces and/or tabs
integer
any number of spaces and/or tabs
)

Examples include:
WORD (  123)
WORD(1 )
WORD\t ( 21\t)
WORD \t ( 1 \t   )
etc.

I don't need to substitute anything, only to identify if such a  
string exists.

Any help with regular expressions would be appreciated.
Thanks.

Dennis



How about this:

Lines - c(WORD (  123),WORD(1), WORD\t ( 21\t) , WORD\t  
( 21\t)  )


 Lines
[1] WORD (  123) WORD(1)  WORD\t ( 21\t) 
[4] WORD\t ( 21\t) 

 grep(^[A-Za-z]+.*\\(.*[0-9]+.*\\), Lines)
[1] 1 2 3 4

You should test it on some real data to see if it works or needs to be  
tweaked further.


^[A-Za-z]+ finds one or more characters at the beginning of the line
.* finds zero or more characters after the word
\\( finds an open paren
.* finds zero or more characters after the open paren
[0-9]+ finds one or more digits
.* finds zero or more characters after the digits
\\) finds the close paren


HTH,

Marc Schwartz

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


Re: [R] Help with complicated regular expression

2009-11-13 Thread jim holtman
try this:

 x - c('WORD(12  )', 'WORD[123)', 'WORD   (   123   )', WORD(xx), WORD(1))
 grep([[:alnum:]]+[[:space:]]*\\([[:space:]]*[[:digit:]]+[[:space:]]*\\), x)
[1] 1 3 5



On Fri, Nov 13, 2009 at 9:12 AM, Dennis Fisher fis...@plessthan.com wrote:
 Colleagues,

 I am using R (2.9.2, all platforms) to search for a complicated text string
 using regular expressions.  I would appreciate any help you can provide.
 The string consists of the following elements:
        SOMEWORDWITHNOSPACES
        any number of spaces and/or tabs
        (
        any number of spaces and/or tabs
        integer
        any number of spaces and/or tabs
        )

 Examples include:
        WORD (  123    )
        WORD(1 )
        WORD\t ( 21\t)
        WORD \t ( 1 \t   )
 etc.

 I don't need to substitute anything, only to identify if such a string
 exists.
 Any help with regular expressions would be appreciated.
 Thanks.

 Dennis



 Dennis Fisher MD
 P  (The P Less Than Company)
 Phone: 1-866-PLessThan (1-866-753-7784)
 Fax: 1-866-PLessThan (1-866-753-7784)
 www.PLessThan.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.




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


[R] Change working directory

2009-11-13 Thread anna_l

Hello, I am using setwd() to change the working directory but I have to enter
it everytime I open R, is there a way to set this permanently as a working
directory? Thanx =^D

-- 
View this message in context: 
http://old.nabble.com/Change-working-directory-tp26337486p26337486.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] LINEAR MIXED EFFECT

2009-11-13 Thread ANARPCG



Douglas Bates-2 wrote:
 
 On Thu, Nov 12, 2009 at 10:14 AM, milton ruser milton.ru...@gmail.com
 wrote:
 Hi Ana,

 I am not quite sure if it is the problem, but if you call your data.frame
 as
 exp,
 you will crash exp() function... try use another name for your
 data.frame.

 By the way, I suggest you not use attach().

 Try something like model-lme(weight~date*diet, data=yourdataframe)

 good luck
 
 and include the random specification in the call to lme, not as a
 separate assignment.
 
 milton

 On Thu, Nov 12, 2009 at 5:43 AM, ANARPCG a.gouvei...@imperial.ac.uk
 wrote:





 Milton's point is dead-on, and I would highly encourage you to give the
 posting guide a look.

 That said... you might try na.action = na.omit in your call to...
 actually, we don't know what function you are using (see first point).
 Regardless, sounds like you have missing data and na.action is set to
 na.fail (ie, fail if any missing data).

 cheers, Dave


 milton ruser wrote:
 
  Dear Ana Golveia,
 
  It is completelly impossible someone realise what kind or help you
 need
 or
  what is happening. I suggest you give a look on the posting guide,
 mainly
  that part about a minimum reproducible code with self explaining
  information, etc.
 
  Cheers
 
  milton
 
  On Wed, Nov 11, 2009 at 7:22 AM, ANARPCG a.gouvei...@imperial.ac.uk
  wrote:
 
 
  CAN ANYONE PLEASE HELP ME WITH THIS
  i HAVE TO DO A MIXED EFFECT LINEAR MODEL WITH MY DATA DUE TO THE FACT
  THAT
  I
  have pseudoreplication!
  Although after reading and trying it for several times can get around
 due
  to
  Error in na.fail.default(list(date = c(1L, 2L, 3L, 4L, 5L, 6L, 7L,
 8L,
  :
  missing values in object
  I uploaded my data file
  Thank you so much
  Kind regards
  AG
  http://old.nabble.com/file/p26300394/rawoctobercalciumexperiment2.txt
  rawoctobercalciumexperiment2.txt
 
  --
  View this message in context:
  http://old.nabble.com/LINEAR-MIXED-EFFECT-tp26300394p26300394.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.htmlhttp://www.r-project.org/posting-guide.html
 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.htmlhttp://www.r-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
  sorry I am new on this things
  the point is after trying to run the model all that happens is:
  exp-read.table(file=file.choose(),header=T)
  attach(exp)
  names(exp)
  [1] group     date      diet      weight    thickness
 length
  [7] width     liplength lipwidth
 
 exp$diet=factor(exp$diet,levels=c(zeropercent,tenpercent,twentypercent,thirtypercent,fortypercent,cuttleprecent))
  exp=na.omit(exp)
  library(nlme)
  random=~date
  model-lme(weight~date*diet)
  Error in na.fail.default(list(date = c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L,
  :
    missing values in object
 
   I have pseudoreplications due to the fact that the measurements of
 the
  replicates have different starting points so I was advised to do lme.
 I
  never used it before and I cant get arround with it! the help I wanted
  from you is to help me to understand how to do a runable model!
 
 
 
 http://old.nabble.com/file/p26315302/rawoctobercalciumexperiment2.txt
 rawoctobercalciumexperiment2.txt
 --
 View this message in context:
 http://old.nabble.com/LINEAR-MIXED-EFFECT-tp26300394p26315302.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.htmlhttp://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-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 
:handshake:it did work finally thk for the help
it went like this
data-read.table(H:\\5.11.09\\rawoctobercalciumexperiment2.txt,header=T)
names(data)

Re: [R] Escaping regular expressions

2009-11-13 Thread Hadley Wickham
I want the user supplied string to be used as a component of a regular
expression that I build up from other pieces that need actual regular
expressions.

Hadley

On Fri, Nov 13, 2009 at 7:41 AM, Henrique Dallazuanna www...@gmail.com wrote:
 Try the fixed argument:

 grep(.$^, c(Test.$^, Test), fixed = TRUE)

 On Fri, Nov 13, 2009 at 11:33 AM, Hadley Wickham had...@rice.edu wrote:
 Hi all,

 Is there a method for escaping strings to be used regular expressions?
  i.e. if I have a user supplied string that I'd like to use as a fixed
 component is there a method that will turn (e.g.) .$^ into
 \\.\\$\\^ ?

 Thanks,

 Hadley

 --
 http://had.co.nz/

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





-- 
http://had.co.nz/

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

2009-11-13 Thread stephen sefick
.Rprofile is executed everytime you start up R

On Fri, Nov 13, 2009 at 8:34 AM, anna_l lippelann...@hotmail.com wrote:

 Hello, I am using setwd() to change the working directory but I have to enter
 it everytime I open R, is there a way to set this permanently as a working
 directory? Thanx =^D

 --
 View this message in context: 
 http://old.nabble.com/Change-working-directory-tp26337486p26337486.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.




-- 
Stephen Sefick

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods.  We are mammals, and have not exhausted the
annoying little problems of being mammals.

-K. Mullis

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

2009-11-13 Thread Peter Dalgaard

amor Gandhi wrote:

Dear all,

I am trying to use SAMr-library(samr), it gives me p-value = 1.001, any idea 
why?


Well, the package maintainer might be a better place to ask. (Bring an 
example if you do.)


However, as a generic matter, the result is obviously nonsensical, and 
could be due to a sloppy approximation of a distribution function, or 
maybe it is a (say) Bonferroni-adjusted p-value which is really an upper 
bound for the correct p-value.


Notice, though, that you should only very rarely care about the exact 
p-value. As soon as it is above 0.1, the message is just that you have 
not proven that there is an effect.


--
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - (p.dalga...@biostat.ku.dk)  FAX: (+45) 35327907

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

2009-11-13 Thread Romain Francois

Hello,

The function you are looking for is grepl. Something like this perhaps:

 words - c(WORD (  123),WORD(1), WORD\t ( 21\t) , WORD\t ( 
21\t)  )

 grepl( [[:space:]]*[(][[:space:]]*[0-9]+[[:space:]]*[)], words )
[1] TRUE TRUE TRUE TRUE

[[:space:]]* : any number of spaces or tabs (including 0 times)
[(]  : a (
[0-9]+   : any number of digits, but at least one
[)]  : a )

Romain


On 11/13/2009 03:12 PM, Dennis Fisher wrote:


Colleagues,

I am using R (2.9.2, all platforms) to search for a complicated text
string using regular expressions. I would appreciate any help you can
provide.
The string consists of the following elements:
SOMEWORDWITHNOSPACES
any number of spaces and/or tabs
(
any number of spaces and/or tabs
integer
any number of spaces and/or tabs
)

Examples include:
WORD ( 123 )
WORD(1 )
WORD\t ( 21\t)
WORD \t ( 1 \t )
etc.

I don't need to substitute anything, only to identify if such a string
exists.
Any help with regular expressions would be appreciated.
Thanks.

Dennis



Dennis Fisher MD
P  (The P Less Than Company)
Phone: 1-866-PLessThan (1-866-753-7784)
Fax: 1-866-PLessThan (1-866-753-7784)
www.PLessThan.com



--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://tr.im/EAD5 : LondonR slides
|- http://tr.im/BcPw : celebrating R commit #5
`- http://tr.im/ztCu : RGG #158:161: examples of package IDPmisc

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

2009-11-13 Thread Gabor Grothendieck
This is not minimal (it will escape every non-word character) but is
short and the needlessly escaped ones should do no harm (though you
might want to double check that assumption on a few examples):

gsub((\\W), \\1, x)

On Fri, Nov 13, 2009 at 8:33 AM, Hadley Wickham had...@rice.edu wrote:
 Hi all,

 Is there a method for escaping strings to be used regular expressions?
  i.e. if I have a user supplied string that I'd like to use as a fixed
 component is there a method that will turn (e.g.) .$^ into
 \\.\\$\\^ ?

 Thanks,

 Hadley

 --
 http://had.co.nz/

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

2009-11-13 Thread Gabor Grothendieck
\w+ will match one or more word characters and \s* will match 0 or
more spacing characters so if this must the described text must be the
complete expression then:

grepl(^\\w+\\s*\\(\\s*\\w+\\s*\\)$, x)

or if its ok for other text to appear before and after as long as the
indicated text is among it then remove the ^ and $.  The above gives a
logical vector as a result or if we use grep rather than grepl we can
get a vector of indexes.

On Fri, Nov 13, 2009 at 9:12 AM, Dennis Fisher fis...@plessthan.com wrote:
 Colleagues,

 I am using R (2.9.2, all platforms) to search for a complicated text string
 using regular expressions.  I would appreciate any help you can provide.
 The string consists of the following elements:
        SOMEWORDWITHNOSPACES
        any number of spaces and/or tabs
        (
        any number of spaces and/or tabs
        integer
        any number of spaces and/or tabs
        )

 Examples include:
        WORD (  123    )
        WORD(1 )
        WORD\t ( 21\t)
        WORD \t ( 1 \t   )
 etc.

 I don't need to substitute anything, only to identify if such a string
 exists.
 Any help with regular expressions would be appreciated.
 Thanks.

 Dennis



 Dennis Fisher MD
 P  (The P Less Than Company)
 Phone: 1-866-PLessThan (1-866-753-7784)
 Fax: 1-866-PLessThan (1-866-753-7784)
 www.PLessThan.com

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


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


[R] format help()

2009-11-13 Thread gabriel singer

Hi everybody,

probably a really stupid question. I updated to 2.10 recently and was 
surprised that the help function comes in a different format, i.e. in 
the old-style as single pages for each function. I know I can use the 
html format in a browser, but would prefer the in-between format with 
the list of all functions (in a specific package) on the left, and 
browsable content on the right... How do I get it back?


Thanks,

Gabriel

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] replace a whole word with sub()

2009-11-13 Thread Giulio Di Giovanni

 

Dear all, 

 

I cannot figure out how to solve a small problem (well, not for me), surely 
somebody can help me in few seconds.

 

I have a series of strings in a vector X of the type  xxx, yyy, zzz, 
IgA, IgG, kkk, IgM, aaa.

I want to substitute every ENTIRE string beginning with Ig with 0.

So, I'd like to have xxx, yyy, zzz, 0, 0, kkk, 0, aaa.

 

I can easily identify these strings with grep(^Ig, X), but if I use this 
criterion in the sub() function (sub(^Ig, 0, X) I obviously get 0A, 0G 
etc.

 

I didn't expect to do it in this way and I tried with metacharacters and 
regexps in order to grep and substitute the whole word (\b \, $). I don't post 
here my tryings,  because they were obviously wrong.

Please can you help me?

 

Giulio
  
_
Carica e scarica in un clic. Fino a 25 GB su SkyDrive 

[[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] replace a whole word with sub()

2009-11-13 Thread Marc Schwartz

On Nov 13, 2009, at 9:13 AM, Giulio Di Giovanni wrote:





Dear all,



I cannot figure out how to solve a small problem (well, not for me),  
surely somebody can help me in few seconds.




I have a series of strings in a vector X of the type  xxx, yyy,  
zzz, IgA, IgG, kkk, IgM, aaa.


I want to substitute every ENTIRE string beginning with Ig with 0.

So, I'd like to have xxx, yyy, zzz, 0, 0, kkk, 0, aaa.



I can easily identify these strings with grep(^Ig, X), but if I  
use this criterion in the sub() function (sub(^Ig, 0, X) I  
obviously get 0A, 0G etc.




I didn't expect to do it in this way and I tried with metacharacters  
and regexps in order to grep and substitute the whole word (\b \,  
$). I don't post here my tryings,  because they were obviously wrong.


Please can you help me?



x - c(xxx, yyy, zzz, IgA, IgG, kkk, IgM, aaa)

 sub(^Ig.*$, 0, x)
[1] xxx yyy zzz 0   0   kkk 0   aaa

You need to have the search regex include the entire element and not  
just the first couple of characters in order to replace the entire  
element.


HTH,

Marc Schwartz

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


Re: [R] replace a whole word with sub()

2009-11-13 Thread Gabor Grothendieck
Here are two ways:

 s - c(xxx, yyy, zzz, IgA, IgG, kkk, IgM, aaa)

 sub(^Ig.*, 0, s)
[1] xxx yyy zzz 0   0   kkk 0   aaa

 replace(s, grepl(^Ig, s), 0)
[1] xxx yyy zzz 0   0   kkk 0   aaa


On Fri, Nov 13, 2009 at 10:13 AM, Giulio Di Giovanni
perimessagg...@hotmail.com wrote:



 Dear all,



 I cannot figure out how to solve a small problem (well, not for me), surely 
 somebody can help me in few seconds.



 I have a series of strings in a vector X of the type  xxx, yyy, zzz, 
 IgA, IgG, kkk, IgM, aaa.

 I want to substitute every ENTIRE string beginning with Ig with 0.

 So, I'd like to have xxx, yyy, zzz, 0, 0, kkk, 0, aaa.



 I can easily identify these strings with grep(^Ig, X), but if I use this 
 criterion in the sub() function (sub(^Ig, 0, X) I obviously get 0A, 
 0G etc.



 I didn't expect to do it in this way and I tried with metacharacters and 
 regexps in order to grep and substitute the whole word (\b \, $). I don't 
 post here my tryings,  because they were obviously wrong.

 Please can you help me?



 Giulio

 _
 Carica e scarica in un clic. Fino a 25 GB su SkyDrive

        [[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] replace a whole word with sub()

2009-11-13 Thread Adaikalavan Ramasamy

Isn't this more straightforward?

 w - grep(^Ig, vec)
 vec[w] - 0

Regards, Adai


Giulio Di Giovanni wrote:
 

Dear all, 

 


I cannot figure out how to solve a small problem (well, not for me), surely 
somebody can help me in few seconds.

 


I have a series of strings in a vector X of the type  xxx, yyy, zzz, IgA, IgG, kkk, 
IgM, aaa.

I want to substitute every ENTIRE string beginning with Ig with 0.

So, I'd like to have xxx, yyy, zzz, 0, 0, kkk, 0, aaa.

 


I can easily identify these strings with grep(^Ig, X), but if I use this criterion in the sub() function 
(sub(^Ig, 0, X) I obviously get 0A, 0G etc.

 


I didn't expect to do it in this way and I tried with metacharacters and regexps 
in order to grep and substitute the whole word (\b \, $). I don't post here my 
tryings,  because they were obviously wrong.

Please can you help me?

 


Giulio
 		 	   		  
_
Carica e scarica in un clic. Fino a 25 GB su SkyDrive 


[[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 can this code be improved?

2009-11-13 Thread Richard R. Liu
Jim, Dennis,

Once again, thanks for all your suggestions.  After developing a more R-like
version of the script I terminated the running one after 976 (of 1697) reports
had been processed.  At that point, the script had been running for approx.
33.5 hours!  Here is the new version:

library(filehash)
db - dbInit(/Volumes/Work on RDR Test Documents/R Databases/DB_TXT, type =
RDS)
dbLoad(db)
dba - dbInit(/Volumes/Work on RDR Test Documents/R Databases/DB_Aux, type =
RDS)
dbLoad(dba)

tokens - sentences.all.tokenized
stopwords - stopwords.pubmed

# Convert to lowercase, remove beginning and end punctuation, tabulate
my.func - function(sent, stop, ...){
list(
freq.table = (temp.table - table(
sub(
[[:punct:]]*$, , sub(
^[[:punct:]]*, , tolower(sent)
)
)
)),
stopword.matches = (temp.matches - match(names(temp.table), 
stop)),
stopword.summary = array(tapply(temp.table, 
!is.na(temp.matches), sum), dim
= 2, dimnames = list(c(no.non.stopwords, no.stopwords)))
)
}

cat(Beginning at , date(), .\n, sep = )
token.tables - 
lapply(1:length(tokens),
function(i.d, doc, stop, func, ...){
if ((i.d - 1) %% 10 == 0) cat((i.d - 1),  report(s) 
completed at ,
date(), .\n, sep = )
lapply(1:length(doc[[i.d]]),
function(i.s, sent, stop, func, ...){
func(sent[[i.s]], stop, ...)
}
, sent = doc[[i.d]], stop = stop, func = func, 
...
)
}
,
doc = tokens, stop = stopwords, func = my.func
)
cat(Terminating at , date(), .\n, sep = )

This script reaches the same point in approx. 1:09 hours, a little under 70
minutes!

What I am noticing now is a severe lack of real memory.  Activity Monitor
shows about 20MB of real memory free.  R, running in 64-bit mode, is using
6.75GB of real and 10GB of virtual memory.  I see lots of disk activity.  This
is undoubtedly the swapping between real and virtual memory.  CPU activity is
very low.  I suppose I could run the script twice, each time on half the
tokens.  That would give me two lists, which I would have to combine into a
single one.

Regards,
Richard


On Thu, 12 Nov 2009 18:53:34 -0500, jim holtman wrote
 Run the script on a small subset of the data and use Rprof to profile
 the code.  This will give you an idea of where time is being spent 
 and where to focus for improvement.  I would suggest that you do not 
 convert the output of the 'table(t)' do a dataframe.  You can just 
 extract the 'names' to get the words.  You might be spending some of 
 the time in the accessing the information in the dataframe, which is 
 really not necessary for your code.
 
 On Thu, Nov 12, 2009 at 2:12 AM, Richard R. Liu richard@pueo-
 owl.ch wrote:
  I am running the following code on a MacBook Pro 17 Unibody early 2009 with
  8GB RAM, OS X 10.5.8, R 2.10.0 Patch from Nov. 2, 2009, in 64-bit mode.
 
  freq.stopwords - numeric(0)
  freq.nonstopwords - numeric(0)
  token.tables - list(0)
  i.ss - c(0)
  cat(Beginning at , date(), .\n)
  for (i.d in 1:length(tokens)) {
         tt - list(0)
         for (i.s in 1:length(tokens[[i.d]])) {
                 t - tolower(tokens[[i.d]][[i.s]])
                 t - sub(^[[:punct:]]*, , t)
                 t - sub([[:punct:]]*$, , t)
                 t - as.data.frame(table(t))
                 i.m - match(t$t, stopwords)
                 i.m.is.na - is.na(i.m)
                 i.ss - i.ss + 1
                 freq.stopwords[i.ss] - sum(t$Freq * !i.m.is.na)
                 freq.nonstopwords[i.ss] - sum(t$Freq * i.m.is.na)
                 tt[[i.s]] - data.frame(token = t$t, freq = t$Freq,
  matches.stopword = i.m)
         }
         token.tables[[i.d]] - tt
         if (i.d %% 5 == 0) cat(i.d, reports completed at , date(), .\n)
  }
  cat(Terminating at , date(), .\n)
 
  The object in the innermost loop are:
  * tokens:  a list of lists.  In the expression tokens[[i.d]][[i.s]], the
  first index runs over 1697 reports, the second over the sentences in the
  report, each of which consists of a vector of tokens, i.e., the character
  strings between the white spaces in the sentence.  One of the largest
  reports takes up 58MB on the harddisk.  Thus, the number of sentences can be
  quite large, and some of the sentences are quite long (measure in tokens as
  well as in characters).
  * stopwords:  is a vector of 571 words that occur very often in written
  English.
 
  The code operates on sentences, converting each token in the sentence to
  lowercase, removing punctuation at the beginning and end of the token,
  tabulating the frequency of the unique 

Re: [R] replace a whole word with sub()

2009-11-13 Thread Prof Brian Ripley
Do you want to replace the whole word or the whole string?  If the 
latter, use


sub(^Ig.*, 0, x)

(Matching is greedy, so .* matches are many characters as possible, 
here the rest of the string.)


If 'whole word', we need a precise definition of word, but

sub(^Ig\\w*, 0, x)

is one conventional one (a word is alphanumeric: but you might not 
allow numbers).


On Fri, 13 Nov 2009, Giulio Di Giovanni wrote:


Dear all,

I cannot figure out how to solve a small problem (well, not for me), 
surely somebody can help me in few seconds.


I have a series of strings in a vector X of the type xxx, yyy, 
zzz, IgA, IgG, kkk, IgM, aaa.


I want to substitute every ENTIRE string beginning with Ig with 0.

So, I'd like to have xxx, yyy, zzz, 0, 0, kkk, 0, aaa.

I can easily identify these strings with grep(^Ig, X), but if I 
use this criterion in the sub() function (sub(^Ig, 0, X) I 
obviously get 0A, 0G etc.


I didn't expect to do it in this way and I tried with metacharacters 
and regexps in order to grep and substitute the whole word (\b \, 
$). I don't post here my tryings, because they were obviously wrong.


Please can you help me?



Giulio

_
Carica e scarica in un clic. Fino a 25 GB su SkyDrive

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



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

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


[R] NetCDF output in R

2009-11-13 Thread nana
Dear Users,

I have corrected the errors. Many thanks.

For this error,

 [1] put.var.ncdf: warning: you asked to write 1440 values, but the passed 
 data array has 37440 entries!
I added start= c(1,1,1), count=c(length(lons),length(lats),length(nt)) in the 
put.var.ncdf function.

so put.var.ncdf(ncid, var, data)
became put.var.ncdf(ncid, var, data, start= c(1,1,1), 
count=c(length(lons),length(lats),length(nt)))

For this,
 Warning message:
 In 1:nt : numerical expression has 26 elements: only the first used

I replaced times with nt in the tdim in the dim.def.ncdf function.
so
tdim - dim.def.ncdf('time','days since 1980-01-01', times, unlim=TRUE)
became
tdim - dim.def.ncdf('time','days since 1980-01-01', nt, unlim=TRUE)

Thanks all.

Nana Browne



There is no key to happiness. The door is always open.


  
[[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 show all the functions and classes that are defined in a library?

2009-11-13 Thread Peng Yu
library(some_library_name)

Suppose I load a library. I'm wondering what command I should use to
list all the functions, classes and variables defined in the library.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] vignettes: .png graphics or pre-compiled .pdf

2009-11-13 Thread Michael Friendly
In a package I'm working on there is a vignette with a number of graphs 
that result in huge .pdf files, so
the .pdf for the vignette is around 17 Mb.  If these graphs are 
converted to .png, and the .tex file

is compiled with pdflatex, the resulting .pdf is ~1 Mb.

I'm reluctant to put the .Rnw file into the package as is, generating 
the huge .pdf for the vignette.
I first tried installing the smaller .pdf file in the package by itself 
(no .Rnw)

together with a file inst/doc/index.html as recommended
in 'Writing R Extensions.'  However, when the package is installed, 
vignette() can't find it


 vignette(package=Guerry)
no vignettes found
 vignette(MultiSpat)
Warning message:
vignette 'MultiSpat' *not* found

Alternatively, is there a way to generate .png graphs from the .Rnw file 
so that those are used in building
the .pdf for the package?  AFAICS, \SweaveOpts{} offers only the choices 
of eps/pdf = {TRUE/FALSE}.


-Michael

--
Michael Friendly Email: friendly AT yorku DOT ca 
Professor, Psychology Dept.

York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele Streethttp://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.


[R] Craddock-Flood Test in R?

2009-11-13 Thread soeren . vogel

Hello

The Craddock-Flood Test is recommended for large tables with small  
degrees of freedom and low-frequency cells. Is there an R procedure  
and/or package which does the test?


Thank you for your help!

Sören Vogel

--
Sören Vogel, Dipl.-Psych. (Univ.), PhD-Student, Eawag, Dept. SIAM
http://www.eawag.ch, http://sozmod.eawag.ch

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 show all the functions and classes that are defined in a library?

2009-11-13 Thread Romain Francois

On 11/13/2009 04:53 PM, Peng Yu wrote:


library(some_library_name)

Suppose I load a library.


You mean package right ? A library is a set of packages


I'm wondering what command I should use to
list all the functions, classes and variables defined in the library.


Check ?ls :

 ls( package:some_package_name )
 ls( package:some_package_name, all = TRUE )

Sometimes you want to see even those that are not exported from the 
namespace:


 ls( asNamespace( some_package_name ) )
 ls( asNamespace( some_package_name ), all = TRUE )

Romain

--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://tr.im/EAD5 : LondonR slides
|- http://tr.im/BcPw : celebrating R commit #5
`- http://tr.im/ztCu : RGG #158:161: examples of package IDPmisc

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] vignettes: .png graphics or pre-compiled .pdf

2009-11-13 Thread Achim Zeileis

On Fri, 13 Nov 2009, Michael Friendly wrote:

In a package I'm working on there is a vignette with a number of graphs that 
result in huge .pdf files, so
the .pdf for the vignette is around 17 Mb.  If these graphs are converted to 
.png, and the .tex file

is compiled with pdflatex, the resulting .pdf is ~1 Mb.

I'm reluctant to put the .Rnw file into the package as is, generating the 
huge .pdf for the vignette.
I first tried installing the smaller .pdf file in the package by itself (no 
.Rnw)

together with a file inst/doc/index.html as recommended
in 'Writing R Extensions.'  However, when the package is installed, 
vignette() can't find it



vignette(package=Guerry)

no vignettes found

vignette(MultiSpat)

Warning message:
vignette 'MultiSpat' *not* found

Alternatively, is there a way to generate .png graphs from the .Rnw file so 
that those are used in building
the .pdf for the package?  AFAICS, \SweaveOpts{} offers only the choices of 
eps/pdf = {TRUE/FALSE}.


Yes, but you can call the png() device yourself within the code chunk

=
png(file = fig1.png, ...)
...
dev.off()
@

and then put

\includegraphics{fig1}

manually into the LaTeX. It's certainly not as nice as Sweave's automatic 
handling of figures but will work and still keep the file self-contained.

Z


-Michael

--
Michael Friendly Email: friendly AT yorku DOT ca Professor, Psychology 
Dept.

York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele Streethttp://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.




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

2009-11-13 Thread Soeren . Vogel

Hello

a - c(Mama, Papa, Papa; Mama, , Sammy; Mama; Papa)
a - strsplit(a, ; )
mama - rep(F, length(a))
mama[sapply(a, function(x) { sum(x==Mama) }, simplify=T)  0] - T
papa - rep(F, length(a))
papa[sapply(a, function(x) { sum(x==Papa) }, simplify=T)  0] - T
# ... more variables

... produces the variables mama and papa correctly. But how do I  
remove all Mama list entries in a in the same run, that is, shrink  
the list by what was already matched?


Thank you for your help!

Sören Vogel


--
Sören Vogel, Dipl.-Psych. (Univ.), PhD-Student, Eawag, Dept. SIAM
http://www.eawag.ch, http://sozmod.eawag.ch

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

2009-11-13 Thread amor Gandhi
Thank you for your reply.

The only contact address of the maintainer is 
http://www-stat.stanford.edu/~tibs/SAM 

However, one find no contact when one visit this page. 

I am not a mathematician, therefore, it is strange for me to get probability 
bigger that 1, if it is like that should I trust the p-value of 0.004332? 

Sorry for these questions.

Best wishes,
Amor


--- Peter Dalgaard p.dalga...@biostat.ku.dk schrieb am Fr, 13.11.2009:

Von: Peter Dalgaard p.dalga...@biostat.ku.dk
Betreff: Re: [R] p-value  1
An: amor Gandhi amorigan...@yahoo.de
CC: r-h...@stat.math.ethz.ch
Datum: Freitag, 13. November 2009, 15:24

amor Gandhi wrote:
 Dear all,
 
 I am trying to use SAMr-library(samr), it gives me p-value = 1.001, any idea 
 why?

Well, the package maintainer might be a better place to ask. (Bring an example 
if you do.)

However, as a generic matter, the result is obviously nonsensical, and could be 
due to a sloppy approximation of a distribution function, or maybe it is a 
(say) Bonferroni-adjusted p-value which is really an upper bound for the 
correct p-value.

Notice, though, that you should only very rarely care about the exact p-value. 
As soon as it is above 0.1, the message is just that you have not proven that 
there is an effect.

--    O__   Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
~~ - (p.dalga...@biostat.ku.dk)              FAX: (+45) 35327907


__


z gegen Massenmails. 

[[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] p-value 1

2009-11-13 Thread Ista Zahn
The maintainer's email address is listed in the package
documentation... as I think is the case with all CRAN packages.

-Ista

On Fri, Nov 13, 2009 at 11:20 AM, amor Gandhi amorigan...@yahoo.de wrote:
 Thank you for your reply.

 The only contact address of the maintainer is
 http://www-stat.stanford.edu/~tibs/SAM

 However, one find no contact when one visit this page.

 I am not a mathematician, therefore, it is strange for me to get probability 
 bigger that 1, if it is like that should I trust the p-value of 0.004332?

 Sorry for these questions.

 Best wishes,
 Amor


 --- Peter Dalgaard p.dalga...@biostat.ku.dk schrieb am Fr, 13.11.2009:

 Von: Peter Dalgaard p.dalga...@biostat.ku.dk
 Betreff: Re: [R] p-value  1
 An: amor Gandhi amorigan...@yahoo.de
 CC: r-h...@stat.math.ethz.ch
 Datum: Freitag, 13. November 2009, 15:24

 amor Gandhi wrote:
 Dear all,

 I am trying to use SAMr-library(samr), it gives me p-value = 1.001, any idea 
 why?

 Well, the package maintainer might be a better place to ask. (Bring an 
 example if you do.)

 However, as a generic matter, the result is obviously nonsensical, and could 
 be due to a sloppy approximation of a distribution function, or maybe it is a 
 (say) Bonferroni-adjusted p-value which is really an upper bound for the 
 correct p-value.

 Notice, though, that you should only very rarely care about the exact 
 p-value. As soon as it is above 0.1, the message is just that you have not 
 proven that there is an effect.

 --    O__   Peter Dalgaard             Øster Farimagsgade 5, Entr.B
   c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
  (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
 ~~ - (p.dalga...@biostat.ku.dk)              FAX: (+45) 35327907


 __


 z gegen Massenmails.

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





-- 
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org

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


Re: [R] How to show all the functions and classes that are defined in a library?

2009-11-13 Thread hadley wickham
On Fri, Nov 13, 2009 at 9:53 AM, Peng Yu pengyu...@gmail.com wrote:
 library(some_library_name)

Try

help(package = some_library_name)

Hadley


-- 
http://had.co.nz/

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

2009-11-13 Thread Thomas Unternaehrer
I need some random numbers in my C program. Here a small example:


#include R.h

void rand (int* n)
{
  int len = *n;
  for (int i = 0; i  len; i++)
Rprintf(%1.5f , unif_rand());
}

dyn.load(rand.dll)
.C(rand, as.integer(10))
dyn.unload(rand.dll)


But this gives me 10 times the number 0.0 (I need 10 numbers between 0
and 1). Can somebody give me a hint what I'm doing wrong (or misunderstand).

Thanks in advance

Thomas

[[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] Problems by saving Rprofile.site under vista

2009-11-13 Thread anna_l

Hello, I am trying to save some changes I have done on the Rprofile.site
under vista and it doesn´t let me save the file saying that it can´t create
the following file (Rprofile.site)  and that I should check the pathfile or
the file name. 

-- 
View this message in context: 
http://old.nabble.com/Problems-by-saving-Rprofile.site-under-vista-tp26339605p26339605.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] package tm fails to remove the with remove stopwords

2009-11-13 Thread Mark Kimpel
Sam,

Thanks for the example. Removing stop words after the DocumentTermMatrix has
been created works fine if one is working with single words, but what if one
is creating a dtm of possible combinations of words? Wouldn't one want to
remove them from the corpus?

Mark

Mark W. Kimpel MD  ** Neuroinformatics ** Dept. of Psychiatry
Indiana University School of Medicine

15032 Hunter Court, Westfield, IN  46074

(317) 490-5129 Work,  Mobile  VoiceMail
(317) 399-1219 Skype No Voicemail please


On Thu, Nov 12, 2009 at 12:04 PM, Sam Thomas sam.tho...@revelanttech.comwrote:

  I'm not sure what's wrong with your approach, but this seems to strip
 the



 require(tm)

 params - list(minDocFreq = 1,

 removeNumbers = TRUE,

 stemming = TRUE,

 stopwords = TRUE,

 weighting = weightTf)



 myDocument - c(the rain in Spain, falls mainly on the plain, jack and
 jill ran up the hill, to fetch a pail of water)

 text.corp - Corpus(VectorSource(myDocument))

 dtm - DocumentTermMatrix(text.corp, control = params)

 dtm

 dtm.mat - as.matrix(dtm)

 dtm.mat





 *From:* Mark Kimpel [mailto:mwkim...@gmail.com]
 *Sent:* Thursday, November 12, 2009 11:30 AM
 *To:* r-help@r-project.org; feine...@logic.at; Sam Thomas
 *Subject:* package tm fails to remove the with remove stopwords



 I am using code that previously worked to remove stopwords using package
 tm. Even manually adding the to the list does not work to remove the.
 This package has undergone extensive redevelopment with changes to the
 function syntax, so perhaps I am just missing something.



 Please see my simple example, output, and sessionInfo() below.



 Thanks!

 Mark



 require(tm)

 myDocument - c(the rain in Spain, falls mainly on the plain, jack and
 jill ran up the hill, to fetch a pail of water)

 text.corp - Corpus(VectorSource(myDocument))

 #

 text.corp - tm_map(text.corp, stripWhitespace)

 text.corp - tm_map(text.corp, removeNumbers)

 text.corp - tm_map(text.corp, removePunctuation)

 ## text.corp - tm_map(text.corp, stemDocument)

 text.corp - tm_map(text.corp, removeWords, c(the, stopwords(english)))

 dtm - DocumentTermMatrix(text.corp)

 dtm

 dtm.mat - as.matrix(dtm)

 dtm.mat



  dtm.mat

 Terms

 Docs falls fetch hill jack jill mainly pail plain rain ran spain the water

1 0 0000  00 01   0 1   1 0

2 1 0000  10 10   0 0   0 0

3 0 0111  00 00   1 0   0 0

4 0 1000  01 00   0 0   0 1



 R version 2.10.0 Patched (2009-10-27 r50222)

 x86_64-unknown-linux-gnu



 locale:

  [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C

  [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8

  [5] LC_MONETARY=C  LC_MESSAGES=en_US.UTF-8

  [7] LC_PAPER=en_US.UTF-8   LC_NAME=C

  [9] LC_ADDRESS=C   LC_TELEPHONE=C

 [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C



 attached base packages:

 [1] stats graphics  grDevices datasets  utils methods   base



 other attached packages:

 [1] chron_2.3-33 RWeka_0.3-23 tm_0.5-1



 loaded via a namespace (and not attached):

 [1] grid_2.10.0  rJava_0.8-1  slam_0.1-6   tools_2.10.0





 Mark W. Kimpel MD  ** Neuroinformatics ** Dept. of Psychiatry
 Indiana University School of Medicine

 15032 Hunter Court, Westfield, IN  46074

 (317) 490-5129 Work,  Mobile  VoiceMail
 (317) 399-1219 Skype No Voicemail please


[[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] linear model and by()

2009-11-13 Thread Sam Albers
 Hello R list,

 This is a question for anyone who has used the by() command. I would like
 to
 perform a regression on a data frame by several factors. Using by() I
 think
 that I have able to perform this using the following:

  lm.r - by(master, list(Sectionf=Sectionf, startd=startd), function(x) lm

 (tot.c ~ starttime, data = x))

 So that is, I would like to perform separate regressions for each level of
 Sectionf for each level of startd. Now I can get the coefficients and
 intercepts from all the fitted models. However, I am now unsure how to
 glean
 more information from the regressions. If I follow up with this command I
 get this:

  summary(lm.r)

 9-09-04.Length  9-09-04.Class  9-09-04.Mode
 12lmlist
 12lmlist
 12lmlist
 9-09-11.Length  9-09-11.Class  9-09-11.Mode
 12lmlist
 12lmlist
 12lmlist

 Under normal circumstances, this usually ends up giving me more info about
 the fitted model, but some reason when using the by() command it doesn't.


 Beacuase the results are a layer deeper than summary is describing;
 Try:
 lapply(lm.r, summary)


Nice. Thanks I get it now.


 (this theory tested with one of the standard datasets, Indometh:

 library(utils)
 data(Indometh)
 reglist - by(Indometh, Indometh$Subject, function(x) lm(conc~time, data=x)
 )
  summary(reglist)
  Length Class Mode
 1 12 lmlist
 4 12 lmlist
 2 12 lmlist
 5 12 lmlist
 6 12 lmlist
 3 12 lmlist

 Whereas, without the assignment to reglist I got a series of expected lm
 output, so by works.


  Similarly, although I wasn't hopeful that this would work, when I tried to
 examine the residuals, I get these warning messages:


 similarly:

 lapply(lm.r, plot)


This definitely worked quite well. Any thoughts on how to get titles from
the list to appear on the diagnostic plots?




  plot(lm.r$fit,lm.r$res,xlab=Fitted,ylab=Residuals)

 Error in plot.window(...) : need finite 'xlim' values
 In addition: Warning messages:
 1: In min(x) : no non-missing arguments to min; returning Inf
 2: In max(x) : no non-missing arguments to max; returning -Inf
 3: In min(x) : no non-missing arguments to min; returning Inf
 4: In max(x) : no non-missing arguments to max; returning -Inf

 So my question might be answered by someone saying that this isn't a good
 way to do this. Still, can anyone suggest some strategies that might help
 me
 out here? Specifically, how might I be able work with these regressions
 once
 I have fitted all the models. Obviously I need to examine the residuals,
 look at the model fit, etc. Any suggestions on what I might be doing wrong
 would be much appreciated. I am also including a subset of the data and
 the
 commands I used in case that is helpful.

 I am using Ubuntu 9.04 and R 2.8.1

 Thanks in advance!

 Sam


 Sorry to not use your data but it's not in a form that lends itself very
 well to quick testing. If you had included the input commands I might have
 tried it.


No problem not use my data. For future reference, would it have been easier
to attach a .csv file and then include the appropriate read.csv command? I
realized that the easier one makes it to help, the easier it is to get a
response.

Thanks a lot for your help!

Ista- To be fair, I did include Sectionf - factor(Section) below. ;)



  attach(master)
 Sectionf - factor(Section)
 startd=as.Date(startdate, format=%d/%m/%Y)


  lm.r - by(master, list(Sectionf=Sectionf, startd=startd), function(x) lm

 (tot.c ~ starttime, data = x))

 Data:

 Section,starttime,startdate,tot.c
 Upstream,0,04/09/09,0.17
 Upstream,0,04/09/09,0.19
 Upstream,0,04/09/09,0.14
 Middle,0,04/09/09,0.2
 Middle,0,04/09/09,0.13
 Middle,0,04/09/09,0.11
 Downstream,0,04/09/09,0.16
 Downstream,0,04/09/09,0.17
 Downstream,0,04/09/09,0.17
 Upstream,25,04/09/09,0.17
 Upstream,25,04/09/09,0.19
 Upstream,25,04/09/09,0.14
 Middle,25,04/09/09,0.2
 Middle,25,04/09/09,0.13
 Middle,25,04/09/09,0.11
 Downstream,25,04/09/09,0.16
 Downstream,25,04/09/09,0.17
 Downstream,25,04/09/09,0.17
 Upstream,50.06,04/09/09,0.17
 Upstream,50.06,04/09/09,0.19
 Upstream,50.06,04/09/09,0.14
 Middle,50.06,04/09/09,0.2
 Middle,50.06,04/09/09,0.13
 Middle,50.06,04/09/09,0.11
 Downstream,50.06,04/09/09,0.16
 Downstream,50.06,04/09/09,0.17
 Downstream,50.06,04/09/09,0.17
 Upstream,75.42,04/09/09,0.17
 Upstream,75.42,04/09/09,0.19
 Upstream,75.42,04/09/09,0.14
 Middle,75.42,04/09/09,0.2
 Middle,75.42,04/09/09,0.13
 Middle,75.42,04/09/09,0.11
 Downstream,75.42,04/09/09,0.16
 Downstream,75.42,04/09/09,0.17
 Downstream,75.42,04/09/09,0.17
 Upstream,100.14,04/09/09,0.17
 Upstream,100.14,04/09/09,0.19
 Upstream,100.14,04/09/09,0.14
 Middle,100.14,04/09/09,0.2
 Middle,100.14,04/09/09,0.13
 Middle,100.14,04/09/09,0.11
 Downstream,100.14,04/09/09,0.16
 Downstream,100.14,04/09/09,0.17
 Downstream,100.14,04/09/09,0.17
 Upstream,125.31,04/09/09,0.17
 Upstream,125.31,04/09/09,0.19
 Upstream,125.31,04/09/09,0.14
 

[R] R and HDF5 Question

2009-11-13 Thread Scott MacDonald
Hello All,

I just signed up to this list, so I apologize if this question has been
asked before.

I am trying to load an hdf5 file into R and running into some problems. Here
are the steps I took to configure my environment:

* R 2.10.0 (x64) on Mac OS X 10.6
* hdf5 1.8.3 installed via macports
* hdf5_1.6.9.tar.gz from CRAN

I suspect the problem I am having relates to incompatibilities in my version
of HDF5 and the one the R module expects. For completeness here is how I
installed the R module:

R CMD INSTALL --configure-vars='CPPFLAGS=-I/opt/local/include'
--configure-args='--with-hdf5=/opt/local' hdf5_1.6.9.tar.gz

This builds fine. The library seems to load without issue, but no data is
returned when I try to load a file:

 library(hdf5)
 hdf5load(test.h5)
 NULL

Yet,

osx:data scott$ h5dump test.h5 HDF5 test.h5 { GROUP / { DATASET
dset { DATATYPE H5T_STD_I32LE DATASPACE SIMPLE { ( 31 ) / ( 31 ) } DATA {
(0): 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, (14):
16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, (22):
4194304, 8388608, 16777216, 33554432, 67108864, 134217728, (28): 268435456,
536870912, 1073741824 } } } }

Any thoughts?

Thanks in advance.
Scott

[[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] processing log file

2009-11-13 Thread Jabez Wilson
Thanks, that's helpful because I can see the individuals and how many times 
they accessed:
The 'plyr' solution of Karl Ove Hufthammer gives me the exact summary 
statistics that I'm looking for.
 
Jab

--- On Fri, 13/11/09, markle...@verizon.net markle...@verizon.net wrote:


From: markle...@verizon.net markle...@verizon.net
Subject: Re: Re: [R] processing log file
To: jabez...@yahoo.co.uk
Date: Friday, 13 November, 2009, 16:36


Hi: I think below does what you want but it doesn't come out formatted very 
nicely. Maybe someone can show you
the formatting ? Good luck.

table.users - read.table(textConnection(Date UserName Machine
2008-11-25 John 641
2008-11-25    Clive 611
2008-11-25   Jeremy 641
2008-11-25 Walt 722
2008-11-25 Tony 645
2008-11-26 Tony 645
2008-11-26 Tony 641
2008-11-26 Tony 641
2008-11-26 Walt 641
2008-11-26 Walt 645
2008-11-30 John 641
2008-11-30    Clive 611
2008-11-30 Tony 641
2008-11-30 John 641
2008-11-30 John 641),header=TRUE,as.is=TRUE)

print(table.users)
print(str(table.users))

lapply(split(table.users,table.users$Date),function(.df) {
    table(.df$Machine)
})

lapply(split(table.users,table.users$Date),function(.df) {
    table(.df$UserName)
})






On Nov 13, 2009, Karl Ove Hufthammer k...@huftis.org wrote: 

On Fri, 13 Nov 2009 11:03:31 + (GMT) Jabez Wilson 
jabez...@yahoo.co.uk wrote:
 What I want to do is to find out how many unique users logged 
 on each day, and how many individual machines where accessed per day.

Use the 'plyr' package:

library(plyr)
ddply(table.users, .(Date), summarise,
users=length(unique(Username)),
machines=length(unique(Machine)))

-- 
Karl Ove Hufthammer

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

2009-11-13 Thread Jgabriel
I can't fully answer all these questions, but I'll do my best - There
have not been any updates of Windows, and I did not update R during
the period, although I did reinstall it after the problem started.
There have been no changes to Norton or any other software that uses
system resources in that way. The one thing I can think of is that I
installed a program called Digitizer (creates data tables/ csds from
visually analyzing line charts) around the same time it started
freezing. I have completely uninstalled it and deleted all related
files. The problem should not be with the data, which is fine. I am
running Windows XP Professional and Excel 2007. I have allowed the
process to run overnight on two separate occasions. The first time it
was completely frozen and there was no progress. Last night it
actually made progress, but the fact remains that a process that used
to take an hour at the most still has not even halfway completed after
over 8 hours. I even installed extra RAM on the system so that there
is more than when the process used to work. I agree that it is
probably a change in software, but I can't figure out what has changed
or what I can do about it.

Thanks for your help,

JGS

On Nov 12, 7:05 pm, J Dougherty j...@surewest.net wrote:
 There are some points of information you should include.  One, have there been
 recent updates of Windows that may have altered system behaviour?  Two, have
 you updated R during the same period?  Three, have you installed software that
 uses system resources that were available to R before - e.g. has Norton or
 whatever you use to guard your system upgraded?  Four, what versions of
 Windows and Excel are you running?  Five, have you inspected your data for
 corruption?  Six, what changes (data entry, editing, recoding, etc.) have you
 done that might coincide with the changed behaviour?  Seven, have you allowed
 the process to simply run - say overnight?  Nine, how big is you database?

 In essence, your problem sounds like system problem.  The most likely cause is
 a change in software, but without some really clear information on changes on
 your system that could potentially have caused this, you are unlikely to find
 it easily.  One possibility is that a change in software has resulted in
 smaller available resource space.  

 JWDougherty

 On Thursday 12 November 2009 09:05:34 am Jgabriel wrote:



  I have a question that might not be kosher here, but I'm running out
  of options and need some help. Basically using the function step is
 freezingR. I am running a model that includes a number of
  interactions on a large data set with a number of dummy variables
  representing whether an event occurred or not. Here's a simplified
  example -

  fit = lm(a~b*(c+d+e)*(f+g+h)*(i+j+k))
  regs = step(fit)

  at this point R freezes and alternates between Not Responding and
  Running in Windows task manager. It wasn't always this way. I was
  able to run the same model on the same dataset a couple weeks ago and
  while it took the step function 20-30 minutes to compute the best AIC
  and didn't exclude all the insignificant variables/interactions, it
  served its purpose. Even after uninstalling and reinstalling R and
  RExcel (which I used to load the data set), the problem persists. I
  tried it on a smaller data set and still no luck. This is more of a
  computing issue, so if anyone can point me to a forum better equipped
  to help me out, I will owe you my eternal gratitude. I hate to fill up
  space with such an uninspired question, but like I said I'm running
  out of options.

  Thanks,

  JGS

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

 __
 r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guidehttp://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] R installation on UNIX machine

2009-11-13 Thread Powers, Randall - BLS
 
Hello All,

I have downloaded and untarred R 2.10.0 onto my SUN UNIX machine. When I
run ./configure, it runs through a series of questions and stops at this
(and I get this when I try the make command): 

checking for iconv.h... yes
checking for iconv... in libiconv
checking whether iconv accepts UTF-8, latin1 and UCS-*... no
configure: error: a suitable iconv is essential
# make
make: not found


Could someone decipher this and tell me how I would get a suitable
iconv? And is that indeed what it causing make to not be found?


I did find this info below in the admin manual appendix. However, when I
click on the link and run the suggested install, I get the same results.



A suitably comprehensive iconv function is essential. The R usage
requires iconv to be able to translate between latin1 and UTF-8, to
recognize  as the current encoding and to translate to and from the
Unicode wide-character formats UCS-[24][BL]E - this is true for glibc
but not of most commercial Unixes. However, you can make use of GNU
libiconv (possibly as a plug-in replacement: see
http://www.gnu.org/software/libiconv/. 

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

2009-11-13 Thread anna_l

Hello, I am getting an error with the following code:
if( P2  P1)
+ {
+ P-P2
+ }
 else
Erro: unexpected 'else' in else
 {
+ P-P1
+ }

I checked the syntax so I don´t understand, I have other if else statements
with the same syntax working. Thanks in advance
-- 
View this message in context: 
http://old.nabble.com/Simple-if-else-statement-problem-tp26340336p26340336.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] Trellis settings get lost when printing to pdf

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

Hi all,

 

I've got some problems when changing the trellis settings for the lattice 
plots. The plots look exactly as I want them to when calling show.settings() as 
well as when plotting them in the graphical window. But when printing to a pdf 
file, none of the settings are used!? Does anyone know what might have 
happened? Because the when changing the trellis settings, these should remain 
in the new state until you close R right..?

 

# Change settings for the boxplot appearance
new.dot=trellis.par.get(box.dot)
new.rectangle=trellis.par.get(box.rectangle)
new.umbrella=trellis.par.get(box.umbrella)
new.symbol=trellis.par.get(plot.symbol)
new.strip.background=trellis.par.get(strip.background)
new.strip.shingle=trellis.par.get(strip.shingle)
new.dot$pch=|
new.dot$col=black
new.rectangle$col=black
new.rectangle$fill=grey65
new.umbrella$col=black
new.umbrella$lty=1 # Continous line, not dotted
new.symbol$col=black
new.strip.background$col=grey87 # Background colour in the upper label
new.strip.shingle$col=black # Border colour around the upper label
trellis.par.set(box.dot=new.dot, box.rectangle=new.rectangle, 
box.umbrella=new.umbrella, plot.symbol=new.symbol, 
strip.background=new.strip.background, strip.shingle=new.strip.shingle)

 

Best regards,

 

Joel
  
_
Nya Windows 7 - Hitta en dator som passar dig! Mer information. 
http://windows.microsoft.com/shop
[[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] Simple if else statement problem

2009-11-13 Thread Benilton Carvalho

align the else with the curly brackets

if (yes){
be happy
}else{
complain
}

b

On Nov 13, 2009, at 3:33 PM, anna_l wrote:



Hello, I am getting an error with the following code:
if( P2  P1)
+ {
+ P-P2
+ }

else

Erro: unexpected 'else' in else

{

+ P-P1
+ }

I checked the syntax so I don´t understand, I have other if else  
statements

with the same syntax working. Thanks in advance
--
View this message in context: 
http://old.nabble.com/Simple-if-else-statement-problem-tp26340336p26340336.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] Simple if else statement problem

2009-11-13 Thread Jim Burke

Anna,

I think the else needs to be on the same line
as the curly bracket like this } else.

P1 - 1
P2 - 2

if( P2  P1)
{
   P-P2
} else
{
   P-P1
}

Good luck,
Jim

anna_l wrote:

Hello, I am getting an error with the following code:
if( P2  P1)
+ {
+ P-P2
+ }
  

else


Erro: unexpected 'else' in else
  

{


+ P-P1
+ }

I checked the syntax so I don´t understand, I have other if else statements
with the same syntax working. Thanks in advance



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Trellis settings get lost when printing to pdf

2009-11-13 Thread Sundar Dorai-Raj
Did you make the changes before or after starting the device:

library(lattice)
## before doesn't change the settings on the device:
trellis.par.set(plot.symbol = list(col = red))
trellis.device(pdf, file = tmp.pdf)
xyplot(1 ~ 1)
dev.off()

## after does
trellis.device(pdf, file = tmp.pdf)
trellis.par.set(plot.symbol = list(col = red))
xyplot(1 ~ 1)
dev.off()

I never do things like this, though. I would suggest creating a theme
instead and supplying it to xyplot (or whatever plot you're using)
using par.settings:

my.theme - list(plot.symbol = list(col = red))
trellis.device(pdf, file = tmp.pdf)
xyplot(1 ~ 1, par.settings = my.theme)
dev.off()

HTH,

--sundar


2009/11/13 Joel Fürstenberg-Hägg joel_furstenberg_h...@hotmail.com:

 Hi all,



 I've got some problems when changing the trellis settings for the lattice 
 plots. The plots look exactly as I want them to when calling show.settings() 
 as well as when plotting them in the graphical window. But when printing to a 
 pdf file, none of the settings are used!? Does anyone know what might have 
 happened? Because the when changing the trellis settings, these should remain 
 in the new state until you close R right..?



 # Change settings for the boxplot appearance
 new.dot=trellis.par.get(box.dot)
 new.rectangle=trellis.par.get(box.rectangle)
 new.umbrella=trellis.par.get(box.umbrella)
 new.symbol=trellis.par.get(plot.symbol)
 new.strip.background=trellis.par.get(strip.background)
 new.strip.shingle=trellis.par.get(strip.shingle)
 new.dot$pch=|
 new.dot$col=black
 new.rectangle$col=black
 new.rectangle$fill=grey65
 new.umbrella$col=black
 new.umbrella$lty=1 # Continous line, not dotted
 new.symbol$col=black
 new.strip.background$col=grey87 # Background colour in the upper label
 new.strip.shingle$col=black # Border colour around the upper label
 trellis.par.set(box.dot=new.dot, box.rectangle=new.rectangle, 
 box.umbrella=new.umbrella, plot.symbol=new.symbol, 
 strip.background=new.strip.background, strip.shingle=new.strip.shingle)



 Best regards,



 Joel

 _
 Nya Windows 7 - Hitta en dator som passar dig! Mer information.
 http://windows.microsoft.com/shop
        [[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] Simple if else statement problem

2009-11-13 Thread anna_l

Ok Jim it worked, thank you! it´s funny because it worked with the first
syntax in some cases...


anna_l wrote:
 
 Hello, I am getting an error with the following code:
 if( P2  P1)
 + {
 + P-P2
 + }
 else
 Erro: unexpected 'else' in else
 {
 + P-P1
 + }
 
 I checked the syntax so I don´t understand, I have other if else
 statements with the same syntax working. Thanks in advance
 

-- 
View this message in context: 
http://old.nabble.com/Simple-if-else-statement-problem-tp26340336p26340642.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] processing log file

2009-11-13 Thread Henrique Dallazuanna
You can use aggregate to get this too:

aggregate(table.users[,c('UserName', 'Machine')], table.users['Date'],
function(x)length(unique(x)))

On Fri, Nov 13, 2009 at 3:01 PM, Jabez Wilson jabez...@yahoo.co.uk wrote:
 Thanks, that's helpful because I can see the individuals and how many times 
 they accessed:
 The 'plyr' solution of Karl Ove Hufthammer gives me the exact summary 
 statistics that I'm looking for.

 Jab

 --- On Fri, 13/11/09, markle...@verizon.net markle...@verizon.net wrote:


 From: markle...@verizon.net markle...@verizon.net
 Subject: Re: Re: [R] processing log file
 To: jabez...@yahoo.co.uk
 Date: Friday, 13 November, 2009, 16:36


 Hi: I think below does what you want but it doesn't come out formatted very 
 nicely. Maybe someone can show you
 the formatting ? Good luck.

 table.users - read.table(textConnection(Date UserName Machine
 2008-11-25 John 641
 2008-11-25    Clive 611
 2008-11-25   Jeremy 641
 2008-11-25 Walt 722
 2008-11-25 Tony 645
 2008-11-26 Tony 645
 2008-11-26 Tony 641
 2008-11-26 Tony 641
 2008-11-26 Walt 641
 2008-11-26 Walt 645
 2008-11-30 John 641
 2008-11-30    Clive 611
 2008-11-30 Tony 641
 2008-11-30 John 641
 2008-11-30 John 641),header=TRUE,as.is=TRUE)

 print(table.users)
 print(str(table.users))

 lapply(split(table.users,table.users$Date),function(.df) {
     table(.df$Machine)
 })

 lapply(split(table.users,table.users$Date),function(.df) {
     table(.df$UserName)
 })






 On Nov 13, 2009, Karl Ove Hufthammer k...@huftis.org wrote:

 On Fri, 13 Nov 2009 11:03:31 + (GMT) Jabez Wilson
 jabez...@yahoo.co.uk wrote:
 What I want to do is to find out how many unique users logged
 on each day, and how many individual machines where accessed per day.

 Use the 'plyr' package:

 library(plyr)
 ddply(table.users, .(Date), summarise,
 users=length(unique(Username)),
 machines=length(unique(Machine)))

 --
 Karl Ove Hufthammer

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





-- 
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] Step Function Freezing R

2009-11-13 Thread Uwe Ligges



Jgabriel wrote:

I can't fully answer all these questions, but I'll do my best - There
have not been any updates of Windows, and I did not update R during
the period, although I did reinstall it after the problem started.
There have been no changes to Norton or any other software that uses
system resources in that way. The one thing I can think of is that I
installed a program called Digitizer (creates data tables/ csds from
visually analyzing line charts) around the same time it started
freezing. I have completely uninstalled it and deleted all related
files. The problem should not be with the data, which is fine. I am
running Windows XP Professional and Excel 2007. I have allowed the
process to run overnight on two separate occasions. The first time it
was completely frozen and there was no progress. Last night it
actually made progress, but the fact remains that a process that used
to take an hour at the most still has not even halfway completed after
over 8 hours. I even installed extra RAM on the system 



Aha! Please ask your local IT experts to check the RAM and if that is 
fine ask them to proceed. I have already seen too many machines with RAM 
problems during the last years. It is hardly an R problem.


Uwe Ligges



so that there
is more than when the process used to work. I agree that it is
probably a change in software, but I can't figure out what has changed
or what I can do about it.

Thanks for your help,

JGS

On Nov 12, 7:05 pm, J Dougherty j...@surewest.net wrote:

There are some points of information you should include.  One, have there been
recent updates of Windows that may have altered system behaviour?  Two, have
you updated R during the same period?  Three, have you installed software that
uses system resources that were available to R before - e.g. has Norton or
whatever you use to guard your system upgraded?  Four, what versions of
Windows and Excel are you running?  Five, have you inspected your data for
corruption?  Six, what changes (data entry, editing, recoding, etc.) have you
done that might coincide with the changed behaviour?  Seven, have you allowed
the process to simply run - say overnight?  Nine, how big is you database?

In essence, your problem sounds like system problem.  The most likely cause is
a change in software, but without some really clear information on changes on
your system that could potentially have caused this, you are unlikely to find
it easily.  One possibility is that a change in software has resulted in
smaller available resource space.  


JWDougherty

On Thursday 12 November 2009 09:05:34 am Jgabriel wrote:




I have a question that might not be kosher here, but I'm running out
of options and need some help. Basically using the function step is
freezingR. I am running a model that includes a number of
interactions on a large data set with a number of dummy variables
representing whether an event occurred or not. Here's a simplified
example -
fit = lm(a~b*(c+d+e)*(f+g+h)*(i+j+k))
regs = step(fit)
at this point R freezes and alternates between Not Responding and
Running in Windows task manager. It wasn't always this way. I was
able to run the same model on the same dataset a couple weeks ago and
while it took the step function 20-30 minutes to compute the best AIC
and didn't exclude all the insignificant variables/interactions, it
served its purpose. Even after uninstalling and reinstalling R and
RExcel (which I used to load the data set), the problem persists. I
tried it on a smaller data set and still no luck. This is more of a
computing issue, so if anyone can point me to a forum better equipped
to help me out, I will owe you my eternal gratitude. I hate to fill up
space with such an uninspired question, but like I said I'm running
out of options.
Thanks,
JGS
__
r-h...@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.htmland provide commented, minimal,
self-contained, reproducible code.

__
r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guidehttp://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] package tm fails to remove the with remove stopwords

2009-11-13 Thread Sam Thomas
Mark,

 

It looks like removeWords removed the in all instances except when
the was the first word in your text.   Maybe there is a parameter that
needs to be set?  I couldn't find anything on the help page.  

 

Here's an example of what I am seeing using the crude dataset

 

#function removeWords does not appear to remove the first word

require(tm)

data(crude)

crude[[1]]

removeWords(crude[[1]], Shamrock)  #Second word removed

removeWords(crude[[1]], Diamond)  #First word not removed

 

Sam Thomas

 

 

From: Mark Kimpel [mailto:mwkim...@gmail.com] 
Sent: Friday, November 13, 2009 11:47 AM
To: Sam Thomas
Cc: r-help@r-project.org; feine...@logic.at
Subject: Re: package tm fails to remove the with remove stopwords

 

Sam,

 

Thanks for the example. Removing stop words after the DocumentTermMatrix
has been created works fine if one is working with single words, but
what if one is creating a dtm of possible combinations of words?
Wouldn't one want to remove them from the corpus?

 

Mark


Mark W. Kimpel MD  ** Neuroinformatics ** Dept. of Psychiatry
Indiana University School of Medicine

15032 Hunter Court, Westfield, IN  46074

(317) 490-5129 Work,  Mobile  VoiceMail
(317) 399-1219 Skype No Voicemail please



On Thu, Nov 12, 2009 at 12:04 PM, Sam Thomas
sam.tho...@revelanttech.com wrote:

I'm not sure what's wrong with your approach, but this seems to strip
the

 

require(tm)

params - list(minDocFreq = 1, 

removeNumbers = TRUE,

stemming = TRUE,

stopwords = TRUE,

weighting = weightTf)

 

myDocument - c(the rain in Spain, falls mainly on the plain, jack
and jill ran up the hill, to fetch a pail of water)

text.corp - Corpus(VectorSource(myDocument))

dtm - DocumentTermMatrix(text.corp, control = params)

dtm

dtm.mat - as.matrix(dtm)

dtm.mat

 

 

From: Mark Kimpel [mailto:mwkim...@gmail.com] 
Sent: Thursday, November 12, 2009 11:30 AM
To: r-help@r-project.org; feine...@logic.at; Sam Thomas
Subject: package tm fails to remove the with remove stopwords

 

I am using code that previously worked to remove stopwords using package
tm. Even manually adding the to the list does not work to remove
the. This package has undergone extensive redevelopment with changes
to the function syntax, so perhaps I am just missing something. 

 

Please see my simple example, output, and sessionInfo() below.

 

Thanks!

Mark

 

require(tm)

myDocument - c(the rain in Spain, falls mainly on the plain, jack
and jill ran up the hill, to fetch a pail of water)

text.corp - Corpus(VectorSource(myDocument))

#

text.corp - tm_map(text.corp, stripWhitespace)

text.corp - tm_map(text.corp, removeNumbers)

text.corp - tm_map(text.corp, removePunctuation)

## text.corp - tm_map(text.corp, stemDocument)

text.corp - tm_map(text.corp, removeWords, c(the,
stopwords(english)))

dtm - DocumentTermMatrix(text.corp)

dtm

dtm.mat - as.matrix(dtm)

dtm.mat

 

 dtm.mat

Terms

Docs falls fetch hill jack jill mainly pail plain rain ran spain the
water

   1 0 0000  00 01   0 1   1
0

   2 1 0000  10 10   0 0   0
0

   3 0 0111  00 00   1 0   0
0

   4 0 1000  01 00   0 0   0
1

 

R version 2.10.0 Patched (2009-10-27 r50222) 

x86_64-unknown-linux-gnu 

 

locale:

 [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C  

 [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8

 [5] LC_MONETARY=C  LC_MESSAGES=en_US.UTF-8   

 [7] LC_PAPER=en_US.UTF-8   LC_NAME=C 

 [9] LC_ADDRESS=C   LC_TELEPHONE=C

[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C   

 

attached base packages:

[1] stats graphics  grDevices datasets  utils methods   base


 

other attached packages:

[1] chron_2.3-33 RWeka_0.3-23 tm_0.5-1

 

loaded via a namespace (and not attached):

[1] grid_2.10.0  rJava_0.8-1  slam_0.1-6   tools_2.10.0

 

 

Mark W. Kimpel MD  ** Neuroinformatics ** Dept. of Psychiatry
Indiana University School of Medicine

15032 Hunter Court, Westfield, IN  46074

(317) 490-5129 Work,  Mobile  VoiceMail
(317) 399-1219 Skype No Voicemail please

 


[[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 the same values cannot be judged to be the same in R

2009-11-13 Thread rusers.sh
Thanks all.
 %in% is what i need.

2009/11/13 jim holtman jholt...@gmail.com

 I think you want to use '%in%' instead of '=='.  Try debugging (or
 understanding) what is happening by evaluating the subexpressions of
 the compares you have in your original posting.  Also take a look at
 the 'recycling' of arguments and then you may understand what is
 happening:

  data2[(data2$x1 %in% data_1$x1)  (data2$y1 %in% data_1$y1)  (data2$tag
 == 0),]
   areaid   x1   y1 tag
 2  1 1.53 2.34   0
 4  1 1.52 2.35   0
 


 On Thu, Nov 12, 2009 at 10:04 PM, rusers.sh rusers...@gmail.com wrote:
  Hi Rusers,
   I found sometimes that the same values cannot be judged to be the same
 in
  R. Anybody knows the probelm? I think i ignored some minor detail.
 Thanks.
  Here is the example.
  
 
 data1-matrix(data=c(1,1.2,1.3,3/23/2004,1,1.5,2.3,3/22/2004,2,0.2,3.3,4/23/2004,3,1.5,1.3,5/22/2004),nrow=4,ncol=4,byrow=TRUE)
  data1-data.frame(data1);names(data1)-c(areaid,x,y,date)
  data2-matrix(data=c(1,1.22,1.32,1,  1.53,  2.34,1,  1.21,  1.37,1,
  1.52,
  2.35,2,  0.21,  3.33,2,  0.23,  3.35,3,  1.57, 1.31,3,  1.59,
  1.33),nrow=8,ncol=3,byrow=TRUE)
  data2-data.frame(data2);names(data2)-c(areaid,x1,y1)
  data2$tag-0
  data1_1-data1[1,]
  data2_1-data2[data2$areaid==data1_1$areaid  data2$tag==0,]
  ran_1-sample(c(1:length(data2_1)),2, replace = FALSE)
  data2_1-data2_1[ran_1,]
  data_1-merge(data1_1,data2_1)
  #data_1
  #   areaid  x   y  date   x1   y1  tag
  #1  1 1.2 1.3 3/23/2004 1.52 2.35   0
  #2  1 1.2 1.3 3/23/2004 1.53 2.34   0
  data2[data_1$x1==data2$x1  data_1$y1==data2$y1  data2$tag==0,]
   #data2[c(data_1$x1==data2$x1  data_1$y1==data2$y1  data2$tag==0),]
  #areaid   x1y1   tag
  #2  11.53  2.34   0
   There should be two same observations between data_1 and data2, but here
  only one was identified.
   Thanks a lot.
 
  --
  -
  Jane Chang
  Queen's
 
 [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 



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

 What is the problem that you are trying to solve?




-- 
-
Jane Chang
Queen's

[[alternative HTML version deleted]]

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


Re: [R] random numbers in C

2009-11-13 Thread Thomas Unternaehrer
Ups... I've overlooked that part. Thanks a lot for the fast response!


On Fri, Nov 13, 2009 at 6:05 PM, Duncan Murdoch murd...@stats.uwo.cawrote:

 On 11/13/2009 11:41 AM, Thomas Unternaehrer wrote:

 I need some random numbers in my C program. Here a small example:


 
 #include R.h

 void rand (int* n)
 {
  int len = *n;
  for (int i = 0; i  len; i++)
Rprintf(%1.5f , unif_rand());
 }

 dyn.load(rand.dll)
 .C(rand, as.integer(10))
 dyn.unload(rand.dll)

 

 But this gives me 10 times the number 0.0 (I need 10 numbers between 0
 and 1). Can somebody give me a hint what I'm doing wrong (or
 misunderstand).


 At a minimum, you forgot to call GetRNGState and PutRNGState.  See Writing
 R Extensions for details.  But if you are running this from outside of R,
 you'll also need to read about building a standalone Mathlib.

 Duncan Murdoch


[[alternative HTML version deleted]]

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


Re: [R] linear model and by()

2009-11-13 Thread Ista Zahn
On Fri, Nov 13, 2009 at 11:49 AM, Sam Albers tonightstheni...@gmail.com wrote:
snip
 No problem not use my data. For future reference, would it have been easier
 to attach a .csv file and then include the appropriate read.csv command? I
 realized that the easier one makes it to help, the easier it is to get a
 response.

 Thanks a lot for your help!

 Ista- To be fair, I did include Sectionf - factor(Section) below. ;)

True enough, sorry I missed it!

snip

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


Re: [R] Simple if else statement problem

2009-11-13 Thread Duncan Murdoch

On 11/13/2009 12:54 PM, anna_l wrote:

Ok Jim it worked, thank you! it´s funny because it worked with the first
syntax in some cases...


If R knows the whole thing is incomplete, it will accept an else on its 
own line.  If the first 4 lines make a complete statement, R will 
evaluate it, and not accept the following else.


So putting braces around the whole thing is another workaround, but 
putting the else on the same line as the first closing brace is probably 
better.


Duncan Murdoch




anna_l wrote:


Hello, I am getting an error with the following code:
if( P2  P1)
+ {
+ P-P2
+ }

else

Erro: unexpected 'else' in else

{

+ P-P1
+ }

I checked the syntax so I don´t understand, I have other if else
statements with the same syntax working. Thanks in advance





__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Unsuccessful in reproducing README file in package build .zip and R library installed package folder

2009-11-13 Thread Uwe Ligges

[Going through some old and from what I see unanswered messages

See Writing R Extensions: The contents of subdirectory ./inst will be 
copied to top level during package installation (i.e. also for making 
binary packages).


Best wishes,
Uwe Ligges



morp...@comcast.net wrote:
My OS is Windows XP. 

Writing R Extensions, Section 1.1 states ‘README’ or ‘ChangeLog’ will be ignored by R, but may be useful to 


end-users.  I see examples of README files in packages grDevices folder afm 
and nlme folder mlbook.


The README file was placed at the top level of the package source folder, after the DESCRIPTION file. 

After running R CMD check, build, and INSTALL --build, the README file was found in the tar.gz file.  However, 


it was not found in the zip file, the package Rcheck folder, and the R library 
package folder.


How is the README put into build such that it is reproduced in the R library installed package folder? 



Bill Morphet, Ph.D.

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


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

2009-11-13 Thread Duncan Murdoch

On 11/13/2009 11:41 AM, Thomas Unternaehrer wrote:

I need some random numbers in my C program. Here a small example:


#include R.h

void rand (int* n)
{
  int len = *n;
  for (int i = 0; i  len; i++)
Rprintf(%1.5f , unif_rand());
}

dyn.load(rand.dll)
.C(rand, as.integer(10))
dyn.unload(rand.dll)


But this gives me 10 times the number 0.0 (I need 10 numbers between 0
and 1). Can somebody give me a hint what I'm doing wrong (or misunderstand).


At a minimum, you forgot to call GetRNGState and PutRNGState.  See 
Writing R Extensions for details.  But if you are running this from 
outside of R, you'll also need to read about building a standalone Mathlib.


Duncan Murdoch

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


[R] multivariate meta-analysis with the metafor package

2009-11-13 Thread Antonio.Gasparrini
Dear Wolfgang Viechtbauer and R users,
 
I have few questions regarding the development of the package 'metafor.
As you suggested , I post to the R-help mailing list.
 
I read you're planning an extension of this method to the multivariate case.
I think it would be a useful tool.
I'm currently performing some analyses with R on multiple outcomes, using the 
Stata command mvmeta to get meta-analytic multivariate estimates, then coming 
back to R to use these results. Obviously, it's irritating to switch software 
every time.
 
Briefly:
- Are you still planning this extension? And in this case, do you have a 
planned date?
- What are likely to be the advantages and limitations of a potential 
'rma.multi' if compared to Stata's 'mvmeta'?

Thank you for your time
Regards,

Antonio Gasparrini
Public and Environmental Health Research Unit (PEHRU)
London School of Hygiene  Tropical Medicine
Keppel Street, London WC1E 7HT, UK
Office: 0044 (0)20 79272406 - Mobile: 0044 (0)79 64925523
Skype contact: a.gasparrini
http://www.lshtm.ac.uk/people/gasparrini.antonio ( 
http://www.lshtm.ac.uk/pehru/ )

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] roc plot with zero length labels error

2009-11-13 Thread Uwe Ligges

[Going through some old and from what I see unanswered messages

Hard to tell what is going on without telling us the data. Works with 
the examples, so may be related to one of the objects scicomp5.model1, 
pred, T, or auc.



 PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html

 and provide commented, minimal, self-contained, reproducible code.


Best wishes,
Uwe Ligges




Chris Anderson wrote:
I am trying to create the roc plot bootstrap method from library(verification), and when I set the plot =both or emp then I get the following error. The roc.plot works fine when the plot is set to binorm. This is my first time using this function in R and am not sure what this error means or how to resolve the issue. It seems to work ok with the example dataset. Is there an option or data formatting I need to due to resolve this error? 
 
roc.plot((scicomp5.model1[164]==High Price), pred, CI = T, n.boot = 100, plot = 'both',binormal = TRUE,

+  main = paste('AREA UNDER CURVE (AUC) =', round(auc$A, 2)))
Error in text.default(DAT[id, 3, i], DAT[id, 2, i], plot.thres[id2], pos = 4,  : 
  zero length 'labels'




Chris Anderson

http://www.seocodebreaker.com/?thankyou-page=429

Instant Debt Consolidation Quote
Free debt consolidation quote online! No obligation. No credit check.
http://thirdpartyoffers.netzero.net/TGL2241/c?cp=cyoog8NQa4mNZIgs6R2NrwAAJ1HbVVWM9bC-t-Va2hgXndJzAAQFAEWLnT8AAAMlABI2kQA=
[[alternative HTML version deleted]]

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


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


[R] sum(row1==y) if row2=x

2009-11-13 Thread Knut Krueger

Hi to all
is there any construct to sum
data=data.frame(row1=c(1,1,3,1,2,3,2,2,1,3,4,5,2,3,2,1) ,
 row2=c(2,2,1,1,1,2,1,2,1,1,1,1,2,2,2,1) )
Means I would like to get all y of row1 if in row2 of the data.frame is 
an x

f.e row1=3 and row2=2
so I would like to get 6

And is there another construct to get the count of pairs where
row1=3 and row2=2
means the result should be 2
I could do this with loop but I am wondering whether there is any better 
way.


Regards Knut

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


Re: [R] 'R CMD check' fails with evaluation nested too deeply: infinite recursion

2009-11-13 Thread Uwe Ligges

[Going through some old and from what I see unanswered messages

No, you cannot have a cycle in Imports / Depends / LinkingTo
otherwise you will run into an the chicken or the egg problem:
That declaration means that the other packages must be loadable on 
installation, for example.


You can try to declare Depends in one and to use Suggests in the one 
with less strong dependencies. If the dependency is too strong: Why not 
merge these essential parts of the functionality that depend on each 
other into one package?


Best wishes,
Uwe Ligges




Joerg van den Hoff wrote:

I get the error

Error : evaluation nested too deeply: infinite recursion / 
options(expressions=)?

during a 'R CMD check ...'

on one of my packages. The reason seems to be that this package is
mutually dependent on another one (i.e. the DESCRIPTION files of package
A lists package B under Depends and vice versa). this might be bad
design (having bits in both packages needed by the other), but I believe
prior to R 2.9. this did not cause trouble. now the log file of the
'check' is something like



Installing *source* package 'roiutils' ...
** R
** exec
** preparing package for lazy loading
Loading required package: roiutils
Loading required package: fzrutils
===CUT (many more of the same) 
Loading required package: roiutils
Loading required package: fzrutils
Loading required package: roiutils
Error : evaluation nested too deeply: infinite recursion / 
options(expressions=)?




i.e. it seems that R loads both packages again and again.

what am I missing/doing wrong?

thanks in advance

joerg

PS:

platform   powerpc-apple-darwin8.11.1  
arch   powerpc 
os darwin8.11.1
system powerpc, darwin8.11.1   
status 
major  2   
minor  9.2 
year   2009
month  08  
day24  
svn rev49384   
language   R   
version.string R version 2.9.2 (2009-08-24)


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


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

2009-11-13 Thread William Dunlap
 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of Hadley Wickham
 Sent: Friday, November 13, 2009 5:34 AM
 To: r-help
 Subject: [R] Escaping regular expressions
 
 Hi all,
 
 Is there a method for escaping strings to be used regular expressions?
  i.e. if I have a user supplied string that I'd like to use as a fixed
 component is there a method that will turn (e.g.) .$^ into
 \\.\\$\\^ ?

I've used the following:
   asFixedRegex - function(pattern) {
  gsub(([][^${}().?*+\\]), \\1, pattern)
   }
E.g.,
asFixedRegex(.$^)
   [1] \\.\\$\\^
or
x - c(C:\\Program Files\\word, P[[:alnum:]]{2,3},
(x+y)[1*3])
regexpr(paste(collapse=|, asFixedRegex(x)), x)
   [1] 1 1 1
   attr(,match.length)
   [1] 21 17 10
nchar(x) # expect same as match.length
   [1] 21 17 10
Is there a standard function to do this?  If so, I'd
like to know its name.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com  


 
 Thanks,
 
 Hadley
 
 -- 
 http://had.co.nz/
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] sum(row1==y) if row2=x

2009-11-13 Thread Jorge Ivan Velez
Hi Knut,

Try

sum(subset(df, row1 == 3  row2 == 2)[,1])

and

nrow(subset( df, row1 == 3  row2 == 2) )

HTH,
Jorge


On Fri, Nov 13, 2009 at 1:59 PM, Knut Krueger  wrote:

 Hi to all
 is there any construct to sum
 data=data.frame(row1=c(1,1,3,1,2,3,2,2,1,3,4,5,2,3,2,1) ,
 row2=c(2,2,1,1,1,2,1,2,1,1,1,1,2,2,2,1) )
 Means I would like to get all y of row1 if in row2 of the data.frame is an
 x
 f.e row1=3 and row2=2
 so I would like to get 6

 And is there another construct to get the count of pairs where
 row1=3 and row2=2
 means the result should be 2
 I could do this with loop but I am wondering whether there is any better
 way.

 Regards Knut

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] sum(row1==y) if row2=x

2009-11-13 Thread Henrique Dallazuanna
Try this:

sum(data[with(data, row1 == 3  row2 == 2),1])

and

sum(with(data, row1 == 3  row2 == 2))


On Fri, Nov 13, 2009 at 4:59 PM, Knut Krueger r...@krueger-family.de wrote:
 Hi to all
 is there any construct to sum
 data=data.frame(row1=c(1,1,3,1,2,3,2,2,1,3,4,5,2,3,2,1) ,
                         row2=c(2,2,1,1,1,2,1,2,1,1,1,1,2,2,2,1) )
 Means I would like to get all y of row1 if in row2 of the data.frame is an x
 f.e row1=3 and row2=2
 so I would like to get 6

 And is there another construct to get the count of pairs where
 row1=3 and row2=2
 means the result should be 2
 I could do this with loop but I am wondering whether there is any better
 way.

 Regards Knut

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

2009-11-13 Thread Uwe Ligges

[Going through some old and from what I see unanswered messages]

R can or cannot response immediately depending on the underlying C 
sources. If the underlying source code is written carefully enough, 
there are more or less regular checks for events such as this one.
If you are using some contributed package, it may be an issue in this 
package's source code.


Best wishes,
Uwe Ligges




Peng Yu wrote:

Occasionally, I start a command (taking long time to finish) that I
did not really want to start. I type 'ctrl+C' to try to quit the
execution. However, R does not quit the execution of the command
immediately. I'm wondering if R could response to ctrl+C immediately.

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

2009-11-13 Thread Don MacQueen
I am wondering if there is a CRAN package that includes a utility 
function that will rotate file names, in the same sense that 
operating systems sometimes rotate log files. Or maybe there's 
something in base R.


That is, we have a set of file names, say file1, file2, file3, and 
when the function is called, file3 is deleted, file2 is renamed 
file3, file1 is renamed file2, and the name of file1 is returned to 
the user's script, which then writes to file1.


I've done some searching (RSiteSearch) but haven't found anything.

Thanks
-Don
--
--
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA
925-423-1062

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

2009-11-13 Thread Henrique Dallazuanna
You can try something about like this:

foo - function() {
unlink(file3.txt)
file.rename(file2.txt, file3.txt)
file.rename(file1.txt, file2.txt)
sink(file1.txt)
cat(test file1)
sink()
}




On Fri, Nov 13, 2009 at 5:20 PM, Don MacQueen m...@llnl.gov wrote:
 I am wondering if there is a CRAN package that includes a utility function
 that will rotate file names, in the same sense that operating systems
 sometimes rotate log files. Or maybe there's something in base R.

 That is, we have a set of file names, say file1, file2, file3, and when the
 function is called, file3 is deleted, file2 is renamed file3, file1 is
 renamed file2, and the name of file1 is returned to the user's script, which
 then writes to file1.

 I've done some searching (RSiteSearch) but haven't found anything.

 Thanks
 -Don
 --
 --
 Don MacQueen
 Environmental Protection Department
 Lawrence Livermore National Laboratory
 Livermore, CA, USA
 925-423-1062

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

2009-11-13 Thread Peter Ehlers


anna_l wrote:

Ok Jim it worked, thank you! it´s funny because it worked with the first
syntax in some cases...


No, it did not. R doesn't randomly work in different
ways on different days.

 -Peter Ehlers




anna_l wrote:

Hello, I am getting an error with the following code:
if( P2  P1)
+ {
+ P-P2
+ }

else

Erro: unexpected 'else' in else

{

+ P-P1
+ }

I checked the syntax so I don´t understand, I have other if else
statements with the same syntax working. Thanks in advance





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

2009-11-13 Thread milton ruser
Hi Ana, you did again :-)

 require(fortunes)
 fortune(dog)
Firstly, don't call your matrix 'matrix'. Would you call your dog 'dog'?
Anyway, it might clash with the function 'matrix'.
   -- Barry Rowlingson
  R-help (October 2004)
if you call your data data you will crach data() function.

cheers

milton

On Fri, Nov 13, 2009 at 8:30 AM, ANARPCG a.gouvei...@imperial.ac.uk wrote:




 Douglas Bates-2 wrote:
 
  On Thu, Nov 12, 2009 at 10:14 AM, milton ruser milton.ru...@gmail.com
  wrote:
  Hi Ana,
 
  I am not quite sure if it is the problem, but if you call your
 data.frame
  as
  exp,
  you will crash exp() function... try use another name for your
  data.frame.
 
  By the way, I suggest you not use attach().
 
  Try something like model-lme(weight~date*diet, data=yourdataframe)
 
  good luck
 
  and include the random specification in the call to lme, not as a
  separate assignment.
 
  milton
 
  On Thu, Nov 12, 2009 at 5:43 AM, ANARPCG a.gouvei...@imperial.ac.uk
  wrote:
 
 
 
 
 
  Milton's point is dead-on, and I would highly encourage you to give the
  posting guide a look.
 
  That said... you might try na.action = na.omit in your call to...
  actually, we don't know what function you are using (see first point).
  Regardless, sounds like you have missing data and na.action is set to
  na.fail (ie, fail if any missing data).
 
  cheers, Dave
 
 
  milton ruser wrote:
  
   Dear Ana Golveia,
  
   It is completelly impossible someone realise what kind or help you
  need
  or
   what is happening. I suggest you give a look on the posting guide,
  mainly
   that part about a minimum reproducible code with self explaining
   information, etc.
  
   Cheers
  
   milton
  
   On Wed, Nov 11, 2009 at 7:22 AM, ANARPCG a.gouvei...@imperial.ac.uk
 
   wrote:
  
  
   CAN ANYONE PLEASE HELP ME WITH THIS
   i HAVE TO DO A MIXED EFFECT LINEAR MODEL WITH MY DATA DUE TO THE
 FACT
   THAT
   I
   have pseudoreplication!
   Although after reading and trying it for several times can get
 around
  due
   to
   Error in na.fail.default(list(date = c(1L, 2L, 3L, 4L, 5L, 6L, 7L,
  8L,
   :
   missing values in object
   I uploaded my data file
   Thank you so much
   Kind regards
   AG
  
 http://old.nabble.com/file/p26300394/rawoctobercalciumexperiment2.txt
   rawoctobercalciumexperiment2.txt
  
   --
   View this message in context:
   http://old.nabble.com/LINEAR-MIXED-EFFECT-tp26300394p26300394.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.htmlhttp://www.r-project.org/posting-guide.html
 http://www.r-project.org/posting-guide.html
  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.htmlhttp://www.r-project.org/posting-guide.html
 http://www.r-project.org/posting-guide.html
   and provide commented, minimal, self-contained, reproducible code.
  
   sorry I am new on this things
   the point is after trying to run the model all that happens is:
   exp-read.table(file=file.choose(),header=T)
   attach(exp)
   names(exp)
   [1] group date  diet  weightthickness
  length
   [7] width liplength lipwidth
  
 
 exp$diet=factor(exp$diet,levels=c(zeropercent,tenpercent,twentypercent,thirtypercent,fortypercent,cuttleprecent))
   exp=na.omit(exp)
   library(nlme)
   random=~date
   model-lme(weight~date*diet)
   Error in na.fail.default(list(date = c(1L, 2L, 3L, 4L, 5L, 6L, 7L,
 8L,
   :
 missing values in object
  
I have pseudoreplications due to the fact that the measurements of
  the
   replicates have different starting points so I was advised to do lme.
  I
   never used it before and I cant get arround with it! the help I
 wanted
   from you is to help me to understand how to do a runable model!
  
  
  
  http://old.nabble.com/file/p26315302/rawoctobercalciumexperiment2.txt
  rawoctobercalciumexperiment2.txt
  --
  View this message in context:
  http://old.nabble.com/LINEAR-MIXED-EFFECT-tp26300394p26315302.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.htmlhttp://www.r-project.org/posting-guide.html
 http://www.r-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
 [[alternative HTML version deleted]]
 
  

Re: [R] LINEAR MIXED EFFECT

2009-11-13 Thread tlumley

On Fri, 13 Nov 2009, milton ruser wrote:


Hi Ana, you did again :-)


require(fortunes)
fortune(dog)

Firstly, don't call your matrix 'matrix'. Would you call your dog 'dog'?
Anyway, it might clash with the function 'matrix'.
  -- Barry Rowlingson
 R-help (October 2004)
if you call your data data you will crach data() function.



No. It won't.  Except in some fairly unusual circumstances, R can distinguish 
functions from other objects and find the one it needs.

The point is that code will usually be easier to read if you have different 
names for different things.

 -thomas


Thomas Lumley   Assoc. Professor, Biostatistics
tlum...@u.washington.eduUniversity of Washington, Seattle

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

2009-11-13 Thread soeren . vogel

Hello:

# some code to assign with and without which
q - 1:20; q[c(9, 12, 14)] - NA
r - 1:20; r[c(8:9, 12:15)] - NA
s - 1:20; s[c(8:9, 12:15)] - NA
r[q  16] - 0
s[which(q  16)] - 0
r;s # both: 0  0  0  0  0  0  0  0 NA  0  0 NA  0 NA  0 16 17 18 19 20
r - 1:20; r[c(8:9, 12:15)] - NA
s - 1:20; s[c(8:9, 12:15)] - NA
r[is.na(q)] - 30
s[which(is.na(q))] - 30
r;s # both: 1  2  3  4  5  6  7 NA 30 10 11 30 NA 30 NA 16 17 18 19 20

So it appears to me that a[b] - c delivers the same results as  
a[which(b)] - c. Is there any situation where the assignment with/ 
out which indeed makes a difference?


Thanks for help

Regards

Sören

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


Re: [R] naive collinear weighted linear regression

2009-11-13 Thread tlumley

On Wed, 11 Nov 2009, David Winsemius wrote:



On Nov 11, 2009, at 7:45 PM, Mauricio Calvao wrote:




When I try:


fit_mod - lm(y~x,weights=1/error^2)


I get

Warning message:
In lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) :
extra arguments weigths are just disregarded.


(Actually the weights are for adjusting for sampling, and I do not see any 
sampling in your design.)




No, the weights are not for adjusting for sampling.  You will get the wrong 
standard errors if you put sampling weights into the  `weights` argument.

 The warning is saying that he had misspelt 'weights' as 'weigths' (and so the 
code he posted wasn' t the same as the code he ran).


 -thomas

Thomas Lumley   Assoc. Professor, Biostatistics
tlum...@u.washington.eduUniversity of Washington, Seattle

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

2009-11-13 Thread William Dunlap

 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of 
 soeren.vo...@eawag.ch
 Sent: Friday, November 13, 2009 12:24 PM
 To: r-help@r-project.org
 Subject: [R] when use which()
 
 Hello:
 
 # some code to assign with and without which
 q - 1:20; q[c(9, 12, 14)] - NA
 r - 1:20; r[c(8:9, 12:15)] - NA
 s - 1:20; s[c(8:9, 12:15)] - NA
 r[q  16] - 0
 s[which(q  16)] - 0
 r;s # both: 0  0  0  0  0  0  0  0 NA  0  0 NA  0 NA  0 16 17 18 19 20
 r - 1:20; r[c(8:9, 12:15)] - NA
 s - 1:20; s[c(8:9, 12:15)] - NA
 r[is.na(q)] - 30
 s[which(is.na(q))] - 30
 r;s # both: 1  2  3  4  5  6  7 NA 30 10 11 30 NA 30 NA 16 17 18 19 20
 
 So it appears to me that a[b] - c delivers the same results as  
 a[which(b)] - c. Is there any situation where the assignment with/ 
 out which indeed makes a difference?


When using [ there should be no difference between
using x[condition] and x[which(condition)].  which() is
just a waste of typing, cpu time, and memory there.
If you want all x that don't satisfy the condition
x[!condition] works but x[-which(condition)]
silently gives the wrong answer when all(condition==FALSE).

There is one weird case, in [[, not [, where there is a
difference, and this might be considered a bug:
list(a=10,b=20,c=30)[[c(FALSE,TRUE,FALSE)]]
   Error in list(a = 10, b = 20, c = 30)[[c(FALSE, TRUE, FALSE)]] :
 attempt to select less than one element
list(a=10,b=20,c=30)[[which(c(FALSE,TRUE,FALSE))]]
   [1] 20
[[ is treating the vector of logicals as a vector of integers
and it can only work if all of them are TRUE and the list has
at least 3 levels of recursion
list(list(list(10,20),list(30,40)))[[c(TRUE,TRUE,TRUE)]]
   [1] 10

Of course, someone can write a package that defines a method for
[ that doesn't work this way, but that would be unfriendly.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 

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

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


  1   2   >