[R] a first opinion on rattle

2009-01-09 Thread Gabriel Ibarra
Graham
 
I have installed rattle and is pretty intuitive and friendly. However, I miss 
some features of the original packages which cannot be invoked from rattle. For 
example, 'randomForest' package is used but random forests cannot be used in 
one of  -in my opinion- most powerful aspects like regression. The same about 
SVM . I would also say include RVM which the scientific literature suggest is 
mugh powerful than SVM.
 
Anyway, I must congratulate you and your team for providing the scientific 
community with rattle.
 
Best regards and thanks
 
 
Dr. Gabriel Ibarra-Berastegi. 
University of the Basque Country
Spain


  
[[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-pkgs] STAR_0.2-2 on CRAN

2009-01-09 Thread Christophe Pouzat
Hi all,

The new version of STAR (0.2-2) is now available on CRAN.

* An error in function varianceTime has been corrected (thanks to Chong Gu).

* The vignette has been updated.

* A new vignette is available on STAR web sire:
http://sites.google.com/site/spiketrainanalysiswithr/

* The new goodness-of-fit test for spike train models announced in the
previous release in now fully functional thanks to feed-back from Vilmos
Prokaj. The test requires the computation of the parameters of a tight
confidence region within which a standard Wiener process stays in, say,
95% of its realizations. The tightest region was shown by Kendall et al
(2007, Statistics and Computing, 17, 1) to have boundaries well approximated
by: a + b*sqrt(t) (where a and b have to be adjusted to get the correct
coverage probability). These 2 parameters are found using the method of
Loader and Deely (J Statist Comput Simulation, 27, 95). The latter method is
also implemented for arbitrary boundaries. The tight case uses C code while
the general case uses pure R code (which is reasonably fast). Error bounds
are also computed.

* Utility functions have been added to estimate the conditional intensity
(CI) of spike trains with smoothing spline (then the hard work is done by
the gss package).

* Detailed demos on how to estimate the CI are now added to the STAR web
site: http://sites.google.com/site/spiketrainanalysiswithr/

A happy new yeaR to all of you,

Christophe
-- 
A Master Carpenter has many tools and is expert with most of them. If you
only know how to use a hammer, every problem starts to look like a nail.
Stay away from that trap.
Richard B Johnson.
--

Christophe Pouzat
Laboratoire de Physiologie Cerebrale
CNRS UMR 8118
UFR biomedicale de l'Universite Paris-Descartes
45, rue des Saints Peres
75006 PARIS
France

tel: +33 (0)1 42 86 38 28
fax: +33 (0)1 42 86 38 30
mobile: +33 (0)6 62 94 10 34
web: http://www.biomedicale.univ-paris5.fr/physcerv/C_Pouzat.html
sip:christophe.pou...@ekiga.net sip%3achristophe.pou...@ekiga.net

[[alternative HTML version deleted]]

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

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


[R] [Fwd: Excluding data with apply]

2009-01-09 Thread Christian Kamenik

Dear all,

I've got many responses to my initial question, which is stated below. 
However, from those responses it has become clear that I need to 
rephrase my problem. All responses dealt with subscripting the data 
matrix before 'apply' is run on it. But this is not want I wanted to do.
'apply' cycles through rows or columns of a matrix, and runs a function 
on each row or column individually. Now, instead of focusing on each 
individual row or column, I want to get rid of these rows or columns, 
and run the function on the remaining matrix.

I could do this with a for loop, such as:

x-matrix(rnorm(100),20,5)
for (i in 1:ncol(x)) print(mean(x[,-i]))

But for more complex problems this becomes tedious...

Any ideas would be highly appreciated, Christian



Dear all,

'Apply' is a great thing for running functions on rows or columns of a 
matrix:


X - rnorm(20, mean = 0, sd = 1)
dim(X) - c(5,4)
apply(X,2,sum)

Is there a way to use apply for excluding rows or columns from a matrix 
to run functions on the remaining rows or columns? I know, I could do 
this with a 'for' loop, but 'apply' would be much easier and quicker, 
and require less programming...


Cheers, Christian
  



--
---
Oeschger Centre for Climate Change Research, Institute of Geography  Institute 
of Plant Sciences
University of Bern

http://www.stomatocysts.unibe.ch/kamenik
mailto: christian.kame...@giub.unibe.ch

Postal address:
Dr. Christian Kamenik
Institute of Geography
Erlachstrasse 9a, Trakt 3
3012 Bern, Switzerland

Tel. +41 (0)31 631 5091
Fax +41 (0)31 631 43 38

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

2009-01-09 Thread Andreas Klein
Hello.

How can I compute the Bootstrap p-value for a two-sided test problem like H_0: 
beta=0 vs. H_1: beta!=0 ?

Example for the sample mean:

x - rnorm(100)

bootsample - numeric(1000)

for(i in 1:1000) {

  idx - sample(1:100,100,replace=TRUE)

  bootsample[i] - mean(x[idx])

}


How can I compute the Bootstrap p-value for the mean of x?

H_0: mean of x = 0 vs. H_1: mean of x != 0



Thank you in advance.


Sincerely,
Andreas Klein.




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


Re: [R] [Fwd: Excluding data with apply]

2009-01-09 Thread Dimitris Rizopoulos

you can use something like the following:

# your matrix
mat - matrix(rnorm(20), 5, 4)

# an indicator matrix specifying which columns
# you want to exclude each time
ind - matrix(sample(1:3, 18, TRUE), ncol = 3)

apply(ind, 1, function (i) mean(mat[, -i]))

where you may change mean() with whatever function or calculation you're 
interested in.



I hope it helps.

Best,
Dimitris


Christian Kamenik wrote:

Dear all,

I've got many responses to my initial question, which is stated below. 
However, from those responses it has become clear that I need to 
rephrase my problem. All responses dealt with subscripting the data 
matrix before 'apply' is run on it. But this is not want I wanted to do.
'apply' cycles through rows or columns of a matrix, and runs a function 
on each row or column individually. Now, instead of focusing on each 
individual row or column, I want to get rid of these rows or columns, 
and run the function on the remaining matrix.

I could do this with a for loop, such as:

x-matrix(rnorm(100),20,5)
for (i in 1:ncol(x)) print(mean(x[,-i]))

But for more complex problems this becomes tedious...

Any ideas would be highly appreciated, Christian



Dear all,

'Apply' is a great thing for running functions on rows or columns of a 
matrix:


X - rnorm(20, mean = 0, sd = 1)
dim(X) - c(5,4)
apply(X,2,sum)

Is there a way to use apply for excluding rows or columns from a 
matrix to run functions on the remaining rows or columns? I know, I 
could do this with a 'for' loop, but 'apply' would be much easier and 
quicker, and require less programming...


Cheers, Christian
  





--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus 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.


[R] [R-pkgs] ConvCalendars

2009-01-09 Thread Thomas Lumley


A new package ConvCalendars is on CRAN, in response to requests earlier this 
week.

It performs conversions between the Gregorian calendar and other calendars 
including the Persian (Jalali) calendar used in Iran and Afghanistan and the 
Hebrew calendar used in Israel.

All the heavy lifting is done by C code from http://www.projectpluto.com.

-thomas

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

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

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


Re: [R] ftp connections for uploading files

2009-01-09 Thread Thomas Loridan
Thanks a lot Duncan

Sorry to insist with my questions but I am very lost with these Rcurl
commands...
could you point out the few ones I need to set up an ftp connection
and just upload a file ?

Greatly appreciated

Thomas

2009/1/8 Duncan Temple Lang dun...@wald.ucdavis.edu:


 Prof Brian Ripley wrote:

 Try system() with curl or a decent ftp client (I don't see that package
 RCurl covers this, but it might despite its description only mentioning
 HTTP).

 It does support FTP, and all of the protocols that are supported in
 the installed libcurl, so it depends the configuration options for libcurl
 itself.

 The protocols it handles can be found via the curlVersion() function, e.g.

 curlVersion()
 $age
 [1] 3

 $version
 [1] 7.16.3

 $vesion_num
 [1] 462851

 $host
 [1] powerpc-apple-darwin9.0

 $features
ipv6  ssl libz ntlm gssnegotiate largefile
   148   16   32   512

 $ssl_version
 [1]  OpenSSL/0.9.7l

 $ssl_version_num
 [1] 0

 $libz_version
 [1] 1.2.3

 $protocols
 [1] tftp   ftptelnet dict   ldap   http   file   https
 [9] ftps

 $ares
 [1] 

 $ares_num
 [1] 0

 $libidn
 [1] 



 sessionInfo()
 R version 2.9.0 Under development (unstable) (2008-09-27 r46576)
 i386-apple-darwin9.5.0

 locale:
 C

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

 other attached packages:
 [1] ROOXML_0.1-0Rcompression_0.4-0  RGoogleDocs_0.2-0
 [4] SVGAnnotation_0.1-0 lattice_0.17-15 RCurl_0.92-0
 [7] XML_1.99-0  RTools_0.1-0bitops_1.0-4

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





  From 'man curl'

   curl offers a busload of useful tricks like proxy support, user authen-
   tication,  ftp upload, HTTP post, SSL connections, cookies, file trans-
   fer resume and more. As you will see below, the amount of features will
   make your head spin!

 Ftp protocols (and there are more than one) are fiendishly complicated,
 especially if proxies are involved.

 BTW, this is yet another case where knowing your OS would have helped give
 a more precise answer. See the posting guide.

 On Thu, 8 Jan 2009, Thomas Loridan wrote:

 Hi all,

 I would like to upload some plots I create wth R via ftp or something
 similar but I don t really understand which command/syntax I should
 use:
 should I go for  make.socket + write.socket or try and create
 environment variables like frp_proxy_user and then ftp my files? how?

 many thanks for your help

 Thomas

 --
 Thomas Loridan
 King's College email: thomas.lori...@kcl.ac.uk
 webpage:http://geography.kcl.ac.uk/micromet/tloridan/index.htm

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






-- 
Thomas Loridan
King's College email: thomas.lori...@kcl.ac.uk
webpage:http://geography.kcl.ac.uk/micromet/tloridan/index.htm

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


Re: [R] Programming Question (setting ylim generally)

2009-01-09 Thread Gavin Simpson
On Fri, 2009-01-09 at 00:22 -0500, stephen sefick wrote:
 library(StreamMetabolism)
snip /
 plot.e - function(b, w, x, y, z){
 a - window.chron(b, w, x, y, z)
 low - min(b*0.98)+5
 high - max(b*1.02)+5
 plot(a, ylim=c(low, high))
 lines(a*0.98, col=blue)
 lines(a*1.02, col=red)
 }
 
 plot.e(day, 03/28/2007, 00:00:00, 03/28/2007, 23:46:00)
 
 why do the low and high objects not set the ylim of the plotting function?

Err, they do. You are plotting 'a' which has (whilst debugging your
plot.e() )

Browse[1] range(a)
[1]  9.93 11.15

You set the ylims to be (computed from 'b', why if plotting 'a'? and why
is 'low' +5, should it be -5?):

Browse[1] low
[1] 14.7314
Browse[1] high
[1] 16.373

And the plot I get has pretty labels/ticks that lie between 14.7 and
16.3, but as the plotted data lie outside the range of the y-axis you
don't see anything.

The figure is actually drawn with a bit of extra (4%) fudge on the x and
y limits as that is how all R plot work by default due to parameters
'xaxs' and 'yaxs'. If you want them to be exactly 'low' and 'high' then
setting yaxs=i might help. See ?par

I suspect your plot.e needs to be something like this:

`plot.e` - function(b, w, x, y, z){
a - window.chron(b, w, x, y, z)
low - min(a*0.98)-5
high - max(a*1.02)+5
plot(a, ylim=c(low, high))
lines(a*0.98, col=blue)
lines(a*1.02, col=red)
}

So you are computing your ylims on a and you make low = foo - 5 not + 5.
At least then the lines you are drawing are displayed on the figure
region - the +/-5 in low and high seem a bit extreme, but that was what
you had so...

HTH

G
 
 thanks
 
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,  [f] +44 (0)20 7679 0565
 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%



signature.asc
Description: This is a digitally signed message part
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Letter-based representation of pairwise comparisons

2009-01-09 Thread I M G
Thank you! It's what I want :)

But I can't make it work. I'm working with R version 2.7.1 under Debian
GNU/Linux. Let me paste my results:

 pairwise.wilcox.test(SAND,Organ,p.adj=bonf) - a

Pairwise comparisons using Wilcoxon rank sum test

data:  SAND and Organ

FlowerA FlowerB FlowerC FlowerD LeafA
FlowerB 0.00062 -   -   -   -
FlowerC 0.00062 0.00432 -   -   -
FlowerD 0.00062 0.00062 0.00062 -   -
LeafA   0.00614 0.00614 0.00614 0.00614 -
LeafC   0.00062 0.00062 0.00062 0.00062 0.32425

P value adjustment method: bonferroni
Warning messages:
1: In wilcox.test.default(xi, xj, ...) :
  cannot compute exact p-value with ties
2: In wilcox.test.default(xi, xj, ...) :
  cannot compute exact p-value with ties
3: In wilcox.test.default(xi, xj, ...) :
  cannot compute exact p-value with ties
4: In wilcox.test.default(xi, xj, ...) :
  cannot compute exact p-value with ties
5: In wilcox.test.default(xi, xj, ...) :
  cannot compute exact p-value with ties

 multcompLetters(a,Letters=c(letters,LETTERS,.))
Error in do.call(compare, list(x, threshold)) :
(list) object cannot be coerced to 'double'

I though it was because the bad format of the argument a (I think the most
similar input may be A square, symmetric matrix with row names), so I
tried with one valid input produced by a Tukey test (valid as input but not
as an analysis of my data because its non-normality) with the aim of
checking if this was the problem.

 TukeyHSD(aov(SAND~Organ)) - b
  Tukey multiple comparisons of means
95% family-wise confidence level

Fit: aov(formula = SAND ~ Organ)

$Organ
  diff  lwr upr p adj
FlowerB-FlowerA -10.39 -12.12877102  -8.6556734 0.000
FlowerC-FlowerA -14.69 -16.42877102 -12.9556734 0.000
FlowerD-FlowerA  -5.28  -7.01654880  -3.5434512 0.000
LeafA-FlowerA-3.478889  -5.21543769  -1.7423401 0.044
LeafC-FlowerA-2.508889  -4.24543769  -0.7723401 0.0011579
FlowerC-FlowerB  -4.30  -6.03654880  -2.5634512 0.000
FlowerD-FlowerB   5.11   3.37567342   6.8487710 0.000
LeafA-FlowerB 6.91   5.17678453   8.6498821 0.000
LeafC-FlowerB 7.88   6.14678453   9.6198821 0.000
FlowerD-FlowerC   9.41   7.67567342  11.1487710 0.000
LeafA-FlowerC11.21   9.47678453  12.9498821 0.000
LeafC-FlowerC12.18  10.44678453  13.9198821 0.000
LeafA-FlowerD 1.80   0.06456231   3.5376599 0.0379548
LeafC-FlowerD 2.77   1.03456231   4.5076599 0.0002720
LeafC-LeafA   0.97  -0.76654880   2.7065488 0.5655196

 multcompLetters(b,Letters=c(letters,LETTERS,.))
Error in do.call(compare, list(x, threshold)) :
(list) object cannot be coerced to 'double'
Además: Warning message:
In if (class(x) == dist) x - as.matrix(x) :
  la condición tiene longitud  1 y sólo el primer elemento será usado (I'm
sorry for the spanish warning, it means that the condition has length1 so
only the first element will be used)

Any idea of what was the mistake I did?

Thank you again!

[[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] Extracting File Basename without Extension

2009-01-09 Thread Berwin A Turlach
G'day all,

On Fri, 9 Jan 2009 08:12:18 -0200
Henrique Dallazuanna www...@gmail.com wrote:

 Try this also:
 
 substr(basename(myfile), 1, nchar(basename(myfile)) - 4)

Or, in case that the extension has more than three letters or myfile
is a vector of names:

R myfile - path1/path2/myoutput.txt
R sapply(strsplit(basename(myfile),\\.), function(x) 
paste(x[1:(length(x)-1)], collapse=.))
[1] myoutput
R myfile2 - c(myfile, path2/path3/myoutput.temp)
R sapply(strsplit(basename(myfile2),\\.), function(x) 
paste(x[1:(length(x)-1)], collapse=.))
[1] myoutput myoutput
R myfile3 - c(myfile2, path4/path5/my.out.put.xls)
R sapply(strsplit(basename(myfile3),\\.), function(x) 
paste(x[1:(length(x)-1)], collapse=.))
[1] myoutput   myoutput   my.out.put

HTH.

Cheers,

Berwin

 On Fri, Jan 9, 2009 at 12:10 AM, Gundala Viswanath
 gunda...@gmail.comwrote:
 
  Dear all,
 
  The basename() function returns the extension also:
 
   myfile - path1/path2/myoutput.txt
   basename(myfile)
  [1] myoutput.txt
 
 
  Is there any other function where it just returns
  plain base:
 
  myoutput
 
  i.e. without 'txt'
 
  - Gundala Viswanath
  Jakarta - Indonesia

=== Full address =
Berwin A TurlachTel.: +65 6516 4416 (secr)
Dept of Statistics and Applied Probability+65 6516 6650 (self)
Faculty of Science  FAX : +65 6872 3919   
National University of Singapore 
6 Science Drive 2, Blk S16, Level 7  e-mail: sta...@nus.edu.sg
Singapore 117546http://www.stat.nus.edu.sg/~statba

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


Re: [R] a first opinion on rattle

2009-01-09 Thread Graham Williams
Received Fri 09 Jan 2009  7:49pm +1100 from Gabriel Ibarra:
[...]

 I have installed rattle and is pretty intuitive and
 friendly. However, I miss some features of the original packages
 which cannot be invoked from rattle. For example, 'randomForest'
 package is??used but random??forests cannot be used in one of ??-in
 my opinion- most powerful aspects like regression. The same about
 SVM??. I would also say include RVM which the scientific literature
 suggest is mugh powerful than SVM.

 Anyway,??I must congratulate you and your team for providing the
 scientific community with rattle.

Thanks for the most kind feedback Gabriel. It is appreciated.

I am always open to suggestions. I should turn the randomForest
regression option on. Thanks for suggesting that. 

RVM from kernlab is in the todo list now. Do you have some simple
examples using rvm for regression? I should have a look to get that
into Rattle. Help (i.e., code or just code examples) is always welcome
:-)

Thanks,
Graham

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


Re: [R] shake rattle() and roll

2009-01-09 Thread Graham Williams
Received Fri 09 Jan 2009  5:08pm +1100 from Dr Eberhard W Lisse:
 Graham,

[...]

 Three Requests for Features for rattle(): would it not be nice to also  
 have direct
 PostgreSQL (RdbiPgSQL) and MySQL (RMySQL) support and support for a  
 SELECT statement?
 In other words, sometimes the database tables directly don't give you  
 what you need
 and so you have to develop a (convoluted) SQL statement first.

 Would be nice if one could ratlle(convolutedSQL) :-)-O

