Re: [R] £50 for help in my masters dissertation kalman filter forecasting

2011-09-19 Thread Paul Hiemstra
 On 09/17/2011 08:37 PM, nclfinance wrote:
> Dear R users,
>
> Just to clarify. I am not offering to pay someone to do my Dissertation.
> These 4-5 commands on Kalman Filter would be only a tiny part of my 10,000
> words dissertation. A part that even after trying for a few days, I am still
> stuck on. I am offering £50, just to say thanks.
>
> Regards
>
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/50-for-help-in-my-masters-dissertation-kalman-filter-forecasting-tp3820657p3820948.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.
...it would probably have been a better idea not to offer any money.
Nerds are not motivated by cash, but by a challenge :). Isn't there a
supervisor you can ask to help out? They are payed to supervise you
during your master's.

good luck,
Paul

-- 
Paul Hiemstra, Ph.D.
Global Climate Division
Royal Netherlands Meteorological Institute (KNMI)
Wilhelminalaan 10 | 3732 GK | De Bilt | Kamer B 3.39
P.O. Box 201 | 3730 AE | De Bilt
tel: +31 30 2206 494

http://intamap.geo.uu.nl/~paul
http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770

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


Re: [R] write.matrix row names vs sink vs capture.output

2011-09-19 Thread Paul Hiemstra
 What do you want with the row names? The help file for ?write.table
lists a row.names argument which can be set to FALSE.

regards,
Paul

On 09/06/2011 02:58 PM, Mark Ebbert wrote:
> Thank you for your help.
>
> The data is meant to be processed by a separate program that expects a simple 
> matrix with row and column names in ascii format. "write.matrix" does exactly 
> what I want except for the row names. It baffles me that this is not an 
> option…
>
>
> On Sep 6, 2011, at 8:22 AM, Paul Hiemstra wrote:
>
>> On 09/06/2011 06:24 AM, Mark Ebbert wrote:
>>> Dear R gurus,
>>>
>>> I am trying to write several large matrices (~ 1GB) to separate files. I 
>>> have learned that write.table is simply too slow for this task and was 
>>> attempting to use write.matrix, but write.matrix does not have the ability 
>>> to include row names in the output. Anyone know why that's the case? I've 
>>> seen a thread stating that write.matrix is the way to go for large prints 
>>> to files, but it doesn't do what I need it to. Since write.matrix wasn't 
>>> working I tried both sink and capture.output, but then the output is 
>>> printed to the file using the same 'width' restrictions as the general 
>>> "options(width=)" limit.
>>>
>>> Any ideas on how to print a large matrix with row names? I could write a 
>>> perl script to modify the files after the fact, but I shouldn't have to do 
>>> that.
>>>
>>> Thanks for your help!
>>>
>>> Mark T. W. Ebbert
>>> __
>>> R-help@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/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,
>>
>> What do you want with the data? If you want to store an R matrix on disk
>> for later use in R, take a look at ?save. If it is for use in another
>> programming language, I would write the matrix in binary format
>> (?writebin). This saves a lot of space and prevents any (significant)
>> rounding errors. It is probably also quite a bit faster. If you really
>> need some more metadata (such as rownames), I would add a second text
>> file which stores this information. Sort of a binary file plus a header,
>> which is a quite common format for storing data. Maybe you can even find
>> a standard binary format which you can use. But it is impossible to
>> comment on this because you did not provide information as to what you
>> want to do with the saved data.
>>
>> good luck!
>> Paul
>>
>> -- 
>> Paul Hiemstra, Ph.D.
>> Global Climate Division
>> Royal Netherlands Meteorological Institute (KNMI)
>> Wilhelminalaan 10 | 3732 GK | De Bilt | Kamer B 3.39
>> P.O. Box 201 | 3730 AE | De Bilt
>> tel: +31 30 2206 494
>>
>> http://intamap.geo.uu.nl/~paul
>> http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770
>>


-- 
Paul Hiemstra, Ph.D.
Global Climate Division
Royal Netherlands Meteorological Institute (KNMI)
Wilhelminalaan 10 | 3732 GK | De Bilt | Kamer B 3.39
P.O. Box 201 | 3730 AE | De Bilt
tel: +31 30 2206 494

http://intamap.geo.uu.nl/~paul
http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770

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


Re: [R] changing "label" in ggplot

2011-09-19 Thread Thomthom
Hi everyone!

Sorry for posting late but my problem is solved! I found a way to do what I
had to do ^^

But if you want to know what exactly it was I can update some of my code and
data... just let me know!

Thanks again for your replies!

Thomas

--
View this message in context: 
http://r.789695.n4.nabble.com/changing-label-in-ggplot-tp3816015p3823153.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 save row values from a matrix into one vector?

2011-09-19 Thread Chris82
Thanks a lot! Works fine!

--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-save-row-values-from-a-matrix-into-one-vector-tp3818415p3823320.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] Possible or not possible: serif axis labels with plotmath [but everything else sans serif]?

2011-09-19 Thread Hofert Jan Marius
Dear expeRts,

I it possible to have serif labels in the following plot?

x <- 1:10
y <- x
plot(x, y, type="b", xlab=expression(x[1]), ylab=expression(x[2]))

I know that one can use pdf(, family="serif"), but then also the axis tick 
marks 
are printed in serif font. Apart from the fact that it may not look nice, I'm 
just interested if one can have serif axis labels but everything else in sans 
serif
(default).

Cheers,

Marius
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Function for running a sign test

2011-09-19 Thread Paul Smith
Dear All,

Has R got a function to perform a sign test? I have done some
searching but with no luck.

Thanks in advance,

Paul

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


Re: [R] Replacing matching values by related values

2011-09-19 Thread Petr PIKAL
Hi

Works for me, how did you tested it?

v <- sample(letters[1:10], 17, replace=T)
d<-data.frame(letters[1:10], 1:10)
d[match(v,d[,1]),2]
 [1]  8  2  6  1  7 10  4 10 10  9 10  8  1  8  6  7  8

Regards
Petr



> Předmět
> 
> Re: [R] Replacing matching values by related values
> 
> Thanks Michael.
> I tested it and it works for numeric values, but not for the 'text' 
values
> that I am comparing, thus comparing "a" with "a","b", etc.
> Any advice how I can solve it?
> 
> Thanks!
> 
> 
> -Oorspronkelijk bericht-
> Van: R. Michael Weylandt  [
> mailto:michael.weyla...@gmail.com]
> Verzonden: zo 18-9-2011 2:27
> Aan: Janssen, K.J.M.
> CC: 
> Onderwerp: Re: [R] Replacing matching values by related values
> 
> Try playing with match(). Something like
> 
> d[match(v,d[,1]),2]
> 
> Should work (untested bc I'm writing from my phone though)
> 
> Michael Weylandt
> 
> On Sep 17, 2011, at 4:33 PM, "Janssen, K.J.M." 
 wrote:
> 
> > 
> > I am trying to replace values of a vector (consisting of 15 values) by 
a
> value that is related to a matching value in a dataset (consisting of 17 
rows).
> > Here's an example
> > The vector: 
> > v <- c(f,a,e,d,m,o,e,f,i,n,e,i,b,a,o)
> > 
> > The dataset's columns consist of the following values
> > d[,1] <- c(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q)
> > d[,2] <- 1:17
> > 
> > So I want to end up with a vector that consists of the values of the 
> second colomn, when the value of the vector matches the value of the 
first colomn.
> > Thus, I aim to end up with a vector with the following values
> > c(6,1,5,4,13,15,5,6,9,14,5,9,2,1,15)
> > 
> > Help is appreciated!
> > 
> > 
--
> > 
> > De informatie opgenomen in dit bericht kan vertrouwelijk zijn en is
> > uitsluitend bestemd voor de geadresseerde. Indien u dit bericht 
onterecht
> > ontvangt, wordt u verzocht de inhoud niet te gebruiken en de afzender 
direct
> > te informeren door het bericht te retourneren. Het Universitair 
Medisch
> > Centrum Utrecht is een publiekrechtelijke rechtspersoon in de zin van 
de W.H.W.
> > (Wet Hoger Onderwijs en Wetenschappelijk Onderzoek) en staat 
geregistreerd bij
> > de Kamer van Koophandel voor Midden-Nederland onder nr. 30244197.
> > 
> > Denk s.v.p aan het milieu voor u deze e-mail afdrukt.
> > 
> > 
--
> > 
> > This message may contain confidential information and 
is...{{dropped:12}}
> > 
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/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] Function for running a sign test

2011-09-19 Thread Sarah Goslee
Your search skills need some work: going to rseek.org and searching
for "sign test" turned up several functions. Without more information on
your problem, I have no idea which is better for you, or if they're all
good.

Although googling for R "sign test" returned both several functions and
a website stating authoritatively that "there is no R function for the
sign test," so its all a matter of your chosen authority, I suppose.

Sarah

On Mon, Sep 19, 2011 at 6:10 AM, Paul Smith  wrote:
> Dear All,
>
> Has R got a function to perform a sign test? I have done some
> searching but with no luck.
>
> Thanks in advance,
>
> Paul
>


-- 
Sarah Goslee
http://www.functionaldiversity.org

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


[R] text matching

2011-09-19 Thread SNV Krishna
Hi All,
 
I have a character vector by name tickers
 
> head(tickers,10)
 
V1
1  ADARSHPL.BO
2AGR.V
3  AGU
4   AGU.TO
5 AIMCO.BO
6  ALUFLUOR.BO
7AMZ.V
8  AVD
9  ANILPROD.BO
10ARIES.BO

I would like to extract all elements that has ".BO" in it. I tried 
 
> grep("\.BO",tickers)
Error: '\.' is an unrecognized escape in character string starting "\."
 
> grep(".BO",tickers)
[1] 1

Could any one please guide me on this. Many thanks for the help
 
Best Regards,
 
Krishna

