Re: [R] Stripchart: way to get different colour for each group

2009-12-01 Thread johannes rara
I was probably too vague. I meant that the group variable descirbes
the group (eg. different individuals) and val1 and val2 are just two
variables measured from eg. individual.

> mydata
   val1 val2 group
1   1.1  4.2 0
2   3.2  5.3 1
3   4.1  3.4 0
4   2.5  2.6 1
5   6.2  5.3 0
6   5.3  6.2 1
7   4.5  7.7 0
8   2.2  4.8 1
9   4.7  3.4 0
10  2.7  2.1 1


So, I want to color the points of those groups using different colour.

- J

2009/12/1 David Winsemius :
>
> On Dec 1, 2009, at 12:42 AM, johannes rara wrote:
>
>> Hi,
>>
>> Is there a way to get different colour based on group when plotting
>> stripchart?
>>
>> mydata <- data.frame(val1 = c(1.1, 3.2, 4.1, 2.5, 6.2, 5.3, 4.5, 2.2,
>> 4.7, 2.7), val2 = c(4.2, 5.3, 3.4, 2.6, 5.3, 6.2, 7.7, 4.8, 3.4, 2.1),
>> group = rep(0:1, 5))
>> mydata.stack <- stack(mydata, select=-group)
>>
>> stripchart(values ~ ind,
>>         data=mydata.stack,
>>         vertical=T,
>>         at=c(1.25, 1.75),
>>         pch=15,
>>         col="red")
>>
>> I would like to get different colour for the two groups (based on
>> group variable). I tried something like
>>
>> stripchart(values ~ ind,
>>         data=mydata.stack,
>>         vertical=T,
>>         at=c(1.25, 1.75),
>>         pch=15,
>>         col=c("red", "yeallow")[mydata$group])
>
> Doesn't this work?
>
> stripchart(values ~ ind,
>         data=mydata.stack,
>         vertical=T,
>         at=c(1.25, 1.75),
>         pch=15,
>         col=c("red", "yellow") )
>
> I would not think that mydata$group would be "in sync" with the dataset that
> you are passing to stripchart.
>
> --
> David
>
> David Winsemius, MD
> Heritage Laboratories
> 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.


[R] Odp: Is there a function to test if all the elements in a vector are unique

2009-12-01 Thread Petr PIKAL
Hi


r-help-boun...@r-project.org napsal dne 01.12.2009 04:42:31:

> length(unique(c(1,2,2)))==length(c(1,2,2))
> 
> I use the above test to test if all the elements in a vector are
> unique. But I'm wondering if there is a convenient function to do so
> in R library.

maybe
any(duplicated(c(1,2,2)))

Regards
Petr

> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Stripchart: way to get different colour for each group

2009-12-01 Thread johannes rara
It seems that it is not possible to color points that way using
stripchart. I found a workaround which solved the problem:

stripchart(values ~ ind,
data=mydata.stack,
vertical=T,
at=c(1.25, 1.75),
pch=15,
col="white")
points(rep(1.25, nrow(mydata)), mydata$val1, col=ifelse(mydata$group
== 0, "red", "yellow"), pch=15)
points(rep(1.75, nrow(mydata)), mydata$val2, col=ifelse(mydata$group
== 0, "red", "yellow"), pch=15)

Thanks,

- J

2009/12/1 johannes rara :
> I was probably too vague. I meant that the group variable descirbes
> the group (eg. different individuals) and val1 and val2 are just two
> variables measured from eg. individual.
>
>> mydata
>   val1 val2 group
> 1   1.1  4.2     0
> 2   3.2  5.3     1
> 3   4.1  3.4     0
> 4   2.5  2.6     1
> 5   6.2  5.3     0
> 6   5.3  6.2     1
> 7   4.5  7.7     0
> 8   2.2  4.8     1
> 9   4.7  3.4     0
> 10  2.7  2.1     1
>
>
> So, I want to color the points of those groups using different colour.
>
> - J
>
> 2009/12/1 David Winsemius :
>>
>> On Dec 1, 2009, at 12:42 AM, johannes rara wrote:
>>
>>> Hi,
>>>
>>> Is there a way to get different colour based on group when plotting
>>> stripchart?
>>>
>>> mydata <- data.frame(val1 = c(1.1, 3.2, 4.1, 2.5, 6.2, 5.3, 4.5, 2.2,
>>> 4.7, 2.7), val2 = c(4.2, 5.3, 3.4, 2.6, 5.3, 6.2, 7.7, 4.8, 3.4, 2.1),
>>> group = rep(0:1, 5))
>>> mydata.stack <- stack(mydata, select=-group)
>>>
>>> stripchart(values ~ ind,
>>>         data=mydata.stack,
>>>         vertical=T,
>>>         at=c(1.25, 1.75),
>>>         pch=15,
>>>         col="red")
>>>
>>> I would like to get different colour for the two groups (based on
>>> group variable). I tried something like
>>>
>>> stripchart(values ~ ind,
>>>         data=mydata.stack,
>>>         vertical=T,
>>>         at=c(1.25, 1.75),
>>>         pch=15,
>>>         col=c("red", "yeallow")[mydata$group])
>>
>> Doesn't this work?
>>
>> stripchart(values ~ ind,
>>         data=mydata.stack,
>>         vertical=T,
>>         at=c(1.25, 1.75),
>>         pch=15,
>>         col=c("red", "yellow") )
>>
>> I would not think that mydata$group would be "in sync" with the dataset that
>> you are passing to stripchart.
>>
>> --
>> David
>>
>> David Winsemius, MD
>> Heritage Laboratories
>> 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.


[R] R script From PHP

2009-12-01 Thread Amrit Nandan
Hi,

I have created a web interface to enable analysis for users without having
much to worry about the stats in the backend. In this particular case I have
reached a stage where I have finally created two arrays between which I want
to do an independant samples T Test. I have the arrays ready in a PHP
script, I was hoping if someone could guide me how to invoke R , pass these
arrays into it and finally get the ttest results out.

Any help is much appreciated

[[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] explanation for left-side behaviour

2009-12-01 Thread Antje

Hi there,

I'm pretty sure that it's written down somewhere but I cannot find it so 
far.


The little example shows different approaches to replace a substring. 
Only the last one works. I think it has something to do with the fact 
that "substr" is used on the left side. Can anybody refer to an 
explanation for this behaviour?


Thanks a lot in advance!

Antje



values <- factor(c(rep("abc",3), rep("bcd",3), rep("cde",3)))

substr(values,2,3) <- ".."
substr(as.character(values),2,3) <- ".."

values <- as.character(values)
substr(values,2,3) <- ".."

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

2009-12-01 Thread Amrit

Hi,

I have created a web interface to enable analysis for users without having
much to worry about the stats in the backend. In this particular case I have
reached a stage where I have finally created two arrays between which I want
to do an independant samples T Test. I have the arrays ready in a PHP
script, I was hoping if someone could guide me how to invoke R , pass these
arrays into it and finally get the ttest results out.

Any help is much appreciated
-- 
View this message in context: 
http://n4.nabble.com/R-Script-From-PHP-tp931877p931877.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] Dec. 1, 2009 tip of the day

2009-12-01 Thread John Christie
RE: Compression

Hi R-Users,

You can deal with pretty decent size data sets in R on a relatively new 
computer.  I have one that I have been working with that is a nearly 100MB 
plain text file.  With storage as inexpensive as it is these days that's not 
really all that much data and I could store it just as it is.

Having said that you may want to compress those data files.  There are two 
reasons for this.  One is that while storage is cheap, large files can be 
harder to move around.  Emailing is an example of something that's difficult to 
do with a larger data file.  The other is that, even though your drive has lots 
of capacity and seems to go pretty fast, it is in fact much much slower than 
your CPU.  Recognizing this, Apple built transparent background compression 
into the file system in it's latest operating system.  It speeds things up 
because the computer spends less time accessing the disk (and more time using 
the CPU decompressing and compressing it, but the CPU usually wasn't doing 
anything anyway, and remember, it's much faster).

It turns out R added transparent decompression for certain kinds of compressed 
files in the latest version (2.10).  If you have your files compressed with 
bzip2, xvz, or gzip they can be read into R as if they are plain text files.  
You should have the proper filename extensions.

The command...

myData <- read.table('myFile.gz')  #gzip compressed files have a "gz" extension

Will work just as if 'myFile.gz' were the raw text file.

This is very handy in distributing your analysis scripts and data to co-workers 
at the same time and saves you space on your hard drive.  More importantly, it 
saves you space on flash drives and backups.

John

PS:  My compressed 100MB data file is 500KB.  That's tiny these days.  Programs 
to do the kinds of compression acceptable for R are available for free.  If you 
have a Mac or Linux computer they are built into your command line and are as 
simple as typing gzip 'filename'.

bonus tip:  R has built in facilities for writing out the compressed files as 
well.  "?connections" gets you the help page with basic info.

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


Re: [R] JMP <-> R ?

2009-12-01 Thread Wai-Kuan Yip

Hi Stephen, 

Option 2 I am not sure, but option 3 cannot be used because R is not an OLE
component (Microsoft-objects). You can call JMP and the functions from C#,
VB, Excel, etc. (all the Microsoft related stuff) but can't call R. You just
need to make sure that the common library JMP.TLB is linked up for example
from your VB code. Unfortunately, R doesn't have this linking. Option 1 is
also out, that's for reading input from the serial port. Keep us updated on
your findings!


Wai-Kuan Yip
http://www.deakin.edu.au/~waiyip http://www.deakin.edu.au/~waiyip 



Upton, Stephen C wrote:
> 
> Hi Robert and Wai-Kuan,
> 
> I'd be interested as well. I see in the JMP Scripting Book that there
> appear
> to be 3 possibilities (all in Chapter 11-at least for version 8):
> 1. using a JMP DataFeed object
> 2. using sockets
> 3. OLE automation
> 
> Sockets with something like RServe may be the way to go. I have not tried
> any of the above methods yet but hope the pointers help.
> 
> steve
> 
> Stephen C. Upton
> Research Associate
> SEED (Simulation Experiments & Efficient Designs) Center for Data Farming
> Naval Postgraduate School
> Cell: 831-402-3888
> 
> 
>> From: Wai Kuan Yip 
>> Date: Thu, 26 Nov 2009 17:54:05 -0800 (PST)
>> To: 
>> Subject: Re: [R] JMP <-> R ?
>> 
>> 
>> Hello Robert,
>> 
>> I am also trying to do the same. There is a way to do it using SAS Macro
>> but
>> I am still trying...
>> 
>> You can have a look at this PDF:
>> www.lexjansen.com/phuse/2008/ts/ts01.pdf
>> www.lexjansen.com/phuse/2008/ts/ts01.pdf
>> 
>> Let me know if it works!?
>> 
>> Wai-Kuan Yip
>> Deakin Motion Capture Lab
>> http://www.deakin.edu.au/~waiyip http://www.deakin.edu.au/~waiyip
>> 
>> 
>> Robert Kinley wrote:
>>> 
>>> A wild thought ...
>>> 
>>>...  anyone out there know if it's possible to call R code from JMP ?
>>> 
>>> Bob Kinley - Eli Lilly & co, UK
>>> [[alternative HTML version deleted]]
>>> 
>>> __
>>> R-help@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide
>>> http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>> 
>>> 
>> 
>> -- 
>> View this message in context:
>> http://old.nabble.com/JMP-%3C-%3E-R---tp26527941p26535853.html
>> Sent from the R help mailing list archive at Nabble.com.
>> 
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: http://n4.nabble.com/JMP-R-tp856631p931804.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] multiple column argument in formula (MASS:lda)

2009-12-01 Thread Wai-Kuan Yip

Hello Marcos,
When you use paste(.), it will return a String, and the first argument of
lda(.) does not read a string as formula. 

>lda(Grupo~paste(names(cien[,3:80]),collapse="+"),data=cien)

Here's what I'd do: 

colIndex <- c(1,2,4,5,...) #what ever index of your input data set that you
want to use as variables

#I presume Grupo is the class column (col=3)?
lda(cien[,colIndex], cien[,3])

Hope this helps.. 

Wai-Kuan Yip
http://www.deakin.edu.au/~waiyip http://www.deakin.edu.au/~waiyip 


-- 
View this message in context: 
http://n4.nabble.com/multiple-column-argument-in-formula-MASS-lda-tp931285p931814.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] areg (stata) equivalent in R?

2009-12-01 Thread John K. Williams
hi, i am looking to reproduce a study done in stata in R, where a
regression was done while absorbing a categorical variable.  i am new
to R, i've i installed the design package but haven't been able to
find an applicable function.  thanks for any help.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Distance between sets of points in transformed environmental space

2009-12-01 Thread Corrado
Dear friends,

I have several sets of points in a transformed environmental space. Each set 
of points can be represented as a cloud in the environmental space.

This space is spanned by n coordinates, corresponding to the first n PCs of 36 
PCs of some environmental variables (12 monthly minimum temperatures, 12 
monthly maximum temperature, 12 monthly precipitations).

I would like to calculate a "distance" or dissimilarity between each pair of 
sets of points.

Let's label two of those sets as X,Y, where x is in X and y is in Y. We are 
interested in defining a distance between X and Y. I have thought of using the 
following:

1) The Euclidean distance between the centroids of X and Y. Simple and 
effective but does not give much real information on the actual degree of 
overlapping.
2) The median of the all the distances between all pairs of points (x,y). Same 
problem as (1), partially resolved.
3) The proportion of points of X U Y which fall outside the intersection of 
the convex or concave hulls (defined with a smoothing parameter) of X and Y, 
i.e. C(X) intersect C(Y). Very complicated, and does not necessarily lead to

What do you think? Are there any other approaches worth considering?  

Kind Regards
-- 
Corrado Topi

Global Climate Change & Biodiversity Indicators
Area 18,Department of Biology
University of York, York, YO10 5YW, UK
Phone: + 44 (0) 1904 328645, E-mail: ct...@york.ac.uk

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


Re: [R] Histogram and Density... Sorry for Mispost

2009-12-01 Thread Charlotte Maia
Hi,

I just responded this post, then have just realised it was already
responded to last month with a similar answer.

I'm very sorry, I just started reading this mailing list a few days ago.
Should be more aware of the discussion in future.


-- 
Charlotte Maia
http://sites.google.com/site/maiagx/home

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


Re: [R] Agreement among three or more observers

2009-12-01 Thread Jim Lemon

On 12/01/2009 03:49 PM, John Sorkin wrote:

R 2.9
Windows XP

Is there an R function that will compute a measure of agreement(e.g. Kappa) 
among three or more observers?
   

Hi John,
There are several in the irr package.

Jim

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


Re: [R] areg (stata) equivalent in R?

2009-12-01 Thread Bernardo Rangel Tura
On Mon, 2009-11-30 at 22:20 -0500, John K. Williams wrote:
> hi, i am looking to reproduce a study done in stata in R, where a
> regression was done while absorbing a categorical variable.  i am new
> to R, i've i installed the design package but haven't been able to
> find an applicable function.  thanks for any help.
> 

John,

Do you show a example for this command?

I don't know stata so I don't help you

-- 
Bernardo Rangel Tura, M.D,MPH,Ph.D
National Institute of Cardiology
Brazil

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


Re: [R] Distance between sets of points in transformed environmental space

2009-12-01 Thread Charlotte Maia
Well, here's another naive post from me (hopefully better than the last one).

Firstly I'm not sure computing euclidean distance is that simple. I
would assume temperatures and precipitation would need to be
standardised in some way.

I think the notion of how far away something is, and how distinct
location wise something is, are quite different, so maybe two
measures?

For distance per se, I think your first idea is the best.
Plus simple is always good...

For distinctness, given one one of two sets, for each point, you could
just compute the closest point to it. If the closest point is a member
of the same set, we will call that a + point, if the closest point is
a member of the other set, we will call it a - point. In principle the
measure of distinctness would be the sum of the +'s, however there
might need to be some scaling to take into account the number of
points in each set.

There are also a lot of fancy things out there, so someone will
probably come up with a much fancier (and possibly better) idea than
this.

Well, that's just my rant, before I go to bed.


kind regards
-- 
Charlotte Maia
http://sites.google.com/site/maiagx/home

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


Re: [R] Distance between sets of points in transformed environmental space

2009-12-01 Thread Mario Valle
silhouette coefficients?
It measure for each point how similar is to its cluster other points and how 
dissimilar
from the points of other clusters.

P.N. Tam, M. Steinbach, V. Kumar, Introduction to data mining, Addison-Wesley, 
2006 page 541

Hope it helps.
mario

Charlotte Maia wrote:
> Well, here's another naive post from me (hopefully better than the last one).
> 
> Firstly I'm not sure computing euclidean distance is that simple. I
> would assume temperatures and precipitation would need to be
> standardised in some way.
> 
> I think the notion of how far away something is, and how distinct
> location wise something is, are quite different, so maybe two
> measures?
> 
> For distance per se, I think your first idea is the best.
> Plus simple is always good...
> 
> For distinctness, given one one of two sets, for each point, you could
> just compute the closest point to it. If the closest point is a member
> of the same set, we will call that a + point, if the closest point is
> a member of the other set, we will call it a - point. In principle the
> measure of distinctness would be the sum of the +'s, however there
> might need to be some scaling to take into account the number of
> points in each set.
> 
> There are also a lot of fancy things out there, so someone will
> probably come up with a much fancier (and possibly better) idea than
> this.
> 
> Well, that's just my rant, before I go to bed.
> 
> 
> kind regards

-- 
Ing. Mario Valle
Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle
Swiss National Supercomputing Centre (CSCS)  | Tel:  +41 (91) 610.82.60
v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax:  +41 (91) 610.82.82

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


Re: [R] R script From PHP

2009-12-01 Thread Marianne Promberger
Amrit Nandan  01-Dec-09 08:27:
> I have created a web interface to enable analysis for users without having
> much to worry about the stats in the backend. In this particular case I have
> reached a stage where I have finally created two arrays between which I want
> to do an independant samples T Test. I have the arrays ready in a PHP
> script, I was hoping if someone could guide me how to invoke R , pass these
> arrays into it and finally get the ttest results out.

Maybe look at
http://cran.r-project.org/doc/FAQ/R-FAQ.html#R-Web-Interfaces

and littler
http://dirk.eddelbuettel.com/code/littler.html
might come in handy as well.

-- 
Marianne Promberger PhD, King's College London
http://promberger.info
R version 2.10.0 (2009-10-26)
Ubuntu 9.04

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


Re: [R] Distance between sets of points in transformed environmental space

2009-12-01 Thread Corrado
Thanks Mario! (Oppure grazie Mario?)

- Can those silhouette coefficients be used for distances between sets or only 
for distances point to set?

- Where did you get the other post you attached? It did not come up when I 
searched the mailing list!
 