Hi Eberhard,

Thanks for the feedback. I'm not a big user of ODBC and so much of
that discussion (particularly re Mac) is beyond me.

I've added the suggestion of directly supporting RdbiPgSQL and RMySQL
to the Rattle todo list. Examples (i.e., R code) of loading data using
these would be very helpful.  So, basically, what is the sequence of R
commands to get the data from either sources into a data frame in R
(yes I could look it up but it would help, time-wise, to be spoon
fed).

The idea of adding the ability to have a SQl SELECT statement written
in the GUI to extract just the data we want is good, and is on my todo
list.

Regards,
Graham

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


Re: [R] Extracting File Basename without Extension

2009-01-09 Thread Wacek Kusnierczyk
Berwin A Turlach wrote:
 G'day all,

 On Fri, 9 Jan 2009 08:12:18 -0200
 Henrique Dallazuanna www...@gmail.com wrote:

   
 Try this also:

 substr(basename(myfile), 1, nchar(basename(myfile)) - 4)
 

 Or, in case that the extension has more than three letters or myfile
 is a vector of names:

 R myfile - path1/path2/myoutput.txt
 R sapply(strsplit(basename(myfile),\\.), function(x) 
 paste(x[1:(length(x)-1)], collapse=.))
 [1] myoutput
 R myfile2 - c(myfile, path2/path3/myoutput.temp)
 R sapply(strsplit(basename(myfile2),\\.), function(x) 
 paste(x[1:(length(x)-1)], collapse=.))
 [1] myoutput myoutput
 R myfile3 - c(myfile2, path4/path5/my.out.put.xls)
 R sapply(strsplit(basename(myfile3),\\.), function(x) 
 paste(x[1:(length(x)-1)], collapse=.))
 [1] myoutput   myoutput   my.out.put

   

or have sub do the job for you:

filenames.ext = c(foo.bar, basename(foo/bar/hello.dolly))
(filenames.noext = sub([.][^.]*$, , filenames.ext, perl=TRUE))



vQ

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


[R] Saving plots as byte streams

2009-01-09 Thread Richard . Cotton
Is it possible to save plots as byte streams?  For example, if I want the 
bytes for a PNG plot, I could use

#Write the plot to a PNG file
png(test.png)
plot(1:10)
dev.off()

#Read the bytes back in from the file
plotbytes - readBin(test.png, raw, n=2000)

Ideally, I'd like to avoid having to bother writing to the file in the 
first place, and simply store the bytes in a variable.  How do I do this?

Regards,
Richie.

Mathematical Sciences Unit
HSL



ATTENTION:

This message contains privileged and confidential inform...{{dropped:20}}

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


Re: [R] Extracting File Basename without Extension

2009-01-09 Thread Gabor Grothendieck
On Fri, Jan 9, 2009 at 6:52 AM, Wacek Kusnierczyk
waclaw.marcin.kusnierc...@idi.ntnu.no wrote:
 Berwin A Turlach wrote:
 G'day all,

 On Fri, 9 Jan 2009 08:12:18 -0200
 Henrique Dallazuanna www...@gmail.com wrote:


 Try this also:

 substr(basename(myfile), 1, nchar(basename(myfile)) - 4)


 Or, in case that the extension has more than three letters or myfile
 is a vector of names:

 R myfile - path1/path2/myoutput.txt
 R sapply(strsplit(basename(myfile),\\.), function(x) 
 paste(x[1:(length(x)-1)], collapse=.))
 [1] myoutput
 R myfile2 - c(myfile, path2/path3/myoutput.temp)
 R sapply(strsplit(basename(myfile2),\\.), function(x) 
 paste(x[1:(length(x)-1)], collapse=.))
 [1] myoutput myoutput
 R myfile3 - c(myfile2, path4/path5/my.out.put.xls)
 R sapply(strsplit(basename(myfile3),\\.), function(x) 
 paste(x[1:(length(x)-1)], collapse=.))
 [1] myoutput   myoutput   my.out.put



 or have sub do the job for you:

 filenames.ext = c(foo.bar, basename(foo/bar/hello.dolly))
 (filenames.noext = sub([.][^.]*$, , filenames.ext, perl=TRUE))

We can omit perl = TRUE here.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Moving Legend Location for a Stacked Histogram

2009-01-09 Thread Jason Rupert
Thank you again for your response. 
 
This worked great. 
 
Quick question about the legend for qplot.  Instead of being outside the plot, 
is it possible to move the location of the legend to the upper left or right 
corner of the plot?  Could you possibly provide an example.
 
Thank you again for your feedback and insights. 


--- On Wed, 1/7/09, hadley wickham h.wick...@gmail.com wrote:

From: hadley wickham h.wick...@gmail.com
Subject: Re: Fw: Re: [R] R Stacked Histogram
To: jasonkrup...@yahoo.com, R-help R-help@r-project.org
Date: Wednesday, January 7, 2009, 12:17 PM

Hi Jason,

 Well, one last questions about stack plot (please forgive the lame example
 below).  I thought the below allow me to resize the the title
of the
 stacked histogram, but no luck.  Any suggestions as to the modificaiton
 necessary to get it to work?  Right now the title is obscured by the plot
 and my boss will be none too happy.  Thanks again.

Yes, that's a really stupid bug that I accidentally introduced in the
latest version.  You can fix it with:

qplot(mpg, wt, data = mtcars, main = My title) + opts(plot.title =
theme_text(vjust = 0, size = 16))

or by adding a new line to the end of the title:

qplot(mpg, wt, data = mtcars, main = My title\n)

Regards,

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





  


  
[[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] Extracting File Basename without Extension

2009-01-09 Thread Wacek Kusnierczyk
Gabor Grothendieck wrote:
 On Fri, Jan 9, 2009 at 6:52 AM, Wacek Kusnierczyk

   
 or have sub do the job for you:

 filenames.ext = c(foo.bar, basename(foo/bar/hello.dolly))
 (filenames.noext = sub([.][^.]*$, , filenames.ext, perl=TRUE))
 

 We can omit perl = TRUE here.

   


or maybe not, depending on the actual task:

names = replicate(1, paste(sample(c(letters, .), 100,
replace=TRUE), collapse=))
system.time(replicate(10, sub([.][^.]*$, , names, perl=TRUE)))
system.time(replicate(10, sub([.][^.]*$, , names)))

vQ

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


Re: [R] Saving plots as byte streams

2009-01-09 Thread Prof Brian Ripley

On Fri, 9 Jan 2009, richard.cot...@hsl.gov.uk wrote:


Is it possible to save plots as byte streams?


You mean bitmap plots?  E.g. PDF plots are not even written 
sequentially.



For example, if I want the
bytes for a PNG plot, I could use

#Write the plot to a PNG file
png(test.png)
plot(1:10)
dev.off()

#Read the bytes back in from the file
plotbytes - readBin(test.png, raw, n=2000)

Ideally, I'd like to avoid having to bother writing to the file in the
first place, and simply store the bytes in a variable.  How do I do this?


The bitmap library interfaces which we use write to files, so there is 
no way to do this short of rewriting all the bitmap code.  If there 
had been, they would be writing to connections already.



Regards,
Richie.

Mathematical Sciences Unit
HSL


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


Re: [R] ATT Researchers and the New York Times

2009-01-09 Thread Roland Studer
I agree, that there are better plattforms.
I'd love to see something like Stack Overflow:
http://stackoverflow.com/

When you type your question, it compares it to previously answered
questions. Answers can get voted up and down. Answers AND questions can be
edited!

Regards
  Roland Studer

On Fri, Jan 9, 2009 at 6:58 AM, Dr Eberhard W Lisse e...@lisse.na wrote:

 Robert,

 go ahead, fix whatever bothers you, this is Open Sauce, not Jet-Engine
 Science
 :-)-O

 el

 On 09 Jan 2009, at 07:41 , Johannes Huesing wrote:

  stephen sefick ssef...@gmail.com [Fri, Jan 09, 2009 at 03:16:11AM CET]:

 It has worked wonders for me over the last years.


  On Thu, Jan 8, 2009 at 8:58 PM, Robert Wilkins irishhac...@gmail.com
 wrote:

 And by the way, ARE YOU GUYS EVER GOING TO FIX your mailing list
 platform? It is extremely user-unfriendly and a technological clunk.


 He possibly means the Web interface to the archive, which I am not
 bothered
 about since the list is mirrored on Gmane.

 --
 Johannes Hüsing


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



--
http://www.sturmfrei.wordpress.com - Berner Mundartrock
home 031 535 43 40 | mobile 079 746 48 59

[[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] ATT Researchers and the New York Times

2009-01-09 Thread Dr Eberhard W Lisse

No problem, easy peasy, just hack it together and put all the old
archives on so the subscribers can vote.

greetings, el

On 09 Jan 2009, at 14:45 , Roland Studer wrote:


I agree, that there are better plattforms.
I'd love to see something like Stack Overflow:
http://stackoverflow.com/

When you type your question, it compares it to previously answered
questions. Answers can get voted up and down. Answers AND questions  
can be

edited!

Regards
 Roland Studer

On Fri, Jan 9, 2009 at 6:58 AM, Dr Eberhard W Lisse e...@lisse.na  
wrote:



Robert,

go ahead, fix whatever bothers you, this is Open Sauce, not Jet- 
Engine

Science
:-)-O

el

On 09 Jan 2009, at 07:41 , Johannes Huesing wrote:

stephen sefick ssef...@gmail.com [Fri, Jan 09, 2009 at 03:16:11AM  
CET]:



It has worked wonders for me over the last years.



On Thu, Jan 8, 2009 at 8:58 PM, Robert Wilkins irishhac...@gmail.com 


wrote:


And by the way, ARE YOU GUYS EVER GOING TO FIX your mailing list
platform? It is extremely user-unfriendly and a technological  
clunk.





He possibly means the Web interface to the archive, which I am not
bothered
about since the list is mirrored on Gmane.

--
Johannes Hüsing



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




--
http://www.sturmfrei.wordpress.com - Berner Mundartrock
home 031 535 43 40 | mobile 079 746 48 59

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


--
Dr. Eberhard W. Lisse  \/ Obstetrician  Gynaecologist (Saar)
e...@lisse.na el108-ARIN /   *   |   Telephone: +264 81 124 6733 (cell)
PO Box 8421 \ / Please send DNS/NA-NiC related e-mail
Bachbrecht, Namibia ;/ to dns-ad...@na-nic.com.na

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


Re: [R] Extracting File Basename without Extension

2009-01-09 Thread Berwin A Turlach
G'day Wacek,

On Fri, 09 Jan 2009 12:52:46 +0100
Wacek Kusnierczyk waclaw.marcin.kusnierc...@idi.ntnu.no wrote:

 Berwin A Turlach wrote:
  G'day all,
 
  On Fri, 9 Jan 2009 08:12:18 -0200
  Henrique Dallazuanna www...@gmail.com wrote:
 

  Try this also:
 
  substr(basename(myfile), 1, nchar(basename(myfile)) - 4)
  
 
  Or, in case that the extension has more than three letters or
  myfile is a vector of names:
 
  R myfile - path1/path2/myoutput.txt
  R sapply(strsplit(basename(myfile),\\.), function(x)
  R paste(x[1:(length(x)-1)], collapse=.))
  [1] myoutput
  R myfile2 - c(myfile, path2/path3/myoutput.temp)
  R sapply(strsplit(basename(myfile2),\\.), function(x)
  R paste(x[1:(length(x)-1)], collapse=.))
  [1] myoutput myoutput
  R myfile3 - c(myfile2, path4/path5/my.out.put.xls)
  R sapply(strsplit(basename(myfile3),\\.), function(x)
  R paste(x[1:(length(x)-1)], collapse=.))
  [1] myoutput   myoutput   my.out.put
 

 
 or have sub do the job for you:
 
 filenames.ext = c(foo.bar, basename(foo/bar/hello.dolly))
 (filenames.noext = sub([.][^.]*$, , filenames.ext, perl=TRUE))

Apparently also a possibility, I guess it can be made to work with the
original example and my extensions.

Though, it seems to require the knowledge of perl, or at least perl's
regular expression. 

Cheers,

Berwin

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


Re: [R] Extracting File Basename without Extension

2009-01-09 Thread Wacek Kusnierczyk
Berwin A Turlach wrote:
 G'day Wacek,


   
 Or, in case that the extension has more than three letters or
 myfile is a vector of names:

 R myfile - path1/path2/myoutput.txt
 R sapply(strsplit(basename(myfile),\\.), function(x)
 R paste(x[1:(length(x)-1)], collapse=.))
 [1] myoutput
 R myfile2 - c(myfile, path2/path3/myoutput.temp)
 R sapply(strsplit(basename(myfile2),\\.), function(x)
 R paste(x[1:(length(x)-1)], collapse=.))
 [1] myoutput myoutput
 R myfile3 - c(myfile2, path4/path5/my.out.put.xls)
 R sapply(strsplit(basename(myfile3),\\.), function(x)
 R paste(x[1:(length(x)-1)], collapse=.))
 [1] myoutput   myoutput   my.out.put

   
   
 or have sub do the job for you:

 filenames.ext = c(foo.bar, basename(foo/bar/hello.dolly))
 (filenames.noext = sub([.][^.]*$, , filenames.ext, perl=TRUE))
 

   

g'afternoon berwin,

 Apparently also a possibility, I guess it can be made to work with the
 original example and my extensions.
   

i guess it does work with the original example and your extensions.

 Though, it seems to require the knowledge of perl, or at least perl's
 regular expression. 
   

oh my, sorry.  it' so bad to go an inch out of the cosy world of r. 
but, as gabor pointed, 'perl=TRUE' is inessential here, so you actually
need to know just (very basic) regular expressions, with no 'perl'
implied.  having learnt this simple regex syntax you can avoid the need
for looking up strsplit and paste in tfm, so i'd consider it worthwhile.

vQ

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


Re: [R] Extracting File Basename without Extension

2009-01-09 Thread Berwin A Turlach
G'day Wacek,

On Fri, 09 Jan 2009 14:22:19 +0100
Wacek Kusnierczyk waclaw.marcin.kusnierc...@idi.ntnu.no wrote:

  Apparently also a possibility, I guess it can be made to work with
  the original example and my extensions.

 
 i guess it does work with the original example and your extensions.

And I thought that you would have known for sure.

  Though, it seems to require the knowledge of perl, or at least
  perl's regular expression.
 
 oh my, sorry.  it' so bad to go an inch out of the cosy world of r. 

Well, if that's how you feel, don't do it.

I regularly use other languages besides R.  Mostly C and Fortran,
occasionally Python.  But I never found time to learn Perl or Java or
awk or C++ or; some people do not have the time to learn all
languages under the sun. Also, if one concentrates on a few, one can
learn them really well.

 but, as gabor pointed, 'perl=TRUE' is inessential here,

I thought that your answer to Gabor indicated that, depending on the
context, perl=TRUE was essential; though I must admit that I did not
run that code.  

 so you actually need to know just (very basic) regular expressions,
 with no 'perl' implied.  having learnt this simple regex syntax you
 can avoid the need for looking up strsplit and paste in tfm, so i'd
 consider it worthwhile.

As people say, YMMV, I do not need to look up strsplit and/or paste;
but I would have to look up what the regular expression syntax or
finally memorise it; something I did not consider worthwhile so far.

Cheers,

Berwin

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] rpart with interval censored data crashes R

2009-01-09 Thread Keith Jewell
Hi Everyone,

This example code results in R 'crashing'; that is the R application closes 
with no warnings or error messages.
#---
myD - read.table(stdin(), header=TRUE, nrows=20)
Broth Salt   pH TempN  Y Growth
13109.0 2.92  10 90.0 NA0
26156.0 7.82  30  1.0  21
32172.0 7.34  10  7.0  81
4338   10.0 4.44  10 90.0 NA0
52404.0 7.33  10 20.0 211
6336   10.0 3.90  10 90.0 NA0
72797.0 6.73  10 90.0 NA0
8   10219.0 5.03  45  8.0  91
99747.0 4.01  45 90.0 NA0
10   2657.0 2.93  10 90.0 NA0
11   9344.0 5.28  45  0.1  11
12   6699.0 5.03  30 90.0 NA0
13   875   10.0 6.24  37  1.0  21
14   3852.0 5.84  20  1.0  21
15   5622.0 5.84  30  0.1  11
16   7180.5 5.54  37  0.1  11
17   8459.0 5.03  37  3.0  61
18   9132.0 5.84  45  0.1  11
19   5774.0 4.10  30 90.0 NA0
20200.5 7.44   8 24.0 271

