Re: [R] RPART - printing full splitting rule number on tree plot

2009-12-14 Thread Prof Brian Ripley

On Mon, 14 Dec 2009, Rebecca O'Leary wrote:


Dear R-users



I am using RPART package to get regression trees.  However having 
trouble getting the text function to put the full splitting rule 
number on the plot, instead to puts it in scientific notation. 
When a covariate has 1e4 or greater number of digits then the 
splitting rule number displayed on the plot is in scientific 
notation.  But print.rpart displays the splitting rules in full.  I 
have tried using digits option in text function but this only alters 
digits of the mean displayed at terminal nodes.  How do I get the 
full splitting rule number displayed on the tree plot?


You change rpart:::labels.rpart, which uses a 'g' format and hence 
uses scientific notation if it is more compact.




Below is an example.



library(rpart)

temp - as.data.frame(cbind(kyphosis, Start2=kyphosis$Start))



temp$Start2 - temp$Start2+1



fit1 - rpart(Age~ Kyphosis +Number + Start2, data=temp)

plot(fit1)

text(fit1, use.n=TRUE, digits=5)

Thanks


Dr Rebecca O'Leary, PhD

Biostatistician
Senior Research Officer
UWA Centre for Child Health Research
Telethon Institute for Child Health Research, 100 Roberts Rd, Subiaco
Perth WA 6008 Australia
Email: role...@ichr.uwa.edu.au
Tel: +61-8-9489 7745
Fax: +61-8-9489 7700

[[alternative HTML version deleted]]


Please send properly formatted text mail without all the blank lines.

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

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


[R] problem with unmatched quotes

2009-12-14 Thread Alfredo Alessandrini
Hi,

I've a problem with unmatched quotes with a bash script within a R script:


 system(awk 'NR2 {FS= 
 ;print$1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12;}' 
 phenology.txt)