Best,

On Tuesday 01 December 2009 10:31:47 Mario Valle wrote:
> silhouette coefficients?
> It measure for each point how similar is to its cluster other points and
>  how dissimilar from the points of other clusters.
> 
> P.N. Tam, M. Steinbach, V. Kumar, Introduction to data mining,
>  Addison-Wesley, 2006 page 541
> 
> Hope it helps.
>   mario
> 
> Charlotte Maia wrote:
> > Well, here's another naive post from me (hopefully better than the last
> > one).
> >
> > Firstly I'm not sure computing euclidean distance is that simple. I
> > would assume temperatures and precipitation would need to be
> > standardised in some way.
> >
> > I think the notion of how far away something is, and how distinct
> > location wise something is, are quite different, so maybe two
> > measures?
> >
> > For distance per se, I think your first idea is the best.
> > Plus simple is always good...
> >
> > For distinctness, given one one of two sets, for each point, you could
> > just compute the closest point to it. If the closest point is a member
> > of the same set, we will call that a + point, if the closest point is
> > a member of the other set, we will call it a - point. In principle the
> > measure of distinctness would be the sum of the +'s, however there
> > might need to be some scaling to take into account the number of
> > points in each set.
> >
> > There are also a lot of fancy things out there, so someone will
> > probably come up with a much fancier (and possibly better) idea than
> > this.
> >
> > Well, that's just my rant, before I go to bed.
> >
> >
> > kind regards
> 





-- 
Corrado Topi

Global Climate Change & Biodiversity Indicators
Area 18,Department of Biology
University of York, York, YO10 5YW, UK
Phone: + 44 (0) 1904 328645, E-mail: ct...@york.ac.uk

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


[R] R 2.10.1 Scheduled for December 14, 2009

2009-12-01 Thread Peter Dalgaard
This is to announce that we plan to release R version 2.10.1 on Monday,
December 14, 2009.

Release procedures start Friday, December 4.

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) and the tarballs can be picked up at

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

a little later.

Binary builds are expected to appear starting Monday, December 7 at the
latest.

For the Core Team
Peter Dalgaard


-- 
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - (p.dalga...@biostat.ku.dk)  FAX: (+45) 35327907

___
r-annou...@stat.math.ethz.ch 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] Trouble with read.table(clipboard)

2009-12-01 Thread Diogo B. Provete
Hi every one,
I'm having some problems with the function read.table(clipboard). I got a
spread sheet in the Excel, and than I make a command+C in the Mac, but the R
returns the message that there is no object in the clipboard.
What could have happened?

Thanks,
Diogo

[[alternative HTML version deleted]]

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


[R] R with atlas in ubuntu karmic 64

2009-12-01 Thread Jose Quesada
Hi,

I'm trying to install R with atlas in ubuntu karmic 64. I do a lot of
matrix operations so I need performance.

Doing

 grep sse2 /proc/cpuinfo

tells me tha my CPU supports SSE2.
But I don't see libatlas3gf-sse2 in the package repositories.

Also, there seem to be some gotchas on how to install atlas, even the
vanilla one, as described here:
http://thread.gmane.org/gmane.comp.lang.r.general/159634/focus=159867

I didn't understand what Bill Dunlap proposes as a solution.
Has anyone installed R with atlas in ubuntu karmic 64? Maybe writing a
howto on a blog post would be a good idea. If I manage to install it, I
will...

Best,
-Jose
-- 
=== I'm minimizing email (can write w one hand only) so if you have
something that requires a long answer, please mail me a time slot and
tel. number and I'll call you. Thanks for your patience.===
Jose Quesada, PhD.

Max Planck Institute,
Center for Adaptive Behavior and Cognition -ABC-,
Lentzeallee 94, office 224, 14195 Berlin

http://www.josequesada.name/
http://twitter.com/Quesada

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


[R] Odp: Trouble with read.table(clipboard)

2009-12-01 Thread Petr PIKAL
Hi

did you put your spreadsheet to the clipboard? I  am not sure if trick 
with Ctrl-C followed by read.delim("clipboard") functions in Mac so maybe 
you will need to try some more elaborated procedure which was suggested 
several times here and I believe is also mentioned in Data import/export 
manual.

Regards
Petr

r-help-boun...@r-project.org napsal dne 01.12.2009 12:29:24:

> Hi every one,
> I'm having some problems with the function read.table(clipboard). I got 
a
> spread sheet in the Excel, and than I make a command+C in the Mac, but 
the R
> returns the message that there is no object in the clipboard.
> What could have happened?
> 
> Thanks,
> Diogo
> 
>[[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] kernlab's ksvm method freeze

2009-12-01 Thread Heiko Strathmann
Sorry i forget to paste it.
But it should be there in another mail.

Also, the suggested trick fixes the problem in with the given workspace,
but still fails in another one (where the kernel matrix IS positive
definite)
http://www-stud.uni-due.de/~sfhestra/freeze_on_pos_def_matrix.tar.gz

This is not a R-workspace, but my zipped working directory.
The file I run is parameterSearch.R.
The freeze happens more or less late in the search, but not at a fixed
point.


Heiko

Am Dienstag, den 01.12.2009, 10:25 +0100 schrieb Uwe Ligges:
> 
> Heiko Strathmann wrote:
> > Hello again,
> > 
> > i got this message from the maintainer:
> 
> And which part is from the maintainer?
> 
> Uwe
> 
> 
> 
> > 
> > Am Montag, den 30.11.2009, 11:22 +0100 schrieb Heiko Strathmann:
> >> Ok, i reported it.
> >> thanks for trying it out again.
> >>
> >> Am 30. November 2009 11:06 schrieb Uwe Ligges
> >> :
> >> My apologies, that must have been a copy&paste error and the
> >> essential argument got lost. I can reproduce it now under
> >> R-2.10.0 both Windows and Linux.
> >> 
> >> Please report your findings to the package maintainer who
> >> might be able to debug this under Linux (probably easier than
> >> under Windows).
> >> 
> >> Best,
> >> 
> >> 
> >> Uwe Ligges
> >> 
> >> 
> >> 
> >> 
> >> 
> >> 
> >> Heiko Strathmann wrote:
> >> I tried out the code you wrote, it also works for me,
> >> but it lacks a
> >> parameter i use in my code.
> >> 
> >> The problem (at this computer) seems to be this
> >> "cross"-parameter of
> >> ksvm - if I, for example, add the parameter cross=10,
> >> i get the old
> >> problem:
> >> 
> >> library("kernlab")
> >> load("freeze_workspace.RDATA")
> >> replicate(10, ksvm(kernel="matrix", kernelMatrix,
> >> trainingDataYs, type="C-svc", C=2, cross=10))
> >> 
> >> gets me a frozen R process, CTRL-C does not work
> >> anymore, and the only thing left is to kill it.
> >> 
> >> (for cross < 4, the thing still works)
> >> 
> >> (I also just reinstalled my Ubuntu and R)
> >> 
> >> Heiko Strathmann
> >> 
> >> 
> >> Am Sonntag, den 29.11.2009, 19:52 +0100 schrieb Uwe
> >> Ligges:
> >> Heiko Strathmann wrote:
> >> Hello uwe,
> >> Thanks for trying out.
> >> the freeze happens after about 10 to
> >> 20 iterations. Did you try as many?
> >> I just tried again:
> >> 
> >> library("kernlab")
> >> load("freeze_workspace.RDATA")
> >> replicate(100, ksvm(kernel="matrix",
> >> kernelMatrix, trainingDataYs, type="C-svc",
> >> C=2))
> >> 
> >> and everything is still fine (same on Linux).
> >> 
> >> Uwe Ligges
> >> 
> >> 
> >> 
> >> Am Sonntag, den 29.11.2009, 17:22
> >> +0100 schrieb Uwe Ligges:
> >> I just tried
> >> 
> >> ksvm(kernel="matrix",
> >> kernelMatrix, trainingDataYs,
> >> type="C-svc", cross=10, C=2)
> >> 
> >> several times on both
> >> workspaces and both returned
> >> some results after a couple of
> >> seconds under the same
> >> versions (R version 2.10.0 and
> >> kernlab 0.9-9.) under Windows
> >> XP.
> >> 
> >> There mist be something else
> >> going on...
> >> 
> >> Best wishes,
> >> Uwe Ligges
> >> 
> 

Re: [R] R script From PHP

2009-12-01 Thread Hrishi Mittal

Hi Amrit,

I believe you can you use the PHP system command to call Rscript or R CMD. I
don't know much PHP but this page might be useful -
http://php.net/manual/en/function.system.php.

You might also want to look at rapache -
http://biostat.mc.vanderbilt.edu/rapache/

Good luck with your project and do post a link to your webpage when you get
it running.
-- 
View this message in context: 
http://n4.nabble.com/R-script-From-PHP-tp931996p932141.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] Modular inverses

2009-12-01 Thread Hans W Borchers
SJ Robson-Davis  bristol.ac.uk> writes:

> 
> I want to find the inverse of an integer k mod p (prime.) Is there a
> function that can do this for me? I know i could simply write (k^(p-2)) %%
> p, but i need to do this for large primes (above 100) and this gives the
> warning message:
> probable complete loss of accuracy in modulus
> so this method does not work. Any ideas?

Computing the inverse mod p applying brute force may not be a very elegant
approach.  With a little knowledge from number theory it is clear that the
(so-called) extended Euclidean algorithms will provide the modular inverse
efficiently, even for very big numbers.

In R the extended Euclidean algorithm is available in the gmp package, see
the 'gcdex' function.  The modular inverse can also directly be calculated
with the 'inv' function, e.g. the invers of 101 modulo 11 is:

library(gmp)
as.numeric(inv(as.bigz(101), as.bigz(11)))
# [1] 499499501

It's not even necessary that p is prime, only that k and p are relatively
prime.  The integers can be bigger than those handled by double-precision
arithmetics.

Regards
Hans Werner

> Thanks,
> 
> Samuel
> 
> --
>

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


Re: [R] R script From PHP

2009-12-01 Thread Romain Francois

On 12/01/2009 12:48 PM, Hrishi Mittal wrote:

Hi Amrit,

I believe you can you use the PHP system command to call Rscript or R CMD. I
don't know much PHP but this page might be useful -
http://php.net/manual/en/function.system.php.

You might also want to look at rapache -
http://biostat.mc.vanderbilt.edu/rapache/

Good luck with your project and do post a link to your webpage when you get
it running.


There is also a simple php client to Rserve in the next version of 
Rserve. http://www.rforge.net/Rserve/index.html


--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://tr.im/FtUu : new package : highlight
|- http://tr.im/EAD5 : LondonR slides
`- http://tr.im/BcPw : celebrating R commit #5

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


Re: [R] Excel-Export

2009-12-01 Thread Erich Neuwirth
The rcom package allows you to access the Excel object model from within
R. So you can do essentially you can either do manually or by VBA from
within Excel also from R.
Formatting cells should not be too hard.





Hans-Peter Suter wrote:
> 2009/11/24 Kevin Wright :
>> If had done a little searching before posting, you surely would have found
>> this link
>> https://stat.ethz.ch/pipermail/r-help/2008-July/169149.html
>> which describes how to create .xls files that are customized any way that
>> you desire.
> 
> Manually convert to html, then manually hack around with a
> texteditor..., not a good idea, imho. RDCOM is better.
> 
> Hans-Peter
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
Erich Neuwirth, University of Vienna
Faculty of Computer Science
Computer Supported Didactics Working Group
Visit our SunSITE at http://sunsite.univie.ac.at
Phone: +43-1-4277-39464 Fax: +43-1-4277-39459

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] assigning values to parameters, based on different names

2009-12-01 Thread Jannis

Dear R help community,


I have tumbleled across some problem quite often and could not find a
solution for it (or was not able to google the right terms).

I am wondering whether there is a way to tell R to assign a value of
parameter X to parameter B while the actual name of parameter X is given
by parameter C. Like this:



C<-"name of parameter X"

B<- parameter X which has the name == C


In that way I can easily change the value of  C and then assign the
values of different parameters to B, depending on which name I entered
and saved as parameter C, which would help me dealing with automatic
loops a lot!

Like this:


for (i in 1:3)
{
  C<-c("name1","name2","name3")[i]
  B<-'parameter with name C'
}

Appreciate any suggestions!

Best
Jannis

P.S. And thanks to all for the amazing answers posted to r-help that
already helped me so many times!

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


Re: [R] assigning values to parameters, based on different names

2009-12-01 Thread Karl Ove Hufthammer
On Tue, 01 Dec 2009 12:45:18 + Jannis  wrote:
> I am wondering whether there is a way to tell R to assign a value of
> parameter X to parameter B while the actual name of parameter X is given
> by parameter C. Like this:

Yes. See ?get.

-- 
Karl Ove Hufthammer

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


Re: [R] Odp: Trouble with read.table(clipboard)

2009-12-01 Thread David Winsemius

On the Mac, reading from the the clipboard is:
pipe("pbpaste")
... and writing to the clipboard:
pipe("pbcopy", "w")
?pipe
--  
David

On Dec 1, 2009, at 6:43 AM, Petr PIKAL wrote:


Hi

did you put your spreadsheet to the clipboard? I  am not sure if trick
with Ctrl-C followed by read.delim("clipboard") functions in Mac so  
maybe
you will need to try some more elaborated procedure which was  
suggested
several times here and I believe is also mentioned in Data import/ 
export

manual.

Regards
Petr

r-help-boun...@r-project.org napsal dne 01.12.2009 12:29:24:


Hi every one,
I'm having some problems with the function read.table(clipboard). I  
got

a
spread sheet in the Excel, and than I make a command+C in the Mac,  
but

the R

returns the message that there is no object in the clipboard.
What could have happened?

Thanks,
Diogo

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


David Winsemius, MD
Heritage Laboratories
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.


[R] Using two (...) in a function

2009-12-01 Thread Márcio Resende

Hello R-Helpers,
I am not sure if it is a very simple question but I would like to use two
(...) in a function, for example,

this is a script where I would like to input the variable names (in one of
the (...)) and the variances associated to those variables which are not
calculated in the script because there is a specific software to calculate
it (the other (...))

data <- function ("DAP", "ALT", var1, var2){   My wish was to do
somethin like function (...,...){
Vec <- matrix(c("DAP", "ALT"))###here it would came the first (...) Vec
<- matrix(c(...))
for (i in seq(along <- Vec)){
caracteristica <- Vec[i]

varF <- if (caracteristica == "DAP") var1 else var2##here I would like
to do something like #if   ###caracteristica == variable1) variance1 else if
(caracteristica == variable2) variance2 else ...
}
}

but to turn this in a function, I would like to replace ("DAP", "ALT") by
any variable and var1, var2 to any variance, and not only necessary 2, for
example
data ("variable1","variable2","variable3", "variance1", "variance2",
"variance3")

I am not sure if I made myself clear and if this is an "answerable" doubt,
anyway thank you vey much
Márcio
-- 
View this message in context: 
http://n4.nabble.com/Using-two-in-a-function-tp932200p932200.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] Using two (...) in a function

2009-12-01 Thread Benilton Carvalho
isn't it simpler just to pass two vectors, say v1 and v2, in which one contains 
the object names and the other has the associated variances? (btw, "data" isn't 
a good function name)

myData <- function(v1, v2){
  Vec <- matrix(v1)
  varF <- v2
}

I may have misunderstood your question, but IMHO all you need is to guarantee 
that v1 and v2 are properly aligned.

Cheers,

b

On Dec 1, 2009, at 11:30 AM, Márcio Resende wrote:

> 
> Hello R-Helpers,
> I am not sure if it is a very simple question but I would like to use two
> (...) in a function, for example,
> 
> this is a script where I would like to input the variable names (in one of
> the (...)) and the variances associated to those variables which are not
> calculated in the script because there is a specific software to calculate
> it (the other (...))
> 
> data <- function ("DAP", "ALT", var1, var2){   My wish was to do
> somethin like function (...,...){
> Vec <- matrix(c("DAP", "ALT"))###here it would came the first (...) Vec
> <- matrix(c(...))
> for (i in seq(along <- Vec)){
> caracteristica <- Vec[i]
> 
> varF <- if (caracteristica == "DAP") var1 else var2##here I would like
> to do something like #if   ###caracteristica == variable1) variance1 else if
> (caracteristica == variable2) variance2 else ...
> }
> }
> 
> but to turn this in a function, I would like to replace ("DAP", "ALT") by
> any variable and var1, var2 to any variance, and not only necessary 2, for
> example
> data ("variable1","variable2","variable3", "variance1", "variance2",
> "variance3")
> 
> I am not sure if I made myself clear and if this is an "answerable" doubt,
> anyway thank you vey much
> Márcio
> --
> View this message in context: 
> http://n4.nabble.com/Using-two-in-a-function-tp932200p932200.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] How to plot log-log figure using R?

2009-12-01 Thread Zhijiang Wang

   --

Best wishes,
Zhijiang Wang

PHD Student
Room 212, Science buliding,
The International WIC Institute,
College of Computer Science and Technology,
Beijing University of Technology,
Beijing, China.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Using two (...) in a function

2009-12-01 Thread David Winsemius
Seems pretty doubtful that a construction like (..., ...) is going to  
be accepted by the R interpreter. However, if you construct your  
function to handle two objects of equal length, one for the variable  
names and the other for their variances, there should be no problem.  
If yu want to handle a more general situation where you are passing an  
arbitrary list and want the first half interpreted as variable names  
and the second half interpreted as variances, well that can be  
programmed as well.


On Dec 1, 2009, at 8:30 AM, Márcio Resende wrote:



Hello R-Helpers,
I am not sure if it is a very simple question but I would like to  
use two

(...) in a function, for example,

this is a script where I would like to input the variable names (in  
one of
the (...)) and the variances associated to those variables which are  
not
calculated in the script because there is a specific software to  
calculate

it (the other (...))

data <- function ("DAP", "ALT", var1, var2){   My wish was to do
somethin like function (...,...){
Vec <- matrix(c("DAP", "ALT"))###here it would came the first  
(...) Vec

<- matrix(c(...))
for (i in seq(along <- Vec)){
caracteristica <- Vec[i]

varF <- if (caracteristica == "DAP") var1 else var2##here I  
would like
to do something like #if   ###caracteristica == variable1) variance1  
else if

(caracteristica == variable2) variance2 else ...
}
}


At this point, because of the bizarrely placed comment symbols,  I am  
wondering if our mail clients are using the same end-of-line markers.




but to turn this in a function, I would like to replace ("DAP",  
"ALT") by
any variable and var1, var2 to any variance, and not only necessary  
2, for

example
data ("variable1","variable2","variable3", "variance1", "variance2",
"variance3")

I am not sure if I made myself clear and if this is an "answerable"  
doubt,

anyway thank you vey much
Márcio
--



David Winsemius, MD
Heritage Laboratories
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] How to plot log-log figure using R?

2009-12-01 Thread David Winsemius


?plot.default

On Dec 1, 2009, at 8:39 AM, Zhijiang Wang wrote:


snipped


David Winsemius, MD
Heritage Laboratories
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.


[R] Loop doesn't work

2009-12-01 Thread Trafim
Hi everybody,

I have the following problem, the following code seems to run only once for
i and j and for k from one to M.
Doesn't R for increase the argument by itself?

for (i in 1:N){
 for (j in 1:(Tk-1)){
  if((XGrid[i] < Xk[j+1])&(Xk[j] <= XGrid[i])){
for (k in 1:M){
   if ((RBins[k]<=Rk[j+1])&(Rk[j+1]https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Calculation of Central Moments

2009-12-01 Thread Ravi Varadhan

You should learn to use search facilities in R, for example:

RSiteSearch("central moments")

Ravi.



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

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


- Original Message -
From: Maithili Shiva 
Date: Tuesday, December 1, 2009 2:09 am
Subject: [R] Calculation of Central Moments
To: r-help@r-project.org


> Dear R helpers
> 
> If for a given data, I need to calculate Mean, Standard Deviation, 
> Mode, Median, Skewness, Kurtosis, is there any package in R, which 
> will calculate these moments?
> 
> Individually I can calculate these, but if there is any function which 
> will calculate these at a stretch, please let me know.
> 
> Maithili
> 
> 
> 
[[elided Yahoo spam]]
> Homepage. 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list
> 
> PLEASE do read the posting guide 
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Calculation of Central Moments

2009-12-01 Thread Jorge Ivan Velez
Hi Maithili,

Here is a suugestion:

R> install.packages('fBasics')
R> require(fBasics)
R> set.seed(123)
R> x <- rnorm(100)
R> basicStats(x)

HTH,
Jorge


On Tue, Dec 1, 2009 at 2:08 AM, Maithili Shiva <> wrote:

> Dear R helpers
>
> If for a given data, I need to calculate Mean, Standard Deviation, Mode,
> Median, Skewness, Kurtosis, is there any package in R, which will calculate
> these moments?
>
> Individually I can calculate these, but if there is any function which will
> calculate these at a stretch, please let me know.
>
> Maithili
>
>
>
>  The INTERNET now has a personality. YOURS! See your Yahoo! Homepage.
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] Using two (...) in a function

2009-12-01 Thread Gabor Grothendieck
Just pass a named vector

f <- function(vars) { nms <- names(vec); ... }

f(c(DAP = var1, ALT = var2))


2009/12/1 Márcio Resende 

>
> Hello R-Helpers,
> I am not sure if it is a very simple question but I would like to use two
> (...) in a function, for example,
>
> this is a script where I would like to input the variable names (in one of
> the (...)) and the variances associated to those variables which are not
> calculated in the script because there is a specific software to calculate
> it (the other (...))
>
> data <- function ("DAP", "ALT", var1, var2){   My wish was to do
> somethin like function (...,...){
> Vec <- matrix(c("DAP", "ALT"))###here it would came the first (...) Vec
> <- matrix(c(...))
> for (i in seq(along <- Vec)){
> caracteristica <- Vec[i]
>
> varF <- if (caracteristica == "DAP") var1 else var2##here I would like
> to do something like #if   ###caracteristica == variable1) variance1 else
> if
> (caracteristica == variable2) variance2 else ...
> }
> }
>
> but to turn this in a function, I would like to replace ("DAP", "ALT") by
> any variable and var1, var2 to any variance, and not only necessary 2, for
> example
> data ("variable1","variable2","variable3", "variance1", "variance2",
> "variance3")
>
> I am not sure if I made myself clear and if this is an "answerable" doubt,
> anyway thank you vey much
> Márcio
> --
> View this message in context:
> http://n4.nabble.com/Using-two-in-a-function-tp932200p932200.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] rpart: how to assign observations to nodes in regression trees

2009-12-01 Thread Terry Therneau
help('rpart.object') will give you information on the return value from
rpart.  I think you want the 'where' portion.
 
For new data help('predict.rpart') gives the predicted results.

Terry T

--
Hi,
I am building a regression tree (method=anova) by using rpart package
and as a final result I get the final leaves characterized by
different means and standard deviations for the dependent variable.
However, differently from the classification tree for categorical
variables I cannot find a way to assign each observation to a leaf,
i.e. I can find no frame whcih contains the observation id coupled to
the leaf id. I also cannot found where the leaves id are stored.
Is there someone which can help me?
Regards, Diego.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Starting estimates for nls Exponential Fit

2009-12-01 Thread Anto

Hello everyone,

I have come across a bit of an odd problem: I am currently analysing data
PCR reaction data of which part is behaving exponential. I would like to fit
the exponential part to the following:

y0 + alpha * E^t

In which Y0 is the groundphase, alpha a fluorescence factor, E the
efficiency of the reaction & t is time (in cycles)

I can get this to work for most of my reactions, but part fails the nls fit
(Convergence failure: iteration limit reached without convergence). This
mainly has to do with the starting estimates for the nls function. I have
used various 'smart' ways of calculating starting estimates (grid searches,
optim(), etc.) but however close the starting estimates are to the actual
values, nls still fails for many datasets.

The weirdest thing is, I have one set of starting estimates (alpha= 0.5 and
E=1.85) which are totaly arbitray and these DO work for, say 99% of the
datasets. I don't know why this is and I don't why my 'good estimates' do
not work. I am desperatly seeking a way of calculating working starting
estimates for my nls function. Can anybody give me a hand?

thanks,

Anto

R version 2.9.2

example dataset:

ExponValues
[1] 2018.34 2012.54 2018.85 2023.52 2054.58 2132.61 2247.17 2468.32 2778.47

ExponCycles
[1] 17 18 19 20 21 22 23 24 25


Example starting estimate calculation

Y0 <- ExponValues[1]

E <-
weighted.mean((ExponValues-eY0)[-1][-1]/(ExponValues-eY0)[-1][-(length(ExponValues)-1)],(1-abs(seq(-1,1,length=(length(ExponValues)-2)))^3)^3)
alpha <- 
weighted.mean((ExponValues[-1]-ExponValues[-length(ExponValues)])/((E^ExponCycles[-1])-(E^ExponCycles[-length(ExponCycles)])),(1-abs(seq(-1,1,length=(length(ExponCycles)-1)))^3)^3)


Optional parameter optimisation:

Esp <-
optim(c(Y0=eY0,a=alpha,E=E),function(x){return(sum(abs(ExponValues-(x[1]+x[2]*x[3]^ExponCycles})$par


nls function:

Emodel<-try(nls(ExponValues ~ (Y0 + a*(E^ExponCycles)) , start= Esp,
algorithm="port"),silent=TRUE)
-- 
View this message in context: 
http://n4.nabble.com/Starting-estimates-for-nls-Exponential-Fit-tp932230p932230.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] Adding and Multiplying two Unevaluated Expressions

2009-12-01 Thread Benjamin Müller
HI,

As I'm trying to compute Taylor series, I'm having problems in adding and 
multiplying unevaluated expressions. I searched for a solution but found none.

my Taylor function works fine for evaluating functions as you can see here:


rTaylorVal=function(exp,x0,dx,n) {

ls=list(x=x0)

newexp=eval(exp,ls)

exp0=exp

for (i in 1:n){
exp0=D(exp0,"x")
newexp=newexp+eval(exp0,ls)/factorial(i)*dx^i
}

return(newexp)

}

Where exp is an expression like exp=expression(x^2*sin(x)), x0 is the 
startvalue, dx the difference between startvalue and searched value and n is 
the length of the series.

So I tried to remove dx as a value, to get a Taylor series expression, but it 
doesn't work as simple multiplication (*) and accumulation (+) is not good for 
expressions.

That's my point so far, now my question:

Is it actually possible to add and/or multiply expressions, and how?

Thank you so far.

Benjamin Müller
Geographer (B.Sc.)


-- 
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!

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


Re: [R] Loop doesn't work

2009-12-01 Thread Barry Rowlingson
On Tue, Dec 1, 2009 at 2:01 PM, Trafim  wrote:
> Hi everybody,
>
> I have the following problem, the following code seems to run only once for
> i and j and for k from one to M.
> Doesn't R for increase the argument by itself?
>
> for (i in 1:N){
>  for (j in 1:(Tk-1)){
>  if((XGrid[i] < Xk[j+1])&(Xk[j] <= XGrid[i])){
>        for (k in 1:M){
>           if ((RBins[k]<=Rk[j+1])&(Rk[j+1]              GR[k] <- +1
>           }
>        }
>  }
>  }
> }
>

 Of course it does. Try this, which is something we call a complete
reproducible example:

N=10
for(i in 1:N){
 print(i)
}

How do we know your N isn't 1 and your Tk isn't 2?

Barry

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


Re: [R] Loop doesn't work

2009-12-01 Thread Trafim
Thanks a lot!
I was afraid smth is wrong with my R syntaxis.

On Tue, Dec 1, 2009 at 3:58 PM, Barry Rowlingson <
b.rowling...@lancaster.ac.uk> wrote:

> On Tue, Dec 1, 2009 at 2:01 PM, Trafim  wrote:
> > Hi everybody,
> >
> > I have the following problem, the following code seems to run only once
> for
> > i and j and for k from one to M.
> > Doesn't R for increase the argument by itself?
> >
> > for (i in 1:N){
> >  for (j in 1:(Tk-1)){
> >  if((XGrid[i] < Xk[j+1])&(Xk[j] <= XGrid[i])){
> >for (k in 1:M){
> >   if ((RBins[k]<=Rk[j+1])&(Rk[j+1] >  GR[k] <- +1
> >   }
> >}
> >  }
> >  }
> > }
> >
>
>  Of course it does. Try this, which is something we call a complete
> reproducible example:
>
> N=10
> for(i in 1:N){
>  print(i)
> }
>
> How do we know your N isn't 1 and your Tk isn't 2?
>
> Barry
>

[[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] Calculation of Central Moments

2009-12-01 Thread William Revelle

At 9:09 AM -0500 12/1/09, Jorge Ivan Velez wrote:

Hi Maithili,

Here is a suugestion:

R> install.packages('fBasics')
R> require(fBasics)
R> set.seed(123)
R> x <- rnorm(100)
R> basicStats(x)

HTH,
Jorge



or, try the describe function in psych.
However, neither fBasics nor describe will report the mode.







On Tue, Dec 1, 2009 at 2:08 AM, Maithili Shiva <> wrote:


 Dear R helpers

 If for a given data, I need to calculate Mean, Standard Deviation, Mode,
 Median, Skewness, Kurtosis, is there any package in R, which will calculate
 these moments?

 Individually I can calculate these, but if there is any function which will
 calculate these at a stretch, please let me know.

 Maithili



  The INTERNET now has a personality. YOURS! See your Yahoo! Homepage.
[[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.



--
William Revelle http://personality-project.org/revelle.html
Professor   http://personality-project.org/personality.html
Department of Psychology http://www.wcas.northwestern.edu/psych/
Northwestern University http://www.northwestern.edu/
Use R for psychology   http://personality-project.org/r
It is 5 minutes to midnight http://www.thebulletin.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] "subset" or "condition" as argument to a function

2009-12-01 Thread Santosh
Dear R gurus..
I had tried out some suggestions sent to me privately..and unfortunately,
they did not work..

To use a condiition in a subset, the associated dataframe needs to be
attached and detached, which I found cumbersome to use if using more than 1
dataframe (with different dimensions) with same condition. I would highly
appreciate your suggestions to overcome this problem.. Please see my example
of usage I am trying to implement. Please note that the "cond' takes in the
character instead of logical values...

cond1 <- 'group==1&sales>200'
cond2 <- 'group==2&sales>200'
cond3 <- 'group==3&sales>200'

d1 <- subset(dat,subset=cond1)
plot(y~x,data=dat,subset=cond1,type='b')
lines(y~x,data=dat,subset=cond2)
points(y~x,data=dat,subset=paste(cond1,cond2,sep='&'),col='blue')
points(y~x,data=d1,subset=cond3,col='red')

If I try the above, I get the following error message:
*Error in subset.data.frame(dat, cond) : 'subset' must evaluate to logical*

If you could also suggest references implementing similar code, I would
highly appreciate it.
Thanks so much,

Santosh

On Mon, Nov 23, 2009 at 6:38 PM, Santosh  wrote:

> Thanks... I would try it out..
>  -santosh
>
>
> On Sat, Nov 21, 2009 at 12:04 AM, Bernardo Rangel Tura <
> t...@centroin.com.br> wrote:
>
>> On Fri, 2009-11-20 at 17:40 -0800, Santosh wrote:
>> > Dear Rxperts!
>> >
>> > I was wondering if it is possible to write a function which can take in
>> > argument of a subset or condition.. Of course, I am aware of the
>> alternate
>> > methods like coplot, par.plot, xyplot etc... I am specifically
>> interested in
>> > using conditions/subsets with "plot"..
>> >
>> > A simple fragmented example is shown here..
>> >
>> > pltit <- function(y,x,dat,dat1,dat2,sbst) {
>> > plot(y~x, data=dat, subset=sbst)
>> > lines(y~x,data=dat1, subset=subst)
>> > points(y~x,data=dat2,subset=subst)
>> > }
>> >
>> > pltit(profit,weeks,dat=zone1, sbst='group==1&sales>200')
>> >
>> > Could you also suggest pointers/references/examples on efficient ways to
>> > plot simulated data overlaid with observed data?
>> >
>> > Have a good weekend!
>>
>>
>>
>

[[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] median for time data

2009-12-01 Thread uvilla

Hi everybody

How do I do to calculate the median and average of a colum of time data like
this: "8:50:10". I also need to plot the time difference between two colums
Thanks a lot
-- 
View this message in context: 
http://n4.nabble.com/median-for-time-data-tp932287p932287.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] "subset" or "condition" as argument to a function

2009-12-01 Thread David Winsemius


On Dec 1, 2009, at 10:38 AM, Santosh wrote:


Dear R gurus..
I had tried out some suggestions sent to me privately..and  
unfortunately,

they did not work..

To use a condiition in a subset, the associated dataframe needs to be
attached and detached, which I found cumbersome to use if using more  
than 1
dataframe (with different dimensions) with same condition. I would  
highly
appreciate your suggestions to overcome this problem.. Please see my  
example
of usage I am trying to implement. Please note that the "cond' takes  
in the

character instead of logical values...

cond1 <- 'group==1&sales>200'
cond2 <- 'group==2&sales>200'
cond3 <- 'group==3&sales>200'


I do not see that you have _ever_ offered a sample dataset in this  
thread, so this suggestion remains untested. Please report what  
happens when you try:




d1 <- subset(dat,subset=eval(parse(text=cond1)))
plot(y~x,data=dat,subset=eval(parse(text=cond1)),type='b')
lines(y~x,data=dat,subset=eval(parse(text=cond2)))
points 
(y 
~ 
x 
,data 
=dat,subset=eval(parse(text=paste(cond1,cond2)),sep='&'),col='blue')

points(y~x,data=d1,subset=eval(parse(text=cond3)),col='red')

If I try the above, I get the following error message:
*Error in subset.data.frame(dat, cond) : 'subset' must evaluate to  
logical*


If you could also suggest references implementing similar code, I  
would

highly appreciate it.


?parse


Thanks so much,

Santosh

On Mon, Nov 23, 2009 at 6:38 PM, Santosh   
wrote:



Thanks... I would try it out..
-santosh


On Sat, Nov 21, 2009 at 12:04 AM, Bernardo Rangel Tura <
t...@centroin.com.br> wrote:


On Fri, 2009-11-20 at 17:40 -0800, Santosh wrote:

Dear Rxperts!

I was wondering if it is possible to write a function which can  
take in

argument of a subset or condition.. Of course, I am aware of the

alternate

methods like coplot, par.plot, xyplot etc... I am specifically

interested in

using conditions/subsets with "plot"..

A simple fragmented example is shown here..

pltit <- function(y,x,dat,dat1,dat2,sbst) {
plot(y~x, data=dat, subset=sbst)
lines(y~x,data=dat1, subset=subst)
points(y~x,data=dat2,subset=subst)
}

pltit(profit,weeks,dat=zone1, sbst='group==1&sales>200')

Could you also suggest pointers/references/examples on efficient  
ways to

plot simulated data overlaid with observed data?

Have a good weekend!






--

.


David Winsemius, MD
Heritage Laboratories
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] "subset" or "condition" as argument to a function

2009-12-01 Thread David Winsemius


On Dec 1, 2009, at 10:55 AM, David Winsemius wrote:



On Dec 1, 2009, at 10:38 AM, Santosh wrote:


Dear R gurus..
I had tried out some suggestions sent to me privately..and  
unfortunately,

they did not work..

To use a condiition in a subset, the associated dataframe needs to be
attached and detached, which I found cumbersome to use if using  
more than 1
dataframe (with different dimensions) with same condition. I would  
highly
appreciate your suggestions to overcome this problem.. Please see  
my example
of usage I am trying to implement. Please note that the "cond'  
takes in the

character instead of logical values...

cond1 <- 'group==1&sales>200'
cond2 <- 'group==2&sales>200'
cond3 <- 'group==3&sales>200'


I do not see that you have _ever_ offered a sample dataset in this  
thread, so this suggestion remains untested. Please report what  
happens when you try:




d1 <- subset(dat,subset=eval(parse(text=cond1)))
plot(y~x,data=dat,subset=eval(parse(text=cond1)),type='b')
lines(y~x,data=dat,subset=eval(parse(text=cond2)))
points 
(y 
~ 
x 
,data 
=dat,subset=eval(parse(text=paste(cond1,cond2)),sep='&'),col='blue')


Probably needs to be tested with this modification:
points(y~x, data=dat, subset=eval(parse(text=paste(cond1,cond2,  
sep='&'))), col='blue')



points(y~x,data=d1,subset=eval(parse(text=cond3)),col='red')

If I try the above, I get the following error message:
*Error in subset.data.frame(dat, cond) : 'subset' must evaluate to  
logical*


If you could also suggest references implementing similar code, I  
would

highly appreciate it.


?parse


Thanks so much,

Santosh

On Mon, Nov 23, 2009 at 6:38 PM, Santosh   
wrote:



Thanks... I would try it out..
-santosh


On Sat, Nov 21, 2009 at 12:04 AM, Bernardo Rangel Tura <
t...@centroin.com.br> wrote:


On Fri, 2009-11-20 at 17:40 -0800, Santosh wrote:

Dear Rxperts!

I was wondering if it is possible to write a function which can  
take in

argument of a subset or condition.. Of course, I am aware of the

alternate

methods like coplot, par.plot, xyplot etc... I am specifically

interested in

using conditions/subsets with "plot"..

A simple fragmented example is shown here..

pltit <- function(y,x,dat,dat1,dat2,sbst) {
plot(y~x, data=dat, subset=sbst)
lines(y~x,data=dat1, subset=subst)
points(y~x,data=dat2,subset=subst)
}

pltit(profit,weeks,dat=zone1, sbst='group==1&sales>200')

Could you also suggest pointers/references/examples on efficient  
ways to

plot simulated data overlaid with observed data?

Have a good weekend!






--

.


David Winsemius, MD
Heritage Laboratories
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.


David Winsemius, MD
Heritage Laboratories
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] How to quit unwanted execution immediately?

2009-12-01 Thread Peng Yu
The delay that I observe is when I type ctrl+C after I str() a long
list. Since str() comes from the core R installation, maybe it should
be improved?

> R can or cannot response immediately depending on the underlying C sources.
> If the underlying source code is written carefully enough, there are more or
> less regular checks for events such as this one.
> If you are using some contributed package, it may be an issue in this
> package's source code.
>
> Best wishes,
> Uwe Ligges
>
>
>
>
> Peng Yu wrote:
>>
>> Occasionally, I start a command (taking long time to finish) that I
>> did not really want to start. I type 'ctrl+C' to try to quit the
>> execution. However, R does not quit the execution of the command
>> immediately. I'm wondering if R could response to ctrl+C immediately.
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/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] "subset" or "condition" as argument to a function

2009-12-01 Thread David Winsemius


On Dec 1, 2009, at 11:04 AM, David Winsemius wrote:



On Dec 1, 2009, at 10:59 AM, David Winsemius wrote:



On Dec 1, 2009, at 10:55 AM, David Winsemius wrote:



On Dec 1, 2009, at 10:38 AM, Santosh wrote:


Dear R gurus..
I had tried out some suggestions sent to me privately..and  
unfortunately,

they did not work..

To use a condiition in a subset, the associated dataframe needs  
to be
attached and detached, which I found cumbersome to use if using  
more than 1
dataframe (with different dimensions) with same condition. I  
would highly
appreciate your suggestions to overcome this problem.. Please see  
my example
of usage I am trying to implement. Please note that the "cond'  
takes in the

character instead of logical values...

cond1 <- 'group==1&sales>200'
cond2 <- 'group==2&sales>200'
cond3 <- 'group==3&sales>200'


I do not see that you have _ever_ offered a sample dataset in this  
thread, so this suggestion remains untested. Please report what  
happens when you try:




d1 <- subset(dat,subset=eval(parse(text=cond1)))
plot(y~x,data=dat,subset=eval(parse(text=cond1)),type='b')
lines(y~x,data=dat,subset=eval(parse(text=cond2)))
points 
(y 
~ 
x 
,data 
= 
dat,subset=eval(parse(text=paste(cond1,cond2)),sep='&'),col='blue')


Probably needs to be tested with this modification:
points(y~x, data=dat, subset=eval(parse(text=paste(cond1,cond2,  
sep='&'))), col='blue')


And I am further guessing that the set will be empty since it seems  
likely that:
  
^unlikely^
(group==1 & group==2) == TRUE, so perhaps you should reconsider your  
logic.






points(y~x,data=d1,subset=eval(parse(text=cond3)),col='red')

If I try the above, I get the following error message:
*Error in subset.data.frame(dat, cond) : 'subset' must evaluate  
to logical*


If you could also suggest references implementing similar code, I  
would

highly appreciate it.


?parse


Thanks so much,

Santosh

On Mon, Nov 23, 2009 at 6:38 PM, Santosh   
wrote:



Thanks... I would try it out..
-santosh


On Sat, Nov 21, 2009 at 12:04 AM, Bernardo Rangel Tura <
t...@centroin.com.br> wrote:


On Fri, 2009-11-20 at 17:40 -0800, Santosh wrote:

Dear Rxperts!

I was wondering if it is possible to write a function which  
can take in

argument of a subset or condition.. Of course, I am aware of the

alternate

methods like coplot, par.plot, xyplot etc... I am specifically

interested in

using conditions/subsets with "plot"..

A simple fragmented example is shown here..

pltit <- function(y,x,dat,dat1,dat2,sbst) {
plot(y~x, data=dat, subset=sbst)
lines(y~x,data=dat1, subset=subst)
points(y~x,data=dat2,subset=subst)
}

pltit(profit,weeks,dat=zone1, sbst='group==1&sales>200')

Could you also suggest pointers/references/examples on  
efficient ways to

plot simulated data overlaid with observed data?

Have a good weekend!






--

.


David Winsemius, MD
Heritage Laboratories
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.


David Winsemius, MD
Heritage Laboratories
West Hartford, CT



David Winsemius, MD
Heritage Laboratories
West Hartford, CT



David Winsemius, MD
Heritage Laboratories
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] "subset" or "condition" as argument to a function

2009-12-01 Thread David Winsemius


On Dec 1, 2009, at 10:59 AM, David Winsemius wrote:



On Dec 1, 2009, at 10:55 AM, David Winsemius wrote:



On Dec 1, 2009, at 10:38 AM, Santosh wrote:


Dear R gurus..
I had tried out some suggestions sent to me privately..and  
unfortunately,

they did not work..

To use a condiition in a subset, the associated dataframe needs to  
be
attached and detached, which I found cumbersome to use if using  
more than 1
dataframe (with different dimensions) with same condition. I would  
highly
appreciate your suggestions to overcome this problem.. Please see  
my example
of usage I am trying to implement. Please note that the "cond'  
takes in the

character instead of logical values...

cond1 <- 'group==1&sales>200'
cond2 <- 'group==2&sales>200'
cond3 <- 'group==3&sales>200'


I do not see that you have _ever_ offered a sample dataset in this  
thread, so this suggestion remains untested. Please report what  
happens when you try:




d1 <- subset(dat,subset=eval(parse(text=cond1)))
plot(y~x,data=dat,subset=eval(parse(text=cond1)),type='b')
lines(y~x,data=dat,subset=eval(parse(text=cond2)))
points 
(y 
~ 
x 
,data 
=dat,subset=eval(parse(text=paste(cond1,cond2)),sep='&'),col='blue')


Probably needs to be tested with this modification:
points(y~x, data=dat, subset=eval(parse(text=paste(cond1,cond2,  
sep='&'))), col='blue')


And I am further guessing that the set will be empty since it seems  
likely that:
 (group==1 & group==2) == TRUE, so perhaps you should reconsider your  
logic.






points(y~x,data=d1,subset=eval(parse(text=cond3)),col='red')

If I try the above, I get the following error message:
*Error in subset.data.frame(dat, cond) : 'subset' must evaluate to  
logical*


If you could also suggest references implementing similar code, I  
would

highly appreciate it.


?parse


Thanks so much,

Santosh

On Mon, Nov 23, 2009 at 6:38 PM, Santosh   
wrote:



Thanks... I would try it out..
-santosh


On Sat, Nov 21, 2009 at 12:04 AM, Bernardo Rangel Tura <
t...@centroin.com.br> wrote:


On Fri, 2009-11-20 at 17:40 -0800, Santosh wrote:

Dear Rxperts!

I was wondering if it is possible to write a function which can  
take in

argument of a subset or condition.. Of course, I am aware of the

alternate

methods like coplot, par.plot, xyplot etc... I am specifically

interested in

using conditions/subsets with "plot"..

A simple fragmented example is shown here..

pltit <- function(y,x,dat,dat1,dat2,sbst) {
plot(y~x, data=dat, subset=sbst)
lines(y~x,data=dat1, subset=subst)
points(y~x,data=dat2,subset=subst)
}

pltit(profit,weeks,dat=zone1, sbst='group==1&sales>200')

Could you also suggest pointers/references/examples on  
efficient ways to

plot simulated data overlaid with observed data?

Have a good weekend!






--

.


David Winsemius, MD
Heritage Laboratories
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.


David Winsemius, MD
Heritage Laboratories
West Hartford, CT



David Winsemius, MD
Heritage Laboratories
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.


[R] Package is loaded but functions are not exported

2009-12-01 Thread Saptarshi Guha
Hello,
I wrote a package, which in the NAMESPACE file exports functions like this:

exportPattern("^\\rh")

On R-2.8 (Linux, 64), upon loading the package I have the rh functions present.

On R-2.10, Mac OS X, (32 bit), it builds, loads, but the functions are not
loaded, i.e the only function is rhyper (which is not from my package).

Is there something wrong with my package setup?

Regards
Saptarshi

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


Re: [R] Package is loaded but functions are not exported

2009-12-01 Thread Saptarshi Guha
As a followup, i can do things Package:::rh*, there just no exported.

On Tue, Dec 1, 2009 at 11:18 AM, Saptarshi Guha
 wrote:
> Hello,
> I wrote a package, which in the NAMESPACE file exports functions like this:
>
> exportPattern("^\\rh")
>
> On R-2.8 (Linux, 64), upon loading the package I have the rh functions 
> present.
>
> On R-2.10, Mac OS X, (32 bit), it builds, loads, but the functions are not
> loaded, i.e the only function is rhyper (which is not from my package).
>
> Is there something wrong with my package setup?
>
> Regards
> Saptarshi
>

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

2009-12-01 Thread Ubuntu Diego
I saw different specifications for Random Effects and I'm confused about 
the use of "/" and  the use of "(0+...|)" .
Let say we have a nested structure where some countries have some 
several plants in different states and we measure the reaction to a drug.


The list of Countries = USA, France, Italy
The States for USA = Michigan, Florida, California
The States for France =  Paris, Orleans
The States for Italy =  Venezia, Sienna, Florence, Rome, Napoli , Sicilia

Plants were classified as High and Low

is this the way to specify a possible model ?

lmer(Reaction ~ Drug + (1| Country / State / Plant) , data)

or should I use something like this
A) lmer(Reaction ~ Drug + (0| Country / State / Plant) , data)
B) lmer(Reaction ~ Drug + (1| Country ) + (0+Country | State / Plant) , 
data)
C) lmer(Reaction ~ Drug + (1| Country ) + (0+Country | State / Plant) + 
(0+Country + State | Plant), data)
D) lmer(Reaction ~ Drug + (1| Country ) + (0+Country | State ) + 
(0+Country + State | Plant), data)


Thanks

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


Re: [R] Package is loaded but functions are not exported

2009-12-01 Thread Duncan Murdoch

On 01/12/2009 11:18 AM, Saptarshi Guha wrote:

Hello,
I wrote a package, which in the NAMESPACE file exports functions like this:

exportPattern("^\\rh")
  


That's a very strange pattern to be using.  Why do you want those 
backslashes there?  If you just want to export items whose names start 
with "rh", you should use the pattern "^rh".


Duncan Murdoch

On R-2.8 (Linux, 64), upon loading the package I have the rh functions present.

On R-2.10, Mac OS X, (32 bit), it builds, loads, but the functions are not
loaded, i.e the only function is rhyper (which is not from my package).

Is there something wrong with my package setup?

Regards
Saptarshi

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Package is loaded but functions are not exported

2009-12-01 Thread Romain Francois

You probably just want : exportPattern("^rh")

What did you expect the backslash to do ?

On 12/01/2009 05:18 PM, Saptarshi Guha wrote:


Hello,
I wrote a package, which in the NAMESPACE file exports functions like this:

exportPattern("^\\rh")

On R-2.8 (Linux, 64), upon loading the package I have the rh functions present.

On R-2.10, Mac OS X, (32 bit), it builds, loads, but the functions are not
loaded, i.e the only function is rhyper (which is not from my package).

Is there something wrong with my package setup?

Regards
Saptarshi


--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://tr.im/FtUu : new package : highlight
|- http://tr.im/EAD5 : LondonR slides
`- http://tr.im/BcPw : celebrating R commit #5

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


[R] eigenvalues of complex matrices

2009-12-01 Thread David Scherrer
Dear all,

I want to compute the eigenvalues of a complex matrix for some statistics.
Comparing it to its matlab/octave sibling, I don't get the same eigenvalues
in R computing it from the exact same matrix.

In R, I used eigen() and arpack() that give different eigenvalues. In
matlab/octave I used eig() and eigs() that give out the same eigenvalues but
different to the R ones.
For real matrices, R and matlab/octave are consistent.

Does anybody know what could go on here and how I could get consistent
eigenvalues in R? Since I definitely want to do the analysis in R.

Many thanks,
David

[[alternative HTML version deleted]]

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


Re: [R] Package is loaded but functions are not exported

2009-12-01 Thread Saptarshi Guha
I have no idea why I used the \\, the perils of copy and pasting from
some other package or source .
So, heres the thing, did R regex interpreter change? How come my
export stopped working?
Thank you
Regards
Saptarshi


On Tue, Dec 1, 2009 at 11:28 AM, Romain Francois
 wrote:
> You probably just want : exportPattern("^rh")
>
> What did you expect the backslash to do ?
>
> On 12/01/2009 05:18 PM, Saptarshi Guha wrote:
>>
>> Hello,
>> I wrote a package, which in the NAMESPACE file exports functions like
>> this:
>>
>> exportPattern("^\\rh")
>>
>> On R-2.8 (Linux, 64), upon loading the package I have the rh functions
>> present.
>>
>> On R-2.10, Mac OS X, (32 bit), it builds, loads, but the functions are not
>> loaded, i.e the only function is rhyper (which is not from my package).
>>
>> Is there something wrong with my package setup?
>>
>> Regards
>> Saptarshi
>
> --
> Romain Francois
> Professional R Enthusiast
> +33(0) 6 28 91 30 30
> http://romainfrancois.blog.free.fr
> |- http://tr.im/FtUu : new package : highlight
> |- http://tr.im/EAD5 : LondonR slides
> `- http://tr.im/BcPw : celebrating R commit #5
>
>

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


[R] problem with RWeka Weka_control RandomForest

2009-12-01 Thread Itziar Frades Alzueta
Dear All,



I am finding trouble trying to guild a Wrapper using random forest to
evaluate the subsets:



I do:

nombi <-
make_Weka_filter("weka/filters/supervised/attribute/AttributeSelection")

datbin<- nombi(gene ~., data=X1X2X4X5W, control =Weka_control(
S=list("weka.attributeSelection.GeneticSearch"),
E=list("weka.attributeSelection.WrapperSubsetEval"),B =
list("weka.classifiers.trees.RandomForest")))



I get the following error:

Exception in thread "main" java.lang.Exception: Illegal options: -B
weka.classifiers.trees.RandomForest

  at weka.core.Utils.checkForRemainingOptions(Unknown Source)

  at
weka.filters.supervised.attribute.AttributeSelection.setOptions(Unknown
Source)



I tryied specifying more parameters and got the same error:



I do:

datbin<- nombi(gene ~., data=X1X2X3X4W,  control =Weka_control(
S=list("weka.attributeSelection.GeneticSearch"),
E=list("weka.attributeSelection.WrapperSubsetEval"),B =
list("weka.classifiers.trees.RandomForest -F 5 -T 0.01 -R 1 -- -I 10 -K
0 -S 1")))



I get the following error:

Exception in thread "main" java.lang.Exception: Illegal options: -B
weka.classifiers.trees.RandomForest -F 5 -T 0.01 -R 1 -- -I 10 -K 0 -S 1


  at weka.core.Utils.checkForRemainingOptions(Unknown Source)

  at
weka.filters.supervised.attribute.AttributeSelection.setOptions(Unknown
Source)




 

 

 



This e-mail is from CIC bioGUNE. The e-mail and any files transmitted with it 
are confidential and intended solely for the use of the individual or entity to 
whom they are addressed. Any unauthorised dissemination or copying of this 
e-mail or its attachments, and any use or disclosure of any information 
contained in them, is strictly prohibited and may be illegal. If you have 
received this e-mail in error, please notify or telephone + 34 944 06 13 00 and 
delete it from your system.

[[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] "subset" or "condition" as argument to a function

2009-12-01 Thread William Dunlap
> -Original Message-
> From: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] On Behalf Of Santosh
> Sent: Tuesday, December 01, 2009 7:39 AM
> To: r-help@r-project.org
> Subject: Re: [R] "subset" or "condition" as argument to a function
> 
> Dear R gurus..
> I had tried out some suggestions sent to me privately..and 
> unfortunately,
> they did not work..
> 
> To use a condiition in a subset, the associated dataframe needs to be
> attached and detached, which I found cumbersome to use if 
> using more than 1
> dataframe (with different dimensions) with same condition. I 
> would highly
> appreciate your suggestions to overcome this problem.. Please 
> see my example
> of usage I am trying to implement. Please note that the 
> "cond' takes in the
> character instead of logical values...
> 
> cond1 <- 'group==1&sales>200'
> cond2 <- 'group==2&sales>200'
> cond3 <- 'group==3&sales>200'
> 
> d1 <- subset(dat,subset=cond1)
> plot(y~x,data=dat,subset=cond1,type='b')

The subset argument to plot (and many similar functions)
must be given as a literal expression, not a string that
could be parsed into an expression nor the name of an object
containing an expression nor a function call that evaluates
to an expression.  This design is handy for interactive
use but painful in programatic use.  One way to deal with
it is to use do.call, which evaluates all the arguments to
the function and then calls the function with the arguments
given literally.  Replace the above plot call with
  do.call("plot", list(y~x,data=dat,subset=parse(text=cond1),type='b'))
and see if you get what you want.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 

> lines(y~x,data=dat,subset=cond2)
> points(y~x,data=dat,subset=paste(cond1,cond2,sep='&'),col='blue')
> points(y~x,data=d1,subset=cond3,col='red')
> 
> If I try the above, I get the following error message:
> *Error in subset.data.frame(dat, cond) : 'subset' must 
> evaluate to logical*
> 
> If you could also suggest references implementing similar 
> code, I would
> highly appreciate it.
> Thanks so much,
> 
> Santosh
> 
> On Mon, Nov 23, 2009 at 6:38 PM, Santosh 
>  wrote:
> 
> > Thanks... I would try it out..
> >  -santosh
> >
> >
> > On Sat, Nov 21, 2009 at 12:04 AM, Bernardo Rangel Tura <
> > t...@centroin.com.br> wrote:
> >
> >> On Fri, 2009-11-20 at 17:40 -0800, Santosh wrote:
> >> > Dear Rxperts!
> >> >
> >> > I was wondering if it is possible to write a function 
> which can take in
> >> > argument of a subset or condition.. Of course, I am aware of the
> >> alternate
> >> > methods like coplot, par.plot, xyplot etc... I am specifically
> >> interested in
> >> > using conditions/subsets with "plot"..
> >> >
> >> > A simple fragmented example is shown here..
> >> >
> >> > pltit <- function(y,x,dat,dat1,dat2,sbst) {
> >> > plot(y~x, data=dat, subset=sbst)
> >> > lines(y~x,data=dat1, subset=subst)
> >> > points(y~x,data=dat2,subset=subst)
> >> > }
> >> >
> >> > pltit(profit,weeks,dat=zone1, sbst='group==1&sales>200')
> >> >
> >> > Could you also suggest pointers/references/examples on 
> efficient ways to
> >> > plot simulated data overlaid with observed data?
> >> >
> >> > Have a good weekend!
> >>
> >>
> >>
> >
> 
>   [[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] problem with RWeka Weka_control RandomForest

2009-12-01 Thread Achim Zeileis

On Tue, 1 Dec 2009, Itziar Frades Alzueta wrote:


Dear All,



I am finding trouble trying to guild a Wrapper using random forest to
evaluate the subsets:



I do:

nombi <-
make_Weka_filter("weka/filters/supervised/attribute/AttributeSelection")

datbin<- nombi(gene ~., data=X1X2X4X5W, control =Weka_control(
S=list("weka.attributeSelection.GeneticSearch"),
E=list("weka.attributeSelection.WrapperSubsetEval"),B =
list("weka.classifiers.trees.RandomForest")))



I get the following error:

Exception in thread "main" java.lang.Exception: Illegal options: -B
weka.classifiers.trees.RandomForest


The error is fairly explicit, isn't it? There is no -B option for 
AttributeSelection, see

  WOW("weka/filters/supervised/attribute/AttributeSelection")

hth,
Z


 at weka.core.Utils.checkForRemainingOptions(Unknown Source)

 at
weka.filters.supervised.attribute.AttributeSelection.setOptions(Unknown
Source)



I tryied specifying more parameters and got the same error:



I do:

datbin<- nombi(gene ~., data=X1X2X3X4W,  control =Weka_control(
S=list("weka.attributeSelection.GeneticSearch"),
E=list("weka.attributeSelection.WrapperSubsetEval"),B =
list("weka.classifiers.trees.RandomForest -F 5 -T 0.01 -R 1 -- -I 10 -K
0 -S 1")))



I get the following error:

Exception in thread "main" java.lang.Exception: Illegal options: -B
weka.classifiers.trees.RandomForest -F 5 -T 0.01 -R 1 -- -I 10 -K 0 -S 1


 at weka.core.Utils.checkForRemainingOptions(Unknown Source)

 at
weka.filters.supervised.attribute.AttributeSelection.setOptions(Unknown
Source)












This e-mail is from CIC bioGUNE. The e-mail and any files transmitted with it 
are confidential and intended solely for the use of the individual or entity to 
whom they are addressed. Any unauthorised dissemination or copying of this 
e-mail or its attachments, and any use or disclosure of any information 
contained in them, is strictly prohibited and may be illegal. If you have 
received this e-mail in error, please notify or telephone + 34 944 06 13 00 and 
delete it from your system.

[[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] median for time data

2009-12-01 Thread Jannis

Hi,


try to convert this to the R time format "POSIXct" or "POSIXlt" via 
strptime(). Then you can simply substract them. I am not sure whether a 
median can be calculated though (should be possible as POSIXct stores 
the value as seconds since 1970)


Best
Jannis

uvilla schrieb:

Hi everybody

How do I do to calculate the median and average of a colum of time data like
this: "8:50:10". I also need to plot the time difference between two colums
Thanks a lot


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


[R] problem with RWeka Weka_control RandomForest

2009-12-01 Thread Itziar Frades Alzueta






Dear All,



I am finding trouble trying to build a Wrapper using random forest to
evaluate the subsets:



I do:

nombi <-
make_Weka_filter("weka/filters/supervised/attribute/AttributeSelection")

datbin<- nombi(gene ~., data=X1X2X4X5W, control =Weka_control(
S=list("weka.attributeSelection.GeneticSearch"),
E=list("weka.attributeSelection.WrapperSubsetEval"),B =
list("weka.classifiers.trees.RandomForest")))



I get the following error:

Exception in thread "main" java.lang.Exception: Illegal options: -B
weka.classifiers.trees.RandomForest

  at weka.core.Utils.checkForRemainingOptions(Unknown Source)

  at
weka.filters.supervised.attribute.AttributeSelection.setOptions(Unknown
Source)



I tryied specifying more parameters and got the same error:



I do:

datbin<- nombi(gene ~., data=X1X2X3X4W,  control =Weka_control(
S=list("weka.attributeSelection.GeneticSearch"),
E=list("weka.attributeSelection.WrapperSubsetEval"),B =
list("weka.classifiers.trees.RandomForest -F 5 -T 0.01 -R 1 -- -I 10 -K
0 -S 1")))



I get the following error:

Exception in thread "main" java.lang.Exception: Illegal options: -B
weka.classifiers.trees.RandomForest -F 5 -T 0.01 -R 1 -- -I 10 -K 0 -S 1


  at weka.core.Utils.checkForRemainingOptions(Unknown Source)

  at
weka.filters.supervised.attribute.AttributeSelection.setOptions(Unknown
Source)



Regards,

Itziar frades




 

 

 



This e-mail is from CIC bioGUNE. The e-mail and any files transmitted with it 
are confidential and intended solely for the use of the individual or entity to 
whom they are addressed. Any unauthorised dissemination or copying of this 
e-mail or its attachments, and any use or disclosure of any information 
contained in them, is strictly prohibited and may be illegal. If you have 
received this e-mail in error, please notify or telephone + 34 944 06 13 00 and 
delete it from your system.

[[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] time series - month value

2009-12-01 Thread Alfredo Alessandrini
Hi,

I've this time series:

> ts_evi
Time Series:
Start = c(2000, 4)
End = c(2002, 7)
Frequency = 23
 [1] 0.1948306 0.1930461 0.1905792 0.1848909 0.1893624 0.1811400 0.1678140
 [8] 0.1750714 0.3100132 0.3495946 0.4103353 0.4973740 0.4937490 0.4031435
[15] 0.3503787 0.2755022 0.2304617 0.2284854 0.2166127 0.2046744 0.2002691
[22] 0.1935237 0.1782539 0.1827050 0.1771288 0.1736177 0.1674035 0.1673382
[29] 0.1676010 0.1735880 0.1734465 0.2634710 0.2833674 0.3706685 0.4634188
[36] 0.4815648 0.4274418 0.3676624 0.2849945 0.2311094 0.2145767 0.2134797
[43] 0.2021141 0.1960431 0.1894779 0.1854458 0.1768988 0.1755865 0.1697464
[50] 0.1735197
> cycle(ts_evi)
Time Series:
Start = c(2000, 4)
End = c(2002, 7)
Frequency = 23
 [1]  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23  1  2  3  4  5
[26]  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23  1  2  3  4  5  6  7



What's the better method for obtain monthly value?


Thanks,

Alfredo

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


[R] Error message when logical indexing vecor is all FALSE

2009-12-01 Thread Jannis

Dears,


is there any way to "switch off" or work around the error message that
pops up when I do something like:


A<-B['logical vector']


and when 'logical vector' only consists of FALSE values? My problem is
that this message always kicks me out of my loops and always testing via
an if clause whether 'logical vector' contains any TRUE values is much
too complex due to many different conditions and several of the above
statements (and actually it seems to make my code really slow).


Cheers
Jannis

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


Re: [R] Error message when logical indexing vecor is all FALSE

2009-12-01 Thread jim holtman
?try

On Tue, Dec 1, 2009 at 12:22 PM, Jannis  wrote:
> Dears,
>
>
> is there any way to "switch off" or work around the error message that
> pops up when I do something like:
>
>
> A<-B['logical vector']
>
>
> and when 'logical vector' only consists of FALSE values? My problem is
> that this message always kicks me out of my loops and always testing via
> an if clause whether 'logical vector' contains any TRUE values is much
> too complex due to many different conditions and several of the above
> statements (and actually it seems to make my code really slow).
>
>
> Cheers
> Jannis
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

What is the problem that you are trying to solve?

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


Re: [R] "subset" or "condition" as argument to a function

2009-12-01 Thread baptiste auguie
Hi,

an alternative to parse() is to use quote and bquote,

set.seed(123)
d = data.frame(a=letters[1:5], b=1:10, c=sample(0:1, 10, repl=TRUE))

cond1 <- quote(a=="b")
cond2 <- quote(b < 6)
cond3 <- bquote(.(cond1) & .(cond2))

subset(d, eval(cond1))
subset(d, eval(cond2))
subset(d, eval(cond3))

HTH,

baptiste



2009/12/1 William Dunlap :
>> -Original Message-
>> From: r-help-boun...@r-project.org
>> [mailto:r-help-boun...@r-project.org] On Behalf Of Santosh
>> Sent: Tuesday, December 01, 2009 7:39 AM
>> To: r-help@r-project.org
>> Subject: Re: [R] "subset" or "condition" as argument to a function
>>
>> Dear R gurus..
>> I had tried out some suggestions sent to me privately..and
>> unfortunately,
>> they did not work..
>>
>> To use a condiition in a subset, the associated dataframe needs to be
>> attached and detached, which I found cumbersome to use if
>> using more than 1
>> dataframe (with different dimensions) with same condition. I
>> would highly
>> appreciate your suggestions to overcome this problem.. Please
>> see my example
>> of usage I am trying to implement. Please note that the
>> "cond' takes in the
>> character instead of logical values...
>>
>> cond1 <- 'group==1&sales>200'
>> cond2 <- 'group==2&sales>200'
>> cond3 <- 'group==3&sales>200'
>>
>> d1 <- subset(dat,subset=cond1)
>> plot(y~x,data=dat,subset=cond1,type='b')
>
> The subset argument to plot (and many similar functions)
> must be given as a literal expression, not a string that
> could be parsed into an expression nor the name of an object
> containing an expression nor a function call that evaluates
> to an expression.  This design is handy for interactive
> use but painful in programatic use.  One way to deal with
> it is to use do.call, which evaluates all the arguments to
> the function and then calls the function with the arguments
> given literally.  Replace the above plot call with
>  do.call("plot", list(y~x,data=dat,subset=parse(text=cond1),type='b'))
> and see if you get what you want.
>
> Bill Dunlap
> Spotfire, TIBCO Software
> wdunlap tibco.com
>
>> lines(y~x,data=dat,subset=cond2)
>> points(y~x,data=dat,subset=paste(cond1,cond2,sep='&'),col='blue')
>> points(y~x,data=d1,subset=cond3,col='red')
>>
>> If I try the above, I get the following error message:
>> *Error in subset.data.frame(dat, cond) : 'subset' must
>> evaluate to logical*
>>
>> If you could also suggest references implementing similar
>> code, I would
>> highly appreciate it.
>> Thanks so much,
>>
>> Santosh
>>
>> On Mon, Nov 23, 2009 at 6:38 PM, Santosh
>>  wrote:
>>
>> > Thanks... I would try it out..
>> >  -santosh
>> >
>> >
>> > On Sat, Nov 21, 2009 at 12:04 AM, Bernardo Rangel Tura <
>> > t...@centroin.com.br> wrote:
>> >
>> >> On Fri, 2009-11-20 at 17:40 -0800, Santosh wrote:
>> >> > Dear Rxperts!
>> >> >
>> >> > I was wondering if it is possible to write a function
>> which can take in
>> >> > argument of a subset or condition.. Of course, I am aware of the
>> >> alternate
>> >> > methods like coplot, par.plot, xyplot etc... I am specifically
>> >> interested in
>> >> > using conditions/subsets with "plot"..
>> >> >
>> >> > A simple fragmented example is shown here..
>> >> >
>> >> > pltit <- function(y,x,dat,dat1,dat2,sbst) {
>> >> > plot(y~x, data=dat, subset=sbst)
>> >> > lines(y~x,data=dat1, subset=subst)
>> >> > points(y~x,data=dat2,subset=subst)
>> >> > }
>> >> >
>> >> > pltit(profit,weeks,dat=zone1, sbst='group==1&sales>200')
>> >> >
>> >> > Could you also suggest pointers/references/examples on
>> efficient ways to
>> >> > plot simulated data overlaid with observed data?
>> >> >
>> >> > Have a good weekend!
>> >>
>> >>
>> >>
>> >
>>
>>       [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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


Re: [R] Starting estimates for nls Exponential Fit

2009-12-01 Thread Katharine Mullen
If you could reformulate your model as alpha * (y0 + E^t) then you could
use nls with alg="plinear" (alpha then would be eliminated from the
nonlinear param and treated as conditionally linear) and this would help
with convergence.

Else you can try package DEoptim to get the starting values; the advantage
over optim is that you need then lower and upper bounds on the parameters,
not more starting values; the bounds however should be appropriate and as
tight as possible.

Also: by default nls uses max. 50 iter.  Depending on where you start off
you may need more than this.

##

ExponValues <- c(2018.34,2012.54,2018.85,2023.52,2054.58,2132.61,2247.17,
 2468.32,2778.47)

ExponCycles <- c(17,18,19,20,21,22,23,24,25)

library(DEoptim)

mod <- function(x) x[1] + x[2]*x[3]^ExponCycles
fun <- function(x) sum((ExponValues-mod(x))^2)

ss <- DEoptim(fun, lower=rep(0,3), upper=c(10e7, 10, 10),
  control=list(trace=FALSE))

pa <- ss$optim$bestmem

## now have par est that give OK fit
matplot(cbind(ExponValues, mod(pa)),type="l")

names(pa) <- c("Y0", "a", "E")

## fit w/port and GN
Emodel<- nls(ExponValues ~ (Y0 + a*(E^ExponCycles)),
 start=pa, algorithm="port",
 control=list(maxiter=1000, warnOnly=TRUE))

Emodel1 <- nls(ExponValues ~ (Y0 + a*(E^ExponCycles)), start=pa,
 control=list(maxiter=1000, warnOnly=TRUE))

## fit
matplot(cbind(ExponValues, fitted(Emodel), fitted(Emodel1)),type="l")

On Tue, 1 Dec 2009, Anto wrote:

>
> Hello everyone,
>
> I have come across a bit of an odd problem: I am currently analysing data
> PCR reaction data of which part is behaving exponential. I would like to fit
> the exponential part to the following:
>
> y0 + alpha * E^t
>
> In which Y0 is the groundphase, alpha a fluorescence factor, E the
> efficiency of the reaction & t is time (in cycles)
>
> I can get this to work for most of my reactions, but part fails the nls fit
> (Convergence failure: iteration limit reached without convergence). This
> mainly has to do with the starting estimates for the nls function. I have
> used various 'smart' ways of calculating starting estimates (grid searches,
> optim(), etc.) but however close the starting estimates are to the actual
> values, nls still fails for many datasets.
>
> The weirdest thing is, I have one set of starting estimates (alpha= 0.5 and
> E=1.85) which are totaly arbitray and these DO work for, say 99% of the
> datasets. I don't know why this is and I don't why my 'good estimates' do
> not work. I am desperatly seeking a way of calculating working starting
> estimates for my nls function. Can anybody give me a hand?
>
> thanks,
>
> Anto
>
> R version 2.9.2
>
> example dataset:
>
> ExponValues
> [1] 2018.34 2012.54 2018.85 2023.52 2054.58 2132.61 2247.17 2468.32 2778.47
>
> ExponCycles
> [1] 17 18 19 20 21 22 23 24 25
>
>
> Example starting estimate calculation
>
> Y0 <- ExponValues[1]
> E <-
> weighted.mean((ExponValues-eY0)[-1][-1]/(ExponValues-eY0)[-1][-(length(ExponValues)-1)],(1-abs(seq(-1,1,length=(length(ExponValues)-2)))^3)^3)
> alpha <-
> weighted.mean((ExponValues[-1]-ExponValues[-length(ExponValues)])/((E^ExponCycles[-1])-(E^ExponCycles[-length(ExponCycles)])),(1-abs(seq(-1,1,length=(length(ExponCycles)-1)))^3)^3)
>
>
> Optional parameter optimisation:
>
> Esp <-
> optim(c(Y0=eY0,a=alpha,E=E),function(x){return(sum(abs(ExponValues-(x[1]+x[2]*x[3]^ExponCycles})$par
>
>
> nls function:
>
> Emodel<-try(nls(ExponValues ~ (Y0 + a*(E^ExponCycles)) , start= Esp,
> algorithm="port"),silent=TRUE)
> --
> View this message in context: 
> http://n4.nabble.com/Starting-estimates-for-nls-Exponential-Fit-tp932230p932230.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] eigenvalues of complex matrices

2009-12-01 Thread Ravi Varadhan
Hi,

You haven't given us much information.  

You might actually have the same eigenvalues, but don't recognize that due
to possibly different orderings.  Complex numbers do not possess ordering.
Therefore, there is no natural way to report complex eigenvalues.  In R, the
complex eigenvalues are ordered in decreasing order of the absolute value of
"real" part, whereas in Matlab it may be that they are ordered in terms of
the modulus (absolute value) of the complex number.

I have used "arpack" before to obtain the first few dominant eigenvalues,
and the same issue of different "ordering" of eigenvalues also applies
there. 


Ravi.


---

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: rvarad...@jhmi.edu

Webpage:
http://www.jhsph.edu/agingandhealth/People/Faculty_personal_pages/Varadhan.h
tml

 





-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of David Scherrer
Sent: Tuesday, December 01, 2009 11:36 AM
To: r-help@r-project.org
Subject: [R] eigenvalues of complex matrices

Dear all,

I want to compute the eigenvalues of a complex matrix for some statistics.
Comparing it to its matlab/octave sibling, I don't get the same eigenvalues
in R computing it from the exact same matrix.

In R, I used eigen() and arpack() that give different eigenvalues. In
matlab/octave I used eig() and eigs() that give out the same eigenvalues but
different to the R ones.
For real matrices, R and matlab/octave are consistent.

Does anybody know what could go on here and how I could get consistent
eigenvalues in R? Since I definitely want to do the analysis in R.

Many thanks,
David

[[alternative HTML version deleted]]

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

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


[R] Problem in reading data

2009-12-01 Thread Megh

In my Excel file, I have data in following format :

Feb-07  38.49
Mar-07  39.95
Apr-07  37.47
May-07  35.77
Jun-07  32.96
Jul-07  33.27

I tried to copy this data as a time series using following code :

library(zoo)
dat <- read.zoo(file="clipboard", format="%m-%y")

However getting following error :

Error in read.zoo(file = "clipboard", format = "%m-%y") : 
  index has bad entries at data rows: 1 2 3 4 5 6

Can anyone please guide me what is the right way to do that?

Thanks,

-- 
View this message in context: 
http://n4.nabble.com/Problem-in-reading-data-tp932386p932386.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] median for time data

2009-12-01 Thread uvilla

Thanks a lot for your answer Jannis.
Actually, I should have specified what I`m trying to do.
I have a datafame which 3 colums, one is the "person ID", second is "Anfag"
and third is "Ende". The two time colums are in this way: "8:50:10", so I
have to calculate the medan of the Anfag colum and to determine the length
of the route.
When I use strptime() I just get NA NA NA
I`m new at using R, must finisth this work thoug

I guess Im doing totally wrong, actually everytime i try to use "POSIXct" it
doesn`t work

Thanks a lot



Jannis wrote:
> 
> Hi,
> 
> 
> try to convert this to the R time format "POSIXct" or "POSIXlt" via 
> strptime(). Then you can simply substract them. I am not sure whether a 
> median can be calculated though (should be possible as POSIXct stores 
> the value as seconds since 1970)
> 
> Best
> Jannis
> 
> uvilla schrieb:
>> Hi everybody
>> 
>> How do I do to calculate the median and average of a colum of time data
>> like
>> this: "8:50:10". I also need to plot the time difference between two
>> colums
>> Thanks a lot
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: 
http://n4.nabble.com/median-for-time-data-tp932287p932402.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] median for time data

2009-12-01 Thread Gabor Grothendieck
# input

library(chron)
tt <- times(c("8:50:10", "9:40:20", "10:55:45"))
tt2 <- times(c("01:00:00", "02:00:00", "03:00:00"))
tt
tt2

# calc median and differences (although it will give results as fractions of
a day if there are negative results)