[[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] automatic selection of object without loop

2011-09-19 Thread Marion Wenty
hi jim,

with the function "get" I could solve the problem using the following
commands:

q1 <- kinderrechte[,q0]
l1 <- get(paste(q0, "_l", sep = ""))

in this way i am getting the content of the object instead of the name of
the object.

thank you very much for your help!

marion


2011/9/16 jim holtman 

> You have to give more specifications as to what you want to do with
> the data that is being processed.  You have values being put into 'q1'
> and 'i1' that don't seem to be used in the loop.  Do you just want
> these values returned?  You can easily do it "without a loop" using
> lapply:
>
> result <- lapply(names(kinderrechte), function(.name){
># return a list with the result
>list(q1 = kinderrechte[, .name], i1 = get(paste(.name, "_l", sep = "")
> })
>
> So what is the problem that you are trying to solve?
>
> On Fri, Sep 16, 2011 at 8:34 AM, jim holtman  wrote:
> > did not see the "_l" so changes below:
> >
> > On Fri, Sep 16, 2011 at 8:33 AM, jim holtman  wrote:
> >> for (i in names(kinderrechte)){
> >>q1 <- kinderrechte[, i]
> >>i 1 <- get(paste(i, "_l", sep = ""))
> >> }
> >>
> >> On Fri, Sep 16, 2011 at 4:47 AM, Marion Wenty 
> wrote:
> >>> Hello,
> >>>
> >>> does anyone know the solution to this problem:
> >>>
> >>> I imported a dataframe from Spss into R and saved it as an object
> called
> >>> "kinderrechte".
> >>>
> >>> I have got the following command lines:
> >>>
> >>> q1 <- kinderrechte[,"q0007_0001"]
> >>> l1 <- q0007_0001_l
> >>>
> >>> now i would like to be able to change the column name in the first
> command
> >>> line (e.g. into q0007_0002) and to get R to automatically change
> >>> q0007_0001_l in the second command line into q0007_0002_l without using
> a
> >>> loop.
> >>>
> >>> Thank you in advance for your help!
> >>>
> >>> Marion
> >>>
> >>>[[alternative HTML version deleted]]
> >>>
> >>> __
> >>> R-help@r-project.org mailing list
> >>> https://stat.ethz.ch/mailman/listinfo/r-help
> >>> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> >>> and provide commented, minimal, self-contained, reproducible code.
> >>>
> >>
> >>
> >>
> >> --
> >> Jim Holtman
> >> Data Munger Guru
> >>
> >> What is the problem that you are trying to solve?
> >>
> >
> >
> >
> > --
> > Jim Holtman
> > Data Munger Guru
> >
> > What is the problem that you are trying to solve?
> >
>
>
>
> --
> Jim Holtman
> Data Munger Guru
>
> What is the problem that you are trying to solve?
>

[[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] Function for running a sign test

2011-09-19 Thread Paul Smith
Thanks, Sarah. I am simply astonished at your brilliance. Please,
search RSeek and check whether you can find a function to perform an
one-sample median test via a sign test; I could not, but I am not a
genius as you are.

Paul


On Mon, Sep 19, 2011 at 11:20 AM, Sarah Goslee  wrote:
> Your search skills need some work: going to rseek.org and searching
> for "sign test" turned up several functions. Without more information on
> your problem, I have no idea which is better for you, or if they're all
> good.
>
> Although googling for R "sign test" returned both several functions and
> a website stating authoritatively that "there is no R function for the
> sign test," so its all a matter of your chosen authority, I suppose.
>
> Sarah
>
> On Mon, Sep 19, 2011 at 6:10 AM, Paul Smith  wrote:
>> Dear All,
>>
>> Has R got a function to perform a sign test? I have done some
>> searching but with no luck.
>>
>> Thanks in advance,
>>
>> Paul
>>
>
>
> --
> Sarah Goslee
> http://www.functionaldiversity.org
>

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


Re: [R] text matching

2011-09-19 Thread Sarah Goslee
Hi,

On Mon, Sep 19, 2011 at 6:15 AM, SNV Krishna  wrote:
> Hi All,
>
> I have a character vector by name tickers
>
>> head(tickers,10)
>
>            V1
> 1  ADARSHPL.BO
> 2        AGR.V
> 3          AGU
> 4       AGU.TO
> 5     AIMCO.BO
> 6  ALUFLUOR.BO
> 7        AMZ.V
> 8          AVD
> 9  ANILPROD.BO
> 10    ARIES.BO
>
> I would like to extract all elements that has ".BO" in it. I tried
>
>> grep("\.BO",tickers)
> Error: '\.' is an unrecognized escape in character string starting "\."

You need instead:
> tickers <- c("A.BO", "BOB", "C.BO")
> grep("\\.BO", tickers)
[1] 1 3
>
> tickers[grep("\\.BO", tickers)]
[1] "A.BO" "C.BO"


>> grep(".BO",tickers)
> [1] 1

That's odd; it should have returned many more matches. You may need to
check the format of your data.

> Could any one please guide me on this. Many thanks for the help
>
> Best Regards,
>
> Krishna
>


-- 
Sarah Goslee
http://www.functionaldiversity.org

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


[R] R as well as Rscript just hangs!

2011-09-19 Thread Rainer M Krug
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi

I want to use R on a cluster, and up to updates, it was working fine.
Now it works on most nodes, but on several nodes I have a problem,
that R as well as Rscript just hangs - no error message. So the
following commands result in a hung R session, which I can not leave
vie Ctrl-c:

Rscript -e "4"
or any other command

R

where Rscript --version
works

I checked ldd Rscript, and the libraries there are all the same - but
I obviously cant check

ldd R

This works on some nodes, and on others it does not.

Do you have any ideas what might cause this behaviour?

The OS is OpenSuSe 64 bit, R 13.1 is installed from source

Any help appreciated where I can guide the admin to (as he has no
experience with R at all),

Cheers,

Rainer

- -- 
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation
Biology, UCT), Dipl. Phys. (Germany)

Centre of Excellence for Invasion Biology
Stellenbosch University
South Africa

Tel :   +33 - (0)9 53 10 27 44
Cell:   +33 - (0)6 85 62 59 98
Fax :   +33 - (0)9 58 10 27 44

Fax (D):+49 - (0)3 21 21 25 22 44

email:  rai...@krugs.de

Skype:  RMkrug
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk53I98ACgkQoYgNqgF2egoybACfVLL11IAbnicNpU9HHsAior+4
8GwAnRpaXCW0Uj5UsY+DNtCRIBis8hxk
=BCnV
-END PGP SIGNATURE-

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


Re: [R] Function for running a sign test

2011-09-19 Thread Sarah Goslee
Dear Paul,

On Mon, Sep 19, 2011 at 6:55 AM, Paul Smith  wrote:
> Thanks, Sarah. I am simply astonished at your brilliance. Please,
> search RSeek and check whether you can find a function to perform an
> one-sample median test via a sign test; I could not, but I am not a
> genius as you are.
>

Please reread your original request, included below for your convenience.
You asked about a sign test, with no explanation of what you meant.

My reply: that searching turned up lots of sign test options, but that without
more information we couldn't advise you as to whether any were suitable.

I'm flattered that you feel my ability to ask for more information is
brilliant, but I practice a lot on this list because many people ask
poorly-formed questions.

Now that we know you want a "one sample median sign test", your
question may be answerable.

For instance, does this help:
http://www.r-tutor.com/elementary-statistics/non-parametric-methods/sign-test

Or this?
http://rgm2.lab.nig.ac.jp/RGM2/func.php?rd_id=BSDA:SIGN.test

Sarah

>
> On Mon, Sep 19, 2011 at 11:20 AM, Sarah Goslee  wrote:
>> Your search skills need some work: going to rseek.org and searching
>> for "sign test" turned up several functions. Without more information on
>> your problem, I have no idea which is better for you, or if they're all
>> good.
>>
>> Although googling for R "sign test" returned both several functions and
>> a website stating authoritatively that "there is no R function for the
>> sign test," so its all a matter of your chosen authority, I suppose.
>>
>> Sarah
>>
>> On Mon, Sep 19, 2011 at 6:10 AM, Paul Smith  wrote:
>>> Dear All,
>>>
>>> Has R got a function to perform a sign test? I have done some
>>> searching but with no luck.
>>>
>>> Thanks in advance,
>>>
>>> Paul
>>>
>>
>>

-- 
Sarah Goslee
http://www.functionaldiversity.org

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


Re: [R] Function for running a sign test

2011-09-19 Thread ONKELINX, Thierry
You did not search hard enough.

RSiteSearch("sign test")

or

library(sos)
findFn("sign test")

Both gives you plenty of possible functions.

> -Oorspronkelijk bericht-
> Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> Namens Paul Smith
> Verzonden: maandag 19 september 2011 12:11
> Aan: R-help
> Onderwerp: [R] Function for running a sign test
> 
> Dear All,
> 
> Has R got a function to perform a sign test? I have done some searching but
> with no luck.
> 
> Thanks in advance,
> 
> Paul
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] switching off commands within character vector

2011-09-19 Thread Marion Wenty
Hello,

could someone help me with this problem?:

I would like to create a latex-script inside of a character vector in order
to being able to compilate it within latex in the end.

if i try the following commands:

l1 <- "Hello world"
latexscript <- paste("\c",l1,"\c")

... I get an error message. I think the problem is that r sees \c as a
command.

How can I get

"\c Hello world \c"

as a result without getting the error message?

Thank you in advance for your help.

Marion

[[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] switching off commands within character vector

2011-09-19 Thread Duncan Murdoch

On 11-09-19 7:30 AM, Marion Wenty wrote:

Hello,

could someone help me with this problem?:

I would like to create a latex-script inside of a character vector in order
to being able to compilate it within latex in the end.

if i try the following commands:

l1<- "Hello world"
latexscript<- paste("\c",l1,"\c")

... I get an error message. I think the problem is that r sees \c as a
command.

How can I get

"\c Hello world \c"

as a result without getting the error message?


Here's the long answer:

R uses \ as an "escape character", which is different from the way LaTeX 
uses it.  The string "\n" contains a single character (a newline 
character.  When you say "\c", the parser thinks you are asking for a 
single character which is written as \c, but there isn't one, so you get 
the error message.


To put the characters \c into a string, you need to escape the 
backslash, i.e. use "\\c".  That's a two character string.  It will 
print as "\\c" using print(), but if you use cat() you will see the 
actual characters \c.


The short answer is:

latexscript <- paste("\\c", l1, "\\c")
cat(latexscript, "\n")

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] Courses in R

2011-09-19 Thread Marion Wenty
thank you for the adresses, i will have a look at the web-pages.
marion

2011/9/15 Mark Sharp 

> Statistics.com has several.
> Mark
>
>
> On 9/15/11 3:46 AM, "Marion Wenty"  wrote:
>
> >Hello,
> >
> >I have a question concerning courses in R in *Vienna, Austria*.
> >
> >Does anyone know where courses in R are offered, that you can do after
> >having attended a course for the basics?
> >
> >Thanks in advance for your help.
> >
> >Marion
> >
> >   [[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.
>
>
> Effective February 1, 2011, the name of Southwest Foundation for Biomedical
> Research changed to the Texas Biomedical Research Institute to better
> reflect our organization and its mission.  There is no change in control,
> tax exempt status, tax ID, or ownership.
>
> Texas Biomedical Research Institute
> Enhancing Lives Through Discovery
>

[[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] Possible or not possible: serif axis labels with plotmath [but everything else sans serif]?

2011-09-19 Thread Eik Vettorazzi
Hi Jan Marius,
using the tikzDevice-package, nearly everything is possible (at least,
all what can be done in LaTeX).

cheers

Am 19.09.2011 11:58, schrieb Hofert Jan Marius:
> Dear expeRts,
> 
> I it possible to have serif labels in the following plot?
> 
> x <- 1:10
> y <- x
> plot(x, y, type="b", xlab=expression(x[1]), ylab=expression(x[2]))
> 
> I know that one can use pdf(, family="serif"), but then also the axis tick 
> marks 
> are printed in serif font. Apart from the fact that it may not look nice, I'm 
> just interested if one can have serif axis labels but everything else in sans 
> serif
> (default).
> 
> Cheers,
> 
> Marius
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.


-- 
Eik Vettorazzi
Institut für Medizinische Biometrie und Epidemiologie
Universitätsklinikum Hamburg-Eppendorf

Martinistr. 52
20246 Hamburg

T ++49/40/7410-58243
F ++49/40/7410-57790

--
Pflichtangaben gemäß Gesetz über elektronische Handelsregister und 
Genossenschaftsregister sowie das Unternehmensregister (EHUG):

Universitätsklinikum Hamburg-Eppendorf; Körperschaft des öffentlichen Rechts; 
Gerichtsstand: Hamburg

Vorstandsmitglieder: Prof. Dr. Jörg F. Debatin (Vorsitzender), Dr. Alexander 
Kirstein, Joachim Prölß, Prof. Dr. Dr. Uwe Koch-Gromus 

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


Re: [R] automatic selection of object without loop

2011-09-19 Thread R. Michael Weylandt
What exactly are you looking to do? If it's just to get the name, drop the
get() call and just put:

q1 <- kinderrechte[,q0]
l1 <- paste(q0,"_l",sep="")

Michael Weylandt

On Mon, Sep 19, 2011 at 6:55 AM, Marion Wenty wrote:

> hi jim,
>
> with the function "get" I could solve the problem using the following
> commands:
>
> q1 <- kinderrechte[,q0]
> l1 <- get(paste(q0, "_l", sep = ""))
>
> in this way i am getting the content of the object instead of the name of
> the object.
>
> thank you very much for your help!
>
> marion
>
>
> 2011/9/16 jim holtman 
>
> > You have to give more specifications as to what you want to do with
> > the data that is being processed.  You have values being put into 'q1'
> > and 'i1' that don't seem to be used in the loop.  Do you just want
> > these values returned?  You can easily do it "without a loop" using
> > lapply:
> >
> > result <- lapply(names(kinderrechte), function(.name){
> ># return a list with the result
> >list(q1 = kinderrechte[, .name], i1 = get(paste(.name, "_l", sep = "")
> > })
> >
> > So what is the problem that you are trying to solve?
> >
> > On Fri, Sep 16, 2011 at 8:34 AM, jim holtman  wrote:
> > > did not see the "_l" so changes below:
> > >
> > > On Fri, Sep 16, 2011 at 8:33 AM, jim holtman 
> wrote:
> > >> for (i in names(kinderrechte)){
> > >>q1 <- kinderrechte[, i]
> > >>i 1 <- get(paste(i, "_l", sep = ""))
> > >> }
> > >>
> > >> On Fri, Sep 16, 2011 at 4:47 AM, Marion Wenty  >
> > wrote:
> > >>> Hello,
> > >>>
> > >>> does anyone know the solution to this problem:
> > >>>
> > >>> I imported a dataframe from Spss into R and saved it as an object
> > called
> > >>> "kinderrechte".
> > >>>
> > >>> I have got the following command lines:
> > >>>
> > >>> q1 <- kinderrechte[,"q0007_0001"]
> > >>> l1 <- q0007_0001_l
> > >>>
> > >>> now i would like to be able to change the column name in the first
> > command
> > >>> line (e.g. into q0007_0002) and to get R to automatically change
> > >>> q0007_0001_l in the second command line into q0007_0002_l without
> using
> > a
> > >>> loop.
> > >>>
> > >>> Thank you in advance for your help!
> > >>>
> > >>> Marion
> > >>>
> > >>>[[alternative HTML version deleted]]
> > >>>
> > >>> __
> > >>> R-help@r-project.org mailing list
> > >>> https://stat.ethz.ch/mailman/listinfo/r-help
> > >>> PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > >>> and provide commented, minimal, self-contained, reproducible code.
> > >>>
> > >>
> > >>
> > >>
> > >> --
> > >> Jim Holtman
> > >> Data Munger Guru
> > >>
> > >> What is the problem that you are trying to solve?
> > >>
> > >
> > >
> > >
> > > --
> > > Jim Holtman
> > > Data Munger Guru
> > >
> > > What is the problem that you are trying to solve?
> > >
> >
> >
> >
> > --
> > Jim Holtman
> > Data Munger Guru
> >
> > What is the problem that you are trying to solve?
> >
>
>[[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] troubles with a for loop

2011-09-19 Thread R. Michael Weylandt
Alas, speaking before I check the optional argumentsc'est la vie.

MW

On Sun, Sep 18, 2011 at 3:00 PM, Jorge I Velez wrote:

> Why wouldn't?  It does for me ;-)
>
> curve(sin(x), 0, 10, col = 4, lwd = 2, las = 1)
> curve(cos(x), 0, 10, add = TRUE)
>
> Best,
> Jorge
>
>
> On Sun, Sep 18, 2011 at 2:07 PM, R. Michael Weylandt <> wrote:
>
>>  Furthermore, if you want to add lines to a plot, I'd advise against the
>> curve() function, rather use lines() to add lines (or points() for, well,
>> points) on a plot.
>>
>> E.g.,
>>
>> x <- seq(0,10,by=0.025)
>> y <- sin(x)
>> y2 <- cos(x)
>>
>> plot(x,y,type="l",col="red4",lwd=3)
>> lines(x,y2)
>>
>> curve() wouldn't work for this
>>
>> Michael
>>
>> On Sun, Sep 18, 2011 at 1:23 PM, Patrick Burns <>wrote:
>>
>>
>> > Sarah has told you how to get from where
>> > you are to where you want to be.
>> >
>> > However, it is easier to start somewhere
>> > else.  The more "R" way to do what you are
>> > doing is to use a list to put the results
>> > of your regressions into.  It is then very
>> > easy to use that list, and it is easier to
>> > keep track of.
>> >
>> > The two documents mentioned in my signature
>> > may help you get up and running in R.  Since
>> > you are coming from Stata, you should also
>> > look at http://r4stats.com
>> >
>> >
>> > On 18/09/2011 17:05, Francesco Sarracino wrote:
>> >
>> >> Dear all,
>> >>
>> >> I am a stata user and I am moving my first steps in R.
>> >> I am dealing with a silly issue concerning looping over variables. I
>> read
>> >> previous posts on similar topics in the R help archive, but I did not
>> find
>> >> a
>> >> solution.
>> >> Here is my case:
>> >>
>> >> I run a simple bivariate linear regression saving the output in objects
>> >> called: pd.memb.0, pd.memb.1, pd.memb.2, pd.memb.3
>> >>
>> >> pd.memb.0<- lm(E.fs.memb ~ M.fs.memb, data, subset = (tag2 == 1))
>> >> pd.memb.1<- lm(E.fs.memb ~ M.fs.memb, data, subset = (M.fs.memb<=
>> >> quantile(M.fs.memb, .25)&  tag2 == 1))
>> >> pd.memb.2<- lm(E.fs.memb ~ M.fs.memb, data, subset = (M.fs.memb>
>> >> quantile(M.fs.memb, .25)&  M.fs.memb<= quantile(M.fs.memb, .75)&  tag2
>> ==
>> >> 1))
>> >> pd.memb.3<- lm(E.fs.memb ~ M.fs.memb, data, subset = (M.fs.memb>
>> >> quantile(M.fs.memb, .75)&  tag2 == 1))
>> >>
>> >> Subsequently, I wish to plot my data superimposing a different line for
>> >> each
>> >> regression model. Here I am trying to apply my loop. Looking at the
>> info I
>> >> found around, the following code sound to me as correct, but I am
>> wrong.
>> >>
>> >> plot(M.fs.memb , E.fs.memb)
>> >> for(i =  1:3){
>> >>   curve(coef(pd.memb.i)[1] + coef(pd.memb.i)[2]*x, add = T, cex = 100,
>> col
>> >> =
>> >> "red")
>> >> }
>> >>
>> >> The plot is plotted, but the curves are not printed and  I get the
>> >> following
>> >> error message:
>> >>
>> >>
>> >> Error in coef(pd.memb.i) :
>> >>   error in evaluating the argument 'object' in selecting a method for
>> >> function 'coef'>  }Error: unexpected '}' in "}"
>> >>
>> >>
>> >> What am I doing wrong?
>> >> Thanks a lot for your help,
>> >> f.
>> >>
>> >>[[alternative HTML version deleted]]
>> >>
>> >> __**
>> >> R-help@r-project.org mailing list
>> >> https://stat.ethz.ch/mailman/**listinfo/r-help<
>> https://stat.ethz.ch/mailman/listinfo/r-help>
>>
>> >> PLEASE do read the posting guide http://www.R-project.org/**
>> >> posting-guide.html 
>>
>> >> and provide commented, minimal, self-contained, reproducible code.
>> >>
>> >>
>> > --
>> > Patrick Burns
>> > pbu...@pburns.seanet.com
>> > twitter: @portfolioprobe
>> > http://www.portfolioprobe.com/**blog <
>> http://www.portfolioprobe.com/blog>
>>
>> > http://www.burns-stat.com
>> > (home of 'Some hints for the R beginner'
>> > and 'The R Inferno')
>> >
>> >
>> > __**
>> > R-help@r-project.org mailing list
>> > https://stat.ethz.ch/mailman/**listinfo/r-help<
>> https://stat.ethz.ch/mailman/listinfo/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.
>>
>
>

[[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] Could R run Cox proportional hazard model with multiple failure time data

2011-09-19 Thread Terry Therneau
--- begin included message --
If my survival data includes more than two outcomes, for example death,
disability and censored. Does R have corresponding packages or programs
to run Cox proportional hazard model with multiple failure time data.
--- end inclusion --

The survival package (R and SPlus) was the very first package that
supported this feature, other statistical packages copied it.  See
Chapter 8 of Therneau and Grambsch for a long discussion of issues; far
more than can be fit here.

Terry T.

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


[R] R 2.14.0 scheduled for October 31, 2.13.2 for September 30

2011-09-19 Thread Peter Dalgaard
This is to announce that we plan to release R version 2.14.0 on Monday,
October 31, 2011. 

As a new feature, we will precede the run-in sequence for 2.14.0 with a final 
release of the 2.13 series, 2.13.2. No further patching of this series is 
intended. 

Those directly involved should review the generic schedule at
http://developer.r-project.org/release-checklist.html

The source tarballs will be made available daily (barring build
troubles) via

http://cran.r-project.org/src/base-prerelease/

For the R Core Team
Peter Dalgaard

-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@gmail.com

___
r-annou...@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-announce

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

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


Re: [R] Possible or not possible: serif axis labels with plotmath [but everything else sans serif]?

2011-09-19 Thread Hofert Jan Marius
Dear Eik,

although possible in this case, tikzDevice is certainly not a general solution 
to all kinds of problems :-) I used it for quite some time before I gave up: I 
had a simple bar plot, the bars being black. This already caused errors like 
"TeX capacity exceeded" ... and I obtained these a lot. In fact, enlarging the 
TeX capacity (not trivial but possible) did not solve these issues. That's why 
I gave up on this package [although, clearly, the idea of full TeX support is 
totally appealing -- that's why I looked at the package in the first place].

Cheers,

Marius

On 2011-09-19, at 14:38 , Eik Vettorazzi wrote:

> Hi Jan Marius,
> using the tikzDevice-package, nearly everything is possible (at least,
> all what can be done in LaTeX).
> 
> cheers
> 
> Am 19.09.2011 11:58, schrieb Hofert Jan Marius:
>> Dear expeRts,
>> 
>> I it possible to have serif labels in the following plot?
>> 
>> x <- 1:10
>> y <- x
>> plot(x, y, type="b", xlab=expression(x[1]), ylab=expression(x[2]))
>> 
>> I know that one can use pdf(, family="serif"), but then also the axis tick 
>> marks 
>> are printed in serif font. Apart from the fact that it may not look nice, 
>> I'm 
>> just interested if one can have serif axis labels but everything else in 
>> sans serif
>> (default).
>> 
>> Cheers,
>> 
>> Marius
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
> 
> 
> -- 
> Eik Vettorazzi
> Institut für Medizinische Biometrie und Epidemiologie
> Universitätsklinikum Hamburg-Eppendorf
> 
> Martinistr. 52
> 20246 Hamburg
> 
> T ++49/40/7410-58243
> F ++49/40/7410-57790
> 
> --
> Pflichtangaben gemäß Gesetz über elektronische Handelsregister und 
> Genossenschaftsregister sowie das Unternehmensregister (EHUG):
> 
> Universitätsklinikum Hamburg-Eppendorf; Körperschaft des öffentlichen Rechts; 
> Gerichtsstand: Hamburg
> 
> Vorstandsmitglieder: Prof. Dr. Jörg F. Debatin (Vorsitzender), Dr. Alexander 
> Kirstein, Joachim Prölß, Prof. Dr. Dr. Uwe Koch-Gromus 
> 

ETH Zurich
Dr. Marius Hofert
RiskLab, Department of Mathematics
HG E 65.2
Rämistrasse 101
8092 Zurich
Switzerland

Phone +41 44 632 2423
marius.hof...@math.ethz.ch
http://www.math.ethz.ch/~hofertj

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


Re: [R] Linear regression interaction terms

2011-09-19 Thread Ben Bolker
Andrey A  gmail.com> writes:

> 
> Hello I performed a linear regression, my equation is Y = âo+ â1A + â2B +
> â3AB.
> Is there a way to separate interaction terms, say â3AB and plot it against a
> certain variable?
> Thanks, Andrew

  Not quite sure what you mean here.  Possibly something like

L1 <- lm(y~A*B,data=mydata)
p <- predict(L1,type="terms",terms="A:B")

 etc

?

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


Re: [R] Possible or not possible: serif axis labels with plotmath [but everything else sans serif]?

2011-09-19 Thread Eik Vettorazzi
Hi Jan Marius,
I had a lot of positive experience with tkiz, but yes, handling large
datasets can push it to the limits.

Anyway, in your case, isn't it as simple as

plot(x, y, type="b",xlab="",ylab="")
title(xlab=expression(x[1]), ylab=expression(x[2]),family="serif")

cheers

Am 19.09.2011 14:51, schrieb Hofert Jan Marius:
> Dear Eik,
> 
> although possible in this case, tikzDevice is certainly not a general 
> solution to all kinds of problems :-) I used it for quite some time before I 
> gave up: I had a simple bar plot, the bars being black. This already caused 
> errors like "TeX capacity exceeded" ... and I obtained these a lot. In fact, 
> enlarging the TeX capacity (not trivial but possible) did not solve these 
> issues. That's why I gave up on this package [although, clearly, the idea of 
> full TeX support is totally appealing -- that's why I looked at the package 
> in the first place].
> 
> Cheers,
> 
> Marius
> 
> On 2011-09-19, at 14:38 , Eik Vettorazzi wrote:
> 
>> Hi Jan Marius,
>> using the tikzDevice-package, nearly everything is possible (at least,
>> all what can be done in LaTeX).
>>
>> cheers
>>
>> Am 19.09.2011 11:58, schrieb Hofert Jan Marius:
>>> Dear expeRts,
>>>
>>> I it possible to have serif labels in the following plot?
>>>
>>> x <- 1:10
>>> y <- x
>>> plot(x, y, type="b", xlab=expression(x[1]), ylab=expression(x[2]))
>>>
>>> I know that one can use pdf(, family="serif"), but then also the axis tick 
>>> marks 
>>> are printed in serif font. Apart from the fact that it may not look nice, 
>>> I'm 
>>> just interested if one can have serif axis labels but everything else in 
>>> sans serif
>>> (default).
>>>
>>> Cheers,
>>>
>>> Marius
>>> __
>>> R-help@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
>> -- 
>> Eik Vettorazzi
>> Institut für Medizinische Biometrie und Epidemiologie
>> Universitätsklinikum Hamburg-Eppendorf
>>
>> Martinistr. 52
>> 20246 Hamburg
>>
>> T ++49/40/7410-58243
>> F ++49/40/7410-57790
>>
>> --
>> Pflichtangaben gemäß Gesetz über elektronische Handelsregister und 
>> Genossenschaftsregister sowie das Unternehmensregister (EHUG):
>>
>> Universitätsklinikum Hamburg-Eppendorf; Körperschaft des öffentlichen 
>> Rechts; Gerichtsstand: Hamburg
>>
>> Vorstandsmitglieder: Prof. Dr. Jörg F. Debatin (Vorsitzender), Dr. Alexander 
>> Kirstein, Joachim Prölß, Prof. Dr. Dr. Uwe Koch-Gromus 
>>
> 
> ETH Zurich
> Dr. Marius Hofert
> RiskLab, Department of Mathematics
> HG E 65.2
> Rämistrasse 101
> 8092 Zurich
> Switzerland
> 
> Phone +41 44 632 2423
> marius.hof...@math.ethz.ch
> http://www.math.ethz.ch/~hofertj
> 


-- 
Eik Vettorazzi

Department of Medical Biometry and Epidemiology
University Medical Center Hamburg-Eppendorf

Martinistr. 52
20246 Hamburg

T ++49/40/7410-58243
F ++49/40/7410-57790

--
Pflichtangaben gemäß Gesetz über elektronische Handelsregister und 
Genossenschaftsregister sowie das Unternehmensregister (EHUG):

Universitätsklinikum Hamburg-Eppendorf; Körperschaft des öffentlichen Rechts; 
Gerichtsstand: Hamburg

Vorstandsmitglieder: Prof. Dr. Jörg F. Debatin (Vorsitzender), Dr. Alexander 
Kirstein, Joachim Prölß, Prof. Dr. Dr. Uwe Koch-Gromus 

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] pasting elements of one character vector together

2011-09-19 Thread Marion Wenty
hello,

i am familiar with the paste command with which i can paste for exaple:

object <- "Hello"
paste(object,"World")

now i would like to be able to paste all the elements of the same vector
together e.g:

object <- c("Hello","World")

getting as a result also:

"Hello World".

Does anyone know the solution to this problem?

Thank you very much in advance.

Marion

[[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] pasting elements of one character vector together

2011-09-19 Thread R. Michael Weylandt
paste(...,collapse=" ")

Michael Weylandt

On Mon, Sep 19, 2011 at 9:58 AM, Marion Wenty wrote:

> hello,
>
> i am familiar with the paste command with which i can paste for exaple:
>
> object <- "Hello"
> paste(object,"World")
>
> now i would like to be able to paste all the elements of the same vector
> together e.g:
>
> object <- c("Hello","World")
>
> getting as a result also:
>
> "Hello World".
>
> Does anyone know the solution to this problem?
>
> Thank you very much in advance.
>
> Marion
>
>[[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] pasting elements of one character vector together

2011-09-19 Thread Dimitris Rizopoulos

Try this:

object <- c("Hello", "World")
paste(object, collapse = " ")


I hope it helps.

Best,
Dimitris



On 9/19/2011 3:58 PM, Marion Wenty wrote:

hello,

i am familiar with the paste command with which i can paste for exaple:

object<- "Hello"
paste(object,"World")

now i would like to be able to paste all the elements of the same vector
together e.g:

object<- c("Hello","World")

getting as a result also:

"Hello World".

Does anyone know the solution to this problem?

Thank you very much in advance.

Marion

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



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

Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014
Web: http://www.erasmusmc.nl/biostatistiek/

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

2011-09-19 Thread arunkumar1111
Hi

I have a variable str = " X", "Y" and values ("0","12")

 i want to set value for X =0 and Y =12 and use inside the program.
how to do this
Please anybody help me. 

--
View this message in context: 
http://r.789695.n4.nabble.com/Setting-the-Values-tp3823388p3823388.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] joint histogram for image comparison

2011-09-19 Thread aurelien
Dear all, 
I need to compute a joint histogram to compare 2 images (with image()
function). I wonder if there is any function available in R to do this
properly?
Thanks for your help,
Aurrélien

--
View this message in context: 
http://r.789695.n4.nabble.com/joint-histogram-for-image-comparison-tp3823800p3823800.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] text matching

2011-09-19 Thread David Winsemius


On Sep 19, 2011, at 7:05 AM, Sarah Goslee wrote:


Hi,

On Mon, Sep 19, 2011 at 6:15 AM, SNV Krishna   
wrote:

Hi All,

I have a character vector by name tickers


head(tickers,10)


   V1
1  ADARSHPL.BO
2AGR.V
3  AGU
4   AGU.TO
5 AIMCO.BO
6  ALUFLUOR.BO
7AMZ.V
8  AVD
9  ANILPROD.BO
10ARIES.BO

I would like to extract all elements that has ".BO" in it. I tried


grep("\.BO",tickers)
Error: '\.' is an unrecognized escape in character string starting  
"\."


You need instead:

tickers <- c("A.BO", "BOB", "C.BO")
grep("\\.BO", tickers)

[1] 1 3


tickers[grep("\\.BO", tickers)]

[1] "A.BO" "C.BO"



grep(".BO",tickers)

[1] 1


That's odd; it should have returned many more matches. You may need to
check the format of your data.


There are two NOT-oddities at work here. Periods and other special  
characters need to be doubly escaped when used as literals in search   
patterns,  and the vector that needs to be searched is not "tickers"  
but rather "tickers$V1".


That result is because there is only one element in the list named  
"tickers" and grep finds that it does have an instance that matches  
the pattern. (Despite that fact that it is not searching what the OP  
thought he was searching for but rather a more general pattern.)


--
David.





Could any one please guide me on this. Many thanks for the help

Best Regards,

Krishna




--
Sarah Goslee
http://www.functionaldiversity.org

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


David Winsemius, MD
West Hartford, CT

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


Re: [R] Setting the Values

2011-09-19 Thread R. Michael Weylandt
Take a look at assign(), but you may want to add some code to make sure
variables with those names don't already exist.

Something like:

str = c("X","Y")
val = c("0","12")
mapply(function(name,value){assign(name,as.double(value),envir=.GlobalEnv)},
str,val)

Hope this helps,

Michael Weylandt

On Mon, Sep 19, 2011 at 5:20 AM, arunkumar  wrote:

> Hi
>
> I have a variable str = " X", "Y" and values ("0","12")
>
>  i want to set value for X =0 and Y =12 and use inside the program.
> how to do this
> Please anybody help me.
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Setting-the-Values-tp3823388p3823388.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] Setting the Values

2011-09-19 Thread Jean-Christophe BOUËTTÉ
Hi,
X = 0
Y =12
works for me.
If you judge my answer as too vague, please reread your original post
and kindly post the code you used to define the objects you are
mentioning.
Thanks,
JC

2011/9/19 arunkumar :
> Hi
>
> I have a variable str = " X", "Y" and values ("0","12")
>
>  i want to set value for X =0 and Y =12 and use inside the program.
> how to do this
> Please anybody help me.
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/Setting-the-Values-tp3823388p3823388.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] pasting elements of one character vector together

2011-09-19 Thread Marion Wenty
hello michael and dimitris,
yes, this was it!
now i understand this collapse-argument.
thank you very much.
marion

2011/9/19 Dimitris Rizopoulos 

> Try this:
>
> object <- c("Hello", "World")
> paste(object, collapse = " ")
>
>
> I hope it helps.
>
> Best,
> Dimitris
>
>
>
>
> On 9/19/2011 3:58 PM, Marion Wenty wrote:
>
>> hello,
>>
>> i am familiar with the paste command with which i can paste for exaple:
>>
>> object<- "Hello"
>> paste(object,"World")
>>
>> now i would like to be able to paste all the elements of the same vector
>> together e.g:
>>
>> object<- c("Hello","World")
>>
>> getting as a result also:
>>
>> "Hello World".
>>
>> Does anyone know the solution to this problem?
>>
>> Thank you very much in advance.
>>
>> Marion
>>
>>[[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.
>>
>>
> --
> Dimitris Rizopoulos
> Assistant Professor
> Department of Biostatistics
> Erasmus University Medical Center
>
> Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
> Tel: +31/(0)10/7043478
> Fax: +31/(0)10/7043014
> Web: 
> http://www.erasmusmc.nl/**biostatistiek/
>

[[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] openPage in the {hwriter} package - reverses Hebrew text

2011-09-19 Thread Tal Galili
Hello dear R help members,

I am playing with the hwriter  package
in the purpose of creating HTML output in the Hebrew language.
I ran into a basic problem:
When I use the openPage command (from the {hwriter} package) the Hebrew text
I try to add to the HTML file is reversed.

# Here is a basic example of the problem:
library("hwriter")
p = openPage('test.html', dirname=getwd(),
charset = "iso8859-8", lang = "he")
txt <- "א ב ג ד ה ו ז ח"
cat(txt, file = p)
closePage(p)


# I know that the problem is not caused by cat since using:
cat(txt, file = "temp.txt")
# Will output the Hebrew text in the correct order

Thank you for any help or suggestion,
Tal


Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--

[[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] write.matrix row names vs sink vs capture.output

2011-09-19 Thread Paul Hiemstra
 Sorry, misread :). Consider my remark as retracted...however

It looks like it would be relatively simple to rewrite write.matrix a
little bit to include rownames...the cat statement in the while loop of
write.matrix could be changed to include a row name. To get he source
code of write.matrix:

library(MASS)
write.matrix
# without the ()!!

hope this helps more than my previous (useless) comment,
Paul

On 09/19/2011 02:37 PM, Mark Ebbert wrote:
> I'm afraid I don't understand your response. As I mentioned in the original 
> question, write.table is way too slow and I need the row names in the file, 
> so setting row.names to FALSE wouldn't accomplish my goal, anyway. And 
> write.matrix doesn't have *any* options to include row names, which baffles 
> me since row names are part of a matrix object. 
>
> I need the row names because an external program, which requires row names, 
> will be processing the files. I wound up using perl to fix the resultant file 
> from write.matrix, but I would love to hear an explanation as to why 
> write.matrix doesn't have an option to include row names, if you know. 
>
> Anyway, thanks for taking the time to respond. 
>
> On Sep 19, 2011, at 1:49 AM, "Paul Hiemstra"  wrote:
>
>> What do you want with the row names? The help file for ?write.table
>> lists a row.names argument which can be set to FALSE.
>>
>> regards,
>> Paul
>>
>> On 09/06/2011 02:58 PM, Mark Ebbert wrote:
>>> Thank you for your help.
>>>
>>> The data is meant to be processed by a separate program that expects a 
>>> simple matrix with row and column names in ascii format. "write.matrix" 
>>> does exactly what I want except for the row names. It baffles me that this 
>>> is not an option…
>>>
>>>
>>> On Sep 6, 2011, at 8:22 AM, Paul Hiemstra wrote:
>>>
 On 09/06/2011 06:24 AM, Mark Ebbert wrote:
> Dear R gurus,
>
> I am trying to write several large matrices (~ 1GB) to separate files. I 
> have learned that write.table is simply too slow for this task and was 
> attempting to use write.matrix, but write.matrix does not have the 
> ability to include row names in the output. Anyone know why that's the 
> case? I've seen a thread stating that write.matrix is the way to go for 
> large prints to files, but it doesn't do what I need it to. Since 
> write.matrix wasn't working I tried both sink and capture.output, but 
> then the output is printed to the file using the same 'width' 
> restrictions as the general "options(width=)" limit.
>
> Any ideas on how to print a large matrix with row names? I could write a 
> perl script to modify the files after the fact, but I shouldn't have to 
> do that.
>
> Thanks for your help!
>
> Mark T. W. Ebbert
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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,

 What do you want with the data? If you want to store an R matrix on disk
 for later use in R, take a look at ?save. If it is for use in another
 programming language, I would write the matrix in binary format
 (?writebin). This saves a lot of space and prevents any (significant)
 rounding errors. It is probably also quite a bit faster. If you really
 need some more metadata (such as rownames), I would add a second text
 file which stores this information. Sort of a binary file plus a header,
 which is a quite common format for storing data. Maybe you can even find
 a standard binary format which you can use. But it is impossible to
 comment on this because you did not provide information as to what you
 want to do with the saved data.

 good luck!
 Paul

 -- 
 Paul Hiemstra, Ph.D.
 Global Climate Division
 Royal Netherlands Meteorological Institute (KNMI)
 Wilhelminalaan 10 | 3732 GK | De Bilt | Kamer B 3.39
 P.O. Box 201 | 3730 AE | De Bilt
 tel: +31 30 2206 494

 http://intamap.geo.uu.nl/~paul
 http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770

>>
>> -- 
>> Paul Hiemstra, Ph.D.
>> Global Climate Division
>> Royal Netherlands Meteorological Institute (KNMI)
>> Wilhelminalaan 10 | 3732 GK | De Bilt | Kamer B 3.39
>> P.O. Box 201 | 3730 AE | De Bilt
>> tel: +31 30 2206 494
>>
>> http://intamap.geo.uu.nl/~paul
>> http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770
>>


-- 
Paul Hiemstra, Ph.D.
Global Climate Division
Royal Netherlands Meteorological Institute (KNMI)
Wilhelminalaan 10 | 3732 GK | De Bilt | Kamer B 3.39
P.O. Box 201 | 3730 AE | De Bilt
tel: +31 30 2206 494

http://intamap.geo.uu.nl/~paul
http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listin

[R] nls picewise FvCB model

2011-09-19 Thread Andres Berger
Greetings R users, maybe there is someone who can help me with this problem:

I'm trying to fit this discontinous model :

GE<-data.frame( Ci<-c(81,87,91,111,159,173,295,453,629,984),
A<-c(-0.9,1.2,3.5,8.3,13.1,14.4,22.9,27.3,29.6,32.6) )
rhs <- function(Ci, Vcmax, J, Rd) {
   R <-0.008314472
   Tleaf <-25
   Kc <-exp(38.05-79.43/(R*(Tleaf+273.15)))
   Ko <-exp(20.30-36.38/(R*(Tleaf+273.15)))
   Gstar <-exp(19.02-38.83/(R*(Tleaf+273.15)))
   O <-210
   ge<-min(  (Vcmax*(Ci-Gstar))/(Ci+(Kc*(1+(O/Ko
,(J*(Ci-Gstar))/((4*Ci)+(8*Gstar))  ) -Rd
   ge
   }

m<- nls(A ~ rhs(Ci, Vcmax, J, Rd), data=GE, start = list(Vcmax=50,
J=150, Rd=4), trace = T)

And get the following error:

Error in qr(.swts * attr(rhs, "gradient")) :
 dims [product 3] do not match the length of object [10]
In addition: Warning messages:
1: In min(x) : no non-missing arguments to min; returning Inf
2: In max(x) : no non-missing arguments to max; returning -Inf
3: In .swts * attr(rhs, "gradient") :
 longer object length is not a multiple of shorter object length

Any clues on how can I solve the Inf issue and avoid the error?
Thanks,

Andre

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


Re: [R] write.matrix row names vs sink vs capture.output

2011-09-19 Thread Mark Ebbert
I'm afraid I don't understand your response. As I mentioned in the original 
question, write.table is way too slow and I need the row names in the file, so 
setting row.names to FALSE wouldn't accomplish my goal, anyway. And 
write.matrix doesn't have *any* options to include row names, which baffles me 
since row names are part of a matrix object. 

I need the row names because an external program, which requires row names, 
will be processing the files. I wound up using perl to fix the resultant file 
from write.matrix, but I would love to hear an explanation as to why 
write.matrix doesn't have an option to include row names, if you know. 

Anyway, thanks for taking the time to respond. 

On Sep 19, 2011, at 1:49 AM, "Paul Hiemstra"  wrote:

> What do you want with the row names? The help file for ?write.table
> lists a row.names argument which can be set to FALSE.
> 
> regards,
> Paul
> 
> On 09/06/2011 02:58 PM, Mark Ebbert wrote:
>> Thank you for your help.
>> 
>> The data is meant to be processed by a separate program that expects a 
>> simple matrix with row and column names in ascii format. "write.matrix" does 
>> exactly what I want except for the row names. It baffles me that this is not 
>> an option…
>> 
>> 
>> On Sep 6, 2011, at 8:22 AM, Paul Hiemstra wrote:
>> 
>>> On 09/06/2011 06:24 AM, Mark Ebbert wrote:
 Dear R gurus,
 
 I am trying to write several large matrices (~ 1GB) to separate files. I 
 have learned that write.table is simply too slow for this task and was 
 attempting to use write.matrix, but write.matrix does not have the ability 
 to include row names in the output. Anyone know why that's the case? I've 
 seen a thread stating that write.matrix is the way to go for large prints 
 to files, but it doesn't do what I need it to. Since write.matrix wasn't 
 working I tried both sink and capture.output, but then the output is 
 printed to the file using the same 'width' restrictions as the general 
 "options(width=)" limit.
 
 Any ideas on how to print a large matrix with row names? I could write a 
 perl script to modify the files after the fact, but I shouldn't have to do 
 that.
 
 Thanks for your help!
 
 Mark T. W. Ebbert
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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,
>>> 
>>> What do you want with the data? If you want to store an R matrix on disk
>>> for later use in R, take a look at ?save. If it is for use in another
>>> programming language, I would write the matrix in binary format
>>> (?writebin). This saves a lot of space and prevents any (significant)
>>> rounding errors. It is probably also quite a bit faster. If you really
>>> need some more metadata (such as rownames), I would add a second text
>>> file which stores this information. Sort of a binary file plus a header,
>>> which is a quite common format for storing data. Maybe you can even find
>>> a standard binary format which you can use. But it is impossible to
>>> comment on this because you did not provide information as to what you
>>> want to do with the saved data.
>>> 
>>> good luck!
>>> Paul
>>> 
>>> -- 
>>> Paul Hiemstra, Ph.D.
>>> Global Climate Division
>>> Royal Netherlands Meteorological Institute (KNMI)
>>> Wilhelminalaan 10 | 3732 GK | De Bilt | Kamer B 3.39
>>> P.O. Box 201 | 3730 AE | De Bilt
>>> tel: +31 30 2206 494
>>> 
>>> http://intamap.geo.uu.nl/~paul
>>> http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770
>>> 
> 
> 
> -- 
> Paul Hiemstra, Ph.D.
> Global Climate Division
> Royal Netherlands Meteorological Institute (KNMI)
> Wilhelminalaan 10 | 3732 GK | De Bilt | Kamer B 3.39
> P.O. Box 201 | 3730 AE | De Bilt
> tel: +31 30 2206 494
> 
> http://intamap.geo.uu.nl/~paul
> http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770
> 
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Replace a for loop with a function

2011-09-19 Thread Eekhout, I.
Hi all, 

I would like to replace the for loop in the code below with a function
to improve the speed and to make the script more efficient. 
The loop creates a vector of integers (x) with the probability of f for
each integer.
The length of f is variable, but sums to 1. 
I tried to use a function with optional arguments which did not work.

Here is the code:

f <- data.matrix(c(0.5,0.15,0.35))
u <- runif(50) 
x <- data.matrix(rep(1, n)) 
fc <- 0
for(i in 1:length(f))   {
fc <- fc + f[i] 
cf <- ifelse(u>fc,1,0)
x <- x + cf
}
x

Can anyone help me with this translation?
Thanks in advance, 

Iris

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


Re: [R] write.matrix row names vs sink vs capture.output

2011-09-19 Thread Mark Ebbert
Thank you, that's a good idea. I should have looked into that!

On Sep 19, 2011, at 8:42 AM, Paul Hiemstra wrote:

> Sorry, misread :). Consider my remark as retracted...however
> 
> It looks like it would be relatively simple to rewrite write.matrix a
> little bit to include rownames...the cat statement in the while loop of
> write.matrix could be changed to include a row name. To get he source
> code of write.matrix:
> 
> library(MASS)
> write.matrix
> # without the ()!!
> 
> hope this helps more than my previous (useless) comment,
> Paul
> 
> On 09/19/2011 02:37 PM, Mark Ebbert wrote:
>> I'm afraid I don't understand your response. As I mentioned in the original 
>> question, write.table is way too slow and I need the row names in the file, 
>> so setting row.names to FALSE wouldn't accomplish my goal, anyway. And 
>> write.matrix doesn't have *any* options to include row names, which baffles 
>> me since row names are part of a matrix object. 
>> 
>> I need the row names because an external program, which requires row names, 
>> will be processing the files. I wound up using perl to fix the resultant 
>> file from write.matrix, but I would love to hear an explanation as to why 
>> write.matrix doesn't have an option to include row names, if you know. 
>> 
>> Anyway, thanks for taking the time to respond. 
>> 
>> On Sep 19, 2011, at 1:49 AM, "Paul Hiemstra"  wrote:
>> 
>>> What do you want with the row names? The help file for ?write.table
>>> lists a row.names argument which can be set to FALSE.
>>> 
>>> regards,
>>> Paul
>>> 
>>> On 09/06/2011 02:58 PM, Mark Ebbert wrote:
 Thank you for your help.
 
 The data is meant to be processed by a separate program that expects a 
 simple matrix with row and column names in ascii format. "write.matrix" 
 does exactly what I want except for the row names. It baffles me that this 
 is not an option…
 
 
 On Sep 6, 2011, at 8:22 AM, Paul Hiemstra wrote:
 
> On 09/06/2011 06:24 AM, Mark Ebbert wrote:
>> Dear R gurus,
>> 
>> I am trying to write several large matrices (~ 1GB) to separate files. I 
>> have learned that write.table is simply too slow for this task and was 
>> attempting to use write.matrix, but write.matrix does not have the 
>> ability to include row names in the output. Anyone know why that's the 
>> case? I've seen a thread stating that write.matrix is the way to go for 
>> large prints to files, but it doesn't do what I need it to. Since 
>> write.matrix wasn't working I tried both sink and capture.output, but 
>> then the output is printed to the file using the same 'width' 
>> restrictions as the general "options(width=)" limit.
>> 
>> Any ideas on how to print a large matrix with row names? I could write a 
>> perl script to modify the files after the fact, but I shouldn't have to 
>> do that.
>> 
>> Thanks for your help!
>> 
>> Mark T. W. Ebbert
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/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,
> 
> What do you want with the data? If you want to store an R matrix on disk
> for later use in R, take a look at ?save. If it is for use in another
> programming language, I would write the matrix in binary format
> (?writebin). This saves a lot of space and prevents any (significant)
> rounding errors. It is probably also quite a bit faster. If you really
> need some more metadata (such as rownames), I would add a second text
> file which stores this information. Sort of a binary file plus a header,
> which is a quite common format for storing data. Maybe you can even find
> a standard binary format which you can use. But it is impossible to
> comment on this because you did not provide information as to what you
> want to do with the saved data.
> 
> good luck!
> Paul
> 
> -- 
> Paul Hiemstra, Ph.D.
> Global Climate Division
> Royal Netherlands Meteorological Institute (KNMI)
> Wilhelminalaan 10 | 3732 GK | De Bilt | Kamer B 3.39
> P.O. Box 201 | 3730 AE | De Bilt
> tel: +31 30 2206 494
> 
> http://intamap.geo.uu.nl/~paul
> http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770
> 
>>> 
>>> -- 
>>> Paul Hiemstra, Ph.D.
>>> Global Climate Division
>>> Royal Netherlands Meteorological Institute (KNMI)
>>> Wilhelminalaan 10 | 3732 GK | De Bilt | Kamer B 3.39
>>> P.O. Box 201 | 3730 AE | De Bilt
>>> tel: +31 30 2206 494
>>> 
>>> http://intamap.geo.uu.nl/~paul
>>> http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770
>>> 
> 
> 
> -- 
> Paul Hiemstra, Ph.D.
> Global Climate Division
> Royal Netherlands Meteorological Institute (KNMI)
> Wilhelminalaan 10 | 3732 GK | 

Re: [R] Planned comparison ANOVA

2011-09-19 Thread Greg Snow
Here is one example of doing it, first create a matrix with all your contrasts 
(I added some to make it full), then invert it to get the dummy variable 
encodings, use the 'contrast' function (or 'C') to set the contrasts, then use 
'aov' or 'lm' and those contrasts will be used:

> my.contrasts <- rbind( 1/5, '1 v 5' = c(1,0,0,0,-1), 
+ '12 v 45' = c(1,1,0,-1,-1)/2, '1 v 2' = c(1,-1,0,0,0),
+ '3 v 1245' = c(-1,-1,4,-1,-1)/4 )
> my.contrasts
  [,1]  [,2] [,3]  [,4]  [,5]
  0.20  0.20  0.2  0.20  0.20
1 v 5 1.00  0.00  0.0  0.00 -1.00
12 v 45   0.50  0.50  0.0 -0.50 -0.50
1 v 2 1.00 -1.00  0.0  0.00  0.00
3 v 1245 -0.25 -0.25  1.0 -0.25 -0.25
> 
> my.dv <- solve(my.contrasts)
> my.dv
   1 v 5 12 v 45 1 v 2 3 v 1245
[1,] 1 0 0.5   0.5 -0.2
[2,] 1 0 0.5  -0.5 -0.2
[3,] 1 0 0.0   0.0  0.8
[4,] 1 1-1.5  -0.5 -0.2
[5,] 1-1 0.5   0.5 -0.2
> 
> g <- factor(rep(1:5, each=20))
> y <- rnorm(100, 10, 2)
> 
> contrasts(g) <- my.dv[,-1]
> 
> fit <- aov( y ~ g )
> summary(fit, split=list(g=1:4))
Df Sum Sq Mean Sq F value  Pr(>F)  
g4  19.20  4.8007  1.3110 0.27151  
  g: C1  1   2.01  2.0054  0.5476 0.46111  
  g: C2  1  15.95 15.9470  4.3548 0.03958 *
  g: C3  1   0.28  0.2814  0.0768 0.78223  
  g: C4  1   0.97  0.9689  0.2646 0.60819  
Residuals   95 347.88  3.6619  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 
> summary.lm(fit)

Call:
aov(formula = y ~ g)

Residuals:
Min  1Q  Median  3Q Max 
-4.4519 -1.1546  0.0749  1.2288  5.2639 

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept)   9.7437 0.1914  50.918   <2e-16 ***
g1 v 5   -1.0330 0.6051  -1.707   0.0911 .  
g12 v 45 -0.8929 0.4279  -2.087   0.0396 *  
g1 v 20.1677 0.6051   0.277   0.7822
g3 v 1245 0.2461 0.4784   0.514   0.6082
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 

Residual standard error: 1.914 on 95 degrees of freedom
Multiple R-squared: 0.05231,Adjusted R-squared: 0.01241 
F-statistic: 1.311 on 4 and 95 DF,  p-value: 0.2715 

> 
> mean( y[g==1] ) - mean(y[g==5]) # compare to estimate for 1st contrast
[1] -1.032981
> (mean( y[g==1] )+mean(y[g==2]) - mean(y[g==4]) - mean(y[g==5]) )/2
[1] -0.8929435
> mean( y[g==1] ) - mean(y[g==2])
[1] 0.1677452
> mean( y[g==3] ) - mean(y[g!=3]) # change this if unbalanced
[1] 0.2460775
>

Hope this helps,

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of robcinm
> Sent: Saturday, September 17, 2011 10:59 PM
> To: r-help@r-project.org
> Subject: [R] Planned comparison ANOVA
> 
> I am trying to do a priori ANOVA analysis for a class assignment. The
> professor uses SPSS and does not know R. I want to do a simple planned
> comparison but have been unable to find a function or specific help.
> There
> is a grouping variable with five levels and a subsequent response
> variable.
> I also created a few columns that contain my group contrasts to see if
> anything could come of that. My first hypothesis, for example, is that
> group
> 1 and group 5 differ. My second is that groups 1 & 2 differ from 4 & 5
> and
> so on...
> 
> I searched and found people wanting similar help, but their projects
> were a
> little beyond my R comprehension right now and the help given did not
> apply.
> 
> --
> View this message in context: http://r.789695.n4.nabble.com/Planned-
> comparison-ANOVA-tp3821357p3821357.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


[R] Results of applying na.omit on zoo object

2011-09-19 Thread Rich Shepard

  I read in ?na.omit that it returns the object with incomplete cases
removed. I interpret this to mean that any zoo object row where any column
shows 'NA' will be removed from the data set.

  That's not what I need, since the 'NA' represents information in my
context. However, what I would like to do is eliminate the rows where every
column is 'NA'. When I aggregate two factors by date in the zoo object, the
rows being with the earliest possible date even if that's not appropriate
for the row factor pair.

  Is there a way to omit only those rows where all columns contain 'NA'?

Rich

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


Re: [R] Results of applying na.omit on zoo object

2011-09-19 Thread Rich Shepard

On Mon, 19 Sep 2011, Rich Shepard wrote:


When I aggregate two factors by date in the zoo object, the rows being ...

   ^

  That should be 'begin'.

Mea culpa!

Rich

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


Re: [R] Results of applying na.omit on zoo object

2011-09-19 Thread Marc Schwartz
On Sep 19, 2011, at 11:48 AM, Rich Shepard wrote:

>  I read in ?na.omit that it returns the object with incomplete cases
> removed. I interpret this to mean that any zoo object row where any column
> shows 'NA' will be removed from the data set.
> 
>  That's not what I need, since the 'NA' represents information in my
> context. However, what I would like to do is eliminate the rows where every
> column is 'NA'. When I aggregate two factors by date in the zoo object, the
> rows being with the earliest possible date even if that's not appropriate
> for the row factor pair.
> 
>  Is there a way to omit only those rows where all columns contain 'NA'?
> 
> Rich



You can look at ?complete.cases for one approach, presuming that it will work 
on zoo objects.

HTH

Marc Schwartz

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


Re: [R] Results of applying na.omit on zoo object

2011-09-19 Thread Rich Shepard

On Mon, 19 Sep 2011, Marc Schwartz wrote:


You can look at ?complete.cases for one approach, presuming that it will
work on zoo objects.


Marc,

  I'll read and try it. Can't hurt anything.

Thanks,

Rich

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


Re: [R] Results of applying na.omit on zoo object

2011-09-19 Thread Rich Shepard

On Mon, 19 Sep 2011, Marc Schwartz wrote:


You can look at ?complete.cases for one approach, presuming that it will
work on zoo objects.


Marc,

  That's the opposite of what I want. It returns only rows with no missing
data. I'm looking for something that will return rows with _only_ missing
data, and drop them in the bit bucket.

Thanks,

Rich

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


Re: [R] Results of applying na.omit on zoo object

2011-09-19 Thread Achim Zeileis

On Mon, 19 Sep 2011, Rich Shepard wrote:


On Mon, 19 Sep 2011, Marc Schwartz wrote:


You can look at ?complete.cases for one approach, presuming that it will
work on zoo objects.


Marc,

 That's the opposite of what I want. It returns only rows with no missing
data. I'm looking for something that will return rows with _only_ missing
data, and drop them in the bit bucket.


This should do what you want, I think:

R> z <- zoo(matrix(1:8, ncol = 2), Sys.Date() + 0:3)
R> z[2,2] <- NA
R> z[3,] <- NA
R> z

2011-09-19  1  5
2011-09-20  2 NA
2011-09-21 NA NA
2011-09-22  4  8

R> z[!apply(is.na(z), 1, all),]

2011-09-19 1  5
2011-09-20 2 NA
2011-09-22 4  8

hth,
Z


Thanks,

Rich

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



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


Re: [R] Replace a for loop with a function

2011-09-19 Thread Eik Vettorazzi
Hi Iris,
maybe I misinterpret this, but I think in the end it all comes down to
sample(1:3,50,prob=c(0.5,0.15,0.35),replace=T))

cheers

Am 19.09.2011 17:16, schrieb Eekhout, I.:
> Hi all, 
> 
> I would like to replace the for loop in the code below with a function
> to improve the speed and to make the script more efficient. 
> The loop creates a vector of integers (x) with the probability of f for
> each integer.
> The length of f is variable, but sums to 1. 
> I tried to use a function with optional arguments which did not work.
> 
> Here is the code:
> 
> f <- data.matrix(c(0.5,0.15,0.35))
> u <- runif(50) 
> x <- data.matrix(rep(1, n)) 
> fc <- 0
>   for(i in 1:length(f))   {
>   fc <- fc + f[i] 
>   cf <- ifelse(u>fc,1,0)
>   x <- x + cf
>   }
> x
> 
> Can anyone help me with this translation?
> Thanks in advance, 
> 
> Iris
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.


-- 
Eik Vettorazzi
Institut für Medizinische Biometrie und Epidemiologie
Universitätsklinikum Hamburg-Eppendorf

Martinistr. 52
20246 Hamburg

T ++49/40/7410-58243
F ++49/40/7410-57790

--
Pflichtangaben gemäß Gesetz über elektronische Handelsregister und 
Genossenschaftsregister sowie das Unternehmensregister (EHUG):

Universitätsklinikum Hamburg-Eppendorf; Körperschaft des öffentlichen Rechts; 
Gerichtsstand: Hamburg

Vorstandsmitglieder: Prof. Dr. Jörg F. Debatin (Vorsitzender), Dr. Alexander 
Kirstein, Joachim Prölß, Prof. Dr. Dr. Uwe Koch-Gromus 

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


Re: [R] Replace a for loop with a function

2011-09-19 Thread Eik Vettorazzi
sorry, there is a superfluous bracket at the end of the line, it should
be read as
sample(1:3,50,prob=c(0.5,0.15,0.35),replace=T)

Am 19.09.2011 19:08, schrieb Eik Vettorazzi:
> Hi Iris,
> maybe I misinterpret this, but I think in the end it all comes down to
> sample(1:3,50,prob=c(0.5,0.15,0.35),replace=T))
> 
> cheers
> 
> Am 19.09.2011 17:16, schrieb Eekhout, I.:
>> Hi all, 
>>
>> I would like to replace the for loop in the code below with a function
>> to improve the speed and to make the script more efficient. 
>> The loop creates a vector of integers (x) with the probability of f for
>> each integer.
>> The length of f is variable, but sums to 1. 
>> I tried to use a function with optional arguments which did not work.
>>
>> Here is the code:
>>
>> f <- data.matrix(c(0.5,0.15,0.35))
>> u <- runif(50) 
>> x <- data.matrix(rep(1, n)) 
>> fc <- 0
>>  for(i in 1:length(f))   {
>>  fc <- fc + f[i] 
>>  cf <- ifelse(u>fc,1,0)
>>  x <- x + cf
>>  }
>> x
>>
>> Can anyone help me with this translation?
>> Thanks in advance, 
>>
>> Iris
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
> 
> 


-- 
Eik Vettorazzi

Department of Medical Biometry and Epidemiology
University Medical Center Hamburg-Eppendorf

Martinistr. 52
20246 Hamburg

T ++49/40/7410-58243
F ++49/40/7410-57790

--
Pflichtangaben gemäß Gesetz über elektronische Handelsregister und 
Genossenschaftsregister sowie das Unternehmensregister (EHUG):

Universitätsklinikum Hamburg-Eppendorf; Körperschaft des öffentlichen Rechts; 
Gerichtsstand: Hamburg

Vorstandsmitglieder: Prof. Dr. Jörg F. Debatin (Vorsitzender), Dr. Alexander 
Kirstein, Joachim Prölß, Prof. Dr. Dr. Uwe Koch-Gromus 

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

2011-09-19 Thread Michael Haenlein
Dear all,



I would like to solve a problem similar to a multiple knapsack problem and
am looking for a function in R that can help me.



Specifically, my situation is as follows: I have a list of n items which I
would like to allocate to m groups with fixed size. Each item has a certain
profit value and this profit depends on the type of group the item is in. My
problem is to allocate the items into groups so the overall profit is
maximized while respecting the fixed size of each group.



Take the following example with 20 items (n=5) and 5 groups (m=5):

set.seed(1)

profits <- matrix(runif(100), nrow=20)

size<-c(2,3,4,5,6)



The matrix "profits" describes the profit of each item when it is allocated
to a certain group. For example, when item 1 is allocated to group 1 it
generates a profit of 0.26550866. However, when item 1 is allocated to group
2 it generates a profit of 0.93470523. The matrix "size" describes the size
of each group. So group 1 can contain 2 items, group 2 3 items, group 4 4
items, etc.



I think this is probably something that could be done with constrOptim() but
I'm not exactly sure how.



Any help is very much appreciated!



Thanks very much in advance,



Michael







Michael Haenlein

Associate Professor of Marketing

ESCP Europe

Paris, France

[[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] Results of applying na.omit on zoo object

2011-09-19 Thread Marc Schwartz

On Sep 19, 2011, at 12:01 PM, Rich Shepard wrote:

> On Mon, 19 Sep 2011, Marc Schwartz wrote:
> 
>> You can look at ?complete.cases for one approach, presuming that it will
>> work on zoo objects.
> 
> Marc,
> 
>  That's the opposite of what I want. It returns only rows with no missing
> data. I'm looking for something that will return rows with _only_ missing
> data, and drop them in the bit bucket.
> 
> Thanks,
> 
> Rich


Rich,

OK, I mis-read your post.

Depending upon the underlying structure/class of the zoo object (eg. matrix 
versus data frame) and presuming that there are no functions in zoo that 
provide this specific functionality, you may have to create a function that 
goes row-by-row looking for all NA's.

Possibly something along the lines of the following for a matrix:

  zoo.object[apply(zoo.object, 1, function(x) all(is.na(x))), ]


That won't work for a data frame class object, so you might have to loop over 
the rows with a for() loop or sapply():

  zoo.object[sapply(rownames(zoo.object), function(x) all(is.na(x))), ]


Both of the above are untested.

HTH,

Marc

P.S. I completely forgot that today is International Talk Like A Pirate Day, so 
Rr Matey…  ;-)

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


Re: [R] Replace a for loop with a function

2011-09-19 Thread Jean V Adams
Eekhout, I. wrote on 09/19/2011 10:16:17 AM:
> 
> Hi all, 
> 
> I would like to replace the for loop in the code below with a function
> to improve the speed and to make the script more efficient. 
> The loop creates a vector of integers (x) with the probability of f for
> each integer.
> The length of f is variable, but sums to 1. 
> I tried to use a function with optional arguments which did not work.
> 
> Here is the code:
> 
> f <- data.matrix(c(0.5,0.15,0.35))
> u <- runif(50) 
> x <- data.matrix(rep(1, n)) 
> fc <- 0
>for(i in 1:length(f))   {
>   fc <- fc + f[i] 
>   cf <- ifelse(u>fc,1,0)
>   x <- x + cf
>}
> x
> 
> Can anyone help me with this translation?
> Thanks in advance, 
> 
> Iris


There was no "n" in the sample code you shared.  I assumed n=50.

n <- 50
f <- data.matrix(c(0.5, 0.15, 0.35))
u <- runif(n)

res <- outer(u, cumsum(f), ">")
x <- rowSums(res) + 1
x

Jean

[[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] Results of applying na.omit on zoo object

2011-09-19 Thread Marc Schwartz

On Sep 19, 2011, at 12:19 PM, Marc Schwartz wrote:

> 
> On Sep 19, 2011, at 12:14 PM, Marc Schwartz wrote:
> 
>> 
>> On Sep 19, 2011, at 12:01 PM, Rich Shepard wrote:
>> 
>>> On Mon, 19 Sep 2011, Marc Schwartz wrote:
>>> 
 You can look at ?complete.cases for one approach, presuming that it will
 work on zoo objects.
>>> 
>>> Marc,
>>> 
>>> That's the opposite of what I want. It returns only rows with no missing
>>> data. I'm looking for something that will return rows with _only_ missing
>>> data, and drop them in the bit bucket.
>>> 
>>> Thanks,
>>> 
>>> Rich
>> 
>> 
>> Rich,
>> 
>> OK, I mis-read your post.
>> 
>> Depending upon the underlying structure/class of the zoo object (eg. matrix 
>> versus data frame) and presuming that there are no functions in zoo that 
>> provide this specific functionality, you may have to create a function that 
>> goes row-by-row looking for all NA's.
>> 
>> Possibly something along the lines of the following for a matrix:
>> 
>> zoo.object[apply(zoo.object, 1, function(x) all(is.na(x))), ]
>> 
>> 
>> That won't work for a data frame class object, so you might have to loop 
>> over the rows with a for() loop or sapply():
>> 
>> zoo.object[sapply(rownames(zoo.object), function(x) all(is.na(x))), ]
>> 
>> 
>> Both of the above are untested.

Rich,

One more time…re-post:

I forgot a critical '!' in both. They should be

 zoo.object[!apply(zoo.object, 1, function(x) all(is.na(x))), ]

and the DF approach is not correct either. It should be:

  zoo.object[!sapply(rownames(zoo.object), function(x) all(is.na(zoo.object[x, 
]))), ]

I clearly have not had enough caffeine yet today…

Marc

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

2011-09-19 Thread Bos, Roger
All,

Could anyone recommend a package that allows the user to constrain the
coefficients from a multiple regression equation?  

I tried using the  gl1ce function in lasso2, but couldn't get it to
work.  I created a contrived example to illustrate my starting point.

data(cars)
 fmla <- formula(dist ~ speed)
 gl1c.E <- gl1ce(fmla, data = cars)
 gl1c.E
 gl1c.E <- gl1ce(fmla, data = cars, link=identity())
 gl1c.E

I started with the example, but I think my data is more Gaussian than
binomial.  This returns the following errors.

>  data(cars)
>  fmla <- formula(dist ~ speed)
>  gl1c.E <- gl1ce(fmla, data = cars)
Error in family(family) : 
  link "family" not available for gaussian family; available links are
'inverse', 'log', 'identity'
> source(.trPaths[5], echo=TRUE, max.deparse.length=150)
>  gl1c.E <- gl1ce(fmla, data = cars, link=identity())
Error in identity() : argument "x" is missing, with no default

In this example I haven't even gotten to the stage of constraining the
coefficients yet because I can't get the function to work with minimal
inputs.

Thanks,

RogerRoger J. Bos, CFA
Rothschild Asset Management, Inc.
Tel +1 (212) 405-5471
Email roger@rothschild.com
1251 Avenue of the Americas, NY, NY  10020
***

This message is for the named person's use only. It may\...{{dropped:14}}

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

2011-09-19 Thread Sai Tong
I have a question about what is the best function or package to use to 
do the following in R:


minimize Q = g W g'  where respect to \gamma

where g is n x 1 vector, W is a n x n matrix and is given,
and g =  1 / T   * sum_from_i=1_to_1=60   [ (1-R[i+1] * ( E[i+1]/E[i ]  
)^(\gamma)  ) ]

and T is a constant

would it be a feasible to first find the vector of g (a n x 1 vector) 
that  minimize  Q using solver from quadprog  and then solve for \gamma 
using the vector elements found?


-Sai

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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: in routine alloca() there is a stack overflow: thread 0, max 535822282KB, used 0KB, request 24B

2011-09-19 Thread D Brown
In a previous post I detailed the error indicated in the subject. I am
posting now to indicate the problem was likely an incompatibility between
the versions of netcdf (3.6.2) and ncdf (1.6.5). What I did to resolve the
problem was install netcdf-4.1.3 and then reinstalled ncdf_1.6.5.

[[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] work about all time series analysis with examples or exercises

2011-09-19 Thread doors

I have a problem on the R, the truth I have never used this tool
but I need to do some exercises of the university, for example not
how to import a number, I need to know all the steps to make the series
of time with graphics, the differentiation of the series, the
autocorrelation, the vector
prices, etc, need as this is being done and if there is a period or
work to implement it, I would be helpful thanks, I await your response
soon as possible.

--
View this message in context: 
http://r.789695.n4.nabble.com/work-about-all-time-series-analysis-with-examples-or-exercises-tp3824818p3824818.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] Results of applying na.omit on zoo object

2011-09-19 Thread Rich Shepard

On Mon, 19 Sep 2011, Achim Zeileis wrote:


This should do what you want, I think:

R> z <- zoo(matrix(1:8, ncol = 2), Sys.Date() + 0:3)
R> z[2,2] <- NA
R> z[3,] <- NA
R> z

2011-09-19  1  5
2011-09-20  2 NA
2011-09-21 NA NA
2011-09-22  4  8

R> z[!apply(is.na(z), 1, all),]

2011-09-19 1  5
2011-09-20 2 NA
2011-09-22 4  8


Z,

  I'm quite new to R so I have a lot to learn even reading all I can, so I
ask your patience.

  Do I mis-read the above that it applies to a matrix but not a data.frame?

Rich

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


Re: [R] Constrained regressions (suggestions welcome)

2011-09-19 Thread Bert Gunter
Roger:

1. Constrain how? Via a penalty? Via a linear or nonlinear equations or
inequalities on the coefficients? You need to be explicit.

2. The above point and:

I started with the example, but I think my data is more Gaussian than
> binomial.  This returns the following errors.
> --
>

both indicate to me that your math/statistical skills may be inadequate for
the task. As a result, I think you would do well to consult a local
statistician -- or someone with adequate statistical background in this
area,anyway. Good people on this list may offer advice, but you may be
heading down the wrong path and thereby committing errors of the third kind
(right answer to wrong question).

Cheers,
Bert




"Men by nature long to get on to the ultimate truths, and will often be
impatient with elementary studies or fight shy of them. If it were possible
to reach the ultimate truths without the elementary studies usually prefixed
to them, these would not be preparatory studies but superfluous diversions."

-- Maimonides (1135-1204)

Bert Gunter
Genentech Nonclinical Biostatistics
467-7374
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

[[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] Poisson-Gamma computation (parameters and likelihood)

2011-09-19 Thread Sebastiano Putoto
Good afternoon/morning readers. This is the first time I am trying to run
some Bayesian computation in R, and am experiencing a few problems.

I am working on a Poisson model for cancer rates which has a conjugate Gamma
prior.

1) The first question is precisely how I work out the parameters.

#Suppose I assign values to theta with *seq()*
*theta<-seq(0,1,len=500)*

#Then I try out the parameters that seem to fit with a certain prior idea on
theta (see next)
*a=182*
*b=3530*
*gaprior<-dgamma(theta,a,b)*
*
*
It should work by trial-and-error (according to "Bayesian Computation with
R") , but how can I check the parameters turned out well: should I just look
at the plot, or evaluate it through the *1 - pgamma(x,a,b) *function, having
knowledge of the 5th percentile (data from US Cancer Statistics)?

2) Then, the next problem I have regards the likelihood distribution.

#Having the *react* table, I name the columns (with y=deaths, and
x=exposures)
*
react
x  y
1   6 15
2   5 16
3   3 12
4   4  6
5  27 77
6   7 17
7   4 11
8   5 10
9  23 63
10 11 29

*
*yr <- react[,2]*
*xr <- react[,1]*



#I then compute the likelihood
*poislike=dpois(yr, theta*xr)*

#And this is what I come up with, which I really don't understand.
*poislike*
*[1] 0 0 0 0 0 0 0 0 0 0*

The values shouldn't be all null, otherwise my posterior cannot be computed
properly. Does anyone have any idea on where I could possibly have messed it
up?

Thank you very much for your attention.

Regards,

Sebastiano Putoto (University of Pavia, Italy)

[[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] openmp on R?

2011-09-19 Thread Simon Zehnder
Dear R-Users,

in the configuring file of R on the supercomputer I am using I found a line  

--disable-openmp  (version R 2.13.1)

Is there a possibility to enable this when I let run a BATCH file via R CMD?

Thanks for comments!


Simon

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


Re: [R] Results of applying na.omit on zoo object

2011-09-19 Thread Rich Shepard

On Mon, 19 Sep 2011, Marc Schwartz wrote:


 Is there a way to omit only those rows where all columns contain 'NA'?



You can look at ?complete.cases for one approach, presuming that it will
work on zoo objects.


Marc,

  Do I even need to worry about these NAs? Thanks to Gabor I have a data
frame with 296 stream/parameter sets. Each set begins and ends on a
different date (used as the zoo index).

  What I want to do initially is plot the time series for each
stream/parameter to see what each has to tell us. In this case, if there are
years of NAs prior to the fist measurement for that stream/parameter pair,
will this affect anything.

  On a related note, I'm reading the zoo help pages and vignettes but do not
see the syntax for specifying which stream/parameter pair I want to plot.
What do I read to learn how to do this?

Rich

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Invisible doesn't exit function?

2011-09-19 Thread Gene Leynes
I thought that invisible works like return()
However, it appears that it doesn't exit a function.  Is it supposed to work
this way?


funInvisible = function(){
invisible(10)
cat('I was not expecting this to print\n')
cat('because it occurs after the invisible return\n')
}
funInvisible()


funVisible = function(){
cat('start of function\n')
return(10)
cat('This error is safely avoided: \n')
cat(1 / 0)
}
funVisible()

[[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] Invisible doesn't exit function?

2011-09-19 Thread Duncan Murdoch

On 11-09-19 5:11 PM, Gene Leynes wrote:

I thought that invisible works like return()
However, it appears that it doesn't exit a function.  Is it supposed to work
this way?





Yes, invisible() just marks its argument as non-printing.  You still 
need to return it.  (The man page is a little ambiguous, but what it is 
saying is that a call to invisible() returns a non-printing object.  It 
isn't saying that it triggers a return from the caller.)


Duncan Murdoch

>


funInvisible = function(){
 invisible(10)
 cat('I was not expecting this to print\n')
 cat('because it occurs after the invisible return\n')
}
funInvisible()


funVisible = function(){
 cat('start of function\n')
 return(10)
 cat('This error is safely avoided: \n')
 cat(1 / 0)
}
funVisible()

[[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 Questions (was: Results of applying na.omit on zoo object)

2011-09-19 Thread Rich Shepard

On Mon, 19 Sep 2011, Rich Shepard wrote:


 On a related note, I'm reading the zoo help pages and vignettes but do
not see the syntax for specifying which stream/parameter pair I want to
plot. What do I read to learn how to do this?


  I think that my reading answered this question, but now I need to refine
the plots.

  If I run 'plot(z[, 1])' for example I get the stream/parameter pair in
that is on the left of the top row. This leads to two refinement questions:

  1) How can I get a list of the stream/parameter pairs and their position
in the summary matrix? and,

  2) How can I determine the earliest and latest dates in each
stream/parameter pair in which there are data? According to the zoo.quickref
vignette, start and end provide the earliest and last dates in the index,
not necessarily for a specific stream/paramater pair. Once I have those
dates I can specify start = as.Date("") and end =
as.Date("").

Rich

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


Re: [R] Results of applying na.omit on zoo object

2011-09-19 Thread Marc Schwartz
On Sep 19, 2011, at 4:00 PM, Rich Shepard wrote:

> On Mon, 19 Sep 2011, Marc Schwartz wrote:
> 
>>> Is there a way to omit only those rows where all columns contain 'NA'?
> 
>> You can look at ?complete.cases for one approach, presuming that it will
>> work on zoo objects.
> 
> Marc,
> 
>  Do I even need to worry about these NAs? Thanks to Gabor I have a data
> frame with 296 stream/parameter sets. Each set begins and ends on a
> different date (used as the zoo index).
> 
>  What I want to do initially is plot the time series for each
> stream/parameter to see what each has to tell us. In this case, if there are
> years of NAs prior to the fist measurement for that stream/parameter pair,
> will this affect anything.
> 
>  On a related note, I'm reading the zoo help pages and vignettes but do not
> see the syntax for specifying which stream/parameter pair I want to plot.
> What do I read to learn how to do this?
> 
> Rich


Hi Rich,

Let me start by acknowledging that I have little practical experience in time 
series analyses, much less proficiency with the zoo package. I just don't come 
across them much in clinical trials/studies, at least the ones that I have been 
involved with over the past 25+ years.

I do know from prior posts on the matter, that the zoo package seems to have 
some of its own approaches to dealing with dates, as compared to base R. So you 
may need to be clear on the differentiation in code/functions required to use 
some of the package functionality.

So from a analytic perspective, I would encourage others to chime in with 
guidance. Missing data generally has an impact at some level, the extent of 
which is going to be specific to the context of the particular analysis being 
performed and any assumptions one may be willing to make.

There is also the r-sig-finance list:

  https://stat.ethz.ch/mailman/listinfo/r-sig-finance

to which this query may be better suited in terms of gaining a focused audience 
in a domain where time series analyses are prevalent. 

There are also some books on using R for time series analyses, some of which 
are listed on the "Books" link from the R homepage. It would seem logical that 
one or more of them might cover the use of the zoo package, but that is a guess 
on my part.

I hope that the above is helpful Rich.

I also presume that you got my "final" version of the two functions, with the 
corrected data frame based approach. Sorry for the confusion on that earlier.

Regards,

Marc

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


Re: [R] Results of applying na.omit on zoo object

2011-09-19 Thread Gabor Grothendieck
On Mon, Sep 19, 2011 at 5:33 PM, Marc Schwartz  wrote:
> On Sep 19, 2011, at 4:00 PM, Rich Shepard wrote:
>
>> On Mon, 19 Sep 2011, Marc Schwartz wrote:
>>
 Is there a way to omit only those rows where all columns contain 'NA'?
>>
>>> You can look at ?complete.cases for one approach, presuming that it will
>>> work on zoo objects.
>>
>> Marc,
>>
>>  Do I even need to worry about these NAs? Thanks to Gabor I have a data
>> frame with 296 stream/parameter sets. Each set begins and ends on a
>> different date (used as the zoo index).
>>
>>  What I want to do initially is plot the time series for each
>> stream/parameter to see what each has to tell us. In this case, if there are
>> years of NAs prior to the fist measurement for that stream/parameter pair,
>> will this affect anything.
>>
>>  On a related note, I'm reading the zoo help pages and vignettes but do not
>> see the syntax for specifying which stream/parameter pair I want to plot.
>> What do I read to learn how to do this?
>>
>> Rich
>
>
> Hi Rich,
>
> Let me start by acknowledging that I have little practical experience in time 
> series analyses, much less proficiency with the zoo package. I just don't 
> come across them much in clinical trials/studies, at least the ones that I 
> have been involved with over the past 25+ years.
>
> I do know from prior posts on the matter, that the zoo package seems to have 
> some of its own approaches to dealing with dates, as compared to base R. So 
> you may need to be clear on the differentiation in code/functions required to 
> use some of the package functionality.

This is not at all the case.  zoo relies on external facilities to
handle index classes and not its own facilities.

In some cases zoo extends base facilities or adds new classes to give
additional possibilities but when this is done the base functionality
is always extended and never changed.  There are no exceptions to this
rule.

In fact, the only time zoo functions or methods have any understanding
of index classes is when interfacing to the outside world since such
interfacing implies knowledge of how the external objects work.

For accurate information on the design of zoo read

vignette("zoo-design")

and the other four vignettes and as well as the help files in the zoo package.

Regarding plotting plotting in zoo is similar to in R so NAs are
ignored in plots.  Thus leading and trailing NAs do not result in
anything on the plot.  To plot a zoo object try:

plot(z) # multiple panels
plot(z, screen = 1) # all columns on 1 panel

or

library(lattice)
xyplot(z)

xyplot also accepts the screen= argument and more info is in ?plot.zoo
and ?xyplot.zoo   Like most zoo functions they tend to work like core
R functions so if you understand those then the working with the zoo
ones come natural.

-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

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


Re: [R] Results of applying na.omit on zoo object

2011-09-19 Thread Rich Shepard

On Mon, 19 Sep 2011, Marc Schwartz wrote:


Let me start by acknowledging that I have little practical experience in
time series analyses, much less proficiency with the zoo package. I just
don't come across them much in clinical trials/studies, at least the ones
that I have been involved with over the past 25+ years.


Marc,

  A lot of folks on the mail list here seem to be in the medical side of
biology. I'm a stream ecologist/fluvial geomorphologist with 30 or so years
of professional experience and each project seems to need new software and
increases in my knowledge to address. I now have two projects involving
water quality that will involve integration of time series analyses,
regression analyses, and spatial modeling of terrain and hydrology. The last
component I've used frequently the past decade or so, the advanced data
analyses and statistical modeling has come up only now.


I do know from prior posts on the matter, that the zoo package seems to
have some of its own approaches to dealing with dates, as compared to base
R. So you may need to be clear on the differentiation in code/functions
required to use some of the package functionality.


  Yes, I can specify the start and end dates using as.Date.


So from a analytic perspective, I would encourage others to chime in with
guidance. Missing data generally has an impact at some level, the extent
of which is going to be specific to the context of the particular analysis
being performed and any assumptions one may be willing to make.


  Missing data between the first sample and the most current one means, in
my contexts, that access to the site was not possible by high water, deep
snow (some sites at > 7,000 feet amsl), or a dry channel in the late summer.
It's ignoring the NAs prior to the first collected samples that I'm hoping
can easily be specified.


There is also the r-sig-finance list:

 https://stat.ethz.ch/mailman/listinfo/r-sig-finance

to which this query may be better suited in terms of gaining a focused
audience in a domain where time series analyses are prevalent.


  I've read some finance/economics-focused time series documents and I
haven't seen the relevance. For example, in the natural environment can we
assume that water samples collected 1 month apart and analyzed for specific
chemical concentrations are autocorrelated? If events such as rain-on-snow
or wildland fires cause a large increase in discharge or clear riparian
vegetation and add soot and chared debris to the stream channel are chemical
concentrations associated with prior ones or to the external influences at
the collection site? Perhaps these data are independent and identically
distributed (iid).

  One of the more interesting (to me, at least) aspects of one of these
projects is to explore the value of the time domain approach for predicting
future values versus the frequency approach to explore periodic and/or
systematic variations in values over time. Regulators tend to focus on the
first and be unaware of the second. At this very early exploratory stage I'm
not sure which approach is more beneficial to my client and the regulators.


There are also some books on using R for time series analyses, some of
which are listed on the "Books" link from the R homepage. It would seem
logical that one or more of them might cover the use of the zoo package,
but that is a guess on my part.


  I am plowing my way through Sumnway and Stoffer's "Time Series Analysis
and Its Applications with R Examples" and have read Cowpertwait and
Metcalf's "Introductory Time Series with R." I need to look again at Zuur et
al. in both "Analyzing Ecological Data" and "Numerical Ecoogy with R"
specifically for discussions of time series. The books and other documents
I've read (with the exception of an article on sandbars in the Colorado
River) are in situations where data are associated with fixed and regular
periods. In the messy real world not only do weather and other conditions
mean irregular data collection dates, but sometimes the regulators decide
that monthly or quarterly samples are no longer requred so semi-annual
samples are the norm thereafter. Biotic data are even worse. :-)

  Zoo seems to be ideal for the irregular, messy data with which I work.
Since I'm quite new to R it will take me time to get up to full speed with
it and zoo. I greatly appreciate the patience and understanding of all of
you who've helped.


I hope that the above is helpful Rich.


  Yep. If you know of references to time series analyses of real-world, messy
data, please share them with me.


I also presume that you got my "final" version of the two functions, with
the corrected data frame based approach. Sorry for the confusion on that
earlier.


  Yes, I did, and there was no confusion as I read them all in the same
session.

Again, many thanks,

Rich

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

Re: [R] Results of applying na.omit on zoo object

2011-09-19 Thread Rich Shepard

On Mon, 19 Sep 2011, Gabor Grothendieck wrote:


For accurate information on the design of zoo read

vignette("zoo-design")

and the other four vignettes and as well as the help files in the zoo
package.


Gabor,

  That's what I've done today. Haven't totally absorbed everything but I do
have a much better understanding of zoo.


plot(z) # multiple panels


  I exceed the 50 panel limit because there are 296 stream/parameter pairs.


plot(z, screen = 1) # all columns on 1 panel


  I did this in lattice and the marginal labels are a solid block. :-)


xyplot also accepts the screen= argument and more info is in ?plot.zoo and
?xyplot.zoo Like most zoo functions they tend to work like core R
functions so if you understand those then the working with the zoo ones
come natural.


  So, the leading and trailing rows that contain only NAs are ignored.
That's great to know! What can I do to get a list of the number associated
with each stream/parameter pair so I can specify which to plot, or which
pair to superimpose?

Thanks,

Rich

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


Re: [R] Alternatives to integrate?

2011-09-19 Thread R. Michael Weylandt
You may perhaps want to be more specific about your problem then "First
option don't gave results as good. May another method ... ?" if you want
help...

I'm not entirely sure what your problem with this sort of discrete numerical
integration is, other than you are making it too hard:

rectIntegrate <- function(f, from, to, ...) {
from <- floor(from); to <- ceiling(to)
n = seq(from, to)
return(sum(do.call(f, c(list(n),...
}

> rectIntegrate(dpois,0,20,3)
[1] 1

> rectIntegrate(function(x,...){dpois(x,...)*x},0,20,3)
[1] 3

So it seems to work pretty well. What was the problem again?

Michael

On Sun, Sep 18, 2011 at 11:40 AM, . .  wrote:

> Hello all,
>
> Returning to this question, I would like to ask for help on how to
> integrate the PMF of a discrete distribution - Michael's guess about
> the most immediate problem (Sep 01, 2011; 2:44pm).
>
> I was thinking in two ways to do this: First is numerically integrate
> the function but sampling it only at integer values. For this, I've
> used the rectangle method of integration:
>
> leftrect <- function(f, from, to, n, ...) {
>h <- (to - from) / n
>sum <- 0
>d <- list(...)
>for(i in seq(from, to-h, h)) {
>dots <- c(list(i), d)
>sum <- sum + do.call(f, dots)
>}
>return(h * sum)
> }
>
> Second option in my mind is to, find and replace the discrete function
> by a continuous version, but I've no idea how to do this.
>
> First option don't gave results as good. May another method ... ? Is
> it possible to specify the sampling points in "Integrate"?
>
> Any comments are welcome.
>
> Thanks in advanve.
>
>
> On Wed, Sep 7, 2011 at 4:47 AM, Berend Hasselman  wrote:
> >
> > . wrote:
> >>
> >> Hi, continuing the improvements...
> >>
> >> I've prepared a new code:
> >>
> >> ddae <- function(individuals, frac, sad, samp="pois", trunc=0, ...) {
> >>   dots <- list(...)
> >>   Compound <- function(individuals, frac, n.species, sad, samp, dots) {
> >> print(c("Size:", length(individuals), "Compound individuals:",
> >> individuals, "End."))
> >> RegDist <- function(n.species, sad, dots) {  # "RegDist" may be
> >> Exponential, Gamma, etc.
> >>   dcom <- paste("d", as.name(sad), sep="")
> >>   dots <- as.list(c(n.species, dots))
> >>   ans <- do.call(dcom, dots)
> >>   return(ans)
> >> }
> >> SampDist <- function(individuals, frac, n.species, samp) {  #
> >> "SampDist" may be Poisson or Negative Binomial
> >>   dcom <- paste("d", samp, sep="")
> >>   lambda <- frac * n.species
> >>   dots <- as.list(c(individuals, lambda))
> >>   ans <- do.call(dcom, dots)
> >>   return(ans)
> >> }
> >> ans <- RegDist(n.species, sad, dots) * SampDist(individuals, frac,
> >> n.species, samp)
> >> return(ans)
> >>   }
> >>   IntegrateScheme <- function(Compound, individuals, frac, sad, samp,
> >> dots) {
> >> print(c("Size:", length(individuals), "Integrate individuals:",
> >> individuals))
> >> ans <- integrate(Compound, 0, 2000, individuals, frac, sad, samp,
> >> dots)$value
> >> return(ans)
> >>   }
> >>   ans <- IntegrateScheme(Compound, individuals, frac, sad, samp, dots)
> >>   return(ans)
> >> }
> >>
> >> ddae(2, 0.05, "exp")
> >>
> >> Now I can't understand what happen to "individuals", why is it
> >> changing in value and size? I've tried to "traceback()" and "debug()",
> >> but I was not smart enough to understand what is going on.
> >>
> >> Could you, please, give some more help?
> >>
> >
> > >From the help for integrate argument f :
> >
> > an R function taking a numeric first argument and returning a numeric
> vector
> > of the same length. .
> >
> > Function Compound is passed to integrate. First argument is "individuals"
> > and integrate is integrating over individuals. That is why it is changing
> in
> > value and size: integrate is only doing what you asked it do.
> >
> > The code is too uncommented and convoluted to supply further comments.
> > You really should simplify this
> >
> > Berend
> >
> >
> > --
> > View this message in context:
> http://r.789695.n4.nabble.com/Alternatives-to-integrate-tp3783624p3795491.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] Plotting Questions (was: Results of applying na.omit on zoo object)

2011-09-19 Thread Gabor Grothendieck
On Mon, Sep 19, 2011 at 5:24 PM, Rich Shepard  wrote:
> On Mon, 19 Sep 2011, Rich Shepard wrote:
>
>>  On a related note, I'm reading the zoo help pages and vignettes but do
>> not see the syntax for specifying which stream/parameter pair I want to
>> plot. What do I read to learn how to do this?
>
>  I think that my reading answered this question, but now I need to refine
> the plots.
>
>  If I run 'plot(z[, 1])' for example I get the stream/parameter pair in
> that is on the left of the top row. This leads to two refinement questions:
>
>  1) How can I get a list of the stream/parameter pairs and their position
> in the summary matrix? and,

names(z) gives the column names of zoo object z.  If the third column
is named SO then z[, 3], z[, "SO"] or z$SO will give that single
column.

>
>  2) How can I determine the earliest and latest dates in each
> stream/parameter pair in which there are data? According to the zoo.quickref
> vignette, start and end provide the earliest and last dates in the index,
> not necessarily for a specific stream/paramater pair. Once I have those
> dates I can specify start = as.Date("") and end =
> as.Date("")

library(zoo)
# test data
z <- zoo(cbind(a = c(NA, 1:3, NA), b = c(NA, NA, 1:3)), Sys.Date() + 1:5)

# get a list of date ranges
lapply(1:ncol(z), function(i) range(time(na.omit(z[, i]

which gives:

[[1]]
[1] "2011-09-21" "2011-09-23"

[[2]]
[1] "2011-09-22" "2011-09-24"


-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

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


Re: [R] Results of applying na.omit on zoo object

2011-09-19 Thread Marc Schwartz

On Sep 19, 2011, at 5:06 PM, Gabor Grothendieck wrote:

> On Mon, Sep 19, 2011 at 5:33 PM, Marc Schwartz  wrote:
>> On Sep 19, 2011, at 4:00 PM, Rich Shepard wrote:
>> 
>>> On Mon, 19 Sep 2011, Marc Schwartz wrote:
>>> 
> Is there a way to omit only those rows where all columns contain 'NA'?
>>> 
 You can look at ?complete.cases for one approach, presuming that it will
 work on zoo objects.
>>> 
>>> Marc,
>>> 
>>>  Do I even need to worry about these NAs? Thanks to Gabor I have a data
>>> frame with 296 stream/parameter sets. Each set begins and ends on a
>>> different date (used as the zoo index).
>>> 
>>>  What I want to do initially is plot the time series for each
>>> stream/parameter to see what each has to tell us. In this case, if there are
>>> years of NAs prior to the fist measurement for that stream/parameter pair,
>>> will this affect anything.
>>> 
>>>  On a related note, I'm reading the zoo help pages and vignettes but do not
>>> see the syntax for specifying which stream/parameter pair I want to plot.
>>> What do I read to learn how to do this?
>>> 
>>> Rich
>> 
>> 
>> Hi Rich,
>> 
>> Let me start by acknowledging that I have little practical experience in 
>> time series analyses, much less proficiency with the zoo package. I just 
>> don't come across them much in clinical trials/studies, at least the ones 
>> that I have been involved with over the past 25+ years.
>> 
>> I do know from prior posts on the matter, that the zoo package seems to have 
>> some of its own approaches to dealing with dates, as compared to base R. So 
>> you may need to be clear on the differentiation in code/functions required 
>> to use some of the package functionality.
> 
> This is not at all the case.  zoo relies on external facilities to
> handle index classes and not its own facilities.
> 
> In some cases zoo extends base facilities or adds new classes to give
> additional possibilities but when this is done the base functionality
> is always extended and never changed.  There are no exceptions to this
> rule.

My apologies then Gabor for perhaps over-generalizing. As noted, I do not use 
zoo, but of course have seen posts previously regarding the conflicts between 
R's as.Date() function and zoo's function of the same name, due to the 
presence/absence of the 'origin' argument. I was not sure if there may be 
others. Thanks for the clarification.

Regards,

Marc

> 
> In fact, the only time zoo functions or methods have any understanding
> of index classes is when interfacing to the outside world since such
> interfacing implies knowledge of how the external objects work.
> 
> For accurate information on the design of zoo read
> 
> vignette("zoo-design")
> 
> and the other four vignettes and as well as the help files in the zoo package.
> 
> Regarding plotting plotting in zoo is similar to in R so NAs are
> ignored in plots.  Thus leading and trailing NAs do not result in
> anything on the plot.  To plot a zoo object try:
> 
> plot(z) # multiple panels
> plot(z, screen = 1) # all columns on 1 panel
> 
> or
> 
> library(lattice)
> xyplot(z)
> 
> xyplot also accepts the screen= argument and more info is in ?plot.zoo
> and ?xyplot.zoo   Like most zoo functions they tend to work like core
> R functions so if you understand those then the working with the zoo
> ones come natural.

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


Re: [R] Results of applying na.omit on zoo object

2011-09-19 Thread Marc Schwartz
Hi Rich,

On Sep 19, 2011, at 5:18 PM, Rich Shepard wrote:

> On Mon, 19 Sep 2011, Marc Schwartz wrote:
> 
>> Let me start by acknowledging that I have little practical experience in
>> time series analyses, much less proficiency with the zoo package. I just
>> don't come across them much in clinical trials/studies, at least the ones
>> that I have been involved with over the past 25+ years.
> 
> Marc,
> 
>  A lot of folks on the mail list here seem to be in the medical side of
> biology. I'm a stream ecologist/fluvial geomorphologist with 30 or so years
> of professional experience and each project seems to need new software and
> increases in my knowledge to address. I now have two projects involving
> water quality that will involve integration of time series analyses,
> regression analyses, and spatial modeling of terrain and hydrology. The last
> component I've used frequently the past decade or so, the advanced data
> analyses and statistical modeling has come up only now.
> 
>> I do know from prior posts on the matter, that the zoo package seems to
>> have some of its own approaches to dealing with dates, as compared to base
>> R. So you may need to be clear on the differentiation in code/functions
>> required to use some of the package functionality.
> 
>  Yes, I can specify the start and end dates using as.Date.

As I noted in my reply to Gabor just now, just be aware of the difference 
between zoo's as.Date() function, which masks base R's function of the same 
name, which also has an 'origin' argument.


> 
>> So from a analytic perspective, I would encourage others to chime in with
>> guidance. Missing data generally has an impact at some level, the extent
>> of which is going to be specific to the context of the particular analysis
>> being performed and any assumptions one may be willing to make.
> 
>  Missing data between the first sample and the most current one means, in
> my contexts, that access to the site was not possible by high water, deep
> snow (some sites at > 7,000 feet amsl), or a dry channel in the late summer.
> It's ignoring the NAs prior to the first collected samples that I'm hoping
> can easily be specified.
> 
>> There is also the r-sig-finance list:
>> 
>> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
>> 
>> to which this query may be better suited in terms of gaining a focused
>> audience in a domain where time series analyses are prevalent.

See comment below…

> 
>  I've read some finance/economics-focused time series documents and I
> haven't seen the relevance. For example, in the natural environment can we
> assume that water samples collected 1 month apart and analyzed for specific
> chemical concentrations are autocorrelated? If events such as rain-on-snow
> or wildland fires cause a large increase in discharge or clear riparian
> vegetation and add soot and chared debris to the stream channel are chemical
> concentrations associated with prior ones or to the external influences at
> the collection site? Perhaps these data are independent and identically
> distributed (iid).
> 
>  One of the more interesting (to me, at least) aspects of one of these
> projects is to explore the value of the time domain approach for predicting
> future values versus the frequency approach to explore periodic and/or
> systematic variations in values over time. Regulators tend to focus on the
> first and be unaware of the second. At this very early exploratory stage I'm
> not sure which approach is more beneficial to my client and the regulators.
> 
>> There are also some books on using R for time series analyses, some of
>> which are listed on the "Books" link from the R homepage. It would seem
>> logical that one or more of them might cover the use of the zoo package,
>> but that is a guess on my part.
> 
>  I am plowing my way through Sumnway and Stoffer's "Time Series Analysis
> and Its Applications with R Examples" and have read Cowpertwait and
> Metcalf's "Introductory Time Series with R." I need to look again at Zuur et
> al. in both "Analyzing Ecological Data" and "Numerical Ecoogy with R"
> specifically for discussions of time series. The books and other documents
> I've read (with the exception of an article on sandbars in the Colorado
> River) are in situations where data are associated with fixed and regular
> periods. In the messy real world not only do weather and other conditions
> mean irregular data collection dates, but sometimes the regulators decide
> that monthly or quarterly samples are no longer requred so semi-annual
> samples are the norm thereafter. Biotic data are even worse. :-)
> 
>  Zoo seems to be ideal for the irregular, messy data with which I work.
> Since I'm quite new to R it will take me time to get up to full speed with
> it and zoo. I greatly appreciate the patience and understanding of all of
> you who've helped.
> 
>> I hope that the above is helpful Rich.
> 
>  Yep. If you know of references to time series analyses of real-world, messy

Re: [R] Results of applying na.omit on zoo object

2011-09-19 Thread Gabor Grothendieck
On Mon, Sep 19, 2011 at 7:42 PM, Marc Schwartz  wrote:
>
> On Sep 19, 2011, at 5:06 PM, Gabor Grothendieck wrote:
>
>> On Mon, Sep 19, 2011 at 5:33 PM, Marc Schwartz  wrote:
>>> On Sep 19, 2011, at 4:00 PM, Rich Shepard wrote:
>>>
 On Mon, 19 Sep 2011, Marc Schwartz wrote:

>> Is there a way to omit only those rows where all columns contain 'NA'?

> You can look at ?complete.cases for one approach, presuming that it will
> work on zoo objects.

 Marc,

  Do I even need to worry about these NAs? Thanks to Gabor I have a data
 frame with 296 stream/parameter sets. Each set begins and ends on a
 different date (used as the zoo index).

  What I want to do initially is plot the time series for each
 stream/parameter to see what each has to tell us. In this case, if there 
 are
 years of NAs prior to the fist measurement for that stream/parameter pair,
 will this affect anything.

  On a related note, I'm reading the zoo help pages and vignettes but do not
 see the syntax for specifying which stream/parameter pair I want to plot.
 What do I read to learn how to do this?

 Rich
>>>
>>>
>>> Hi Rich,
>>>
>>> Let me start by acknowledging that I have little practical experience in 
>>> time series analyses, much less proficiency with the zoo package. I just 
>>> don't come across them much in clinical trials/studies, at least the ones 
>>> that I have been involved with over the past 25+ years.
>>>
>>> I do know from prior posts on the matter, that the zoo package seems to 
>>> have some of its own approaches to dealing with dates, as compared to base 
>>> R. So you may need to be clear on the differentiation in code/functions 
>>> required to use some of the package functionality.
>>
>> This is not at all the case.  zoo relies on external facilities to
>> handle index classes and not its own facilities.
>>
>> In some cases zoo extends base facilities or adds new classes to give
>> additional possibilities but when this is done the base functionality
>> is always extended and never changed.  There are no exceptions to this
>> rule.
>
> My apologies then Gabor for perhaps over-generalizing. As noted, I do not use 
> zoo, but of course have seen posts previously regarding the conflicts between 
> R's as.Date() function and zoo's function of the same name, due to the 
> presence/absence of the 'origin' argument. I was not sure if there may be 
> others. Thanks for the clarification.
>

I think you are misinterpreting what you are reading or else you are
interpreting them as written but the posts themselves are misinformed
and you are unaware of it since you haven't actually used the
software.  zoo does extend as.Date.numeric by adding extra
functionality but as mentioned in my prior post all such extensions
are just that -- extensions and not changes.  If it works in R it also
works with zoo.  There are no exceptions.

-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

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


Re: [R] Results of applying na.omit on zoo object

2011-09-19 Thread Rich Shepard

On Mon, 19 Sep 2011, Marc Schwartz wrote:


Having a better idea of your domain, you might want to consider looking at
the r-sig-ecology list as a supplement to R-help:

 https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


  Done. Thanks.

Rich

--
Richard B. Shepard, Ph.D.  |   Integrity - Credibility - Innovation
Applied Ecosystem Services, Inc.   |Helping Ensure Our Clients' Futures
 Voice: 503-667-4517  Fax: 503-667-8863

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


Re: [R] Results of applying na.omit on zoo object

2011-09-19 Thread Gabor Grothendieck
On Mon, Sep 19, 2011 at 7:42 PM, Marc Schwartz  wrote:
>
> On Sep 19, 2011, at 5:06 PM, Gabor Grothendieck wrote:
>
>> On Mon, Sep 19, 2011 at 5:33 PM, Marc Schwartz  wrote:
>>> On Sep 19, 2011, at 4:00 PM, Rich Shepard wrote:
>>>
 On Mon, 19 Sep 2011, Marc Schwartz wrote:

>> Is there a way to omit only those rows where all columns contain 'NA'?

> You can look at ?complete.cases for one approach, presuming that it will
> work on zoo objects.

 Marc,

  Do I even need to worry about these NAs? Thanks to Gabor I have a data
 frame with 296 stream/parameter sets. Each set begins and ends on a
 different date (used as the zoo index).

  What I want to do initially is plot the time series for each
 stream/parameter to see what each has to tell us. In this case, if there 
 are
 years of NAs prior to the fist measurement for that stream/parameter pair,
 will this affect anything.

  On a related note, I'm reading the zoo help pages and vignettes but do not
 see the syntax for specifying which stream/parameter pair I want to plot.
 What do I read to learn how to do this?

 Rich
>>>
>>>
>>> Hi Rich,
>>>
>>> Let me start by acknowledging that I have little practical experience in 
>>> time series analyses, much less proficiency with the zoo package. I just 
>>> don't come across them much in clinical trials/studies, at least the ones 
>>> that I have been involved with over the past 25+ years.
>>>
>>> I do know from prior posts on the matter, that the zoo package seems to 
>>> have some of its own approaches to dealing with dates, as compared to base 
>>> R. So you may need to be clear on the differentiation in code/functions 
>>> required to use some of the package functionality.
>>
>> This is not at all the case.  zoo relies on external facilities to
>> handle index classes and not its own facilities.
>>
>> In some cases zoo extends base facilities or adds new classes to give
>> additional possibilities but when this is done the base functionality
>> is always extended and never changed.  There are no exceptions to this
>> rule.
>
> My apologies then Gabor for perhaps over-generalizing. As noted, I do not use 
> zoo, but of course have seen posts previously regarding the conflicts between 
> R's as.Date() function and zoo's function of the same name, due to the 
> presence/absence of the 'origin' argument. I was not sure if there may be 
> others. Thanks for the clarification.
>

You do realize that what you are erroneously describing, again, as a
conflict is not a conflict at all?

-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

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


Re: [R] Plotting Questions (was: Results of applying na.omit on zoo object)

2011-09-19 Thread Rich Shepard

On Mon, 19 Sep 2011, Gabor Grothendieck wrote:


names(z) gives the column names of zoo object z.



# get a list of date ranges
lapply(1:ncol(z), function(i) range(time(na.omit(z[, i]


Gabor,

  That combination is just what I was looking for. Now I can start using my
new knowledge on these data.

Much appreciated,

Rich

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 Questions (was: Results of applying na.omit on zoo object)

2011-09-19 Thread Gabor Grothendieck
On Mon, Sep 19, 2011 at 8:34 PM, Rich Shepard  wrote:
> On Mon, 19 Sep 2011, Gabor Grothendieck wrote:
>
>> names(z) gives the column names of zoo object z.
>
>> # get a list of date ranges
>> lapply(1:ncol(z), function(i) range(time(na.omit(z[, i]
>

If z has column names (but do not use this if it does not) then the
following improvement will display them in the output:

> sapply(names(z), function(nm) range(time(na.omit(z[, nm]))), simplify = FALSE)
$a
[1] "2011-09-21" "2011-09-23"

$b
[1] "2011-09-22" "2011-09-24"



-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

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


Re: [R] text matching

2011-09-19 Thread SNV Krishna
Hi,

I noticed the mistake, first thing is double escape, so it should be "\\.BO"
instead of "\.BO" . Second and more important observation is tickers$V1.
Thanks for pointing out David and thank you all for the help.

Best regards,

Krishna

-Original Message-
From: David Winsemius [mailto:dwinsem...@comcast.net] 
Sent: Monday, September 19, 2011 10:10 PM
To: Sarah Goslee
Cc: SNV Krishna; r-help@r-project.org
Subject: Re: [R] text matching


On Sep 19, 2011, at 7:05 AM, Sarah Goslee wrote:

> Hi,
>
> On Mon, Sep 19, 2011 at 6:15 AM, SNV Krishna 
> wrote:
>> Hi All,
>>
>> I have a character vector by name tickers
>>
>>> head(tickers,10)
>>
>>V1
>> 1  ADARSHPL.BO
>> 2AGR.V
>> 3  AGU
>> 4   AGU.TO
>> 5 AIMCO.BO
>> 6  ALUFLUOR.BO
>> 7AMZ.V
>> 8  AVD
>> 9  ANILPROD.BO
>> 10ARIES.BO
>>
>> I would like to extract all elements that has ".BO" in it. I tried
>>
>>> grep("\.BO",tickers)
>> Error: '\.' is an unrecognized escape in character string starting 
>> "\."
>
> You need instead:
>> tickers <- c("A.BO", "BOB", "C.BO")
>> grep("\\.BO", tickers)
> [1] 1 3
>>
>> tickers[grep("\\.BO", tickers)]
> [1] "A.BO" "C.BO"
>
>
>>> grep(".BO",tickers)
>> [1] 1
>
> That's odd; it should have returned many more matches. You may need to 
> check the format of your data.

There are two NOT-oddities at work here. Periods and other special  
characters need to be doubly escaped when used as literals in search   
patterns,  and the vector that needs to be searched is not "tickers"  
but rather "tickers$V1".

That result is because there is only one element in the list named "tickers"
and grep finds that it does have an instance that matches the pattern.
(Despite that fact that it is not searching what the OP thought he was
searching for but rather a more general pattern.)

--
David.


>
>> Could any one please guide me on this. Many thanks for the help
>>
>> Best Regards,
>>
>> Krishna
>>
>
>
> -- 
> Sarah Goslee
> http://www.functionaldiversity.org
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius, MD
West Hartford, CT

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


Re: [R] Results of applying na.omit on zoo object

2011-09-19 Thread Gabor Grothendieck
On Mon, Sep 19, 2011 at 7:52 PM, Marc Schwartz  wrote:
> Hi Rich,
>
> On Sep 19, 2011, at 5:18 PM, Rich Shepard wrote:
>
>> On Mon, 19 Sep 2011, Marc Schwartz wrote:
>>
>>> Let me start by acknowledging that I have little practical experience in
>>> time series analyses, much less proficiency with the zoo package. I just
>>> don't come across them much in clinical trials/studies, at least the ones
>>> that I have been involved with over the past 25+ years.
>>
>> Marc,
>>
>>  A lot of folks on the mail list here seem to be in the medical side of
>> biology. I'm a stream ecologist/fluvial geomorphologist with 30 or so years
>> of professional experience and each project seems to need new software and
>> increases in my knowledge to address. I now have two projects involving
>> water quality that will involve integration of time series analyses,
>> regression analyses, and spatial modeling of terrain and hydrology. The last
>> component I've used frequently the past decade or so, the advanced data
>> analyses and statistical modeling has come up only now.
>>
>>> I do know from prior posts on the matter, that the zoo package seems to
>>> have some of its own approaches to dealing with dates, as compared to base
>>> R. So you may need to be clear on the differentiation in code/functions
>>> required to use some of the package functionality.
>>
>>  Yes, I can specify the start and end dates using as.Date.
>
> As I noted in my reply to Gabor just now, just be aware of the difference 
> between zoo's as.Date() function, which masks base R's function of the same 
> name, which also has an 'origin' argument.

If you are using zoo whether or not you use as.Date's
origin="1970-01-01" argument it won't matter. It will work and give
the same answer in both cases so there is really no good reason to be
particularly aware of this.  You can't easily go wrong.

-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

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


Re: [R] perm.test()

2011-09-19 Thread Jorge I Velez
Hi,

Take a look at example 2 in

require(exactRankTests)
?perm.test

If that does not help at all, could you please let us know what you did and
how?

HTH,
Jorge


On Sun, Sep 18, 2011 at 7:29 PM, song_gpqg <> wrote:

> Hi!
> I am doing a two sample permutation test and trying to find confidence
> interval. perm.test() seems can do that but when the vector contains
> negative numbers it occurs an error. And for perm.test(x,y), elements in x
> can't be more than in y. I am wondering how I can fix these two problems?
> Thanks a lot.
>
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/perm-test-tp3822738p3822738.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.