Errore: unexpected string constant in system(awk 'NR2 {FS= ;print$1



Alfredo

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

2009-12-14 Thread ruchita gupta
Hello

I need one urgent help
I am trying to fit the Sigmod curve of logistic growth model using NLS
estimation.
But i do not get the R square value in that even after getting the Summary
In that case how to compare the fit for 3 models and find which one is
better fit??

How to get this R Square value when using NLS estimation?

Thanks
Ruchita

[[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] GBM package: Extract coefficients

2009-12-14 Thread Kyle Werner
I am using the gbm package for generalized boosted regression models,
and would like to be able to extract the coefficients produced for
storage in a database.

I am already using R to automatically generate formulas that I can
export to a database and store. For example, I have been using Dr.
Harrell's lrm package to perform logistic regression, e.g.:

output - lrm(outcome~predictor1+predictor2,data=dataset)
cat(output$coefficients)

This allows me to take input (predictor1) from a user, multiply it by
the correctly transformed $coefficient, and to produce a success
probability without having to run R again.

Is it possible to do this with gbm? If not in general, is it perhaps
at least possible to do so in the case where interaction.depth=1
(e.g., no interactions are allowed)?

Thank you for any insight!

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


Re: [R] help: forest plots

2009-12-14 Thread Viechtbauer Wolfgang (STAT)
If you have the bounds of a 95% CI in the form of:

exponential(estimate +/- 1.96*SE)

then it is easy to get the SE back:

SE = (log(UL) - log(LL)) / (2*1.96)

Then supply the estimates and the SEs to the forest() function:

forest(estimate, sei=SE)

You can use:

forest(estimate, sei=SE, transf=exp)

if you want to exponentiate the estimates and CI bounds. Alternatively, you can 
use:

forest(estimate, sei=SE, atransf=exp)

to exponentiate the x-axis values.

Best,

--
Wolfgang Viechtbauerhttp://www.wvbauer.com/
Department of Methodology and StatisticsTel: +31 (0)43 388-2277
School for Public Health and Primary Care   Office Location:
Maastricht University, P.O. Box 616 Room B2.01 (second floor)
6200 MD Maastricht, The Netherlands Debyeplein 1 (Randwyck)


Original Message
From: r-help-boun...@r-project.org
[mailto:r-help-boun...@r-project.org] On Behalf Of Kim Jung Hwa Sent:
Monday, December 14, 2009 05:22 To: C.H.
Cc: r-help@r-project.org
Subject: Re: [R] help: forest plots

 Thanks for this link. It helps, but I have to make lots of forest
 plots and these R scripts are not generic.

 Are you aware of similar functions as forest(), which can take input
 in the form of estimates, lower_limit, upper_limit? Thanks a lot!

 ~Kim

 On Sun, Dec 13, 2009 at 8:12 PM, C.H. chainsawti...@gmail.com wrote:

 This one does required the metafor package.

 http://tables2graphs.com/doku.php?id=04_regression_coefficients



 On Mon, Dec 14, 2009 at 8:13 AM, Kim Jung Hwa
 kimhwamaill...@gmail.com
 wrote:
 Hi All,

 I'm fitting a Poisson regression. And I want to plot 95% Confidence
 Interval of Regression Estimates.

 After coming back to original scale (using following formula):

 exponential(estimate +/- 1.96*SE),

 at best I can get the output in the form of estimates, lower_limit,
 upper_limit values.

 As far I know forest() in metafor package needs input in the form of
 estimates and their variances. In the above case can I still use
 forest()? OR if there exists some other function which takes such
 input and gives forest plots?

 Any help would be highly appreciated,
 Thanks,
 Kim

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


Re: [R] problem with unmatched quotes

2009-12-14 Thread Uwe Ligges

Escape the inner quotes.

Uwe Ligges


Alfredo Alessandrini wrote:

Hi,

I've a problem with unmatched quotes with a bash script within a R script:



system(awk 'NR2 {FS= 
;print$1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12;}' phenology.txt)

Errore: unexpected string constant in system(awk 'NR2 {FS= ;print$1



Alfredo

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


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


Re: [R] R square in NLS-urgent help

2009-12-14 Thread Peter Dalgaard
ruchita gupta wrote:
 Hello
 
 I need one urgent help

The urgency is entirely on your part, and you are not going to get an
answer more quickly by posting several times!

 I am trying to fit the Sigmod curve of logistic growth model using NLS
 estimation.
 But i do not get the R square value in that even after getting the Summary
 In that case how to compare the fit for 3 models and find which one is
 better fit??
 
 How to get this R Square value when using NLS estimation?
 
 Thanks
 Ruchita
 
   [[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.


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


[R] Combinations

2009-12-14 Thread Amelia Livington

Dear R helpers,
 
I am working on the scenario analysis pertaining to various interest rates. In 
this connection I need to form the various combinations as under :
 
Suppose I have two sets A = (a, b, c) and B = (x,y,z)
 
Then I can easily form the cominations as
(ax, ay, az, bx, by, bz, cx, cy, cz)
 
However, if I have say 5 variables, then total no of possible combinations will 
be 3^5 = 243.
Thus, A = (a,b,c), B = (x, y, z), C = (l, m, n), D = (p,q,r), E = (s, t, u). 
Then may be my possble combination will start as (a, x, l, p, s), then next 
combination may be (a, x, l, p, u) and so on. The last combination (243rd in 
this case) may be (c, z, n, r, u) or something like this.
 
In R, is there any way to list all these 3^5 = 243 combinations? 
 
Amelia


  
[[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] Combinations

2009-12-14 Thread baptiste auguie
Hi,

Try this,

apply(expand.grid(letters[1:3], letters[24:26]), 1, paste,collapse=)
[1] ax bx cx ay by cy az bz cz

?expand.grid

HTH,

baptiste

2009/12/14 Amelia Livington amelia_living...@yahoo.com:

 Dear R helpers,

 I am working on the scenario analysis pertaining to various interest rates. 
 In this connection I need to form the various combinations as under :

 Suppose I have two sets A = (a, b, c) and B = (x,y,z)

 Then I can easily form the cominations as
 (ax, ay, az, bx, by, bz, cx, cy, cz)

 However, if I have say 5 variables, then total no of possible combinations 
 will be 3^5 = 243.
 Thus, A = (a,b,c), B = (x, y, z), C = (l, m, n), D = (p,q,r), E = (s, t, u). 
 Then may be my possble combination will start as (a, x, l, p, s), then next 
 combination may be (a, x, l, p, u) and so on. The last combination (243rd in 
 this case) may be (c, z, n, r, u) or something like this.

 In R, is there any way to list all these 3^5 = 243 combinations?

 Amelia



        [[alternative HTML version deleted]]


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



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


[R] Why doesnot Rscript work ?

2009-12-14 Thread z_axis

%cat stock.R
#! /usr/local/bin/Rscript

args - commandArgs(TRUE)
args

x - read.csv(000301.csv)
matplot(x[,1],x[,-1],type=l)
#q(save=no)

%Rscript stock.R 000301.csv
[1] 000301.csv
matplot doesnot draw anything(no drawing window).

Howeve, in R, source works great!
source(stock.R)

Sincerely!

-- 
View this message in context: 
http://n4.nabble.com/Why-doesnot-Rscript-work-tp963418p963418.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] Combinations

2009-12-14 Thread Romain Francois

On 12/14/2009 10:50 AM, baptiste auguie wrote:


Hi,

Try this,

apply(expand.grid(letters[1:3], letters[24:26]), 1, paste,collapse=)
[1] ax bx cx ay by cy az bz cz


This will be faster, as it takes advantage of the vectorized paste:

cpaste - function(...) paste(..., sep =  )
do.call( cpaste, expand.grid(letters[1:3], letters[24:26]) )

Romain

 system.time( do.call( cpaste, expand.grid(letters[1:26], 
letters[1:26]) ) )

   user  system elapsed
  0.002   0.000   0.002
 system.time( apply(expand.grid(letters[1:26], letters[1:26]), 1, 
paste,collapse=) )

   user  system elapsed
  0.015   0.000   0.018

Does not make too much difference on the OP example:

glue - function( ... ){
  cpaste - function(...) paste(..., sep =  )
  do.call( cpaste, do.call( expand.grid, list(...) ) )
}

GLUE - function(...){
apply( do.call( expand.grid, list(...) ), 1, paste, collapse =  )
}


system.time( glue( A = c(a,b,c), B = c(x, y, z), C = c(l, 
m, n), D = c(p,q,r), E = c(s, t, u) ) )

   user  system elapsed
  0.002   0.000   0.002
 system.time( GLUE( A = c(a,b,c), B = c(x, y, z), C = 
c(l, m, n), D = c(p,q,r), E = c(s, t, u) ) )

   user  system elapsed
  0.008   0.000   0.008




?expand.grid

HTH,

baptiste

2009/12/14 Amelia Livingtonamelia_living...@yahoo.com:


Dear R helpers,

I am working on the scenario analysis pertaining to various interest rates. In 
this connection I need to form the various combinations as under :

Suppose I have two sets A = (a, b, c) and B = (x,y,z)

Then I can easily form the cominations as
(ax, ay, az, bx, by, bz, cx, cy, cz)

However, if I have say 5 variables, then total no of possible combinations will 
be 3^5 = 243.
Thus, A = (a,b,c), B = (x, y, z), C = (l, m, n), D = (p,q,r), E = (s, t, u). 
Then may be my possble combination will start as (a, x, l, p, s), then next 
combination may be (a, x, l, p, u) and so on. The last combination (243rd in 
this case) may be (c, z, n, r, u) or something like this.

In R, is there any way to list all these 3^5 = 243 combinations?

Amelia




--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://tr.im/HlX9 : new package : bibtex
|- http://tr.im/Gq7i : ohloh
`- http://tr.im/FtUu : new package : highlight

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


Re: [R] Why doesnot Rscript work ?

2009-12-14 Thread Romain Francois

Hi,

Rscript is meant for non-interactive use, so the default device is not 
the same as when you run R.


If you really want a window, open it yourself by calling the appropriate 
function (X11, windows, ... ) or reset the device option to whichever 
device you want to use, but it will disappear at the end of the script, 
so not very interesting.


You probably should open a png device or something and then write the 
grap there.


See ?png, ?pdf, ?X11, ?options, ?Rscript

Romain

On 12/14/2009 10:59 AM, z_axis wrote:

%cat stock.R
#! /usr/local/bin/Rscript

args- commandArgs(TRUE)
args

x- read.csv(000301.csv)
matplot(x[,1],x[,-1],type=l)
#q(save=no)

%Rscript stock.R 000301.csv
[1] 000301.csv
matplot doesnot draw anything(no drawing window).

Howeve, in R, source works great!

source(stock.R)


Sincerely!




--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://tr.im/HlX9 : new package : bibtex
|- http://tr.im/Gq7i : ohloh
`- http://tr.im/FtUu : new package : highlight

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


[R] R 2.10.1 is released

2009-12-14 Thread Peter Dalgaard
R-2.10.1.tar.gz was built a short while ago.

This is a maintenance release and fixes a number of mostly minor issues.

See the full list of changes below.

You can get it from

http://cran.r-project.org/src/base/R-2/R-2.10.1.tar.gz

or wait for it to be mirrored at a CRAN site nearer to you. Binaries
for various platforms will appear in due course.


For the R Core Team

Peter Dalgaard


These are the md5sums for the freshly created files, in case you wish
to check that they are uncorrupted:

70447ae7f2c35233d3065b004aa4f331  INSTALL
433182754c05c2cf7a04ad0da474a1d0  README
4f004de59e24a52d0f500063b4603bcb  OONEWS
ff4bd9073ef440b1eb43b1428ce96872  ONEWS
08687cc1d9e5bb23875c1182f9f9cb2d  NEWS
d80a5c5808f038b36f79d8f0defaa0b9  THANKS
070cca21d9f8a6af15f992edb47a24d5  AUTHORS
a6f89e2100d9b6cdffcea4f398e37343  COPYING.LIB
eb723b61539feef013de476e68b5c50a  COPYING
020479f381d5f9038dcb18708997f5da  RESOURCES
4219bfcf875f995b84e5aebb1e02f3a5  FAQ
75f8b7e875b846ea96a4c6cc0abc00a4  R-2.10.1.tar.gz
75f8b7e875b846ea96a4c6cc0abc00a4  R-latest.tar.gz



Here is the relevant part of the NEWS file:

CHANGES IN R VERSION 2.10.1

NEW FEATURES

o   The PCRE library has been updated to version 8.00.

o   R CMD INSTALL has new options --no-R, --no-libs, --no-data,
--no-help, --no-demo, --no-exec, and --no-inst to suppress
installation of the specified part of the package.  These are
intended for special purposes (e.g. building a database
of help pages without fully installing all packages).

o   The documented line-length limit of 4095 bytes when reading
from the console now also applies also to parse(file=)
(which previously had a limit of around 1024 bytes).

o   A Bioconductor mirror can be set for use by setRepositories()
via the option BioC_mirror, e.g. the European mirror can be
selected by
options(BioC_mirror=http://bioconductor.statistik.tu-dortmund.de;)

o   Double-clicking in a tk_select.list() list box now selects the
item and closes the list box (as happens on the Windows
select.list() widget).

INSTALLATION

o   configure will be able to find a usable libtiff in some rare
circumstances where it did not previously (where libtiff
needed to be linked explicitly against -ljpeg).

o   Making refman.pdf works around a problem with the indexing
with hyperref 6.79d and later.

DEPRECATED  DEFUNCT

o   The 'extended' argument is deprecated in strsplit(), grep(),
grepl(), sub(), gsub(), regexpr() and gregexpr() (not just the
value extended = FALSE) and will be removed in R 2.11.0.

BUG FIXES

o   trigamma(x) and other psigamma(x, n) calls are now accurate for
very large abs(x). (PR#14020)

o   [g]sub(perl=FALSE, fixed=FALSE) could use excessive stack space
when used with a very long vector containing some non-ASCII
strings.

o   The default method of weighted.mean(na.rm = TRUE) did not omit
weights for NA observations in 2.10.0.  (PR#14032)

o   [g]regexpr(pattern, fixed = TRUE) returned match positions in
bytes (not characters) in an MBCS locale if 'pattern' was a
single byte.

[g]sub(fixed = TRUE) with a single-byte pattern could
conceivably have matched part of a multibyte character in a
non-UTF-8 MBCS.

o   findLineNum() and setBreakpoint() would sometimes fail if the
specified file was not in the current directory.

o   Package tcltk's demo(tkdensity) was broken in 2.9.0 when demo()
was changed to set par(ask = TRUE).

o   gsub() with backrefs could fail on extremely long strings
(hundreds of thousands of characters) due to integer overflow
in a length calculation.

o   abline(*, untf=TRUE) now uses a better x-grid in log-scale, e.g.,
for plot(c(1,300), c(1,300), log=xy) ; abline(4,1, untf=TRUE).

o   detach/unloadNamespace() arrange to flush the package's
lazyload cache of R objects once the package/namespace is no
longer needed.

o   There have been small fixes to the rendering of help,
e.g. \command is now rendered verbatim (so e.g. -- is not
interpreted, PR#14045).

Also, there are many small changes to help files where the new
converters were not rendering them in the same way as before.

o   available.packages() would fail when run on a repository
with no packages meeting the filtering conditions. (PR#14042)

o   rep(x, times, each = 2) gave invalid results when the 'times'
argument is a vector longer than 'x'.  Reported by Bill Dunlap.

o   An error when unloadNamespace() attempted to run the .onUnload()
function gave an error in the reporting function and so was
not reported properly.

o   Text help rendering did not handle very long input lines
properly.

o   

Re: [R] Why doesnot Rscript work ?

2009-12-14 Thread Prof Brian Ripley

On Mon, 14 Dec 2009, z_axis wrote:



%cat stock.R
#! /usr/local/bin/Rscript

args - commandArgs(TRUE)
args

x - read.csv(000301.csv)
matplot(x[,1],x[,-1],type=l)
#q(save=no)

%Rscript stock.R 000301.csv
[1] 000301.csv
matplot doesnot draw anything(no drawing window).


Incorrect: it plots on the default device for batch use, most likely 
pdf(), so look for a file Rplots.pdf.


You have ignored the posting guide so we do not know your OS.  On a 
Unix-alike, you could explicitly open X11() (quartz() on a Mac), but 
it would be closed again at the end of your script unless you arrange 
to pause the script.



Howeve, in R, source works great!

source(stock.R)


Sincerely!


Real names and the courtesy of a signature block are preferred here.

--
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] Literature analysis

2009-12-14 Thread Schwan
Dear Liviu,

I have tried the Rcmdr GUI but when i load the data, there is no active
data set(this is the error message i got).
Can someone help me further to realize my project?

Thanks


On Fri, 2009-12-11 at 19:05 +, Liviu Andronic wrote:
 Hello
 
 On 12/11/09, Schwan s.s.hosse...@utwente.nl wrote:
   However, I dont know how to tell R that it just should look for e.g.
   author,keywords and year and how to plot these for example on x axis the
   author and y axis the keywords and on z axis the year?
 
 I suggest that you try to get going in R with the Rcmdr GUI. Import
 the data using Data  Import  Text file. Then in Graphics try various
 graphs: Scatterplot, Scatterplot matrix, 3D Scatterplot.
 
 Regards
 Liviu


-- 
---
Hosseiny, MSc. S.S. (Seyed Schwan)
University of Twente Science and Technology
Meander, ME 322
P.O. Box 217 7500 AE Enschede
The Netherlands
Phone +31 534892869
Email:  s.s.hosse...@utwente.n

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

2009-12-14 Thread Bunny, lautloscrew.com
Dear all, 

i have a programming problem that should be simple, though i am stuck with it. 
Please note that this is not a specific geonames problem, though i use it as an 
example - it´s just a basic problem with lapply.

I use the geonames webservices with the R geonames packages which works almost 
smoothly. 
I have a vector of Zipcodes and i want to do a geonames lookup for all of them, 
which should not be a problem. 
Of course i could create a loop for that one, but i think lapply should be 
possible, too. 

The problem is to hand over the variable to the lookup function. 

lapply(zipcodes,GNpostalCodeLookup(postalcode=zipcodes,country=US))

where zipcodes is my vector of zip codes an GNpostalCodeLookup is the function 
that gives back some information like longitude and aptitude etc. Is it 
possible to use lapply in that context or can I just use it in contexts like 
lapply(somelistofvectors, mean) ?

all i´d like to have is some data.frame like this

zip aptlong
1234  xy.xxx.x
1235  ax.x   aa.a

thx in advance

matt
[[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] Printing to PDF in for

2009-12-14 Thread Trafim Vanishek
Hi everybody,

I would like to ask if it is possible using pdf function or some other to
print plots in cycle such that every new plot is on new page.

like this

pdf(file=D:/Plot.pdf,width = 9.25,height=9.25,
family=Helvetica,pointsize=8,bg=white)

for (i in 1:10){

x - seq(1,40,1)
y - 2*x+1+5*rnorm(length(x))

hist(y,freq = FALSE)
plot(density(y))
}

dev.off( )

but the problem is that I have a lot of other code in the cycle which I
don't want to be printed in PDF.

Thanks a lot for the help

[[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] Problem with coeftest using Newey West estimator

2009-12-14 Thread Bender, Marina

Hi,
As I didn't get a response last week, I try it again.

I want to calculate the t- and p-values for a linear model using the Newey West 
estimator.
 I tried this Code and it usually worked just fine:

 oberlm - lm(DYH ~ BIP + Infl + EOil, data=HU_H)
 coeftest(oberlm, NeweyWest(oberlm, lag=2))

t test of coefficients:

  Estimate Std. Error  t value Pr(|t|)
(Intercept)  0.1509950  0.0743832   2.0300 0.179486
BIP -5.5131683  1.2536813  -4.3976 0.048016 *  
Infl-0.0623530  0.0036215 -17.2175 0.003356 ** 
EOil 8.6762170  0.0853216 101.6884 9.67e-05 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 



But then I got an error and I don't understand what it means or even why it 
occurs now:

 oberlm - lm(DYI ~ BIP + BrInv_bw + EOil, data=HU_I)
 coeftest(oberlm, NeweyWest(oberlm, lag=2))
Fehler in if ((dimension  1) | (dimension  n)) stop(wrong embedding 
dimension) : 
  Argument hat Länge 0
Zusätzlich: Warning message:
In log(det(varE[[m - order.min + 1]])) : NaNs wurden erzeugt

Can anyone understand there the problem is?

Best, 
Marina






[[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] Printing to PDF in for

2009-12-14 Thread Romain Francois
See the onefile and file arguments of ?pdf and then do something 
like this :


pdf( file = plot-%03d.pdf, onefile = FALSE, width = 9.25, height = 
9.25, family=Helvetica,pointsize=8,bg=white )


Romain

On 12/14/2009 12:09 PM, Trafim Vanishek wrote:


Hi everybody,

I would like to ask if it is possible using pdf function or some other to
print plots in cycle such that every new plot is on new page.

like this

pdf(file=D:/Plot.pdf,width = 9.25,height=9.25,
family=Helvetica,pointsize=8,bg=white)

for (i in 1:10){

x- seq(1,40,1)
y- 2*x+1+5*rnorm(length(x))

hist(y,freq = FALSE)
plot(density(y))
}

dev.off( )

but the problem is that I have a lot of other code in the cycle which I
don't want to be printed in PDF.

Thanks a lot for the help



--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://tr.im/HlX9 : new package : bibtex
|- http://tr.im/Gq7i : ohloh
`- http://tr.im/FtUu : new package : highlight

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


Re: [R] Literature analysis

2009-12-14 Thread Liviu Andronic
Hello

On 12/14/09, Schwan s.s.hosse...@utwente.nl wrote:
  I have tried the Rcmdr GUI but when i load the data, there is no active
  data set(this is the error message i got).

Can you post the exact error message? Also, could you post a sample
data file (for example, on tinyupload.com) so that we could replicate
what you do?
Liviu

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


Re: [R] Problem with coeftest using Newey West estimator

2009-12-14 Thread Achim Zeileis



On Mon, 14 Dec 2009, Bender, Marina wrote:



Hi,
As I didn't get a response last week, I try it again.

I want to calculate the t- and p-values for a linear model using the Newey West 
estimator.
I tried this Code and it usually worked just fine:


oberlm - lm(DYH ~ BIP + Infl + EOil, data=HU_H)
coeftest(oberlm, NeweyWest(oberlm, lag=2))


t test of coefficients:

 Estimate Std. Error  t value Pr(|t|)
(Intercept)  0.1509950  0.0743832   2.0300 0.179486
BIP -5.5131683  1.2536813  -4.3976 0.048016 *
Infl-0.0623530  0.0036215 -17.2175 0.003356 **
EOil 8.6762170  0.0853216 101.6884 9.67e-05 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1



But then I got an error and I don't understand what it means or even why it 
occurs now:


oberlm - lm(DYI ~ BIP + BrInv_bw + EOil, data=HU_I)
coeftest(oberlm, NeweyWest(oberlm, lag=2))

Fehler in if ((dimension  1) | (dimension  n)) stop(wrong embedding 
dimension) :
 Argument hat L?nge 0
Zus?tzlich: Warning message:
In log(det(varE[[m - order.min + 1]])) : NaNs wurden erzeugt

Can anyone understand there the problem is?


No, the information above is not enough to replicate the problem. I tried:

## packages
library(sandwich)
library(lmtest)

## artificial data
set.seed(123)
HU_I - as.data.frame(matrix(rnorm(40), ncol = 4))
colnames(HU_I) - c(DYI, BIP, BrInv_bw, EOil)

## fit + test
oberlm - lm(DYI ~ BIP + BrInv_bw + EOil, data=HU_I)
coeftest(oberlm, NeweyWest(oberlm, lag=2))

So clearly there is something going on on your side that is non-standard 
in some way, e.g., HU_I or one of its columns might be of a non-standard 
class, there might be too few observations or something else. I don't 
know, I haven't seen the error above.


Look at the posting guide which asks you to provide a small reproducible 
example. Trying to find one, often helps you to get closer to the source 
of the problem. traceback() might also help you to get a (partial) 
solution.


Best,
Z


Best,
Marina






[[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] Error with hgu133a2.db

2009-12-14 Thread Duncan Murdoch

mkna005 mkna005 wrote:

Hi,
I'm trying to get this library working under R2.10.0. I downloaded it
and installed it from zip file. i get the following output.

  

library(hgu133a2.db)


Error in library(hgu133a2.db) : there is no package called 'hgu133a2.db'
  

utils:::menuInstallLocal()


package 'hgu133a2.db' successfully unpacked and MD5 sums checked
  

library(hgu133a2.db)


Loading required package: AnnotationDbi
Loading required package: Biobase

Welcome to Bioconductor

 Vignettes contain introductory material. To view, type
 'openVignette()'. To cite Bioconductor, see
 'citation(Biobase)' and for packages 'citation(pkgname)'.

Loading required package: DBI
Error in fun(...) : could not find function createAnnObjs.HUMANCHIP_DB
In addition: Warning message:
package 'hgu133a2.db' was built under R version 2.7.0 and help will
not work correctly
Please re-install it
Error : .onLoad failed in 'loadNamespace' for 'hgu133a2.db'
Error: package/namespace load failed for 'hgu133a2.db'

Whats the problem and how can I fix it?
  


You tried to install a binary for an obsolete version of R.  Find a 
current build instead, or find the source and build one yourself.


It's likely that if the source is of the same vintage as the file you 
installed that it will need updating.  You might have better luck asking 
on the Bioconductor list.


Duncan Murdoch

Thanks

Christoph

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

2009-12-14 Thread ehcpieterse

Hi,

I have a new workstation and am in the process of moving all my work onto
it. I have also installed R 2.10.0 on the new machine.

I remember changing my R settings of my old machine (R 2.9.1) to connect to
the internet, but I can't remember exactly how. I have tried Sys.getenv(),
but it does not give me the proxy settings I would need to finish the setup
of my new machine.

Does anyone know how to extract the R setup from one machine, to clone
onto another?

Many thanks,
Eduard
-- 
View this message in context: 
http://n4.nabble.com/Connect-to-internet-tp963486p963486.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] how to use Rengine instance to parse R script String

2009-12-14 Thread Gray Calhoun
Hi hobartlul,

  The R-devel mailing list is more appropriate for this sort of
question.  You'll probably get the best response there if you include
your own code (that I assume is not running correctly) and ask about
specific errors you're getting---I don't know that anyone has their
own small, self contained example that it would be easy for them to
send you.

Best,
Gray

On Sun, Dec 13, 2009 at 4:08 PM, hobartlul hobart...@gmail.com wrote:

 Hello everyone

 I am currently developing a web based R script editor. My idea is to pass
 the R script command as a string into the backend , then use the Rengine
 instance to parse the R script command and get the resutls. Do anyone know
 how to use Rengine instance to parse a R script String? if so, could you
 give me a small example (in Java)? i really appreciate.


 --
 View this message in context: 
 http://n4.nabble.com/how-to-use-Rengine-instance-to-parse-R-script-String-tp963194p963194.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.




-- 
Gray Calhoun

Assistant Professor of Economics
Iowa State University

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


Re: [R] Problem with coeftest using Newey West estimator

2009-12-14 Thread Bender, Marina
I give you a reproducable example from my data:
 
## packages
library(sandwich)
library(lmtest)

## data
DYF - c(-0.1164, 0.1164, -0.1164, -0.1287, 0.1287, 0.4127)
BIP - c(0.063, 0.039, 0.057, 0.036, 0.052, 0.033)
AQ - c(-0.3, -0.9, -0.1, 0.2, 0.0, 1.4)
BrInv_t - c(0.044, 0.044, 0.080, 0.042, 0.028, 0.042)
HU_F - as.data.frame(cbind(DYF, BIP, AQ, BrInv_t))

## fit + test
oberlm - lm(DYF ~ BIP + AQ + BrInv_t, data=HU_F)
coeftest(oberlm, vcov = NeweyWest(oberlm, lag=2))

## result of the test I get:
Fehler in if ((dimension  1) | (dimension  n)) stop(wrong embedding 
dimension) : 
  Argument hat Länge 0
Zusätzlich: Warning message:
In log(det(varE[[m - order.min + 1]])) : NaNs wurden erzeugt

But when I test the fit on another sample, it works!
 DYH - c(-0.2451, 0.1287, 0., -0.1287, -0.1443, 0.3895)
 BIP - c(0.063, 0.039, 0.057, 0.036, 0.052, 0.033)
 Infl - c(0.0, -0.9, -3.9, -0.5, 2.1, -3.3)
 EOil - c(-0.0089, 0.0249, -0.0038, -0.0044, 0.0082, 0.0108)
 HU_H - as.data.frame(cbind(DYH, BIP, Infl, EOil))
 oberlm - lm(DYH ~ BIP + Infl + EOil, data=HU_H)
 coeftest(oberlm, vcov = NeweyWest(oberlm, lag=2))

t test of coefficients:

  Estimate Std. Error  t value Pr(|t|)
(Intercept)  0.1509950  0.0743832   2.0300 0.179486
BIP -5.5131683  1.2536813  -4.3976 0.048016 *  
Infl-0.0623530  0.0036215 -17.2175 0.003356 ** 
EOil 8.6762170  0.0853216 101.6884 9.67e-05 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 

-Ursprüngliche Nachricht-
Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Im 
Auftrag von Achim Zeileis
Gesendet: Montag, 14. Dezember 2009 12:42
An: Bender, Marina
Cc: r-help@r-project.org
Betreff: Re: [R] Problem with coeftest using Newey West estimator



On Mon, 14 Dec 2009, Bender, Marina wrote:


 Hi,
 As I didn't get a response last week, I try it again.

 I want to calculate the t- and p-values for a linear model using the Newey 
 West estimator.
 I tried this Code and it usually worked just fine:

 oberlm - lm(DYH ~ BIP + Infl + EOil, data=HU_H)
 coeftest(oberlm, NeweyWest(oberlm, lag=2))

 t test of coefficients:

  Estimate Std. Error  t value Pr(|t|)
 (Intercept)  0.1509950  0.0743832   2.0300 0.179486
 BIP -5.5131683  1.2536813  -4.3976 0.048016 *
 Infl-0.0623530  0.0036215 -17.2175 0.003356 **
 EOil 8.6762170  0.0853216 101.6884 9.67e-05 ***
 ---
 Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1



 But then I got an error and I don't understand what it means or even why it 
 occurs now:

 oberlm - lm(DYI ~ BIP + BrInv_bw + EOil, data=HU_I)
 coeftest(oberlm, NeweyWest(oberlm, lag=2))
 Fehler in if ((dimension  1) | (dimension  n)) stop(wrong embedding 
 dimension) :
  Argument hat L?nge 0
 Zus?tzlich: Warning message:
 In log(det(varE[[m - order.min + 1]])) : NaNs wurden erzeugt

 Can anyone understand there the problem is?

No, the information above is not enough to replicate the problem. I tried:

## packages
library(sandwich)
library(lmtest)

## artificial data
set.seed(123)
HU_I - as.data.frame(matrix(rnorm(40), ncol = 4))
colnames(HU_I) - c(DYI, BIP, BrInv_bw, EOil)

## fit + test
oberlm - lm(DYI ~ BIP + BrInv_bw + EOil, data=HU_I)
coeftest(oberlm, NeweyWest(oberlm, lag=2))

So clearly there is something going on on your side that is non-standard 
in some way, e.g., HU_I or one of its columns might be of a non-standard 
class, there might be too few observations or something else. I don't 
know, I haven't seen the error above.

Look at the posting guide which asks you to provide a small reproducible 
example. Trying to find one, often helps you to get closer to the source 
of the problem. traceback() might also help you to get a (partial) 
solution.

Best,
Z

 Best,
 Marina






   [[alternative HTML version deleted]]



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

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


[R] Determining the correlation coefficient?

2009-12-14 Thread Anja Mohorko
Hello, I need your help! Probably the answer is quite easy, but still ...
How can I sample two (or more) vectors of data from a normal distribution so 
they are correlated with an exact value I select (for example pearson's r = 
.30)?

Thanks!
James


  
[[alternative HTML version deleted]]

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


Re: [R] how to use Rengine instance to parse R script String

2009-12-14 Thread Romain Francois

On 12/14/2009 01:35 PM, Gray Calhoun wrote:


Hi hobartlul,

   The R-devel mailing list is more appropriate for this sort of
question.


Slightly, but the one mailing list where the question actually fits is 
this one : 
http://mailman.rz.uni-augsburg.de/mailman/listinfo/stats-rosuda-devel



You'll probably get the best response there if you include
your own code (that I assume is not running correctly) and ask about
specific errors you're getting


please


---I don't know that anyone has their
own small, self contained example that it would be easy for them to
send you.

Best,
Gray

On Sun, Dec 13, 2009 at 4:08 PM, hobartlulhobart...@gmail.com  wrote:


Hello everyone

I am currently developing a web based R script editor. My idea is to pass
the R script command as a string into the backend , then use the Rengine
instance to parse the R script command and get the resutls. Do anyone know
how to use Rengine instance to parse a R script String? if so, could you
give me a small example (in Java)? i really appreciate.



--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://tr.im/HlX9 : new package : bibtex
|- http://tr.im/Gq7i : ohloh
`- http://tr.im/FtUu : new package : highlight

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


Re: [R] Problem with coeftest using Newey West estimator

2009-12-14 Thread Achim Zeileis

On Mon, 14 Dec 2009, Bender, Marina wrote:


I give you a reproducable example from my data:


One of my suspicion's was correct: too few data.

You have 6 observations with which you estimate 4 regression coefficients. 
That's already questionable. But then, to obtain the standard errors, you 
want to prewhite the estimating functions (= fitting a VAR(1) to the 
4-dimensional series of length 6) and finally apply a kernel smoother to 
the prewhitened estimating functions to obtain the 4 standard errors.


In short: This is far too complex for the amount of data you have and 
should not have been employed in the first place.


The explanation for the error message you see is: The problems above lead 
to numerical instabilities which produce a determinant of about -7e-17 
which should be = 0. This happens in ar.ols() (so not in NeweyWest()). 
I'll send an e-mail to R-devel about this so that a more useful error 
message can be thrown in the future.


Best,
Z


## packages
library(sandwich)
library(lmtest)

## data
DYF - c(-0.1164, 0.1164, -0.1164, -0.1287, 0.1287, 0.4127)
BIP - c(0.063, 0.039, 0.057, 0.036, 0.052, 0.033)
AQ - c(-0.3, -0.9, -0.1, 0.2, 0.0, 1.4)
BrInv_t - c(0.044, 0.044, 0.080, 0.042, 0.028, 0.042)
HU_F - as.data.frame(cbind(DYF, BIP, AQ, BrInv_t))

## fit + test
oberlm - lm(DYF ~ BIP + AQ + BrInv_t, data=HU_F)
coeftest(oberlm, vcov = NeweyWest(oberlm, lag=2))

## result of the test I get:
Fehler in if ((dimension  1) | (dimension  n)) stop(wrong embedding 
dimension) :
 Argument hat Länge 0
Zusätzlich: Warning message:
In log(det(varE[[m - order.min + 1]])) : NaNs wurden erzeugt

But when I test the fit on another sample, it works!

DYH - c(-0.2451, 0.1287, 0., -0.1287, -0.1443, 0.3895)
BIP - c(0.063, 0.039, 0.057, 0.036, 0.052, 0.033)
Infl - c(0.0, -0.9, -3.9, -0.5, 2.1, -3.3)
EOil - c(-0.0089, 0.0249, -0.0038, -0.0044, 0.0082, 0.0108)
HU_H - as.data.frame(cbind(DYH, BIP, Infl, EOil))
oberlm - lm(DYH ~ BIP + Infl + EOil, data=HU_H)
coeftest(oberlm, vcov = NeweyWest(oberlm, lag=2))


t test of coefficients:

 Estimate Std. Error  t value Pr(|t|)
(Intercept)  0.1509950  0.0743832   2.0300 0.179486
BIP -5.5131683  1.2536813  -4.3976 0.048016 *
Infl-0.0623530  0.0036215 -17.2175 0.003356 **
EOil 8.6762170  0.0853216 101.6884 9.67e-05 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

-Ursprüngliche Nachricht-
Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Im 
Auftrag von Achim Zeileis
Gesendet: Montag, 14. Dezember 2009 12:42
An: Bender, Marina
Cc: r-help@r-project.org
Betreff: Re: [R] Problem with coeftest using Newey West estimator



On Mon, 14 Dec 2009, Bender, Marina wrote:



Hi,
As I didn't get a response last week, I try it again.

I want to calculate the t- and p-values for a linear model using the Newey West 
estimator.
I tried this Code and it usually worked just fine:


oberlm - lm(DYH ~ BIP + Infl + EOil, data=HU_H)
coeftest(oberlm, NeweyWest(oberlm, lag=2))


t test of coefficients:

 Estimate Std. Error  t value Pr(|t|)
(Intercept)  0.1509950  0.0743832   2.0300 0.179486
BIP -5.5131683  1.2536813  -4.3976 0.048016 *
Infl-0.0623530  0.0036215 -17.2175 0.003356 **
EOil 8.6762170  0.0853216 101.6884 9.67e-05 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1



But then I got an error and I don't understand what it means or even why it 
occurs now:


oberlm - lm(DYI ~ BIP + BrInv_bw + EOil, data=HU_I)
coeftest(oberlm, NeweyWest(oberlm, lag=2))

Fehler in if ((dimension  1) | (dimension  n)) stop(wrong embedding 
dimension) :
 Argument hat L?nge 0
Zus?tzlich: Warning message:
In log(det(varE[[m - order.min + 1]])) : NaNs wurden erzeugt

Can anyone understand there the problem is?


No, the information above is not enough to replicate the problem. I tried:

## packages
library(sandwich)
library(lmtest)

## artificial data
set.seed(123)
HU_I - as.data.frame(matrix(rnorm(40), ncol = 4))
colnames(HU_I) - c(DYI, BIP, BrInv_bw, EOil)

## fit + test
oberlm - lm(DYI ~ BIP + BrInv_bw + EOil, data=HU_I)
coeftest(oberlm, NeweyWest(oberlm, lag=2))

So clearly there is something going on on your side that is non-standard
in some way, e.g., HU_I or one of its columns might be of a non-standard
class, there might be too few observations or something else. I don't
know, I haven't seen the error above.

Look at the posting guide which asks you to provide a small reproducible
example. Trying to find one, often helps you to get closer to the source
of the problem. traceback() might also help you to get a (partial)
solution.

Best,
Z


Best,
Marina






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

Re: [R] Determining the correlation coefficient?

2009-12-14 Thread Liviu Andronic
Hello

On 12/14/09, Anja Mohorko nekostrg...@yahoo.com wrote:
 Hello, I need your help! Probably the answer is quite easy, but still ...
  How can I sample two (or more) vectors of data from a normal distribution so 
 they are correlated with an exact value I select (for example pearson's r = 
 .30)?


require(MASS)
Sigma - matrix(c(10,3,3,2),2,2)
Sigma
mvrnorm(n=1000, rep(0, 2), Sigma)

Liviu

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


Re: [R] Literature analysis

2009-12-14 Thread Schwan
I have uploaded the csv file here:

http://s000.tinyupload.com/?file_id=79349565739733953435

It contains the citations, which I generated from the bibtex file.
The exact error message is:


[2] ERROR:  
  more columns than column names

A screenshot of the Rcmd is located here:

http://s000.tinyupload.com/?file_id=82322752628856954474





On Mon, 2009-12-14 at 11:37 +, Liviu Andronic wrote:
 Hello
 
 On 12/14/09, Schwan s.s.hosse...@utwente.nl wrote:
   I have tried the Rcmdr GUI but when i load the data, there is no active
   data set(this is the error message i got).
 
 Can you post the exact error message? Also, could you post a sample
 data file (for example, on tinyupload.com) so that we could replicate
 what you do?
 Liviu


-- 
---
Hosseiny, MSc. S.S. (Seyed Schwan)
University of Twente Science and Technology
Meander, ME 322
P.O. Box 217 7500 AE Enschede
The Netherlands
Phone +31 534892869
Email:  s.s.hosse...@utwente.n

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

2009-12-14 Thread tonitogomez

Dear R Users,

Do you know whether is possible to call R code from within STATA and how to
do it?


Also, do you know whether is there any way of doing the other way round,
i.e. calling STATA from within R (possibly in a similar way that is possible
to call WinBUGS from within R using the function Bugs)??

Thanks,
Manuel 
-- 
View this message in context: 
http://n4.nabble.com/Calling-R-code-from-within-STATA-tp963555p963555.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] rpart - classification and regression trees (CART)

2009-12-14 Thread Terry Therneau
When two variables have exactly the same figure of merit, they will be
listed in the output in the same order in which they appeared in your
model statement.  
   Terry Therneau

-- begin inclusion ---
I had a question regarding the rpart command in R.  I used seven
continuous
predictor variables in the model and the variable called TB122 was
chosen
for the first split.  But in looking at the output, there are 4
variables
that improve the predicted membership equally (TB122, TB139, TB144, and
TB118) - output pasted below.

Node number 1: 268 observations,complexity param=0.6
  predicted class=0  expected loss=0.3
class counts:   19771
   probabilities: 0.735 0.265 
  left son=2 (188 obs) right son=3 (80 obs)
  Primary splits:
  TB122  80  to the left,  improve=50, (0 missing)
  TB139  90  to the left,  improve=50, (0 missing)
  TB144  90  to the left,  improve=50, (0 missing)
  TB118  90  to the left,  improve=50, (0 missing)
  TB129  100 to the left,  improve=40, (0 missing)

--- end inclusion ---

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


Re: [R] Non-linear Weibull model for aggregated parasite data

2009-12-14 Thread Terry Therneau
 I am trying to fit a non-linear model for a parasite dataset.
Initially, I ...

 The survreg() function will fit a weibull distribution.  It has the
further ability to include censored data, a facility you don't need.
library(survival)
fit - survreg(Surv(coccidiaopg) ~ age + year + sex*season, data=...

One day I should update it so that if there is no censoring then the
Surv() wrapper is not required.  Also, see the examples in the ?survreg
documentation for comments on shape and scale.  This routine uses a
location-scale parameterization which is different than rweibull.

Terry Therneau

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


Re: [R] Literature analysis

2009-12-14 Thread Erich Neuwirth
The screenshot shows your error.
Just have a look at the error message in the bottom part of the window.
Your csv file has more columns than column names.


On Dec 14, 2009, at 2:42 PM, Schwan wrote:

 I have uploaded the csv file here:
 
 http://s000.tinyupload.com/?file_id=79349565739733953435
 
 It contains the citations, which I generated from the bibtex file.
 The exact error message is:
 
 
 [2] ERROR:  
  more columns than column names
 
 A screenshot of the Rcmd is located here:
 
 http://s000.tinyupload.com/?file_id=82322752628856954474
 
 
 
 
 
 On Mon, 2009-12-14 at 11:37 +, Liviu Andronic wrote:
 Hello
 
 On 12/14/09, Schwan s.s.hosse...@utwente.nl wrote:
 I have tried the Rcmdr GUI but when i load the data, there is no active
 data set(this is the error message i got).
 
 Can you post the exact error message? Also, could you post a sample
 data file (for example, on tinyupload.com) so that we could replicate
 what you do?
 Liviu
 
 
 -- 
 ---
 Hosseiny, MSc. S.S. (Seyed Schwan)
 University of Twente Science and Technology
 Meander, ME 322
 P.O. Box 217 7500 AE Enschede
 The Netherlands
 Phone +31 534892869
 Email:  s.s.hosse...@utwente.n
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Literature analysis

2009-12-14 Thread Liviu Andronic
On 12/14/09, Schwan s.s.hosse...@utwente.nl wrote:
  [2] ERROR:
   more columns than column names

I looked at the data and there is a column name called ISBN#. Try to
remove # and then import the data.

Liviu

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


Re: [R] Literature analysis

2009-12-14 Thread Romain Francois

Hello,

Sorry to arrive late on this. Did you try the recently uploaded bibtex 
package. It reads a bibtex file into an R list (of class citationList).


So for example : if your posted example lives in biblio.bib for example, 
you can read it like this :


 bib - read.bib( biblio.bib )
 sapply( bib[[1]], function(item) item$title )
[1] Adsorption and Diffusion of VOsup2+/sup  and\nVOsub2/sub 
sup+/sup\n\tacross Cation Membrane for All-Vanadium Redox Flow Battery
[2] Modification of Daramic, microporous separator, for redox\nflow 
battery\n\tapplications


Romain

On 12/11/2009 03:41 PM, Schwan wrote:


They are in Bibtex

For example:

@ARTICLE{adsdifvanadiumcationexchange,
   author = {Jin-qing Chen and Bao-guo Wang and Ji-chu Yang},
   title = {Adsorption and Diffusion of VOsup2+/sup  and
VOsub2/sub  sup+/sup
across Cation Membrane for All-Vanadium Redox Flow Battery},
   journal = {Solvent Extraction and Ion Exchange},
   year = {2009},
   volume = {27},
   pages = {312--327},
   number = {2},
   abstract = {A method based on a selectivity coefficient and the
Nernst-Planck
equation is proposed to determine diffusion coefficients of vanadium
ions across a cation exchange membrane in VOsup2+/sup/Hsup+/sup
and VOsub2/sub  sup+/sup/Hsup+/sup  systems. This simplified
method can be applied to high concentrations of vanadium ions. Three
cation exchange membranes were studied. The logarithmic value of
the selectivity coefficient was linearly dependent on the molar
fraction
of vanadium ions in solution. The diffusion coefficient of vanadium
ions decreased with decreasing water content. The membrane with the
lowest diffusion coefficient was selected as a battery separator
and showed the lowest capacity loss of the studied membranes.},
   issn = {0736-6299},
   publisher = {Taylor \  Francis},
   url = {http://www.informaworld.com/10.1080/07366290802674614}
}

@ARTICLE{Chieng1992,
   author = {Chieng, S.C. and Kazacos, M. and Skyllas-Kazacos, M.},
   title = {Modification of Daramic, microporous separator, for redox
flow battery
applications},
   journal = {Journal of Membrane Science},
   year = {1992},
   volume = {75},
   pages = {81--91},
   number = {1-2},
   month = dec,
   issn = {0376-7388},
   keywords = {Daramic, microporous separator, redox flow cell and
battery},
   owner = {schwan},
   timestamp = {2009.11.30},
   url =
{http://www.sciencedirect.com/science/article/B6TGK-43S71CR-7K/2/06f90d391c0eff0ff5df3f282ad5fe28}
}



On Fri, 2009-12-11 at 15:37 +0100, Gustaf Rydevik wrote:



On Fri, Dec 11, 2009 at 3:04 PM, Schwans.s.hosse...@utwente.nl
wrote:
 Thanks, but how should I put the citation inside a data frame?

 data.frame(first txt file, second txt file...)
 plot (what should I insert here) type=p

 And how should I load the txt files anyway inside the frame?




Can you give an example of a couple of text files? Are they in a
standardised format (i.e. bibTEX or similar)?


/Gustaf

--
Gustaf Rydevik, M.Sci.
tel: +46(0)703 051 451
address:Essingetorget 40,112 66 Stockholm, SE
skype:gustaf_rydevik






--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://tr.im/HlX9 : new package : bibtex
|- http://tr.im/Gq7i : ohloh
`- http://tr.im/FtUu : new package : highlight

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

2009-12-14 Thread Pieter Deleu
Hi!

Something funny happens to me in lnme. I don't know if it's a bug or not.
Here's a short sketch of the problem (you could skip the introduction and
just go to the models):

I'm counting the number of spider webs ( = response variable) along two
rivers, with a two-level treatment: free-flowing and dammed.
There are three field sites (random factor) along each river, and
measurements are done six times (= random factor for repeated measurements).

Webs are counted on four different distances along the river (fixed effect),
with six plots at each distance.

My model looks like this:

*
Model-lme(Webslog1~Treatment*Distance,random=~Week|Uniquesite/Uniqueplot,method=REML)
*

I want to leave out the interaction between Treatment and Distance, so that
would go like this:
*
ModelNoInteraction-lme(Webslog1~Treatment+Distance,random=~Week|Uniquesite/Uniqueplot,method=REML)
*

However, then i get the error message:*
Error in model.frame.default(formula = ~Week + Webslog1 + Treatment +  :
  invalid type (list) for variable 'Distance' *

I first thought that it is for some reason just not allowed to leave out the
interaction. But when i try to run the first model again, i get the same
error message! Therefore i thought the thing could be a bug. The whole thing
looks like this:

*
Model-lme(Webslog1~Treatment*Distance,random=~Week|Uniquesite/Uniqueplot,method=REML)


ModelNoInteraction-lme(Webslog1~Treatment+Distance,random=~Week|Uniquesite/Uniqueplot,method=REML)

Error in model.frame.default(formula = ~Week + Webslog1 + Treatment +  :
  invalid type (list) for variable 'Distance3'


Model-lme(Webslog1~Treatment*Distance,random=~Week|Uniquesite/Uniqueplot,method=REML)

Error in model.frame.default(formula = ~Week + Webslog1 + Treatment +  :
  invalid type (list) for variable 'Distance3'*
**


Someone any idea? Bug or just my poor R skills?

Thanks for having a look at this!

Pieter

[[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] rpart - classification and regression trees (CART)

2009-12-14 Thread Katie N

Actually, that's the first thing I thought too, but they weren't listed in
that order in my model statement (model that I used is below):

fit=rpart(pres ~ TB144 + TB118 + TB129 + TB139 + TB114 + TB131 + TB122,
method=class, data=data8)

Would the selection of the best split when improvement is the same have
anything to do with the Gini Index?  I read on another site that the best
split is determined by the amount of homogeneity (or impurity as measured by
the Gini Index) resulting from a split (more homogeneity is better).  TB122
does have less variability (ie smaller standard deviation around the mean)
than the others, could that be why it was chosen despite having the same
level of merit as the other predictors?





Therneau, Terry M., Ph.D. wrote:
 
 When two variables have exactly the same figure of merit, they will be
 listed in the output in the same order in which they appeared in your
 model statement.  
Terry Therneau
 
 -- begin inclusion ---
 I had a question regarding the rpart command in R.  I used seven
 continuous
 predictor variables in the model and the variable called TB122 was
 chosen
 for the first split.  But in looking at the output, there are 4
 variables
 that improve the predicted membership equally (TB122, TB139, TB144, and
 TB118) - output pasted below.
 
 Node number 1: 268 observations,complexity param=0.6
   predicted class=0  expected loss=0.3
 class counts:   19771
probabilities: 0.735 0.265 
   left son=2 (188 obs) right son=3 (80 obs)
   Primary splits:
   TB122  80  to the left,  improve=50, (0 missing)
   TB139  90  to the left,  improve=50, (0 missing)
   TB144  90  to the left,  improve=50, (0 missing)
   TB118  90  to the left,  improve=50, (0 missing)
   TB129  100 to the left,  improve=40, (0 missing)
 
 --- end inclusion ---
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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://n4.nabble.com/rpart-classification-and-regression-trees-CART-tp962680p963620.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] write.csv and header

2009-12-14 Thread Walther, Alexander
Dear list,

I would like to export a matrix to a TXT-File by using write.csv (not
necessarily). Is there a way to add a header (with additional
informations concerning the project) spanning multiple lines to this
file before the actual data are listed up? Should look like this:



date:
filename:
number of permutations:



data (as a matrix)



Any suggestions? Thnx in advance.


cheers

Alex

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


Re: [R] odfWeave produces output file that OO can't open

2009-12-14 Thread Max Kuhn
Can you:

  - run any of the examples in the package's examples directory
  - provide the results of sessionInfo()
  - tell us what version of OO
  - read the posting guide?

Max

On Sun, Dec 13, 2009 at 2:17 PM, Michael Kubovy kub...@virginia.edu wrote:
 Dear R-helpers,

 I'm trying to learn how to use odfSweave.

 Here is my source file (in /Users/mk/myTeach/2010-1-7720/odfWeave):
 
 Analysis of the iris Data

 Created on \Sexpr{date()}

 loadLibs, echo = FALSE, results = hide=
 # I usually load the libraries first so that any output produced by loading 
 the library does not end up in the document
 library(MASS)
 library(lattice)
 library(grid)
 data(iris)
 @

 This famous (Fisher's or Anderson's) iris data set gives the measurements in 
 centimeters of the variables sepal length and width and petal length and 
 width, respectively, for \Sexpr{dim(iris)[1]/3} flowers from each of 
 \Sexpr{length(levels(iris$Species))} species of iris. The species are 
 \Sexpr{paste(levels(iris$Species), collapse = , )}.

 Here is a bulleted list of the species:
 showOutputList, echo = FALSE, results = xml=
 odfItemize(levels(iris$Species))
 @
 

 With
 
 R version 2.10.0 (2009-10-26)
 x86_64-apple-darwin9.8.0
 locale:
 [1] C/C/en_US/C/C/C
 attached base packages:
 [1] grid      stats     graphics  grDevices datasets  utils     methods
 [8] base
 other attached packages:
 [1] MASS_7.3-4      odfWeave_0.7.10 XML_2.6-0       lattice_0.17-26
 [5] JGR_1.7-0       iplots_1.1-3    JavaGD_0.5-2    rJava_0.8-1
 loaded via a namespace (and not attached):
 [1] Matrix_0.999375-32 lme4_0.999375-32   tools_2.10.0
 
 I run:
 
 odfWeave('simple1.odt','simpleOut.odt')
  Copying  simple1.odt
  Setting wd to  
 /var/folders/TG/TG6nWu2pHYCI-BdWWiyMxU+++TI/-Tmp-//RtmplOpSLO/odfWeave13103539684
  Unzipping ODF file using unzip -o simple1.odt

  Removing  simple1.odt
  Creating a Pictures directory

  Pre-processing the contents
  Sweaving  content.Rnw

  Writing to file content_1.xml
  Processing code chunks ...
    1 : term hide(label=loadLibs)
    2 : term xml(label=showOutputList)

  'content_1.xml' has been Sweaved

  Removing content.xml

  Post-processing the contents
  Removing content.Rnw
  Removing styles.xml
  Renaming styles_2.xml to styles.xml
  Removing extra files

  Packaging file using zip -r simple1.odt .
  Copying  simple1.odt
  Resetting wd
  Removing  
 /var/folders/TG/TG6nWu2pHYCI-BdWWiyMxU+++TI/-Tmp-//RtmplOpSLO/odfWeave13103539684

  Done
 Warning message:
 closing unused connection 3 (content.xml)
 

 When I try to open simpleOut.odt I get: Format error discovered in the file 
 in sub-document content.xml at 22,124(row,col). The file content.xml is 
 empty.




 __
 Professor Michael Kubovy
 University of Virginia
 Department of Psychology
 for mail add:
 P.O.Box 400400
 Charlottesville, VA 22904-4400
 USA
 for FedEx or UPS add:
 Gilmer Hall, Room 102
 McCormick Road
 Charlottesville, VA 22903
 USA
                room    phone
 Office:    B011 +1-434-982-4729
 Lab:        B019        +1-434-982-4751
 Fax:                            +1-434-982-4766
 WWW:    http://www.people.virginia.edu/~mk9y/

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




-- 

Max

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


Re: [R] Bug in lnme package?

2009-12-14 Thread ONKELINX, Thierry
Dear Pieter,

I suppose that you have attached your data.frame and then messed up the
Distance variable. Therefore do not use attach(your.data.frame) but use
the data = your.data.frame argument in your models.

If that does not solve the problem, then send us a reproducible example
of your problem (= models + dummy data). 

HTH,

Thierry




ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek
team Biometrie  Kwaliteitszorg
Gaverstraat 4
9500 Geraardsbergen
Belgium

Research Institute for Nature and Forest
team Biometrics  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 Pieter Deleu
Verzonden: maandag 14 december 2009 16:20
Aan: r-h...@stat.math.ethz.ch
Onderwerp: [R] Bug in lnme package?

Hi!

Something funny happens to me in lnme. I don't know if it's a bug or
not.
Here's a short sketch of the problem (you could skip the introduction
and just go to the models):

I'm counting the number of spider webs ( = response variable) along two
rivers, with a two-level treatment: free-flowing and dammed.
There are three field sites (random factor) along each river, and
measurements are done six times (= random factor for repeated
measurements).

Webs are counted on four different distances along the river (fixed
effect), with six plots at each distance.

My model looks like this:

*
Model-lme(Webslog1~Treatment*Distance,random=~Week|Uniquesite/Uniqueplo
t,method=REML)
*

I want to leave out the interaction between Treatment and Distance, so
that would go like this:
*
ModelNoInteraction-lme(Webslog1~Treatment+Distance,random=~Week|Unique
site/Uniqueplot,method=REML)
*

However, then i get the error message:*
Error in model.frame.default(formula = ~Week + Webslog1 + Treatment +
:
  invalid type (list) for variable 'Distance' *

I first thought that it is for some reason just not allowed to leave out
the interaction. But when i try to run the first model again, i get the
same error message! Therefore i thought the thing could be a bug. The
whole thing looks like this:

*
Model-lme(Webslog1~Treatment*Distance,random=~Week|Uniquesite/Uniqueplo
t,method=REML)


ModelNoInteraction-lme(Webslog1~Treatment+Distance,random=~Week|Uniques
ite/Uniqueplot,method=REML)

Error in model.frame.default(formula = ~Week + Webslog1 + Treatment +  :
  invalid type (list) for variable 'Distance3'


Model-lme(Webslog1~Treatment*Distance,random=~Week|Uniquesite/Uniqueplo
t,method=REML)

Error in model.frame.default(formula = ~Week + Webslog1 + Treatment +  :
  invalid type (list) for variable 'Distance3'*
**


Someone any idea? Bug or just my poor R skills?

Thanks for having a look at this!

Pieter

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

Druk dit bericht a.u.b. niet onnodig af.
Please do not print this message unnecessarily.

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

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


[R] R output

2009-12-14 Thread Manuel Jesús López Rodríguez
Dear all,
I would like to ask you if exists some way of having the results of an R 
instruction (for instance, summary) in a table to copy it directly in Excel.
Thank you very much in advance.
Best wishes!

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


[R] Odp: R square in NLS-urgent help

2009-12-14 Thread Petr PIKAL
Hi

I believe it was answered several times and if I remember correctly R 
squared in nonlinear models is not so simple (from statistical point of 
wiev).
Here you have some insights from help archive, which you could probably 
get as easy as myself if you had used search facilities offered to you on 
CRAN.

I searched  nls r squared 

- Original Message - 
From: Douglas Bates ba...@stat.wisc.edu 
Sent: Wednesday, May 01, 2002 2:40 PM 
Subject: Re: [R] coefficient of determination on a nls regression 
There is a good reason that an nls model fit in R does not provide 
r-squared - r-squared doesn't make sense for a general nls model. 
One way of thinking of r-squared is as a comparison of the residual 
sum of squares for the fitted model to the residual sum of squares for 
a trivial model that consists of a constant only. You cannot 
guarantee that this is a comparison of nested models when dealing with 
an nls model. If the models aren't nested this comparison is not 
terribly meaningful. 
 So the answer is that you probably don't want to do this in the first 
place. 


From: Gabor Grothendieck ggrothendieck_at_gmail.com 
Date: Mon 06 Jun 2005 - 10:22:05 EST
On 6/5/05, James Salsman ja...@bovik.org wrote: 
 Why doesn't nls() produce any kind of R-squared value? In the absence 
 of such information, how are we supposed to compare one fit to another 
 when the y-axis scale changes? 
 
  sm - nls(y ~ SSfpl(x, miny, maxy, midx, grad)) 
  summary(sm) 
 
 Formula: y ~ SSfpl(x, miny, maxy, midx, grad) 
 
 Parameters: 
 Estimate Std. Error t value Pr(|t|) 
 miny -0.5845 4.6104 -0.127 0.90524 
 maxy 7.2680 1.5512 4.686 0.00941 ** 
 midx 16.9187 2.2340 7.573 0.00163 ** 
 grad 1.7283 1.9150 0.903 0.41782 
 --- 
 Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1 
 
 Residual standard error: 1.13 on 4 degrees of freedom 
 
 Correlation of Parameter Estimates: 
 miny maxy midx 
 maxy -0.6654 
 midx 0.8936 -0.3221 
 grad -0.9068 0.8477 -0.6865 
 
One uses anova (which has an anova.nls method) to compare two nls models.

^^

Regards
Petr



r-help-boun...@r-project.org napsal dne 14.12.2009 09:42:51:

 Hello
 
 I need one urgent help
 I am trying to fit the Sigmod curve of logistic growth model using NLS
 estimation.
 But i do not get the R square value in that even after getting the 
Summary
 In that case how to compare the fit for 3 models and find which one is
 better fit??
 
 How to get this R Square value when using NLS estimation?
 
 Thanks
 Ruchita
 
[[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] Repeated Measures Analysis - GLM

2009-12-14 Thread Michael Friendly

To follow up on John's advice:

Start with something like

my.mod - lm(cbind(OpenR1, OpenR2, OpenR3) ~ AgeClass * Treatment, 
data=my.data)


then read ?Anova to see how to specify idata= and idesign= for the 
repeated factor.


hth,
-Michael

John Fox wrote:

Dear Ingo,

One approach would be to use the Anova() function in the car package. See
?Anova and in particular the O'Brien and Kaiser example, which is for a more
complicated repeated-measures design. If you want to get type-III tests
(as opposed to the default type-II tests), be careful with the contrast
coding for the between-subjects factors.

I hope this helps,
 John


John Fox
Senator William McMaster 
  Professor of Social Statistics

Department of Sociology
McMaster University
Hamilton, Ontario, Canada
web: socserv.mcmaster.ca/jfox



-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]

On

Behalf Of protonringe
Sent: December-13-09 11:29 AM
To: r-help@r-project.org
Subject: [R] Repeated Measures Analysis - GLM


Hello to the R world...

I have some problems regarding a GLM - repeated measures analysis.

I want to test overall differences between AgeClass and Treatment (between
subject) with OpenR1+OpenR2+OpenR3 (repeated measures, within subject).

The

table looks kind like this:

AgeClassTreatment   OpenR1  OpenR2  OpenR3
1   1   0   0   12.63
1   1   12.67   3.8345.67
1   1   38.46   65.38   75.21
1   1   14.46   0   17.96
1   2   27.83   47.33   66.38
1   2   15.75   0   10.21
1   2   43.96   41.04   51.88
1   2   52.96   55.54   41.58
1   3   43.13   71.25   82.71
1   3   0.2518.46   27.04
1   3   0.7921.75   68.38
2   1   0   0   0
2   1   0   0   0
2   1   1.1718.75   45.67
2   1   0   0   0
2   1   0   0   49.42
2   2   2.130   26.63
2   2   0   8.1323.88
2   2   2.250   0
2   2   30.96   25.71   10.92
2   3   33.33   30.71   16.63
2   3   0   20.04   14.88
2   3   24.96   0   3.88
.
.
.

I tried several things, for example this:


aov(?~(OpenR1*OpenR2*OpenR3*AgeClass*Treatment)+Error(??/(OpenR1*Ope
n

R2*OpenR3))+(AgeClass*Treatment))

I don't really know what response-variable to use, or what the
subject-variable is

There is no problem to create the model with SPSS, but for my

Diploma-Thesis

in biology i want to do all the statistics with R...

Regards and many thanks in advance

Ingo


--
View this message in context: http://n4.nabble.com/Repeated-Measures-
Analysis-GLM-tp963016p963016.html
Sent from the R help mailing list archive at Nabble.com.

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

http://www.R-project.org/posting-guide.html

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





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

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


Re: [R] write.csv and header

2009-12-14 Thread Patrick Hausmann

Hi Alex,

try this

mfile - c:\\ex01.txt
nperm - 12

sDate - paste(date: , 2009-12-13, sep=)
sFile - paste(filename: , mfile, sep=)
sPerm - paste(number of permutations: , nperm, sep=)

mt - matrix(1:10, 2)

sink(mfile)
  cat(sDate, \n)
  cat(sFile, \n)
  cat(sPerm, \n)
  cat(-, \n\n)
  print(mt)
sink()

Best
Patrick


Walther, Alexander schrieb:

Dear list,

I would like to export a matrix to a TXT-File by using write.csv (not
necessarily). Is there a way to add a header (with additional
informations concerning the project) spanning multiple lines to this
file before the actual data are listed up? Should look like this:



date:
filename:
number of permutations:



data (as a matrix)



Any suggestions? Thnx in advance.


cheers

Alex

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

2009-12-14 Thread Jennifer Young
splendid!

This worked well, but there are two oddities that I can't resolve.

1. In the real data, the baseline is a cumulative probability plot (from
simulations) rather than the straight line.  The panel.lines plots this
curve, but seems to join the first and last points together.
panel.points(x, baseline, type=l) did the same.
I checked that the vector is indeed sorted properly, so I'm not sure why
it should connect the first point to the last.

2. The screens are correctly labeled, but in the wrong order (left to
right, top to bottom: 3,4,1,2). Is this easily corrected?

I've been cowardly avoiding learning xyplot() so thanks for the jumpstart!

 Try this using xyplot.zoo in the zoo package.  We define the baseline
 and a panel function.   The panel function just performs the default
 action to display the graphs and adds the baseline.   The screens
 variable is 1,1,2,2,3,3,4,4.  We create a zoo object from dat and use
 screens to name the columns according to their group.  Finally we call
 xyplot.zoo passing it screens so that the successive columns go in the
 indicated panels and also passing the other items.  See ?xyplot.zoo in
 zoo and ?xyplot in lattice.

 library(zoo)
 library(lattice)

 baseline - 1:nrow(dat)/nrow(dat)
 pnl - function(x, ...) {
   panel.plot.default(x, ...)
   panel.lines(x, baseline, lwd = 2, col = grey(0.5))
 }
 nc - ncol(dat)
 screens - rep(1:(nc/2), each = 2)
 z - zoo(dat)
 colnames(z) - paste(Group, screens)
 xyplot(z, screens = screens , layout = c(2, 2), col = black, lty =
 2, scales = list(y = list(relation = same)), panel = pnl)


 On Fri, Dec 11, 2009 at 10:02 AM, Jennifer Young
 jennifer.yo...@math.mcmaster.ca wrote:
 Hello

 I've created a function to make a plot with multiple pannels from
 columns
 of data that are created in a previous function.  In the example below
 the
 number of columns is 8, giving 4 pannels, but in general it takes data
 with any number of columns and figures out a nice layout.

 The panels all have the same axes, and so I wonder what functions are
 avialable to create axes only on the left and bottom of the whole plot
 rather than each pannel.
 I'd really like a generic way to do this for any number of plots, but
 was
 even having trouble figuring out how to do it manually for this example;
 How are pannels referred to, in a layout context?
 That is, how do I say,

 if(current.pannel==4) {do stuff}

 Here's a simple version of the code.

 baseline - (1:20)/20    #example data
 dat1 - matrix(baseline,20,8)
 dat - dat1+matrix(rnorm(20*8)/30, 20,8)

 nstrat - ncol(dat)
 rows - ceiling(nstrat/4)
 layout(matrix(1:(rows*2), rows, 2, T))
 par(oma=c(4,4,3,1))
 par(mar=c(1,1,0,1))
 for(i in which(1:nstrat%%2!=0)){
    plot(baseline, type=l, col=grey, lwd=2,
            xlab=, ylab=, ylim=c(0,1), xaxt='n', yaxt='n')
    axis(1, labels=F); axis(2, labels=F)
    points(dat[,i], type=l, lty=2)
    points(dat[,i+1], type=l, lty=2)
 }



 Thank you muchly
 Jennifer Young

 PS: I am a subscriber, but can't for the life of me figure out how to
 send
 an email while logged in so that the moderators don't have to take the
 time to read it over.  I always get the please wait while we check it
 over email.  Likely I'm being dumb.

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

2009-12-14 Thread Liviu Andronic
On 12/14/09, Schwan s.s.hosse...@utwente.nl wrote:
  but unfortunately somehow the package bibtex dont want to install
  (actually it installs, but if i follow your instruction:  bib -
  read.bib( /home/schwan/Desktop/science.bib ) I got an Error Message
  which says:  Error: could not find function read.bib

Did you
library(bibtex)

before running the function?
Liviu

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


[R] Odp: R output

2009-12-14 Thread Petr PIKAL
Hi


r-help-boun...@r-project.org napsal dne 14.12.2009 17:09:55:

 Dear all,
 I would like to ask you if exists some way of having the results of an R 

 instruction (for instance, summary) in a table to copy it directly in 
Excel.

What do you mean directly in Excel. If the output is structured like table 
you can use something like

write.table(object, clipboard, sep= \t, row.names=F)

You can copy an output from console just the same way as you use 
copy/paste procedure between Word and Excel.
You can use some other more sophisticated ways (see data import/export 
manual or you can invent your own ways and preferred procedures too.

Regards
Petr


 Thank you very much in advance.
 Best wishes!
 
 Manuel
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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 vectors from lists of lists

2009-12-14 Thread Jennifer Young
This is just the thing.
The former version I would never have guessed, but the function(x) version
is much more intuitive.

Does there exist some section of some manual where these sorts of things
are explained? I find that figuring out how to access parts of output is
the trickiest thing in R.
For instance, it took me ages to figure out that to extract the actual
derivative from the output of x-deriv() you have to use attr(x,
gradient).

Thanks also to David and Benilton, who also replied with the same
solution; I received all 3 responses within 10 minutes of asking the
question!

 Jennifer -
 Does this do what you want?

 v1 = sapply(output,'[[','vec')
 v2 = sapply(output,'[[','other')
 v1
   [,1] [,2]
 [1,]16
 [2,]27
 [3,]38
 [4,]49
 [5,]5   10
 v2
 [1] stuff stuff

 (in more readable form:

 v1 = sapply(output,function(x)x$vec)
 v2 = sapply(output,function(x)x$other))


 Notice that if the objects returned by sapply are not conformable,
 it will return its result in a list.


   - Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
spec...@stat.berkeley.edu



 On Fri, 11 Dec 2009, Jennifer Young wrote:

 Good evening

 I often have as output from simulations a list of various values,
 vectors
 and matrices.
 Supposing that I then run said simulation several times, I often want to
 extract a particular result from each simulation for plotting and,
 ideally, put it in a matrix.

 A simple example

 v1 - 1:5
 v2 - 6:10
 other1 - stuff
 other2 - stuff

 set1 - list(v1,other1)
 names(set1) - c(vec,other)
 set2 - list(v2,other2)
 names(set2) - c(vec,other)

 output - list(set1, set2)


 Is there some form of lapply() that will allow me to extract v1 and v2
 (ie, the $vec elements) from both sets?
 Bonus if I can then put it into a matrix tidily.

 many thanks
 Jennifer Young

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

2009-12-14 Thread Schwan
Thanks,

but unfortunately somehow the package bibtex dont want to install
(actually it installs, but if i follow your instruction:  bib -
read.bib( /home/schwan/Desktop/science.bib ) I got an Error Message
which says:  Error: could not find function read.bib

I already installed the package as root, but this didnt help as well,
also I copied the package inside the Library of R, where all the other
packages are, but also this was not successful.

Any help?

Thanks 
 
 





On Mon, 2009-12-14 at 15:41 +0100, Erich Neuwirth wrote: 
 The screenshot shows your error.
 Just have a look at the error message in the bottom part of the window.
 Your csv file has more columns than column names.
 
 
 On Dec 14, 2009, at 2:42 PM, Schwan wrote:
 
  I have uploaded the csv file here:
  
  http://s000.tinyupload.com/?file_id=79349565739733953435
  
  It contains the citations, which I generated from the bibtex file.
  The exact error message is:
  
  
  [2] ERROR:  
   more columns than column names
  
  A screenshot of the Rcmd is located here:
  
  http://s000.tinyupload.com/?file_id=82322752628856954474
  
  
  
  
  
  On Mon, 2009-12-14 at 11:37 +, Liviu Andronic wrote:
  Hello
  
  On 12/14/09, Schwan s.s.hosse...@utwente.nl wrote:
  I have tried the Rcmdr GUI but when i load the data, there is no active
  data set(this is the error message i got).
  
  Can you post the exact error message? Also, could you post a sample
  data file (for example, on tinyupload.com) so that we could replicate
  what you do?
  Liviu
  
  
  -- 
  ---
  Hosseiny, MSc. S.S. (Seyed Schwan)
  University of Twente Science and Technology
  Meander, ME 322
  P.O. Box 217 7500 AE Enschede
  The Netherlands
  Phone +31 534892869
  Email:  s.s.hosse...@utwente.n
  
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
  
 


-- 
---
Hosseiny, MSc. S.S. (Seyed Schwan)
University of Twente Science and Technology
Meander, ME 322
P.O. Box 217 7500 AE Enschede
The Netherlands
Phone +31 534892869
Email:  s.s.hosse...@utwente.n

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


[R] ggplot : scale_x_datetime issues

2009-12-14 Thread ravi
Dear R users,
My immediate problem is that I do not seem to understand how to use the 
function scale_x_datetime function in ggplot. My deeper problem is that I don’t 
understand the use of the POSIXct class.
 
My data looks like like the following :
T  val
2009-11-04 23:59:57   972.357117 
2009-11-05 00:02:21   969.389221 
2009-11-05 00:04:45   868.817749 
2009-11-05 00:07:09   805.593079 
2009-11-05 00:09:33   928.946106 
2009-11-05 00:11:57   1004.880249   
2009-11-05 00:14:21   969.154846 
2009-11-05 00:16:45   989.090942 
2009-11-05 00:19:09   1009.907837   
2009-11-05 00:21:33   1058.458374   
2009-11-05 00:23:57   1179.298096   
……
…….
2009-11-06 23:57:23   650.345631
 
 
I attempted to code with the following :
 
df-read.table(file=file1,header=TRUE,sep=\t,colClasses=c(character,numeric))
# Could not directly read in the time with the POSIXct class instead of as 
character
t1-as.POSIXct(df$T)
# interested in a specific time frame
# first attempted without the CET in the limits
lim2- c(2009-11-05 12:00:00 CET,2009-11-06 13:00:00 CET)
library(ggplot)
ggplot(data=df,aes(x=T,y=val))+geom_line()+scale_x_datetime(limits=lim2,format=%H)
 
I get the following error message :
#
Error in if (length(range) == 1 || diff(range) == 0) { : 
  missing value where TRUE/FALSE needed
In addition: Warning message:
In get(transform, env = trans, inherits = TRUE)(trans, ...) :
  NAs introduced by coercion
##
I next tried to get a subset of the dataframe with the following :
 
df2-df [df$T2009-11-05 11:57:33 CET  df$T2009-11-06 12:59:57 CET,]
 head(df2)
[1] Tid1 Rok 
0 rows (or 0-length row.names)
 
I don’t seem to understand how I should work with the POSIXct class. And, this 
is just the first step in my analysis (with many more steps pending)..
I will appreciate any and all the help that I can get.
Thanking you,
Ravi

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


Re: [R] Determining the correlation coefficient?

2009-12-14 Thread Ravi Varadhan

If you want the samples to have exact correlation that you have specified, then 
you must specify the `empirical=TRUE' option:

mvrnorm(n=1000, rep(0, 2), Sigma, empirical=TRUE)

Ravi.


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

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


- Original Message -
From: Liviu Andronic landronim...@gmail.com
Date: Monday, December 14, 2009 8:52 am
Subject: Re: [R] Determining the correlation coefficient?
To: Anja Mohorko nekostrg...@yahoo.com
Cc: r-help@r-project.org


 Hello
 
 On 12/14/09, Anja Mohorko nekostrg...@yahoo.com wrote:
  Hello, I need your help! Probably the answer is quite easy, but 
 still ...
   How can I sample two (or more) vectors of data from a normal 
 distribution so they are correlated with an exact value I select (for 
 example pearson's r = .30)?
 
 
 require(MASS)
 Sigma - matrix(c(10,3,3,2),2,2)
 Sigma
 mvrnorm(n=1000, rep(0, 2), Sigma)
 
 Liviu
 
 __
 R-help@r-project.org mailing list
 
 PLEASE do read the posting guide 
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Bug in lnme package?

2009-12-14 Thread Ben Bolker
Pieter Deleu pieterdeleu at gmail.com writes:

 
 Hi!
 
 Something funny happens to me in lnme. I don't know if it's a bug or not.
 Here's a short sketch of the problem (you could skip the introduction and
 just go to the models):
 
 I'm counting the number of spider webs ( = response variable) along two
 rivers, with a two-level treatment: free-flowing and dammed.
 There are three field sites (random factor) along each river, and
 measurements are done six times (= random factor for repeated measurements).
 
 Webs are counted on four different distances along the river (fixed effect),
 with six plots at each distance.
 
 My model looks like this:
 
 *
 Model-lme(Webslog1~Treatment*Distance,
   random=~Week|Uniquesite/Uniqueplot,method=REML)
 *

[snip]

A few suggestions:

(1) please give us a reproducible example -- either include
your data (dput() is one way to dump it in a useful form),
or post it somewhere, or make up a small data set that
demonstrates the same problem.

(2) it would probably be best to repost this question (with
reproducible example) on r-sig-mixed-mod...@lists.r-project.org ,
which is specially geared toward mixed model questions.

(3) you may not have your model specification
quite right.  For example, do you really intend to model
a linear increase/decrease in the response as a function of
week that varies across plots  sites?  (If so, you 
should also probably consider a fixed effect of Week).
Or do you simply want to allow plots/sites to be 
different (in which case you would say ~1|Uniquesite/Uniqueplot)?

  By the way, it's nlme not lnme

  Ben Bolker

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

2009-12-14 Thread stephen sefick
?write.table()

2009/12/14 Manuel Jesús López Rodríguez mjlr1...@yahoo.es:
 Dear all,
 I would like to ask you if exists some way of having the results of an R 
 instruction (for instance, summary) in a table to copy it directly in Excel.
 Thank you very much in advance.
 Best wishes!

 Manuel
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] how can generate from trunceted gamma distribution in R ?

2009-12-14 Thread Peter Ruckdeschel

 Duncan Murdoch wrote:
 On 11/12/2009 7:12 AM, khaz...@ceremade.dauphine.fr wrote:
 Hi, all
 How can generate a sample from truncated inverse  gamma distribution
 in R?

 Using the inverse CDF method or rejection sampling are possible,
 depending on what your truncation is like.  If your truncation forces
 the observations far out into the tails, you need to be careful about
 rounding and underflow when using the the inverse CDF method.

 Duncan Murdoch

 
 I think perusal of this paper might be a good idea:
 
 Sampling Truncated Normal, Beta, and Gamma Densities
 Paul Damien and Stephen G. Walker
 Journal of Computational and Graphical Statistics, Vol. 10, No. 2 (Jun.,
 2001), pp. 206-215
 
 Remembering that the inverse gamma is the inverse of a gamma, you may be
 able to get a truncated inverse gamma from a truncated (at the other
 end) gamma. Alternatively, the methodology outlined in the paper most
 likely can be modified for the inverse gamma.
 
 David Scott
 

While David Scott's reply definitely gives a more problem specific
solution than we could offer, you might also want to look at package
distr on CRAN where a general truncation operator for distributions is
provided --- see ?Truncate (after installing/attaching package distr).

The inverse Gamma so far is not implemented to distr as an S4-class
(you could easily do this yourself, though). But, as David Scott
mentioned you can produce it by something along the lines

require(distr)
G0 - Gammad(scale = 2.3, shape = 1.4) ## generates a Gamma distribution
G - 1/G0 ## the corresponding inverse Gamma
d(G)(2) ### density of G at 2
p(G)(4) ## cdf of G at 4 ...

## example for Truncated G
TG - Truncate(G, lower=0, upper=0.9)
 ## the lower=0  is somehow redundant in this case, will see if this
 ## can be set automatically in a next release..

q(TG)(0.99) ## upper 1% quantile

## and some functionals:
require(distrEx)
E(TG)
mad(TG)
sd(TG)

## I am not claiming that this code gives extremely accurate results,
## but for higher accuracy, you could easily overload operator / for
## operands numeric, Gammad (and if you like, correspondingly,
## write methods for E())

Note that our package even takes into account that you might
want to use log-scales if you are interested in the tails,
so it takes up Duncan Murdoch's comment in some sense,
automatically.


Best, Peter

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


[R] Problems loading RMySQL

2009-12-14 Thread Azeez

Hi!

I have installed MySQL, DBI  RODBC with any problems. I installed MySQL 5.0
 everything went fine. Since the second time I tried loading RMySQL I have
been receiving this error message:

 library(RMySQL)
Error in if (utils::file_test(-d, MySQLhome)) break :   
Argument hat Länge 0 
Error : .onLoad in 'loadNamespace' für 'RMySQL' fehlgeschlagen 
Fehler: Laden von Paket/Namensraum für 'RMySQL' fehlgeschlagen

I deinstalled MySQL 5.0  downloaded 5.1 meanwhile, but nothing has changed
- still getting the same message :-(

Thanks for any help!
-- 
View this message in context: 
http://n4.nabble.com/Problems-loading-RMySQL-tp963717p963717.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] hdf5 package

2009-12-14 Thread jgarcia
Hi all,
I'm testing the use of the hdf5 R library under Windows XP.

With some simple example (an R list with several subobjects as showed in
the examples in the library) the library exports and imports .hdf files
adequately. However, if I try to open the exported file with another
program (HDFView 2.5) I receive the message that the file is an
unsupported format. HDFView 2.5 does not seems to have any problem with
another hdf5 files.

Has anyone experienced a similar problem with R exporte hdf5 files and
could indicate if it is likely originated by either the R interface or the
hdf library in my computer?

Thanks and best regards,
Javier
--

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


Re: [R] shared axes in multipanel plot

2009-12-14 Thread Gabor Grothendieck
On Mon, Dec 14, 2009 at 11:30 AM, Jennifer Young
jennifer.yo...@math.mcmaster.ca wrote:
 splendid!

 This worked well, but there are two oddities that I can't resolve.

 1. In the real data, the baseline is a cumulative probability plot (from
 simulations) rather than the straight line.  The panel.lines plots this
 curve, but seems to join the first and last points together.
 panel.points(x, baseline, type=l) did the same.
 I checked that the vector is indeed sorted properly, so I'm not sure why
 it should connect the first point to the last.

I can't reproduce the problem based on this description.


 2. The screens are correctly labeled, but in the wrong order (left to
 right, top to bottom: 3,4,1,2). Is this easily corrected?

xyplot(..., as.table = TRUE) will give one reordering.

Another possibility is:
   plt - xplot(...)
   plt[ix]
where ix is a permutation of 1:4


 I've been cowardly avoiding learning xyplot() so thanks for the jumpstart!

 Try this using xyplot.zoo in the zoo package.  We define the baseline
 and a panel function.   The panel function just performs the default
 action to display the graphs and adds the baseline.   The screens
 variable is 1,1,2,2,3,3,4,4.  We create a zoo object from dat and use
 screens to name the columns according to their group.  Finally we call
 xyplot.zoo passing it screens so that the successive columns go in the
 indicated panels and also passing the other items.  See ?xyplot.zoo in
 zoo and ?xyplot in lattice.

 library(zoo)
 library(lattice)

 baseline - 1:nrow(dat)/nrow(dat)
 pnl - function(x, ...) {
       panel.plot.default(x, ...)
       panel.lines(x, baseline, lwd = 2, col = grey(0.5))
 }
 nc - ncol(dat)
 screens - rep(1:(nc/2), each = 2)
 z - zoo(dat)
 colnames(z) - paste(Group, screens)
 xyplot(z, screens = screens , layout = c(2, 2), col = black, lty =
 2, scales = list(y = list(relation = same)), panel = pnl)


 On Fri, Dec 11, 2009 at 10:02 AM, Jennifer Young
 jennifer.yo...@math.mcmaster.ca wrote:
 Hello

 I've created a function to make a plot with multiple pannels from
 columns
 of data that are created in a previous function.  In the example below
 the
 number of columns is 8, giving 4 pannels, but in general it takes data
 with any number of columns and figures out a nice layout.

 The panels all have the same axes, and so I wonder what functions are
 avialable to create axes only on the left and bottom of the whole plot
 rather than each pannel.
 I'd really like a generic way to do this for any number of plots, but
 was
 even having trouble figuring out how to do it manually for this example;
 How are pannels referred to, in a layout context?
 That is, how do I say,

 if(current.pannel==4) {do stuff}

 Here's a simple version of the code.

 baseline - (1:20)/20    #example data
 dat1 - matrix(baseline,20,8)
 dat - dat1+matrix(rnorm(20*8)/30, 20,8)

 nstrat - ncol(dat)
 rows - ceiling(nstrat/4)
 layout(matrix(1:(rows*2), rows, 2, T))
 par(oma=c(4,4,3,1))
 par(mar=c(1,1,0,1))
 for(i in which(1:nstrat%%2!=0)){
    plot(baseline, type=l, col=grey, lwd=2,
            xlab=, ylab=, ylim=c(0,1), xaxt='n', yaxt='n')
    axis(1, labels=F); axis(2, labels=F)
    points(dat[,i], type=l, lty=2)
    points(dat[,i+1], type=l, lty=2)
 }



 Thank you muchly
 Jennifer Young

 PS: I am a subscriber, but can't for the life of me figure out how to
 send
 an email while logged in so that the moderators don't have to take the
 time to read it over.  I always get the please wait while we check it
 over email.  Likely I'm being dumb.

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

2009-12-14 Thread Prof Brian Ripley

On Mon, 14 Dec 2009, jgar...@ija.csic.es wrote:


Hi all,
I'm testing the use of the hdf5 R library under Windows XP.

With some simple example (an R list with several subobjects as showed in
the examples in the library) the library exports and imports .hdf files
adequately. However, if I try to open the exported file with another
program (HDFView 2.5) I receive the message that the file is an
unsupported format. HDFView 2.5 does not seems to have any problem with
another hdf5 files.

Has anyone experienced a similar problem with R exporte hdf5 files and
could indicate if it is likely originated by either the R interface or the
hdf library in my computer?


Well, it is the hdf5 library that writes the file, so that must be the 
origin.


Beyond that, please do read the posting guide, and send a small 
reproducible example to the package maintainer.




Thanks and best regards,
Javier
--

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



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

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


Re: [R] shared axes in multipanel plot

2009-12-14 Thread Jennifer Young
 On Mon, Dec 14, 2009 at 11:30 AM, Jennifer Young
 jennifer.yo...@math.mcmaster.ca wrote:
 splendid!

 This worked well, but there are two oddities that I can't resolve.

 1. In the real data, the baseline is a cumulative probability plot
 (from
 simulations) rather than the straight line.  The panel.lines plots this
 curve, but seems to join the first and last points together.
 panel.points(x, baseline, type=l) did the same.
 I checked that the vector is indeed sorted properly, so I'm not sure why
 it should connect the first point to the last.

 I can't reproduce the problem based on this description.

sorry that was lazy of me. If you modify the code you gave me as follows
(with an extra line of the sqare root of baseline, as an example) the
first and last points are joined. I didn't notice this before when
baseline was just a line.

baseline - (1:20)/20
dat1 - matrix(baseline,20,8)
dat - dat1+matrix(rnorm(20*8)/30, 20,8)
b2-sqrt(baseline)
pnl - function(x, ...) {
panel.plot.default(x, ...)
panel.lines(x, baseline, lwd = 2, col = grey(0.5))
panel.lines(x, b2)
}
nc - ncol(dat)
screens - rep(1:(nc/2), each = 2)
z - zoo(dat)
colnames(z) - paste(Group, screens)
xyplot(z, screens = screens , layout = c(2, 2), col = black, lty =
2, scales = list(y = list(relation = same)), panel = pnl)




 2. The screens are correctly labeled, but in the wrong order (left to
 right, top to bottom: 3,4,1,2). Is this easily corrected?

 xyplot(..., as.table = TRUE) will give one reordering.

 Another possibility is:
plt - xplot(...)
plt[ix]
 where ix is a permutation of 1:4



as.table=TRUE did the trick thanks.

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


[R] Logit Estimation with Panel Data

2009-12-14 Thread Moysés Nascimento
Hi all!

Do you know if there is any R function/package that can be used to
estimate logit models with panel data and forecasting?

Thanks,

Moysés.





-- 
Moysés Nascimento
Bacharel em Estatística/UFES
Mestre em Estatística Aplicada e Biometria/UFV
Doutorando em Estatística e Experimentação Agropecuária/UFLA
moysesnas...@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] shared axes in multipanel plot

2009-12-14 Thread Gabor Grothendieck
Try this:
You seem to have found a problem.  At any rate try this instead:

pnl - function(x, y, ...) {
   tt - time(z)
   y - matrix(y, length(tt))
   for(j in 1:ncol(y)) panel.plot.default(tt, y[,j], ...)
   panel.lines(tt, baseline, lwd = 2, col = grey(0.5))
   panel.lines(tt, b2)
}

On Mon, Dec 14, 2009 at 3:19 PM, Jennifer Young
jennifer.yo...@math.mcmaster.ca wrote:
 On Mon, Dec 14, 2009 at 11:30 AM, Jennifer Young
 jennifer.yo...@math.mcmaster.ca wrote:
 splendid!

 This worked well, but there are two oddities that I can't resolve.

 1. In the real data, the baseline is a cumulative probability plot
 (from
 simulations) rather than the straight line.  The panel.lines plots this
 curve, but seems to join the first and last points together.
 panel.points(x, baseline, type=l) did the same.
 I checked that the vector is indeed sorted properly, so I'm not sure why
 it should connect the first point to the last.

 I can't reproduce the problem based on this description.

 sorry that was lazy of me. If you modify the code you gave me as follows
 (with an extra line of the sqare root of baseline, as an example) the
 first and last points are joined. I didn't notice this before when
 baseline was just a line.

 baseline - (1:20)/20
 dat1 - matrix(baseline,20,8)
 dat - dat1+matrix(rnorm(20*8)/30, 20,8)
 b2-sqrt(baseline)
 pnl - function(x, ...) {
        panel.plot.default(x, ...)
        panel.lines(x, baseline, lwd = 2, col = grey(0.5))
        panel.lines(x, b2)
 }
 nc - ncol(dat)
 screens - rep(1:(nc/2), each = 2)
 z - zoo(dat)
 colnames(z) - paste(Group, screens)
 xyplot(z, screens = screens , layout = c(2, 2), col = black, lty =
 2, scales = list(y = list(relation = same)), panel = pnl)




 2. The screens are correctly labeled, but in the wrong order (left to
 right, top to bottom: 3,4,1,2). Is this easily corrected?

 xyplot(..., as.table = TRUE) will give one reordering.

 Another possibility is:
    plt - xplot(...)
    plt[ix]
 where ix is a permutation of 1:4



 as.table=TRUE did the trick thanks.


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


Re: [R] shared axes in multipanel plot

2009-12-14 Thread Gabor Grothendieck
One resolution of the need to go outside of pnl would be to use this line:

tt - unique(x)

in place of tt - time(z).  That would overcome the objection that the
pnl function is not self contained.

On Mon, Dec 14, 2009 at 3:44 PM, Gabor Grothendieck
ggrothendi...@gmail.com wrote:
 Try this:
 You seem to have found a problem.  At any rate try this instead:

 pnl - function(x, y, ...) {
   tt - time(z)
   y - matrix(y, length(tt))
   for(j in 1:ncol(y)) panel.plot.default(tt, y[,j], ...)
   panel.lines(tt, baseline, lwd = 2, col = grey(0.5))
   panel.lines(tt, b2)
 }

 On Mon, Dec 14, 2009 at 3:19 PM, Jennifer Young
 jennifer.yo...@math.mcmaster.ca wrote:
 On Mon, Dec 14, 2009 at 11:30 AM, Jennifer Young
 jennifer.yo...@math.mcmaster.ca wrote:
 splendid!

 This worked well, but there are two oddities that I can't resolve.

 1. In the real data, the baseline is a cumulative probability plot
 (from
 simulations) rather than the straight line.  The panel.lines plots this
 curve, but seems to join the first and last points together.
 panel.points(x, baseline, type=l) did the same.
 I checked that the vector is indeed sorted properly, so I'm not sure why
 it should connect the first point to the last.

 I can't reproduce the problem based on this description.

 sorry that was lazy of me. If you modify the code you gave me as follows
 (with an extra line of the sqare root of baseline, as an example) the
 first and last points are joined. I didn't notice this before when
 baseline was just a line.

 baseline - (1:20)/20
 dat1 - matrix(baseline,20,8)
 dat - dat1+matrix(rnorm(20*8)/30, 20,8)
 b2-sqrt(baseline)
 pnl - function(x, ...) {
        panel.plot.default(x, ...)
        panel.lines(x, baseline, lwd = 2, col = grey(0.5))
        panel.lines(x, b2)
 }
 nc - ncol(dat)
 screens - rep(1:(nc/2), each = 2)
 z - zoo(dat)
 colnames(z) - paste(Group, screens)
 xyplot(z, screens = screens , layout = c(2, 2), col = black, lty =
 2, scales = list(y = list(relation = same)), panel = pnl)




 2. The screens are correctly labeled, but in the wrong order (left to
 right, top to bottom: 3,4,1,2). Is this easily corrected?

 xyplot(..., as.table = TRUE) will give one reordering.

 Another possibility is:
    plt - xplot(...)
    plt[ix]
 where ix is a permutation of 1:4



 as.table=TRUE did the trick thanks.



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


Re: [R] A random number from any distribution?þ

2009-12-14 Thread Bert Gunter
Sounds like the poster might be interested in bootstrap sampling ...
As usual, what's the question of interest?

Bert Gunter
Genentech Nonclinical Biostatistics
 
 
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Greg Snow
Sent: Monday, December 14, 2009 12:45 PM
To: ivan popivanov; r-help@r-project.org
Subject: Re: [R]A random number from any distribution?‏

Look at the logspline package for an alternative.

-- 
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 ivan popivanov
 Sent: Saturday, December 12, 2009 7:38 PM
 To: r-help@r-project.org
 Subject: [R] A random number from any distribution?‏
 
 
 Hello,
 
 I have some data, and I want to generate random numbers following the
 distribution of this data (in other words, to generate a synthetic data
 set sharing the same stats as a given data set). Reading an old thread
 I found the following text:
 
 If you can compute the quantile function of the distribution (i.e.,
 the
 inverse of the integral of the pdf), then you can use the probability
 integral transform: If U is a U(0,1) random variable and Q is the
 quantile
 function of the distribution F, then Q(U) is a random variable
 distributed
 as F.
 
 That sounds good, but is there a quick way to do this in R? Let's say
 my data is contained in ee, I can get the quantiles using:
 
 qq = quantile(ee, probs=(0,1,0.25))
0%   25%   50%   75%  100%
 -0.2573385519 -0.0041451053  0.0004538924  0.0049276991  0.1037823292
 
 Then I know how to use the above method to generate Q(U) (by looking
 up U in the first row, and then mapping it to a number using the second
 row), but is there an R function that does that? Otherwise I need to
 write my own to lookup the table.
 
 Thanks in advance,
 Ivan
 
 _
 
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

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

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


Re: [R] Logit Estimation with Panel Data

2009-12-14 Thread Gray Calhoun
RSiteSearch(logit panel) and RSiteSearch(logit longitudinal) will
turn up some results, including task views.  So... yes.
--Gray

On Mon, Dec 14, 2009 at 2:44 PM, Moysés Nascimento
moysesnas...@gmail.com wrote:
 Hi all!

 Do you know if there is any R function/package that can be used to
 estimate logit models with panel data and forecasting?

 Thanks,

 Moysés.





 --
 Moysés Nascimento
 Bacharel em Estatística/UFES
 Mestre em Estatística Aplicada e Biometria/UFV
 Doutorando em Estatística e Experimentação Agropecuária/UFLA
 moysesnas...@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.





-- 
Gray Calhoun

Assistant Professor of Economics
Iowa State University

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


Re: [R] debug an error that incapacitates R?

2009-12-14 Thread Brian Diggs
 -Original Message-
 From: Liviu Andronic [mailto:landronim...@gmail.com]
 Sent: Sunday, December 13, 2009 4:05 AM
 To: Duncan Murdoch
 Cc: r-help@r-project.org Help
 Subject: Re: [R] debug an error that incapacitates R?
 
 Hello
 And thank you for the quick answer.
 
 On 12/13/09, Duncan Murdoch murd...@stats.uwo.ca wrote:
   I think you need to go back to old-fashioned debugging methods.
  Identify
  the line the triggers the error, by using debug() and single stepping
  through sosInit(), or by adding print() or cat() statements to it (or
  setting tracepoints with trace()), and seeing how many succeed before
  things
  go bad.
 
 Experimenting with browser() and subsequently with the step-through
 debug() I managed to identify the first line that triggers the
 invalid connection error:
 doItAndPrint(paste(## Launching RSiteSearch, please be patient..))

I have seen this invalid connection type error when there is a sink()
active that does not have a valid connection associated with it.  In that
case, any output generates the error.  Try issuing sink() commands (without
any arguments) to remove any active sinks.  When there are not any more 
sinks you will get the message:

Warning message:
In sink() : no sink to remove

   Once you see the bad line, it may be obvious what's wrong with it,
  or you
  may need to ask for help, by putting together a minimal example that
  triggers it.
 
 Unfortunately, there is nothing obviously wrong with the call, nor
 with the environment. Omitting the line makes the function work in all
 my test cases. I will contact John Fox on this.

If it is an invalid sink, this would just be the first call that generates
output.  It would be a sink somewhere before that that is setting up a bad
connection (which doesn't cause problems until something is to be written).

 Thank you
 Liviu
 

--
Brian Diggs, Ph.D.
Senior Research Associate, Department of Surgery, Oregon Health  Science 
University




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


[R] Creating a string

2009-12-14 Thread Tom Pitt

Hi All,

Thanks for your help.

I want to add a letter x and a number to a string like x1.

How do I do that?

Thanks,
Tom
-- 
View this message in context: 
http://n4.nabble.com/Creating-a-string-tp963915p963915.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] debug an error that incapacitates R?

2009-12-14 Thread Rolf Turner


Wouldn't sink.number() give you a handle on whether
the problem is that there is an invalid sink() in effect?

On 15/12/2009, at 10:55 AM, Brian Diggs wrote:


-Original Message-
From: Liviu Andronic [mailto:landronim...@gmail.com]
Sent: Sunday, December 13, 2009 4:05 AM
To: Duncan Murdoch
Cc: r-help@r-project.org Help
Subject: Re: [R] debug an error that incapacitates R?

Hello
And thank you for the quick answer.

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

 I think you need to go back to old-fashioned debugging methods.
Identify
the line the triggers the error, by using debug() and single  
stepping
through sosInit(), or by adding print() or cat() statements to it  
(or
setting tracepoints with trace()), and seeing how many succeed  
before

things
go bad.


Experimenting with browser() and subsequently with the step-through
debug() I managed to identify the first line that triggers the
invalid connection error:
doItAndPrint(paste(## Launching RSiteSearch, please be patient..))


I have seen this invalid connection type error when there is a  
sink()
active that does not have a valid connection associated with it.   
In that
case, any output generates the error.  Try issuing sink() commands  
(without
any arguments) to remove any active sinks.  When there are not any  
more

sinks you will get the message:

Warning message:
In sink() : no sink to remove


 Once you see the bad line, it may be obvious what's wrong with it,
or you
may need to ask for help, by putting together a minimal example that
triggers it.


Unfortunately, there is nothing obviously wrong with the call, nor
with the environment. Omitting the line makes the function work in  
all

my test cases. I will contact John Fox on this.


If it is an invalid sink, this would just be the first call that  
generates
output.  It would be a sink somewhere before that that is setting  
up a bad
connection (which doesn't cause problems until something is to be  
written).



Thank you
Liviu



--
Brian Diggs, Ph.D.
Senior Research Associate, Department of Surgery, Oregon Health   
Science University





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

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



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

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


Re: [R] shared axes in multipanel plot

2009-12-14 Thread Jennifer Young
Ah, I think i see the problem.
The default plot recognizes there is one set of x for each set of y, but
since there were two vectors in the default.plot, the x vector is repeated
and loops around for the lines part.  Presumably the default plot uses
your recursive plot automatically.

At any rate, it seems that this simpler version (with your unique(x)
solution) also works and avoids the recursion.

pnl - function(x, y, ...) {

tt - unique(x)
panel.plot.default(x,y, ...)
panel.lines(tt, baseline, lwd = 2, col = grey(0.5))

}

Thanks for your time!!

 One resolution of the need to go outside of pnl would be to use this line:

 tt - unique(x)

 in place of tt - time(z).  That would overcome the objection that the
 pnl function is not self contained.

 On Mon, Dec 14, 2009 at 3:44 PM, Gabor Grothendieck
 ggrothendi...@gmail.com wrote:
 Try this:
 You seem to have found a problem.  At any rate try this instead:

 pnl - function(x, y, ...) {
   tt - time(z)
   y - matrix(y, length(tt))
   for(j in 1:ncol(y)) panel.plot.default(tt, y[,j], ...)
   panel.lines(tt, baseline, lwd = 2, col = grey(0.5))
   panel.lines(tt, b2)
 }

 On Mon, Dec 14, 2009 at 3:19 PM, Jennifer Young
 jennifer.yo...@math.mcmaster.ca wrote:
 On Mon, Dec 14, 2009 at 11:30 AM, Jennifer Young
 jennifer.yo...@math.mcmaster.ca wrote:
 splendid!

 This worked well, but there are two oddities that I can't resolve.

 1. In the real data, the baseline is a cumulative probability plot
 (from
 simulations) rather than the straight line.  The panel.lines plots
 this
 curve, but seems to join the first and last points together.
 panel.points(x, baseline, type=l) did the same.
 I checked that the vector is indeed sorted properly, so I'm not sure
 why
 it should connect the first point to the last.

 I can't reproduce the problem based on this description.

 sorry that was lazy of me. If you modify the code you gave me as
 follows
 (with an extra line of the sqare root of baseline, as an example) the
 first and last points are joined. I didn't notice this before when
 baseline was just a line.

 baseline - (1:20)/20
 dat1 - matrix(baseline,20,8)
 dat - dat1+matrix(rnorm(20*8)/30, 20,8)
 b2-sqrt(baseline)
 pnl - function(x, ...) {
        panel.plot.default(x, ...)
        panel.lines(x, baseline, lwd = 2, col = grey(0.5))
        panel.lines(x, b2)
 }
 nc - ncol(dat)
 screens - rep(1:(nc/2), each = 2)
 z - zoo(dat)
 colnames(z) - paste(Group, screens)
 xyplot(z, screens = screens , layout = c(2, 2), col = black, lty =
 2, scales = list(y = list(relation = same)), panel = pnl)




 2. The screens are correctly labeled, but in the wrong order (left to
 right, top to bottom: 3,4,1,2). Is this easily corrected?

 xyplot(..., as.table = TRUE) will give one reordering.

 Another possibility is:
    plt - xplot(...)
    plt[ix]
 where ix is a permutation of 1:4



 as.table=TRUE did the trick thanks.




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


Re: [R] A random number from any distribution?þ

2009-12-14 Thread ivan popivanov

:) I might be trying to do something stupid so let me try again:

1) I have a large sample - daily percentage movement for a stock
2) I want to generate a synthetic stock which has daily movements from the same 
distribution as the original

The solution I was planning to implement (following the old post cited) is:

1) Compute the quantiles over the known data
2) Generate a uniformly distributed U in (0,1)
3) Find the quantile corresponding to U
4) Using U's offset from the left end of the quantile, compute the daily 
movement for the synthetic stock

Below is the function I came up with. Two questions:
1) Is there an existing R function to do that?
2) Is this a sound approach?

Thanks in advance!

rsample = function(s, n, step=0.01)
{
   qs = quantile(s, probs=seq(0, 1, step))

   res = rep(0, n)

   unif = runif(n)

   for(i in 1:n)
   {
  uu = unif[i]

  # find uu's quantile
  qid = ceiling(uu / step)
  qleft = (qid - 1)*step

  # compute the result using uu's offset within the quantile
  res[i] = as.numeric(qs[qid]) + ((uu - qleft)/step)*(as.numeric(qs[qid+1]) 
- as.numeric(qs[qid]))
   }

   return(res)
}

 From: gunter.ber...@gene.com
 To: greg.s...@imail.org; ivan.popiva...@hotmail.com; r-help@r-project.org
 Subject: RE: [R]A random number from any distribution?þ
 Date: Mon, 14 Dec 2009 13:04:37 -0800
 
 Sounds like the poster might be interested in bootstrap sampling ...
 As usual, what's the question of interest?
 
 Bert Gunter
 Genentech Nonclinical Biostatistics
  
  
 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
 Behalf Of Greg Snow
 Sent: Monday, December 14, 2009 12:45 PM
 To: ivan popivanov; r-help@r-project.org
 Subject: Re: [R]A random number from any distribution?‏
 
 Look at the logspline package for an alternative.
 
 -- 
 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 ivan popivanov
  Sent: Saturday, December 12, 2009 7:38 PM
  To: r-help@r-project.org
  Subject: [R] A random number from any distribution?‏
  
  
  Hello,
  
  I have some data, and I want to generate random numbers following the
  distribution of this data (in other words, to generate a synthetic data
  set sharing the same stats as a given data set). Reading an old thread
  I found the following text:
  
  If you can compute the quantile function of the distribution (i.e.,
  the
  inverse of the integral of the pdf), then you can use the probability
  integral transform: If U is a U(0,1) random variable and Q is the
  quantile
  function of the distribution F, then Q(U) is a random variable
  distributed
  as F.
  
  That sounds good, but is there a quick way to do this in R? Let's say
  my data is contained in ee, I can get the quantiles using:
  
  qq = quantile(ee, probs=(0,1,0.25))
 0%   25%   50%   75%  100%
  -0.2573385519 -0.0041451053  0.0004538924  0.0049276991  0.1037823292
  
  Then I know how to use the above method to generate Q(U) (by looking
  up U in the first row, and then mapping it to a number using the second
  row), but is there an R function that does that? Otherwise I need to
  write my own to lookup the table.
  
  Thanks in advance,
  Ivan
  
  _
  
  
  [[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.
 
  
_
Windows Live: Make it easier for your friends to see what you’re up to on 
Facebook.
http://go.microsoft.com/?linkid=9691816
[[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] debug an error that incapacitates R?

2009-12-14 Thread Brian Diggs


 -Original Message-
 From: Rolf Turner [mailto:r.tur...@auckland.ac.nz]
 Sent: Monday, December 14, 2009 2:07 PM
 To: Brian Diggs
 Cc: r-help@r-project.org Help
 Subject: Re: [R] debug an error that incapacitates R?
 
 
 Wouldn't sink.number() give you a handle on whether
 the problem is that there is an invalid sink() in effect?

It would.  I had forgotten about that function.

On 15/12/2009, at 10:55 AM, Brian Diggs wrote:
 
  -Original Message-
  From: Liviu Andronic [mailto:landronim...@gmail.com]
  Sent: Sunday, December 13, 2009 4:05 AM
  To: Duncan Murdoch
  Cc: r-help@r-project.org Help
  Subject: Re: [R] debug an error that incapacitates R?
 
  Hello
  And thank you for the quick answer.
 
  On 12/13/09, Duncan Murdoch murd...@stats.uwo.ca wrote:
   I think you need to go back to old-fashioned debugging methods.
  Identify
  the line the triggers the error, by using debug() and single
  stepping
  through sosInit(), or by adding print() or cat() statements to it
  (or
  setting tracepoints with trace()), and seeing how many succeed
  before
  things
  go bad.
 
  Experimenting with browser() and subsequently with the step-through
  debug() I managed to identify the first line that triggers the
  invalid connection error:
  doItAndPrint(paste(## Launching RSiteSearch, please be patient..))
 
  I have seen this invalid connection type error when there is a
  sink()
  active that does not have a valid connection associated with it.
  In that
  case, any output generates the error.  Try issuing sink() commands
  (without
  any arguments) to remove any active sinks.  When there are not any
  more
  sinks you will get the message:
 
  Warning message:
  In sink() : no sink to remove
 
   Once you see the bad line, it may be obvious what's wrong with it,
  or you
  may need to ask for help, by putting together a minimal example
 that
  triggers it.
 
  Unfortunately, there is nothing obviously wrong with the call, nor
  with the environment. Omitting the line makes the function work in
  all
  my test cases. I will contact John Fox on this.
 
  If it is an invalid sink, this would just be the first call that
  generates
  output.  It would be a sink somewhere before that that is setting
  up a bad
  connection (which doesn't cause problems until something is to be
  written).
 
  Thank you
  Liviu
 
 
  --
  Brian Diggs, Ph.D.
  Senior Research Associate, Department of Surgery, Oregon Health 
  Science University
 
 
 
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-
  guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
 ##
 Attention:
 This e-mail message is privileged and confidential. If you are not the
 intended recipient please delete the message and notify the sender.
 Any views or opinions presented are solely those of the author.
 
 This e-mail has been scanned and cleared by MailMarshal
 www.marshalsoftware.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] fast matrix-vector multiplication

2009-12-14 Thread parkbomee






Hi all,

Is there a way to do a matrix multiplication in a faster way?
I am making a product of a matrix (composed of a lot of dummy variables) and a 
vector, and is there any way to make it faster?
The simple X %*% y takes too long a time.
I know using sparse matrix would help, but don't know how to do it i R.


Thank you.


  
_
[[elided Hotmail spam]]

[[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] shared axes in multipanel plot

2009-12-14 Thread Felix Andrews
I think the basic problem is that you are bringing in new data from
outside the xyplot() call -- i.e `b2` and `baseline` -- and are then
trying to plot that against the panel argument `x`. This is asking for
trouble, as you have found, because `x` as passed to the panel
function is modified by grouping, conditioning or subsetting
operations.

If you are using outside data, it is best to define both the x and y
values together. Alternatively, merge all the data into one object (a
matrix in this case) and define the plot structure in the high-level
plot call, so that all the data series are grouped or subsetted
together.

Hope that helps.

-Felix


2009/12/15 Gabor Grothendieck ggrothendi...@gmail.com:
 One resolution of the need to go outside of pnl would be to use this line:

 tt - unique(x)

 in place of tt - time(z).  That would overcome the objection that the
 pnl function is not self contained.

 On Mon, Dec 14, 2009 at 3:44 PM, Gabor Grothendieck
 ggrothendi...@gmail.com wrote:
 Try this:
 You seem to have found a problem.  At any rate try this instead:

 pnl - function(x, y, ...) {
   tt - time(z)
   y - matrix(y, length(tt))
   for(j in 1:ncol(y)) panel.plot.default(tt, y[,j], ...)
   panel.lines(tt, baseline, lwd = 2, col = grey(0.5))
   panel.lines(tt, b2)
 }

 On Mon, Dec 14, 2009 at 3:19 PM, Jennifer Young
 jennifer.yo...@math.mcmaster.ca wrote:
 On Mon, Dec 14, 2009 at 11:30 AM, Jennifer Young
 jennifer.yo...@math.mcmaster.ca wrote:
 splendid!

 This worked well, but there are two oddities that I can't resolve.

 1. In the real data, the baseline is a cumulative probability plot
 (from
 simulations) rather than the straight line.  The panel.lines plots this
 curve, but seems to join the first and last points together.
 panel.points(x, baseline, type=l) did the same.
 I checked that the vector is indeed sorted properly, so I'm not sure why
 it should connect the first point to the last.

 I can't reproduce the problem based on this description.

 sorry that was lazy of me. If you modify the code you gave me as follows
 (with an extra line of the sqare root of baseline, as an example) the
 first and last points are joined. I didn't notice this before when
 baseline was just a line.

 baseline - (1:20)/20
 dat1 - matrix(baseline,20,8)
 dat - dat1+matrix(rnorm(20*8)/30, 20,8)
 b2-sqrt(baseline)
 pnl - function(x, ...) {
        panel.plot.default(x, ...)
        panel.lines(x, baseline, lwd = 2, col = grey(0.5))
        panel.lines(x, b2)
 }
 nc - ncol(dat)
 screens - rep(1:(nc/2), each = 2)
 z - zoo(dat)
 colnames(z) - paste(Group, screens)
 xyplot(z, screens = screens , layout = c(2, 2), col = black, lty =
 2, scales = list(y = list(relation = same)), panel = pnl)




 2. The screens are correctly labeled, but in the wrong order (left to
 right, top to bottom: 3,4,1,2). Is this easily corrected?

 xyplot(..., as.table = TRUE) will give one reordering.

 Another possibility is:
    plt - xplot(...)
    plt[ix]
 where ix is a permutation of 1:4



 as.table=TRUE did the trick thanks.



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




-- 
Felix Andrews / 安福立
Postdoctoral Fellow
Integrated Catchment Assessment and Management (iCAM) Centre
Fenner School of Environment and Society [Bldg 48a]
The Australian National University
Canberra ACT 0200 Australia
M: +61 410 400 963
T: + 61 2 6125 4670
E: felix.andr...@anu.edu.au
CRICOS Provider No. 00120C
-- 
http://www.neurofractal.org/felix/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 random number from any distribution?þ

2009-12-14 Thread Bert Gunter
Questionable. Doesn't this implicitly assumes that the log(stock prices) form 
an AR(1) series? If so, is this reasonable? And what about the occasional 
shocks? 

Appropriate simulation of time series like stock prices is a tricky business, I 
believe. I would question whether your naïve approach is going to capture 
enough of the real dynamics to give meaningful answers. As I'm far from an 
expert on this sort of thing, I'll just leave it at that.


Bert Gunter
Genentech Nonclinical Biostatistics

http://devo.gene.com/groups/devo/depts/ncb/home.shtml

 

 


-Original Message-
From: ivan popivanov [mailto:ivan.popiva...@hotmail.com] 
Sent: Monday, December 14, 2009 2:27 PM
To: gunter.ber...@gene.com; greg.s...@imail.org; r-help@r-project.org
Subject: RE: [R]A random number from any distribution?þ

:) I might be trying to do something stupid so let me try again:

1) I have a large sample - daily percentage movement for a stock
2) I want to generate a synthetic stock which has daily movements from the same 
distribution as the original

The solution I was planning to implement (following the old post cited) is:

1) Compute the quantiles over the known data
2) Generate a uniformly distributed U in (0,1)
3) Find the quantile corresponding to U
4) Using U's offset from the left end of the quantile, compute the daily 
movement for the synthetic stock

Below is the function I came up with. Two questions:
1) Is there an existing R function to do that?
2) Is this a sound approach?

Thanks in advance!

rsample = function(s, n, step=0.01)
{
   qs = quantile(s, probs=seq(0, 1, step))

   res = rep(0, n)

   unif = runif(n)

   for(i in 1:n)
   {
  uu = unif[i]

  # find uu's quantile
  qid = ceiling(uu / step)
  qleft = (qid - 1)*step

  # compute the result using uu's offset within the quantile
  res[i] = as.numeric(qs[qid]) + ((uu - qleft)/step)*(as.numeric(qs[qid+1]) 
- as.numeric(qs[qid]))
   }

   return(res)
}

 From: gunter.ber...@gene.com
 To: greg.s...@imail.org; ivan.popiva...@hotmail.com; r-help@r-project.org
 Subject: RE: [R]A random number from any distribution?þ
 Date: Mon, 14 Dec 2009 13:04:37 -0800
 
 Sounds like the poster might be interested in bootstrap sampling ...
 As usual, what's the question of interest?
 
 Bert Gunter
 Genentech Nonclinical Biostatistics
 
 
 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
 Behalf Of Greg Snow
 Sent: Monday, December 14, 2009 12:45 PM
 To: ivan popivanov; r-help@r-project.org
 Subject: Re: [R]A random number from any distribution?‏
 
 Look at the logspline package for an alternative.
 
 -- 
 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 ivan popivanov
  Sent: Saturday, December 12, 2009 7:38 PM
  To: r-help@r-project.org
  Subject: [R] A random number from any distribution?‏
  
  
  Hello,
  
  I have some data, and I want to generate random numbers following the
  distribution of this data (in other words, to generate a synthetic data
  set sharing the same stats as a given data set). Reading an old thread
  I found the following text:
  
  If you can compute the quantile function of the distribution (i.e.,
  the
  inverse of the integral of the pdf), then you can use the probability
  integral transform: If U is a U(0,1) random variable and Q is the
  quantile
  function of the distribution F, then Q(U) is a random variable
  distributed
  as F.
  
  That sounds good, but is there a quick way to do this in R? Let's say
  my data is contained in ee, I can get the quantiles using:
  
  qq = quantile(ee, probs=(0,1,0.25))
  0% 25% 50% 75% 100%
  -0.2573385519 -0.0041451053 0.0004538924 0.0049276991 0.1037823292
  
  Then I know how to use the above method to generate Q(U) (by looking
  up U in the first row, and then mapping it to a number using the second
  row), but is there an R function that does that? Otherwise I need to
  write my own to lookup the table.
  
  Thanks in advance,
  Ivan
  
  _
  
  
  [[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.
 




Windows Live: Make it easier for your friends to see what you’re up to on 
Facebook. 

Re: [R] shared axes in multipanel plot

2009-12-14 Thread Gabor Grothendieck
Good observation.  In fact, panel.plot.default works because it uses
the subscripts and groups variables which are passed down to the panel
function and if not explicitly referenced in the formal argument list
of pnl are passed via ... thus we could use any of these equivalent
pnl functions though the prior solution using unique seems the
shortest:

# using groups
pick out x components corresponding to group 1
pnl - function(x, ..., groups) {
   panel.plot.default(x, ..., groups)
   ix - which(groups == 1)
   panel.lines(x[ix], b2, lwd = 2, col = grey(0.5))
}

# using groups and subscripts
pnl - function(x, y, subscripts, ..., groups) {
   panel.plot.default(x, y, subscripts, ..., groups)
   tt - x[groups[subscripts] == 1]
   panel.lines(tt, b2, lwd = 2, col = grey(0.5))
}

# trim x to length of b2
pnl - function(x, ...) {
   panel.plot.default(x, ...)
   tt - head(x, length(b2))
   panel.lines(tt, b2, lwd = 2, col = grey(0.5))
}

# unique
pnl - function(x, ...) {
   panel.plot.default(x, ...)
   tt - unique(x)
   panel.lines(tt, b2, lwd = 2, col = grey(0.5))
}


baseline - (1:20)/20
dat1 - matrix(baseline,20,8)
dat - dat1+matrix(rnorm(20*8)/30, 20,8)
b2-sqrt(baseline)
nc - ncol(dat)
screens - rep(1:(nc/2), each = 2)
z - zoo(dat)
colnames(z) - paste(Group, screens)
xyplot(z, screens = screens , layout = c(2, 2), col = black, lty = 2,
   scales = list(y = list(relation = same)), panel = pnl)




On Mon, Dec 14, 2009 at 5:21 PM, Jennifer Young
jennifer.yo...@math.mcmaster.ca wrote:
 Ah, I think i see the problem.
 The default plot recognizes there is one set of x for each set of y, but
 since there were two vectors in the default.plot, the x vector is repeated
 and loops around for the lines part.  Presumably the default plot uses
 your recursive plot automatically.

 At any rate, it seems that this simpler version (with your unique(x)
 solution) also works and avoids the recursion.

    pnl - function(x, y, ...) {

        tt - unique(x)
        panel.plot.default(x,y, ...)
        panel.lines(tt, baseline, lwd = 2, col = grey(0.5))

    }

 Thanks for your time!!

 One resolution of the need to go outside of pnl would be to use this line:

 tt - unique(x)

 in place of tt - time(z).  That would overcome the objection that the
 pnl function is not self contained.

 On Mon, Dec 14, 2009 at 3:44 PM, Gabor Grothendieck
 ggrothendi...@gmail.com wrote:
 Try this:
 You seem to have found a problem.  At any rate try this instead:

 pnl - function(x, y, ...) {
   tt - time(z)
   y - matrix(y, length(tt))
   for(j in 1:ncol(y)) panel.plot.default(tt, y[,j], ...)
   panel.lines(tt, baseline, lwd = 2, col = grey(0.5))
   panel.lines(tt, b2)
 }

 On Mon, Dec 14, 2009 at 3:19 PM, Jennifer Young
 jennifer.yo...@math.mcmaster.ca wrote:
 On Mon, Dec 14, 2009 at 11:30 AM, Jennifer Young
 jennifer.yo...@math.mcmaster.ca wrote:
 splendid!

 This worked well, but there are two oddities that I can't resolve.

 1. In the real data, the baseline is a cumulative probability plot
 (from
 simulations) rather than the straight line.  The panel.lines plots
 this
 curve, but seems to join the first and last points together.
 panel.points(x, baseline, type=l) did the same.
 I checked that the vector is indeed sorted properly, so I'm not sure
 why
 it should connect the first point to the last.

 I can't reproduce the problem based on this description.

 sorry that was lazy of me. If you modify the code you gave me as
 follows
 (with an extra line of the sqare root of baseline, as an example) the
 first and last points are joined. I didn't notice this before when
 baseline was just a line.

 baseline - (1:20)/20
 dat1 - matrix(baseline,20,8)
 dat - dat1+matrix(rnorm(20*8)/30, 20,8)
 b2-sqrt(baseline)
 pnl - function(x, ...) {
        panel.plot.default(x, ...)
        panel.lines(x, baseline, lwd = 2, col = grey(0.5))
        panel.lines(x, b2)
 }
 nc - ncol(dat)
 screens - rep(1:(nc/2), each = 2)
 z - zoo(dat)
 colnames(z) - paste(Group, screens)
 xyplot(z, screens = screens , layout = c(2, 2), col = black, lty =
 2, scales = list(y = list(relation = same)), panel = pnl)




 2. The screens are correctly labeled, but in the wrong order (left to
 right, top to bottom: 3,4,1,2). Is this easily corrected?

 xyplot(..., as.table = TRUE) will give one reordering.

 Another possibility is:
    plt - xplot(...)
    plt[ix]
 where ix is a permutation of 1:4



 as.table=TRUE did the trick thanks.






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


Re: [R] MLE for a t distribution

2009-12-14 Thread Kjetil Halvorsen
Brian Ripley sometimes on this list or elsewhere suggested to
reparametrize as 1/k. I have used that with good results. But you
should be aware that
usually data contains very little information about k, so thhat
if you do not have a lot more than 100 observations you coukld
be out of luck. You should try to plot the likelihood as a function of k,
possibly also the profile likelihood.

Kjetil

On Thu, Dec 10, 2009 at 6:06 PM, Barbara Gonzalez
barbara.p.gonza...@gmail.com wrote:
 Thank you.

 I actually found fitdistr() in the package MASS, that estimates the
 df, but it does a very bad job. I know that the main problem is that
 the t distribution has a lot of local maxima, and of course, when
 k-infty we have the Normal distribution, which has nice and easy to
 obtain MLEs.

 I will try re-parametrizing k, but I doubt this will solve the problem
 with the multiple local maxima.

 I would like to implement something like the EM algorithm to go around
 this problem, but I don't know how to do that.

 Barbara

 On Thu, Dec 10, 2009 at 2:59 PM, Albyn Jones jo...@reed.edu wrote:
 k - infinity gives the normal distribution.  You probably don't care
 much about the difference between k=1000 and k=10, so you might
 try reparametrizing df on [1,infinity) to a parameter on [0,1]...

 albyn

 On Thu, Dec 10, 2009 at 02:14:26PM -0600, Barbara Gonzalez wrote:
 Given X1,...,Xn ~ t_k(mu,sigma) student t distribution with k degrees
 of freedom, mean mu and standard deviation sigma, I want to obtain the
 MLEs of the three parameters (mu, sigma and k). When I try traditional
 optimization techniques I don't find the MLEs. Usually I just get
 k-infty. Does anybody know of any algorithms/functions in R that can
 help me obtain the MLEs? I am especially interested in the MLE for k,
 the degrees of freedom.

 Thank you!

 Barbara

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



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


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


[R] R2 in lm function

2009-12-14 Thread Tom Pitt

Hi All,

After I run the lm function, where (which variable) do I find my R-squared
for further calculations?

Thanks,
Tom
-- 
View this message in context: 
http://n4.nabble.com/R2-in-lm-function-tp963958p963958.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] Loop counter used in variable

2009-12-14 Thread Tom Pitt

Hi All,

I need to run muliple lm functions.  My independent variables are called
dataset$x1, x2, x3, x4 etc.

How can I use a loop counter variable to replace the numbers?



fit1=lm(dataset$y~dataset$x1)
fit2=lm(dataset$y~dataset$x2)
fit3=lm(dataset$y~dataset$x3)
fit4=lm(dataset$y~dataset$x4)

Thanks,
Tom
-- 
View this message in context: 
http://n4.nabble.com/Loop-counter-used-in-variable-tp963984p963984.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] R2 in lm function

2009-12-14 Thread Jorge Ivan Velez
Hi Tom,

Take a look at the following taken/modified from ?lm:

ctl - c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
trt - c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
group - gl(2,10,20, labels=c(Ctl,Trt))
weight - c(ctl, trt)
lm.D9 - lm(weight ~ group)
slm - summary(lm.D9)
str(slm)
slm$r.squared

Best regards,
Jorge


On Mon, Dec 14, 2009 at 5:20 PM, Tom Pitt  wrote:


 Hi All,

 After I run the lm function, where (which variable) do I find my R-squared
 for further calculations?

 Thanks,
 Tom
 --
 View this message in context:
 http://n4.nabble.com/R2-in-lm-function-tp963958p963958.html
 Sent from the R help mailing list archive at Nabble.com.

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


[[alternative HTML version deleted]]

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


Re: [R] fast matrix-vector multiplication

2009-12-14 Thread Gray Calhoun
Check out crossprod and the Matrix package (capitalized); there's also
a discussion of their speed gains in the R newsletter that should turn
up with a search and in the vignette as well.

-Gray

On Monday, December 14, 2009, parkbomee bbom...@hotmail.com wrote:






 Hi all,

 Is there a way to do a matrix multiplication in a faster way?
 I am making a product of a matrix (composed of a lot of dummy variables) and 
 a vector, and is there any way to make it faster?
 The simple X %*% y takes too long a time.
 I know using sparse matrix would help, but don't know how to do it i R.


 Thank you.



 _
 [[elided Hotmail spam]]

         [[alternative HTML version deleted]]

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


-- 
Gray Calhoun

Assistant Professor of Economics
Iowa State University

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


[R] Help in R

2009-12-14 Thread li li
Hello,
   Can anyone give me some suggestion in term of calculating the sum below.
Is there a function in R that can help doing it faster?

x1, x2, ...xn where xi can be 0 or 1. I want to calculate the following:

sum{ beta[a+sum(xi), b+n-sum(xi) ]* [ (1-x1)dnorm(0,1)+x1dnorm(2,1) ]*  [
(1-x2)dnorm(0,1)+x2dnorm(2,1) ]* ...* [ (1-xn)dnorm(0,1)+xndnorm(2,1) ] }

The sum in the beginning is over all 2^n possible values for the vector x1,
x2, ...xn .

   Thank you very much!

Hannah

[[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] Is there lazy copy in R?

2009-12-14 Thread Peng Yu
I'm wondering if lazy copy is available in R or not. For example, in
the following code, I'm wondering if the memory for y is allocated in
the 2nd line or the 3rd line. Is there a documentation for this?

x=1:1
y=x
y[[10]]=5

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


Re: [R] lapply , mapply questions

2009-12-14 Thread Michael Denslow
Hi Matt,

On Mon, Dec 14, 2009 at 5:49 AM, Bunny, lautloscrew.com
bu...@lautloscrew.com wrote:
 Dear all,

 i have a programming problem that should be simple, though i am stuck with 
 it. Please note that this is not a specific geonames problem, though i use it 
 as an example - it愀 just a basic problem with lapply.

 I use the geonames webservices with the R geonames packages which works 
 almost smoothly.
 I have a vector of Zipcodes and i want to do a geonames lookup for all of 
 them, which should not be a problem.
 Of course i could create a loop for that one, but i think lapply should be 
 possible, too.

 The problem is to hand over the variable to the lookup function.

 lapply(zipcodes,GNpostalCodeLookup(postalcode=zipcodes,country=US))

 where zipcodes is my vector of zip codes an GNpostalCodeLookup is the 
 function that gives back some information like longitude and aptitude etc. Is 
 it possible to use lapply in that context or can I just use it in contexts 
 like lapply(somelistofvectors, mean) ?

 all i悲 like to have is some data.frame like this

 zip     apt    long
 1234  xy.x        xx.x
 1235  ax.x   aa.a

I am not sure what aptitude is, but this might help.
Note that this is a reproducible example.

library(geonames)
# make fake dataframe
z.df - data.frame(zip = c(28607, 28608, 28609),country = c('US','US','US'))

# add longitude to dataframe
z.df$long=apply(z.df,1,function(l){GNpostalCodeLookup(postalcode =
l[1], country = l[2])$lng})
# add latitude to dateframe
z.df$lat=apply(z.df,1,function(l){GNpostalCodeLookup(postalcode =
l[1], country = l[2])$lat})

I am sure there is a way to get this into one function but this is
what I came up with.

Hope this helps,
Michael


 thx in advance

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





-- 
Michael Denslow

Graduate Student  Adjunct Instructor
I.W. Carpenter Jr. Herbarium [BOON]
Department of Biology
Appalachian State University
Boone, North Carolina U.S.A.
-- AND --
Communications Manager
Southeast Regional Network of Expertise and Collections
sernec.org

36.214177, -81.681480 +/- 3103 meters

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


Re: [R] Is there lazy copy in R?

2009-12-14 Thread Benilton Carvalho
use tracemem() to figure out... and read its documentation in detail.
b


On Dec 15, 2009, at 1:03 AM, Peng Yu wrote:

 I'm wondering if lazy copy is available in R or not. For example, in
 the following code, I'm wondering if the memory for y is allocated in
 the 2nd line or the 3rd line. Is there a documentation for this?
 
 x=1:1
 y=x
 y[[10]]=5
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Is there lazy copy in R?

2009-12-14 Thread Peng Yu
 a=1:10
 b=a
 a=1:10
 tracemem(a)# I assume the following is address 'a' points to
[1] 0x05cf2798
 b=a
 b[1]=1
tracemem[0x05cf2798 - 0x05cf2750]:
tracemem[0x05cf2750 - 0x05ed8ba0]:

I don't understand what these addresses mean. Would you please help me
understand it?

On Mon, Dec 14, 2009 at 9:23 PM, Benilton Carvalho bcarv...@jhsph.edu wrote:
 use tracemem() to figure out... and read its documentation in detail.
 b


 On Dec 15, 2009, at 1:03 AM, Peng Yu wrote:

 I'm wondering if lazy copy is available in R or not. For example, in
 the following code, I'm wondering if the memory for y is allocated in
 the 2nd line or the 3rd line. Is there a documentation for this?

 x=1:1
 y=x
 y[[10]]=5

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



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


Re: [R] Is there lazy copy in R?

2009-12-14 Thread hadley wickham
 I don't understand what these addresses mean. Would you please help me
 understand it?

Did you try reading the documentation?

 When an object is traced any copying of the object by the C
 function ‘duplicate’ or by arithmetic or mathematical operations
 produces a message to standard output.  The message consists of
 the string ‘tracemem’, the identifying strings for the object
 being copied and the new object being created, and a stack trace
 showing where the duplication occurred.  ‘retracemem()’ is used to
 indicate that a variable should be considered a copy of a previous
 variable (e.g. after subscripting).

Hadley

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

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


[R] Diagonal Labels on Beside Bars in Barplot

2009-12-14 Thread Jason Rupert
My question is based on an example provided in the following:
Referencing:
Statistics with R
Vincent Zoonekynd
zoo...@math.jussieu.fr
6th January 2007

URL:
http://zoonek2.free.fr/UNIX/48_R/all.html

data(HairEyeColor)
a - as.table( apply(HairEyeColor, c(1,2), sum) )

#  Provided Example
barplot(a, beside = TRUE,
legend.text = attr(a, dimnames)$Hair)

 

# I would like to make the labels on the x-axis diagonal, so I tried the 
following: 
barplot_reference-barplot(a, beside = TRUE, 
  legend.text = attr(a, dimnames)$Hair,
  xaxt = n,  xlab = )

text(barplot_reference, par(usr)[3] - 0.09, srt = 45, adj = 1,
 labels = as.character(colnames(a)), xpd = TRUE, offset = 1,
 col = black)

# The labels are diagonal, but unfortunately the eye color labels are now 
applied to every bar and then repeat. 

# Is there any way to correct this problem, so that the diagonal labels are 
only the following:
Brown, Blue, Hazel, Green

# Those labels should not be repeated, so any help and insight is greatly 
appreciated.

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


Re: [R] Is there lazy copy in R?

2009-12-14 Thread Linlin Yan
It means that R does have the lazy copy mechanism, which I didn't
know, and I think it can be very useful to make R running more
quickly.

On Tue, Dec 15, 2009 at 12:15 PM, Peng Yu pengyu...@gmail.com wrote:
 a=1:10
 b=a
 a=1:10
 tracemem(a)# I assume the following is address 'a' points to
 [1] 0x05cf2798
 b=a
 b[1]=1
 tracemem[0x05cf2798 - 0x05cf2750]:
 tracemem[0x05cf2750 - 0x05ed8ba0]:

 I don't understand what these addresses mean. Would you please help me
 understand it?

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

2009-12-14 Thread Anderson, Chris
I'm trying to display my deciles without scientific notation, but have not 
found an option that will allow me to do so. According to web searches, the 
options(scipen=999) should remove scientific notation, but it seems not too. 
Does this option work with quantcut function? Is there any other option that 
can be used?  I am using verison 2.10.0.

library(gtools)
library(gdata)
options(scipen=999)
 parad-quantcut(benchmarkPara$Benchmark_Total, q=seq(0,1,by=0.1), na.rm=TRUE)
 table(parad)
parad
 [2.29e+05,2.7e+05]  (2.7e+05,3.69e+05] (3.69e+05,3.99e+05] (3.99e+05,4.64e+05] 
(4.64e+05,5.12e+05] (5.12e+05,6.74e+05]
  3   2   2   2 
  3   2
(6.74e+05,7.23e+05] (7.23e+05,7.79e+05] (7.79e+05,1.03e+06] (1.03e+06,1.49e+06]
  2   2   2   3

Chris Anderson
Data Analyst
Medical Affairs
wk: 925-677-4870
cell: 707-315-8486
Fax:925-677-4670





This electronic message transmission, including any attachments, contains
information which may be confidential, privileged and/or otherwise exempt
from disclosure under applicable law. The information is intended to be for the
use of the individual(s) or entity named above. If you are not the intended
recipient or the employee or agent responsible for delivering the message
to the intended recipient, you are hereby notified that any disclosure, copying,
distribution or use of the contents of this information is strictly prohibited. 
 If
you have received this electronic transmission in error, please notify the 
sender
immediately by telephone (800-676-6777) or by a reply to sender only
message and destroy all electronic and hard copies of the communication,
including attachments.  Thank you.

For more information on Paradigm Management Services, LLC, please visit
http://www.paradigmcorp.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] Supressing Scientific Notation

2009-12-14 Thread Daniel Malter
Example:

x=rnorm(1000)
terc.cut.x=cut(x,breaks=quantile(x,probs=c(0,1/3,2/3,1)),labels=c(L,M,H
),include.lowest=T)

HTH,
Daniel

-
cuncta stricte discussurus
-

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Anderson, Chris
Sent: Monday, December 14, 2009 7:17 PM
To: 'r-help@R-project.org'
Subject: [R] Supressing Scientific Notation

I'm trying to display my deciles without scientific notation, but have not
found an option that will allow me to do so. According to web searches, the
options(scipen=999) should remove scientific notation, but it seems not too.
Does this option work with quantcut function? Is there any other option that
can be used?  I am using verison 2.10.0.

library(gtools)
library(gdata)
options(scipen=999)
 parad-quantcut(benchmarkPara$Benchmark_Total, q=seq(0,1,by=0.1),
na.rm=TRUE)
 table(parad)
parad
 [2.29e+05,2.7e+05]  (2.7e+05,3.69e+05] (3.69e+05,3.99e+05]
(3.99e+05,4.64e+05] (4.64e+05,5.12e+05] (5.12e+05,6.74e+05]
  3   2   2
2   3   2
(6.74e+05,7.23e+05] (7.23e+05,7.79e+05] (7.79e+05,1.03e+06]
(1.03e+06,1.49e+06]
  2   2   2
3

Chris Anderson
Data Analyst
Medical Affairs
wk: 925-677-4870
cell: 707-315-8486
Fax:925-677-4670





This electronic message transmission, including any attachments, contains
information which may be confidential, privileged and/or otherwise exempt
from disclosure under applicable law. The information is intended to be for
the
use of the individual(s) or entity named above. If you are not the intended
recipient or the employee or agent responsible for delivering the message
to the intended recipient, you are hereby notified that any disclosure,
copying,
distribution or use of the contents of this information is strictly
prohibited.  If
you have received this electronic transmission in error, please notify the
sender
immediately by telephone (800-676-6777) or by a reply to sender only
message and destroy all electronic and hard copies of the communication,
including attachments.  Thank you.

For more information on Paradigm Management Services, LLC, please visit
http://www.paradigmcorp.com

[[alternative HTML version deleted]]

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

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


Re: [R] fast matrix-vector multiplication

2009-12-14 Thread Martin Maechler
 GC == Gray Calhoun gray.calh...@gmail.com
 on Mon, 14 Dec 2009 19:26:44 -0600 writes:

GC Check out crossprod and the Matrix package (capitalized); there's also
GC a discussion of their speed gains in the R newsletter that should turn
GC up with a search and in the vignette as well.

Yes, use the 'Matrix' package.

For the problem you mention,   X  being a design matrix of
regression problem,
you may be interested in the   sparse.model.matrix()  function
which constructs such a sparse X from a formula and a data
frame.
With 

  library(Matrix)
  example(sparse.model.matrix)

you get a few (small sample) examples.

Martin Maechler, ETH Zurich

GC -Gray

GC On Monday, December 14, 2009, parkbomee bbom...@hotmail.com wrote:
 
 
 Hi all,
 
 Is there a way to do a matrix multiplication in a faster way?
 I am making a product of a matrix (composed of a lot of dummy variables) 
and a vector, and is there any way to make it faster?
 The simple X %*% y takes too long a time.
 I know using sparse matrix would help, but don't know how to do it i R.
 
 
 Thank you.

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