median(tt)
tt - tt2
tt2 - tt

On Tue, Dec 1, 2009 at 10:46 AM, uvilla  wrote:

>
> Hi everybody
>
> How do I do to calculate the median and average of a colum of time data
> like
> this: "8:50:10". I also need to plot the time difference between two colums
> Thanks a lot
> --
> View this message in context:
> http://n4.nabble.com/median-for-time-data-tp932287p932287.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.


[R] Testing the significance of gradients in trends

2009-12-01 Thread Steve Murray

Dear all,

I want to determine if the slopes of the trends I have in my plot are 
significantly different from each other (I have 2 time-series trends). What 
statistical test is most suitable for this purpose and is it available in the R 
base package?

Many thanks,

Steve
  
_
Use Hotmail to send and receive mail from your different email accounts

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


Re: [R] Problem in reading data

2009-12-01 Thread Gabor Grothendieck
Specify that your input is of class yearmon (as opposed to Date class) and
also correct the format specification as per the percent codes in ?strptime

library(zoo)
z <- read.zoo("clipboard", FUN = as.yearmon, format = "%b-%y")



On Tue, Dec 1, 2009 at 12:55 PM, Megh  wrote:

>
> In my Excel file, I have data in following format :
>
> Feb-07  38.49
> Mar-07  39.95
> Apr-07  37.47
> May-07  35.77
> Jun-07  32.96
> Jul-07  33.27
>
> I tried to copy this data as a time series using following code :
>
> library(zoo)
> dat <- read.zoo(file="clipboard", format="%m-%y")
>
> However getting following error :
>
> Error in read.zoo(file = "clipboard", format = "%m-%y") :
>  index has bad entries at data rows: 1 2 3 4 5 6
>
> Can anyone please guide me what is the right way to do that?
>
> Thanks,
>
> --
> View this message in context:
> http://n4.nabble.com/Problem-in-reading-data-tp932386p932386.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] Learning R

