[R] reading and parsing gzipped files

2008-09-05 Thread Dmitriy Skvortsov
Hi all,I have  large  compressed text tab delimited  files,
I am trying to write efficient function to read them,
I am using   gzfile()  and readLines()

zz - gzfile(exampl.txt.gz, r)  # compressed file
system.time(temp1-readLines(zz ))
close(zz)

which work fast, and create vector of strings.
The problem is to parse the result, if  I use strsplit  it takes longer then
decompress file manually , read it with scan and erase it.

Can anybody recommend  an efficient way of parsing large vector  ~200,000
entries
Dmitriy

[[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] question on FARIMA innovationsIn-Reply-To=[EMAIL PROTECTED]

2008-09-05 Thread Tony Cricenti
Hi Ferebee,
I am also working on a similar problem. Have you solved it? I am trying to 
write a function to to determine the innovations.
However, I think that the Farma package may do this. I haven't succeeded in 
getting Farma to work. It requires OX.
Can you let me know if you have made any progress
 
Tony Cricenti
 
Regards
A.L. Cricenti,   
Academic Leader Telecommunications 
Faculty of Information and Communication Technologies
Swinburne University of Technology, 
PO Box 218, Hawthorn, Vic 3122, Australia. 
email: [EMAIL PROTECTED] 
Phone: (voice) +61-3-9214 5506   (fax) +61-3-9819 6443

-
Swinburne University of Technology
CRICOS Provider Code: 00111D

NOTICE
This e-mail and any attachments are confidential and int...{{dropped:18}}

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


Re: [R] isoMDS and dist

2008-09-05 Thread Prof Brian Ripley

On Thu, 4 Sep 2008, Carolyn A. Pucko wrote:



I am starting with a matrix in which rows are vegetation plots and columns 
are various characteristics including ID# and elevation. I removed elevation 
and ID columns to avoid having those characteristics influence the distances 
between points which I calculated using the dist command. The resulting 
distance file was then used in isoMDS.


What I want to know is whether I can reattach the ID and elevation onto the 
point location information given from isoMDS? or is it possible that the 
order given in the isoMDS output is not the same as the order of the original 
data used to calculate distances?


The order is the same.  From the help page

Value:

 Two components:

  points: A k-column vector of the fitted configuration.
...

and see how it describes 'the fitted configuration'.

BTW, it is regarded as basic courtesy to credit the work of others: isoMDS 
is from package MASS.






Thanks,
Carrie Pucko
University of Vermont

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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,  [EMAIL PROTECTED]
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] how to deal with NaN in boot object

2008-09-05 Thread Prof Brian Ripley

On Fri, 5 Sep 2008, Jinsong Zhao wrote:


Hi there,

I use boot() to do bootstrap simulation on my statistic, I get a boot
object, named obj. For certain reasons, there are some NaN in obj$t.
Now, I hope to get confidence interval using boot.ci(), it give the
following error:

Error in if (const(t, min(1e-08, mean(t)/1e+06))) { :
 missing value where TRUE/FALSE needed

Now, what I could do is I have to edit the obj by hand.

Any suggestions? Thanks in advanced!


Correct your 'statistic' function not to return NaN.

--
Brian D. Ripley,  [EMAIL PROTECTED]
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] algorithm to create unique identifiers

2008-09-05 Thread Prof Brian Ripley
For a much simpler solution that does always work for numbers, see 
unique's methods for matrices and data frames.


On Thu, 4 Sep 2008, Henrik Bengtsson wrote:


On Thu, Sep 4, 2008 at 8:44 PM, Ralph S. [EMAIL PROTECTED] wrote:


Hi all,

I am trying to create a unique identifier for each row, combining 
numbers from three columns.


Do you know if there is a general formula to do this (or some manual 
where I can read about this)?


I figure I can use the numeric entries of the columns as coordinates 
and multiply them with different coefficients (different magnitudes) to 
get the unique ID - but it would be nice to read about such algorithms 
in general.


What are you numbers?  Are they in a fixed range?  Integers or reals?
If fixed range integers, it is easy.  Think regular numerical
representation, e.g. binary, octadecimal, decimal and hexadecimal.

For a more generic solution that works with any data types, see e.g.
MD5 [http://en.wikipedia.org/wiki/MD5].  It is not guaranteed to
generated unique codes, but it is extremely rare that two different
inputs gives the same MD5 code.  MD5 (and others) are implemented in
the 'digest' packages, e.g.


library(digest)
digest(list(a=1, b=list(1:10, c=letters)))

[1] 73e0ae066a97bfff7f79d41c65b55fde

My $.02

/Henrik




Any links/input would be great -

Ralph


--
Brian D. Ripley,  [EMAIL PROTECTED]
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] Trouble with R CMD check: I can't seem to get dependencies right (maybe I'm using R_LIBS incorrectly?)

2008-09-05 Thread Prof Brian Ripley

'Writing R Extensions' does say

@quotation Note
@code{R CMD check} and @code{R CMD build} run @R{} with
@option{--vanilla}, so none of the user's startup files are read.  If
you need @env{R_LIBS} set (to find packages in a non-standard library)
you will need to set it in the environment.
@end quotation

~/.Renviron is one of those startup files (and so is ~/.Rprofile).

On Thu, 4 Sep 2008, Dylan Arena wrote:


Hi there,


I'm in the following directory:

~/Documents/Rstuff/diceFiles/dice_1.1

The directory dice is in this directory, with all the usual build
files (DESCRIPTION, NAMESPACE, etc).  I'm trying to run the following
command:

R CMD check dice

(where dice is the name of the package I'm checking), and I get the following:

* checking package dependencies ... ERROR
Packages required but not available:
 gtools

My DESCRIPTION file does (correctly) list gtools as a dependency, so
I'm happy this check is ensuring its availability.  What I can't
figure out is how to get the check command to see that gtools is in
fact installed.  I've created a file called .Renviron in my home
directory that has the following line in it:

R_LIBS=~/Documents/Rstuff/library

And in the directory specified by R_LIBS above is the gtools package.
(I've also got a file called .Rprofile in my home directory, with the
line .libPaths(~/Documents/Rstuff/library)
in it.)  My reading of the R-intro manual is that setting R_LIBS in
this way should allow the R CMD check command to search in the
directory specified by R_LIBS when looking for gtools.  I'm pretty
sure at this point, though, that my understanding is incorrect.

At this point I'm in over my depth.  I'm writing because I'm hopeful
that to someone on this list my problem is trivially solvable.  My
basic question is: what must I do to get R CMD check to find the
gtools package?


Please let me know any ideas you might have for me,
Dylan

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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,  [EMAIL PROTECTED]
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] how to write a escape sequences in to a file

2008-09-05 Thread Prof Brian Ripley

A newline is \n.  So hai \nhru.

On Fri, 5 Sep 2008, Kurapati, Ravichandra (Ravichandra) wrote:




Hi



  Str1-hai 

  Str2-hru



 I want to write these 2 strings in a file  separated by
newline.





  How can I get this.

Thanks

K.Ravichandra






[[alternative HTML version deleted]]

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



--
Brian D. Ripley,  [EMAIL PROTECTED]
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] reading and parsing gzipped files

2008-09-05 Thread Prof Brian Ripley

On Thu, 4 Sep 2008, Dmitriy Skvortsov wrote:


Hi all,I have  large  compressed text tab delimited  files,
I am trying to write efficient function to read them,
I am using   gzfile()  and readLines()

zz - gzfile(exampl.txt.gz, r)  # compressed file
system.time(temp1-readLines(zz ))
close(zz)

which work fast, and create vector of strings.
The problem is to parse the result, if  I use strsplit  it takes longer then
decompress file manually , read it with scan and erase it.

Can anybody recommend  an efficient way of parsing large vector  ~200,000
entries


'parse'?  What is wrong with using read.delim (reading 'tab delimited 
files' is its job)?  It (and scan) work with gzfile connections, so there 
is no need to decompress manually.


See the 'R Data Import/Export Manual' for how to use read.delim efficiently.


Dmitriy

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


PLEASE do.


--
Brian D. Ripley,  [EMAIL PROTECTED]
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] Odp: Help for par(mfrow)

2008-09-05 Thread Petr PIKAL
Hi
see from plot.boot help page

Side Effects
All screens are closed and cleared and a number of plots are produced on 
the current graphics device. Screens are closed but not cleared at 
termination of this function. 

You need to change a behaviour of this function what shall not be simple.

Or maybe you can produce set of graphs in one pdf file or in several png 
files and then to add them together by external means

Regards
Petr


[EMAIL PROTECTED] napsal dne 03.09.2008 12:03:03:

 Hi, R users
 I have a question with par(mfrow). I try to histograms and qqplots 
 form boot output for 5 statistics but par(mfrow=c(5,2)) or 
 par(mfrow=c(5,1)) does not work. R still display each figure 
 separately. What did I do wrong? (I check ?par)
  c1.boot-boot(c1data,c1.fun,R=999)
  c1.boot
 
 ORDINARY NONPARAMETRIC BOOTSTRAP
 Call:
 boot(data = c1data, statistic = c1.fun, R = 999)
 
 Bootstrap Statistics :
 originalbiasstd. error
 t1*  0.30447696  0.0014228306  0.01026153
 t2*  0.05967183 -0.0014505285  0.01274977
 t3*  1.11852318 -0.0009339349  0.31586852
 t4*  4.12856813 -0.0310221125  0.39602210
 t5* -1.29958196  0.0222876889  0.67625299
 
  par(mfrow=c(5,2))
  for (i in 1:5) {plot(c1.boot, index=i, col=i)}
 Many Thanks
 Chunhao
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] restricted bootstrap

2008-09-05 Thread ONKELINX, Thierry
Grant,

Have you considered a gls model instead of a lm model? In a gls model
one can model the correlation between the measures. So you won't need to
select a subset of your data. You can kind gls in the nlme package.

HTH,

Thierry




ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium 
tel. + 32 54/436 185
[EMAIL PROTECTED] 
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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Namens Grant Gillis
Verzonden: donderdag 4 september 2008 14:57
Aan: r-help@r-project.org
Onderwerp: Re: [R] restricted bootstrap

Hello Professor Ripely,

Sorry for not being clear.  I posted after a long day of struggling.
Also
my toy distance matrix should have been symmetrical.

Simply put I have spatially autocorrelated data collected from many
points.
I would like to do a linear regression on these data.  To deal with the
autocrrelation I want to resample a subset of my data with replacement
but I
need to restrict subsets such that no two locations where data was
collected
are closer than Xm apart (further apart than the autocrrelation in the
data).

Thanks for having a look at this for me.  I will look up the hard-core
spatial point process.

Grant

2008/9/4 Prof Brian Ripley [EMAIL PROTECTED]

 I see nothing here to do with the 'bootstrap', which is sampling with
 replacement.

 Do you know what you mean exactly by 'randomly sample'?  In general
the way
 to so this is to sample randomly (uniformly, whatever) and reject
samples
 that do not meet your restriction.   For some restrictions there are
more
 efficient algorithms, but I don't understand yours.  (What are the
'rows'?
  Do you want to sample rows in space or xy locations?  How come 'dist'
is
 not symmetric?)  For some restrictions, an MCMC sampling scheme is
needed,
 the hard-core spatial point process being a related example.


 On Wed, 3 Sep 2008, Grant Gillis wrote:

  Hello List,

 I am not sure that I have the correct terminology here (restricted
 bootstrap) which may be hampering my archive searches.  I have quite
a
 large
 spatially autocorrelated data set.  I have xy coordinates and the
 corresponding pairwise distance matrix (metres) for each row.  I
would
 like
 to randomly sample some number of rows but restricting samples such
that
 the
 distance between them is larger than the threshold of
autocorrelation.  I
 have been been unsuccessfully trying to link the 'sample' function to
 values
 in the distance matrix.

 My end goal is to randomly sample M thousand rows of data N thousand
times
 calculating linear regression coefficients for each sample but am
stuck on
 taking the initial sample. I believe I can figure out the rest.


 Example Question

 I would like to radomly sample 3 rows further but withe the
restriction
 that
 they are greater than 100m apart

 example data:
 main data:

 y- c(1, 2, 9, 5, 6)
 x-c( 1, 3, 5, 7, 9)
 z-c(2, 4, 6, 8, 10)
 a-c(3, 9, 6, 4 ,4)

 maindata-cbind(y, x, z, a)

y x x a
 [1,] 1 1 1 3
 [2,] 2 3 3 9
 [3,] 9 5 5 6
 [4,] 5 7 7 4
 [5,] 6 9 9 4

 distance matrix:
 row1-c(0, 123, 567, 89)
 row2-c(98, 0, 345, 543)
 row3-c(765, 90, 0, 987)
 row4-c(654, 8, 99, 0)

 dist-rbind(row1, row2, row3, row4)

[,1] [,2] [,3] [,4]
 row10  123  567   89
 row2   980  345  543
 row3  765   900  987
 row4  6548   990

 Thanks for all of the help in the past and now

 Cheers
 Grant

[[alternative HTML version deleted]]

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


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


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

[R] Add marks to a point pattern

2008-09-05 Thread Vanessa Santos
My name is Vanessa and I am from Spain.I have in Excel a list of children that 
go and don´t go to the dentist, and I want to add these categorical marks to 
the point pattern in package spatstat.How can I do it?
Thanks for your 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] Package for Tidying-up R-code

2008-09-05 Thread Gundala Viswanath
Dear all,

Is there any such package?

I am thinking of something equivalent to Perl::Tidy.
For example with VI editor one can visual highlight a portion
of Perlcode and then issue the command:

!perltidy

then the code will be automatically arranged.

- Gundala Viswanath
Jakarta - Indonesia

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


Re: [R] Package for Tidying-up R-code

2008-09-05 Thread Dimitris Rizopoulos

