[R] Is there a better way to check if an element of a list exists than using match on names?

2008-07-29 Thread Paul.Rustomji

Hello R mailing list

Is there a better way than this to see if an element exists *within* a
list object :

#generate "file.txt" using current routine
cat("var1=33\nvar2=TRUE",file="file.txt")

#load file to a list called "ipf"
f <- function(.file){source(.file,local=TRUE);as.list(environment())}
ipf<- f("file.txt")

print(ipf)


#this is the bit I need help with...
res <- match("var1",names(ipf)) # returns result > 0 if "var" exists
within ipf ie. TRUE
print(res)
res <- match("var3",names(ipf)) #returns NA as "var3" is not in ipf ie.
FALSE
print(res)

I have tried the exists function but cannot get it to apply to items of
a list (though can get it to see if the list exists as an object...)

Thanks
Paul.

Paul Rustomji
Rivers and Estuaries
CSIRO Land and Water
GPO Box 1666
Canberra ACT 2601

ph +61 2 6246 5810
mobile 0406 375 739

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


Re: [R] finding a faster way to do an iterative computation

2008-07-29 Thread Moshe Olshansky
Try

abs(outer(xk,x,"-"))

(see ?outer)


--- On Wed, 30/7/08, dxc13 <[EMAIL PROTECTED]> wrote:

> From: dxc13 <[EMAIL PROTECTED]>
> Subject: [R]  finding a faster way to do an iterative computation
> To: r-help@r-project.org
> Received: Wednesday, 30 July, 2008, 4:12 AM
> useR's,
> 
> I am trying trying to find out if there is a faster way to
> do a certain
> computation.  I have successfully used FOR loops and the
> apply function to
> do this, but it can take some time to fully compute, but I
> was wondering if
> anyone may know of a different function or way to do this:
> > x
> [1] 1 2 3 4 5
> > xk
>  [1] 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0
> 
> I want to do: abs(x-xk[i]) where i = 1 to length(xk)=13. 
> It should result
> in a 13 by 5 matrix or data frame.  Does anyone have a
> "quicker" solution
> than FOR loops or apply()?
> 
> Much appreciation and thanks,
> dxc13
> -- 
> View this message in context:
> http://www.nabble.com/finding-a-faster-way-to-do-an-iterative-computation-tp18718233p18718233.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained,
> reproducible code.

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


Re: [R] R command history -- can it be like Matlab's?

2008-07-29 Thread losemind



Prof Brian Ripley wrote:
> 
> A patch to do this was posted on 2007-09-29 by Glenn Davis.  Some people 
> not addicted to Matlab find the behaviour very inconvenient and prefer the 
> getline/readline behaviour (triggered by ^R/^S) of Rterm and R on Unixen.
> 
> On Tue, 29 Jul 2008, losemind wrote:
> 
>>
>> Hi all,
>>
>> In R GUI window, if you use "up" and "down" key, you will be able to
>> recall
>> the previous and next command that has been used and stored in the
>> command
>> history cache.
>>
>> But there is one inconvenience:
> 
> Or an inconvenience of Matlab not shared by R, depending on your 
> preferences.
> 
>> In Matlab, you can type the first a few characters of the command that
>> you
>> previously used,
>>
>> and then press “up" key, you will be able to get to that previous command
>> very fast,
>>
>> no matter how long ago it has been used...
>>
>> In R GUI, there is no such functionality.
>>
>> Any thoughts on making R work my productivity?
>>
>> --
>>
>> Also where do I find good debugger for R?
>>
>> Thanks!
>> -- 
>> View this message in context:
>> http://www.nabble.com/R-command-historycan-it-be-like-Matlab%27s--tp18719530p18719530.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.
> 
> 



Hi,

I don't find Glenn Davis's patch... where is it?

I like that Matlab feature. And I am using R GUI on windows...

Please help me!

Please also give me pointers to good R debuggers?

Thanks!

-- 
View this message in context: 
http://www.nabble.com/R-command-historycan-it-be-like-Matlab%27s--tp18719530p18722696.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] What's the best way to operate R from within Excel?

2008-07-29 Thread losemind

Hi all,

How do I operate R from within Excel?

I mean, highlight a bunch of cells, and send to R, and do some statistics in
R, and return back the numbers and do some plots in R.

For example, I have some parameters for Gaussian Random variable, and I
would find the most convenient way to send these numbers to R and do some
plots...

How to do that?

Thanks a lot!

-- 
View this message in context: 
http://www.nabble.com/What%27s-the-best-way-to-operate-R-from-within-Excel--tp18722737p18722737.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] placing a text in the corner of a plot

2008-07-29 Thread Jörg Groß
> legend("topleft",c("Your text here"),pch=1)


Thanks!

But is it possible to get rid of the legend-box and the box-shadow?

I don't find an argument in the manual for that.



Am 30.07.2008 um 00:08 schrieb Jorge Ivan Velez:

>
> Dear Jörg,
>
> Perhaps,
>
> plot(1:10)
> legend("topleft",c("Your text here"),pch=1)
>
> See ?legend and ?text for more information.
>
> HTH,
>
> Jorge
>
>
> On Tue, Jul 29, 2008 at 6:04 PM, Jörg Groß <[EMAIL PROTECTED]>  
> wrote:
> Is there an easy way to add a text into an R-plot and place it in  
> the upper left corner?
>
> Like that:
>
>
> 
> |  (a)  |
> | |
> | |
> | |
> | |
> | |
> 
>
> The (a) should be at the borders of a box defined by the box()- 
> command.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Legality Question about R's Open Source GNU GPL License

2008-07-29 Thread David Henderson

Hi All:

I know this has been discussed at length already, but 1) I get R-Help  
in digest and didn't see this until 3am Pacific time this morning, and  
2) We, REvolution, have been discussing this as of late.  I thought I  
would pass on some of the knowledge we have recently obtained vis a  
vis the GPL and R.