2009-12-01 Thread Dr. Thomas W. MacFarland
Hi Julia:

I am sure that you will find many useful resources as you attempt to learn
R.

If time permits, please look at the Tegrity-based video that I’ve prepared
for my students:

http://tegrity1.acast.nova.edu/tegrityUtils/GetCourseListing.aspx?Session_In
fo=7KmTs8Wkvvr0/Q0TsCfcur4RNGDvBGYk0jY+RNouoFosZ5zARrXkT5Sh6Kna2HKM 

The video is about one hour in length, it is specific to the needs of
beginners, and it covers the type of concerns that you post in your message.

If you do not have prior experience with Tegrity-based videos, you can
easily show the entire screen just by clicking on the screen maximize icon,
on the right side of the screen.  You can then toggle between full screen
and partial screen by using the Escape (Esc) key.

Good luck with R and your program of studies.  However, you may want to
allow for more than two months to learn R, even if you are a quick study.  

Best wishes.

Dr. Thomas W. MacFarland

-
Thomas W. MacFarland, Ed.D.
Senior Research Associate; Institutional Effectiveness and Associate
Professor
Nova Southeastern University
Voice 954-262-5395  Fax 954-262-3970  tom...@nsu.nova.edu

Julia Cains wrote:
> Dear R helpers,
> 
> Almost 15 days back I have become member of this very active and wonderful
group. So far I have been only raising  queries and in turn got them solved
too and I really thank for the spirit this group member show when it comes
to the guidance.
> 
> I wish to learn R language and I have given 2 months time for this. Can
anyone please guide me as how do I begin i.e. from basics to advance.
> 
> R is such a vast thing to learn, so I wish to learn it step by step
without getting lost at any stage.
> 
> Please guide me where do I start and upgrade myself to higher level step
by step.
> 
> Regards
> 
> Julia
> 


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of r-help-requ...@r-project.org
Sent: Tuesday, December 01, 2009 6:00 AM
To: r-help@r-project.org
Subject: R-help Digest, Vol 82, Issue 1