library(rpart)
library(survival)
fit-rpart(Surv(N,Y,type=interval2)~Salt+pH+Temp, data=myD)
#-

Professor Ripley helpfully pointed out that the documentation does not say 
that interval censoring is supported, and indeed this seems only to happen 
with interval censored data.

?rpart indicates that the dependent variable may be a survival object. 
Neither ?rpart nor An Introduction to Recursive Partitioning Using the 
RPART Routines (Therneau et al 1997) suggest that the dependent variable 
may contain interval censored data, but neither do they suggest it 
shouldn't; i.e. as far as I'm aware (!) this restriction is not documented.

This post has three purposes:

1) Bring this behaviour - especially the crash in response to 'bad' data - 
to the attention of the authors.

2) Seek an explanation of the restriction (if intentional). In my 
simplicity, it seems that interval censored data should be easier to handle 
than left or right censored - after all the information content is greater.

3) Seek guidance on how to work around the problem. I'm minded to replace 
the interval censored data by the mid points of the intervals. Does anyone 
have any comments on such an approach?

Any comments gratefully received.

Keith Jewell
==
Version:
 platform = i386-pc-mingw32
 arch = i386
 os = mingw32
 system = i386, mingw32
 status = Patched
 major = 2
 minor = 8.1
 year = 2009
 month = 01
 day = 07
 svn rev = 47502
 language = R
 version.string = R version 2.8.1 Patched (2009-01-07 r47502)

Windows Server 2003 x64 (build 3790) Service Pack 2

Locale:
LC_COLLATE=English_United Kingdom.1252;LC_CTYPE=English_United 
Kingdom.1252;LC_MONETARY=English_United 
Kingdom.1252;LC_NUMERIC=C;LC_TIME=English_United Kingdom.1252

Search Path:
 .GlobalEnv, package:stats, package:graphics, package:grDevices, 
package:utils, package:datasets, package:methods, Autoloads, package:base

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

2009-01-09 Thread baptiste auguie

Dear list,

I'm having second thoughts after solving a very trivial problem: I  
want to extend the relevel() function to reorder an arbitrary number  
of levels of a factor in one go. I could not find a trivial way of  
using the code obtained by getS3method(relevel,factor). Instead, I  
thought of solving the problem in a recursive manner (possibly after  
reading Paul Graham essays on Lisp too recently). Here is my attempt :




order.factor - function (x, ref)
{

last.index - length(ref) # convenience for matlab's end keyword
	if(last.index == 1) return(relevel(x, ref)) # end case, normal case  
of relevel
	my.new.list - list(x=relevel(x, ref[last.index]),  # creating a  
list with updated parameters,


# going through the list in reverse order
ref=ref[-last.index]) # 
chop the vector from its last level
return(do.call(order.factor, my.new.list)) # recursive call
}

ff - factor(c(a, b, c, d))
ff
relevel(ff, levels(ff)[1])
relevel(ff, levels(ff)[2]) # that's the usual case: you want to put  
a level first


order.factor(x=ff, ref=c(a, b))
order.factor(x=ff, ref=c(c))
order.factor(x=ff, ref=c(c, d)) # that's my wish: put c and d in  
that order as the first two levels





I'm hoping this can be improved in several aspects:

- there is probably already a better function I missed or overlooked  
(I'd still be curious about the following points, though)


- after reading a few threads, it appears that some recursive  
functions are fragile in some sense, and I'm not sure what this means  
in practice. (Should I use Recall, somehow?)


- it's probably quite slow for large data.frames

- I could not think of a good name, this one might clash with some S3  
method perhaps?


- any other thoughts welcome!


Best wishes,

Baptiste
_

Baptiste Auguié

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag

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


Re: [R] Extracting File Basename without Extension

2009-01-09 Thread Wacek Kusnierczyk
Berwin A Turlach wrote:
 G'day Wacek,

 On Fri, 09 Jan 2009 14:22:19 +0100
 Wacek Kusnierczyk waclaw.marcin.kusnierc...@idi.ntnu.no wrote:

   
 Apparently also a possibility, I guess it can be made to work with
 the original example and my extensions.
   
   
 i guess it does work with the original example and your extensions.
 

 And I thought that you would have known for sure.
   

i thought i did until you made that comment, which made me think you've
just discovered it doesn't.

   
 Though, it seems to require the knowledge of perl, or at least
 perl's regular expression.
   
 oh my, sorry.  it' so bad to go an inch out of the cosy world of r. 
 

 Well, if that's how you feel, don't do it.
   

quite the opposite.

 I regularly use other languages besides R.  Mostly C and Fortran,
 occasionally Python.  But I never found time to learn Perl or Java or
 awk or C++ or; some people do not have the time to learn all
 languages under the sun. Also, if one concentrates on a few, one can
 learn them really well.
   

i think i did not suggest the original poster to learn perl.

many responses on this list involve regular expressions, and regexes are
so ubiquitous in code that has to do with parsing and processing text,
be it filenames or loads of data, that a user of r may well want to
learn a bit of this stuff in addition to the details about how real
numbers are represented below the surface.

you may want to keep saying 'use r where applicable instead of worse
tools', and i'd like to keep saying 'use regexes where they're
applicable instead of worse tools'.  same philosophy.


   
 but, as gabor pointed, 'perl=TRUE' is inessential here,
 

 I thought that your answer to Gabor indicated that, depending on the
 context, perl=TRUE was essential; though I must admit that I did not
 run that code.  
   

i see i may have expressed that wrongly.  it should have been but maybe
you'd want to keep it, meaning this is not essential for the final
result, but may improve the runtime.


   
 so you actually need to know just (very basic) regular expressions,
 with no 'perl' implied.  having learnt this simple regex syntax you
 can avoid the need for looking up strsplit and paste in tfm, so i'd
 consider it worthwhile.
 

 As people say, YMMV, I do not need to look up strsplit and/or paste;
 but I would have to look up what the regular expression syntax or
 finally memorise it; something I did not consider worthwhile so far.
   

well, the regex syntax is fairly standard, though variations exist among
languages.  once you learn it, or rather the ideas behind the syntax,
you're well equipped for quite a range of tasks.  on the other hand, the
details of strsplit and paste are pretty r-specific, and you don't gain
much by remembering them (except for freeing yourself from having to
read tfm again).

i have seen quite a bunch of programs written by scientists who spent
over one hundred lines of code on just parsing command line arguments; 
i wish they knew regexes exist (and better, getopt-like modules too). 
if you're doing serious programming without knowing regexes, you're
rather lucky.

vQ

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


[R] [R} how to build TermDocMatrix in tm text mining package of R

2009-01-09 Thread Kum-Hoe Hwang
Howdy Gurus

I 'd like to ask a question about how to build TermDocMatrix in tm text
mining package.

It is not clear about importing a plain text file, and them converting that
text file into TermDocMatrix file, etc to me.
How can I build a TermDocMatrix of  a plain text document file for text
association?
Or are there any good manuals?

Thank you in advance,

-- 
Kum-Hoe Hwang, Ph.D.

Phone : 82-31-250-3516
Email : phdhw...@gmail.com

[[alternative HTML version deleted]]

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


Re: [R] Extracting File Basename without Extension

2009-01-09 Thread Wacek Kusnierczyk
Prof Brian Ripley wrote:

 Actually, that's a valid regex in any of the variants offered.  A more
 conventional writing of it is the second of

 f - 'foo.bar.R'
 sub([.][^.]*$, , f)
 [1] foo.bar
 sub(\\.[^.]*$, , f)
 [1] foo.bar


more conventional in r, perhaps.  it's not portable, due to the 'escape
the escape to have an escape' feature of r when it comes to regexes; in
perl, for example, /\\.[^.]*$/ would hardly do the job.

vQ

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


Re: [R] Extracting File Basename without Extension

2009-01-09 Thread Berwin A Turlach
G'day Wacek,

On Fri, 09 Jan 2009 15:19:46 +0100
Wacek Kusnierczyk waclaw.marcin.kusnierc...@idi.ntnu.no wrote:

 i think i did not suggest the original poster to learn perl.

As I see it, you didn't suggest anything to the original poster, at
least not directly.  But, since these days you have to be subscribed
to r-help to post IIRC, it is probably reasonable to assume that the
original poster saw your posting.
 
 many responses on this list involve regular expressions, and regexes
 are so ubiquitous in code that has to do with parsing and processing
 text, be it filenames or loads of data, that a user of r may well
 want to learn a bit of this stuff in addition to the details about
 how real numbers are represented below the surface.

You should really get rid of that chip on your shoulder.

 you may want to keep saying 'use r where applicable instead of worse
 tools', 

Now I am getting really confused, isn't your suggested solution not
using R too?  So why would I say something like this?  I suggest you get
rid of the chip on the other shoulder too... :)

 well, the regex syntax is fairly standard, though variations exist
 among languages.  

Exactly, and the existence of these variations which can trip one up
and require to rtfm in anything but the most simplest situations,
that's why regexp are not what jumps first to my mind.

 i have seen quite a bunch of programs written by scientists who spent
 over one hundred lines of code on just parsing command line
 arguments; i wish they knew regexes exist (and better, getopt-like
 modules too). if you're doing serious programming without knowing
 regexes, you're rather lucky.

Probably depends on what one calls serious.

Best wishes,

Berwin

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


Re: [R] recursive relevel

2009-01-09 Thread Dimitris Rizopoulos
I think that you can still use to core of stats:::relevel.factor; the 
only thing that needs to be changed is the controls for bad values of 
the 'ref' argument, i.e.,


relevelNew - function (x, ref, ...) {
lev - levels(x)
if (is.character(ref))
ref - match(ref, lev)
if (any(is.na(ref)))
stop('ref' must be an existing level)
nlev - length(lev)
if (any(ref  1 | ref  nlev))
stop(gettextf(ref = %d must be in 1:%d, ref, nlev), domain = NA)
factor(x, levels = lev[c(ref, seq_along(lev)[-ref])])
}


ff - factor(c(a, b, c, d))
ff
relevelNew(ff, c)
relevelNew(ff, c(c, d))


I hope it helps.

Best,
Dimitris


baptiste auguie wrote:

Dear list,

I'm having second thoughts after solving a very trivial problem: I want 
to extend the relevel() function to reorder an arbitrary number of 
levels of a factor in one go. I could not find a trivial way of using 
the code obtained by getS3method(relevel,factor). Instead, I thought 
of solving the problem in a recursive manner (possibly after reading 
Paul Graham essays on Lisp too recently). Here is my attempt :




order.factor - function (x, ref)
{
   
last.index - length(ref) # convenience for matlab's end keyword
if(last.index == 1) return(relevel(x, ref)) # end case, normal 
case of relevel
my.new.list - list(x=relevel(x, ref[last.index]),  # creating a 
list with updated parameters,
# going 
through the list in reverse order
ref=ref[-last.index]) # chop the vector 
from its last level

return(do.call(order.factor, my.new.list)) # recursive call
}

ff - factor(c(a, b, c, d))
ff
relevel(ff, levels(ff)[1])
relevel(ff, levels(ff)[2]) # that's the usual case: you want to put a 
level first


order.factor(x=ff, ref=c(a, b))
order.factor(x=ff, ref=c(c))
order.factor(x=ff, ref=c(c, d)) # that's my wish: put c and d in 
that order as the first two levels





I'm hoping this can be improved in several aspects:

- there is probably already a better function I missed or overlooked 
(I'd still be curious about the following points, though)


- after reading a few threads, it appears that some recursive functions 
are fragile in some sense, and I'm not sure what this means in practice. 
(Should I use Recall, somehow?)


- it's probably quite slow for large data.frames

- I could not think of a good name, this one might clash with some S3 
method perhaps?


- any other thoughts welcome!


Best wishes,

Baptiste
_

Baptiste Auguié

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag

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

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



--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus 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.


[R] snow and different R versions

2009-01-09 Thread Gábor Csárdi
Dear Luke and others,

I have many R versions on my machine and want to start a particular
one when snow builds its cluster. (The same version I start snow
from.) It seems that everything is set up correctly in
defaultClusterOptions:

 mget(ls(defaultClusterOptions), defaultClusterOptions)
$homogeneous
[1] TRUE

$manual
[1] FALSE

$master
  nodename
maya.unil.ch

$outfile
[1] /dev/null

$port
[1] 10187

$rhome
R_HOME  sessionInfo()
R version 2.8.0 (2008-10-20)
x86_64-redhat-linux-gnu

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

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

other attached packages:
[1] snow_0.3-3

/home/gabor/software/lib64/R

$rlibs
 R_LIBS
/usr/lib64/R/library:/usr/share/R/library

$rprog
[1] /home/gabor/software/lib64/R/bin/R

$rscript
[1] /home/gabor/software/lib64/R/bin/Rscript

$rshcmd
[1] ssh

$scriptdir
[1] /home/gabor/.R/library/snow

$snowlib
[1] /home/gabor/.R/library

$timeout
[1] 31536000

$type
[1] MPI

$user
   user
gabor

$useRscript
[1] TRUE

but snow still starts a different version, the one in /usr/bin/R. Is
this a bug? If not, how can I tell snow to start the same version, the
one that is listed in defaultClusterOptions?

Thanks,
Gabor

 sessionInfo()
R version 2.8.0 (2008-10-20)
x86_64-redhat-linux-gnu

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

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

other attached packages:
[1] snow_0.3-3


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

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


Re: [R] recursive relevel

2009-01-09 Thread baptiste auguie


On 9 Jan 2009, at 15:26, Dimitris Rizopoulos wrote:


I think that you can still use to core of stats:::relevel.factor; the
only thing that needs to be changed is the controls for bad values of
the 'ref' argument, i.e.,

relevelNew - function (x, ref, ...) {
lev - levels(x)
if (is.character(ref))
ref - match(ref, lev)
if (any(is.na(ref)))
stop('ref' must be an existing level)
nlev - length(lev)
if (any(ref  1 | ref  nlev))
stop(gettextf(ref = %d must be in 1:%d, ref, nlev), domain  
= NA)

factor(x, levels = lev[c(ref, seq_along(lev)[-ref])])
}


ff - factor(c(a, b, c, d))
ff
relevelNew(ff, c)
relevelNew(ff, c(c, d))


I hope it helps.

Best,
Dimitris



Very good point! I knew I was missing something obvious, but I was  
wrongly assuming that the changes needed were more drastic. I'm now  
wondering why this wasn't implemented in relevel() in the first place.  
Perhaps such a small modification could be useful, at least in the  
documentation?


Thanks,

baptiste




baptiste auguie wrote:

Dear list,

I'm having second thoughts after solving a very trivial problem: I  
want

to extend the relevel() function to reorder an arbitrary number of
levels of a factor in one go. I could not find a trivial way of using
the code obtained by getS3method(relevel,factor). Instead, I  
thought

of solving the problem in a recursive manner (possibly after reading
Paul Graham essays on Lisp too recently). Here is my attempt :



order.factor - function (x, ref)
   {

   last.index - length(ref) # convenience for matlab's end keyword
   if(last.index == 1) return(relevel(x, ref)) # end case, normal
case of relevel
   my.new.list - list(x=relevel(x, ref[last.index]),  # creating a
list with updated parameters,
   # going
through the list in reverse order
   ref=ref[-last.index]) # chop the vector
from its last level
   return(do.call(order.factor, my.new.list)) # recursive call
}

ff - factor(c(a, b, c, d))
ff
relevel(ff, levels(ff)[1])
relevel(ff, levels(ff)[2]) # that's the usual case: you want to  
put a

level first

order.factor(x=ff, ref=c(a, b))
order.factor(x=ff, ref=c(c))
order.factor(x=ff, ref=c(c, d)) # that's my wish: put c and d in
that order as the first two levels




I'm hoping this can be improved in several aspects:

- there is probably already a better function I missed or overlooked
(I'd still be curious about the following points, though)

- after reading a few threads, it appears that some recursive  
functions
are fragile in some sense, and I'm not sure what this means in  
practice.

(Should I use Recall, somehow?)

- it's probably quite slow for large data.frames

- I could not think of a good name, this one might clash with some S3
method perhaps?

- any other thoughts welcome!


Best wishes,

Baptiste
_

Baptiste Auguié

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag

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



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

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



_

Baptiste Auguié

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag

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


Re: [R] recursive relevel

2009-01-09 Thread ONKELINX, Thierry
Dear Baptiste,

You can avoid the recursive stuff. And it will run about twice as fast.

  order.factor - function (x, ref)
+  {
+  last.index - length(ref) # convenience for matlab's end keyword
+  if(last.index == 1) return(relevel(x, ref)) # end case, normal case  
+  my.new.list - list(x=relevel(x, ref[last.index]), ref=ref[-last.index])
+  return(do.call(order.factor, my.new.list)) # recursive call
+  }
 
 order.factor2 - function(x, ref){
+ factor(x, levels = c(ref, sort(levels(x)[!levels(x) %in% ref])))
+ }
 order.factor3 - function(x, ref){
+ factor(x, levels = c(ref, sort(levels(x)[!levels(x) %in% ref])), labels = 
c(ref, sort(levels(x)[!levels(x) %in% ref])))
+ }
 
 x - factor(sample(LETTERS[1:5], 1000, replace = TRUE))
 y - factor(sample(LETTERS[1:20], 1000, replace = TRUE))
 system.time(order.factor(x, c(D, B)))
   user  system elapsed 
   5.690.386.09 
 system.time(order.factor2(x, c(D, B)))
   user  system elapsed 
   3.900.204.12 
 system.time(order.factor3(x, c(D, B)))
   user  system elapsed 
   3.260.193.46 
 system.time(order.factor(y, c(D, B)))
   user  system elapsed 
  17.430.39   17.84 
 system.time(order.factor3(y, c(D, B)))
   user  system elapsed 
   8.250.178.46 


HTH,

Thierry 



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

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

The plural of anecdote is not data.
~ Roger Brinner

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

-Oorspronkelijk bericht-
Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens 
baptiste auguie
Verzonden: vrijdag 9 januari 2009 15:11
Aan: R R-help
Onderwerp: [R] recursive relevel

Dear list,

I'm having second thoughts after solving a very trivial problem: I  
want to extend the relevel() function to reorder an arbitrary number  
of levels of a factor in one go. I could not find a trivial way of  
using the code obtained by getS3method(relevel,factor). Instead, I  
thought of solving the problem in a recursive manner (possibly after  
reading Paul Graham essays on Lisp too recently). Here is my attempt :


 order.factor - function (x, ref)
   {
   
   last.index - length(ref) # convenience for matlab's end keyword
   if(last.index == 1) return(relevel(x, ref)) # end case, normal case  
 of relevel
   my.new.list - list(x=relevel(x, ref[last.index]),  # creating a  
 list with updated parameters,
   
 # going through the list in reverse order
   ref=ref[-last.index]) # 
 chop the vector from its last level
   return(do.call(order.factor, my.new.list)) # recursive call
 }

 ff - factor(c(a, b, c, d))
 ff
 relevel(ff, levels(ff)[1])
 relevel(ff, levels(ff)[2]) # that's the usual case: you want to put  
 a level first

 order.factor(x=ff, ref=c(a, b))
 order.factor(x=ff, ref=c(c))
 order.factor(x=ff, ref=c(c, d)) # that's my wish: put c and d in  
 that order as the first two levels



I'm hoping this can be improved in several aspects:

- there is probably already a better function I missed or overlooked  
(I'd still be curious about the following points, though)

- after reading a few threads, it appears that some recursive  
functions are fragile in some sense, and I'm not sure what this means  
in practice. (Should I use Recall, somehow?)

- it's probably quite slow for large data.frames

- I could not think of a good name, this one might clash with some S3  
method perhaps?

- any other thoughts welcome!


Best wishes,

Baptiste
_

Baptiste Auguié

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag

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

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex 

Re: [R] Programming Question (setting ylim generally)

2009-01-09 Thread stephen sefick
WOW, I am not going to post after midnight.  Thank you for your
response, and this is what I settled on.

`plot.e` - function(b, w, x, y, z){
a - window.chron(b, w, x, y, z)
low - min(a*0.98)-(min(a)*0.04)
high - max(a*1.02)+(max(a)*0.04)
plot(a, ylim=c(low, high))
lines(a*0.98, col=blue)
lines(a*1.02, col=red)
}

On Fri, Jan 9, 2009 at 5:38 AM, Gavin Simpson gavin.simp...@ucl.ac.uk wrote:
 On Fri, 2009-01-09 at 00:22 -0500, stephen sefick wrote:
 library(StreamMetabolism)
 snip /
 plot.e - function(b, w, x, y, z){
 a - window.chron(b, w, x, y, z)
 low - min(b*0.98)+5
 high - max(b*1.02)+5
 plot(a, ylim=c(low, high))
 lines(a*0.98, col=blue)
 lines(a*1.02, col=red)
 }

 plot.e(day, 03/28/2007, 00:00:00, 03/28/2007, 23:46:00)

 why do the low and high objects not set the ylim of the plotting function?

 Err, they do. You are plotting 'a' which has (whilst debugging your
 plot.e() )

 Browse[1] range(a)
 [1]  9.93 11.15

 You set the ylims to be (computed from 'b', why if plotting 'a'? and why
 is 'low' +5, should it be -5?):

 Browse[1] low
 [1] 14.7314
 Browse[1] high
 [1] 16.373

 And the plot I get has pretty labels/ticks that lie between 14.7 and
 16.3, but as the plotted data lie outside the range of the y-axis you
 don't see anything.

 The figure is actually drawn with a bit of extra (4%) fudge on the x and
 y limits as that is how all R plot work by default due to parameters
 'xaxs' and 'yaxs'. If you want them to be exactly 'low' and 'high' then
 setting yaxs=i might help. See ?par

 I suspect your plot.e needs to be something like this:

 `plot.e` - function(b, w, x, y, z){
 a - window.chron(b, w, x, y, z)
 low - min(a*0.98)-5
 high - max(a*1.02)+5
 plot(a, ylim=c(low, high))
 lines(a*0.98, col=blue)
 lines(a*1.02, col=red)
 }

 So you are computing your ylims on a and you make low = foo - 5 not + 5.
 At least then the lines you are drawing are displayed on the figure
 region - the +/-5 in low and high seem a bit extreme, but that was what
 you had so...

 HTH

 G

 thanks

 --
 %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
  Dr. Gavin Simpson [t] +44 (0)20 7679 0522
  ECRC, UCL Geography,  [f] +44 (0)20 7679 0565
  Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
  Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
  UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
 %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%





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


[R] ATT Researchers and the New York Times

2009-01-09 Thread Gábor Csárdi
On Fri, Jan 9, 2009 at 1:45 PM, Roland Studer roland.stu...@gmail.com wrote:
 I agree, that there are better plattforms.
 I'd love to see something like Stack Overflow:
 http://stackoverflow.com/

Why, you cannot see it now? You can start posting your R questions and
answers to it right away if you like.

 When you type your question, it compares it to previously answered
 questions. Answers can get voted up and down. Answers AND questions can be
 edited!

Personally I like that on the mailing list you have 'conversations',
and I would really hate if these could be edited. But as I said, there
is nothing that holds you back from using the above mentioned site for
R questions.

Gabor

 Regards
  Roland Studer

 On Fri, Jan 9, 2009 at 6:58 AM, Dr Eberhard W Lisse e...@lisse.na wrote:

 Robert,

 go ahead, fix whatever bothers you, this is Open Sauce, not Jet-Engine
 Science
 :-)-O

 el

 On 09 Jan 2009, at 07:41 , Johannes Huesing wrote:

  stephen sefick ssef...@gmail.com [Fri, Jan 09, 2009 at 03:16:11AM CET]:

 It has worked wonders for me over the last years.


  On Thu, Jan 8, 2009 at 8:58 PM, Robert Wilkins irishhac...@gmail.com
 wrote:

 And by the way, ARE YOU GUYS EVER GOING TO FIX your mailing list
 platform? It is extremely user-unfriendly and a technological clunk.


 He possibly means the Web interface to the archive, which I am not
 bothered
 about since the list is mirrored on Gmane.

 --
 Johannes Hüsing


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



 --
 http://www.sturmfrei.wordpress.com - Berner Mundartrock
 home 031 535 43 40 | mobile 079 746 48 59

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



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

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


Re: [R] Extracting File Basename without Extension

2009-01-09 Thread Henrique Dallazuanna
Right,

Other option is:



substr(nameFile, 1, tail(unlist(gregexpr(\\., nameFile)), 1) - 1)

On Fri, Jan 9, 2009 at 1:23 PM, Rau, Roland r...@demogr.mpg.de wrote:

 Hi,

  [mailto:r-help-boun...@r-project.org] On Behalf Of Henrique
  Dallazuanna
 
  Try this also:
 
  substr(basename(myfile), 1, nchar(basename(myfile)) - 4)
 

 This, of course, assumes that the extensions are always 3 characters.
 Sometimes there might be more (index.html), sometimes less
 (shellscript.sh).

 Although my solution is not as compact as the others (I wish I was
 proficient in 'mastering regular expressions'), I'd like to provide my
 little code-snippet which does not require any regular expressions (but
 expects a . in the filename).

 ##
 x1 - roland.txt
 x2 - roland.html
 x3 - roland.sh

 no.extension - function(astring) {
  if (substr(astring, nchar(astring), nchar(astring))==.) {
return(substr(astring, 1, nchar(astring)-1))
  } else {
no.extension(substr(astring, 1, nchar(astring)-1))
  }
 }

 no.extension(x1)
 no.extension(x2)
 no.extension(x3)
 ##

 Hope this helps a bit,
 Roland

 P.S. Any suggestions how to become more proficient with regular
 expressions? The O'Reilly book (Mastering...)? Whenever I tried
 anything more complicated than basic usage (things like ^ $ * . ) in R,
 I was way faster to write a new function (like above) instead of finding
 a regex solution.

 By the way: it might be still possible to *write* regular expressions,
 but what about code re-use? Are there people who can easily *read*
 complicated regular expressions?

 --
 This mail has been sent through the MPI for Demographic Research.  Should
 you receive a mail that is apparently from a MPI user without this text
 displayed, then the address has most likely been faked. If you are uncertain
 about the validity of this message, please check the mail header or ask your
 system administrator for assistance.




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

[[alternative HTML version deleted]]

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


Re: [R] Extracting File Basename without Extension

2009-01-09 Thread Duncan Murdoch

On 1/8/2009 9:10 PM, Gundala Viswanath wrote:

Dear all,

The basename() function returns the extension also:


myfile - path1/path2/myoutput.txt
basename(myfile)

[1] myoutput.txt


Is there any other function where it just returns
plain base:

myoutput

i.e. without 'txt'


I'm curious about something: does file extension have a standard 
definition?  Most (all?  I haven't tried them all) of the solutions 
presented in this thread would return an empty string for the plain 
base if given the filename .bashrc.


Windows (where file extensions really mean something), though reluctant 
to create such a file, appears to agree that the extension is bashrc, 
even though to me it appears clear that that file has no extension.


Duncan Murdoch

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


Re: [R] Extracting File Basename without Extension

2009-01-09 Thread Rau, Roland
Hi, 

 [mailto:r-help-boun...@r-project.org] On Behalf Of Henrique 
 Dallazuanna
 
 Try this also:
 
 substr(basename(myfile), 1, nchar(basename(myfile)) - 4)
 

This, of course, assumes that the extensions are always 3 characters.
Sometimes there might be more (index.html), sometimes less
(shellscript.sh).

Although my solution is not as compact as the others (I wish I was
proficient in 'mastering regular expressions'), I'd like to provide my
little code-snippet which does not require any regular expressions (but
expects a . in the filename).

##
x1 - roland.txt
x2 - roland.html
x3 - roland.sh

no.extension - function(astring) {
  if (substr(astring, nchar(astring), nchar(astring))==.) {
return(substr(astring, 1, nchar(astring)-1))
  } else {
no.extension(substr(astring, 1, nchar(astring)-1))
  }
}

no.extension(x1)
no.extension(x2)
no.extension(x3)
##

Hope this helps a bit,
Roland

P.S. Any suggestions how to become more proficient with regular
expressions? The O'Reilly book (Mastering...)? Whenever I tried
anything more complicated than basic usage (things like ^ $ * . ) in R,
I was way faster to write a new function (like above) instead of finding
a regex solution.

By the way: it might be still possible to *write* regular expressions,
but what about code re-use? Are there people who can easily *read*
complicated regular expressions?

--
This mail has been sent through the MPI for Demographic Research.  Should you 
receive a mail that is apparently from a MPI user without this text displayed, 
then the address has most likely been faked. If you are uncertain about the 
validity of this message, please check the mail header or ask your system 
administrator for assistance.

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

2009-01-09 Thread David Hajage
Dear R useRs,

Sorry for this foolish question, but I can't find how to escape the *
character when using grep :

 grep(-, c(/3, 2*3, 4-4))
[1] 3
 grep(/, c(/3, 2*3, 4-4))
[1] 1
 grep(*, c(/3, 2*3, 4-4))
Erreur dans grep(*, c(/3, 2*3, 4-4)) :
  expression régulière incorrecte '*'
De plus : Warning message:
In grep(*, c(/3, 2*3, 4-4)) :
  erreur rgcomp : 'Expression régulière précédente incorrecte'
 grep(\*, c(/3, 2*3, 4-4))
Erreur dans grep(*, c(/3, 2*3, 4-4)) :
  expression régulière incorrecte '*'
De plus : Warning messages:
1: '\*' est un code escape non reconnu dans une chaîne de caractères
2: code escape non reconnu éliminé de \*
3: In grep(*, c(/3, 2*3, 4-4)) :
  erreur rgcomp : 'Expression régulière précédente incorrecte'

Best regards,

david

[[alternative HTML version deleted]]

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


Re: [R] grep : escape *

2009-01-09 Thread Duncan Murdoch

On 1/9/2009 10:38 AM, David Hajage wrote:

Dear R useRs,

Sorry for this foolish question, but I can't find how to escape the *
character when using grep :


You use a backslash to escape the *.  Unfortunately, to enter a 
backslash in an R string, you need to escape it.  So the pattern is \\*.


Duncan Murdoch




grep(-, c(/3, 2*3, 4-4))

[1] 3

grep(/, c(/3, 2*3, 4-4))

[1] 1

grep(*, c(/3, 2*3, 4-4))

Erreur dans grep(*, c(/3, 2*3, 4-4)) :
  expression régulière incorrecte '*'
De plus : Warning message:
In grep(*, c(/3, 2*3, 4-4)) :
  erreur rgcomp : 'Expression régulière précédente incorrecte'

grep(\*, c(/3, 2*3, 4-4))

Erreur dans grep(*, c(/3, 2*3, 4-4)) :
  expression régulière incorrecte '*'
De plus : Warning messages:
1: '\*' est un code escape non reconnu dans une chaîne de caractères
2: code escape non reconnu éliminé de \*
3: In grep(*, c(/3, 2*3, 4-4)) :
  erreur rgcomp : 'Expression régulière précédente incorrecte'

Best regards,

david

[[alternative HTML version deleted]]





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


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


Re: [R] ATT Researchers and the New York Times

2009-01-09 Thread Ajay ohri
R would have truly arrived if the Wall Street Journal mentions it as an
alternative to SAS or Excel...but that is some years away...
Ajay

www.decisionstats.com

On Fri, Jan 9, 2009 at 7:28 AM, Robert Wilkins irishhac...@gmail.comwrote:

 Is anyone in the leadership of the R-project going to contact the New
 York Times and clarify that the article gave remarkably short shrift
 to the people who designed the user interface for R, to a large extent
 ATT researchers from an earlier generation? It would be the
 appropriate thing to do.

 The R team did not develop the user interface for R, the designers of
 the S programming language did. The layman reader of Vance's article
 will get the impression that R is a brand new invention, which is
 misleading and unfair. Gentleman and Ihaka should try harder to give
 credit where credit is due.


 And by the way, ARE YOU GUYS EVER GOING TO FIX your mailing list
 platform? It is extremely user-unfriendly and a technological clunk.
 The mailing lists for SAS, Python , and others (UseNet) may not be a
 user-interface-work-of-genius, but they are far superior to the R
 mailing list. What a clunk.

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


[[alternative HTML version deleted]]

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


[R] Pack and Unpack Strings in R

2009-01-09 Thread Gundala Viswanath
Dear all,

Does R has any function/package that can pack
and unpack string into bit size?

The reason I want to do this in R is that R
has much more native statistical function than Perl.

Yet the data I need to process is so large that it
required me to compress it into smaller unit - process it - finally
recover them back again into string with new information.

In Perl the implementation will look like this:
I wonder how can this be implemented in R.

__BEGIN__
my %charmap = (
A = '00',
C = '01',
G = '10',
T = '11',
);

my %digmap = (
'00'= A,
'01'= C,
'10'= G,
'11'= T,
);

my $string = 'GATTA';
$string =~ s/(.)/$charmap{$1}/ge;

my $compressed = pack 'b*', $string;

print COMP: $compressed\n;
printf %d bytes\n, length $compressed;

my @data;

# Store the compressed bit into array
push @data, $compressed;

# process the array
foreach my $dat ( @data ) {

   my $decompressed = unpack 'b*', $dat;
   $decompressed =~ s/(..)/$digmap{$1}/ge;

   print $decompressed\n;
   # or do further processing on $dat
}
__END__


- Gundala Viswanath
Jakarta - Indonesia

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


Re: [R] grep : escape *

2009-01-09 Thread Henrique Dallazuanna
Use double backslashes:

grep(\\*, c(/3, 2*3, 4-4))

2009/1/9 David Hajage dhajag...@gmail.com

 Dear R useRs,

 Sorry for this foolish question, but I can't find how to escape the *
 character when using grep :

  grep(-, c(/3, 2*3, 4-4))
 [1] 3
  grep(/, c(/3, 2*3, 4-4))
 [1] 1
  grep(*, c(/3, 2*3, 4-4))
 Erreur dans grep(*, c(/3, 2*3, 4-4)) :
  expression régulière incorrecte '*'
 De plus : Warning message:
 In grep(*, c(/3, 2*3, 4-4)) :
  erreur rgcomp : 'Expression régulière précédente incorrecte'
  grep(\*, c(/3, 2*3, 4-4))
 Erreur dans grep(*, c(/3, 2*3, 4-4)) :
  expression régulière incorrecte '*'
 De plus : Warning messages:
 1: '\*' est un code escape non reconnu dans une chaîne de caractères
 2: code escape non reconnu éliminé de \*
 3: In grep(*, c(/3, 2*3, 4-4)) :
  erreur rgcomp : 'Expression régulière précédente incorrecte'

 Best regards,

 david

[[alternative HTML version deleted]]


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




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

[[alternative HTML version deleted]]

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


Re: [R] Extracting File Basename without Extension

2009-01-09 Thread Gabor Grothendieck
On Fri, Jan 9, 2009 at 10:23 AM, Rau, Roland r...@demogr.mpg.de wrote:
 Hi,

 [mailto:r-help-boun...@r-project.org] On Behalf Of Henrique
 Dallazuanna

 Try this also:

 substr(basename(myfile), 1, nchar(basename(myfile)) - 4)


 This, of course, assumes that the extensions are always 3 characters.

The regex solutions posted did not make this assumption.


 P.S. Any suggestions how to become more proficient with regular
 expressions? The O'Reilly book (Mastering...)? Whenever I tried
 anything more complicated than basic usage (things like ^ $ * . ) in R,
 I was way faster to write a new function (like above) instead of finding
 a regex solution.

See the links in the Links box at:
http://gsubfn.googlecode.com




 By the way: it might be still possible to *write* regular expressions,
 but what about code re-use? Are there people who can easily *read*
 complicated regular expressions?

 --
 This mail has been sent through the MPI for Demographic Research.  Should you 
 receive a mail that is apparently from a MPI user without this text 
 displayed, then the address has most likely been faked. If you are uncertain 
 about the validity of this message, please check the mail header or ask your 
 system administrator for assistance.

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

2009-01-09 Thread Gabor Grothendieck
Use fixed = TRUE argument to grep.

2009/1/9 David Hajage dhajag...@gmail.com:
 Dear R useRs,

 Sorry for this foolish question, but I can't find how to escape the *
 character when using grep :

 grep(-, c(/3, 2*3, 4-4))
 [1] 3
 grep(/, c(/3, 2*3, 4-4))
 [1] 1
 grep(*, c(/3, 2*3, 4-4))
 Erreur dans grep(*, c(/3, 2*3, 4-4)) :
  expression régulière incorrecte '*'
 De plus : Warning message:
 In grep(*, c(/3, 2*3, 4-4)) :
  erreur rgcomp : 'Expression régulière précédente incorrecte'
 grep(\*, c(/3, 2*3, 4-4))
 Erreur dans grep(*, c(/3, 2*3, 4-4)) :
  expression régulière incorrecte '*'
 De plus : Warning messages:
 1: '\*' est un code escape non reconnu dans une chaîne de caractères
 2: code escape non reconnu éliminé de \*
 3: In grep(*, c(/3, 2*3, 4-4)) :
  erreur rgcomp : 'Expression régulière précédente incorrecte'

 Best regards,

 david

[[alternative HTML version deleted]]


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



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


Re: [R] grep : escape *

2009-01-09 Thread Gábor Csárdi
* must be escaped for grep with \ and \ must be escaped for R itself
with another \, so you need

grep(\\*, c(/3, 2*3, 4-4))

Gabor

2009/1/9 David Hajage dhajag...@gmail.com:
 Dear R useRs,

 Sorry for this foolish question, but I can't find how to escape the *
 character when using grep :

 grep(-, c(/3, 2*3, 4-4))
 [1] 3
 grep(/, c(/3, 2*3, 4-4))
 [1] 1
 grep(*, c(/3, 2*3, 4-4))
 Erreur dans grep(*, c(/3, 2*3, 4-4)) :
  expression régulière incorrecte '*'
 De plus : Warning message:
 In grep(*, c(/3, 2*3, 4-4)) :
  erreur rgcomp : 'Expression régulière précédente incorrecte'
 grep(\*, c(/3, 2*3, 4-4))
 Erreur dans grep(*, c(/3, 2*3, 4-4)) :
  expression régulière incorrecte '*'
 De plus : Warning messages:
 1: '\*' est un code escape non reconnu dans une chaîne de caractères
 2: code escape non reconnu éliminé de \*
 3: In grep(*, c(/3, 2*3, 4-4)) :
  erreur rgcomp : 'Expression régulière précédente incorrecte'

 Best regards,

 david

[[alternative HTML version deleted]]


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





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

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


Re: [R] grep : escape *

2009-01-09 Thread Tony Breyal
Hi there, you probably want something like:

# R
grep(\\*, c(/3, 2*3, 4-4))


hope that helps a little,
Tony Breyal



On 9 Jan, 15:38, David Hajage dhajag...@gmail.com wrote:
 Dear R useRs,

 Sorry for this foolish question, but I can't find how to escape the *
 character when using grep :

  grep(-, c(/3, 2*3, 4-4))
 [1] 3
  grep(/, c(/3, 2*3, 4-4))
 [1] 1
  grep(*, c(/3, 2*3, 4-4))

 Erreur dans grep(*, c(/3, 2*3, 4-4)) :
   expression régulière incorrecte '*'
 De plus : Warning message:
 In grep(*, c(/3, 2*3, 4-4)) :
   erreur rgcomp : 'Expression régulière précédente incorrecte' grep(\*, 
 c(/3, 2*3, 4-4))

 Erreur dans grep(*, c(/3, 2*3, 4-4)) :
   expression régulière incorrecte '*'
 De plus : Warning messages:
 1: '\*' est un code escape non reconnu dans une chaîne de caractères
 2: code escape non reconnu éliminé de \*
 3: In grep(*, c(/3, 2*3, 4-4)) :
   erreur rgcomp : 'Expression régulière précédente incorrecte'

 Best regards,

 david

         [[alternative HTML version deleted]]

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


Re: [R] recursive relevel

2009-01-09 Thread baptiste auguie

Thanks Thierry,

A quick test shows almost equivalent timing with the modification of  
relevel() suggested earlier:




relevel -
function (x, ref, ...)
{
lev - levels(x)
if (is.character(ref))
ref - match(ref, lev)
if (any(is.na(ref)))
stop('ref' must be an existing level)
nlev - length(lev)
if (any(ref  1 | ref  nlev))
stop(gettextf(ref = %d must be in 1:%d, ref, nlev),
domain = NA)
factor(x, levels = lev[c(ref, seq_along(lev)[-ref])])
}



 system.time(relevel(y, c(D, B)))
   user  system elapsed
  5.972   0.258   6.395

 system.time(order.factor3(y, c(D, B)))
   user  system elapsed
  5.962   0.274   6.459



It's always good to learn other options, though.

Thanks,

baptiste

On 9 Jan 2009, at 15:50, ONKELINX, Thierry wrote:


Dear Baptiste,

You can avoid the recursive stuff. And it will run about twice as  
fast.



order.factor - function (x, ref)

+  {
+  last.index - length(ref) # convenience for matlab's end keyword
+  if(last.index == 1) return(relevel(x, ref)) # end case, normal case
+  my.new.list - list(x=relevel(x, ref[last.index]), ref=ref[- 
last.index])

+  return(do.call(order.factor, my.new.list)) # recursive call
+  }


order.factor2 - function(x, ref){

+ factor(x, levels = c(ref, sort(levels(x)[!levels(x) %in% ref])))
+ }

order.factor3 - function(x, ref){
+ factor(x, levels = c(ref, sort(levels(x)[!levels(x) %in%  
ref])), labels = c(ref, sort(levels(x)[!levels(x) %in% ref])))

+ }


x - factor(sample(LETTERS[1:5], 1000, replace = TRUE))
y - factor(sample(LETTERS[1:20], 1000, replace = TRUE))
system.time(order.factor(x, c(D, B)))

  user  system elapsed
  5.690.386.09

system.time(order.factor2(x, c(D, B)))

  user  system elapsed
  3.900.204.12

system.time(order.factor3(x, c(D, B)))

  user  system elapsed
  3.260.193.46

system.time(order.factor(y, c(D, B)))

  user  system elapsed
 17.430.39   17.84

system.time(order.factor3(y, c(D, B)))

  user  system elapsed
  8.250.178.46


HTH,

Thierry



ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for  
Nature and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,  
methodology and quality assurance

Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

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

~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

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

~ John Tukey

-Oorspronkelijk bericht-
Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r- 
project.org] Namens baptiste auguie

Verzonden: vrijdag 9 januari 2009 15:11
Aan: R R-help
Onderwerp: [R] recursive relevel

Dear list,

I'm having second thoughts after solving a very trivial problem: I
want to extend the relevel() function to reorder an arbitrary number
of levels of a factor in one go. I could not find a trivial way of
using the code obtained by getS3method(relevel,factor). Instead, I
thought of solving the problem in a recursive manner (possibly after
reading Paul Graham essays on Lisp too recently). Here is my attempt :



order.factor - function (x, ref)
 {

 last.index - length(ref) # convenience for matlab's end keyword
 if(last.index == 1) return(relevel(x, ref)) # end case, normal  
case

of relevel
 my.new.list - list(x=relevel(x, ref[last.index]),  # creating a
list with updated parameters,
 # going 
 through the list in reverse order
 ref=ref[- 
last.index]) # chop the vector from its last level

 return(do.call(order.factor, my.new.list)) # recursive call
}

ff - factor(c(a, b, c, d))
ff
relevel(ff, levels(ff)[1])
relevel(ff, levels(ff)[2]) # that's the usual case: you want to put
a level first

order.factor(x=ff, ref=c(a, b))
order.factor(x=ff, ref=c(c))
order.factor(x=ff, ref=c(c, d)) # that's my wish: put c and d in
that order as the first two levels




I'm hoping this can be improved in several aspects:

- there is probably already a better function I missed or overlooked
(I'd still be curious about the following points, though)

- after reading a few threads, it appears that some recursive
functions are fragile in some sense, and I'm not sure what this means
in practice. (Should I use Recall, somehow?)

- it's probably quite slow for large data.frames

- I could not think of a good name, this one might clash with some S3
method perhaps?

- any other thoughts welcome!


Re: [R] grep : escape *

2009-01-09 Thread David Hajage
oooups. Thank you very much.

2009/1/9 Duncan Murdoch murd...@stats.uwo.ca

 On 1/9/2009 10:38 AM, David Hajage wrote:

 Dear R useRs,

 Sorry for this foolish question, but I can't find how to escape the *
 character when using grep :


 You use a backslash to escape the *.  Unfortunately, to enter a backslash
 in an R string, you need to escape it.  So the pattern is \\*.

 Duncan Murdoch


  grep(-, c(/3, 2*3, 4-4))

 [1] 3

 grep(/, c(/3, 2*3, 4-4))

 [1] 1

 grep(*, c(/3, 2*3, 4-4))

 Erreur dans grep(*, c(/3, 2*3, 4-4)) :
  expression régulière incorrecte '*'
 De plus : Warning message:
 In grep(*, c(/3, 2*3, 4-4)) :
  erreur rgcomp : 'Expression régulière précédente incorrecte'

 grep(\*, c(/3, 2*3, 4-4))

 Erreur dans grep(*, c(/3, 2*3, 4-4)) :
  expression régulière incorrecte '*'
 De plus : Warning messages:
 1: '\*' est un code escape non reconnu dans une chaîne de caractères
 2: code escape non reconnu éliminé de \*
 3: In grep(*, c(/3, 2*3, 4-4)) :
  erreur rgcomp : 'Expression régulière précédente incorrecte'

 Best regards,

 david

[[alternative HTML version deleted]]



 

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




[[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] longtable example

2009-01-09 Thread Felipe Carrillo
This is what I got.

\documentclass[11pt]{article}
\usepackage{longtable,lscape}
\usepackage{accents}
\usepackage[usenames,dvipsnames]{color} % load all the colors
\title{\color{Blue}How to transfer column names and add captions to pages in 
document}
\begin{document}
\maketitle
I am using Sweave and MikTex to generate my report but I am having problems 
with a table
that has 52 rows. I have no problem creating the 'longtable' but since my table 
is created dynamically,
I don't know how to transfer the column names to the second page of the PDF. I 
can name my column
names manually but since the table is created on the fly I wonder if there's a 
way that the column
headers from the first page be transferred automatically to the second or third 
pages and also have
captions on the header and footer of the pages ( something like 'Continued on 
next page').
Here's an example
tab.R,echo=FALSE,results=tex=
x - matrix(rnorm(1000), ncol = 10)
x.big - data.frame(x)
x.big - xtable(x,label='big',align=c|cc|,caption='Example of 
longtable spanning several pages')
print(x.big,tabular.environment='longtable',latex.environments=c(center),include.rownames=FALSE,floating=FALSE)
@
I want to add the column headers from the first page to the rest of the pages
and the caption 'Continued' to the top of each page. Thanks
\end{document}



--- On Thu, 1/8/09, Dieter Menne dieter.me...@menne-biomed.de wrote:

 From: Dieter Menne dieter.me...@menne-biomed.de
 Subject: Re: [R] longtable example
 To: r-h...@stat.math.ethz.ch
 Date: Thursday, January 8, 2009, 11:32 PM
 Felipe Carrillo mazatlanmexico at yahoo.com
 writes:
 
  
  Could someone try to run this example? I can't
 make it work.
 
 It would be better if you would show a complete sample; the
 error could be 
 in the header part, and chances are better to get a reply
 when other do 
 not have to guess what to add.
 
   \begin{small}
   \setlongtables
   \begin{longtable}{
   results=tex,fig=FALSE=
   cat(paste(c('c', rep('cc', 34/2-1),
 'c'), collapse='@{\hspace{2pt}}'))
   @ 
   }
   \hline
 
 
 The { after \begin{longtable} looks suspicious.
 
 Dieter
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] a first opinion on rattle

2009-01-09 Thread Gabriel Ibarra
Graham: OK. Just give me a few days and I will be sending you some simple RVM 
code lines. However, you have the Kernlab help with some nice examples
 
Best regards
 
Dr. Gabriel Ibarra-Berastegi
University of the Basque Country
SPAIN


--- El vie, 9/1/09, Graham Williams graham.willi...@togaware.com escribió:

De: Graham Williams graham.willi...@togaware.com
Asunto: Re: [R] a first opinion on rattle
Para: r-help@r-project.org
Fecha: viernes, 9 enero, 2009 12:40

Received Fri 09 Jan 2009  7:49pm +1100 from Gabriel Ibarra:
[...]

 I have installed rattle and is pretty intuitive and
 friendly. However, I miss some features of the original packages
 which cannot be invoked from rattle. For example, 'randomForest'
 package is??used but random??forests cannot be used in one of ??-in
 my opinion- most powerful aspects like regression. The same about
 SVM??. I would also say include RVM which the scientific literature
 suggest is mugh powerful than SVM.

 Anyway,??I must congratulate you and your team for providing the
 scientific community with rattle.

Thanks for the most kind feedback Gabriel. It is appreciated.

I am always open to suggestions. I should turn the randomForest
regression option on. Thanks for suggesting that. 

RVM from kernlab is in the todo list now. Do you have some simple
examples using rvm for regression? I should have a look to get that
into Rattle. Help (i.e., code or just code examples) is always welcome
:-)

Thanks,
Graham

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] [R} how to build TermDocMatrix in tm text mining package of R

2009-01-09 Thread Tony Breyal
Hi there, I think something like the following is what you want:

### R start...
# if you put your plain text files in a folder like this
my.path - 'C:\\Documents and Settings\\tony\\Desktop\\texts\\'

# then you can construct a simple tdm like this
library(tm)
my.corpus - Corpus(DirSource(my.path), readerControl = list
(reader=readPlain))
my.tdm - TermDocMatrix(my.corpus)

# this show show how words are distributed in the first text document
my.tdm[1, ]
### R end.

by the way, there are some nice examples of using the tm package in
the last Rnews letter (Volume 8/2, October 2008), under the section
'An Introduction to Text Mining in R':
http://cran.r-project.org/doc/Rnews/Rnews_2008-2.pdf

Hope that helps a little bit,
Tony Breyal

On 9 Jan, 14:21, Kum-Hoe Hwang phdhw...@gmail.com wrote:
 Howdy Gurus

 I 'd like to ask a question about how to build TermDocMatrix in tm text
 mining package.

 It is not clear about importing a plain text file, and them converting that
 text file into TermDocMatrix file, etc to me.
 How can I build a TermDocMatrix of  a plain text document file for text
 association?
 Or are there any good manuals?

 Thank you in advance,

 --
 Kum-Hoe Hwang, Ph.D.

 Phone : 82-31-250-3516
 Email : phdhw...@gmail.com

         [[alternative HTML version deleted]]

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


Re: [R] Pack and Unpack Strings in R

2009-01-09 Thread Henrique Dallazuanna
Try this:


## 1
map - list(A = '00', C = '01', G = '10', T = '11')
myStr - 'GATTA'
paste(map[unlist(strsplit(myStr, NULL))], collapse = )

## 2
cod - 100000
library(gsubfn)
strapply(cod, '[0-9]{2}')
names(map)[match(unlist(strapply(cod, '[0-9]{2}')), map)]

On Fri, Jan 9, 2009 at 1:50 PM, Gundala Viswanath gunda...@gmail.comwrote:

 Dear all,

 Does R has any function/package that can pack
 and unpack string into bit size?

 The reason I want to do this in R is that R
 has much more native statistical function than Perl.

 Yet the data I need to process is so large that it
 required me to compress it into smaller unit - process it - finally
 recover them back again into string with new information.

 In Perl the implementation will look like this:
 I wonder how can this be implemented in R.

 __BEGIN__
 my %charmap = (
A = '00',
C = '01',
G = '10',
T = '11',
 );

 my %digmap = (
'00'= A,
'01'= C,
'10'= G,
'11'= T,
 );

 my $string = 'GATTA';
 $string =~ s/(.)/$charmap{$1}/ge;

 my $compressed = pack 'b*', $string;

 print COMP: $compressed\n;
 printf %d bytes\n, length $compressed;

 my @data;

 # Store the compressed bit into array
 push @data, $compressed;

 # process the array
 foreach my $dat ( @data ) {

   my $decompressed = unpack 'b*', $dat;
   $decompressed =~ s/(..)/$digmap{$1}/ge;

   print $decompressed\n;
   # or do further processing on $dat
 }
 __END__


 - Gundala Viswanath
 Jakarta - Indonesia

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




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

[[alternative HTML version deleted]]

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


Re: [R] ATT Researchers and the New York Times

2009-01-09 Thread David M Smith
On Thu, Jan 8, 2009 at 5:58 PM, Robert Wilkins irishhac...@gmail.comwrote:

 Is anyone in the leadership of the R-project going to contact the New
 York Times and clarify that the article gave remarkably short shrift
 to the people who designed the user interface for R, to a large extent
 ATT researchers from an earlier generation? It would be the
 appropriate thing to do.


Colleagues of mine did contact Ashlee Vance after his article was published
and learned that his original text was shortened by the NYT section editors,
and so many details didn't make it to the print edition.  But he has
published a followup on the NYT's website clarifying and expanding a number
of details here:

http://bits.blogs.nytimes.com/2009/01/08/r-you-ready-for-r/

You can also provide comments on his article there too, if you like.

# David Smith

-- 
David M Smith da...@revolution-computing.com
Director of Community, REvolution Computing www.revolution-computing.com
Tel: +1 (206) 577-4778 x3203 (Seattle, USA)

[[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] Pack and Unpack Strings in R

2009-01-09 Thread Martin Morgan

Gundala --

Gundala Viswanath wrote:

Dear all,

Does R has any function/package that can pack
and unpack string into bit size?


All of your questions relate to DNA strings. The R/Bioconductor package 
Biostrings is designed to manipulate such objects. It does not 
necessarily address this particular problem (because in general DNA 
strings contain any of the 16 IUPAC symbols and hence compression 
becomes less compelling, and as you indicate even with compression the 
size of the data means that one might often need to process parts of the 
data at a time), but may provide useful containers and methods that make 
such issues less important.


 source('http://bioconductor.org/biocLite.R')
 biocLite('Biostrings')
 library('Biostrings')

see also the vignettes for the package, available within R or for example at

http://bioconductor.org/packages/release/bioc/html/Biostrings.html

It seems that you have data suitable for representation as a DNAStringSet.

The package is actively developed, and using the 'devel' version of R 
(and hence 'devel' version of Biostrings) might provide additional 
important facilities. If this proves useful then follow-up questions 
should use the Bioconductor mailing lists


http://bioconductor.org/docs/mailList.html

Martin


The reason I want to do this in R is that R
has much more native statistical function than Perl.

Yet the data I need to process is so large that it
required me to compress it into smaller unit - process it - finally
recover them back again into string with new information.

In Perl the implementation will look like this:
I wonder how can this be implemented in R.

__BEGIN__
my %charmap = (
A = '00',
C = '01',
G = '10',
T = '11',
);

my %digmap = (
'00'= A,
'01'= C,
'10'= G,
'11'= T,
);

my $string = 'GATTA';
$string =~ s/(.)/$charmap{$1}/ge;

my $compressed = pack 'b*', $string;

print COMP: $compressed\n;
printf %d bytes\n, length $compressed;

my @data;

# Store the compressed bit into array
push @data, $compressed;

# process the array
foreach my $dat ( @data ) {

   my $decompressed = unpack 'b*', $dat;
   $decompressed =~ s/(..)/$digmap{$1}/ge;

   print $decompressed\n;
   # or do further processing on $dat
}
__END__


- Gundala Viswanath
Jakarta - Indonesia

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



--
Martin Morgan
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109

Location: Arnold Building M2 B169
Phone: (206) 667-2793

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


Re: [R] Extracting File Basename without Extension

2009-01-09 Thread Peter Dalgaard
Duncan Murdoch wrote:
 On 1/8/2009 9:10 PM, Gundala Viswanath wrote:
 Dear all,

 The basename() function returns the extension also:

 myfile - path1/path2/myoutput.txt
 basename(myfile)
 [1] myoutput.txt


 Is there any other function where it just returns
 plain base:

 myoutput

 i.e. without 'txt'
 
 I'm curious about something: does file extension have a standard
 definition?  Most (all?  I haven't tried them all) of the solutions
 presented in this thread would return an empty string for the plain
 base if given the filename .bashrc.
 
 Windows (where file extensions really mean something), though reluctant
 to create such a file, appears to agree that the extension is bashrc,
 even though to me it appears clear that that file has no extension.

I'm not sure what is clear about it, but the GNU utility agrees with you:

basename abc/.exe .exe
.exe
basename abc/1.exe .exe
1

Anyone want to contribute code for an optional suffix= argument for R's
basename()?

-- 
   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] Extracting File Basename without Extension

2009-01-09 Thread Marc Schwartz
on 01/09/2009 09:00 AM Duncan Murdoch wrote:
 On 1/8/2009 9:10 PM, Gundala Viswanath wrote:
 Dear all,

 The basename() function returns the extension also:

 myfile - path1/path2/myoutput.txt
 basename(myfile)
 [1] myoutput.txt


 Is there any other function where it just returns
 plain base:

 myoutput

 i.e. without 'txt'
 
 I'm curious about something: does file extension have a standard
 definition?  Most (all?  I haven't tried them all) of the solutions
 presented in this thread would return an empty string for the plain
 base if given the filename .bashrc.
 
 Windows (where file extensions really mean something), though reluctant
 to create such a file, appears to agree that the extension is bashrc,
 even though to me it appears clear that that file has no extension.

Duncan,

That is going to be highly OS and even OS version specific. More
information here:

  http://en.wikipedia.org/wiki/Filename
  http://en.wikipedia.org/wiki/Filename_extension

There are relevant standard extensions for standard file formats:

  http://en.wikipedia.org/wiki/List_of_file_formats

but that does not guarantee that user created filenames will adhere to
them, especially for text files.

As you note, filenames beginning with a '.' will be common on
Unixen/Linuxen as otherwise normally hidden system/config files. Such
files would actually create problems if attempted to be opened on
Windows with certain applications and I have even seen problems with
such files when using SMB under Linux to access files on a server.

HTH,

Marc Schwartz

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


[R] The R Inferno

2009-01-09 Thread Patrick Burns

The R Inferno is now on the Burns Statistics website at

http://www.burns-stat.com/pages/Tutor/R_inferno.pdf

Abstract: If you are using R and you think you're in hell,
this is a map for you.

Also, I've expanded the outline concerning R on the
Burns Statistics 'Links' page. Suggestions (off-list) for
additional items are encouraged.


Patrick Burns
patr...@burns-stat.com
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of The R Inferno and A Guide for the Unwilling S User)

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


Re: [R] Pack and Unpack Strings in R

2009-01-09 Thread jim holtman
see:

http://www.nabble.com/Compressing-String-in-R-td21160453.html

On Fri, Jan 9, 2009 at 10:50 AM, Gundala Viswanath gunda...@gmail.com wrote:
 Dear all,

 Does R has any function/package that can pack
 and unpack string into bit size?

 The reason I want to do this in R is that R
 has much more native statistical function than Perl.

 Yet the data I need to process is so large that it
 required me to compress it into smaller unit - process it - finally
 recover them back again into string with new information.

 In Perl the implementation will look like this:
 I wonder how can this be implemented in R.

 __BEGIN__
 my %charmap = (
A = '00',
C = '01',
G = '10',
T = '11',
 );

 my %digmap = (
'00'= A,
'01'= C,
'10'= G,
'11'= T,
 );

 my $string = 'GATTA';
 $string =~ s/(.)/$charmap{$1}/ge;

 my $compressed = pack 'b*', $string;

 print COMP: $compressed\n;
 printf %d bytes\n, length $compressed;

 my @data;

 # Store the compressed bit into array
 push @data, $compressed;

 # process the array
 foreach my $dat ( @data ) {

   my $decompressed = unpack 'b*', $dat;
   $decompressed =~ s/(..)/$digmap{$1}/ge;

   print $decompressed\n;
   # or do further processing on $dat
 }
 __END__


 - Gundala Viswanath
 Jakarta - Indonesia

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Calculating p-values from your own distribution as an array

2009-01-09 Thread Stephen Montgomery
Hi -

If I have a hypothetical distribution as an array

distribution-c(0,1,2,3,4,5,6,7,8,9)

and I want to find the probability there is a value smaller than a new
value.

new_value-4

(such that I'd get this type of output)

new_value   p-value
4   0.5
3.4 0.4 
3   0.4
0   0.1
-1  0.0

Thanks for the help, I bet this is really easy... :/ 

Stephen


-- 
 The Wellcome Trust Sanger Institute is operated by Genome Research 
 Limited, a charity registered in England with number 1021457 and a 
 company registered in England with number 2742969, whose registered 
 office is 215 Euston Road, London, NW1 2BE.

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


Re: [R] The R Inferno

2009-01-09 Thread Ajay ohri
excellent adaptation of Dante and R with real common sense tips to help
beginners especially ..goes to the blogroll..
now if only i could get tips to sort a 5 column * 1 million rows  dataset in
less than ..eternity

Ajay
www.decisionstats.com

On Fri, Jan 9, 2009 at 9:44 PM, Patrick Burns pbu...@pburns.seanet.comwrote:

 The R Inferno is now on the Burns Statistics website at

 http://www.burns-stat.com/pages/Tutor/R_inferno.pdf

 Abstract: If you are using R and you think you're in hell,
 this is a map for you.

 Also, I've expanded the outline concerning R on the
 Burns Statistics 'Links' page. Suggestions (off-list) for
 additional items are encouraged.


 Patrick Burns
 patr...@burns-stat.com
 +44 (0)20 8525 0696
 http://www.burns-stat.com
 (home of The R Inferno and A Guide for the Unwilling S User)

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


[[alternative HTML version deleted]]

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


[R] Calling R functions from Python

2009-01-09 Thread ryan

   All-



   Thanks in advance for your help.



   I'm trying to call R function using Python in a windows environment and have
   downloaded the Rpy library however it doesn't appear to work with R 2.7.2.
   Does anyone know if a new version of Rpy exists for windows that will work
   with R and where it can be downloaded from?





   Here's an example of the error I'm getting:



   Traceback (most recent call last):
 File C:\Documents and Settings\rkirkish\Desktop\test.py, line 1, in
   module
   from rpy import r
 File C:\Python25\Lib\site-packages\rpy.py, line 134, in module
% RVERSION)
   RuntimeError: No module named _rpy2072

 RPy module can not be imported. Please check if your rpy
 installation supports R 2.7.2. If you have multiple R versions
 installed, you may need to set RHOME before importing rpy. For
 example:
   
  from rpy_options import set_options
  set_options(RHOME='c:/progra~1/r/rw2011/')
  from rpy import *
 
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] The R Inferno

2009-01-09 Thread Peter Dalgaard

Ajay ohri wrote:

excellent adaptation of Dante and R with real common sense tips to help
beginners especially ..goes to the blogroll..
now if only i could get tips to sort a 5 column * 1 million rows  dataset in
less than ..eternity


Er, that's a fairly short eternity:

 x - data.frame(rnorm(1e6),rnorm(1e6),rnorm(1e6),rnorm(1e6),rnorm(1e6))
 names(x) - letters[1:5]
 system.time(y - x[order(x$a),])
   user  system elapsed
  3.259   0.160   3.435
 head(y)
   a  b  c   d   e
227944 -4.418977  0.9635349  0.2477897 -0.10172584  0.09840375
492006 -4.327607 -1.4967631 -0.3467700  0.53053492 -0.80043595
89830  -4.285324 -2.0491949 -2.2024725 -0.34946013 -0.63538249



--
   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] How to compute Bootstrap p-values

2009-01-09 Thread Murray Cooper

Do you really need the p-value or do you want to test at one
of the socially acceptable levels (i.e. .05 or .01). If all you want
is the test, use:

quantile(bootsample,c(0.025,0.975))

If the quantile range includes 0 then you decide there is no evidence
that the mean is different from zero, at the .05 level.

If the quantile range does not include 0 then you decide there is evidence
that the mean is different from zero, at the .05 level.

If you wanted to use .01 level then use:

quantile(bootsample,c(0.005,0.995))

Murray M Cooper
Richland Statistics
9800 N 24th St
Richland, MI, USA 49083
Mail: richs...@earthlink.net

- Original Message - 
From: Andreas Klein klein82...@yahoo.de

To: r-help@r-project.org
Sent: Friday, January 09, 2009 4:36 AM
Subject: [R] How to compute Bootstrap p-values



Hello.

How can I compute the Bootstrap p-value for a two-sided test problem like 
H_0: beta=0 vs. H_1: beta!=0 ?


Example for the sample mean:

x - rnorm(100)

bootsample - numeric(1000)

for(i in 1:1000) {

 idx - sample(1:100,100,replace=TRUE)

 bootsample[i] - mean(x[idx])

}


How can I compute the Bootstrap p-value for the mean of x?

H_0: mean of x = 0 vs. H_1: mean of x != 0



Thank you in advance.


Sincerely,
Andreas Klein.




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

2009-01-09 Thread Andrew Choens

 now if only i could get tips to sort a 5 column * 1 million rows  dataset in
 less than ..eternity

May I suggest mySQL, postgreSQL, etc.? If what you need to do is a basic
sort, a database is going to be faster than R.

-- 
Insert something humorous here.  :-)

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


Re: [R] longtable example

2009-01-09 Thread Dieter Menne



Felipe Carrillo wrote:
 
 This is what I got.
 
 \documentclass[11pt]{article}
 \usepackage{longtable,lscape}
 \usepackage{accents}
 \usepackage[usenames,dvipsnames]{color} % load all the colors
 \title{\color{Blue}How to transfer column names and add captions to pages
 in document}
 ...
 

The example you provided did not work, because you forgot the
library(xtable).
I cannot help you with xtable because I normally use latex in Hmisc; see
below

Dieter

-

\documentclass[11pt]{article}
\usepackage{longtable,lscape}
\usepackage[usenames,dvipsnames]{color} % load all the colors
\title{\color{Blue}How to transfer column names and add captions to pages in
document}
\begin{document}
\maketitle
tab.R,echo=FALSE,results=tex=
library(Hmisc)
#library(xtable)
x - matrix(rnorm(1000), ncol = 10)
x.big - data.frame(x)
latex(x.big,,file=,longtable=TRUE, dec=2,
  caption='Example of longtable spanning several pages')
#x.big - xtable(x,label='big',align=c|cc|,
#  caption='Example of longtable spanning several pages')
#print(x.big,tabular.environment='longtable',
#  latex.environments=c(center),include.rownames=FALSE,floating=FALSE)
@
I want to add the column headers from the first page to the rest of the
pages
and the caption 'Continued' to the top of each page. Thanks
\end{document}



-- 
View this message in context: 
http://www.nabble.com/longtable-example-tp21356712p21377352.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] bug in R2WinBUGS

2009-01-09 Thread John Smith
In newest version of R2WinBUGS, the default directory is changed to
working.directory, but never changed back once finished bugs call.

[[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] Maintain Spaces and Parentheses in Variable Names

2009-01-09 Thread Cloudy56

Is there any way to maintain spaces, slashes, and parentheses in variable
names when reading these into R?

Of course, read.table converts these to periods.  However, I know that it's
not strictly illegal to have these characters in variable names as I am able
to add them using the variable editor portion of the data editor.

I need to batch produce dozens of histograms for reporting purposes and my
data is loaded with special characters e.g. Historic Trend (mm/yr)  
Adding Historic.Trend..mm.yr. to my plots is not acceptable for reporting
purposes.  Do I really need to manually label all of my plots each time I
produce them in R or manually change the variable names in the Data Editor?

Any help that anyone may be able to provide to allow me to read data without
corrupting my variable labels would be appreciated.  (Forgive me if this
is a dumb question, first day in R.)
-- 
View this message in context: 
http://www.nabble.com/Maintain-Spaces-and-Parentheses-in-Variable-Names-tp21377255p21377255.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] Maintain Spaces and Parentheses in Variable Names

2009-01-09 Thread Henrique Dallazuanna
Try this:

read.table(, check.names = FALSE)

On Fri, Jan 9, 2009 at 3:56 PM, Cloudy56 clough.jonat...@gmail.com wrote:


 Is there any way to maintain spaces, slashes, and parentheses in variable
 names when reading these into R?

 Of course, read.table converts these to periods.  However, I know that it's
 not strictly illegal to have these characters in variable names as I am
 able
 to add them using the variable editor portion of the data editor.

 I need to batch produce dozens of histograms for reporting purposes and my
 data is loaded with special characters e.g. Historic Trend (mm/yr)
 Adding Historic.Trend..mm.yr. to my plots is not acceptable for reporting
 purposes.  Do I really need to manually label all of my plots each time I
 produce them in R or manually change the variable names in the Data Editor?

 Any help that anyone may be able to provide to allow me to read data
 without
 corrupting my variable labels would be appreciated.  (Forgive me if this
 is a dumb question, first day in R.)
 --
 View this message in context:
 http://www.nabble.com/Maintain-Spaces-and-Parentheses-in-Variable-Names-tp21377255p21377255.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.




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

[[alternative HTML version deleted]]

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


Re: [R] The R Inferno

2009-01-09 Thread roger koenker
I think that this continuation constitutes what Pat calls hijacking  
the thread
at the end of his new and magnificent opus.  The original thread  
should be

reserved for kudos to Pat.


url:www.econ.uiuc.edu/~rogerRoger Koenker
emailrkoen...@uiuc.eduDepartment of Economics
vox: 217-333-4558University of Illinois
fax:   217-244-6678Champaign, IL 61820



On Jan 9, 2009, at 11:52 AM, Andrew Choens wrote:



now if only i could get tips to sort a 5 column * 1 million rows   
dataset in

less than ..eternity


May I suggest mySQL, postgreSQL, etc.? If what you need to do is a  
basic

sort, a database is going to be faster than R.

--
Insert something humorous here.  :-)

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

2009-01-09 Thread Felipe Carrillo
Thanks Dieter: 
It's exactly what I want. Thanks a lot for you help. One thing that I noticed 
though, when I generated my pdf all the pages had different numbers of rows, 
for example page 1 had 24 rows,second page 15 rows,third page 2 rows of data. 
Is that something that can be controlled with pagebreaks? I am reading about 
the 'latex' function right now in some cases I will need to print some tables 
in 'landscape',so is there an option to landscape that particular page instead 
of just landscaping the table?



--- On Fri, 1/9/09, Dieter Menne dieter.me...@menne-biomed.de wrote:

 From: Dieter Menne dieter.me...@menne-biomed.de
 Subject: Re: [R] longtable example
 To: r-help@r-project.org
 Date: Friday, January 9, 2009, 10:01 AM
 Felipe Carrillo wrote:
  
  This is what I got.
  
  \documentclass[11pt]{article}
  \usepackage{longtable,lscape}
  \usepackage{accents}
  \usepackage[usenames,dvipsnames]{color} % load all
 the colors
  \title{\color{Blue}How to transfer column
 names and add captions to pages
  in document}
  ...
  
 
 The example you provided did not work, because you forgot
 the
 library(xtable).
 I cannot help you with xtable because I normally use latex
 in Hmisc; see
 below
 
 Dieter
 
 -
 
 \documentclass[11pt]{article}
 \usepackage{longtable,lscape}
 \usepackage[usenames,dvipsnames]{color} % load all the
 colors
 \title{\color{Blue}How to transfer column names and
 add captions to pages in
 document}
 \begin{document}
 \maketitle
 tab.R,echo=FALSE,results=tex=
 library(Hmisc)
 #library(xtable)
 x - matrix(rnorm(1000), ncol = 10)
 x.big - data.frame(x)
 latex(x.big,,file=,longtable=TRUE,
 dec=2,
   caption='Example of longtable spanning several
 pages')
 #x.big -
 xtable(x,label='big',align=c|cc|,
 #  caption='Example of longtable spanning several
 pages')
 #print(x.big,tabular.environment='longtable',
 # 
 latex.environments=c(center),include.rownames=FALSE,floating=FALSE)
 @
 I want to add the column headers from the first page to the
 rest of the
 pages
 and the caption 'Continued' to the top of each
 page. Thanks
 \end{document}
 
 
 
 -- 
 View this message in context:
 http://www.nabble.com/longtable-example-tp21356712p21377352.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] longtable example

2009-01-09 Thread Dieter Menne
Felipe Carrillo mazatlanmexico at yahoo.com writes:


 One thing that I noticed though, when I generated my pdf
 all the pages had different numbers of rows, for example page 1 had 24
rows,second page 15 rows,third page 2
 rows of data. Is that something that can be controlled with pagebreaks? 

I darkly remember having seen something like that before, it has to do with 
some block processing in latex (I mean tex/latex, not the R function); 

As a workaround, try 

lines.page=1

But don't expect miracles, I am not sure it will help.

Dieter

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


Re: [R] Programming Question (setting ylim generally)

2009-01-09 Thread Mike Prager
stephen sefick ssef...@gmail.com wrote:

 low - min(a*0.98)-(min(a)*0.04)
 high - max(a*1.02)+(max(a)*0.04)
 plot(a, ylim=c(low, high))

Unless I am misreading your example, this can be done a little
more compactly as:

plot(a, ylim = range(a * 0.94, a * 1.06))

-- 
Mike Prager, NOAA, Beaufort, NC
* Opinions expressed are personal and not represented otherwise.
* Any use of tradenames does not constitute a NOAA endorsement.

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


Re: [R] Calling R functions from Python

2009-01-09 Thread culpritNr1

Hello Ryan,

I have good and bad news for you.

The good one is that there is a new rpy in active development. The bad one
is that you should compile it yourself.

You can get it here

http://rpy.sourceforge.net/rpy2.html

I use the regular distro of rpy under Linux x86_64. It works. I hope you get
your windows to work as well. To start with, I suggest that you upgrade to R
2.8.0. By now R 2.8.1 is the official version for Fedora (linux) users. So,
we can consider 2.7 rather old.

Best,

culpritNr1




ryan-147 wrote:
 
 
All-
 
 
 
Thanks in advance for your help.
 
 
 
I'm trying to call R function using Python in a windows environment and
 have
downloaded the Rpy library however it doesn't appear to work with R
 2.7.2.
Does anyone know if a new version of Rpy exists for windows that will
 work
with R and where it can be downloaded from?
 
 
 
 
 
Here's an example of the error I'm getting:
 
 
 
Traceback (most recent call last):
  File C:\Documents and Settings\rkirkish\Desktop\test.py, line 1, in
module
from rpy import r
  File C:\Python25\Lib\site-packages\rpy.py, line 134, in module
 % RVERSION)
RuntimeError: No module named _rpy2072
 
  RPy module can not be imported. Please check if your rpy
  installation supports R 2.7.2. If you have multiple R versions
  installed, you may need to set RHOME before importing rpy. For
  example:

   from rpy_options import set_options
   set_options(RHOME='c:/progra~1/r/rw2011/')
   from rpy import *
  
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/Calling-R-functions-from-Python-tp21377066p21378554.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] Programming Question (setting ylim generally)

2009-01-09 Thread Gabor Grothendieck
Or even:

plot(a, ylim = range(a) + 0.06 * c(-1, 1))


On Fri, Jan 9, 2009 at 2:07 PM, Mike Prager mike.pra...@noaa.gov wrote:
 stephen sefick ssef...@gmail.com wrote:

 low - min(a*0.98)-(min(a)*0.04)
 high - max(a*1.02)+(max(a)*0.04)
 plot(a, ylim=c(low, high))

 Unless I am misreading your example, this can be done a little
 more compactly as:

 plot(a, ylim = range(a * 0.94, a * 1.06))

 --
 Mike Prager, NOAA, Beaufort, NC
 * Opinions expressed are personal and not represented otherwise.
 * Any use of tradenames does not constitute a NOAA endorsement.

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] equation of confidence interval calculated by predict.lm