check Section 3.1 of the `Writing R Extensions' manual.


I hope it helps.

Best,
Dimitris


Gundala Viswanath wrote:

Dear all,

Is there any such package?

I am thinking of something equivalent to Perl::Tidy.
For example with VI editor one can visual highlight a portion
of Perlcode and then issue the command:

!perltidy

then the code will be automatically arranged.

- Gundala Viswanath
Jakarta - Indonesia

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



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

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

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

2008-09-05 Thread Tom La Bone

I am running R 2.7.1 on an eeepc with the standard Xandros Linux. I
install/upgrade R binaries using synaptic from the
http://cran.r-project.org/bin/linux/debian/etch-cran/ repository. R 2.7.2
does not appear to be available from this repository. Will it be available
soon or is there another repository I should be using?

Tom

-- 
View this message in context: 
http://www.nabble.com/Upgrade-to-R-2.7.2-from-Debian-Repository-tp19328325p19328325.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] controlling lattice plot ticks with relation=free

2008-09-05 Thread Richard . Cotton
How do you persuade lattice to draw tick marks on both the left and right 
side of the y-axis, when relation=free in the scales component?

#Ticks appear on both sides
histogram(~height|voice.part, data=singer)

##Ticks only on left
histogram(~height|voice.part, data=singer, 
scales=list(y=list(relation=free)))

Providing tck as a vector of length 2 doesn't seem to work, neither does 
setting alternating=3 (since the argument is ignored, and I don't really 
want the labels on both sides - just the ticks).

I'm sure I'm missing something obvious.

Regards,
Richie.

Mathematical Sciences Unit
HSL



ATTENTION:

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

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


Re: [R] Fitted probabilities in conditional logit regression

2008-09-05 Thread Gavin Simpson
On Sun, 2008-08-31 at 09:49 -0400, Min Chen wrote:
 Dear R-help,
 
 I'm doing conditional logit regression for a discrete choice model.
 I want to know whether there's a way to get the fitted probabilities. In
 Stata, predict works for clogit, but it seems that in R predict does
 not.
 
 Thank you very much!
 
 Best wishes.

Can you explain/demonstrate how/why predict doesn't work for clogit? I
can get predictions from a clogit model:

## from ?clogit
mod - clogit(case~spontaneous+induced+strata(stratum),data=infert)
predict(mod)
predict(mod, type = expected)

all work for that example to give the fitted values.

See ?predict.coxph for details of the predict function. I'm not familiar
with either the code or the methods, but 'type = expected' seems to
give what you want.

HTH

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

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 write a escape sequences in to a file

2008-09-05 Thread Henrique Dallazuanna
Try this:

cat(Str1, Str2, file = out.txt, sep = \n)

On Fri, Sep 5, 2008 at 2:21 AM, Kurapati, Ravichandra (Ravichandra) 
[EMAIL PROTECTED] wrote:



 Hi



   Str1-hai 

   Str2-hru



  I want to write these 2 strings in a file  separated by
 newline.





   How can I get this.

 Thanks

 K.Ravichandra






[[alternative HTML version deleted]]

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




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

[[alternative HTML version deleted]]

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


Re: [R] Plotting using 'if' statements

2008-09-05 Thread Steve Murray

Sorry! Hopefully just one more question!

I'm now trying to plot columns 3 and 6. I've tried:

 plot(January[3:6])

...but this plots columns 4 and 5 too!


I've also tried:

 plot(January[3],January[6])
 plot(January[3,6])
 plot(January[3]:January[6])

But these don't produce the right results (instead, errors!)

Again, I'm sure it's a just a small (but important) detail that I'm missing, 
and I'd be very grateful if anyone could help me out.

Many thanks again,

Steve


Date: Thu, 4 Sep 2008 13:52:03 -0300
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: Re: [R] Plotting using 'if' statements
CC: r-help@r-project.org

Use '':

plot(January[January[,3] 0  January[,3]  2, 3:4])

On Thu, Sep 4, 2008 at 1:47 PM, Steve Murray  wrote:



Ah that's great, thank you very much.



As a follow-on, in the same format, how would I plot where column 3 is greater 
than 0 *but also less than 2*?



Once again, any help is much appreciated.





Thanks,



Steve





Date: Thu, 4 Sep 2008 13:39:12 -0300

From: [EMAIL PROTECTED]

To: [EMAIL PROTECTED]

Subject: Re: [R] Plotting using 'if' statements

CC: r-help@r-project.org



Try this:



plot(January[January[,3] 0, 3:4])



On Thu, Sep 4, 2008 at 1:28 PM, Steve Murray  wrote:











Dear all,







I have a dataset of four columns, and I wish to plot (as a scatter graph) the 
values of the third column where the values are greater than zero, and the 
fourth column.







I tried doing this via the plot command itself, but got into a bit of a mess 
(resulting in errors!). My dataframe is called 'January':







 plot(January[3(0):4])



Error: unexpected '' in plot(January[3(











After a few variations on this, I thought I'd try making a new object which 
includes all values from the third column of January0 (to plot in a separate 
step) as follows:







 JanFilter - January[3]0







No error here. However, when I display the 'values' of JanFilter, it shows that 
instead of keeping the numerical values, the above operation simply displays 
the results of the logical test:







 head(JanFilter)



   Value



[1,]   FALSE



[2,]TRUE



[3,]TRUE



[4,]TRUE



[5,]TRUE



[6,]TRUE











[[elided Hotmail spam]]







So my question is, how do I perform 'if' statements in order to filter out 
various parts of a dataset, for plotting on a graph.







Many thanks,







Steve







__



R-help@r-project.org mailing list







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



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









--

Henrique Dallazuanna

Curitiba-Paraná-Brasil

25° 25' 40 S 49° 16' 22 O







_







--
Henrique Dallazuanna
Curitiba-Paraná-Brasil

25° 25' 40 S 49° 16' 22 O



_
Win New York holidays with Kellogg’s  Live Search

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


Re: [R] Plotting using 'if' statements

2008-09-05 Thread Henrique Dallazuanna
Use this:

plot(January[c(3, 6)])

On Fri, Sep 5, 2008 at 8:52 AM, Steve Murray [EMAIL PROTECTED] wrote:


 Sorry! Hopefully just one more question!

 I'm now trying to plot columns 3 and 6. I've tried:

  plot(January[3:6])

 ...but this plots columns 4 and 5 too!


 I've also tried:

  plot(January[3],January[6])
  plot(January[3,6])
  plot(January[3]:January[6])

 But these don't produce the right results (instead, errors!)

 Again, I'm sure it's a just a small (but important) detail that I'm
 missing, and I'd be very grateful if anyone could help me out.

 Many thanks again,

 Steve

 
 Date: Thu, 4 Sep 2008 13:52:03 -0300
 From: [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Subject: Re: [R] Plotting using 'if' statements
 CC: r-help@r-project.org

 Use '':

 plot(January[January[,3] 0  January[,3]  2, 3:4])

 On Thu, Sep 4, 2008 at 1:47 PM, Steve Murray  wrote:



 Ah that's great, thank you very much.



 As a follow-on, in the same format, how would I plot where column 3 is
 greater than 0 *but also less than 2*?



 Once again, any help is much appreciated.





 Thanks,



 Steve



 

 Date: Thu, 4 Sep 2008 13:39:12 -0300

 From: [EMAIL PROTECTED]

 To: [EMAIL PROTECTED]

 Subject: Re: [R] Plotting using 'if' statements

 CC: r-help@r-project.org



 Try this:



 plot(January[January[,3] 0, 3:4])



 On Thu, Sep 4, 2008 at 1:28 PM, Steve Murray  wrote:











 Dear all,







 I have a dataset of four columns, and I wish to plot (as a scatter graph)
 the values of the third column where the values are greater than zero, and
 the fourth column.







 I tried doing this via the plot command itself, but got into a bit of a
 mess (resulting in errors!). My dataframe is called 'January':







  plot(January[3(0):4])



 Error: unexpected '' in plot(January[3(











 After a few variations on this, I thought I'd try making a new object which
 includes all values from the third column of January0 (to plot in a
 separate step) as follows:







  JanFilter - January[3]0







 No error here. However, when I display the 'values' of JanFilter, it shows
 that instead of keeping the numerical values, the above operation simply
 displays the results of the logical test:







  head(JanFilter)



   Value



 [1,]   FALSE



 [2,]TRUE



 [3,]TRUE



 [4,]TRUE



 [5,]TRUE



 [6,]TRUE











 This is obviously no good for plotting the numerical values on axes!







 So my question is, how do I perform 'if' statements in order to filter out
 various parts of a dataset, for plotting on a graph.







 Many thanks,







 Steve







 __



 R-help@r-project.org mailing list



 https://stat.ethz.ch/mailman/listinfo/r-help



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



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









 --

 Henrique Dallazuanna

 Curitiba-Paraná-Brasil

 25° 25' 40 S 49° 16' 22 O







 _

 Make a mini you and download it into Windows Live Messenger

 http://clk.atdmt.com/UKM/go/111354029/direct/01/



 --
 Henrique Dallazuanna
 Curitiba-Paraná-Brasil

 25° 25' 40 S 49° 16' 22 O



 _
 Win New York holidays with Kellogg's  Live Search
 http://clk.atdmt.com/UKM/go/111354033/direct/01/




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

[[alternative HTML version deleted]]

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


[R] how to draw the legend about color from 3d picture

2008-09-05 Thread yk
I have drawed a picture with persp, it's 3d map with different color,
indicate different altitude. In gnuplot, the corresponding command
'splot' will generate a picture beside to indicate the relationship
between color and altitude. But in R, how to draw it? I have read the
manual of legend, but they are all about how to draw a legend with
colored text, not a continuous varing color with corresponding number.

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

2008-09-05 Thread Williams, Robin
Hi, 
  I have eight vectors that I would like to orthogonalize preferably
using R. The vectors are of considerable length, however due to their
nature I know they satisfy the conditions needed to apply the
Gram-Schmidt algorithm. Before I embark on some R coding, I wanted to
check that there is no facility / function already around that computes
the orthogonalized set of vectors? I have performed an RSiteSearch etc
with no luck. 
  Anything that could help me along the way would be much appreciated. 
Thanks in advance,
Robin Williams
Met Office summer intern - Health Forecasting
[EMAIL PROTECTED] 
 

[[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] Orthogonalization algorithms

2008-09-05 Thread Williams, Robin
Please ignore this, it appears I have found what I'm looking for in the
far package.   


Robin Williams 
Met Office summer intern - Health Forecasting 
[EMAIL PROTECTED] 
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Williams, Robin
Sent: Friday, September 05, 2008 1:18 PM
To: r-help@r-project.org
Subject: [R] Orthogonalization algorithms

Hi,
  I have eight vectors that I would like to orthogonalize preferably
using R. The vectors are of considerable length, however due to their
nature I know they satisfy the conditions needed to apply the
Gram-Schmidt algorithm. Before I embark on some R coding, I wanted to
check that there is no facility / function already around that computes
the orthogonalized set of vectors? I have performed an RSiteSearch etc
with no luck. 
  Anything that could help me along the way would be much appreciated. 
Thanks in advance,
Robin Williams
Met Office summer intern - Health Forecasting
[EMAIL PROTECTED] 
 

[[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] Error: can not allocate vector of 117.3 Mb

2008-09-05 Thread ram basnet
Hi R users,
 
I am doing multiscale bootstrapping for clustering through pvclust package. I 
have large data set (observations 182 and variables 5546). When i tried to make 
bootstrapping, then i got message as Bootstrap (r = 0.5)Error: 
cannot allocate vector of size 117.3 Mb.
I am new R user and could not understand what is the problem and also don't 
know the easiet solution.
If someone knows, pls help me.
Thanks in advance.
 
Ram Kumar Basnet
Graduate student.


  
[[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: can not allocate vector of 117.3 Mb

2008-09-05 Thread Uwe Ligges



ram basnet wrote:

Hi R users,
 
I am doing multiscale bootstrapping for clustering through pvclust package. I have large data set (observations 182 and variables 5546). When i tried to make bootstrapping, then i got message as Bootstrap (r = 0.5)Error: cannot allocate vector of size 117.3 Mb.

I am new R user and could not understand what is the problem and also don't 
know the easiet solution.
If someone knows, pls help me.


Please read ?Memory

Uwe Ligges



Thanks in advance.
 
Ram Kumar Basnet

Graduate student.


  
	[[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] Plotting using 'if' statements

2008-09-05 Thread Steve Murray

Thanks again for a very quick reply! It worked really well too!



_
Discover Bird's Eye View now with Multimap from Live Search

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 draw the legend about color from 3d picture

2008-09-05 Thread Duncan Murdoch

On 9/5/2008 8:06 AM, yk wrote:

I have drawed a picture with persp, it's 3d map with different color,
indicate different altitude. In gnuplot, the corresponding command
'splot' will generate a picture beside to indicate the relationship
between color and altitude. But in R, how to draw it? I have read the
manual of legend, but they are all about how to draw a legend with
colored text, not a continuous varing color with corresponding number.


I don't think there's an automatic way to do this (though probably some 
package provides one).


If you want to write your own, take a look at example(filled.contour). 
The legend it draws is done by this code:


plot.new()
plot.window(xlim = c(0, 1), ylim = range(levels), xaxs = i,
yaxs = i)
rect(0, levels[-length(levels)], 1, levels[-1], col = col)
if (missing(key.axes)) {
if (axes)
axis(4)
}
else key.axes
box()

(but it has done a lot of setup using layout() and par() before this).

Duncan Murdoch

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


[R] Use of colour in plots

2008-09-05 Thread Steve Murray

Dear all,

I have 3 datasets all of which share the same longitude and latitude values, 
which I'm looking to plot onto a scattergraph. The third dataset has values 
which can only be either '1' or '2'. So to incorporate all three datasets onto 
two axes, I'm wondering if I can plot dataset1 and dataset2 as normal, but then 
use colour to determine whether these points are either values '1' or '2' 
according to the third dataset.

If so, how would I go about doing this in R, and what format would the command 
take?

Thanks for any help offered,

Steve

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


Re: [R] cluster a distance(analogue)-object using agnes(cluster)

2008-09-05 Thread Gavin Simpson
On Thu, 2008-09-04 at 11:28 +0200, Martin Maechler wrote:
  B == Birgitle  [EMAIL PROTECTED]
  on Tue, 2 Sep 2008 03:02:31 -0700 (PDT) writes:
 
 B I try to perform a clustering using an existing dissimilarity matrix 
 that I
 B calculated using distance (analogue)
 B I tried two different things. One of them worked and one not and I 
 don`t
 B understand why.
 B Here the code:
 
 B not working example
 
 B library(cluster)
 B library(analogue)
 
 B iris2 - as.data.frame(iris)
 
 why that? After the above,  iris2  is identical() to iris !
 
 B str(iris2)
 B 'data.frame':  150 obs. of  5 variables:
 B $ Sepal.Length: num  5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
 B $ Sepal.Width : num  3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ...
 B $ Petal.Length: num  1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 ...
 B $ Petal.Width : num  0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
 B $ Species : Factor w/ 3 levels setosa,versicolor,..: 1 1 1 1 1 
 1 1
 B 1 1 1 ...
 
 B Test.Gower - distance(iris2, method =mixed)
 
 why not just 
 daisy(iris2, metric = gower)
 
 daisy() is in cluster which has been a recommended R package
 forever.
 
 So the solution (here, not in general!)
 is to stay with package 'cluster' and use
 daisy() before agnes().

And as the author of distance(), I agree *completely*, and say so in the
Environmetrics Task View.

distance() was written for a very specific task and that it does what
you want it to, Birgit, is side effect of the way I wrote distance().

Anyway, Birgit, you'll be glad to know that the example you included
works in the R-forge version of analogue (0.5-4 to be). Get it from:

https://r-forge.r-project.org/R/?group_id=69

or directly from within R