Send R-help mailing list submissions to
r-help@r-project.org

To subscribe or unsubscribe via the World Wide Web, visit
https://stat.ethz.ch/mailman/listinfo/r-help
or, via email, send a message with subject or body 'help' to
r-help-requ...@r-project.org

You can reach the person managing the list at
r-help-ow...@r-project.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of R-help digest..."

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


[R] write.csv fails with $ operator invalid for atomic

2009-12-01 Thread ggraves

I want to export a csv file so I can do other things with it.

I issue this command to break down years as to whether it was windy or not:

t<-tapply(TURB,list(year,windy),mean,na.rm=T)

which results in:

> t
no   yes
1990 21.516514  39.86400
1991 13.580435  28.87500
1992 12.171429  22.93913
1993 21.550893  26.41200
1994 12.003913  40.76928
1995 14.707917  35.39057
1996 22.041765  44.54927
1997 17.577625  31.60761
1998 26.283978  34.36190
1999 14.597922  43.85804
2000 30.805139  63.06042
2001 23.204545  36.64634
2002 21.062791  32.86696
2003 14.487111  33.68727
2004 36.294595  73.38125
2005 49.089583 114.28333
2006 44.941667  89.37917
2007 57.456667  70.00435
2008 52.251163  89.83864
2009 24.212821  37.49375

when I issue this command

write.csv(t$table, file = "t.csv")

I get the error

ERROR $ operator is invalid for atomic vectors

??


-- 
View this message in context: 
http://n4.nabble.com/write-csv-fails-with-operator-invalid-for-atomic-tp932414p932414.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] median for time data

2009-12-01 Thread Jannis v. Buttlar



uvilla schrieb:

When I use strptime() I just get NA NA NA
I`m new at using R, must finisth this work thoug

I guess Im doing totally wrong, actually everytime i try to use "POSIXct" it
doesn`t work



If you have a look at help(strptime) you find that you have to specify 
the format in which you time is written.


Try

strptime("08:10:10","%H:%M:%S")

The stuff after the comma in the "" is the way to give strptime the format.

Now you only have use

strptime(vectorwithyourtime,"%H:%M:%S")

and you should get a vector with R format times out of it. It uses 
todays date though but for your calculations this should work. This 
POSIXct format is not very handy to use though, so you perhaps better 
consider using library(chron) as Gabor suggested.






Thanks a lot



Jannis wrote:

Hi,


try to convert this to the R time format "POSIXct" or "POSIXlt" via 
strptime(). Then you can simply substract them. I am not sure whether a 
median can be calculated though (should be possible as POSIXct stores 
the value as seconds since 1970)


Best
Jannis

uvilla schrieb:

Hi everybody

How do I do to calculate the median and average of a colum of time data
like
this: "8:50:10". I also need to plot the time difference between two
colums
Thanks a lot

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






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


[R] Multiple grouping on the X axis.

2009-12-01 Thread Munin

   I am trying to plot data with multiple logical and physical groups using
R.  Below is a sample of the kind of data I am working with and the desired
output.  We have a jmp script that can do the same thing, but at ~$200 a
year the licensing is counterproductive.  Thanks for any help.

Data input: Loaded from a CSV file.
Physical_1 Logical_1 Logical_2 Data_1 Data_2
x   Y   Z2  54   56
x   Y2 Z2  53   55
x   Y3 Z2  52   54
x2 Y   Z60   58
x2 Y2 Z59   57
x2 Y3 Z58   56
x3 Y   Z56   53
x3 Y2 Z55   52
x3 Y3 Z54   51
x4 Y   Z2  52   55
x4 Y2 Z2   51   54
x4 Y3 Z2   50   53


I need the graph to be grouped as follows:
-
|Y|Y2|Y3|Y|Y2|Y3|Y|Y2|Y3|Y|Y2|Y3|
-
| X|  X4  |  X2   |  X3  |
-
|   Z   |Z2 |
-

   Again, any help would be appreciated.
-- 
View this message in context: 
http://n4.nabble.com/Multiple-grouping-on-the-X-axis-tp932397p932397.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] ggplot legend for multiple time series

2009-12-01 Thread Changyou Sun
Hello All,

 

I am trying to create a legend for a black-white graph. The package I
use is ggplot2. It can add colors to the legend key but not line types.
Can you please help?

 

# example from Wickman (2009, ggplot2 - elegant graphics for data
analysis, page 109)

 

library(ggplot2)

huron <- data.frame(year=1875:1972, level=LakeHuron)

ggplot(huron, aes(year)) +

geom_line(aes(y=level+5, colour="above")) +

geom_line(aes(y=level-5, colour="below")) +

scale_colour_manual("Direction", c("above"="black",
"below"="black"))

 

Thanks,

 

 

Edwin

 

Changyou Sun, Ph.D.

Associate Professor

Natural Resource Policy & Economics

Box 9681, Department of Forestry

Mississippi State University

Mississippi State, MS 39762

 

#363 Thompson Hall

(662) 325 7271 (ph), 325 8726 (fax)

c...@cfr.msstate.edu

www.cfr.msstate.edu/forestry

 


[[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] ggplot legend for multiple time series

2009-12-01 Thread Edwin Sun

Hello All,

I am trying to create a legend for a black-white graph. The package I use is
ggplot2. It can add colors to the legend key but not line types. Can you
please help?

# example from Wickman (2009, ggplot2 – elegant graphics for data analysis,
page 109)

library(ggplot2)
huron <- data.frame(year=1875:1972, level=LakeHuron)
ggplot(huron, aes(year)) +
geom_line(aes(y=level+5, colour="above")) +
geom_line(aes(y=level-5, colour="below")) +
scale_colour_manual("Direction", c("above"="black", "below"="black"))

Thanks,


Edwin

Changyou Sun, Ph.D.
Associate Professor
Natural Resource Policy & Economics
Box 9681, Department of Forestry
Mississippi State University
Mississippi State, MS 39762

#363 Thompson Hall
(662) 325 7271 (ph), 325 8726 (fax)
c...@cfr.msstate.edu
www.cfr.msstate.edu/forestry
-- 
View this message in context: 
http://n4.nabble.com/ggplot-legend-for-multiple-time-series-tp932430p932430.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] LMER: How to specify Random Effects

2009-12-01 Thread Ubuntu Diego

Thanks for your feedback.
Actually Plant is nested since High and Low are qualitative relative 
values (High in Michigan is not the same as High in Sienna).



S Ellison wrote:

The Plant classification is not nested; it's an effect across all
countires and states and probably a fixed effct (assuming you want to
measure its size or significance). But the state is nested in country.

That would suggest to me 
lmer(Reaction~Drug+Plant+(1|Country/State),...)


(or Plant*Drug, if you want an interaction)

However, though your states are nested in countrythey are readily
identifiable by lmer as different for each country (you do not have
country1: State1, State2..., Country2:State1,State2..) so the nesting by
country probably doesn't need to be specified. I think the above would,
_in this case_ be almost identical to 


lmer(Reaction~Drug+Plant+(1|Country)+(1|State),...)





  

Ubuntu Diego  01/12/2009 16:22:09 >>>


I saw different specifications for Random Effects and I'm confused
about 
the use of "/" and  the use of "(0+...|)" .
Let say we have a nested structure where some countries have some 
several plants in different states and we measure the reaction to a

drug.

The list of Countries = USA, France, Italy
The States for USA = Michigan, Florida, California
The States for France =  Paris, Orleans
The States for Italy =  Venezia, Sienna, Florence, Rome, Napoli ,
Sicilia

Plants were classified as High and Low

is this the way to specify a possible model ?

lmer(Reaction ~ Drug + (1| Country / State / Plant) , data)

or should I use something like this
A) lmer(Reaction ~ Drug + (0| Country / State / Plant) , data)
B) lmer(Reaction ~ Drug + (1| Country ) + (0+Country | State / Plant) ,

data)
C) lmer(Reaction ~ Drug + (1| Country ) + (0+Country | State / Plant) +

(0+Country + State | Plant), data)
D) lmer(Reaction ~ Drug + (1| Country ) + (0+Country | State ) + 
(0+Country + State | Plant), data)


Thanks

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


***
This email and any attachments are confidential. Any u...{{dropped:9}}


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


[R] Cut intervals (character) to numeric midpoint; regex problem

2009-12-01 Thread David Winsemius
Starting with the head of a 499 element matrix whose column names are  
now the labels trom a cut() operation, I needed to get to a vector of  
midpoints to serve as the basis for plotting a calibration curve  
( exp(linear predictor) vs.  :


> dput(head(dimnames(mtcal)[2][[1]])) # was starting point


testvec <- c("(-8.616,-3.084]", "(-3.084,-2.876]", "(-2.876,-2.756]",  
"(-2.756,-2.668]",

"(-2.668,-2.597]", "(-2.597,-2.539]")

I started this message with the thought of requesting an answer but  
kept asking myself if I really had check the docs and tested my  
understanding. I eventually solved it using the gsubfn from the gsubfn  
package:


testintvl <-as.numeric(gsubfn("\\((-?[[:digit:]]+.?[[:digit:]]*),
(-?[[:digit:]]+.?[[:digit:]]*)\\]",
~ (as.numeric(x)+as.numeric(y))/2,  testvec))

# I did discover that carriage returns in the middle of the pattern  
will not give desired results, so if this is broken by your mail- 
client, be sure to rejoin in the console.


The extra "?"'s after the decimal point are in there because I had 4  
NA's around the median linear predictor:


> dimnames(mtcal)[2][[1]][which(is.na(testintvl))]
[1] "(-1.008,-1]"  "(-1,-0.9922]" "(0.9914,1]"   "(1,1.009]"

So a better test vector would be:

testvec <- c("(-8.616,-3.084]", "(-3.084,-2.876]", "(-2.876,-2.756]",  
"(-2.756,-2.668]",
"(-2.668,-2.597]", "(-2.597,-2.539]", "(-1.008,-1]",  "(-1,-0.9922]",  
"(0.9914,1]", "(1,1.009]" )


> testintvl <-as.numeric(gsubfn("\\((-?[[:digit:]]+.?[[:digit:]]*),(-? 
[[:digit:]]+.?[[:digit:]]*)\\]",

+ ~ (as.numeric(x)+as.numeric(y))/2,  testvec))

> testintvl
 [1] -5.8500 -2.9800 -2.8160 -2.7120 -2.6325 -2.5680 -1.0040 -0.9961   
0.9957  1.0045


I offer this to those who may feel regex challenged (as I often do).  
The gsubfn function is pretty slick. I don't see an author listed for  
the function, but the author of the package documents is Gabor  
Grothendieck.


--

David Winsemius, MD
Heritage Laboratories
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] Remark on tapply().

2009-12-01 Thread Rolf Turner


On 1/12/2009, at 8:32 PM, Karl Ove Hufthammer wrote:




Exercise to the reader:

Note that
sapply(split(x, ff, drop=TRUE), sum)
gives you the values of (just) the non-empty levels.

Now, why does
  sapply(split(x, ff), sum, drop=TRUE)
give the wrong value (1) for these levels, while
  sapply(split(x, ff), sum, drop=FALSE)
gives the the correct value?

(The answer should be fairly obvious, but it's an easy mistake to  
make.)


That is ***CUTE***.  I had to think long and hard to see what was  
going on.