First, I would like to say that  you have already received some great  
advice and some good pointers to information about R and its use of  
the GPL.  I'm only hoping to augment that information.  Plus, I'm not  
a lawyer, but I have been visiting with lawyers a lot lately and this  
information comes from my interpretation of what they have told me  
about the GPL, specifically with respect to R.


With respect to your specific question, the GPL license in R would  
only have bearing on your code should you decide to distribute it and  
only when you distribute it and then only if you linked some compiled  
code to it (think C/C++/FORTRAN).  So, if you are only distributing  
the compiled code within your corporation, you only have to provide  
the source for your code to your own colleagues as the GPL states that  
the code must be available upon request and only your colleagues  
should know about the code's existence to request it.  If you are only  
creating script, then the GPL license provided in R provides an  
exception as discussed below.  Note that installing R on your system  
does not GPL license all code on your system.


The topic of Linux being GPL is not really relevant.  Generally,  
software libraries in Linux are provided with a LGPL license to avoid  
the GPL problem you describe.  Also, there are exceptions in the GPL  
for Linux device drivers to prevent them from infecting code in  
Linux.  So, using Linux is a different discussion than using R.


A better analogy for using R in corporate environments than something  
like apache is the BASH shell. BASH is GPL, but your BASH script is  
not GPL as there is an exception in the standard GPL for interpreted  
languages.


With respect to commercial versions of R, these R distributions will  
not have different licenses than the GPL already in R.  Unless all of  
R Core and other copyright holders to the R source provide an  
exception to the GPL license in R, any commercial distribution of R  
will also have the same GPL license.  It is doubtful that an exception  
will ever be granted for the R source code itself.  What these  
commercial distributions do provide is support and services on top of  
open source R and in our case replacement of the BLAS routines with  
optimized ones.


If your legal department is still concerned, have them look at the  
license in Java.  It most likely is GPL (unless you have a special  
commercial version of Java installed) and thus makes any Java program  
you create subject to the GPL in Java due to the JIT compiler used in  
Java.  If your legal department does not have a problem with Java,  
then they should not have a problem with R.


And again, I am not a lawyer and you are receiving third hand  
information (some lawyers to me, and from me to you).


By the way, I enjoyed the y0k discussion...

Thanks!!

Dave H

On Jul 29, 2008, at 3:00 AM, [EMAIL PROTECTED] wrote:


From: zerfetzen <[EMAIL PROTECTED]>
Date: July 28, 2008 11:32:04 AM PDT
To: r-help@r-project.org
Subject: [R] Legality Question about R's Open Source GNU GPL License



Hi,
I use R at home, and am interested in using it at my work company  
(which is
in the Fortune 100).  I began the request, and our legal team has  
given some
gruff about the open source license.  Not boring you with the  
details here,
but I used some info on gnu.org as a rebuttal, and someone at the  
company
replied that the generalities of GNU GPL may differ from R's  
specific GNU
GPL license, and that I should refer specifically to it, and it  
should be on

the CRAN website.

I may be blind, but haven't seen such a document.  Does one exist,  
and how
may I obtain it?  I believe they are wrong.  Our legal team is  
notorious for
being overly conservative, and I'm personally betting they think I  
won't
look into it, and then they won't have to deal with it.  But I will,  
and I

want to use R.  Thanks.

PS
Sorry if the document was posted and obvious, and I simply couldn't  
find it.

Thanks.
--
View this message in context: 
http://www.nabble.com/Legality-Question-about-R%27s-Open-Source-GNU-GPL-License-tp18696623p18696623.html
Sent from the R help mailing list archive at Nabble.com.


--
David Henderson, Ph.D.
Director of Community
REvolution Computing
1100 Dexter Avenue North, Suite 250
206-577-4778 x3203
[EMAIL PROTECTED]
http://www.revolution-computing.com

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


Re: [R] Help interpreting density().

2008-07-29 Thread Bill.Venables
In general there is no relation.  The output of density gives you
something you can plot, essentially.  So the x-values are simply a
series of points covering the range of the density and the y values are
the ordinates at those abscissae.

try

plot(density(rnorm(1000)^2)))

for example.


Bill Venables
CSIRO Laboratories
PO Box 120, Cleveland, 4163
AUSTRALIA
Office Phone (email preferred): +61 7 3826 7251
Fax (if absolutely necessary):  +61 7 3826 7304
Mobile: +61 4 8819 4402
Home Phone: +61 7 3286 7700
mailto:[EMAIL PROTECTED]
http://www.cmis.csiro.au/bill.venables/ 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, 29 July 2008 6:09 PM
To: r-help@r-project.org; Venables, Bill (CMIS, Cleveland)
Subject: RE: [R] Help interpreting density().

Sorry, poor example. I started with normal deviates and jumped without
thinking to Poisson. The main crux of the question is how does the
output of density relate to the parameters that describe some of the
standard distributions (mean and std for normal, lambda for Poisson, n
and p for Binomial, alpha and beta for Beta, etc.).

Thank you.

Kevin

 [EMAIL PROTECTED] wrote: 