install.packages(analogue, repos=http://R-Forge.R-project.org;)

if you want to use distance(), but I'd be using the cluster package
tools myself for the problem you emailed about.

You also probably want to use as.dist() on the output from distance() to
store the matrix in a more compact form. Because of how I wanted to
calculate distances (between two data sets), the matrix output was
essential, but this output is storing (and computing) redundant data in
the case you cite (a single matrix).

All the best,

G

 
 Regards,
 Martin Maechler, ETH Zurich  
{same city!  feel free to phone me..}
 
 B Test.Gower.agnes-agnes(Test.Gower, diss=T)
 B Fehler in agnes(Test.Gower, diss = T) : 
 B (list) Objekt kann nicht nach 'logical' umgewandelt werden
 B Error in agnes(Test.Gower, diss=T).
 B (list) object can`t be transformed to logical
 
 B working example only numerics used:
 
 B library(cluster)
 B library(analogue)
 
 B irisPart-subset(iris, select= Sepal.Length:Petal.Width)
 B Dist.Gower - distance(irisPart, method =mixed)
 B AgnesA - agnes(Dist.Gower, method=average, diss=TRUE) 
 
 B Would be great if somebody could help me.
 B The dataset that I would like to use for the clustering also contains
 B factors.
 B and gives me the same Error message as in the not working example.
 
 B Thanks in advance
 
 B B.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,  [f] +44 (0)20 7679 0565
 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

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

2008-09-05 Thread Alan Cox
Hello,  Is it possible to create confidence intervals for hazard rates?  I'm 
creating two muhaz objects:  

haz1 - muhaz(NumDaysCustomer[cRV==true],status[cRV==true])
haz2 - muhaz(NumDaysCustomer[cRV==false],status[cRV==false])

and plotting them.  

There are many, many more observations in the cohort cRV==false than 
==true.  And, there are many more observations with lifetimes in the middle 
of the range than at the ends.  I suspect that this is a common phenomenon.
When I plot the two hazard rate curves, haz1 looks very different than haz2, 
but I'd like to see if it's different enough.  How can I go about creating 
confidence intervals and plotting them?

Thanks,  Alan 


-- 
Alan Cox 
Director, User Experience 
iContact, Corp. 
p 919.459.1038 f 919.287.2475 

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

2008-09-05 Thread David Carslaw

Hi R people,

I want to write some functions to automate the plotting of some expressions
that use some of the plotmath capabilities.

An example is a string supplied to a plot call such as:

plot(1, 1, ylab = pm10 (ug/m3))

This should actually appear like:

plot(1, 1, ylab = expression(PM[10] *  ( * mu * g m ^-3 * )))

 i.e. pollutant name, units

What I would like to do is write a function that will automatically detect
certain strings, reformat them, and supply it as an argument to plot.  I
could just search for the whole string, but I would like something more
flexible because there will be many combinations of pollutant (pm10, nox,
no2...) and units (ug/m3, mg/m3, ng/m3...).

My question is this - is there a way to separately process the pollutant and
units and supply the correct overall expression to plot?

I'm not sure of the best strategy for this having read through previous
posts etc., and would appreciate your help!

Many thanks.

David Carslaw

-
Institute for Transport Studies
University of Leeds
-- 
View this message in context: 
http://www.nabble.com/text-processing-for-plots-tp19331219p19331219.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] Maximum likelihood estimation

2008-09-05 Thread Ravi Varadhan
Hi,


You should re-write your function `fr' as follows:


fr - function(par){
a - par[1]
b - par[2]
p - par[3]
lambda - par[4]

l - 0.5*(lambda + b*p + (1-p)*(lambda-b))
l^2  lambda*b*p
delta - sqrt(abs(l^2 - b*p*lambda))
mt - a/p*(1-exp(-l*t)*cosh(delta*t)-(l-b*p)*exp(-t)*sinh(delta*t)/delta)
logl - sum(diff(y)*log(diff(mt))-diff(mt)-lfactorial(diff(y)))
return(-logl)
}

However, I don't understand what the following fragment is doing in `fr':

l^2  lambda*b*p

Can you clarfy that?

Ravi.


---

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: [EMAIL PROTECTED]

Webpage:  http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html

 





-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of toh
Sent: Thursday, September 04, 2008 9:15 PM
To: r-help@r-project.org
Subject: Re: [R] Maximum likelihood estimation


Yes I'm trying to optimize the parameters a, b, p and lambda where a  0, b
 0 and 0  p  1. I attached the error message that I got when I run mle. 


 t - c(1:90)
 y -
 c(5,10,15,20,26,34,36,43,47,49,80,84,108,157,171,183,191,200,204,211,2
 17,226,230,
+
234,236,240,243,252,254,259,263,264,268,271,277,290,309,324,331,346,367,375,
381,
+
401,411,414,417,425,430,431,433,435,437,444,446,446,448,451,453,460,463,463,
464,
+
464,465,465,465,466,467,467,467,468,469,469,469,469,470,472,472,473,473,473,
473,
+ 473,473,473,475,475,475,475)
 
 library(stats4)
 fr - function(a, b, p, lambda){
+ l - 0.5*(lambda + b*p + (1-p)*(lambda-b))
+ l^2  lambda*b*p
+ delta - sqrt(abs(l^2 - b*p*lambda))
+ mt - 
+ a/p*(1-exp(-l*t)*cosh(delta*t)-(l-b*p)*exp(-t)*sinh(delta*t)/delta)
+ logl - sum(diff(y)*log(diff(mt))-diff(mt)-lfactorial(diff(y)))
+ return(-logl)
+ }
 
 mle(start=list(a=12,b=0.01,p=0.5,lambda=0.01),fr, method=L-BFGS-B,
+ lower = c(0.002, 0.002, 0.002, 0.002), upper = c(Inf, Inf, 0.999,
Inf),control=list(fnscale=-1))
Error in optim(start, f, method = method, hessian = TRUE, ...) : 
  non-finite finite-difference value [3]












Prof Brian Ripley wrote:
 
From ?optim
 
fn: A function to be minimized (or maximized), with first
argument the vector of parameters over which minimization is
to take place.  It should return a scalar result.
 
 I think you intended to optimize over c(a,b,p, lambda), so you need to 
 specify them as a single vector.
 
 You may be making life unnecessarily hard for yourself: see function 
 mle() in package stats4.
 
 Showing your code without a verbal description of what you are doing 
 nor the error message you got is less helpful than we need.
 
 On Wed, 3 Sep 2008, toh wrote:
 

 Hi R-experts,
 I'm new to R in mle. I tried to do the following but just couldn't 
 get it right. Hope someone can point out the mistakes. thanks a lot.

 t - c(1:90)
 y -
 c(5,10,15,20,26,34,36,43,47,49,80,84,108,157,171,183,191,200,204,211,
 217,226,230,

 234,236,240,243,252,254,259,263,264,268,271,277,290,309,324,331,346,3
 67,375,381,

 401,411,414,417,425,430,431,433,435,437,444,446,446,448,451,453,460,4
 63,463,464,


464,465,465,465,466,467,467,467,468,469,469,469,469,470,472,472,473,473,473,
473,
  473,473,473,475,475,475,475)
 fr - function(a, b, p, lambda){
 l - 0.5*(lambda + b*p + (1-p)*(lambda-b))
 l^2  lambda*b*p
 delta - sqrt(abs(l^2 - b*p*lambda))
 mt - 
 a/p*(1-exp(-l*t)*cosh(delta*t)-(l-b*p)*exp(-t)*sinh(delta*t)/delta)
 logl - sum(diff(y)*log(diff(mt))-diff(mt)-lfactorial(diff(y)))
 return(-logl)
 }
 optim(c(15,0.01,0.5,0.01),fr, method=L-BFGS-B, lower = c(0.002, 
 0.002, 0.002, 0.002), upper = c(Inf, Inf, 0.999,
 Inf),control=list(fnscale=-1))

 --
 View this message in context:
 http://www.nabble.com/Maximum-likelihood-estimation-tp19304249p193042
 49.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.

 
 -- 
 Brian D. Ripley,  [EMAIL PROTECTED]
 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.
 
 

--
View this message in 

Re: [R] Error: can not allocate vector of 117.3 Mb

2008-09-05 Thread Tom La Bone

To see some useful discussions of this problem in various settings search
R-Help for the phrase cannot allocate vector of size.

Tom



ram basnet wrote:
 
 Hi R users,
  
 I am doing multiscale bootstrapping for clustering through pvclust
 package. I have large data set (observations 182 and variables 5546). When
 i tried to make bootstrapping, then i got message as Bootstrap (r =
 0.5)Error: cannot allocate vector of size 117.3 Mb.
 I am new R user and could not understand what is the problem and also
 don't know the easiet solution.
 If someone knows, pls help me.
 Thanks in advance.
  
 Ram Kumar Basnet
 Graduate student.
 
 
   
   [[alternative HTML version deleted]]
 
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/Error%3A-can-not-allocate-vector-of-117.3-Mb-tp19330258p19331629.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] Question about col.names in write.csv

2008-09-05 Thread Luz Milena Zea Fernandez
Dear support, I don't ignore col.names in write.csv. I want to write names for 
the firts row. How can I do?

Thanks in advance

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


Re: [R] (with subject)

2008-09-05 Thread Dr Eberhard W Lisse

Oh, YES, thank you!

This weekend I'll try and figure out how to plot these events on
a 24 hour scale, i.e I'll aggregate the SQL query on the time
But not on the date) to see how many of those fall outside of
normal working hours :-)-O

greetings, el

On 05 Sep 2008, at 00:59 , Gabor Grothendieck wrote:


I assume the problem is that you want the axis to have all 12
months but your data is much shorter.  Try this:

mos - seq(as.Date(2008-01-01), length = 12, by = month)
plot(range(mos), range(rawData$y), type = n, xaxt = n)
lines(rawData$Date, rawData$y)
axis(1, mos, month.abb)


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


Re: [R] Use of colour in plots

2008-09-05 Thread John Kane
Here is an example doing the same type of thing.  
It should be easy enough to adapt. 

Good luck

===
x - runif(100, 0, 1)
y - runif(100, 0, 1)
z - data.frame(x,y)

 plot(subset(z, z$y =.5), col=red, ylim=c(min(z$y),
 max(z$y)), pch=16) 
 points(subset(z, z$y =.49), col=blue, pch=16)
===


--- On Fri, 9/5/08, Steve Murray [EMAIL PROTECTED] wrote:

 From: Steve Murray [EMAIL PROTECTED]
 Subject: [R] Use of colour in plots
 To: r-help@r-project.org
 Received: Friday, September 5, 2008, 9:10 AM
 Dear all,
 
 I have 3 datasets all of which share the same longitude and
 latitude values, which I'm looking to plot onto a
 scattergraph. The third dataset has values which can only be
 either '1' or '2'. So to incorporate all
 three datasets onto two axes, I'm wondering if I can
 plot dataset1 and dataset2 as normal, but then use colour to
 determine whether these points are either values '1'
 or '2' according to the third dataset.
 
 If so, how would I go about doing this in R, and what
 format would the command take?
 
 Thanks for any help offered,
 
 Steve
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Example on Maximum likelihood estimation using R

2008-09-05 Thread VincentLee

Hi all,

I am very new to R too, but I read that R is powerful.

May I know given a set of data, are there any simple examples on using mle()
to estimate parameters of a lognormal and weibull distribution ?

Hope to hear from you soon.
Thank you

Vincent  




Ravi Varadhan wrote:
 
 Hi,
 
 
 You should re-write your function `fr' as follows:
 
 
 fr - function(par){
 a - par[1]
 b - par[2]
 p - par[3]
 lambda - par[4]
 
 l - 0.5*(lambda + b*p + (1-p)*(lambda-b))
 l^2  lambda*b*p
 delta - sqrt(abs(l^2 - b*p*lambda))
 mt - a/p*(1-exp(-l*t)*cosh(delta*t)-(l-b*p)*exp(-t)*sinh(delta*t)/delta)
 logl - sum(diff(y)*log(diff(mt))-diff(mt)-lfactorial(diff(y)))
 return(-logl)
 }
 
 However, I don't understand what the following fragment is doing in `fr':
 
 l^2  lambda*b*p
 
 Can you clarfy that?
 
 Ravi.
 
 
 ---
 
 Ravi Varadhan, Ph.D.
 
 Assistant Professor, The Center on Aging and Health
 
 Division of Geriatric Medicine and Gerontology 
 
 Johns Hopkins University
 
 Ph: (410) 502-2619
 
 Fax: (410) 614-9625
 
 Email: [EMAIL PROTECTED]
 
 Webpage:  http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html
 
  
 
 
 
 
 
 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
 On
 Behalf Of toh
 Sent: Thursday, September 04, 2008 9:15 PM
 To: r-help@r-project.org
 Subject: Re: [R] Maximum likelihood estimation
 
 
 Yes I'm trying to optimize the parameters a, b, p and lambda where a  0,
 b
 0 and 0  p  1. I attached the error message that I got when I run mle. 
 
 
 t - c(1:90)
 y -
 c(5,10,15,20,26,34,36,43,47,49,80,84,108,157,171,183,191,200,204,211,2
 17,226,230,
 +
 234,236,240,243,252,254,259,263,264,268,271,277,290,309,324,331,346,367,375,
 381,
 +
 401,411,414,417,425,430,431,433,435,437,444,446,446,448,451,453,460,463,463,
 464,
 +
 464,465,465,465,466,467,467,467,468,469,469,469,469,470,472,472,473,473,473,
 473,
 + 473,473,473,475,475,475,475)
 
 library(stats4)
 fr - function(a, b, p, lambda){
 + l - 0.5*(lambda + b*p + (1-p)*(lambda-b))
 + l^2  lambda*b*p
 + delta - sqrt(abs(l^2 - b*p*lambda))
 + mt - 
 + a/p*(1-exp(-l*t)*cosh(delta*t)-(l-b*p)*exp(-t)*sinh(delta*t)/delta)
 + logl - sum(diff(y)*log(diff(mt))-diff(mt)-lfactorial(diff(y)))
 + return(-logl)
 + }
 
 mle(start=list(a=12,b=0.01,p=0.5,lambda=0.01),fr, method=L-BFGS-B,
 + lower = c(0.002, 0.002, 0.002, 0.002), upper = c(Inf, Inf, 0.999,
 Inf),control=list(fnscale=-1))
 Error in optim(start, f, method = method, hessian = TRUE, ...) : 
   non-finite finite-difference value [3]
 
 
 
 
 
 
 
 
 
 
 
 
 Prof Brian Ripley wrote:
 
From ?optim
 
fn: A function to be minimized (or maximized), with first
argument the vector of parameters over which minimization is
to take place.  It should return a scalar result.
 
 I think you intended to optimize over c(a,b,p, lambda), so you need to 
 specify them as a single vector.
 
 You may be making life unnecessarily hard for yourself: see function 
 mle() in package stats4.
 
 Showing your code without a verbal description of what you are doing 
 nor the error message you got is less helpful than we need.
 
 On Wed, 3 Sep 2008, toh wrote:
 

 Hi R-experts,
 I'm new to R in mle. I tried to do the following but just couldn't 
 get it right. Hope someone can point out the mistakes. thanks a lot.

 t - c(1:90)
 y -
 c(5,10,15,20,26,34,36,43,47,49,80,84,108,157,171,183,191,200,204,211,
 217,226,230,

 234,236,240,243,252,254,259,263,264,268,271,277,290,309,324,331,346,3
 67,375,381,

 401,411,414,417,425,430,431,433,435,437,444,446,446,448,451,453,460,4
 63,463,464,


 464,465,465,465,466,467,467,467,468,469,469,469,469,470,472,472,473,473,473,
 473,
 473,473,473,475,475,475,475)
 fr - function(a, b, p, lambda){
 l - 0.5*(lambda + b*p + (1-p)*(lambda-b))
 l^2  lambda*b*p
 delta - sqrt(abs(l^2 - b*p*lambda))
 mt - 
 a/p*(1-exp(-l*t)*cosh(delta*t)-(l-b*p)*exp(-t)*sinh(delta*t)/delta)
 logl - sum(diff(y)*log(diff(mt))-diff(mt)-lfactorial(diff(y)))
 return(-logl)
 }
 optim(c(15,0.01,0.5,0.01),fr, method=L-BFGS-B, lower = c(0.002, 
 0.002, 0.002, 0.002), upper = c(Inf, Inf, 0.999,
 Inf),control=list(fnscale=-1))

 --
 View this message in context:
 http://www.nabble.com/Maximum-likelihood-estimation-tp19304249p193042
 49.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.

 
 -- 
 Brian D. Ripley,  [EMAIL PROTECTED]
 Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
 University of Oxford, Tel:  +44 1865 272861 (self)
 1 South Parks Road, +44 