2009-01-09 Thread kloe

Hello,
Sorry to ask this question, I have been searching quite a lot but I could
not find an answer.
I have seen one post about this subject but I did not really understand the
answer.

I have a linear regression with 95% confidence interval.
I would like to find the x-absciss of the intersection point with the upper
confidence interval curve and a straight line (y=y0).
For this I apply a formula of inverse regression from Draper and Smith,
(Applied Regression analysis,1981): 
Xu=mean(X)+(b1(Yo-mean(Y))+t*s*(((Yo-mean(Y))²/Sxx)+(b1²/n)-(t²*s²/n*Sxx))^(1/2))/(b1²-t²*s²/Sxx)
with:
n=number of points in the regression
Yo:ordinate of the intersection point
b1:slope of linear regression
s:sample standard deviation
Sxx=sum(Xi-mean(X))²
t=t(v,1-a/2) with a=0.05 and v=number of degrees of freedom of s²

To check my code, I plot the regression line with its confidence interval
(using predict.lm) and y=Yo, and it was clear that results were not as
expected. It seems that the formula for confidence interval used by Draper
and Smith, is the following: Y=bo+b1*X +/-
t*s*((1/n)+(X-mean(X))²/Sxx)^(1/2))
with the same parameters as above and bo being the second parameter from
regression.