> You should read the documentation more carefully.  The bw is not
> "essentially the sd".  To quote the documentation the bw is "the
> smoothing bandwidth to be used. The kernels are scaled such that this
is
> the standard deviation of the smoothing kernel."  That is a very
> different thing.
> 
> You are confusing the standard deviation of the distribution with the
> standard deviation of the gaussian smoothing kernels.  
> 
> In the second case, density(rpois(1000, 0)), you are getting the
kernel
> density for a sample of 1000 zeros.  So there is just one distinct
> smoothing kernel and the bw is a default used for this case.  If you 
> 
> plot(density(rpois(1000, 0)))
> 
> you will see what that smoothing kernel looks like.
> 
> 
> Bill Venables
> CSIRO Laboratories
> PO Box 120, Cleveland, 4163
> AUSTRALIA
> Office Phone (email preferred): +61 7 3826 7251
> Fax (if absolutely necessary):  +61 7 3826 7304
> Mobile: +61 4 8819 4402
> Home Phone: +61 7 3286 7700
> mailto:[EMAIL PROTECTED]
> http://www.cmis.csiro.au/bill.venables/ 
> 
> -Original Message-
> From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
> On Behalf Of [EMAIL PROTECTED]
> Sent: Tuesday, 29 July 2008 2:15 PM
> To: r-help@r-project.org
> Subject: [R] Help interpreting density().
> 
> I issue the following:
> 
> > d <- density(rnorm(1000))
> > d
> 
> and get:
> 
> Call:
> density.default(x = rnorm(1000))
> 
> Data: rnorm(1000) (1000 obs.);  Bandwidth 'bw' = 0.2235
> 
>x y
>  Min.   :-3.5157   Min.   :2.416e-05  
>  1st Qu.:-1.6892   1st Qu.:1.129e-02  
>  Median : 0.1373   Median :7.267e-02  
>  Mean   : 0.1373   Mean   :1.367e-01  
>  3rd Qu.: 1.9639   3rd Qu.:2.693e-01  
>  Max.   : 3.7904   Max.   :4.014e-01  
> 
> The documentation indicates that the bw is essentially the sd. Yet I
> have specified an sd of 1? How am I to interpret the ranges of the
> values? x ranges almost from -4 to +4 and y ranges from 0 to 0.4. The
> mean x is .1 which isn't too awfully close to what I would expect
(0.0).
> Then there is:
> 
> > d <- density(rpois(1000,0))
> > d
> 
> Call:
> density.default(x = rpois(1000, 0))
> 
> Data: rpois(1000, 0) (1000 obs.);   Bandwidth 'bw' = 0.2261
> 
>x y  
>  Min.   :-0.6782   Min.   :0.01979  
>  1st Qu.:-0.3391   1st Qu.:0.14073  
>  Median : 0.   Median :0.57178  
>  Mean   : 0.   Mean   :0.73454  
>  3rd Qu.: 0.3391   3rd Qu.:1.32830  
>  Max.   : 0.6782   Max.   :1.76436  
> 
> Here I am getting the mean that I expect from a Poisson distribuition
> but y ranges from 0 to 1.75. Again I am not sure what these numbers
> mean. How can I map the output to the standard distirbution
description
> parameters?
> 
> 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.
> 
> 

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


Re: [R] Chi-square parameter estimation

2008-07-29 Thread Moshe Olshansky
If v is your vector of sample variances (and assuming that their distribution 
is chi-square) you can define
f(df) <- sum(dchisq(v,df,log=TRUE))
and now you need to maximize f, which can be done using any optimization 
function (like optim).


--- On Sat, 26/7/08, Julio Rojas <[EMAIL PROTECTED]> wrote:

> From: Julio Rojas <[EMAIL PROTECTED]>
> Subject: [R] Chi-square parameter estimation
> To: r-help@r-project.org
> Received: Saturday, 26 July, 2008, 12:03 AM
> Hi. I have made 100 experiments of an M/M/1 queue, and for
> each one I have calculated both, mean and variance of the
> queue size. Now, a professor has told me that variance is
> usually chi-squared distributed. Is there a way in R that I
> can find the parameter that best fits a chi-square to the
> variance data? I know there's fitdistr()m but this
> function doesn't handle chi-square. I believe the mean
> estimator for the chi-square is df (degrees of freedom).
> The theoretical variance for an M/M/1 queue with
> lambda=30/33 is ~108. So, should I expect the chi-square
> with parameter 108 is the one that best fits the data?
> 
> Thanks a lot for your help.
> 
> 
> 
> 
> 
>  
> 
> Yahoo! MTV Blog & Rock >¡Cuéntanos tu
> historia, inspira una canción y gánate un viaje a los
> Premios MTV! Participa aquí http://mtvla.yahoo.com/
>   [[alternative HTML version
> deleted]]__
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained,
> reproducible code.

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


Re: [R] placing a text in the corner of a plot

2008-07-29 Thread Rolf Turner


On 30/07/2008, at 10:47 AM, Jörg Groß wrote:


legend("topleft",c("Your text here"),pch=1)



Thanks!

But is it possible to get rid of the legend-box and the box-shadow?

I don't find an argument in the manual for that.


You explicitly said that you *wanted* a box!!!

But be that as it may, you can eliminate the box
by putting ``bty="n"'' in the call to legend.

I have no idea what you mean by ``box-shadow''.



cheers,

Rolf Turner
##
Attention: 
This e-mail message is privileged and confidential. If you are not the 
intended recipient please delete the message and notify the sender. 
Any views or opinions presented are solely those of the author.


This e-mail has been scanned and cleared by MailMarshal 
www.marshalsoftware.com

##

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


Re: [R] placing a text in the corner of a plot

2008-07-29 Thread Ben Tupper


On Jul 29, 2008, at 6:47 PM, Jörg Groß wrote:


legend("topleft",c("Your text here"),pch=1)



Thanks!

But is it possible to get rid of the legend-box and the box-shadow?

I don't find an argument in the manual for that.



Hi,

The documentation for the argument is right there - but as always it  
is finding it that is the trick.


Try this...

legend("topleft",c("Your text here"),pch=1, box.lty = 0)


Cheers,
Ben





Am 30.07.2008 um 00:08 schrieb Jorge Ivan Velez:



Dear Jörg,

Perhaps,

plot(1:10)
legend("topleft",c("Your text here"),pch=1)

See ?legend and ?text for more information.

HTH,

Jorge


On Tue, Jul 29, 2008 at 6:04 PM, Jörg Groß <[EMAIL PROTECTED]>
wrote:
Is there an easy way to add a text into an R-plot and place it in
the upper left corner?