[R] using nls to fit a curve to data

2008-09-05 Thread jpl

Hi,

I am trying to fit a curve to data.  My command line is:

model10=nls(offspring~((A*c^k)/gamma(k))*((degdays-alpha)^(k-1))*exp(-c*(degdays-alpha)),
start=list(A=30,k=2,c=.018,alpha=131))

I get the error message:
Error in numericDeriv(form[[3]], names(ind), env) : 
Missing value or an infinity produced when evaluating the model
In addition: Warning message:
full precision was not achieved in 'gammafn' 


My starting values yield a curve very similar t to other models which I
fitted successfully.  So any suggestions?  I've tried different starting
values. 
-- 
View this message in context: 
http://www.nabble.com/using-nls-to-fit-a-curve-to-data-tp19332210p19332210.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] Use of colour in plots

2008-09-05 Thread Petr PIKAL
Hi

[EMAIL PROTECTED] napsal dne 05.09.2008 16:24:35:

 Here is an example doing the same type of thing. 
 It should be easy enough to adapt. 
 
 Good luck
 
 ===
 x - runif(100, 0, 1)
 y - runif(100, 0, 1)
 z - data.frame(x,y)
 
  plot(subset(z, z$y =.5), col=red, ylim=c(min(z$y),
  max(z$y)), pch=16) 
  points(subset(z, z$y =.49), col=blue, pch=16)
 ===

Or

third - (z$y =.5)+1
plot(z, col=third, pch=16)

Just tell to col a vector of colors with appropriate use of logical.

Or you can use col = as.numeric(some factor), which is quite convenient 
use of factors feature which is not desired in other cases.
See warning section of factor help page.

Regards

 
 
 --- On Fri, 9/5/08, Steve Murray [EMAIL PROTECTED] wrote:
 
  From: Steve Murray [EMAIL PROTECTED]
  Subject: [R] Use of colour in plots
  To: r-help@r-project.org
  Received: Friday, September 5, 2008, 9:10 AM
  Dear all,
  
  I have 3 datasets all of which share the same longitude and
  latitude values, which I'm looking to plot onto a
  scattergraph. The third dataset has values which can only be
  either '1' or '2'. So to incorporate all
  three datasets onto two axes, I'm wondering if I can
  plot dataset1 and dataset2 as normal, but then use colour to
  determine whether these points are either values '1'
  or '2' according to the third dataset.
  
  If so, how would I go about doing this in R, and what
  format would the command take?
  
  Thanks for any help offered,
  
  Steve
  
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/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] Density estimates in modelling framework

2008-09-05 Thread hadley wickham
Thanks for all your replies.  The suggestions I got were:

  * gss
  * logspline
  * locfit

I ended up using locfit because the interface was just right for my
needs, and it was faster than the alternatives.

Hadley

On Fri, Aug 29, 2008 at 2:03 PM, hadley wickham [EMAIL PROTECTED] wrote:
 Hi all,

 Do any packages implement density estimation in a modelling framework?
  I want to be able to do something like:

 dmodel - density(~ a + b, data = mydata)
 predict(dmodel, newdata)

 This isn't how sm or KernSmooth or base density estimation works.  Are
 there other packages that do density estimation?  Or is there some
 reason that this is a bad idea.

 Hadley

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




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

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


Re: [R] ggplot2: Changes to grobs not saved to file output

2008-09-05 Thread hadley wickham
Unfortunately it's not particularly easy in the current version.  In
the next version, you can do:

p - qplot(wt, mpg, data=mtcars, colour=cyl)
# Get the plot grob
grob - ggplotGrob(p)
# Modify it place
grob - geditGrob(grob, gPath(strip,label), gp=gpar(fontface=bold))

# Draw it
pdf(...)
grid.newpage()
grid.draw(grob)
dev.off()

I think in the current version you can do

qplot(wt, mpg, data=mtcars, colour=cyl)
grob - grid.grab()

and then follow the remaining steps.

Regards,

Hadley

On Fri, Aug 29, 2008 at 8:58 AM, btcruiser [EMAIL PROTECTED] wrote:

 Hello,

 Maybe I missed something - most likely .:-(

 I create a gplot and then makes some changes to the plot using grid graphics
 functions. These changes show up on the display OK, but when I save using
 ggsave() the grid changes do not show up. How do I save the plot with these
 changes?

 Thanks in advance.
 --
 View this message in context: 
 http://www.nabble.com/ggplot2%3A-Changes-to-grobs-not-saved-to-file-output-tp19220492p19220492.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.




-- 
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] binary order combinations

2008-09-05 Thread Dimitri Liakhovitski
Dear all!

I have a vector of names
names-(V1, V2, V3,., V15)

I could create all possible combinations of these names (of all
lengths) using R:

combos-lapply(1:15,function(x)
{combn(names,x)
})

I get a list with all possible combinations of elements of 'names'
that looks like this (just the very beginning of it):

[[1]] - the first element contains all combinations of 1 name
 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14]
[1,] V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13 V14
 [,15]
[1,] V15

[[2]] - the second element contains all possible combinations of 2 names
 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]  [,10] [,11] [,12] [,13]
[1,] V1 V1 V1 V1 V1 V1 V1 V1 V1  V1  V1  V1  V1
[2,] V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13 V14
.
.
.
etc.

My question is: Is there any way to re-arrange all sub-elements of the
above list (i.e., all possible combinations of names such as V1,
V1:V3, V1:V2:V4:V5) in a binary system order. More specifically,
according to this system:
V1=1
V2=2
V3=4
V4=8
V5=16, etc

So, I'd like those combinations to be arranged in a vector in the
following order:
1. V1 (because V1=1)
2. V2 (because V2=2)
3. V1:V2 (because V1=1 and V2=2 so that 1+2=3)
4. V3 (because V3=4)
5. V1:V3 (because V1=1 and V3=4 so that 1+4=5)
6. V2:V3 (because V2=2 and V3=4 so that 2+4=6)
7. V1:V2:V3 (because V1=1 and V2=2 and V3=4 so that 1+2+4=7)
8. V4 (because V4=8)
etc.

Is it at all possible?
Or maybe there is a way to create the name combinations in such an
order in the first place?

Thank you very much!
Dimitri Liakhovitski

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


Re: [R] binary order combinations

2008-09-05 Thread roger koenker

Does ?combos in the quantreg package do what you want?


url:www.econ.uiuc.edu/~rogerRoger Koenker
email[EMAIL PROTECTED]Department of Economics
vox: 217-333-4558University of Illinois
fax:   217-244-6678Champaign, IL 61820



On Sep 5, 2008, at 9:58 AM, Dimitri Liakhovitski wrote:


Dear all!

I have a vector of names
names-(V1, V2, V3,., V15)

I could create all possible combinations of these names (of all
lengths) using R:

combos-lapply(1:15,function(x)
{combn(names,x)
})

I get a list with all possible combinations of elements of 'names'
that looks like this (just the very beginning of it):

[[1]] - the first element contains all combinations of 1 name
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [, 
13] [,14]
[1,] V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12  
V13 V14

[,15]
[1,] V15

[[2]] - the second element contains all possible combinations of 2  
names
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]  [,10] [,11] [,12]  
[,13]
[1,] V1 V1 V1 V1 V1 V1 V1 V1 V1  V1  V1  V1   
V1
[2,] V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13  
V14

.
.
.
etc.

My question is: Is there any way to re-arrange all sub-elements of the
above list (i.e., all possible combinations of names such as V1,
V1:V3, V1:V2:V4:V5) in a binary system order. More specifically,
according to this system:
V1=1
V2=2
V3=4
V4=8
V5=16, etc

So, I'd like those combinations to be arranged in a vector in the
following order:
1. V1 (because V1=1)
2. V2 (because V2=2)
3. V1:V2 (because V1=1 and V2=2 so that 1+2=3)
4. V3 (because V3=4)
5. V1:V3 (because V1=1 and V3=4 so that 1+4=5)
6. V2:V3 (because V2=2 and V3=4 so that 2+4=6)
7. V1:V2:V3 (because V1=1 and V2=2 and V3=4 so that 1+2+4=7)
8. V4 (because V4=8)
etc.

Is it at all possible?
Or maybe there is a way to create the name combinations in such an
order in the first place?

Thank you very much!
Dimitri Liakhovitski

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] controlling lattice plot ticks with relation=free

2008-09-05 Thread Richard . Cotton
 How do you persuade lattice to draw tick marks on both the left and 
right 
 side of the y-axis, when relation=free in the scales component?
 
 #Ticks appear on both sides
 histogram(~height|voice.part, data=singer)
 
 ##Ticks only on left
 histogram(~height|voice.part, data=singer, 
 scales=list(y=list(relation=free)))

I had an off list reply that was very helpful, suggesting the use of 
panel.axis.   For posterity, here's my own answer to my problem, using 
yscale.component. It's not a particularly natural solution, and it 
requires manually increasing the horizontal spacing between plots (with 
the between agrument), but it works.

myyscale.component - function(...)
{
  ans - yscale.components.default(...)
  ans$right - ans$left
  ans$right$labels$labels - NULL
  ans
} 

histogram(~height|voice.part, data=singer, 
   scales=list(y=list(relation=free)),
   yscale.component=myyscale.component,
   between=list(x=.5))

Regards,
Richie.

Mathematical Sciences Unit
HSL



ATTENTION:

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

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


[R] Time Series (attribute)

2008-09-05 Thread Oliver Bandel
Hello,

what kind of advantages does R's time series offer?

Would it be possible to use data with units?

For example data from a real time series with certain
sampling rates - could they be used so,
that the sample-times are measured in millisceonds or
microseconds, instead of an index of the positions?

If so, this would be much easier to handle than just
working with indices of a vector.

If the above mentioned way would not be possible, for what
is this timeseries-attribute (?) useful?


Ciao,
   Oliver

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


Re: [R] binary order combinations

2008-09-05 Thread Dimitri Liakhovitski
I am not sure it can do it. Besides, I ran a test of combos from quantreg:

library(quantreg)
H-1:3
test.combos-lapply(1:3,function(x)
{combn(H,x)
})

Every time I tried it crashed my R...

:(

Dimitri

On 9/5/08, roger koenker [EMAIL PROTECTED] wrote:
 Does ?combos in the quantreg package do what you want?


 url:www.econ.uiuc.edu/~rogerRoger Koenker
 email[EMAIL PROTECTED]Department of Economics
 vox: 217-333-4558University of Illinois
 fax:   217-244-6678Champaign, IL 61820




 On Sep 5, 2008, at 9:58 AM, Dimitri Liakhovitski wrote:

 
  Dear all!
 
  I have a vector of names
  names-(V1, V2, V3,., V15)
 
  I could create all possible combinations of these names (of all
  lengths) using R:
 
  combos-lapply(1:15,function(x)
  {combn(names,x)
  })
 
  I get a list with all possible combinations of elements of 'names'
  that looks like this (just the very beginning of it):
 
  [[1]] - the first element contains all combinations of 1 name
 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13]
 [,14]
  [1,] V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13
 V14
 [,15]
  [1,] V15
 
  [[2]] - the second element contains all possible combinations of 2 names
 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]  [,10] [,11] [,12] [,13]
  [1,] V1 V1 V1 V1 V1 V1 V1 V1 V1  V1  V1  V1  V1
  [2,] V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13 V14
  .
  .
  .
  etc.
 
  My question is: Is there any way to re-arrange all sub-elements of the
  above list (i.e., all possible combinations of names such as V1,
  V1:V3, V1:V2:V4:V5) in a binary system order. More specifically,
  according to this system:
  V1=1
  V2=2
  V3=4
  V4=8
  V5=16, etc
 
  So, I'd like those combinations to be arranged in a vector in the
  following order:
  1. V1 (because V1=1)
  2. V2 (because V2=2)
  3. V1:V2 (because V1=1 and V2=2 so that 1+2=3)
  4. V3 (because V3=4)
  5. V1:V3 (because V1=1 and V3=4 so that 1+4=5)
  6. V2:V3 (because V2=2 and V3=4 so that 2+4=6)
  7. V1:V2:V3 (because V1=1 and V2=2 and V3=4 so that 1+2+4=7)
  8. V4 (because V4=8)
  etc.
 
  Is it at all possible?
  Or maybe there is a way to create the name combinations in such an
  order in the first place?
 
  Thank you very much!
  Dimitri Liakhovitski
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/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] Lowest k values of list

2008-09-05 Thread Markus Mühlbacher
Hi @ all,

how do I get the largest or lowest k values of list? It must similar to the 
min() / max() function, but I just don't get it. 

Best wishes,
Markus




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


[R] Plot by column

2008-09-05 Thread Zhang Yanwei - Princeton-MRAm
Dear list,

 I have the following matrix. How can I make the following plot?
 1. The x-axis has index 1:7, and the first column is plotted against index 1, 
second against 2, and so on.
 2. I want the points from the left upper conner including the antidiagonal to 
be plotted with col=2, and the rest with col=3
  [,1]  [,2]  [,3]  [,4]  [,5]  [,6]  [,7]
[1,] 0.589 0.857 0.923 0.944 0.954 0.963 0.980
[2,] 0.470 0.763 0.877 0.900 0.911 0.957 0.974
[3,] 0.486 0.863 0.905 0.960 0.968 0.998 1.015
[4,] 0.653 0.888 0.943 0.952 0.962 0.992 1.009
[5,] 0.664 0.774 0.958 0.986 0.996 1.027 1.045
[6,] 0.546 0.910 1.011 1.041 1.051 1.083 1.102
[7,] 0.407 0.600 0.667 0.686 0.693 0.715 0.727


The following the my code to do the above with the matrix called r. How can I 
simply the code?


plot(r[,1],type=n,ylim=c(0.4,1.2))
for (i in 1:7)
 {points(rep(i,8-i),r[,i][1:(8-i)],col=2) }
for (i in 2:7)
 {points(rep(i,(i-1)),r[,i][(9-i):7],col=3)}

Thanks


Sincerely,
Yanwei Zhang
Department of Actuarial Research and Modeling
Munich Re America
mailto:[EMAIL PROTECTED]