I also plotted this equation and I did not obtain the same confidence
interval as the one predicted by predict.lm
I would like to know which formula is used in predict.lm to calculate
correctly the confidence interval in order to calculate correctly the
intersection point... I try to read the code but I did not get a clue...

Any help would be really welcome, thanks a lot for your time !!
Have a good day!!
Chloé

-- 
View this message in context: 
http://www.nabble.com/equation-of-confidence-interval-calculated-by-predict.lm-tp21377924p21377924.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] Maintain Spaces and Parentheses in Variable Names

2009-01-09 Thread Cloudy56

Thank you very much.  That certainly worked.  Somehow I did not see that when
reading the help file, nor could I find it via Google search so I appreciate
your help!   -- JC


Henrique Dallazuanna wrote:
 
 Try this:
 
 read.table(, check.names = FALSE)
 
 On Fri, Jan 9, 2009 at 3:56 PM, Cloudy56 clough.jonat...@gmail.com
 wrote:
 

 Is there any way to maintain spaces, slashes, and parentheses in variable
 names when reading these into R?

 Of course, read.table converts these to periods.  However, I know that
 it's
 not strictly illegal to have these characters in variable names as I am
 able
 to add them using the variable editor portion of the data editor.

 I need to batch produce dozens of histograms for reporting purposes and
 my
 data is loaded with special characters e.g. Historic Trend (mm/yr)
 Adding Historic.Trend..mm.yr. to my plots is not acceptable for
 reporting
 purposes.  Do I really need to manually label all of my plots each time I
 produce them in R or manually change the variable names in the Data
 Editor?

 Any help that anyone may be able to provide to allow me to read data
 without
 corrupting my variable labels would be appreciated.  (Forgive me if
 this
 is a dumb question, first day in R.)
 --
 View this message in context:
 http://www.nabble.com/Maintain-Spaces-and-Parentheses-in-Variable-Names-tp21377255p21377255.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.

 
 
 
 -- 
 Henrique Dallazuanna
 Curitiba-Paraná-Brasil
 25° 25' 40 S 49° 16' 22 O
 
   [[alternative HTML version deleted]]
 
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/Maintain-Spaces-and-Parentheses-in-Variable-Names-tp21377255p21377996.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] question about the scale in ridge regression of the MASS package