(But then I'm never very quick out of the blocks. :-) )

cheers,

Rolf Turner

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

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


[R] An R vs. SAS Discrepancy: How do I determine which is correct?

2009-12-01 Thread Kevin E. Thorpe

I was messing around with some data in R and SAS (the reason is
unimportant) fitting a multiple linear regression and got a
curious discrepancy.  The data set is too big to post, but if
someone wants it, I can send it.

So, here are the (partial) results:

From R:

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 61.114341.48065  41.275  < 2e-16 ***
sexWomen 2.911080.35753   8.1425e-16 ***
diabp0.206750.01504  13.746  < 2e-16 ***
age -0.080850.02088  -3.871 0.000110 ***

From SAS (sorry about word-wrap if it happens):

  Parameter Estimates

Parameter Standard
 Variable   Label DF EstimateError 
 t Value


 Intercept  Intercept  1 58.20326  1.57802 
   36.88
 SEXSEX1  2.91108  0.35753 
8.14
 DIABP  Diastolic BP mmHg  1  0.20675  0.01504 
   13.75
 AGEAge (years) at examination 1 -0.08085  0.02088 
   -3.87


  Parameter Estimates

 Variable   Label DF  Pr > |t|

 Intercept  Intercept  1<.0001
 SEXSEX1<.0001
 DIABP  Diastolic BP mmHg  1<.0001
 AGEAge (years) at examination 10.0001

The curious thihs is that all parameter estimates agree except the
intercept.  In R I also computed the coefficients directly using
(X'X)^(-1) X' y and get the same coefficients as lm() have me.
Also, ols() in Design agrees with lm()

As far as I can tell, the data used in R and SAS are identical.  So,
whose answer is correct and how do I prove it?  Here's my sessionInfo
(yes, I know my version of R is oldish).

> sessionInfo()
R version 2.8.0 (2008-10-20)
i686-pc-linux-gnu

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

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

other attached packages:
[1] Design_2.2-0survival_2.35-4 Hmisc_3.6-0 lattice_0.17-25

loaded via a namespace (and not attached):
[1] cluster_1.12.0 grid_2.8.0

--
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

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


Re: [R] Cut intervals (character) to numeric midpoint; regex problem

2009-12-01 Thread Gabor Grothendieck
You also might want to look at

demo("gsubfn-cut")


On Tue, Dec 1, 2009 at 2:41 PM, David Winsemius wrote:

> Starting with the head of a 499 element matrix whose column names are now
> the labels trom a cut() operation, I needed to get to a vector of midpoints
> to serve as the basis for plotting a calibration curve ( exp(linear
> predictor) vs.  :
>
> > dput(head(dimnames(mtcal)[2][[1]])) # was starting point
>
>
> testvec <- c("(-8.616,-3.084]", "(-3.084,-2.876]", "(-2.876,-2.756]",
> "(-2.756,-2.668]",
> "(-2.668,-2.597]", "(-2.597,-2.539]")
>
> I started this message with the thought of requesting an answer but kept
> asking myself if I really had check the docs and tested my understanding. I
> eventually solved it using the gsubfn from the gsubfn package:
>
> testintvl <-as.numeric(gsubfn("\\((-?[[:digit:]]+.?[[:digit:]]*),
> (-?[[:digit:]]+.?[[:digit:]]*)\\]",
> ~ (as.numeric(x)+as.numeric(y))/2,  testvec))
>
> # I did discover that carriage returns in the middle of the pattern will
> not give desired results, so if this is broken by your mail-client, be sure
> to rejoin in the console.
>
> The extra "?"'s after the decimal point are in there because I had 4 NA's
> around the median linear predictor:
>
> > dimnames(mtcal)[2][[1]][which(is.na(testintvl))]
> [1] "(-1.008,-1]"  "(-1,-0.9922]" "(0.9914,1]"   "(1,1.009]"
>
> So a better test vector would be:
>
> testvec <- c("(-8.616,-3.084]", "(-3.084,-2.876]", "(-2.876,-2.756]",
> "(-2.756,-2.668]",
> "(-2.668,-2.597]", "(-2.597,-2.539]", "(-1.008,-1]",  "(-1,-0.9922]",
> "(0.9914,1]", "(1,1.009]" )
>
> > testintvl
> <-as.numeric(gsubfn("\\((-?[[:digit:]]+.?[[:digit:]]*),(-?[[:digit:]]+.?[[:digit:]]*)\\]",
> + ~ (as.numeric(x)+as.numeric(y))/2,  testvec))
>
> > testintvl
>  [1] -5.8500 -2.9800 -2.8160 -2.7120 -2.6325 -2.5680 -1.0040 -0.9961
>  0.9957  1.0045
>
> I offer this to those who may feel regex challenged (as I often do). The
> gsubfn function is pretty slick. I don't see an author listed for the
> function, but the author of the package documents is Gabor Grothendieck.
>
> --
>
> David Winsemius, MD
> Heritage Laboratories
> 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.
>

[[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] ggplot legend for multiple time series

2009-12-01 Thread baptiste auguie
Hi,

I don't understand why you used scale_manual_colour if you want only
black lines. To have different line types in the legend you can map
the linetype to the data,


huron <- data.frame(year=1875:1972, level=LakeHuron)

ggplot(huron, aes(year)) +
   geom_line(aes(y=level+5, linetype="above")) +
   geom_line(aes(y=level-5, linetype="below")) +
   scale_linetype_manual("offset", c(1, 2))

HTH,

baptiste
2009/12/1 Edwin Sun :
>
> Hello All,
>
> I am trying to create a legend for a black-white graph. The package I use is
> ggplot2. It can add colors to the legend key but not line types. Can you
> please help?
>
> # example from Wickman (2009, ggplot2 – elegant graphics for data analysis,
> page 109)
>
> library(ggplot2)
> huron <- data.frame(year=1875:1972, level=LakeHuron)
> ggplot(huron, aes(year)) +
>    geom_line(aes(y=level+5, colour="above")) +
>    geom_line(aes(y=level-5, colour="below")) +
>    scale_colour_manual("Direction", c("above"="black", "below"="black"))
>
> Thanks,
>
>
> Edwin
>
> Changyou Sun, Ph.D.
> Associate Professor
> Natural Resource Policy & Economics
> Box 9681, Department of Forestry
> Mississippi State University
> Mississippi State, MS 39762
>
> #363 Thompson Hall
> (662) 325 7271 (ph), 325 8726 (fax)
> c...@cfr.msstate.edu
> www.cfr.msstate.edu/forestry
> --
> View this message in context: 
> http://n4.nabble.com/ggplot-legend-for-multiple-time-series-tp932430p932430.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] An R vs. SAS Discrepancy: How do I determine which is correct?

2009-12-01 Thread Kevin E. Thorpe

Thanks to an insightful comment from Jeremy Miles, who politely
pointed out my thick-headed moment, I know what happened.

The sex variable was coded as 1/2 in the SAS data, but was a factor
in the R data and so became a properly coded dummy variable.

Sorry for the obvious question and answer.

Kevin E. Thorpe wrote:

I was messing around with some data in R and SAS (the reason is
unimportant) fitting a multiple linear regression and got a
curious discrepancy.  The data set is too big to post, but if
someone wants it, I can send it.

So, here are the (partial) results:

 From R:

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 61.114341.48065  41.275  < 2e-16 ***
sexWomen 2.911080.35753   8.1425e-16 ***
diabp0.206750.01504  13.746  < 2e-16 ***
age -0.080850.02088  -3.871 0.000110 ***

 From SAS (sorry about word-wrap if it happens):

  Parameter Estimates

Parameter Standard
 Variable   Label DF EstimateError 
 t Value


 Intercept  Intercept  1 58.20326  1.57802 
   36.88
 SEXSEX1  2.91108  0.35753 
8.14
 DIABP  Diastolic BP mmHg  1  0.20675  0.01504 
   13.75
 AGEAge (years) at examination 1 -0.08085  0.02088 
   -3.87


  Parameter Estimates

 Variable   Label DF  Pr > |t|

 Intercept  Intercept  1<.0001
 SEXSEX1<.0001
 DIABP  Diastolic BP mmHg  1<.0001
 AGEAge (years) at examination 10.0001

The curious thihs is that all parameter estimates agree except the
intercept.  In R I also computed the coefficients directly using
(X'X)^(-1) X' y and get the same coefficients as lm() have me.
Also, ols() in Design agrees with lm()

As far as I can tell, the data used in R and SAS are identical.  So,
whose answer is correct and how do I prove it?  Here's my sessionInfo
(yes, I know my version of R is oldish).

 > sessionInfo()
R version 2.8.0 (2008-10-20)
i686-pc-linux-gnu

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



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

other attached packages:
[1] Design_2.2-0survival_2.35-4 Hmisc_3.6-0 lattice_0.17-25

loaded via a namespace (and not attached):
[1] cluster_1.12.0 grid_2.8.0




--
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

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


Re: [R] Cut intervals (character) to numeric midpoint; regex problem

2009-12-01 Thread Henrique Dallazuanna
Perhaps this shoul work too:

sapply(strsplit(gsub("^\\W|\\W$", "", testvec), ","),
function(x)sum(as.numeric(x))/2)

On Tue, Dec 1, 2009 at 5:41 PM, David Winsemius  wrote:
> Starting with the head of a 499 element matrix whose column names are now
> the labels trom a cut() operation, I needed to get to a vector of midpoints
> to serve as the basis for plotting a calibration curve ( exp(linear
> predictor) vs.  :
>
>> dput(head(dimnames(mtcal)[2][[1]])) # was starting point
>
>
> testvec <- c("(-8.616,-3.084]", "(-3.084,-2.876]", "(-2.876,-2.756]",
> "(-2.756,-2.668]",
> "(-2.668,-2.597]", "(-2.597,-2.539]")
>
> I started this message with the thought of requesting an answer but kept
> asking myself if I really had check the docs and tested my understanding. I
> eventually solved it using the gsubfn from the gsubfn package:
>
> testintvl <-as.numeric(gsubfn("\\((-?[[:digit:]]+.?[[:digit:]]*),
> (-?[[:digit:]]+.?[[:digit:]]*)\\]",
> ~ (as.numeric(x)+as.numeric(y))/2,  testvec))
>
> # I did discover that carriage returns in the middle of the pattern will not
> give desired results, so if this is broken by your mail-client, be sure to
> rejoin in the console.
>
> The extra "?"'s after the decimal point are in there because I had 4 NA's
> around the median linear predictor:
>
>> dimnames(mtcal)[2][[1]][which(is.na(testintvl))]
> [1] "(-1.008,-1]"  "(-1,-0.9922]" "(0.9914,1]"   "(1,1.009]"
>
> So a better test vector would be:
>
> testvec <- c("(-8.616,-3.084]", "(-3.084,-2.876]", "(-2.876,-2.756]",
> "(-2.756,-2.668]",
> "(-2.668,-2.597]", "(-2.597,-2.539]", "(-1.008,-1]",  "(-1,-0.9922]",
> "(0.9914,1]", "(1,1.009]" )
>
>> testintvl
>> <-as.numeric(gsubfn("\\((-?[[:digit:]]+.?[[:digit:]]*),(-?[[:digit:]]+.?[[:digit:]]*)\\]",
> + ~ (as.numeric(x)+as.numeric(y))/2,  testvec))
>
>> testintvl
>  [1] -5.8500 -2.9800 -2.8160 -2.7120 -2.6325 -2.5680 -1.0040 -0.9961  0.9957
>  1.0045
>
> I offer this to those who may feel regex challenged (as I often do). The
> gsubfn function is pretty slick. I don't see an author listed for the
> function, but the author of the package documents is Gabor Grothendieck.
>
> --
>
> David Winsemius, MD
> Heritage Laboratories
> 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.
>



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

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


Re: [R] ggplot legend for multiple time series

2009-12-01 Thread Edwin Sun

Hello - Thank you so much for the help. It works perfectly. I guess that as
many have pointed out, ggplot is a great package but there is a lack of
documentation and examples. 

Edwin Sun


baptiste auguie-5 wrote:
> 
> Hi,
> 
> I don't understand why you used scale_manual_colour if you want only
> black lines. To have different line types in the legend you can map
> the linetype to the data,
> 
> 
> huron <- data.frame(year=1875:1972, level=LakeHuron)
> 
> ggplot(huron, aes(year)) +
>geom_line(aes(y=level+5, linetype="above")) +
>geom_line(aes(y=level-5, linetype="below")) +
>scale_linetype_manual("offset", c(1, 2))
> 
> HTH,
> 
> baptiste
> 2009/12/1 Edwin Sun :
>>
>> Hello All,
>>
>> I am trying to create a legend for a black-white graph. The package I use
>> is
>> ggplot2. It can add colors to the legend key but not line types. Can you
>> please help?
>>
>> # example from Wickman (2009, ggplot2 – elegant graphics for data
>> analysis,
>> page 109)
>>
>> library(ggplot2)
>> huron <- data.frame(year=1875:1972, level=LakeHuron)
>> ggplot(huron, aes(year)) +
>>    geom_line(aes(y=level+5, colour="above")) +
>>    geom_line(aes(y=level-5, colour="below")) +
>>    scale_colour_manual("Direction", c("above"="black", "below"="black"))
>>
>> Thanks,
>>
>>
>> Edwin
>>
>> Changyou Sun, Ph.D.
>> Associate Professor
>> Natural Resource Policy & Economics
>> Box 9681, Department of Forestry
>> Mississippi State University
>> Mississippi State, MS 39762
>>
>> #363 Thompson Hall
>> (662) 325 7271 (ph), 325 8726 (fax)
>> c...@cfr.msstate.edu
>> www.cfr.msstate.edu/forestry
>> --
>> View this message in context:
>> http://n4.nabble.com/ggplot-legend-for-multiple-time-series-tp932430p932430.html
>> Sent from the R help mailing list archive at Nabble.com.
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: 
http://n4.nabble.com/ggplot-legend-for-multiple-time-series-tp932430p932491.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] Cut intervals (character) to numeric midpoint; regex problem

2009-12-01 Thread David Winsemius

I'm sitting here chuckling. Your solution is just so "pure".

I would offer an enhancement. When I tested with my cuts that had "-"  
before the digits, you solution dropped them, so my suggestion for the  
pattern would be:   "[-[:digit:].]+"


I will admit that I thought it might fail with positive numbers but it  
does not seem to:


> interv <- strapply(testvec, "[-[:digit:].]+", as.numeric, simplify  
= TRUE)

> interv
   [,1] [,2]   [,3]   [,4]   [,5]   [,6]   [,7][,8]   [, 
9] [,10]
[1,] -8.616   -3.084 -2.876 -2.756 -2.668 -2.597 -1.008 -1. 0.9914  
1.000
[2,] -3.084   -2.876 -2.756 -2.668 -2.597 -2.539 -1.000 -0.9922 1.  
1.009


I was not able to get that pattern to give acceptable results in  
gsubfn, so I obviously need to study this more closely.


--
David.

On Dec 1, 2009, at 2:47 PM, Gabor Grothendieck wrote:


You also might want to look at

demo("gsubfn-cut")


On Tue, Dec 1, 2009 at 2:41 PM, David Winsemius > wrote:
Starting with the head of a 499 element matrix whose column names  
are now the labels trom a cut() operation, I needed to get to a  
vector of midpoints to serve as the basis for plotting a calibration  
curve ( exp(linear predictor) vs.  :


> dput(head(dimnames(mtcal)[2][[1]])) # was starting point


testvec <- c("(-8.616,-3.084]", "(-3.084,-2.876]",  
"(-2.876,-2.756]", "(-2.756,-2.668]",

"(-2.668,-2.597]", "(-2.597,-2.539]")

I started this message with the thought of requesting an answer but  
kept asking myself if I really had check the docs and tested my  
understanding. I eventually solved it using the gsubfn from the  
gsubfn package:


testintvl <-as.numeric(gsubfn("\\((-?[[:digit:]]+.?[[:digit:]]*),
(-?[[:digit:]]+.?[[:digit:]]*)\\]",
~ (as.numeric(x)+as.numeric(y))/2,  testvec))

# I did discover that carriage returns in the middle of the pattern  
will not give desired results, so if this is broken by your mail- 
client, be sure to rejoin in the console.


The extra "?"'s after the decimal point are in there because I had 4  
NA's around the median linear predictor:


> dimnames(mtcal)[2][[1]][which(is.na(testintvl))]
[1] "(-1.008,-1]"  "(-1,-0.9922]" "(0.9914,1]"   "(1,1.009]"

So a better test vector would be:

testvec <- c("(-8.616,-3.084]", "(-3.084,-2.876]",  
"(-2.876,-2.756]", "(-2.756,-2.668]",
"(-2.668,-2.597]", "(-2.597,-2.539]", "(-1.008,-1]",   
"(-1,-0.9922]", "(0.9914,1]", "(1,1.009]" )


> testintvl <-as.numeric(gsubfn("\\((-?[[:digit:]]+.?[[:digit:]]*), 
(-?[[:digit:]]+.?[[:digit:]]*)\\]",

+ ~ (as.numeric(x)+as.numeric(y))/2,  testvec))

> testintvl
 [1] -5.8500 -2.9800 -2.8160 -2.7120 -2.6325 -2.5680 -1.0040  
-0.9961  0.9957  1.0045


I offer this to those who may feel regex challenged (as I often do).  
The gsubfn function is pretty slick. I don't see an author listed  
for the function, but the author of the package documents is Gabor  
Grothendieck.


--

David Winsemius, MD
Heritage Laboratories
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.



David Winsemius, MD
Heritage Laboratories
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] median for time data

2009-12-01 Thread uvilla

Thanks you both

Jannis now it is working!!. I just have one mor request, please!
How I'm suppose to make a boxplot with anfang, when working with times, it
just have on the y axis some decimal number which make no sense. i need the
time to appear in the y axis in order to see the median in the boxplot


Thanks again!!!



Jannis v. Buttlar wrote:
> 
> 
> 
> uvilla schrieb:
>> When I use strptime() I just get NA NA NA
>> I`m new at using R, must finisth this work thoug
>> 
>> I guess Im doing totally wrong, actually everytime i try to use "POSIXct"
>> it
>> doesn`t work
>> 
> 
> If you have a look at help(strptime) you find that you have to specify 
> the format in which you time is written.
> 
> Try
> 
> strptime("08:10:10","%H:%M:%S")
> 
> The stuff after the comma in the "" is the way to give strptime the
> format.
> 
> Now you only have use
> 
> strptime(vectorwithyourtime,"%H:%M:%S")
> 
> and you should get a vector with R format times out of it. It uses 
> todays date though but for your calculations this should work. This 
> POSIXct format is not very handy to use though, so you perhaps better 
> consider using library(chron) as Gabor suggested.
> 
> 
> 
> 
>> Thanks a lot
>> 
>> 
>> 
>> Jannis wrote:
>>> Hi,
>>>
>>>
>>> try to convert this to the R time format "POSIXct" or "POSIXlt" via 
>>> strptime(). Then you can simply substract them. I am not sure whether a 
>>> median can be calculated though (should be possible as POSIXct stores 
>>> the value as seconds since 1970)
>>>
>>> Best
>>> Jannis
>>>
>>> uvilla schrieb:
 Hi everybody

 How do I do to calculate the median and average of a colum of time data
 like
 this: "8:50:10". I also need to plot the time difference between two
 colums
 Thanks a lot
>>> __
>>> R-help@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide
>>> http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>>
>>
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: 
http://n4.nabble.com/median-for-time-data-tp932287p932511.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] Cut intervals (character) to numeric midpoint; regex problem

2009-12-01 Thread Gabor Grothendieck
Try this:

> library(gsubfn)
> strapply(testvec, "[-+.0-9]+", as.numeric, simplify = ~
colMeans(cbind(...)))
[1] -5.8500 -2.9800 -2.8160 -2.7120 -2.6325 -2.5680


On Tue, Dec 1, 2009 at 3:14 PM, David Winsemius wrote:

> I'm sitting here chuckling. Your solution is just so "pure".
>
> I would offer an enhancement. When I tested with my cuts that had "-"
> before the digits, you solution dropped them, so my suggestion for the
> pattern would be:   "[-[:digit:].]+"
>
> I will admit that I thought it might fail with positive numbers but it does
> not seem to:
>
> > interv <- strapply(testvec, "[-[:digit:].]+", as.numeric, simplify =
> TRUE)
> > interv
>   [,1] [,2]   [,3]   [,4]   [,5]   [,6]   [,7][,8]   [,9] [,10]
> [1,] -8.616   -3.084 -2.876 -2.756 -2.668 -2.597 -1.008 -1. 0.9914
> 1.000
> [2,] -3.084   -2.876 -2.756 -2.668 -2.597 -2.539 -1.000 -0.9922 1.
> 1.009
>
> I was not able to get that pattern to give acceptable results in gsubfn, so
> I obviously need to study this more closely.
>
> --
> David.
>
>
> On Dec 1, 2009, at 2:47 PM, Gabor Grothendieck wrote:
>
>  You also might want to look at
>>
>> demo("gsubfn-cut")
>>
>>
>> On Tue, Dec 1, 2009 at 2:41 PM, David Winsemius 
>> wrote:
>> Starting with the head of a 499 element matrix whose column names are now
>> the labels trom a cut() operation, I needed to get to a vector of midpoints
>> to serve as the basis for plotting a calibration curve ( exp(linear
>> predictor) vs.  :
>>
>> > dput(head(dimnames(mtcal)[2][[1]])) # was starting point
>>
>>
>> testvec <- c("(-8.616,-3.084]", "(-3.084,-2.876]", "(-2.876,-2.756]",
>> "(-2.756,-2.668]",
>> "(-2.668,-2.597]", "(-2.597,-2.539]")
>>
>> I started this message with the thought of requesting an answer but kept
>> asking myself if I really had check the docs and tested my understanding. I
>> eventually solved it using the gsubfn from the gsubfn package:
>>
>> testintvl <-as.numeric(gsubfn("\\((-?[[:digit:]]+.?[[:digit:]]*),
>> (-?[[:digit:]]+.?[[:digit:]]*)\\]",
>> ~ (as.numeric(x)+as.numeric(y))/2,  testvec))
>>
>> # I did discover that carriage returns in the middle of the pattern will
>> not give desired results, so if this is broken by your mail-client, be sure
>> to rejoin in the console.
>>
>> The extra "?"'s after the decimal point are in there because I had 4 NA's
>> around the median linear predictor:
>>
>> > dimnames(mtcal)[2][[1]][which(is.na(testintvl))]
>> [1] "(-1.008,-1]"  "(-1,-0.9922]" "(0.9914,1]"   "(1,1.009]"
>>
>> So a better test vector would be:
>>
>> testvec <- c("(-8.616,-3.084]", "(-3.084,-2.876]", "(-2.876,-2.756]",
>> "(-2.756,-2.668]",
>> "(-2.668,-2.597]", "(-2.597,-2.539]", "(-1.008,-1]",  "(-1,-0.9922]",
>> "(0.9914,1]", "(1,1.009]" )
>>
>> > testintvl
>> <-as.numeric(gsubfn("\\((-?[[:digit:]]+.?[[:digit:]]*),(-?[[:digit:]]+.?[[:digit:]]*)\\]",
>> + ~ (as.numeric(x)+as.numeric(y))/2,  testvec))
>>
>> > testintvl
>>  [1] -5.8500 -2.9800 -2.8160 -2.7120 -2.6325 -2.5680 -1.0040 -0.9961
>>  0.9957  1.0045
>>
>> I offer this to those who may feel regex challenged (as I often do). The
>> gsubfn function is pretty slick. I don't see an author listed for the
>> function, but the author of the package documents is Gabor Grothendieck.
>>
>> --
>>
>> David Winsemius, MD
>> Heritage Laboratories
>> 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.
>>
>>
> David Winsemius, MD
> Heritage Laboratories
> West Hartford, CT
>
>

[[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] ggplot legend for multiple time series

2009-12-01 Thread hadley wickham
Because of the combinatorial nature of ggplot2, it is simply not
possible to provide an example that illustrates every single
combination of options.  There are already over 600 example graphics
in the package - if you can't find one that exactly meets your need,
you need to buy the book and learn more about the rich theory
underlying the package.

Hadley

On Tue, Dec 1, 2009 at 2:02 PM, Edwin Sun  wrote:
>
> Hello - Thank you so much for the help. It works perfectly. I guess that as
> many have pointed out, ggplot is a great package but there is a lack of
> documentation and examples.
>
> Edwin Sun
>
>
> baptiste auguie-5 wrote:
>>
>> Hi,
>>
>> I don't understand why you used scale_manual_colour if you want only
>> black lines. To have different line types in the legend you can map
>> the linetype to the data,
>>
>>
>> huron <- data.frame(year=1875:1972, level=LakeHuron)
>>
>> ggplot(huron, aes(year)) +
>>    geom_line(aes(y=level+5, linetype="above")) +
>>    geom_line(aes(y=level-5, linetype="below")) +
>>    scale_linetype_manual("offset", c(1, 2))
>>
>> HTH,
>>
>> baptiste
>> 2009/12/1 Edwin Sun :
>>>
>>> Hello All,
>>>
>>> I am trying to create a legend for a black-white graph. The package I use
>>> is
>>> ggplot2. It can add colors to the legend key but not line types. Can you
>>> please help?
>>>
>>> # example from Wickman (2009, ggplot2 – elegant graphics for data
>>> analysis,
>>> page 109)
>>>
>>> library(ggplot2)
>>> huron <- data.frame(year=1875:1972, level=LakeHuron)
>>> ggplot(huron, aes(year)) +
>>>    geom_line(aes(y=level+5, colour="above")) +
>>>    geom_line(aes(y=level-5, colour="below")) +
>>>    scale_colour_manual("Direction", c("above"="black", "below"="black"))
>>>
>>> Thanks,
>>>
>>>
>>> Edwin
>>>
>>> Changyou Sun, Ph.D.
>>> Associate Professor
>>> Natural Resource Policy & Economics
>>> Box 9681, Department of Forestry
>>> Mississippi State University
>>> Mississippi State, MS 39762
>>>
>>> #363 Thompson Hall
>>> (662) 325 7271 (ph), 325 8726 (fax)
>>> c...@cfr.msstate.edu
>>> www.cfr.msstate.edu/forestry
>>> --
>>> View this message in context:
>>> http://n4.nabble.com/ggplot-legend-for-multiple-time-series-tp932430p932430.html
>>> Sent from the R help mailing list archive at Nabble.com.
>>>
>>> __
>>> R-help@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide
>>> http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
>
> --
> View this message in context: 
> http://n4.nabble.com/ggplot-legend-for-multiple-time-series-tp932430p932491.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

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


Re: [R] Cut intervals (character) to numeric midpoint; regex problem

2009-12-01 Thread David Winsemius

On Dec 1, 2009, at 3:28 PM, Gabor Grothendieck wrote:

> Try this:
>
> > library(gsubfn)
> > strapply(testvec, "[-+.0-9]+", as.numeric, simplify = ~  
> colMeans(cbind(...)))
> [1] -5.8500 -2.9800 -2.8160 -2.7120 -2.6325 -2.5680

Very, nice. Also tried on some other valid ("200,2") and  
invalid )"2..2") numbers as it has worked as expected. It did not  
accept "--2.597" but that hardly seems to be a plausible result from a  
cut operation.

-- 
David.

>
>
> On Tue, Dec 1, 2009 at 3:14 PM, David Winsemius  > wrote:
> I'm sitting here chuckling. Your solution is just so "pure".
>
> I would offer an enhancement. When I tested with my cuts that had  
> "-" before the digits, you solution dropped them, so my suggestion  
> for the pattern would be:   "[-[:digit:].]+"
>
> I will admit that I thought it might fail with positive numbers but  
> it does not seem to:
>
> > interv <- strapply(testvec, "[-[:digit:].]+", as.numeric, simplify  
> = TRUE)
> > interv
>   [,1] [,2]   [,3]   [,4]   [,5]   [,6]   [,7][,8]   [, 
> 9] [,10]
> [1,] -8.616   -3.084 -2.876 -2.756 -2.668 -2.597 -1.008 -1.  
> 0.9914 1.000
> [2,] -3.084   -2.876 -2.756 -2.668 -2.597 -2.539 -1.000 -0.9922  
> 1. 1.009
>
> I was not able to get that pattern to give acceptable results in  
> gsubfn, so I obviously need to study this more closely.
>
> -- 
> David.
>
>
> On Dec 1, 2009, at 2:47 PM, Gabor Grothendieck wrote:
>
> You also might want to look at
>
> demo("gsubfn-cut")
>
>
> On Tue, Dec 1, 2009 at 2:41 PM, David Winsemius  > wrote:
> Starting with the head of a 499 element matrix whose column names  
> are now the labels trom a cut() operation, I needed to get to a  
> vector of midpoints to serve as the basis for plotting a calibration  
> curve ( exp(linear predictor) vs.  :
>
> > dput(head(dimnames(mtcal)[2][[1]])) # was starting point
>
>
> testvec <- c("(-8.616,-3.084]", "(-3.084,-2.876]",  
> "(-2.876,-2.756]", "(-2.756,-2.668]",
> "(-2.668,-2.597]", "(-2.597,-2.539]")
>
> I started this message with the thought of requesting an answer but  
> kept asking myself if I really had check the docs and tested my  
> understanding. I eventually solved it using the gsubfn from the  
> gsubfn package:
>
> testintvl <-as.numeric(gsubfn("\\((-?[[:digit:]]+.?[[:digit:]]*),
> (-?[[:digit:]]+.?[[:digit:]]*)\\]",
> ~ (as.numeric(x)+as.numeric(y))/2,  testvec))
>
> # I did discover that carriage returns in the middle of the pattern  
> will not give desired results, so if this is broken by your mail- 
> client, be sure to rejoin in the console.
>
> The extra "?"'s after the decimal point are in there because I had 4  
> NA's around the median linear predictor:
>
> > dimnames(mtcal)[2][[1]][which(is.na(testintvl))]
> [1] "(-1.008,-1]"  "(-1,-0.9922]" "(0.9914,1]"   "(1,1.009]"
>
> So a better test vector would be:
>
> testvec <- c("(-8.616,-3.084]", "(-3.084,-2.876]",  
> "(-2.876,-2.756]", "(-2.756,-2.668]",
> "(-2.668,-2.597]", "(-2.597,-2.539]", "(-1.008,-1]",   
> "(-1,-0.9922]", "(0.9914,1]", "(1,1.009]" )
>
> > testintvl <-as.numeric(gsubfn("\\((-?[[:digit:]]+.?[[:digit:]]*), 
> (-?[[:digit:]]+.?[[:digit:]]*)\\]",
> + ~ (as.numeric(x)+as.numeric(y))/2,  testvec))
>
> > testintvl
>  [1] -5.8500 -2.9800 -2.8160 -2.7120 -2.6325 -2.5680 -1.0040  
> -0.9961  0.9957  1.0045
>
> I offer this to those who may feel regex challenged (as I often do).  
> The gsubfn function is pretty slick. I don't see an author listed  
> for the function, but the author of the package documents is Gabor  
> Grothendieck.
>
> --
>
> David Winsemius, MD
> Heritage Laboratories
> 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.
>
>
> David Winsemius, MD
> Heritage Laboratories
> West Hartford, CT
>
>

David Winsemius, MD
Heritage Laboratories
West Hartford, CT


[[alternative HTML version deleted]]

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


[R] How to compute contrast where there are interaction terms in the linear model?

2009-12-01 Thread Peng Yu
Could somebody recommend some textbook how to compute contrast when
there are interactions terms? "Applied Linear Regression Models"
(book) mentioned contrast, but I cannot extend it to the case where
there are interaction terms.

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

2009-12-01 Thread Hongbo Zhu
Hi,

I am using R 2.9.0.  It seems the documentation for the calculation of
Canberra distance using stats::dist is ambiguous. Does anyone have the
original definition given in the Lance & Williams paper from Aust. Comput.
J. 1, 15-20, 1967?

When there are zeros at certain position in both vectors, they are not
omitted as documented in the function (see below). Instead, Canberra
distance is calculated as described in Frédéric Chiroleu's post (
http://tolstoy.newcastle.edu.au/R/e3/help/07/10/1370.html )
d(x,y) = (NZ + 1)/NZ * sum(abs(x-y)/(x+y)), where NZ is the number of
none-zero positions. This can also be seen from the example given in the
document for stats::dist (see below).
However, when there is no such a position where the values are zero in both
vectors, the Canberra distance is calculated using the formula given in the
document.

Examples:

> dist(rbind(c(1,2,3,4), c(2,3,4,5)), method='canberra')
  1
2 0.7873016

> dist(rbind(c(1,2,3,4,0), c(2,3,4,5,0)), method='canberra')
 1
2 0.984127


> help(dist)
dist  package:stats  R Documentation

Distance Matrix Computation
 ..

 'canberra': sum(|x_i - y_i| / |x_i + y_i|).  Terms with zero
  numerator and denominator are omitted from the sum and
  treated as if the values were missing.

 ## example of binary and canberra distances.
 x <- c(0, 0, 1, 1, 1, 1)
 y <- c(1, 0, 1, 1, 0, 1)
 dist(rbind(x,y), method= "binary")
 ## answer 0.4 = 2/5
 dist(rbind(x,y), method= "canberra")
 ## answer 2 * (6/5)

Thanks!
-- 
Hongbo

[[alternative HTML version deleted]]

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


Re: [R] How to compute contrast where there are interaction terms in the linear model?

2009-12-01 Thread Charles C. Berry

On Tue, 1 Dec 2009, Peng Yu wrote:


Could somebody recommend some textbook how to compute contrast when
there are interactions terms? "Applied Linear Regression Models"
(book) mentioned contrast, but I cannot extend it to the case where
there are interaction terms.



Textbook? Schmextbook!

You have the power of R at your fingertips!

Use it to explore concepts you are trying to wrap your brain around!



df <- expand.grid(x1=1:20,x2=factor(letters[1:2]))
vanilla <- model.matrix(~0+poly(x1,degree=3), df )
matplot(row( vanilla) , vanilla, type='b')
inter <-  model.matrix(~0+poly(x1,degree=3):x2, df )
matplot(row( inter ) , inter, type='b')




Chuck


Charles C. Berry(858) 534-2098
Dept of Family/Preventive Medicine
E mailto:cbe...@tajo.ucsd.edu   UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901

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


Re: [R] write.csv fails with $ operator invalid for atomic

2009-12-01 Thread John Kane
Where does the table come from?

write.csv(t, file = "t.csv")

looks like it would work



--- On Tue, 12/1/09, ggraves  wrote:

> From: ggraves 
> Subject: [R]  write.csv fails with $ operator invalid for atomic
> To: r-help@r-project.org
> Received: Tuesday, December 1, 2009, 1:36 PM
> 
> I want to export a csv file so I can do other things with
> it.
> 
> I issue this command to break down years as to whether it
> was windy or not:
> 
> t<-tapply(TURB,list(year,windy),mean,na.rm=T)
> 
> which results in:
> 
> > t
>             no   
>    yes
> 1990 21.516514  39.86400
> 1991 13.580435  28.87500
> 1992 12.171429  22.93913
> 1993 21.550893  26.41200
> 1994 12.003913  40.76928
> 1995 14.707917  35.39057
> 1996 22.041765  44.54927
> 1997 17.577625  31.60761
> 1998 26.283978  34.36190
> 1999 14.597922  43.85804
> 2000 30.805139  63.06042
> 2001 23.204545  36.64634
> 2002 21.062791  32.86696
> 2003 14.487111  33.68727
> 2004 36.294595  73.38125
> 2005 49.089583 114.28333
> 2006 44.941667  89.37917
> 2007 57.456667  70.00435
> 2008 52.251163  89.83864
> 2009 24.212821  37.49375
> 
> when I issue this command
> 
> write.csv(t$table, file = "t.csv")
> 
> I get the error
> 
> ERROR $ operator is invalid for atomic vectors
> 
> ??
> 
> 
> -- 
> View this message in context: 
> http://n4.nabble.com/write-csv-fails-with-operator-invalid-for-atomic-tp932414p932414.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.
> 


  __
Yahoo! Canada Toolbar: Search from anywhere on the web, and bookmark your 
favourite sites. Download it now
http://ca.toolbar.yahoo.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] write.csv fails with $ operator invalid for atomic

2009-12-01 Thread ggraves

It was in some documentation along with using data.frame and other entries that 
didn't work.  Can't explain why I didn't try it "as is".
 
Gregory A. Graves
Lead Scientist
REstoration COoordination and VERification (RECOVER) 
Restoration Sciences Department
South Florida Water Management District
Phones:  DESK:  561 / 682 - 2429
  CELL:  561 / 719 - 8157
 



From: John Kane-2 [via R] [mailto:ml-node+932595-1696738...@n4.nabble.com]
Sent: Tue 12/1/2009 5:12 PM
To: Graves, Gregory
Subject: Re: [R] write.csv fails with $ operator invalid for atomic


Where does the table come from? 

write.csv(t, file = "t.csv") 

looks like it would work 



--- On Tue, 12/1/09, ggraves <[hidden email] 
 > wrote: 


> From: ggraves <[hidden email] 
>  > 
> Subject: [R]  write.csv fails with $ operator invalid for atomic 
> To: [hidden email] 
>   
> Received: Tuesday, December 1, 2009, 1:36 PM 
> 
> I want to export a csv file so I can do other things with 
> it. 
> 
> I issue this command to break down years as to whether it 
> was windy or not: 
> 
> t<-tapply(TURB,list(year,windy),mean,na.rm=T) 
> 
> which results in: 
> 
> > t 
> no
>yes 
> 1990 21.516514  39.86400 
> 1991 13.580435  28.87500 
> 1992 12.171429  22.93913 
> 1993 21.550893  26.41200 
> 1994 12.003913  40.76928 
> 1995 14.707917  35.39057 
> 1996 22.041765  44.54927 
> 1997 17.577625  31.60761 
> 1998 26.283978  34.36190 
> 1999 14.597922  43.85804 
> 2000 30.805139  63.06042 
> 2001 23.204545  36.64634 
> 2002 21.062791  32.86696 
> 2003 14.487111  33.68727 
> 2004 36.294595  73.38125 
> 2005 49.089583 114.28333 
> 2006 44.941667  89.37917 
> 2007 57.456667  70.00435 
> 2008 52.251163  89.83864 
> 2009 24.212821  37.49375 
> 
> when I issue this command 
> 
> write.csv(t$table, file = "t.csv") 
> 
> I get the error 
> 
> ERROR $ operator is invalid for atomic vectors 
> 
> ?? 
> 
> 
> -- 
> View this message in context: 
> http://n4.nabble.com/write-csv-fails-with-operator-invalid-for-atomic-tp932414p932414.html
> Sent from the R help mailing list archive at Nabble.com. 
> 
> __ 
> [hidden email] 
>   
> mailing list 
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, 
> reproducible code. 
> 


  __ 
Yahoo! Canada Toolbar: Search from anywhere on the web, and bookmark your 
favourite sites. Download it now 
http://ca.toolbar.yahoo.com  . 

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





View message @ 
http://n4.nabble.com/write-csv-fails-with-operator-invalid-for-atomic-tp932414p932595.html
 
To unsubscribe from write.csv fails with $ operator invalid for atomic, click 
here < (link removed) > . 


-- 
View this message in context: 
http://n4.nabble.com/write-csv-fails-with-operator-invalid-for-atomic-tp932414p932605.html
Sent from the R help mailing list archive at Nabble.com.

[[alternative HTML version deleted]]

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


  1   2   >