[[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] Upgrade to R 2.7.2 from Debian Repository

2008-09-05 Thread Dirk Eddelbuettel

Tom,

(That's a suitable question for r-sig-debian)

On 5 September 2008 at 03:08, Tom La Bone wrote:
| I am running R 2.7.1 on an eeepc with the standard Xandros Linux. I
| install/upgrade R binaries using synaptic from the
| http://cran.r-project.org/bin/linux/debian/etch-cran/ repository. R 2.7.2
| does not appear to be available from this repository. Will it be available
| soon or is there another repository I should be using?

The volunteer who is providing these backports for CRAN indicated a few days
ago that he is being slowed down due to network issues.  So sorry, right now
you either have to wait, fine someone else to build the .deb files on etch
for you, or do it yourself.  We do have the Ubuntu backports in place so if
you were contemplating switching your Xandros install with the Ubuntu/EEE
setup you'd be covered...  

Dirk

-- 
Three out of two people have difficulties with fractions.

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


Re: [R] Confidence Intervals on Hazard Plots

2008-09-05 Thread David Winsemius


On Sep 5, 2008, at 9:20 AM, Alan Cox wrote:

Hello,  Is it possible to create confidence intervals for hazard  
rates?  I'm creating two muhaz objects:


haz1 - muhaz(NumDaysCustomer[cRV==true],status[cRV==true])
haz2 - muhaz(NumDaysCustomer[cRV==false],status[cRV==false])

and plotting them.

There are many, many more observations in the cohort cRV==false  
than ==true.  And, there are many more observations with lifetimes  
in the middle of the range than at the ends.  I suspect that this is  
a common phenomenon.When I plot the two hazard rate curves, haz1  
looks very different than haz2, but I'd like to see if it's  
different enough.  How can I go about creating confidence intervals  
and plotting them?


?muhaz.object  says that var.min and bias.min could be extracted from  
haz1 and haz2, since you have not changed the default for bw.method.


The default haz.est vector is twice as long as the default var.min  
vector, so you will need to take care to only plot the haz.est values  
only for the the event times, or perhaps you could specify that  
n.est.grid be the same as n.min.grid at the time of creating your  
fits. Not sure if the second method might have any undesirable side- 
effects, however.


--
David Winsemius
Heritage Laboratories

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

2008-09-05 Thread Alexy Khrabrov
Certain timeseries I have had outliers, which I removed by assigning  
NA to their positions.  Now acf() refuses to go to work.  What's the  
right way to remove outliers from ts objects, and what are teh  
standard ways to interpolate NAs in them?


Cheers,
Alexy

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


Re: [R] Time Series (attribute)

2008-09-05 Thread Gabor Grothendieck
The zoo package can handle series with times of any class that
is totally ordered and provides certain methods.  That
includes all common time classes and allows for you to define
new time classes too.  See

library(zoo)
?zoo

and the three vignettes (i.e. pdf documents) that come with it.

On Fri, Sep 5, 2008 at 11:22 AM, Oliver Bandel
[EMAIL PROTECTED] wrote:
 Hello,

 what kind of advantages does R's time series offer?

 Would it be possible to use data with units?

 For example data from a real time series with certain
 sampling rates - could they be used so,
 that the sample-times are measured in millisceonds or
 microseconds, instead of an index of the positions?

 If so, this would be much easier to handle than just
 working with indices of a vector.

 If the above mentioned way would not be possible, for what
 is this timeseries-attribute (?) useful?


 Ciao,
   Oliver

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

2008-09-05 Thread Jorge Ivan Velez
Dear Markus,
Try this:

# Data set
set.seed(123)
mylist=list(a=rnorm(10),b=rpois(15,10),f=rnorm(30,12,3))
mylist


# min and max
temp=lapply(mylist,function(x){
 res=c(min(x),max(x))
 names(res)=c('Min.','Max.')
 res
}
)

do.call(rbind,temp)
Min.  Max.
a -1.265061  1.715065
b  3.00 15.00
f  7.353742 18.506868


HTH,

Jorge



On Fri, Sep 5, 2008 at 11:26 AM, Markus Mühlbacher [EMAIL PROTECTED]wrote:

 Hi @ all,

 how do I get the largest or lowest k values of list? It must similar to the
 min() / max() function, but I just don't get it.

 Best wishes,
 Markus




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

2008-09-05 Thread David Winsemius


On Sep 5, 2008, at 11:26 AM, Markus Mühlbacher wrote:


Hi @ all,

how do I get the largest or lowest k values of list? It must similar  
to the min() / max() function, but I just don't get it.



Might depend on how you define high and low. Consider these  
experiments:


 z - list(1,4,5,6,,2,3)
 head(sort(unlist(z)),n=2)
[1] 1 2
 tail(sort(unlist(z)),n=2)
[1] 5 6


 z - list(1,2,3,4,5,6,a)
 tail(sort(unlist(z)),n=2)
[1] 6 a
 head(sort(unlist(z)),n=2)
[1] 1 2



--
David Winsemius

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


Re: [R] binary order combinations

2008-09-05 Thread Henrik Bengtsson
names - sprintf(V%d, 1:4);
n - length(names);
stopifnot(n = 32); # Theoretical upper limit
x - matrix(intToBits(1:(2^n-1)), ncol=2^n-1);
x - x[1:n,,drop=FALSE];
keys - apply(x, MARGIN=2, FUN=function(z) paste(names[as.logical(z)],
collapse=:));
print(keys);

 [1] V1  V2  V1:V2   V3
 [5] V1:V3   V2:V3   V1:V2:V3V4
 [9] V1:V4   V2:V4   V1:V2:V4V3:V4
[13] V1:V3:V4V2:V3:V4V1:V2:V3:V4

/H

On Fri, Sep 5, 2008 at 8:23 AM, Dimitri Liakhovitski [EMAIL PROTECTED] wrote:
 I am not sure it can do it. Besides, I ran a test of combos from quantreg:

 library(quantreg)
 H-1:3
 test.combos-lapply(1:3,function(x)
 {combn(H,x)
 })

 Every time I tried it crashed my R...

 :(

 Dimitri

 On 9/5/08, roger koenker [EMAIL PROTECTED] wrote:
 Does ?combos in the quantreg package do what you want?


 url:www.econ.uiuc.edu/~rogerRoger Koenker
 email[EMAIL PROTECTED]Department of Economics
 vox: 217-333-4558University of Illinois
 fax:   217-244-6678Champaign, IL 61820




 On Sep 5, 2008, at 9:58 AM, Dimitri Liakhovitski wrote:

 
  Dear all!
 
  I have a vector of names
  names-(V1, V2, V3,., V15)
 
  I could create all possible combinations of these names (of all
  lengths) using R:
 
  combos-lapply(1:15,function(x)
  {combn(names,x)
  })
 
  I get a list with all possible combinations of elements of 'names'
  that looks like this (just the very beginning of it):
 
  [[1]] - the first element contains all combinations of 1 name
 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13]
 [,14]
  [1,] V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13
 V14
 [,15]
  [1,] V15
 
  [[2]] - the second element contains all possible combinations of 2 names
 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]  [,10] [,11] [,12] [,13]
  [1,] V1 V1 V1 V1 V1 V1 V1 V1 V1  V1  V1  V1  V1
  [2,] V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13 V14
  .
  .
  .
  etc.
 
  My question is: Is there any way to re-arrange all sub-elements of the
  above list (i.e., all possible combinations of names such as V1,
  V1:V3, V1:V2:V4:V5) in a binary system order. More specifically,
  according to this system:
  V1=1
  V2=2
  V3=4
  V4=8
  V5=16, etc
 
  So, I'd like those combinations to be arranged in a vector in the
  following order:
  1. V1 (because V1=1)
  2. V2 (because V2=2)
  3. V1:V2 (because V1=1 and V2=2 so that 1+2=3)
  4. V3 (because V3=4)
  5. V1:V3 (because V1=1 and V3=4 so that 1+4=5)
  6. V2:V3 (because V2=2 and V3=4 so that 2+4=6)
  7. V1:V2:V3 (because V1=1 and V2=2 and V3=4 so that 1+2+4=7)
  8. V4 (because V4=8)
  etc.
 
  Is it at all possible?
  Or maybe there is a way to create the name combinations in such an
  order in the first place?
 
  Thank you very much!
  Dimitri Liakhovitski
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/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] Lowest k values of list

2008-09-05 Thread jim holtman
Do you mean a vector? If so, head/tail will work for you:

 x - runif(10)
 x
 [1] 0.26550866 0.37212390 0.57285336 0.90820779 0.20168193 0.89838968
0.94467527
 [8] 0.66079779 0.62911404 0.06178627
 # lowest 5
 head(sort(x), 5)
[1] 0.06178627 0.20168193 0.26550866 0.37212390 0.57285336
 # highest 5
 tail(sort(x), 5)
[1] 0.6291140 0.6607978 0.8983897 0.9082078 0.9446753



On Fri, Sep 5, 2008 at 11:26 AM, Markus Mühlbacher [EMAIL PROTECTED] wrote:
 Hi @ all,

 how do I get the largest or lowest k values of list? It must similar to the 
 min() / max() function, but I just don't get it.

 Best wishes,
 Markus




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




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

What is the problem that you are trying to solve?

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


Re: [R] binary order combinations

2008-09-05 Thread Dimitri Liakhovitski
Sorry,

I misread it first. I tried:

library(quantreg)
 test.combos-lapply(1:15,function(x)
 {combos(15,x)
 })

It gives me a list with an order that is somewhat different from
before, but I am not sure it helps me much:

[[1]]
 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14]
[1,]1234567891011121314
 [,15]
[1,]15

[[2]]
 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14]
[1,]111111111 1 1 1 1 1
[2,]2   15   14   13   12   11   1098 7 6 5 4 3
 [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25] [,26]
[1,] 2 2 2 2 2 2 2 2 2 2 2 2
[2,] 3151413121110 9 8 7 6 5


Dimitri

On 9/5/08, roger koenker [EMAIL PROTECTED] wrote:
 You need to read the help file ?combos, and then use it to do indexing
 of your objects, it only knows how to construct the integer combinations
 given  a pair (n,p).

 url:www.econ.uiuc.edu/~rogerRoger Koenker
 email[EMAIL PROTECTED]Department of Economics
 vox: 217-333-4558University of Illinois
 fax:   217-244-6678Champaign, IL 61820



 On Sep 5, 2008, at 10:23 AM, Dimitri Liakhovitski wrote:

  I am not sure it can do it. Besides, I ran a test of combos from quantreg:
 
  library(quantreg)
  H-1:3
  test.combos-lapply(1:3,function(x)
  {combn(H,x)
  })
 
  Every time I tried it crashed my R...
 
  :(
 
  Dimitri
 
  On 9/5/08, roger koenker [EMAIL PROTECTED] wrote:
 
   Does ?combos in the quantreg package do what you want?
  
  
   url:www.econ.uiuc.edu/~rogerRoger Koenker
   email[EMAIL PROTECTED]Department of Economics
   vox: 217-333-4558University of Illinois
   fax:   217-244-6678Champaign, IL 61820
  
  
  
  
   On Sep 5, 2008, at 9:58 AM, Dimitri Liakhovitski wrote:
  
  
   
Dear all!
   
I have a vector of names
names-(V1, V2, V3,., V15)
   
I could create all possible combinations of these names (of all
lengths) using R:
   
combos-lapply(1:15,function(x)
{combn(names,x)
})
   
I get a list with all possible combinations of elements of 'names'
that looks like this (just the very beginning of it):
   
[[1]] - the first element contains all combinations of 1 name
 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13]
   
   [,14]
  
[1,] V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12
 V13
   
   V14
  
 [,15]
[1,] V15
   
[[2]] - the second element contains all possible combinations of 2
 names
 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]  [,10] [,11] [,12] [,13]
[1,] V1 V1 V1 V1 V1 V1 V1 V1 V1  V1  V1  V1
 V1
[2,] V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13
 V14
.
.
.
etc.
   
My question is: Is there any way to re-arrange all sub-elements of the
above list (i.e., all possible combinations of names such as V1,
V1:V3, V1:V2:V4:V5) in a binary system order. More specifically,
according to this system:
V1=1
V2=2
V3=4
V4=8
V5=16, etc
   
So, I'd like those combinations to be arranged in a vector in the
following order:
1. V1 (because V1=1)
2. V2 (because V2=2)
3. V1:V2 (because V1=1 and V2=2 so that 1+2=3)
4. V3 (because V3=4)
5. V1:V3 (because V1=1 and V3=4 so that 1+4=5)
6. V2:V3 (because V2=2 and V3=4 so that 2+4=6)
7. V1:V2:V3 (because V1=1 and V2=2 and V3=4 so that 1+2+4=7)
8. V4 (because V4=8)
etc.
   
Is it at all possible?
Or maybe there is a way to create the name combinations in such an
order in the first place?
   
Thank you very much!
Dimitri Liakhovitski
   
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Lowest k values of list

2008-09-05 Thread Jorge Ivan Velez
Dear Markus,
I think that I missed something in my previous reply. Here is another
approach using the first k values of each list:

# Data set
set.seed(123)
mylist=list(a=rnorm(10),b=rpois(15,10),f=rnorm(30,12,3))

# Function to report the first k values
k.values=function(x,k){
res= x[order(x)][1:k]
names(res)=paste('value_',1:k,sep=)
res
}

# Example: first 3 values
res=lapply(mylist,k.values,k=3)
do.call(rbind,res)
 value_1value_2value_3
a -1.265061 -0.6868529 -0.5604756
b  3.00  4.000  6.000
f  7.353742  8.2038109  8.5855892


HTH,

Jorge




On Fri, Sep 5, 2008 at 11:26 AM, Markus Mühlbacher [EMAIL PROTECTED]wrote:

 Hi @ all,

 how do I get the largest or lowest k values of list? It must similar to the
 min() / max() function, but I just don't get it.

 Best wishes,
 Markus




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

2008-09-05 Thread roger koenker

You need to read the help file ?combos, and then use it to do indexing
of your objects, it only knows how to construct the integer combinations
given  a pair (n,p).

url:www.econ.uiuc.edu/~rogerRoger Koenker
email[EMAIL PROTECTED]Department of Economics
vox: 217-333-4558University of Illinois
fax:   217-244-6678Champaign, IL 61820



On Sep 5, 2008, at 10:23 AM, Dimitri Liakhovitski wrote:

I am not sure it can do it. Besides, I ran a test of combos from  
quantreg:


library(quantreg)
H-1:3
test.combos-lapply(1:3,function(x)
{combn(H,x)
})

Every time I tried it crashed my R...