2009-01-09 Thread Xue, Liangjie
Hi

I am reading the source code of the ridge regression of the MASS package,
and I found the following piece of code
X - model.matrix(Terms, m, contrasts)
n - nrow(X); p - ncol(X)
offset - model.offset(m)
if(!is.null(offset)) Y - Y - offset
if(Inter - attr(Terms, intercept))
{
Xm - colMeans(X[, -Inter])
Ym - mean(Y)
p - p - 1
X - X[, -Inter] - rep(Xm, rep(n, p))
Y - Y - Ym
} else Ym - Xm - NA
   * Xscale - drop(rep(1/n, n) %*% X^2)^0.5*# line 38 of the original
code
X - X/rep(Xscale, rep(n, p))

It uses sqrt((x-xbar)^2)/n to calculate the scale of the data, while the
scale function provided by R uses sqrt((x-xbar)^2)/(n-1), which calculates
the standard deviation of the data. Is this a mistake in the MASS package,
or there are some other reasons?

Thank you very much.

L.J.

[[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] Programming Question (setting ylim generally)

2009-01-09 Thread stephen sefick
WOW, Gabor, that is fancy.  I have gotten better at this R thing, but
have far to go.  That is a neat solution.
thanks

Stephen


On Fri, Jan 9, 2009 at 2:22 PM, Gabor Grothendieck
ggrothendi...@gmail.com wrote:
 Or even:

 plot(a, ylim = range(a) + 0.06 * c(-1, 1))


 On Fri, Jan 9, 2009 at 2:07 PM, Mike Prager mike.pra...@noaa.gov wrote:
 stephen sefick ssef...@gmail.com wrote:

 low - min(a*0.98)-(min(a)*0.04)
 high - max(a*1.02)+(max(a)*0.04)
 plot(a, ylim=c(low, high))

 Unless I am misreading your example, this can be done a little
 more compactly as:

 plot(a, ylim = range(a * 0.94, a * 1.06))

 --
 Mike Prager, NOAA, Beaufort, NC
 * Opinions expressed are personal and not represented otherwise.
 * Any use of tradenames does not constitute a NOAA endorsement.

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




-- 
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] Ashlee Vance's article on R in the New York Times

2009-01-09 Thread Patrick Connolly
On Thu, 08-Jan-2009 at 01:26AM -0500, Robert Wilkins wrote:

[]

| Some R promoters point out that R has lexical scope and lots of
| Scheme goodness. ( and what widespread programming language today
| does not have lexical scope? ). But other R promoters point out
| that programs in S-Plus usually work in R, and vice-versa. Well, in
| that case, then it's the same damn programming language!

Same language, but a different 'interface'.

The effort to get them to work in the other interface relates mostly
to dealing with the the presence or absence of lexical scoping.  But
even if Splus did have lexical scoping, I'd probably have changed to R
anyway.

The main reason why I changed was because it was such a hassle getting
anything new added.  Bean-counters had to be satisfied that the admin
work was value for money before it was permissable to have an IT guy
spend time setting up a different function library.  It could take
months getting that through.

By contrast, because of no bean-counter issues, with R, I could
install everying myself and simply add packages that looked
interesting.  We're comparing seconds with months.  The crucial
difference in the interfaces is the difference between proprietary and
open.

[]


| One big, and crucial exception is the category of all-purpose
| programming languages. Thousands of open source developers go to
| bed dreaming of being the next Larry Wall. Thankfully, we have Ruby
| and Python as a result.

So your point is that the problem with data organisation is that it is
not all-purpose enough, so we have to wait until somebody produces a
proprietary product?

Your list of Ruby and Python reminds me of the scene in 'The Life of
Brian' where the John Cleese character asks the rhetorical question:
What have the Romans ever done for us?  

http://www.youtube.com/watch?v=ExWfh6sGyso


-- 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
   ___Patrick Connolly   
 {~._.~}   Great minds discuss ideas
 _( Y )_ Average minds discuss events 
(:_~*~_:)  Small minds discuss people  
 (_)-(_)  . Eleanor Roosevelt
  
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

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


Re: [R] The R Inferno

2009-01-09 Thread Duncan Murdoch

On 1/9/2009 1:27 PM, roger koenker wrote:
I think that this continuation constitutes what Pat calls hijacking  
the thread
at the end of his new and magnificent opus.  The original thread  
should be

reserved for kudos to Pat.


Which he well deserves -- it's good advice, and a fun read too.

Duncan




url:www.econ.uiuc.edu/~rogerRoger Koenker
emailrkoen...@uiuc.eduDepartment of Economics
vox: 217-333-4558University of Illinois
fax:   217-244-6678Champaign, IL 61820



On Jan 9, 2009, at 11:52 AM, Andrew Choens wrote:



now if only i could get tips to sort a 5 column * 1 million rows   
dataset in

less than ..eternity


May I suggest mySQL, postgreSQL, etc.? If what you need to do is a  
basic

sort, a database is going to be faster than R.

--
Insert something humorous here.  :-)

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

2009-01-09 Thread Barry Rowlingson
2009/1/9 Duncan Murdoch murd...@stats.uwo.ca:

 Which he well deserves -- it's good advice, and a fun read too.

 I'm looking forward to the sequel - Shakespeare perhaps?
as.YouLike(it)? Much Ado About NULL? Night[12] | What(You.Will)?

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] create sequences from two from and to vectors

2009-01-09 Thread Yasir Kaheil

hi all,
how can I create sequences that start from a known vector, say x1 and end
with another say x2- also suppose all the sequences will be the same length.
I don't want to use a for loop
x1-c(1,2,3,4); x2-(3,4,5,6);
what I want is 
1 2 3 4 
2 3 4 5
3 4 5 6

Thanks

-
Yasir H. Kaheil
Columbia University
-- 
View this message in context: 
http://www.nabble.com/create-sequences-from-two-%22from%22-and-%22to%22-vectors-tp21380194p21380194.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] create sequences from two from and to vectors

2009-01-09 Thread Dimitris Rizopoulos

one way is using mapply(), e.g.,

mapply(:, 1:4, 3:6)


I hope it helps.

Best,
Dimitris


Yasir Kaheil wrote:

hi all,
how can I create sequences that start from a known vector, say x1 and end
with another say x2- also suppose all the sequences will be the same length.
I don't want to use a for loop
x1-c(1,2,3,4); x2-(3,4,5,6);
what I want is 
1 2 3 4 
2 3 4 5

3 4 5 6

Thanks

-
Yasir H. Kaheil
Columbia University


--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus 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] create sequences from two from and to vectors

2009-01-09 Thread Marc Schwartz
on 01/09/2009 02:42 PM Yasir Kaheil wrote:
 hi all,
 how can I create sequences that start from a known vector, say x1 and end
 with another say x2- also suppose all the sequences will be the same length.
 I don't want to use a for loop
 x1-c(1,2,3,4); x2-(3,4,5,6);
 what I want is 
 1 2 3 4 
 2 3 4 5
 3 4 5 6
 
 Thanks


 mapply(seq, x1, x2)
 [,1] [,2] [,3] [,4]
[1,]1234
[2,]2345
[3,]3456



See ?mapply

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] create sequences from two from and to vectors

2009-01-09 Thread Yasir Kaheil

Great! thank you so much!