Like that:



|  (a)  |
| |
| |
| |
| |
| |


The (a) should be at the borders of a box defined by the box()-
command.

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


Ben Tupper
[EMAIL PROTECTED]

I GoodSearch for Ashwood Waldorf School.

Raise money for your favorite charity or school just by searching the  
Internet with GoodSearch - www.goodsearch.com - powered by Yahoo!


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] correlation between matrices - both with some NAs

2008-07-29 Thread rcoder

Hi everyone,

I'm having trouble applying the Cor() function to two matrices, both of
which contain NAs. I am doing the following:

a<-cor(m1, m2, use="complete.obs")

... and I get the following error message:

Error in cor(m1, m2, use = "complete.obs") : 
  no complete element pairs

Does anyone know how I can apply a correlation, ignoring any NAs?

Thanks,

rcoder
-- 
View this message in context: 
http://www.nabble.com/correlation-between-matrices---both-with-some-NAs-tp18721853p18721853.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] rollapply() opertation on time series

2008-07-29 Thread rcoder

Hi Gabor,

Thanks for your reply. Assuming I have a time series that is ready made
(i.e. not constructed it using a zoo function) will the procedure below
still retain the dates in the matrix?

Thanks,

rcoder

quote author="Gabor Grothendieck">
rollapply along an index:

library(zoo)
z <- zoo(matrix(101:110, 5), 201:205)
tt <- time(z)
zz <- zoo(seq_along(tt), tt)
out <- rollapply(zz, 3, function(ix) list(z[ix,]))
str(out) # list of zoo objects


On Mon, Jul 28, 2008 at 5:03 PM, rcoder <[EMAIL PROTECTED]> wrote:
>
>
> rcoder wrote:
>>
>> Hi everyone,
>>
>> Is there a way to perform a rollapply operation on a time series data
>> matrix and preserve the time frame? Currently, when I apply rollapply in
>> its standart form, the date column is no longer present in the o/p
>> matrix.
>>
>> Thanks,
>>
>> rcoder
>>
>
> --
> View this message in context:
> http://www.nabble.com/rollapply%28%29-opertation-on-ts-matrix-tp18694735p18699707.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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



-- 
View this message in context: 
http://www.nabble.com/rollapply%28%29-opertation-on-ts-matrix-tp18694735p18721849.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] rolling regression between adjacent columns

2008-07-29 Thread rcoder

Hi everyone,

I am trying to apply linear regression to adjacent columns in a matrix (i.e.
col1~col2; col3~col4; etc.). The columns in my matrix come with identifiers
at the top of each column, but when I try to use these identifiers to
reference the columns in the regression function using rollapply(), the
columns are not recognised and the regression breaks down. Is there a more
robust way to reference the columns I need, so that I can apply the
regression across the matrix; 'by.column', but every other column?

Thanks,

rcoder
-- 
View this message in context: 
http://www.nabble.com/rolling-regression-between-adjacent-columns-tp18722392p18722392.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] Legality Question about R's Open Source GNU GPL License

2008-07-29 Thread Gad Abraham
If your legal department is still concerned, have them look at the 
license in Java.  It most likely is GPL (unless you have a special 
commercial version of Java installed) and thus makes any Java program 
you create subject to the GPL in Java due to the JIT compiler used in 
Java.  If your legal department does not have a problem with Java, then 
they should not have a problem with R.


This is conflating two issues, the license of the compiler/interpreter, 
and the license of the code you wrote in that language.


From http://gplv3.fsf.org/wiki/index.php/FAQ_Update:

``Can I use GPL-covered editors such as GNU Emacs to develop non-free 
programs? Can I use GPL-covered tools such as GCC to compile them?


Yes, because the copyright on the editors and tools does not cover the 
code you write. Using them does not place any restrictions, legally, on 
the license you use for your code.


Some programs copy parts of themselves into the output for technical 
reasons--for example, Bison copies a standard parser program into its 
output file. In such cases, the copied text in the output is covered by 
the same license that covers it in the source code. Meanwhile, the part 
of the output which is derived from the program's input inherits the 
copyright status of the input.


As it happens, Bison can also be used to develop non-free programs. This 
is because we decided to explicitly permit the use of the Bison standard 
parser program in Bison output files without restriction. We made the 
decision because there were other tools comparable to Bison which 
already permitted use for non-free programs.''



--
Gad Abraham
Dept. CSSE and NICTA
The University of Melbourne
Parkville 3010, Victoria, Australia
email: [EMAIL PROTECTED]
web: http://www.csse.unimelb.edu.au/~gabraham

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


Re: [R] Colors in Sweave

2008-07-29 Thread Duncan Murdoch

On 27/07/2008 3:10 PM, Stephen Tucker wrote:

Hi list,

I was using Sweave and was wondering if anyone has had any luck changing the 
font colors of the code chunks. For instance, in my .Rnw preample I tried 
including:

===
\usepackage[usenames]{colors}
\definecolor{darkred}{rgb}{0.545,0,0}
\definecolor{midnightblue}{rgb}{0.098,0.098,0.439}
\DefineVerbatimEnvironment{Sinput}{Verbatim}{fontshape=sl,formatcom={\color{midnightblue}}}
\DefineVerbatimEnvironment{Soutput}{Verbatim}{formatcom={\color{darkred}}}
\DefineVerbatimEnvironment{Scode}{Verbatim}{fontshape=sl,formatcom={\color{blue}}}
===

which works in the sense that colors do show up in the processed pdf document, 
but extra spaces in between the input and output code chunks appear (which is 
not the case when colors are not specified), resulting in a long document with 
many blank lines.

Alternatively, in the resulting tex document I replaced all instances of 
\begin{Sinput}... \end{Sinput} with {\color{midnightblue}\begin{Sinput} ... 
\end{Sinput}} and darkred for Soutput and so on. When I do this, I get the 
following error message:

=== LaTeX excerpt ===
\begin{Schunk}
{\color{midnightblue}\begin{Sinput}
ISOdatetime(1970, 1, 1, 0, 0, 0, "") - ISOdatetime(1970, 1, 1, 

+ 0, 0, 0, "GMT")
\end{Sinput}}
{\color{darkred}\begin{Soutput}
Time difference of 8 hours
\end{Soutput}}
\end{Schunk}
===

=== error message ===
)
! FancyVerb Error:
  Extraneous input `}\end{}' between \end{Sinput} and line end
.
[EMAIL PROTECTED] ... {FancyVerb Error:
\space \space #1
}
  
l.13 \end{Sinput}}

===

I guess I don't know enough of the Schunk/Sinput/Soutput definitions to toy with it and was wondering if anyone had tried something similar. 


The definitions are very simple:  see Sweave.sty, they're just

\DefineVerbatimEnvironment{Sinput}{Verbatim}{fontshape=sl}
\DefineVerbatimEnvironment{Soutput}{Verbatim}{}
\DefineVerbatimEnvironment{Scode}{Verbatim}{fontshape=sl}

\newenvironment{Schunk}{}{}

I would use

\DefineVerbatimEnvironment{Sinput}{Verbatim}{fontshape=sl,formatcom=\color{midnightblue}}

(i.e. no extra braces), but whether or not I do that, I don't notice 
extra spacing beyond what Sweave always puts in.  To get rid of the 
usual Sweave extra spacing, try


\fvset{listparameters={\setlength{\topsep}{0pt}}}
\renewenvironment{Schunk}{\vspace{\topsep}}{\vspace{\topsep}}

Duncan Murdoch

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


Re: [R] Legality Question about R's Open Source GNU GPL License

2008-07-29 Thread Gad Abraham

Gad Abraham wrote:
If your legal department is still concerned, have them look at the 
license in Java.  It most likely is GPL (unless you have a special 
commercial version of Java installed) and thus makes any Java program 
you create subject to the GPL in Java due to the JIT compiler used in 
Java.  If your legal department does not have a problem with Java, 
then they should not have a problem with R.


This is conflating two issues, the license of the compiler/interpreter, 
and the license of the code you wrote in that language.


 From http://gplv3.fsf.org/wiki/index.php/FAQ_Update:

``Can I use GPL-covered editors such as GNU Emacs to develop non-free 
programs? Can I use GPL-covered tools such as GCC to compile them?


Yes, because the copyright on the editors and tools does not cover the 
code you write. Using them does not place any restrictions, legally, on 
the license you use for your code.


Some programs copy parts of themselves into the output for technical 
reasons--for example, Bison copies a standard parser program into its 
output file. In such cases, the copied text in the output is covered by 
the same license that covers it in the source code. Meanwhile, the part 
of the output which is derived from the program's input inherits the 
copyright status of the input.


As it happens, Bison can also be used to develop non-free programs. This 
is because we decided to explicitly permit the use of the Bison standard 
parser program in Bison output files without restriction. We made the 
decision because there were other tools comparable to Bison which 
already permitted use for non-free programs.''




Replying to myself, Java is a particularly bad example here, because 
under the standard GPL v2, inheritance is considered derivative work, so 
every time you instantiate any object (thus inheriting from Object) and 
the Object class is GPL, then your code is GPL. For v2, there is the 
version of the GPL with the Classpath exception 
http://www.gnu.org/software/classpath/faq/faq.html#faq2_1, that 
specifically allows for that.


This may have implications for object oriented R, as if I choose to 
extend the Matrix class, for example, then it's considered derivative 
work and hence under the GPL.



--
Gad Abraham
Dept. CSSE and NICTA
The University of Melbourne
Parkville 3010, Victoria, Australia
email: [EMAIL PROTECTED]
web: http://www.csse.unimelb.edu.au/~gabraham

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


Re: [R] Legality Question about R's Open Source GNU GPL License

2008-07-29 Thread David Henderson

Hello Gad:

On Jul 29, 2008, at 4:41 PM, Gad Abraham wrote:

If your legal department is still concerned, have them look at the  
license in Java.  It most likely is GPL (unless you have a special  
commercial version of Java installed) and thus makes any Java  
program you create subject to the GPL in Java due to the JIT  
compiler used in Java.  If your legal department does not have a  
problem with Java, then they should not have a problem with R.


This is conflating two issues, the license of the compiler/ 
interpreter, and the license of the code you wrote in that language.


From http://gplv3.fsf.org/wiki/index.php/FAQ_Update:

``Can I use GPL-covered editors such as GNU Emacs to develop non- 
free programs? Can I use GPL-covered tools such as GCC to compile  
them?


Yes, because the copyright on the editors and tools does not cover  
the code you write. Using them does not place any restrictions,  
legally, on the license you use for your code.


Some programs copy parts of themselves into the output for technical  
reasons--for example, Bison copies a standard parser program into  
its output file. In such cases, the copied text in the output is  
covered by the same license that covers it in the source code.  
Meanwhile, the part of the output which is derived from the  
program's input inherits the copyright status of the input.


As it happens, Bison can also be used to develop non-free programs.  
This is because we decided to explicitly permit the use of the Bison  
standard parser program in Bison output files without restriction.  
We made the decision because there were other tools comparable to  
Bison which already permitted use for non-free programs.''



The issue I was addressing here was actually that when you write a  
Java program, it is compiled at runtime and then linked to the other  
com libraries that come with the installation that are under the GPL  
license.  It is this linking that happens at compile time that invokes  
the Java GPL over the license you apply to your code.


We should probably move this off-line if we need to discuss this  
further and maybe update the list once we've reached a conclusion (if  
we do), rather than continue a long off-topic, but relevant, discussion.


Thanks!!

Dave H
--
David Henderson, Ph.D.
1535 NW 51st ST
Seatle, WA 98107
206-794-8552
[EMAIL PROTECTED]

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


Re: [R] table questions

2008-07-29 Thread Ted Harding
On 29-Jul-08 16:28:26, Edna Bell wrote:
> Hi again!
> Suppose I have the following:
> 
>> xy <- round(rexp(20),1)
>> xy
>  [1] 0.1 3.4 1.6 0.4 1.0 1.4 0.2 0.3 1.6 0.2 0.0 0.1 0.1 1.0 2.0 0.9
> 2.5 0.1 1.5 0.4
>> table(xy)
> xy
>   0 0.1 0.2 0.3 0.4 0.9   1 1.4 1.5 1.6   2 2.5 3.4
>   1   4   2   1   2   1   2   1   1   2   1   1   1
>>
> Is there a way to set things up to have
> 0 - 0.4   0.5 - 0.9  etc. please?
> 
> I know there is the cut functions, but breaks are required.  If you
> don't have breaks, what should you do, please?
> 
> Would using the breaks from the hist function work appropriately,
> please?
> 
> thanks
> Edna Bell

It could, though it seems a bit clumsy:

  xy<-round(rexp(20),1)
  H<-hist(xy,breaks=(-0.05+0.5*(0:8)),plot=FALSE)
  brks<-H$breaks ; cts<-H$counts
  Tbl<-rbind(NULL,cts)
  brlabs<-paste(brks[1:(k-1)]+0.05,"-",brks[2:k]-0.05,sep="")
  colnames(Tbl)<-brlabs
  Tbl
#  0-0.4 0.5-0.9 1-1.4 1.5-1.9 2-2.4 2.5-2.9 3-3.4 3.5-3.9
#cts   5   4 6   3 0   1 1   0

One could fiddle with formatting to replace 0 by 0.0 and
3 by 3.0, and set rownames=NULL; but I don't see how to get
the counts placed in the "middle" of the range. But it's
better than nothing, I suppose!

Ted.


E-Mail: (Ted Harding) <[EMAIL PROTECTED]>
Fax-to-email: +44 (0)870 094 0861
Date: 30-Jul-08   Time: 01:14:43
-- XFMail --

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


Re: [R] Legality Question about R's Open Source GNU GPL License

2008-07-29 Thread Charles Annis, P.E.
Gad and David - would you be so kind as to include me in any off-line
discussion of this vital topic of R and GPL?

Many thanks.

Charles Annis, P.E.

[EMAIL PROTECTED]
phone: 561-352-9699
eFax:  614-455-3265
http://www.StatisticalEngineering.com
 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of David Henderson
Sent: Tuesday, July 29, 2008 8:04 PM
To: Gad Abraham
Cc: r-help@r-project.org; zerfetzen
Subject: Re: [R] Legality Question about R's Open Source GNU GPL License

Hello Gad:

On Jul 29, 2008, at 4:41 PM, Gad Abraham wrote:

>> If your legal department is still concerned, have them look at the  
>> license in Java.  It most likely is GPL (unless you have a special  
>> commercial version of Java installed) and thus makes any Java  
>> program you create subject to the GPL in Java due to the JIT  
>> compiler used in Java.  If your legal department does not have a  
>> problem with Java, then they should not have a problem with R.
>
> This is conflating two issues, the license of the compiler/ 
> interpreter, and the license of the code you wrote in that language.
>
> From http://gplv3.fsf.org/wiki/index.php/FAQ_Update:
>
> ``Can I use GPL-covered editors such as GNU Emacs to develop non- 
> free programs? Can I use GPL-covered tools such as GCC to compile  
> them?
>
> Yes, because the copyright on the editors and tools does not cover  
> the code you write. Using them does not place any restrictions,  
> legally, on the license you use for your code.
>
> Some programs copy parts of themselves into the output for technical  
> reasons--for example, Bison copies a standard parser program into  
> its output file. In such cases, the copied text in the output is  
> covered by the same license that covers it in the source code.  
> Meanwhile, the part of the output which is derived from the  
> program's input inherits the copyright status of the input.
>
> As it happens, Bison can also be used to develop non-free programs.  
> This is because we decided to explicitly permit the use of the Bison  
> standard parser program in Bison output files without restriction.  
> We made the decision because there were other tools comparable to  
> Bison which already permitted use for non-free programs.''


The issue I was addressing here was actually that when you write a  
Java program, it is compiled at runtime and then linked to the other  
com libraries that come with the installation that are under the GPL  
license.  It is this linking that happens at compile time that invokes  
the Java GPL over the license you apply to your code.

We should probably move this off-line if we need to discuss this  
further and maybe update the list once we've reached a conclusion (if  
we do), rather than continue a long off-topic, but relevant, discussion.

Thanks!!

Dave H
--
David Henderson, Ph.D.
1535 NW 51st ST
Seatle, WA 98107
206-794-8552
[EMAIL PROTECTED]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] how to get the position of a vector-value

2008-07-29 Thread Jörg Groß
I am searching for a way to get nearest position of a number in a  
vector from a search-value.


So perhaps if I have this vector:
1.0   1.2   1.4   1.6   1.8   2.0

I want to get the position of a special number.

with match(1.4 ,x), I get "3" for position three.

But now I want the nearest number in that vector from perhaps 1.5 (the  
mean).




I tried it with sequences:
 match(seq(from=1.1, to=1.6, by=.1),x)

but what I get is:
[1] NA NA NA NA NA  4
(instead of (NA 2 NA 3 NA 4).

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


Re: [R] rollapply() opertation on time series

2008-07-29 Thread Gabor Grothendieck
methods(rollapply)
shows which classes have rollapply methods.

On Tue, Jul 29, 2008 at 5:48 PM, rcoder <[EMAIL PROTECTED]> wrote:
>
> Hi Gabor,
>
> Thanks for your reply. Assuming I have a time series that is ready made
> (i.e. not constructed it using a zoo function) will the procedure below
> still retain the dates in the matrix?
>
> Thanks,
>
> rcoder
>
> quote author="Gabor Grothendieck">
> rollapply along an index:
>
> library(zoo)
> z <- zoo(matrix(101:110, 5), 201:205)
> tt <- time(z)
> zz <- zoo(seq_along(tt), tt)
> out <- rollapply(zz, 3, function(ix) list(z[ix,]))
> str(out) # list of zoo objects
>
>
> On Mon, Jul 28, 2008 at 5:03 PM, rcoder <[EMAIL PROTECTED]> wrote:
>>
>>
>> rcoder wrote:
>>>
>>> Hi everyone,
>>>
>>> Is there a way to perform a rollapply operation on a time series data
>>> matrix and preserve the time frame? Currently, when I apply rollapply in
>>> its standart form, the date column is no longer present in the o/p
>>> matrix.
>>>
>>> Thanks,
>>>
>>> rcoder
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/rollapply%28%29-opertation-on-ts-matrix-tp18694735p18699707.html
>> Sent from the R help mailing list archive at Nabble.com.
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>
>
> --
> View this message in context: 
> http://www.nabble.com/rollapply%28%29-opertation-on-ts-matrix-tp18694735p18721849.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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


Re: [R] rolling regression between adjacent columns

2008-07-29 Thread Gabor Grothendieck
Read the last line of every message to r-help.

On Tue, Jul 29, 2008 at 6:15 PM, rcoder <[EMAIL PROTECTED]> wrote:
>
> Hi everyone,
>
> I am trying to apply linear regression to adjacent columns in a matrix (i.e.
> col1~col2; col3~col4; etc.). The columns in my matrix come with identifiers
> at the top of each column, but when I try to use these identifiers to
> reference the columns in the regression function using rollapply(), the
> columns are not recognised and the regression breaks down. Is there a more
> robust way to reference the columns I need, so that I can apply the
> regression across the matrix; 'by.column', but every other column?
>
> Thanks,
>
> rcoder
> --
> View this message in context: 
> http://www.nabble.com/rolling-regression-between-adjacent-columns-tp18722392p18722392.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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


Re: [R] finding a faster way to do an iterative computation

2008-07-29 Thread dxc13

Thank you to all who applied.  These all seem to work the way I want them to. 
The outer function seems really useful, I probably could use that for a lot
of my work.
Thanks!

Rolf Turner-3 wrote:
> 
> 
> On 30/07/2008, at 6:12 AM, dxc13 wrote:
> 
>>
>> useR's,
>>
>> I am trying trying to find out if there is a faster way to do a  
>> certain
>> computation.  I have successfully used FOR loops and the apply  
>> function to
>> do this, but it can take some time to fully compute, but I was  
>> wondering if
>> anyone may know of a different function or way to do this:
>>> x
>> [1] 1 2 3 4 5
>>> xk
>>  [1] 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0
>>
>> I want to do: abs(x-xk[i]) where i = 1 to length(xk)=13.  It should  
>> result
>> in a 13 by 5 matrix or data frame.  Does anyone have a "quicker"  
>> solution
>> than FOR loops or apply()?
> 
>   outer(xk,x,function(a,b){abs(a-b)})
> 
> ##
> 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.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/finding-a-faster-way-to-do-an-iterative-computation-tp18718233p18723369.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] how to get the position of a vector-value

2008-07-29 Thread jim holtman
?findInterval

> x <- c(1.0,1.2,1.4,1.6,1.8,2.0)
> findInterval(1.4,x)
[1] 3
> findInterval(1.5,x)
[1] 3
> findInterval(10,x)
[1] 6


On Tue, Jul 29, 2008 at 8:32 PM, Jörg Groß <[EMAIL PROTECTED]> wrote:
> I am searching for a way to get nearest position of a number in a vector
> from a search-value.
>
> So perhaps if I have this vector:
> 1.0   1.2   1.4   1.6   1.8   2.0
>
> I want to get the position of a special number.
>
> with match(1.4 ,x), I get "3" for position three.
>
> But now I want the nearest number in that vector from perhaps 1.5 (the
> mean).
>
>
>
> I tried it with sequences:
>  match(seq(from=1.1, to=1.6, by=.1),x)
>
> but what I get is:
> [1] NA NA NA NA NA  4
> (instead of (NA 2 NA 3 NA 4).
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

What is the problem 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] Is there a better way to check if an element of a list exists than using match on names?

2008-07-29 Thread jim holtman
Is this what you want:

> "var3" %in% names(ipf)
[1] FALSE
> "var1" %in% names(ipf)
[1] TRUE
>


On Tue, Jul 29, 2008 at 6:20 PM,  <[EMAIL PROTECTED]> wrote:
>
> Hello R mailing list
>
> Is there a better way than this to see if an element exists *within* a
> list object :
>
> #generate "file.txt" using current routine
> cat("var1=33\nvar2=TRUE",file="file.txt")
>
> #load file to a list called "ipf"
> f <- function(.file){source(.file,local=TRUE);as.list(environment())}
> ipf<- f("file.txt")
>
> print(ipf)
>
>
> #this is the bit I need help with...
> res <- match("var1",names(ipf)) # returns result > 0 if "var" exists
> within ipf ie. TRUE
> print(res)
> res <- match("var3",names(ipf)) #returns NA as "var3" is not in ipf ie.
> FALSE
> print(res)
>
> I have tried the exists function but cannot get it to apply to items of
> a list (though can get it to see if the list exists as an object...)
>
> Thanks
> Paul.
>
> Paul Rustomji
> Rivers and Estuaries
> CSIRO Land and Water
> GPO Box 1666
> Canberra ACT 2601
>
> ph +61 2 6246 5810
> mobile 0406 375 739
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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 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] R command history -- can it be like Matlab's?

2008-07-29 Thread Spencer Graves
 Regarding dubuggers,  RSiteSearch("debug", "fun") produced 183 
hits for me just now.  The first two reference a "debug" package, while 
the third describes the "debug" function in the "base" package. 

 The "debug{base}" function is great, but not as good as the Matlab 
debugger.  The "debug" package provides other useful functionality but 
is harder to use.  I use the "debug{base}" function routinely and the 
"debug" package only very rarely. 

 Hope this helps. 
 Spencer


losemind wrote:


Prof Brian Ripley wrote:
  
A patch to do this was posted on 2007-09-29 by Glenn Davis.  Some people 
not addicted to Matlab find the behaviour very inconvenient and prefer the 
getline/readline behaviour (triggered by ^R/^S) of Rterm and R on Unixen.


On Tue, 29 Jul 2008, losemind wrote:



Hi all,

In R GUI window, if you use "up" and "down" key, you will be able to
recall
the previous and next command that has been used and stored in the
command
history cache.

But there is one inconvenience:
  
Or an inconvenience of Matlab not shared by R, depending on your 
preferences.




In Matlab, you can type the first a few characters of the command that
you
previously used,

and then press “up" key, you will be able to get to that previous command
very fast,

no matter how long ago it has been used...

In R GUI, there is no such functionality.

Any thoughts on making R work my productivity?

--

Also where do I find good debugger for R?

Thanks!
--
View this message in context:
http://www.nabble.com/R-command-historycan-it-be-like-Matlab%27s--tp18719530p18719530.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.







Hi,

I don't find Glenn Davis's patch... where is it?

I like that Matlab feature. And I am using R GUI on windows...

Please help me!

Please also give me pointers to good R debuggers?

Thanks!




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


[R] Repeated Measure ANOVA-Old question

2008-07-29 Thread ctu

Hi R users,
I google the website and I found that there are three ways to perform  
repeated measure ANOVA: aov, lme and lmer.

http://www.mail-archive.com/[EMAIL PROTECTED]/msg58502.html
But the questions are which one is good to use and how to do post-hoc test?

I use the example that is provided in the above link and I try

tt<-aov(p.pa~group*time+Error(subject/time),data=P.PA)
TukeyHSD(tt)

Error in UseMethod("TukeyHSD") : no applicable method for "TukeyHSD"

Any suggestions?

Appreciate in advance~
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.


Re: [R] Re peated Measure ANOVA-Old question

2008-07-29 Thread Mark Difford

Hi Chunhao,

>> I google the website and I found that there are three ways to perform  
>> repeated measure ANOVA: aov, lme and lmer.

It's also a good idea to search through the archives.

>> I use the example that is provided in the above link and I try
>> > tt<-aov(p.pa~group*time+Error(subject/time),data=P.PA)
>> > TukeyHSD(tt)
>> Error in UseMethod("TukeyHSD") : no applicable method for "TukeyHSD"

Because of ... + Error().

See the following thread, where this is answered:

http://www.nabble.com/Tukey-HSD-(or-other-post-hoc-tests)-following-repeated-measures-ANOVA-td17508294.html#a17559307

HTH, Mark.


ctu wrote:
> 
> Hi R users,
> I google the website and I found that there are three ways to perform  
> repeated measure ANOVA: aov, lme and lmer.
> http://www.mail-archive.com/[EMAIL PROTECTED]/msg58502.html
> But the questions are which one is good to use and how to do post-hoc
> test?
> 
> I use the example that is provided in the above link and I try
>> tt<-aov(p.pa~group*time+Error(subject/time),data=P.PA)
>> TukeyHSD(tt)
> Error in UseMethod("TukeyHSD") : no applicable method for "TukeyHSD"
> 
> Any suggestions?
> 
> Appreciate in advance~
> 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.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Repeated-Measure-ANOVA-Old-question-tp18726146p18726722.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] Urgent

2008-07-29 Thread Moshe Olshansky
Hi Yunlei,

Is your problem constrained or not?
If it is unconstrained and your matrix is not positive definite, the minimum is 
unbounded (unless you are extremely lucky and the matrix is positive 
semi-definite and the vector which multiplies the unknowns is exactly 
perpendicular to all the eigenvectors with 0 eigenvalues).
If the problem is constrained you may use regular optimization functions (like 
optim).

Regards,

Moshe.


--- On Tue, 22/7/08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

> From: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
> Subject: [R] Urgent
> To: r-help@r-project.org
> Received: Tuesday, 22 July, 2008, 6:12 PM
> Hi everyone
> 
> I try to use the solve.QP to solve the quadratic
> programming problem.
> But the Dmat in the funciotn is non-positive definite.
> 
> Can anyone tell me which R function can deal with the
> quadratic
> programming with non positive definite Dmat matrix ( in
> solve.QP)
> 
> I really appreaciated.
> 
> Yunlei Hu
> 
> ___
> 
> This e-mail may contain information that is confidential,
> privileged or otherwise protected from disclosure. If you
> are not an intended recipient of this e-mail, do not
> duplicate or redistribute it by any means. Please delete it
> and any attachments and notify the sender that you have
> received it in error. Unless specifically indicated, this
> e-mail is not an offer to buy or sell or a solicitation to
> buy or sell any securities, investment products or other
> financial product or service, an official confirmation of
> any transaction, or an official statement of Barclays. Any
> views or opinions presented are solely those of the author
> and do not necessarily represent those of Barclays. This
> e-mail is subject to terms available at the following link:
> www.barcap.com/emaildisclaimer. By messaging with Barclays
> you consent to the foregoing.  Barclays Capital is the
> investment banking division of Barclays Bank PLC, a company
> registered in England (number 1026167) with its registered
> offi!
>  ce at 1 Churchill Place, London, E14 5HP.  This email may
> relate to or be sent from other members of the Barclays
> Group.
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained,
> reproducible code.

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


<    1   2