:(

Dimitri

On 9/5/08, roger koenker [EMAIL PROTECTED] wrote:

Does ?combos in the quantreg package do what you want?


url:www.econ.uiuc.edu/~rogerRoger Koenker
email[EMAIL PROTECTED]Department of Economics
vox: 217-333-4558University of Illinois
fax:   217-244-6678Champaign, IL 61820




On Sep 5, 2008, at 9:58 AM, Dimitri Liakhovitski wrote:



Dear all!

I have a vector of names
names-(V1, V2, V3,., V15)

I could create all possible combinations of these names (of all
lengths) using R:

combos-lapply(1:15,function(x)
{combn(names,x)
})

I get a list with all possible combinations of elements of 'names'
that looks like this (just the very beginning of it):

[[1]] - the first element contains all combinations of 1 name
  [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [, 
13]

[,14]
[1,] V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11  
V12 V13

V14

  [,15]
[1,] V15

[[2]] - the second element contains all possible combinations of 2  
names
  [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]  [,10] [,11] [,12]  
[,13]
[1,] V1 V1 V1 V1 V1 V1 V1 V1 V1  V1  V1   
V1  V1
[2,] V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12  
V13 V14

.
.
.
etc.

My question is: Is there any way to re-arrange all sub-elements of  
the

above list (i.e., all possible combinations of names such as V1,
V1:V3, V1:V2:V4:V5) in a binary system order. More specifically,
according to this system:
V1=1
V2=2
V3=4
V4=8
V5=16, etc

So, I'd like those combinations to be arranged in a vector in the
following order:
1. V1 (because V1=1)
2. V2 (because V2=2)
3. V1:V2 (because V1=1 and V2=2 so that 1+2=3)
4. V3 (because V3=4)
5. V1:V3 (because V1=1 and V3=4 so that 1+4=5)
6. V2:V3 (because V2=2 and V3=4 so that 2+4=6)
7. V1:V2:V3 (because V1=1 and V2=2 and V3=4 so that 1+2+4=7)
8. V4 (because V4=8)
etc.

Is it at all possible?
Or maybe there is a way to create the name combinations in such an
order in the first place?

Thank you very much!
Dimitri Liakhovitski

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] how to draw the legend about color from 3d picture

2008-09-05 Thread Greg Snow
Look at the color.legend function in the plotrix package to see if it does what 
you want.  You may want to use the layout function to split the graphics device 
into 2 sections, one for the persp plot and the other to hold the legend.

Hope this helps,

--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
(801) 408-8111



 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of yk
 Sent: Friday, September 05, 2008 6:07 AM
 To: r-help@r-project.org
 Subject: [R] how to draw the legend about color from 3d picture

 I have drawed a picture with persp, it's 3d map with
 different color, indicate different altitude. In gnuplot, the
 corresponding command 'splot' will generate a picture beside
 to indicate the relationship between color and altitude. But
 in R, how to draw it? I have read the manual of legend, but
 they are all about how to draw a legend with colored text,
 not a continuous varing color with corresponding number.

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

2008-09-05 Thread rkevinburton
I did a ?lm and it said basically to be careful when using lm and a time 
series. But my question is probably more to do with my inexperience that 
anything. If I have a time series object 'ti' how do I write the formula? The 
response is the value at any particular time and the time is basically the 
index of the time series. But I don't know how to put that into a formula.

Thank you.

Kevin

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


Re: [R] binary order combinations

2008-09-05 Thread Dimitri Liakhovitski
Henrik,
this is amazing! wow!
Thank you so much!
Dimitri

On 9/5/08, Henrik Bengtsson [EMAIL PROTECTED] wrote:
 names - sprintf(V%d, 1:4);
 n - length(names);
 stopifnot(n = 32); # Theoretical upper limit
 x - matrix(intToBits(1:(2^n-1)), ncol=2^n-1);
 x - x[1:n,,drop=FALSE];
 keys - apply(x, MARGIN=2, FUN=function(z) paste(names[as.logical(z)],
 collapse=:));
 print(keys);

  [1] V1  V2  V1:V2   V3
  [5] V1:V3   V2:V3   V1:V2:V3V4
  [9] V1:V4   V2:V4   V1:V2:V4V3:V4
 [13] V1:V3:V4V2:V3:V4V1:V2:V3:V4

 /H

 On Fri, Sep 5, 2008 at 8:23 AM, Dimitri Liakhovitski [EMAIL PROTECTED] 
 wrote:
  I am not sure it can do it. Besides, I ran a test of combos from quantreg:
 
  library(quantreg)
  H-1:3
  test.combos-lapply(1:3,function(x)
  {combn(H,x)
  })
 
  Every time I tried it crashed my R...
 
  :(
 
  Dimitri
 
  On 9/5/08, roger koenker [EMAIL PROTECTED] wrote:
  Does ?combos in the quantreg package do what you want?
 
 
  url:www.econ.uiuc.edu/~rogerRoger Koenker
  email[EMAIL PROTECTED]Department of Economics
  vox: 217-333-4558University of Illinois
  fax:   217-244-6678Champaign, IL 61820
 
 
 
 
  On Sep 5, 2008, at 9:58 AM, Dimitri Liakhovitski wrote:
 
  
   Dear all!
  
   I have a vector of names
   names-(V1, V2, V3,., V15)
  
   I could create all possible combinations of these names (of all
   lengths) using R:
  
   combos-lapply(1:15,function(x)
   {combn(names,x)
   })
  
   I get a list with all possible combinations of elements of 'names'
   that looks like this (just the very beginning of it):
  
   [[1]] - the first element contains all combinations of 1 name
  [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13]
  [,14]
   [1,] V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13
  V14
  [,15]
   [1,] V15
  
   [[2]] - the second element contains all possible combinations of 2 names
  [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]  [,10] [,11] [,12] [,13]
   [1,] V1 V1 V1 V1 V1 V1 V1 V1 V1  V1  V1  V1  V1
   [2,] V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13 
   V14
   .
   .
   .
   etc.
  
   My question is: Is there any way to re-arrange all sub-elements of the
   above list (i.e., all possible combinations of names such as V1,
   V1:V3, V1:V2:V4:V5) in a binary system order. More specifically,
   according to this system:
   V1=1
   V2=2
   V3=4
   V4=8
   V5=16, etc
  
   So, I'd like those combinations to be arranged in a vector in the
   following order:
   1. V1 (because V1=1)
   2. V2 (because V2=2)
   3. V1:V2 (because V1=1 and V2=2 so that 1+2=3)
   4. V3 (because V3=4)
   5. V1:V3 (because V1=1 and V3=4 so that 1+4=5)
   6. V2:V3 (because V2=2 and V3=4 so that 2+4=6)
   7. V1:V2:V3 (because V1=1 and V2=2 and V3=4 so that 1+2+4=7)
   8. V4 (because V4=8)
   etc.
  
   Is it at all possible?
   Or maybe there is a way to create the name combinations in such an
   order in the first place?
  
   Thank you very much!
   Dimitri Liakhovitski
  
   __
   R-help@r-project.org mailing list
   https://stat.ethz.ch/mailman/listinfo/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] lm and time series.

2008-09-05 Thread Gabor Grothendieck
The Time Series section in ?lm should be self explanatory.   If you are using
diff's and lag's then look at the dyn package.

On Fri, Sep 5, 2008 at 12:25 PM,  [EMAIL PROTECTED] wrote:
 I did a ?lm and it said basically to be careful when using lm and a time 
 series. But my question is probably more to do with my inexperience that 
 anything. If I have a time series object 'ti' how do I write the formula? The 
 response is the value at any particular time and the time is basically the 
 index of the time series. But I don't know how to put that into a formula.

 Thank you.

 Kevin

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


Re: [R] Lowest k values of list

2008-09-05 Thread Greg Snow
In addition to the other responses, you may want to look at the 'partial' 
argument to sort.  For large vectors it may speed things up to not sort 
everything if all you care about is the top and bottom few.

Try:

 tmp - rnorm(100)
 plot( sort(tmp, partial=c(1,2,99,100) ) )

Hope this helps,

--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
(801) 408-8111



 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Markus Mühlbacher
 Sent: Friday, September 05, 2008 9:26 AM
 To: r-help@r-project.org
 Subject: [R] Lowest k values of list

 Hi @ all,

 how do I get the largest or lowest k values of list? It must
 similar to the min() / max() function, but I just don't get it.

 Best wishes,
 Markus




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

2008-09-05 Thread Henrique Dallazuanna
You can try something like about this:

r[upper.tri(r)] - NA
matplot(t(r), lty = 1, type = 'p', pch = 1, ylim = c(0.4, 1.2), col =
'black')


On Fri, Sep 5, 2008 at 12:27 PM, Zhang Yanwei - Princeton-MRAm 
[EMAIL PROTECTED] wrote:

 Dear list,

  I have the following matrix. How can I make the following plot?
  1. The x-axis has index 1:7, and the first column is plotted against index
 1, second against 2, and so on.
  2. I want the points from the left upper conner including the antidiagonal
 to be plotted with col=2, and the rest with col=3
  [,1]  [,2]  [,3]  [,4]  [,5]  [,6]  [,7]
 [1,] 0.589 0.857 0.923 0.944 0.954 0.963 0.980
 [2,] 0.470 0.763 0.877 0.900 0.911 0.957 0.974
 [3,] 0.486 0.863 0.905 0.960 0.968 0.998 1.015
 [4,] 0.653 0.888 0.943 0.952 0.962 0.992 1.009
 [5,] 0.664 0.774 0.958 0.986 0.996 1.027 1.045
 [6,] 0.546 0.910 1.011 1.041 1.051 1.083 1.102
 [7,] 0.407 0.600 0.667 0.686 0.693 0.715 0.727


 The following the my code to do the above with the matrix called r. How
 can I simply the code?


 plot(r[,1],type=n,ylim=c(0.4,1.2))
 for (i in 1:7)
  {points(rep(i,8-i),r[,i][1:(8-i)],col=2) }
 for (i in 2:7)
  {points(rep(i,(i-1)),r[,i][(9-i):7],col=3)}

 Thanks


 Sincerely,
 Yanwei Zhang
 Department of Actuarial Research and Modeling
 Munich Re America
 mailto:[EMAIL PROTECTED]

[[alternative HTML version deleted]]

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




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

[[alternative HTML version deleted]]

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


[R] Adding a legend to R graph device with several plots (no to individual plots!)

2008-09-05 Thread Monica Pisica

Hi Nelson,

I don't know if you got your answer or not but here it is my low-tech solution 
for what is worth. I like to do a layout as I want my graphs to be and add some 
space where I plot an invisible graph with dummy data and add the legend 
there. In this case I decided to put the legend on middle top of the layout. 

Because you used lapply to do your graphs it seems that I have to change the 
numbers in the p.names parameter because somehow it establishes the order of 
your graphs as well. I usually use the simple for loop because you never have 
loads of graphs in one page, so it is safe enough. 

I hope this helps a little.

Monica

# code starts

l - layout(matrix(c(rep(1, 2), seq(2,5)), 3,2, byrow = T), c(3,3,3), 
c(1,3,3,3))
layout.show(l)
par(mar = c(1,1,1,1))

plot(seq(1,10), seq(1,10), type = n, axes = F)
smartlegend(x= center, y=top, c(1995,2006), lty=2:1)
par(mar = c(4,4,3,2))

p.names - c(2,3,4,5)### change p.names definition
lapply(p.names, function(x) {
d1 - density(rnorm(100,0,1))
d2 - density(rnorm(100,.3,1.2))
plot(range(d1$x, d2$x), range(d1$y, d2$y), type = n, xlab = , ylab = ) 
## change xlab, ylab in plot
lines(d1, col = black, lty = 2)
lines(d2, col = black, lty = 1)
})
mtext(Learning R the hard way, side = 1, line=-1.5, outer=TRUE)

 code ends

--
Message: 16
Date: Thu, 4 Sep 2008 09:35:42 -0400
From: Nelson Villoria 
Subject: [R] Adding a legend to R graph device with several plots (no
to individual plots!)
To: r-help@r-project.org
Message-ID:

Content-Type: text/plain; charset=ISO-8859-1

Dear Users, I already posted this question: it either went unnoticed,
or it is to basic (if this is so, please sent me a hint).
I would like to know if there is a way to add a common
legend to an arrangement of plots. In the example below, I get four
plots in my device. each one has a density for 1995 and one for 2006.
I have found that using legend or smartlegend I can add a legend to
each plot, but I am looking for something in the spirit of mtext. That
is, putting the legend anywhere I want on the device. In my situation
I have:

par(mfrow=c(2,2), ann = FALSE)
p.names - c(1,2,3,4)
lapply(p.names, function(x) {
d1 - density(rnorm(100,0,1))
d2 - density(rnorm(100,.3,1.2))
plot(range(d1$x, d2$x), range(d1$y, d2$y), type = n, xlab = NULL,
ylab = NULL)
lines(d1, col = black, lty = 2)
lines(d2, col = black, lty = 1)
})
mtext(Learning R the hard way, side = 1, line=-1.5, outer=TRUE)
smartlegend(x= center, y=top, c(1995,2006), lty=2:1)

the last line puts the legend on the lower-right plot. I'd like to put
it in the middle - or top of the device. Any suggestion?

Thanks!

Nelson




_


50F681DAD532637!5295.entry?ocid=TXT_TAGLM_WL_domore_092008
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] casting help please

2008-09-05 Thread davidr
I have a data.frame which I believe is melted already and am having
trouble casting it to 'wide' format.

It looks something like

 

 (x - data.frame(ticker=c(rep(A,5),rep(B,6)), date=c(1:5, 1:6),
value=c(NA,100*exp(rnorm(10,0,.1)

 cast(x, date ~ ticker) # this does what I want with toy data

 

But when I use my real data frame

 

 str(prices)

'data.frame':   308188 obs. of  3 variables:

 $ Ticker: chr  ticker1  ticker1  ticker1  ticker1 ...

 $ Date:Class 'Date'  num [1:308188] 12296 12297 12298 12299 12300
...

 $ Price   : num  NA NA NA NA NA NA NA NA NA NA ...

 

I get

 

 prices.wide - cast(prices, Date ~ Ticker, add.missing=TRUE)

Error in data.frame(data[, c(variables), drop = FALSE], result =
data$value) : 

  arguments imply differing number of rows: 308188, 0

 

(I tried various other arguments to cast - all gave the same error
message.)

It is a fact that the various tickers have data for different date
ranges in the data frame and there are lots of NA's,

but the toy example above has different date ranges for the two tickers
and an NA, so I don't know what else to look for in my data,

or what args to cast might make it work.

 

Any insights or direction would be much appreciated.

 

David L. Reiner, PhD

Head Quant

Rho Trading Securities, LLC

 


[[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] Question about col.names in write.csv

2008-09-05 Thread Julian Burgos

Hi Luz,
No entiendo bien tu pregunta.  Querés grabar una tabla con nombres en 
las columnas y tambien en la primera fila?  Si es asi, tenés que 
asignarle los nombres a la tabla antes de grabar.  Por ejemplo:


mi.tabla=matrix(runif(30),ncol=3)

colnames(mi.tabla)=c(A,B,C)
rownames(mi.tabla)=c(D,rep(,9))

write.csv(mi.tabla,file=mi.archivo.csv)

Cuando asignás nombres a las filas o columnas, el vector tiene que tener 
la misma longitud que el numero de filas o columnas.  Entonces, para 
darle un nombre solamente a la primera fila, hice un vector con el 
nombre y nueve espacios en blanco (para completar las diez filas que 
tiene mi tabla).


Al grabar la tabla usando write.csv, el comportamiento default es 
guardar los nombres de las columnas y filas.



Saludos,

Julian

Luz Milena Zea Fernandez wrote:

Dear support, I don't ignore col.names in write.csv. I want to write names for 
the firts row. How can I do?

Thanks in advance

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


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


Re: [R] casting help please

2008-09-05 Thread hadley wickham
Hi David,

Does getting rid of the missings help?

prices - prices[complete.cases(prices), ]

Also, you shouldn't need  add.missing=TRUE - what are you trying to do?

Hadley

On Fri, Sep 5, 2008 at 12:12 PM,  [EMAIL PROTECTED] wrote:
 I have a data.frame which I believe is melted already and am having
 trouble casting it to 'wide' format.

 It looks something like



 (x - data.frame(ticker=c(rep(A,5),rep(B,6)), date=c(1:5, 1:6),
 value=c(NA,100*exp(rnorm(10,0,.1)

 cast(x, date ~ ticker) # this does what I want with toy data



 But when I use my real data frame



 str(prices)

 'data.frame':   308188 obs. of  3 variables:

  $ Ticker: chr  ticker1  ticker1  ticker1  ticker1 ...

  $ Date:Class 'Date'  num [1:308188] 12296 12297 12298 12299 12300
 ...

  $ Price   : num  NA NA NA NA NA NA NA NA NA NA ...



 I get



 prices.wide - cast(prices, Date ~ Ticker, add.missing=TRUE)

 Error in data.frame(data[, c(variables), drop = FALSE], result =
 data$value) :

  arguments imply differing number of rows: 308188, 0



 (I tried various other arguments to cast - all gave the same error
 message.)

 It is a fact that the various tickers have data for different date
 ranges in the data frame and there are lots of NA's,

 but the toy example above has different date ranges for the two tickers
 and an NA, so I don't know what else to look for in my data,

 or what args to cast might make it work.



 Any insights or direction would be much appreciated.



 David L. Reiner, PhD

 Head Quant

 Rho Trading Securities, LLC




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




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

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


Re: [R] casting help please

2008-09-05 Thread davidr
I think I just remembered that in a melted data.frame the values have to
be called 'value' and tried renaming my third column so. Now it works
(without add.missing).

Thanks for this powerful piece of software!
-- David
(I was trying to convert a set of data in 'long' format to 'wide'
format. Basically I have a pretty long price history for many tickers
basically stacked up as indicated in the toy example and want them
reshaped with each ticker in a column with dates in the first column.
Maybe cast was not the best tool? But it works now.)

-Original Message-
From: hadley wickham [mailto:[EMAIL PROTECTED] 
Sent: Friday, September 05, 2008 1:10 PM
To: David Reiner [EMAIL PROTECTED]
Cc: r-help@r-project.org
Subject: [SPAM] - Re: [R] casting help please - Found word(s) list error
in the Text body

Hi David,

Does getting rid of the missings help?

prices - prices[complete.cases(prices), ]

Also, you shouldn't need  add.missing=TRUE - what are you trying to do?

Hadley

On Fri, Sep 5, 2008 at 12:12 PM,  [EMAIL PROTECTED] wrote:
 I have a data.frame which I believe is melted already and am having
 trouble casting it to 'wide' format.

 It looks something like



 (x - data.frame(ticker=c(rep(A,5),rep(B,6)), date=c(1:5, 1:6),
 value=c(NA,100*exp(rnorm(10,0,.1)

 cast(x, date ~ ticker) # this does what I want with toy data



 But when I use my real data frame



 str(prices)

 'data.frame':   308188 obs. of  3 variables:

  $ Ticker: chr  ticker1  ticker1  ticker1  ticker1 ...

  $ Date:Class 'Date'  num [1:308188] 12296 12297 12298 12299 12300
 ...

  $ Price   : num  NA NA NA NA NA NA NA NA NA NA ...



 I get



 prices.wide - cast(prices, Date ~ Ticker, add.missing=TRUE)

 Error in data.frame(data[, c(variables), drop = FALSE], result =
 data$value) :

  arguments imply differing number of rows: 308188, 0



 (I tried various other arguments to cast - all gave the same error
 message.)

 It is a fact that the various tickers have data for different date
 ranges in the data frame and there are lots of NA's,

 but the toy example above has different date ranges for the two
tickers
 and an NA, so I don't know what else to look for in my data,

 or what args to cast might make it work.



 Any insights or direction would be much appreciated.



 David L. Reiner, PhD

 Head Quant

 Rho Trading Securities, LLC




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




-- 
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] upgraded maps database for italy?

2008-09-05 Thread livio spam
Dear UseRs,
I'm using the library maps. I'm drawing maps of Italy. The map available for
this library were prepared around *1989*:
This italy database comes from the NUTS III (Tertiary Administrative Units
of the European Community) database of the United Nations Environment
Programme (UNEP) GRID-Geneva data sets. These were prepared around *1989*
[cited: help(italy)].
The details of this map is by province, which is not maybe optimal, but is
OK.
However, after 1989 many new province are born. So for example the new
provincia of Rimini has born and the sardinan Island has doubled them.

Some of you do know how to get upgraded maps of italy? I think it would
useful for all Italian mapers.

The second question is as follow: Italy is subdivided in regioni. Each
regione is a set of many province; so, if I want to plot map region-based
index, how can I omit the borders of prince belonging to the same regione?
so, how plot maps to a higher unit level?

[[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] upgraded maps database for italy?

2008-09-05 Thread Greg Snow
If I remember correctly, the maps package only has a few dedicated maps that 
works with it.  The maptools package has similar (but not exactly the same) 
functionality and can work with shapefiles that are more commonly available.  
Maptools also integrates nicely with the sp and related packages that give many 
more options for working with the maps.

For the 2nd question, I would suggest plotting the map first using the 
province, then plot a second map over the top using the information on the 
regioni using a different color/line thickness for the boarders and no fill (so 
that the province show through).  This requires having 2 different map files, 
one with province and one with regioni information (there may be a better way 
with overlaying information, but this method works without having to think 
about it too much).

Hope this helps,

--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
(801) 408-8111



 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of livio spam
 Sent: Friday, September 05, 2008 12:24 PM
 To: r-help@r-project.org
 Subject: [R] upgraded maps database for italy?

 Dear UseRs,
 I'm using the library maps. I'm drawing maps of Italy. The
 map available for this library were prepared around *1989*:
 This italy database comes from the NUTS III (Tertiary
 Administrative Units of the European Community) database of
 the United Nations Environment Programme (UNEP) GRID-Geneva
 data sets. These were prepared around *1989*
 [cited: help(italy)].
 The details of this map is by province, which is not maybe
 optimal, but is OK.
 However, after 1989 many new province are born. So for
 example the new provincia of Rimini has born and the sardinan
 Island has doubled them.

 Some of you do know how to get upgraded maps of italy? I
 think it would useful for all Italian mapers.

 The second question is as follow: Italy is subdivided in
 regioni. Each regione is a set of many province; so, if I
 want to plot map region-based index, how can I omit the
 borders of prince belonging to the same regione?
 so, how plot maps to a higher unit level?

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

2008-09-05 Thread Philip Twumasi-Ankrah
Hi Marshall,

This link provides very good directions and examples you can use.

http://www.image.ucar.edu/GSP/Software/Netcdf/

A Smile costs Nothing  
 But Rewards Everything

Happiness is not perfected until it is shared
  -Jane Porter  
  


--- On Fri, 9/5/08, Marshall Mdoka [EMAIL PROTECTED] wrote:
From: Marshall Mdoka [EMAIL PROTECTED]
Subject: Re: [R] asscii2netcdf]
To: r-help@r-project.org
Date: Friday, September 5, 2008, 1:15 PM

Dear All,

A friend of mine seeks help in converting the attached ascii to netcdf. 
Any assistance will be sincerely appreciated.

Regards,

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



  
[[alternative HTML version deleted]]

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


[R] boxplot including null info from dataframe, not with SQLite dataframe

2008-09-05 Thread Coey Minear
I have been trying to use R to gather some information from parsed log
files (as part of examining some performance issues).  I parsed the
log files and put the data into an SQLite database, and then used
RSQLite to load the data into R.  The fields of interest are
controller, action and total_time: controller and action have string
values; total_time has a decimal value.

I first did the following box plot to find the problem controllers.
  boxplot(total_time ~ controller, all_data)

Having identified one controller of interest (let's say
BadController), I then wanted to then focus on the actions
associated with that controller.  So I did this:
  boxplot(total_time ~ action, subset(all_data, controller == BadController))

This gave me a plot I was expecting: just the actions which are
associated with BadController.  However, I'd done this work on a
FreeBSD system, and then I wanted to print it, and the easiest means
seemed to re-plot using R on Windows.  So I wrote the data to a file,
moved it to Windows and loaded it up there.  

On FreeBSD: 
  write.table(all_data, datafile.R)

On Windows:
  all_data - read.table(datafile.R)

However, on Windows, when I get to the boxplot of the subset of data,
I'm seeing every action that's part of all_data, not just the ones
that are associated with BadController.  Eventually, I found that
this wasn't a Windows vs. FreeBSD issue, because if I reload the data
from the file on FreeBSD, I start to see the same behavior.

Based on a few bug reports I found, it would seem that this is working
as designed.  So my question is: 
What do I do to get it to truly ignore the actions with no data?  I've
tried adding drop=FALSE to the subset call; that hasn't worked.  I
also tried specifically adding na.action=NULL to the boxplot call,
with no change.

I'm also curious what's different between a data frame loaded from
SQLite versus a data frame loaded from a file.

In the mean time, I'll either try to install RSQLite on Windows or get
postscript working on FreeBSD.  (My quick attempt with postscript in R
on FreeBSD was not drawing the bounding box nor the axes.)

Thanks for any help.



-- 
Coey Minear

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


[R] comparing two files

2008-09-05 Thread Rajasekaramya

Hi there

I have two object on is a vector T and the other is  dataframe C.
vector T has more no of rows when comapred with a dataframe Ccolumn[,2].I
want to find the the missing rows in dataframe C.That is those values that
are not matchig  in dataframe C[,2]

Kindly give me suggestion on how to go about it.

Ramya

-- 
View this message in context: 
http://www.nabble.com/comparing-two-files-tp19337486p19337486.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] library/function that estimates parameters of well known distributions from empirical data?

2008-09-05 Thread Ben Bolker
Ted Byers r.ted.byers at gmail.com writes:

 
 
 I found this a few months ago, but for the life of me I can't remember what
 the function or package was, and I have had no luck finding it this week.
 
 I have found, again, the functions for working with distributions like
 Cauchy, F, normal, c., and ks.test, but I have not found the functions for
 estimating the distribution parameters given a vector of values.
 

  Look at the fitdistr function in the MASS package.  Consider
AIC comparisons for ranking the fits to these non-nested models.

  good luck
   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] boxplot including null info from dataframe, not with SQLite dataframe

2008-09-05 Thread Ben Bolker
Coey Minear cminear at securecomputing.com writes:

 
 I have been trying to use R to gather some information from parsed log
 files (as part of examining some performance issues).  I parsed the
 log files and put the data into an SQLite database, and then used
 RSQLite to load the data into R.  The fields of interest are
 controller, action and total_time: controller and action have string
 values; total_time has a decimal value.
 
 I first did the following box plot to find the problem controllers.
   boxplot(total_time ~ controller, all_data)
 
 Having identified one controller of interest (let's say
 BadController), I then wanted to then focus on the actions
 associated with that controller.  So I did this:
   boxplot(total_time ~ action, subset(all_data, controller == 
 BadController))
 
 This gave me a plot I was expecting: just the actions which are
 associated with BadController.  However, I'd done this work on a
 FreeBSD system, and then I wanted to print it, and the easiest means
 seemed to re-plot using R on Windows.  So I wrote the data to a file,
 moved it to Windows and loaded it up there.  
 
 On FreeBSD: 
   write.table(all_data, datafile.R)
 
 On Windows:
   all_data - read.table(datafile.R)
 

  I'm guessing that you want

bad - subset(all_data,controller==BadController)
bad$action - factor(bad$action)
boxplot(total_time ~ action)

   Subsetting doesn't drop factor levels that don't
occur, which is an unfortunate design decision ...


   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] lm and time series.

2008-09-05 Thread rkevinburton
I am sorry but I looked at ?lm and could not see any guidance on writting a 
formula. If I have two arrays or a data set then I know how to do that (y ~ x) 
but for a time series I am not sure how to write y or x.

Thank you.

Kevin

 Gabor Grothendieck [EMAIL PROTECTED] wrote: 
 The Time Series section in ?lm should be self explanatory.   If you are using
 diff's and lag's then look at the dyn package.
 
 On Fri, Sep 5, 2008 at 12:25 PM,  [EMAIL PROTECTED] wrote:
  I did a ?lm and it said basically to be careful when using lm and a time 
  series. But my question is probably more to do with my inexperience that 
  anything. If I have a time series object 'ti' how do I write the formula? 
  The response is the value at any particular time and the time is basically 
  the index of the time series. But I don't know how to put that into a 
  formula.
 
  Thank you.
 
  Kevin

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


Re: [R] comparing two files

2008-09-05 Thread John Kane
?which

which(C[,2]!= T)  # untested


--- On Fri, 9/5/08, Rajasekaramya [EMAIL PROTECTED] wrote:

 From: Rajasekaramya [EMAIL PROTECTED]
 Subject: [R]  comparing two files
 To: r-help@r-project.org
 Received: Friday, September 5, 2008, 2:57 PM
 Hi there
 
 I have two object on is a vector T and the other is 
 dataframe C.
 vector T has more no of rows when comapred with a dataframe
 Ccolumn[,2].I
 want to find the the missing rows in dataframe C.That is
 those values that
 are not matchig  in dataframe C[,2]
 
 Kindly give me suggestion on how to go about it.
 
 Ramya
 
 -- 
 View this message in context:
 http://www.nabble.com/comparing-two-files-tp19337486p19337486.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.


  __
[[elided Yahoo spam]]

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


Re: [R] comparing two files

2008-09-05 Thread jim holtman
?match

 T.v - sample(1:20)
 C.df - data.frame(a=1:10, b= sample(1:20, 10))
 T.v
 [1] 10 12  9  4 14 11 19  2 18  5 16  6  7 17  8 20  1 13  3 15
 C.df
a  b
1   1 10
2   2 17
3   3  8
4   4  5
5   5  2
6   6 16
7   7 19
8   8  7
9   9 18
10 10 14
 # find the missing values
 T.v[is.na(match(T.v, C.df[,2]))]
 [1] 12  9  4 11  6 20  1 13  3 15



On Fri, Sep 5, 2008 at 2:57 PM, Rajasekaramya [EMAIL PROTECTED] wrote:

 Hi there

 I have two object on is a vector T and the other is  dataframe C.
 vector T has more no of rows when comapred with a dataframe Ccolumn[,2].I
 want to find the the missing rows in dataframe C.That is those values that
 are not matchig  in dataframe C[,2]

 Kindly give me suggestion on how to go about it.

 Ramya

 --
 View this message in context: 
 http://www.nabble.com/comparing-two-files-tp19337486p19337486.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.




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

What is the problem that you are trying to solve?

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


Re: [R] comparing two files

2008-09-05 Thread Jorge Ivan Velez
Hi there,
See ?%in%  Here is an example:

 x=sample(1:10)
 x
 [1]  2  1 10  5  4  7  3  6  8  9
 y=sample(4:20)
 y
 [1] 17 16 18 10  8 19  4  5 11 13 12 14 20  6  7  9 15
 x[x%in%y]  # x values present in y
[1] 10  5  4  7  6  8  9

HTH,


Jorge



On Fri, Sep 5, 2008 at 2:57 PM, Rajasekaramya [EMAIL PROTECTED]wrote:


 Hi there

 I have two object on is a vector T and the other is  dataframe C.
 vector T has more no of rows when comapred with a dataframe Ccolumn[,2].I
 want to find the the missing rows in dataframe C.That is those values that
 are not matchig  in dataframe C[,2]

 Kindly give me suggestion on how to go about it.

 Ramya

 --
 View this message in context:
 http://www.nabble.com/comparing-two-files-tp19337486p19337486.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] dealing with NAs in time series

2008-09-05 Thread stephen sefick
look at zoo
na.approx
this will interpolate in a couple of ways

On Fri, Sep 5, 2008 at 11:28 AM, Alexy Khrabrov [EMAIL PROTECTED] wrote:
 Certain timeseries I have had outliers, which I removed by assigning NA to
 their positions.  Now acf() refuses to go to work.  What's the right way to
 remove outliers from ts objects, and what are teh standard ways to
 interpolate NAs in them?

 Cheers,
 Alexy

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

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] lm and time series.

2008-09-05 Thread stephen sefick
what do you want to do?

On Fri, Sep 5, 2008 at 3:22 PM,  [EMAIL PROTECTED] wrote:
 I am sorry but I looked at ?lm and could not see any guidance on writting a 
 formula. If I have two arrays or a data set then I know how to do that (y ~ 
 x) but for a time series I am not sure how to write y or x.

 Thank you.

 Kevin

  Gabor Grothendieck [EMAIL PROTECTED] wrote:
 The Time Series section in ?lm should be self explanatory.   If you are using
 diff's and lag's then look at the dyn package.

 On Fri, Sep 5, 2008 at 12:25 PM,  [EMAIL PROTECTED] wrote:
  I did a ?lm and it said basically to be careful when using lm and a time 
  series. But my question is probably more to do with my inexperience that 
  anything. If I have a time series object 'ti' how do I write the formula? 
  The response is the value at any particular time and the time is basically 
  the index of the time series. But I don't know how to put that into a 
  formula.
 
  Thank you.
 
  Kevin

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

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] Package for Tidying-up R-code

2008-09-05 Thread Don MacQueen
I don't know what kind of tidying you want, but ESS within emacs is a 
possibility.


-Don

At 6:32 PM +0900 9/5/08, Gundala Viswanath wrote:

Dear all,

Is there any such package?

I am thinking of something equivalent to Perl::Tidy.
For example with VI editor one can visual highlight a portion
of Perlcode and then issue the command:

!perltidy

then the code will be automatically arranged.

- Gundala Viswanath
Jakarta - Indonesia

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



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

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


[R] Using R to generate reports

2008-09-05 Thread Bill Cunliffe
Hi all,

 

I would like to generate nicely formatted reports on a daily basis.  The
reports would be a combination of charts and tables, generated in an
environment such as R.

 

Ideally, this would be an automated process.  Does anyone know if this is
feasible, and how I could achieve well formatted reports?  One idea would be
to have R scripts process the data/generate the charts and then use Latex to
create the report, referencing the charts produced by R.

 

I've not used Latex before so I'm trying to get a feel for how to best
proceed.

 

Thanks for your input,

 

Bill.


[[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] Recall: Using R to generate reports

2008-09-05 Thread Bill Cunliffe
Bill Cunliffe would like to recall the message, Using R to generate
reports.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] lm and time series.

2008-09-05 Thread rkevinburton
I want to fit a function to time series. If I had:

x - 1:4
y - 1:4

lm(y~x)

This would fit a simple line to the four points. But if it is represented as a 
time series

x - 1:4
t - ts(x)

lm()

So I have a time series in the object t. How do I write a formula for lm? What 
do I put in the formula for x and y when I only have t (the time series). 

Kevin

 stephen sefick [EMAIL PROTECTED] wrote: 
 what do you want to do?
 
 On Fri, Sep 5, 2008 at 3:22 PM,  [EMAIL PROTECTED] wrote:
  I am sorry but I looked at ?lm and could not see any guidance on writting a 
  formula. If I have two arrays or a data set then I know how to do that (y ~ 
  x) but for a time series I am not sure how to write y or x.
 
  Thank you.
 
  Kevin
 
   Gabor Grothendieck [EMAIL PROTECTED] wrote:
  The Time Series section in ?lm should be self explanatory.   If you are 
  using
  diff's and lag's then look at the dyn package.
 
  On Fri, Sep 5, 2008 at 12:25 PM,  [EMAIL PROTECTED] wrote:
   I did a ?lm and it said basically to be careful when using lm and a time 
   series. But my question is probably more to do with my inexperience that 
   anything. If I have a time series object 'ti' how do I write the 
   formula? The response is the value at any particular time and the time 
   is basically the index of the time series. But I don't know how to put 
   that into a formula.
  
   Thank you.
  
   Kevin
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/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
 Research Scientist
 Southeastern Natural Sciences Academy
 
 Let's not spend our time and resources thinking about things that are
 so little or so large that all they really do for us is puff us up and
 make us feel like gods. We are mammals, and have not exhausted the
 annoying little problems of being mammals.
 
   -K. Mullis

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


[R] Area of density

2008-09-05 Thread pragmatic

Hello!
Please, anybody help me.

Can I calculate area of density was created by:
 D - density(x)
In other words I want to know area under curve 'plot(D)'
and It's good to calculate area before and after 0 separately.

-- 
View this message in context: 
http://www.nabble.com/Area-of-density-tp19338958p19338958.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] Articles about comparision between R and others softwares

2008-09-05 Thread ricardo13

Hi

Do you know some articles, papers, something than tell about comparision
between R and others softwares statisticals.

Thank You

Ricardo
-- 
View this message in context: 
http://www.nabble.com/Articles-about-comparision-between-R-and-others-softwares-tp19338210p19338210.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] upgraded maps database for italy?

2008-09-05 Thread Ray Brownrigg
The italy (and france) databases only exists in the maps package because somebody 
supplied me with the data in an appropriate format - latitude/longitude pairs separately 
for each polygon (provinces in this case).  If you have the appropriate data for what you 
want i.e. updated provinces and regioni, then I could generate a new database (no promises 
as to how quickly this will happen though).  You *could* do it yourself if you read all 
the references contain in the maps documentation, but I wouldn't recommend learning how to 
do this unless you intend doing it frequently.


However as Greg Snow comments, maptools may well be a better way to go and uses a more 
generally available data format.  The maps package, which traces its roots back to 'New' S 
(the Blue book), is rather showing its age, but there is no reason to delete it while some 
people still find it useful.


Regards,
Ray Brownrigg

livio spam wrote:

Dear UseRs,
I'm using the library maps. I'm drawing maps of Italy. The map available for
this library were prepared around *1989*:
This italy database comes from the NUTS III (Tertiary Administrative Units
of the European Community) database of the United Nations Environment
Programme (UNEP) GRID-Geneva data sets. These were prepared around *1989*
[cited: help(italy)].
The details of this map is by province, which is not maybe optimal, but is
OK.
However, after 1989 many new province are born. So for example the new
provincia of Rimini has born and the sardinan Island has doubled them.

Some of you do know how to get upgraded maps of italy? I think it would
useful for all Italian mapers.

The second question is as follow: Italy is subdivided in regioni. Each
regione is a set of many province; so, if I want to plot map region-based
index, how can I omit the borders of prince belonging to the same regione?
so, how plot maps to a higher unit level?

[[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] Multiple Correspondence Analysis

2008-09-05 Thread Bill Vorias
Is there a way to get the coordinates from a plot of an MCA object?


[[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] library/function that estimates parameters of well known distributions from empirical data?

2008-09-05 Thread Ted Byers

Thanks Ben

That was the one I'd remembered but couldn't find.

Mark Leeds also told me about DistributionFits(fBasics), which I hadn't
seen.  There seems to be only a little overlap between the two.

Could I trouble you to expand on AIC (esp. what the function name and
package is to apply it to the output from these two functions)?  I just read
the help provided for each and neither mentions AIC.

Thanks again Ben

Ted


Ben Bolker wrote:
 
 Ted Byers r.ted.byers at gmail.com writes:
 
 
 
 I found this a few months ago, but for the life of me I can't remember
 what
 the function or package was, and I have had no luck finding it this week.
 
 I have found, again, the functions for working with distributions like
 Cauchy, F, normal, c., and ks.test, but I have not found the functions
 for
 estimating the distribution parameters given a vector of values.
 
 
   Look at the fitdistr function in the MASS package.  Consider
 AIC comparisons for ranking the fits to these non-nested models.
 
   good luck
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.
 
 

-- 
View this message in context: 
http://www.nabble.com/library-function-that-estimates-parameters-of-well-known-distributions-from-empirical-data--tp19323700p19339442.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] Multiple Correspondence Analysis

2008-09-05 Thread Jorge Ivan Velez
Dear Bill,
See http://finzi.psych.upenn.edu/R/library/ade4/html/dudi.acm.html

HTH,


Jorge



On Fri, Sep 5, 2008 at 5:00 PM, Bill Vorias [EMAIL PROTECTED]wrote:

 Is there a way to get the coordinates from a plot of an MCA object?


[[alternative HTML version deleted]]

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


[[alternative HTML version deleted]]

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


Re: [R] Using R to generate reports

2008-09-05 Thread Jorge Ivan Velez
Dear Bill,
See http://www.statistik.lmu.de/~leisch/Sweave/


HTH,


Jorge


On Fri, Sep 5, 2008 at 5:40 PM, Bill Cunliffe [EMAIL PROTECTED] wrote:

 Hi all,



 I would like to generate nicely formatted reports on a daily basis.  The
 reports would be a combination of charts and tables, generated in an
 environment such as R.



 Ideally, this would be an automated process.  Does anyone know if this is
 feasible, and how I could achieve well formatted reports?  One idea would
 be
 to have R scripts process the data/generate the charts and then use Latex
 to
 create the report, referencing the charts produced by R.



 I've not used Latex before so I'm trying to get a feel for how to best
 proceed.



 Thanks for your input,



 Bill.


[[alternative HTML version deleted]]

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


[[alternative HTML version deleted]]

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


Re: [R] lm and time series.

2008-09-05 Thread stephen sefick
So you want time as the independent variable?  Let's say that the
units of y in your first example were seconds- couldn't you just use a
regular lm and say that the units were seconds, minutes, or what ever?
 I am probably out of my league here, but I am just not understanding
what it is that you want.  a time series is just a series of data
points indexed by time.  Arima maybe, or some other cool times series
modeling approach- wavelet, spectral density- for frequency domain
type things...  What are you trying to accomplish?

On Fri, Sep 5, 2008 at 5:47 PM,  [EMAIL PROTECTED] wrote:
 I want to fit a function to time series. If I had:

 x - 1:4
 y - 1:4

 lm(y~x)

 This would fit a simple line to the four points. But if it is represented as 
 a time series

 x - 1:4
 t - ts(x)

 lm()

 So I have a time series in the object t. How do I write a formula for lm? 
 What do I put in the formula for x and y when I only have t (the time series).

 Kevin

  stephen sefick [EMAIL PROTECTED] wrote:
 what do you want to do?

 On Fri, Sep 5, 2008 at 3:22 PM,  [EMAIL PROTECTED] wrote:
  I am sorry but I looked at ?lm and could not see any guidance on writting 
  a formula. If I have two arrays or a data set then I know how to do that 
  (y ~ x) but for a time series I am not sure how to write y or x.
 
  Thank you.
 
  Kevin
 
   Gabor Grothendieck [EMAIL PROTECTED] wrote:
  The Time Series section in ?lm should be self explanatory.   If you are 
  using
  diff's and lag's then look at the dyn package.
 
  On Fri, Sep 5, 2008 at 12:25 PM,  [EMAIL PROTECTED] wrote:
   I did a ?lm and it said basically to be careful when using lm and a 
   time series. But my question is probably more to do with my 
   inexperience that anything. If I have a time series object 'ti' how do 
   I write the formula? The response is the value at any particular time 
   and the time is basically the index of the time series. But I don't 
   know how to put that into a formula.
  
   Thank you.
  
   Kevin
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/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
 Research Scientist
 Southeastern Natural Sciences Academy

 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





-- 
Stephen Sefick
Research Scientist
Southeastern Natural Sciences Academy

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] Area of density

2008-09-05 Thread Duncan Murdoch

On 05/09/2008 4:32 PM, pragmatic wrote:

Hello!
Please, anybody help me.

Can I calculate area of density was created by:

D - density(x)

In other words I want to know area under curve 'plot(D)'


That should be 1.


and It's good to calculate area before and after 0 separately.


That's harder, but a good approximation should be sum(x  0)/length(x) 
and sum(x  0)/length(x).


Duncan Murdoch

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


[R] xls to csv conversion via WinXP's context menu?

2008-09-05 Thread Mark Na
Frequently I need to convert a .xls to a .csv (for import into R) and I 
do this by opening the file in excel and saving it as a csv. I would 
rather do this using WinXP's context menu (right click the xls, choose 
convert to csv) but I don't know of a utility that does this. Any 
ideas? Thanks, Mark


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


Re: [R] Area of density

2008-09-05 Thread Rolf Turner


On 6/09/2008, at 8:32 AM, pragmatic wrote:



Hello!
Please, anybody help me.

Can I calculate area of density was created by:

D - density(x)

In other words I want to know area under curve 'plot(D)'
and It's good to calculate area before and after 0 separately.


(1) You could use splinefun()

foo - splinefun(D$x,D$y)
integrate(foo,min(D$x),0)
integrate(foo,0,max(D$x))

or you could use simp() from

http://finzi.psych.upenn.edu/R/Rhelp02a/archive/134918.html

with(D,simp(y=y[x0],x=x[x0]))
with(D,simp(y=y[x0],x=x[x0]))

You'll get different answers, neither of which is ``correct''.

cheers,

Rolf Turner

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

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


Re: [R] xls to csv conversion via WinXP's context menu?

2008-09-05 Thread Gabor Grothendieck
See ?xls2csv in the gdata package.

On Fri, Sep 5, 2008 at 6:45 PM, Mark Na [EMAIL PROTECTED] wrote:
 Frequently I need to convert a .xls to a .csv (for import into R) and I do
 this by opening the file in excel and saving it as a csv. I would rather do
 this using WinXP's context menu (right click the xls, choose convert to
 csv) but I don't know of a utility that does this. Any ideas? Thanks, Mark

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


Re: [R] xls to csv conversion via WinXP's context menu?

2008-09-05 Thread Jorge Ivan Velez
Dear Mark,
I think you don't need to convert your xls files into csv files to read them
using R. There are several ways to read them such as
the RODBC package and ?read.xls in gdata. Now, if you really want to do the
conversion, try ?xls2csv in gdata as well.

HTH,

Jorge



On Fri, Sep 5, 2008 at 6:45 PM, Mark Na [EMAIL PROTECTED] wrote:

 Frequently I need to convert a .xls to a .csv (for import into R) and I do
 this by opening the file in excel and saving it as a csv. I would rather do
 this using WinXP's context menu (right click the xls, choose convert to
 csv) but I don't know of a utility that does this. Any ideas? Thanks, Mark

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


[[alternative HTML version deleted]]

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


[R] annotating objects in workspace

2008-09-05 Thread Alexy Khrabrov
Is there a way to associate descriptions with the objects in the  
workspace, and later retrieve them to know what the object was created  
for?


Thanks,
Alexy

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


  1   2   >