Dimitris Rizopoulos-4 wrote:
 
 one way is using mapply(), e.g.,
 
 mapply(:, 1:4, 3:6)
 
 
 I hope it helps.
 
 Best,
 Dimitris
 
 
 Yasir Kaheil wrote:
 hi all,
 how can I create sequences that start from a known vector, say x1 and end
 with another say x2- also suppose all the sequences will be the same
 length.
 I don't want to use a for loop
 x1-c(1,2,3,4); x2-(3,4,5,6);
 what I want is 
 1 2 3 4 
 2 3 4 5
 3 4 5 6
 
 Thanks
 
 -
 Yasir H. Kaheil
 Columbia University
 
 -- 
 Dimitris Rizopoulos
 Assistant Professor
 Department of Biostatistics
 Erasmus 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.
 
 


-
Yasir H. Kaheil
Columbia University
-- 
View this message in context: 
http://www.nabble.com/create-sequences-from-two-%22from%22-and-%22to%22-vectors-tp21380194p21380311.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] Extracting File Basename without Extension

2009-01-09 Thread Wacek Kusnierczyk

 Duncan Murdoch wrote:
   

 I'm curious about something: does file extension have a standard
 definition?  Most (all?  I haven't tried them all) of the solutions
 presented in this thread would return an empty string for the plain
 base if given the filename .bashrc.
 


right;  there's a straightforward fix to my solution that accounts for
cases such as '.bashrc':

names = c(foo.bar, .zee)
sub((.+)[.][^.]+$, \\1, names)

you could also use a lookbehind if possible (not in r, afaik).

vQ

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


Re: [R] Extracting File Basename without Extension

2009-01-09 Thread Wacek Kusnierczyk
Rau, Roland wrote:

 P.S. Any suggestions how to become more proficient with regular
 expressions? The O'Reilly book (Mastering...)? Whenever I tried
 anything more complicated than basic usage (things like ^ $ * . ) in R,
 I was way faster to write a new function (like above) instead of finding
 a regex solution.
   

the book you mention is good.
you may also consider http://www.regular-expressions.info/

regexes are usually well explained with lots of examples in perl books.

 By the way: it might be still possible to *write* regular expressions,
 but what about code re-use? Are there people who can easily *read*
 complicated regular expressions?
   


in some cases it is possible to write regular expressions in a way that
facilitates reading them by a human.  in perl, for example, you can use
so-called readable regexes:

/
   (.+)# match and remember at least one arbitrary character
   [.] # match a dot
   [^.]+ # match at least one non-dot character
   $  # end of string anchor
/x;

you can also use within regex comments:

/(.+)(?# one or more chars)[.](?# a dot)[^.]+(?# one or more
non-dots)$(?# end of string)/


nothing of the sorts in r, however.

vQ

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


Re: [R] ftp connections for uploading files

2009-01-09 Thread Duncan Temple Lang


Hi Thomas

 Rather than getting into the details of libcurl options
which are quite general and very flexible, I thought
it was easier to write an explicit ftpUpload() function
that takes care of the details.

You need a new version of the package (as it contains the function and
a small change to the C code), but I don't have the time to build the 
Windows version for the next few days.


The function can be used as

  ftpUpload(path/to/file, ftp://server/path/to/target/file;,
 userpwd = login:password)

and you can deal with contents in memory too rather than from a file.


 HTH,
   D.

Thomas Loridan wrote:

Thanks a lot Duncan

Sorry to insist with my questions but I am very lost with these Rcurl
commands...
could you point out the few ones I need to set up an ftp connection
and just upload a file ?

Greatly appreciated

Thomas

2009/1/8 Duncan Temple Lang dun...@wald.ucdavis.edu:


Prof Brian Ripley wrote:

Try system() with curl or a decent ftp client (I don't see that package
RCurl covers this, but it might despite its description only mentioning
HTTP).

It does support FTP, and all of the protocols that are supported in
the installed libcurl, so it depends the configuration options for libcurl
itself.

The protocols it handles can be found via the curlVersion() function, e.g.


curlVersion()

$age
[1] 3

$version
[1] 7.16.3

$vesion_num
[1] 462851

$host
[1] powerpc-apple-darwin9.0

$features
   ipv6  ssl libz ntlm gssnegotiate largefile
  148   16   32   512

$ssl_version
[1]  OpenSSL/0.9.7l

$ssl_version_num
[1] 0

$libz_version
[1] 1.2.3

$protocols
[1] tftp   ftptelnet dict   ldap   http   file   https
[9] ftps

$ares
[1] 

$ares_num
[1] 0

$libidn
[1] 



sessionInfo()
R version 2.9.0 Under development (unstable) (2008-09-27 r46576)
i386-apple-darwin9.5.0

locale:
C

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

other attached packages:
[1] ROOXML_0.1-0Rcompression_0.4-0  RGoogleDocs_0.2-0
[4] SVGAnnotation_0.1-0 lattice_0.17-15 RCurl_0.92-0
[7] XML_1.99-0  RTools_0.1-0bitops_1.0-4

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




 From 'man curl'

  curl offers a busload of useful tricks like proxy support, user authen-
  tication,  ftp upload, HTTP post, SSL connections, cookies, file trans-
  fer resume and more. As you will see below, the amount of features will
  make your head spin!

Ftp protocols (and there are more than one) are fiendishly complicated,
especially if proxies are involved.

BTW, this is yet another case where knowing your OS would have helped give
a more precise answer. See the posting guide.

On Thu, 8 Jan 2009, Thomas Loridan wrote:


Hi all,

I would like to upload some plots I create wth R via ftp or something
similar but I don t really understand which command/syntax I should
use:
should I go for  make.socket + write.socket or try and create
environment variables like frp_proxy_user and then ftp my files? how?

many thanks for your help

Thomas

--
Thomas Loridan
King's College email: thomas.lori...@kcl.ac.uk
webpage:http://geography.kcl.ac.uk/micromet/tloridan/index.htm

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

2009-01-09 Thread John Fox
Dear Barry,

In Dante's Divine Comedy the sequels were the Purgatorio and the Paradiso;
the analogy suggests that there may be a way out of R Hell (and actually
Patrick provides the way out right in his Inferno -- thanks Patrick!).

Regards,
 John


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On
 Behalf Of Barry Rowlingson
 Sent: January-09-09 3:12 PM
 To: Duncan Murdoch
 Cc: roger koenker; r-h...@stat.math.ethz.ch; Patrick Burns
 Subject: Re: [R] The R Inferno
 
 2009/1/9 Duncan Murdoch murd...@stats.uwo.ca:
 
  Which he well deserves -- it's good advice, and a fun read too.
 
  I'm looking forward to the sequel - Shakespeare perhaps?
 as.YouLike(it)? Much Ado About NULL? Night[12] | What(You.Will)?
 
 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-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Extracting File Basename without Extension

2009-01-09 Thread Gabor Grothendieck
On Fri, Jan 9, 2009 at 4:20 PM, Wacek Kusnierczyk
waclaw.marcin.kusnierc...@idi.ntnu.no wrote:

 Duncan Murdoch wrote:


 I'm curious about something: does file extension have a standard
 definition?  Most (all?  I haven't tried them all) of the solutions
 presented in this thread would return an empty string for the plain
 base if given the filename .bashrc.



 right;  there's a straightforward fix to my solution that accounts for
 cases such as '.bashrc':

 names = c(foo.bar, .zee)
 sub((.+)[.][^.]+$, \\1, names)

 you could also use a lookbehind if possible (not in r, afaik).


or:

 sub(.*[.], ., names)
[1] .bar .zee

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

2009-01-09 Thread Dylan Beaudette
Hi,


Subsequent calls to:

conn - dbConnect(PgSQL(), host=localhost, dbname=xxx, user=xxx)
query - dbSendQuery(conn, query_text)
res - dbGetResult(query) 

are resulting in this:

*** glibc detected *** /usr/local/lib/R/bin/exec/R: realloc(): invalid 
pointer: 0x0a605de4 ***
=== Backtrace: =
/lib/i686/cmov/libc.so.6[0xb7cd16b4]
/lib/i686/cmov/libc.so.6(realloc+0x242)[0xb7cd5d12]
/usr/local/pgsql/lib/libpq.so.4(pqCheckOutBufferSpace+0x7c)[0xb780edfe]


# R info
sessionInfo()
R version 2.8.0 (2008-10-20) 
i686-pc-linux-gnu 

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

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

other attached packages:
[1] RdbiPgSQL_1.8.0 Rdbi_1.8.0  lattice_0.17-20


Any ideas?


-- 
Dylan Beaudette
Soil Resource Laboratory
http://casoilresource.lawr.ucdavis.edu/
University of California at Davis
530.754.7341

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


Re: [R] Extracting File Basename without Extension

2009-01-09 Thread Gabor Grothendieck
On Fri, Jan 9, 2009 at 4:28 PM, Wacek Kusnierczyk
waclaw.marcin.kusnierc...@idi.ntnu.no wrote:
 Rau, Roland wrote:

 P.S. Any suggestions how to become more proficient with regular
 expressions? The O'Reilly book (Mastering...)? Whenever I tried
 anything more complicated than basic usage (things like ^ $ * . ) in R,
 I was way faster to write a new function (like above) instead of finding
 a regex solution.


 the book you mention is good.
 you may also consider http://www.regular-expressions.info/

 regexes are usually well explained with lots of examples in perl books.

 By the way: it might be still possible to *write* regular expressions,
 but what about code re-use? Are there people who can easily *read*
 complicated regular expressions?



 in some cases it is possible to write regular expressions in a way that
 facilitates reading them by a human.  in perl, for example, you can use
 so-called readable regexes:

 /
   (.+)# match and remember at least one arbitrary character
   [.] # match a dot
   [^.]+ # match at least one non-dot character
   $  # end of string anchor
 /x;

 you can also use within regex comments:

 /(.+)(?# one or more chars)[.](?# a dot)[^.]+(?# one or more
 non-dots)$(?# end of string)/


 nothing of the sorts in r, however.

Supports that if you begin the regular expression with (?x) and
use perl = TRUE.  See ?regexp

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

2009-01-09 Thread Bhargab Chattopadhyay
Hi,


Can any one please explain why the following code doesn't work? Or can anyone 
suggest an alternative.
Suppose
  x-c(23,67,2,87,9,63,8,2,35,6,91,41,22,3)
   mat-0;
   for(j in 1:length(x))
   {    
  for(i in 1:p)   
   mat[i,j]-x[j]^i;
   }
   Actually I want to have a matrix with p columns such that each column will 
have the elements of  x^(column#).

Thanks in advance.

Bhargab


  
[[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] Calculating p-values from your own distribution as an array

2009-01-09 Thread Greg Snow
Try this (replace the 0:9 with your values):

 distfun - approxfun( c(-Inf,0:9), seq(0,1,length=length(0:9)+1), 
 method='constant', rule=2)
 distfun( c(-1,0,3,3.4,4,12) )


Does that do what you want?

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Stephen Montgomery
 Sent: Friday, January 09, 2009 9:29 AM
 To: r-help@r-project.org
 Subject: [R] Calculating p-values from your own distribution as an
 array
 
 Hi -
 
 If I have a hypothetical distribution as an array
 
 distribution-c(0,1,2,3,4,5,6,7,8,9)
 
 and I want to find the probability there is a value smaller than a new
 value.
 
 new_value-4
 
 (such that I'd get this type of output)
 
 new_value p-value
 4 0.5
 3.4   0.4
 3 0.4
 0 0.1
 -10.0
 
 Thanks for the help, I bet this is really easy... :/
 
 Stephen
 
 
 --
  The Wellcome Trust Sanger Institute is operated by Genome Research
  Limited, a charity registered in England with number 1021457 and a
  company registered in England with number 2742969, whose registered
  office is 215 Euston Road, London, NW1 2BE.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Maintain Spaces and Parentheses in Variable Names

2009-01-09 Thread Greg Snow
You may also want to look at the label function (and friends) from the Hmisc 
package.  This gives a way to use short, correct names for the variables, but 
have a longer, more descriptive label to use in plots.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Cloudy56
 Sent: Friday, January 09, 2009 11:42 AM
 To: r-help@r-project.org
 Subject: Re: [R] Maintain Spaces and Parentheses in Variable Names
 
 
 Thank you very much.  That certainly worked.  Somehow I did not see
 that when
 reading the help file, nor could I find it via Google search so I
 appreciate
 your help!   -- JC
 
 
 Henrique Dallazuanna wrote:
 
  Try this:
 
  read.table(, check.names = FALSE)
 
  On Fri, Jan 9, 2009 at 3:56 PM, Cloudy56 clough.jonat...@gmail.com
  wrote:
 
 
  Is there any way to maintain spaces, slashes, and parentheses in
 variable
  names when reading these into R?
 
  Of course, read.table converts these to periods.  However, I know
 that
  it's
  not strictly illegal to have these characters in variable names as I
 am
  able
  to add them using the variable editor portion of the data
 editor.
 
  I need to batch produce dozens of histograms for reporting purposes
 and
  my
  data is loaded with special characters e.g. Historic Trend (mm/yr)
  Adding Historic.Trend..mm.yr. to my plots is not acceptable for
  reporting
  purposes.  Do I really need to manually label all of my plots each
 time I
  produce them in R or manually change the variable names in the Data
  Editor?
 
  Any help that anyone may be able to provide to allow me to read data
  without
  corrupting my variable labels would be appreciated.  (Forgive me
 if
  this
  is a dumb question, first day in R.)
  --
  View this message in context:
  http://www.nabble.com/Maintain-Spaces-and-Parentheses-in-Variable-
 Names-tp21377255p21377255.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.
 
 
 
 
  --
  Henrique Dallazuanna
  Curitiba-Paraná-Brasil
  25° 25' 40 S 49° 16' 22 O
 
  [[alternative HTML version deleted]]
 
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
 
 --
 View this message in context: http://www.nabble.com/Maintain-Spaces-
 and-Parentheses-in-Variable-Names-tp21377255p21377996.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] create sequences from two from and to vectors

2009-01-09 Thread Greg Snow
Try:

 mapply( seq, from=1:4, to=7:10 )
 [,1] [,2] [,3] [,4]
[1,]1234
[2,]2345
[3,]3456
[4,]4567
[5,]5678
[6,]6789
[7,]789   10

Is that what you want?

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Yasir Kaheil
 Sent: Friday, January 09, 2009 1:43 PM
 To: r-help@r-project.org
 Subject: [R] create sequences from two from and to vectors
 
 
 hi all,
 how can I create sequences that start from a known vector, say x1 and
 end
 with another say x2- also suppose all the sequences will be the same
 length.
 I don't want to use a for loop
 x1-c(1,2,3,4); x2-(3,4,5,6);
 what I want is
 1 2 3 4
 2 3 4 5
 3 4 5 6
 
 Thanks
 
 -
 Yasir H. Kaheil
 Columbia University
 --
 View this message in context: http://www.nabble.com/create-sequences-
 from-two-%22from%22-and-%22to%22-vectors-tp21380194p21380194.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


[R] no subject

2009-01-09 Thread glenn
Very simple questions if anyone can help:

(1) what is the value in saving workspaces, which is offered at every close?
I thought it might save the set up of the GUI but I cant work out what it
does ­ I run a script that loads the packages I need at the start of every
session.
(2) mathematica has a term (%) that when typed means the last returned
value, so% + 1 say would return the last outputted value +1 .is there
an R equivalent please?

Many thanks 

glenn

[[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] Matrix: Problem with the code

2009-01-09 Thread Sarah Goslee
Well, mat doesn't have any dimensions / isn't a matrix, and we don't
know what p is supposed to be. But leaving aside those little details,
do you perhaps want something like this:

  x-c(23,67,2,87,9,63,8,2,35,6,91,41,22,3)
  p - 5
  mat- matrix(0, nrow=p, ncol=length(x))
  for(j in 1:length(x))
  {
  for(i in 1:p)
  mat[i,j]-x[j]^i
  }

Two notes: I didn't try it out, and if that's what you want rather
than a toy example
of a larger problem, there are more elegant ways to do it in R.

Sarah

On Fri, Jan 9, 2009 at 6:42 PM, Bhargab Chattopadhyay
bharga...@yahoo.com wrote:
 Hi,


 Can any one please explain why the following code doesn't work? Or can anyone 
 suggest an alternative.
 Suppose
   x-c(23,67,2,87,9,63,8,2,35,6,91,41,22,3)
mat-0;
for(j in 1:length(x))
{
   for(i in 1:p)
mat[i,j]-x[j]^i;
}
Actually I want to have a matrix with p columns such that each column will 
 have the elements of  x^(column#).

 Thanks in advance.

 Bhargab






-- 
Sarah Goslee
http://www.functionaldiversity.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] no subject

2009-01-09 Thread Sarah Goslee
Hi Glenn,

On Fri, Jan 9, 2009 at 7:20 PM, glenn g1enn.robe...@btinternet.com wrote:
 Very simple questions if anyone can help:

 (1) what is the value in saving workspaces, which is offered at every close?
 I thought it might save the set up of the GUI but I cant work out what it
 does ­ I run a script that loads the packages I need at the start of every
 session.

Saving  a workspace doesn't save the packages you have loaded, but
does save your data in its current state, as well as any sourced functions.
Very useful if you have a bunch of work you don't want to reconstruct, or
a simulation that just took three days to run.

 (2) mathematica has a term (%) that when typed means the last returned
 value, so% + 1 say would return the last outputted value +1 .is there
 an R equivalent please?

I don't think so - you need to assign that value to something to be able
to reuse it.

Sarah

-- 
Sarah Goslee
http://www.functionaldiversity.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.


  1   2   >