Re: [R] test if a package is installed

2010-04-03 Thread Vincent Davis
>
> @Jorge

# defining a function

is.installed <- function(mypkg) is.element(mypkg, installed.packages()[,1])


Thanks for that

*Vincent Davis
720-301-3003 *
vinc...@vincentdavis.net
 my blog  |
LinkedIn


On Sat, Apr 3, 2010 at 10:50 PM, Jorge Ivan Velez
wrote:

> Hi Vincent,
>
> Perhaps the following might work:
>
> # defining a function
> is.installed <- function(mypkg) is.element(mypkg, installed.packages()[,1])
>
> R> is.installed('MASS')
> [1] TRUE
>
> R> is.installed('base')
> [1] TRUE
>
> R> is.installed('ROCR')
> [1] FALSE
>
> HTH,
> Jorge
>
>
> On Sun, Apr 4, 2010 at 12:40 AM, Vincent Davis <> wrote:
>
>> I am aware of .packages(all.available = TRUE) but I would like to just
>> ask .packages('base') and get TRUE or even better check a list of packages
>> and get a true/false list back. Is there a way to do this?
>>
>>  *Vincent Davis
>> 720-301-3003 *
>> vinc...@vincentdavis.net
>>  my blog  |
>> LinkedIn
>>
>>[[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] test if a package is installed

2010-04-03 Thread Jorge Ivan Velez
Hi Vincent,

Perhaps the following might work:

# defining a function
is.installed <- function(mypkg) is.element(mypkg, installed.packages()[,1])

R> is.installed('MASS')
[1] TRUE

R> is.installed('base')
[1] TRUE

R> is.installed('ROCR')
[1] FALSE

HTH,
Jorge


On Sun, Apr 4, 2010 at 12:40 AM, Vincent Davis <> wrote:

> I am aware of .packages(all.available = TRUE) but I would like to just
> ask .packages('base') and get TRUE or even better check a list of packages
> and get a true/false list back. Is there a way to do this?
>
>  *Vincent Davis
> 720-301-3003 *
> vinc...@vincentdavis.net
>  my blog  |
> LinkedIn
>
>[[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] Export bug? Hist() vs. barchart().

2010-04-03 Thread Jeff Brown

You were right.  Jorge Velez wrote me off-list and pointed out that I need to
call print() to write the barplot to the device, just as explained in the
FAQ.

Thanks!
-- 
View this message in context: 
http://n4.nabble.com/Export-bug-Hist-vs-barchart-tp1750593p1750672.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] test if a package is installed

2010-04-03 Thread Vincent Davis
I am aware of .packages(all.available = TRUE) but I would like to just
ask .packages('base') and get TRUE or even better check a list of packages
and get a true/false list back. Is there a way to do this?

  *Vincent Davis
720-301-3003 *
vinc...@vincentdavis.net
 my blog  |
LinkedIn

[[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] Palette color order in bwplot (lattice violin plot) vs. boxplot

2010-04-03 Thread Deepayan Sarkar
On Thu, Apr 1, 2010 at 4:10 AM, Luigi Ponti  wrote:
> Hello,
>
> I am trying to give different colors to boxes in a violin plot obtained via
> bwplot from lattice package using a color palette from RColorBrewer:
>
>> require(RColorBrewer)
>> MyPalette <- brewer.pal(6, "Set3")
>
> A call to:
>
>> boxplot(count ~ spray, data = InsectSprays, col = MyPalette)
>
> yields the example boxplot with each box colored according to the different
> colors from MyPalette. In addition, boxes are colored with the same color
> order of MyPalette. See
>
>> display.brewer.pal(6, "Set3")
>
> However, when I do the same thing with a violin plot from the lattice
> package
>> require(lattice)
>> bwplot(count ~ spray, data = InsectSprays,
> +        panel = function(..., box.ratio) {
> +            panel.violin(..., col = "transparent",
> +                         varwidth = FALSE, box.ratio = box.ratio)
> +            panel.bwplot(..., fill = MyPalette, box.ratio = .1)
> +        } )
>
> boxplots are colored with the right colors (each box has a different color)
> but with a different color order -- too bad because I would like to color
> code the plot according to certain pre-defined colors. Same thing (wrong
> color order) with a simple bwplot:
>
>> bwplot(count ~ spray, data = InsectSprays, fill = MyPalette)
>
> Is there a way to get the right color (i.e. same order as in MyPalette) in
> bwplot/panel.violin?

The correct approach would be along the lines of

bwplot(count ~ spray, data = InsectSprays,
   groups = spray,
   panel = panel.superpose,
   panel.groups = panel.violin,
   col = MyPalette)

(unlike panel.xyplot etc., panel.bwplot does not explicitly handle grouping).

-Deepayan

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


Re: [R] Export bug? Hist() vs. barchart().

2010-04-03 Thread David Winsemius


On Apr 3, 2010, at 7:20 PM, Jeff Brown wrote:



Hi,

If you want to export a single bar chart, this works:

png( "ET" );
barchart( data[,"ET"] )
dev.off()

quartz_off_screen
   2

But if you want to export a few of them, this does not:

factorCols <- c("MR","ET");
sapply( factorCols, function(x) {

+   png( x );
+   barchart( data[, x] );
+   dev.off();
+ } );
MR.quartz_off_screen ET.quartz_off_screen
  22

R gives no indication of an error, but the files do not appear in the
working directory as they should.  Why is that?

I'm led to suspect this is a bug,


It much more likely to be related to the FAQ item (memory suggested it  
was 7.21, but checking I see that I'm off by one)  that discusses why  
lattice functions won't plot as inexperienced useRs expect them to.


--
David



because it works fine if you use hist()
instead of barchart():

factorCols <- c("YR","AG");
sapply( factorCols, function(x) {

+   png( x );
+   hist( data[, x] );
+   dev.off();
+ } );
YR.quartz_off_screen AG.quartz_off_screen
  22

Thanks,
Jeff
--
View this message in context: 
http://n4.nabble.com/Export-bug-Hist-vs-barchart-tp1750593p1750593.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.


David Winsemius, MD
West Hartford, CT

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


[R] Export bug? Hist() vs. barchart().

2010-04-03 Thread Jeff Brown

Hi,

If you want to export a single bar chart, this works:
> png( "ET" );
> barchart( data[,"ET"] )
> dev.off()
quartz_off_screen 
2 

But if you want to export a few of them, this does not:
> factorCols <- c("MR","ET");
> sapply( factorCols,   function(x) {
+   png( x );
+   barchart( data[, x] );
+   dev.off();
+ } );
MR.quartz_off_screen ET.quartz_off_screen 
   22 

R gives no indication of an error, but the files do not appear in the
working directory as they should.  Why is that?

I'm led to suspect this is a bug, because it works fine if you use hist()
instead of barchart():
> factorCols <- c("YR","AG");
> sapply( factorCols,   function(x) {
+   png( x );
+   hist( data[, x] );
+   dev.off();
+ } );
YR.quartz_off_screen AG.quartz_off_screen 
   22 

Thanks,
Jeff
-- 
View this message in context: 
http://n4.nabble.com/Export-bug-Hist-vs-barchart-tp1750593p1750593.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] compare two fingerprint images

2010-04-03 Thread Jim Lemon

On 04/04/2010 05:18 AM, Juan Antonio Gil Pascual wrote:

Hi Bernado

I need to compare two fingerprint images and let me know if you can do
with R. I have used the technique of minutiae but it seems to work
better with the cross-correlation and wanted to know if you can do with R.


Hi Juan,
If you're using minutiae, you will want something like character 
recognition to identify the (admittedly arbitrary) elements of 
fingerprints like loops and whorls and their relative extents and 
positions. I don't know whether there is much character recognition 
stuff done in R, but it would certainly be related.


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] compare two fingerprint images

2010-04-03 Thread Tal Galili
How do you nominate a "fortune" ?

First run this code:

for (i in 1:1000) cat("

   Please follow the Posting Guide.

")


>
>




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




On Sat, Apr 3, 2010 at 11:07 PM, Charles C. Berry wrote:

> On Sat, 3 Apr 2010, Juan Antonio Gil Pascual wrote:
>
>  Hi Bernado
>> I need to compare two fingerprint images and let me know if you can do
>> with R. I have used the technique of minutiae but it seems to work better
>> with the cross-correlation and wanted to know if you can do with R.
>>
>
>
> First run this code:
>
> for (i in 1:1000) cat("
>
>Please follow the Posting Guide.
>
> ")
>
> And if that didn't help run
>
>help.request()
>
> giving forthright answers to the questions.
>
> Then return with commented, minimal, self-contained, reproducible code (as
> you were asked to do).
>
> You might also include some discussion of why the functions and packages
> revealed by the 'Do Your Homework' section of the Posting Guide fall short
> of your needs. Better still illustrate such problems with the code you
> submit here.
>
> HTH,
>
> Chuck
>
>
>
>
>> Thank you very much
>>
>> Juan
>>
>>
>> Bernardo Rangel Tura escribió:
>>
>>>  On Fri, 2010-04-02 at 20:52 +0200, Juan Antonio Gil Pascual wrote:
>>>
>>> >  Hello
>>> >  I wanted to compare two fingerprint images. How do you do with R?.
>>> >  Is there a role for cross-correlation of images?
>>> > >  Thanks
>>> > >
>>>  Hi juan,
>>>
>>>  You was a quite vage in your question, so I don't know exactly what you
>>>  need but try this;
>>>
>>>  require(ReadImages)
>>>  x <- read.jpeg(image1)
>>>  x1 <- read.jpeg(image2)
>>>  table(x1==x)
>>>
>>>
>>>
>>>
>> --
>> =
>> Juan Antonio Gil Pascual
>> Prof. Titular de Métodos de Investigación en Educación
>> correo: j...@edu.uned.es
>> web: www.uned.es/personal/jgil
>>
>> U.N.E.D.
>> Fac. de Educación
>> Dpto. MIDE I
>> Pº Senda del Rey,7 desp. 122
>> 28040 MADRID
>> Tel. 91 398 72 79
>> Fax. 91 398 72 88
>>
>>
>> Antes de imprimir este correo piense bien si es necesario hacerlo: El
>> medioambiente es cosa de todos
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
>>
> 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.
>
>

[[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] compare two fingerprint images

2010-04-03 Thread Barry Rowlingson
On Sat, Apr 3, 2010 at 8:18 PM, Juan Antonio Gil Pascual
 wrote:

> I need to compare two fingerprint images and let me know if you can do with
> R. I have used the technique of minutiae but it seems to work better with
> the cross-correlation and wanted to know if you can do with R.

 I don't think any pure R code will be as fast as whatever they use on
CSI:Miami. If they are using R, they coded the critical parts in C.
And then ported R to HollywoodOS:

http://c2.com/cgi/wiki?HollywoodOs

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] compare two fingerprint images

2010-04-03 Thread Bernardo Rangel Tura
On Sat, 2010-04-03 at 21:18 +0200, Juan Antonio Gil Pascual wrote:
> Hi Bernado
> 
> I need to compare two fingerprint images and let me know if you can do 
> with R. I have used the technique of minutiae but it seems to work 
> better with the cross-correlation and wanted to know if you can do with R.
> 
> Thank you very much
> 
> Juan
> 
> 
> Bernardo Rangel Tura escribió:
> > On Fri, 2010-04-02 at 20:52 +0200, Juan Antonio Gil Pascual wrote:
> >   
> >> Hello
> >> I wanted to compare two fingerprint images. How do you do with R?.
> >> Is there a role for cross-correlation of images?
> >>
> >> Thanks
> >>
> >> 
> >
> > Hi juan,
> >
> > You was a quite vage in your question, so I don't know exactly what you
> > need but try this;
> >
> > require(ReadImages)
> > x <- read.jpeg(image1)
> > x1 <- read.jpeg(image2)
> > table(x1==x)
> >
> >
> >   
> 

Juan,

I don't know cross-correlation to images but I know this for time series
in this case:


ccf(ts(as.numeric(x)),ts(as.numeric(x1)))


-- 
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] histogram-like barplot? (or reverse?)

2010-04-03 Thread Nick Matzke


Nevermind, I think I got it:


tempdata = data.frame(cbind(x,y))

xyplot(y ~ x, data=tempdata,
xlab=xlabel,
ylab=ylabel,
xlim=c(1.05* min(timebins), 0),
horizontal=FALSE,
col="gray",
scales=list(alternating=FALSE,
tck=c(1,0),
x=list(at=timebins,
labels=timebins)),
panel=function(...)
{
panel.fill(col="white")
panel.grid(-1,0,lty=3,col="gray")
panel.barchart(...)
},
main="xyplot", box.width=timebin_size
)



Modified/simplified from these post on doing barcharts on 
time series data:


http://www.mail-archive.com/r-help@r-project.org/msg84294.html
http://www.mail-archive.com/r-help@r-project.org/msg84391.html

===
#create the dummy data
digrate <- data.frame(Perc=runif(30), 
Drate=rep(letters[1:3], 10),


date=c(rep("26-06-2010",9),rep("27-06-2010",21)),

hour=rep(c("18:00","20:00","23:00","03:00","05:30","08:00","10:00","14:40","17:30","19:30"),each=3))
digrate$hora<-paste(digrate$date,digrate$hour)
digrate
library(lattice)

# barchart example does not get the time scale
# get the time range for the x-axes in graph 2
r<-range(strptime(digrate$hora,"%d-%m-%Y %H:%M"))


xyplot(Perc ~ as.POSIXct(hora,format="%d-%m-%Y %H:%M"),
   data=digrate, groups=Drate, ## key=leg,
   xlab="time of the day",
   horizontal=FALSE,
scales=list(alternating=FALSE,
  tck=c(1,0),
  x=list(at=seq(r[1],r[2],by="hour"),
labels=format(seq(r[1],r[2],"hours"), format="%H"))),
   panel=function(...) {
 panel.fill(col="white")
 panel.grid(-1,0,lty=3,col="gray")
 panel.barchart(...)
   },
  main="xyplot", box.width=5000
  )

===


Nick Matzke wrote:

Hi,

I have a simple task I can't figure out.  I'd like to take some 
measurements I made, e.g.:


year (y-axis)
1
2
3
4
5
6

counts (x-axis)
10
10
20
30
40
50

And then, make a barplot with the x-axis ticks (representing the borders 
between years) between the bars.


However, barplot seems to force you to make the x-axis arbitrary 
categories.  I want it to be continuous (as in a histogram) as I have to 
bin the data by a series of different time periods (1 year intervals, 2 
year intervals, etc.) and then plot several of the histograms/barplots 
in a series of figures to show how differing resolution changes the 
pattern.


I have calculated the counts manually, but I can't just pipe the raw 
data into hist due to its weirdness (species stratigraphic ranges).


Basically I want a scatterplot to plot x,y data points, except with 
vertical bars instead of points.


I've tried hacking hist() but so far without luck.

Any help greatly appreciated!

Nick




--

Nicholas J. Matzke
Ph.D. Student, Graduate Student Researcher
Huelsenbeck Lab
Center for Theoretical Evolutionary Genomics
4151 VLSB (Valley Life Sciences Building)
Department of Integrative Biology
University of California, Berkeley

Graduate Student Instructor, IB200A
Principles of Phylogenetics: Systematics
http://ib.berkeley.edu/courses/ib200a/index.shtml

Lab websites:
http://ib.berkeley.edu/people/lab_detail.php?lab=54
http://fisher.berkeley.edu/cteg/hlab.html
Dept. personal page: 
http://ib.berkeley.edu/people/students/person_detail.php?person=370
Lab personal page: 
http://fisher.berkeley.edu/cteg/members/matzke.html

Lab phone: 510-643-6299
Dept. fax: 510-643-6264
Cell phone: 510-301-0179
Email: mat...@berkeley.edu

Mailing address:
Department of Integrative Biology
3060 VLSB #3140
Berkeley, CA 94720-3140

-
"[W]hen people thought the earth was flat, they were wrong. 
When people thought the earth was spherical, they were 
wrong. But if you think that thinking the earth is spherical 
is just as wrong as thinking the earth is flat, then your 
view is wronger than both of them put together."


Isaac Asimov (1989). "The Relativity of Wrong." The 
Skeptical Inquirer, 14(1), 35-44. Fall 1989.

http://chem.tufts.edu/AnswersInScience/RelativityofWrong.htm

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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-like barplot? (or reverse?)

2010-04-03 Thread Kjetil Halvorsen
It might work to just say
barplot(table(...))

Kjetil

CC  Or maybe even   plot(table(...))



On Sat, Apr 3, 2010 at 5:14 PM, Bob O'Hara  wrote:
> Hi, Nick!
>
> plot(.., type="h", lwd=5, lend=3, xaxt="n")
> axis(1, at=c(...))
>
> is the way to start, after which you play with the code. For years.
>
> Bob
>
> On 3 April 2010 21:52, Nick Matzke  wrote:
>
>> Hi,
>>
>> I have a simple task I can't figure out.  I'd like to take some
>> measurements I made, e.g.:
>>
>> year (y-axis)
>> 1
>> 2
>> 3
>> 4
>> 5
>> 6
>>
>> counts (x-axis)
>> 10
>> 10
>> 20
>> 30
>> 40
>> 50
>>
>> And then, make a barplot with the x-axis ticks (representing the borders
>> between years) between the bars.
>>
>> However, barplot seems to force you to make the x-axis arbitrary
>> categories.  I want it to be continuous (as in a histogram) as I have to bin
>> the data by a series of different time periods (1 year intervals, 2 year
>> intervals, etc.) and then plot several of the histograms/barplots in a
>> series of figures to show how differing resolution changes the pattern.
>>
>> I have calculated the counts manually, but I can't just pipe the raw data
>> into hist due to its weirdness (species stratigraphic ranges).
>>
>> Basically I want a scatterplot to plot x,y data points, except with
>> vertical bars instead of points.
>>
>> I've tried hacking hist() but so far without luck.
>>
>> Any help greatly appreciated!
>>
>> Nick
>>
>>
>> --
>> 
>> Nicholas J. Matzke
>> Ph.D. Student, Graduate Student Researcher
>> Huelsenbeck Lab
>> Center for Theoretical Evolutionary Genomics
>> 4151 VLSB (Valley Life Sciences Building)
>> Department of Integrative Biology
>> University of California, Berkeley
>>
>> Graduate Student Instructor, IB200A
>> Principles of Phylogenetics: Systematics
>> http://ib.berkeley.edu/courses/ib200a/index.shtml
>>
>> Lab websites:
>> http://ib.berkeley.edu/people/lab_detail.php?lab=54
>> http://fisher.berkeley.edu/cteg/hlab.html
>> Dept. personal page:
>> http://ib.berkeley.edu/people/students/person_detail.php?person=370
>> Lab personal page: http://fisher.berkeley.edu/cteg/members/matzke.html
>> Lab phone: 510-643-6299
>> Dept. fax: 510-643-6264
>> Cell phone: 510-301-0179
>> Email: mat...@berkeley.edu
>>
>> Mailing address:
>> Department of Integrative Biology
>> 3060 VLSB #3140
>> Berkeley, CA 94720-3140
>>
>> -
>> "[W]hen people thought the earth was flat, they were wrong. When people
>> thought the earth was spherical, they were wrong. But if you think that
>> thinking the earth is spherical is just as wrong as thinking the earth is
>> flat, then your view is wronger than both of them put together."
>>
>> Isaac Asimov (1989). "The Relativity of Wrong." The Skeptical Inquirer,
>> 14(1), 35-44. Fall 1989.
>> http://chem.tufts.edu/AnswersInScience/RelativityofWrong.htm
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>
>
> --
> Bob O'Hara
>
> Biodiversity and Climate Research Centre
> Senckenberganlage 25
> D-60325 Frankfurt am Main,
> Germany
>
> Tel: +49 69 798 40216
> Mobile: +49 1515 888 5440
> WWW:   http://www.bik-f.de/root/index.php?page_id=219
> Blog: http://blogs.nature.com/boboh
> Google Wave: rni@googlewave.com
> Journal of Negative Results - EEB: www.jnr-eeb.org
>
>        [[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] tetrachoric correlations

2010-04-03 Thread Kjetil Halvorsen
Did you REALLY try
 RSiteSearch("tetrachoric")
before sending your email?

Kjetil

On Fri, Apr 2, 2010 at 7:25 PM, HAKAN DEMIRTAS  wrote:
> Hi,
>
> Is there any R library/package that calculates tetrachoric correlations from 
> given marginals and Pearson correlations among ordinal variables?
>
> Inputs to polychor function in polycor package are either contingency tables 
> or ordinal data themselves. I am looking for something that takes marginal 
> distributions and Pearson correlation as inputs.
>
> For example, Y1=(1,2,3) with P(Y1=1)=0.3, P(Y1=2)=0.5, P(Y1=3)=0.2 and
> Y2=(1,2) with P(Y2=1)=0.6, P(Y2=2)=0.4, and corr(Y1,Y2)=0.5 (Pearson
> correlation among ordinal variables)
>
> How do I calculate the tetrachoric correlation here?
>
> Thanks,
> Hakan Demirtas
>        [[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] histogram-like barplot? (or reverse?)

2010-04-03 Thread Bob O'Hara
Hi, Nick!

plot(.., type="h", lwd=5, lend=3, xaxt="n")
axis(1, at=c(...))

is the way to start, after which you play with the code. For years.

Bob

On 3 April 2010 21:52, Nick Matzke  wrote:

> Hi,
>
> I have a simple task I can't figure out.  I'd like to take some
> measurements I made, e.g.:
>
> year (y-axis)
> 1
> 2
> 3
> 4
> 5
> 6
>
> counts (x-axis)
> 10
> 10
> 20
> 30
> 40
> 50
>
> And then, make a barplot with the x-axis ticks (representing the borders
> between years) between the bars.
>
> However, barplot seems to force you to make the x-axis arbitrary
> categories.  I want it to be continuous (as in a histogram) as I have to bin
> the data by a series of different time periods (1 year intervals, 2 year
> intervals, etc.) and then plot several of the histograms/barplots in a
> series of figures to show how differing resolution changes the pattern.
>
> I have calculated the counts manually, but I can't just pipe the raw data
> into hist due to its weirdness (species stratigraphic ranges).
>
> Basically I want a scatterplot to plot x,y data points, except with
> vertical bars instead of points.
>
> I've tried hacking hist() but so far without luck.
>
> Any help greatly appreciated!
>
> Nick
>
>
> --
> 
> Nicholas J. Matzke
> Ph.D. Student, Graduate Student Researcher
> Huelsenbeck Lab
> Center for Theoretical Evolutionary Genomics
> 4151 VLSB (Valley Life Sciences Building)
> Department of Integrative Biology
> University of California, Berkeley
>
> Graduate Student Instructor, IB200A
> Principles of Phylogenetics: Systematics
> http://ib.berkeley.edu/courses/ib200a/index.shtml
>
> Lab websites:
> http://ib.berkeley.edu/people/lab_detail.php?lab=54
> http://fisher.berkeley.edu/cteg/hlab.html
> Dept. personal page:
> http://ib.berkeley.edu/people/students/person_detail.php?person=370
> Lab personal page: http://fisher.berkeley.edu/cteg/members/matzke.html
> Lab phone: 510-643-6299
> Dept. fax: 510-643-6264
> Cell phone: 510-301-0179
> Email: mat...@berkeley.edu
>
> Mailing address:
> Department of Integrative Biology
> 3060 VLSB #3140
> Berkeley, CA 94720-3140
>
> -
> "[W]hen people thought the earth was flat, they were wrong. When people
> thought the earth was spherical, they were wrong. But if you think that
> thinking the earth is spherical is just as wrong as thinking the earth is
> flat, then your view is wronger than both of them put together."
>
> Isaac Asimov (1989). "The Relativity of Wrong." The Skeptical Inquirer,
> 14(1), 35-44. Fall 1989.
> http://chem.tufts.edu/AnswersInScience/RelativityofWrong.htm
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Bob O'Hara

Biodiversity and Climate Research Centre
Senckenberganlage 25
D-60325 Frankfurt am Main,
Germany

Tel: +49 69 798 40216
Mobile: +49 1515 888 5440
WWW:   http://www.bik-f.de/root/index.php?page_id=219
Blog: http://blogs.nature.com/boboh
Google Wave: rni@googlewave.com
Journal of Negative Results - EEB: www.jnr-eeb.org

[[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] compare two fingerprint images

2010-04-03 Thread Charles C. Berry

On Sat, 3 Apr 2010, Juan Antonio Gil Pascual wrote:


Hi Bernado
I need to compare two fingerprint images and let me know if you can do with 
R. I have used the technique of minutiae but it seems to work better with the 
cross-correlation and wanted to know if you can do with R.



First run this code:

for (i in 1:1000) cat("

Please follow the Posting Guide.

")

And if that didn't help run

help.request()

giving forthright answers to the questions.

Then return with commented, minimal, self-contained, reproducible code (as 
you were asked to do).


You might also include some discussion of why the functions and packages 
revealed by the 'Do Your Homework' section of the Posting Guide fall short 
of your needs. Better still illustrate such problems with the code you 
submit here.


HTH,

Chuck




Thank you very much

Juan


Bernardo Rangel Tura escribió:

 On Fri, 2010-04-02 at 20:52 +0200, Juan Antonio Gil Pascual wrote:

>  Hello
>  I wanted to compare two fingerprint images. How do you do with R?.
>  Is there a role for cross-correlation of images?
> 
>  Thanks
> 
> 


 Hi juan,

 You was a quite vage in your question, so I don't know exactly what you
 need but try this;

 require(ReadImages)
 x <- read.jpeg(image1)
 x1 <- read.jpeg(image2)
 table(x1==x)





--
=
Juan Antonio Gil Pascual
Prof. Titular de Métodos de Investigación en Educación
correo: j...@edu.uned.es
web: www.uned.es/personal/jgil

U.N.E.D.
Fac. de Educación
Dpto. MIDE I
Pº Senda del Rey,7 desp. 122
28040 MADRID
Tel. 91 398 72 79
Fax. 91 398 72 88


Antes de imprimir este correo piense bien si es necesario hacerlo: El 
medioambiente es cosa de todos


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




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.


[R] histogram-like barplot? (or reverse?)

2010-04-03 Thread Nick Matzke

Hi,

I have a simple task I can't figure out.  I'd like to take 
some measurements I made, e.g.:


year (y-axis)
1
2
3
4
5
6

counts (x-axis)
10
10
20
30
40
50

And then, make a barplot with the x-axis ticks (representing 
the borders between years) between the bars.


However, barplot seems to force you to make the x-axis 
arbitrary categories.  I want it to be continuous (as in a 
histogram) as I have to bin the data by a series of 
different time periods (1 year intervals, 2 year intervals, 
etc.) and then plot several of the histograms/barplots in a 
series of figures to show how differing resolution changes 
the pattern.


I have calculated the counts manually, but I can't just pipe 
the raw data into hist due to its weirdness (species 
stratigraphic ranges).


Basically I want a scatterplot to plot x,y data points, 
except with vertical bars instead of points.


I've tried hacking hist() but so far without luck.

Any help greatly appreciated!

Nick


--

Nicholas J. Matzke
Ph.D. Student, Graduate Student Researcher
Huelsenbeck Lab
Center for Theoretical Evolutionary Genomics
4151 VLSB (Valley Life Sciences Building)
Department of Integrative Biology
University of California, Berkeley

Graduate Student Instructor, IB200A
Principles of Phylogenetics: Systematics
http://ib.berkeley.edu/courses/ib200a/index.shtml

Lab websites:
http://ib.berkeley.edu/people/lab_detail.php?lab=54
http://fisher.berkeley.edu/cteg/hlab.html
Dept. personal page: 
http://ib.berkeley.edu/people/students/person_detail.php?person=370
Lab personal page: 
http://fisher.berkeley.edu/cteg/members/matzke.html

Lab phone: 510-643-6299
Dept. fax: 510-643-6264
Cell phone: 510-301-0179
Email: mat...@berkeley.edu

Mailing address:
Department of Integrative Biology
3060 VLSB #3140
Berkeley, CA 94720-3140

-
"[W]hen people thought the earth was flat, they were wrong. 
When people thought the earth was spherical, they were 
wrong. But if you think that thinking the earth is spherical 
is just as wrong as thinking the earth is flat, then your 
view is wronger than both of them put together."


Isaac Asimov (1989). "The Relativity of Wrong." The 
Skeptical Inquirer, 14(1), 35-44. Fall 1989.

http://chem.tufts.edu/AnswersInScience/RelativityofWrong.htm

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


Re: [R] compare two fingerprint images

2010-04-03 Thread Juan Antonio Gil Pascual

Hi Bernado

I need to compare two fingerprint images and let me know if you can do 
with R. I have used the technique of minutiae but it seems to work 
better with the cross-correlation and wanted to know if you can do with R.


Thank you very much

Juan


Bernardo Rangel Tura escribió:

On Fri, 2010-04-02 at 20:52 +0200, Juan Antonio Gil Pascual wrote:
  

Hello
I wanted to compare two fingerprint images. How do you do with R?.
Is there a role for cross-correlation of images?

Thanks




Hi juan,

You was a quite vage in your question, so I don't know exactly what you
need but try this;

require(ReadImages)
x <- read.jpeg(image1)
x1 <- read.jpeg(image2)
table(x1==x)


  


--
=
Juan Antonio Gil Pascual
Prof. Titular de Métodos de Investigación en Educación
correo: j...@edu.uned.es
web: www.uned.es/personal/jgil

U.N.E.D.
Fac. de Educación
Dpto. MIDE I
Pº Senda del Rey,7 desp. 122
28040 MADRID
Tel. 91 398 72 79
Fax. 91 398 72 88


Antes de imprimir este correo piense bien si es necesario hacerlo: El 
medioambiente es cosa de todos

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

2010-04-03 Thread Uwe Ligges


I know this one is ages old, but I just try to clean up my last two weeks:

Maybe you forgot to ask for

data(varespec )

after loading the package with library(packagename)


Uwe Ligges

On 23.03.2010 14:25, David Winsemius wrote:

The "inner components" of object are not accessible by name. You need to
use the proper functions to retrieve or modify them. You are asked by
the PostingGuide to show your code and be more specific about problems.
Until you do so, that is about all anyone will be able to say about your
mistakes.



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

2010-04-03 Thread Sam Albers
Fantastic. Solved.

Thanks!

On Sat, Apr 3, 2010 at 9:59 AM, Gabor Grothendieck
wrote:

> # 1
> grep returns an index,  not the value unless you use grep(..., value =
> TRUE).
>
> Easier might be:
>
> # 2
> Sample2 <- substr(Sample, 1, 2)
> ifelse(Sample2 == "BU", "up", ifelse(Sample2 == "BM", "mid", "down"))
>
> or
>
> #3 the following which matches the first 2 characters against the
> given list names and return the corresponding list values.
>
> library(gsubfn)
> gsubfn("^(..).", list(BU = "up", BD = "down", BM = "mid"), Sample)
>
> Note that if Sample is a factor rather than character then use
> as.character(Sample) in place of Sample in the last line.
>
>
> On Sat, Apr 3, 2010 at 12:18 PM, Sam Albers 
> wrote:
> > Good Morning,
> >
> > I am trying to create a new column of character strings based on the
> first
> > two letters in a string in another column. I believe that I need to use
> some
> > combination of ifelse and grep but I am not totally sure how to combine
> > them. I am not totally sure why the command below isn't working.
> Obviously
> > it isn't finding anything that matches my criteria but I am not sure why.
> > Any ideas on how I might be able to modify this to get to work? Below is
> > also a data example of what I would like to achieve with this command.
> >
> >> section <- ifelse(Sample==grep("^BU", Sample),"up",
> > ifelse(Sample==grep("^BM", Sample), "mid","down"))
> >> section
> >  [1] "down" "down" "down" "down" "down" "down" "down" "down" "down"
> "down"
> > [11] "down" "down"
> >
> > Thanks in advance.
> >
> > Sam
> >
> >  Sample Transmission section  BU1 0.39353 up  BU2 0.38778 up  BU3 0.42645
> up
> > BM1 0.37510 mid  BM2 0.5103 mid  BM3 0.67224 mid  BD1 0.37482 down  BD2
> > 0.54716 down  BD3 0.50866 down  BU1 0.34869 up  BU2 0.32831 up  BU3
> 0.59877
> > up  BM1 0.52518 mid  BM2 0.94387 mid  BM3 0.94387 mid  BD1 0.46872 down
>  BD2
> > 0.63115 down  BD3 0.45239 down
> > n" "down" "down" "down" "down" "down" "down"
> >
> >
> >
> >
> > --
> > *
> > Sam Albers
> > Geography Program
> > University of Northern British Columbia
> >  University Way
> > Prince George, British Columbia
> > Canada, V2N 4Z9
> > phone: 250 960-6777
> > *
> >
> >[[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.
> >
>



-- 
*
Sam Albers
Geography Program
University of Northern British Columbia
 University Way
Prince George, British Columbia
Canada, V2N 4Z9
phone: 250 960-6777
*

[[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] errors in package nortest

2010-04-03 Thread Uwe Ligges

Will try to contact the maintainer on some private way and report back.

Uwe Ligges



On 29.03.2010 12:11, Robert Offinger wrote:

There are two errors in the R package nortest.
I tried to contact the maintainer Juergen Gross
but to no avail.
How should one progress if the mail address is still
valid but the maintainer does not answer or react in
any way, e.g. since he left the university? The
automatic R checking system for orphaned packages
will not catch such a situation, I guess.
And now on to the errors:

The first error in the function cvm.test was in a way
found by
http://tolstoy.newcastle.edu.au/R/help/06/06/29029.html
but the data set shows only the effect.
Here is the problem:
The approximation formula used in cvm.test has the
effect that the p-value increases for very large values
of the test statistic WW (WW>=1.334).
Therefore very large values of WW result in absurd
p values (as one can see in the given link).
The easiest approach would be to set the resulting
p-value to 0 for large values of WW (e.g. WW>=1.334)

The second error in the function lillie.test was described
in
https://stat.ethz.ch/pipermail/r-devel/2007-July/046282.html
but this error is really harmless since in
p <- pnorm((x - mean(x))/sd(x))
the case sd(x)==0 was not caught.

Robert Offinger

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Multilevel model with lme(): Weird degrees of freedom (group level df > # of groups)

2010-04-03 Thread Bertolt Meyer

Hello everyone,

I am trying to regress applicants' performance in an assessment center  
(AC) on their gender (individual level) and the size of the AC (group  
level) with a multi-level model:


model.0 <- lme(performance ~ ACsize + gender, random = ~1 | ACNumber,  
method = "ML", control = list(opt = "optim"))


I have 1047 applicants in 118 ACs:

> length(performance)
[1] 1047

> length(levels(as.factor(ACNumber)))
[1] 118

There are five AC sizes and gender has two levels (coded as -1 for  
female and 1 for male):


> length(levels(as.factor(ACsize)))
[1] 5

> length(levels(as.factor(gender)))
[1] 2

However, when I examine the model summary, the predictor on the  
individual level (gender) and the predictor on group level (ACsize)  
have the same degrees of freedom:


> summary(model.0)
Linear mixed-effects model fit by maximum likelihood
[...]

Random effects:
 Formula: ~1 | ACNumber
(Intercept)  Residual
StdDev:   0.1650112 0.8146622

Fixed effects: performance ~ ACsize + gender
 Value  Std.Error  DF   t-value p-value
(Intercept)  3.0927051 0.24573622 927 12.585467  0.
ACsize  -0.0568915 0.02782755 927 -2.044431  0.0412
gender   0.1679830 0.02780940 927  6.040510  0.
[...]

Number of Observations: 1047
Number of Groups: 118

How is it possible that the group-level predictor has a df > than the  
number of groups? I am a little at a loss here and would appreciate it  
if someone could explain this to me... What am I missing?


Regards,
Bertolt

--
Dr. Bertolt Meyer
Senior research and teaching associate
Social Psychology, Institute of Psychology, University of Zurich
Binzmuehlestrasse 14, Box 15
CH-8050 Zurich
Switzerland

bme...@sozpsy.uzh.ch
tel:   +41446357282
fax:   +41446357279
mob:   +41788966111

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

2010-04-03 Thread Gabor Grothendieck
# 1
grep returns an index,  not the value unless you use grep(..., value = TRUE).

Easier might be:

# 2
Sample2 <- substr(Sample, 1, 2)
ifelse(Sample2 == "BU", "up", ifelse(Sample2 == "BM", "mid", "down"))

or

#3 the following which matches the first 2 characters against the
given list names and return the corresponding list values.

library(gsubfn)
gsubfn("^(..).", list(BU = "up", BD = "down", BM = "mid"), Sample)

Note that if Sample is a factor rather than character then use
as.character(Sample) in place of Sample in the last line.


On Sat, Apr 3, 2010 at 12:18 PM, Sam Albers  wrote:
> Good Morning,
>
> I am trying to create a new column of character strings based on the first
> two letters in a string in another column. I believe that I need to use some
> combination of ifelse and grep but I am not totally sure how to combine
> them. I am not totally sure why the command below isn't working. Obviously
> it isn't finding anything that matches my criteria but I am not sure why.
> Any ideas on how I might be able to modify this to get to work? Below is
> also a data example of what I would like to achieve with this command.
>
>> section <- ifelse(Sample==grep("^BU", Sample),"up",
> ifelse(Sample==grep("^BM", Sample), "mid","down"))
>> section
>  [1] "down" "down" "down" "down" "down" "down" "down" "down" "down" "down"
> [11] "down" "down"
>
> Thanks in advance.
>
> Sam
>
>  Sample Transmission section  BU1 0.39353 up  BU2 0.38778 up  BU3 0.42645 up
> BM1 0.37510 mid  BM2 0.5103 mid  BM3 0.67224 mid  BD1 0.37482 down  BD2
> 0.54716 down  BD3 0.50866 down  BU1 0.34869 up  BU2 0.32831 up  BU3 0.59877
> up  BM1 0.52518 mid  BM2 0.94387 mid  BM3 0.94387 mid  BD1 0.46872 down  BD2
> 0.63115 down  BD3 0.45239 down
> n" "down" "down" "down" "down" "down" "down"
>
>
>
>
> --
> *
> Sam Albers
> Geography Program
> University of Northern British Columbia
>  University Way
> Prince George, British Columbia
> Canada, V2N 4Z9
> phone: 250 960-6777
> *
>
>        [[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] Using ifelse and grep

2010-04-03 Thread William Dunlap
> -Original Message-
> From: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] On Behalf Of Sam Albers
> Sent: Saturday, April 03, 2010 9:18 AM
> To: r-help@r-project.org
> Subject: [R] Using ifelse and grep
> 
> Good Morning,
> 
> I am trying to create a new column of character strings based 
> on the first
> two letters in a string in another column. I believe that I 
> need to use some
> combination of ifelse and grep but I am not totally sure how 
> to combine
> them. I am not totally sure why the command below isn't 
> working. Obviously
> it isn't finding anything that matches my criteria but I am 
> not sure why.
> Any ideas on how I might be able to modify this to get to 
> work? Below is
> also a data example of what I would like to achieve with this command.
> 
> > section <- ifelse(Sample==grep("^BU", Sample),"up",
> ifelse(Sample==grep("^BM", Sample), "mid","down"))
> > section
>  [1] "down" "down" "down" "down" "down" "down" "down" "down" 
> "down" "down"
> [11] "down" "down"

I'm not sure what Sample contains, but if you break this
nested set of functions calls down you can see what the problem is:
grep() returns the positions of strings that match the pattern.

E.g., if you have
Sample <- c("BU1", "BU2", "BM1", "BD1", "BU3")
then grep("^BU", Sample) returns c(1,2,5) and
Sample==c(1,2,5) doesn't make much sense.

If you instead grepl in a subscript, as in
   section <- character(length(Sample))
   section[grepl("^BU", Sample)] <- "up"
   section[grepl("^BM", Sample)] <- "mid"
   section[grepl("^BD", Sample)] <- "down" 
then section is c("up","up","mid","down","up").

There are lots of ways to make this mapping, especially
for such a simple set of patterns (they don't overlap
and they are all the initial 2 characters of a string).
E.g.,
   map <- c(BU="up", BM="mid", BD="down")
   section <- unname(map[substring(Sample, 1, 2)])
or
   from <- c("BU", "BM", "BD")
   to <- c("up", "mid", "down")
   section <- to[match(substring(Sample,1,2), from)]

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com  

> 
> Thanks in advance.
> 
> Sam
> 
>  Sample Transmission section  BU1 0.39353 up  BU2 0.38778 up  
> BU3 0.42645 up
> BM1 0.37510 mid  BM2 0.5103 mid  BM3 0.67224 mid  BD1 0.37482 
> down  BD2
> 0.54716 down  BD3 0.50866 down  BU1 0.34869 up  BU2 0.32831 
> up  BU3 0.59877
> up  BM1 0.52518 mid  BM2 0.94387 mid  BM3 0.94387 mid  BD1 
> 0.46872 down  BD2
> 0.63115 down  BD3 0.45239 down
> n" "down" "down" "down" "down" "down" "down"
> 
> 
> 
> 
> -- 
> *
> Sam Albers
> Geography Program
> University of Northern British Columbia
>  University Way
> Prince George, British Columbia
> Canada, V2N 4Z9
> phone: 250 960-6777
> *
> 
>   [[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] Writing summary.aov results to a file which can be opened in Excel

2010-04-03 Thread Sam Albers

Julia,

I think exporting to excel takes you a step back. Likely it would be easier
to work solely in R and sort the P values like that. I had to do something
similar only with a bunch of regressions a while back. I found this post
extremely helpful as well as the plyr package

http://www.r-bloggers.com/r-calculating-all-possible-linear-regression-models-for-a-given-set-of-predictors/

Not much help I realize but maybe it will point you in the right path.

Sam
-- 
View this message in context: 
http://n4.nabble.com/Writing-summary-aov-results-to-a-file-which-can-be-opened-in-Excel-tp1749775p1750249.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] RCOM Save

2010-04-03 Thread koj

Sorry. Of course you are right. I am using library(RDCOMClient). I tried the
new suggestion which is the solution. Thank you.
-- 
View this message in context: 
http://n4.nabble.com/RCOM-Save-tp1746602p1749968.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] Using ifelse and grep

2010-04-03 Thread Sam Albers
Good Morning,

I am trying to create a new column of character strings based on the first
two letters in a string in another column. I believe that I need to use some
combination of ifelse and grep but I am not totally sure how to combine
them. I am not totally sure why the command below isn't working. Obviously
it isn't finding anything that matches my criteria but I am not sure why.
Any ideas on how I might be able to modify this to get to work? Below is
also a data example of what I would like to achieve with this command.

> section <- ifelse(Sample==grep("^BU", Sample),"up",
ifelse(Sample==grep("^BM", Sample), "mid","down"))
> section
 [1] "down" "down" "down" "down" "down" "down" "down" "down" "down" "down"
[11] "down" "down"

Thanks in advance.

Sam

 Sample Transmission section  BU1 0.39353 up  BU2 0.38778 up  BU3 0.42645 up
BM1 0.37510 mid  BM2 0.5103 mid  BM3 0.67224 mid  BD1 0.37482 down  BD2
0.54716 down  BD3 0.50866 down  BU1 0.34869 up  BU2 0.32831 up  BU3 0.59877
up  BM1 0.52518 mid  BM2 0.94387 mid  BM3 0.94387 mid  BD1 0.46872 down  BD2
0.63115 down  BD3 0.45239 down
n" "down" "down" "down" "down" "down" "down"




-- 
*
Sam Albers
Geography Program
University of Northern British Columbia
 University Way
Prince George, British Columbia
Canada, V2N 4Z9
phone: 250 960-6777
*

[[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] compare two fingerprint images

2010-04-03 Thread Bernardo Rangel Tura
On Fri, 2010-04-02 at 20:52 +0200, Juan Antonio Gil Pascual wrote:
> Hello
> I wanted to compare two fingerprint images. How do you do with R?.
> Is there a role for cross-correlation of images?
> 
> Thanks
> 

Hi juan,

You was a quite vage in your question, so I don't know exactly what you
need but try this;

require(ReadImages)
x <- read.jpeg(image1)
x1 <- read.jpeg(image2)
table(x1==x)


-- 
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] Derivative of a smooth function

2010-04-03 Thread Chidambaram Annamalai
While this doesn't answer your question, I want to let you know that there
is a proposal for a related improvement within R that will let users compute
(numerically) the derivatives, of any order, of a given function inside of
R. In your case, this means that you will write the smooth spline function,
symbolically f(x), that will interpolate between the points. Using Automatic
Differentiation, the proposed solution, will automatically let you find
f'(x), f''(x), etc.. by using the same function but overloading the meaning
of the arithmetic operators and mathematical functions to act upon a special
data type.

The initial idea
came
from Prof. John Nash who suggested bringing the ability of Automatic
Differentiation to R. We both have, since, collaborated to bring out
adetailed 
proposaloutlining
the various features to be implemented.

Note that, this is being planned to be implemented as part of Google's
Summer of Code program for this year. So, should our proposal be selected,
much more than simple second derivative computation can be accomplished from
within R.

Regards,
Chillu

On Fri, Apr 2, 2010 at 2:06 PM, FMH  wrote:

>
> Dear All,
>
> I've been searching for appropriate codes to compute the rate of change and
> the curvature of  nonparametric regression model whish was denoted by a
> smooth function but unfortunately don't manage to do it. I presume that such
> characteristics from a smooth curve can be determined by the first and
> second derivative operators.
>
> The following are the example of fitting a nonparametric regression model
> via smoothing spline function from the Help file in R.
>
> ###
> attach(cars)
> plot(speed, dist, main = "data(cars)  &  smoothing splines")
> cars.spl <- smooth.spline(speed, dist)
> lines(cars.spl, col = "blue")
> lines(smooth.spline(speed, dist, df=10), lty=2, col = "red")
> legend(5,120,c(paste("default [C.V.] => df =",round(cars.spl$df,1)),"s( * ,
> df = 10)"), col = c("blue","red"), lty = 1:2, bg='bisque')
> detach()
>
> ###
>
>
> Could someone please advice me the appropriate way to determine such
> derivatives on the curves which were fitted by the function above and would
> like to thank you in advance.
>
> Cheers
> Fir
>
>
>
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Restricting optimisation algorithm's parameter space

2010-04-03 Thread Prof. John C Nash
I have a problem. I am  using the NLME library to fit a non-linear model. There is a linear  component to the model that has a couple parameter values that can only  be positive (the coefficients are embedded in a sqrt). When I try and  fit the model to data the search algorithm tries to see if a negative  value for one of these parameter values will produce an optimal fit. When  it does so, it crashes because the equation can not have a negative  value because its in a sqrt function. 


QUESTION: How do I  restrict the optimisation algorithm's  parameter space so 
it does not  search negative values when using GNLM? Are there other Libraries 
that Fit Non-linear models and allow for one to control the parameter space the 
search algorithm is restricted by?


There are two issues here:

1) Rendering optimization codes resistant to inadmissible parameter vectors (sqrt of 
negatives etc.)


2) Providing constraints, particularly parameter bounds, on parameter inputs to 
optimization.

There is quite a lot of activity going on right now with optimization in R. With Ravi 
Varadhan, Kate Mullen and Paul Gilbert, I've been putting some codes on R-forge in the 
OptimizeR project. Doug Bates has done some important kibbitzing. Stefan Theussl and 
others have the R Optimization Infrastructure. There are some differences of focus in 
these projects.


For the present poster, I cannot unfortunately help much on GNLM details, but I can say 
that there are trial versions of methods that will handle bounds (packages minqa, Rcgmin 
and Rvmmin) that accept bounds, along with existing L-BFGS-B in optim(). Rcgmin and Rvmmin 
also accept "masks", that is fixed parameters. These routines are about to go into CRAN.


It appears GNLM is not a CRAN package. Does it permit substitution of optimizer? That is 
something those of us working in optimization strongly recommend to package writers i.e., 
make the optimization a black box so any of a number of tools can be slotted in easily. 
That way, advances or even minor fixups to routines can be included in tools quickly.


However, the "bad parameters" issue, such as trying to take square root of negatives, 
requires the user or the writer of a package that the user calls to code the objective 
function to return a flag -- we are looking at an Inf or an NA, we are not yet fully 
decided on the rules -- AND the optimization package writer to then make it act 
appropriately. Mary Walker-Smith and I had this in BASIC codes in the 1980s, but we were 
maybe a bit ahead of folk and it didn't catch on generally.


If R users have some nice examples of things crashing because of such issues, I would 
really like to hear of them off-list. For us, "nice" means pretty small and easy to build 
into tests. Without such tests -- and users always provide better ones than we can think 
of -- the code is never as robust.


JN

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


Re: [R] roccomp

2010-04-03 Thread Ravi Kulkarni

Yes, there does not seem to be a method for comparing two ROC curves in ROCR.
But I found a discussion in the R-archives which may be useful:

 http://tolstoy.newcastle.edu.au/R/help/06/03/23667.html

You should also see the replies to that post. 

I am also interested in comparing two ROC curves, so if you find an(other)
implementation, I would appreciate knowing about it.

Regards,
  Ravi
-- 
View this message in context: 
http://n4.nabble.com/roccomp-tp1748818p1750071.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] mouse-clicking on xy-plot

2010-04-03 Thread Tal Galili
To extend on Walmes "locator", there is a great article (by Timothée) on how
to extract data points from an image using R:

http://www.r-bloggers.com/getting-data-from-an-image-introductory-post/



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




On Fri, Apr 2, 2010 at 11:24 PM, Walmes Zeviani
wrote:

>
> You can use identify() to obtain coordinates from plotted points but if you
> want any coordinates you could use locator():
>
> > plot(1:10)
> > loc <- locator(n=3)
> > str(loc)
> List of 2
>  $ x: num [1:3] 2.3 5.4 8.29
>  $ y: num [1:3] 6.15 8.33 2.6
> > points(loc$x, loc$y, col=2)
> >
>
> Walmes.
>
> -
> ..ooo0
>
> ...
> ..()... 0ooo...  Walmes Zeviani
> ...\..(.(.)... Master in Statistics and Agricultural
> Experimentation
> \_). )../   walmeszevi...@hotmail.com, Lavras - MG, Brasil
> 
>
> (_/
> --
> View this message in context:
> http://n4.nabble.com/mouse-clicking-on-xy-plot-tp1749562p1749586.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] McDonald's omega calculation. How to???

2010-04-03 Thread Jim Lemon

On 04/03/2010 09:30 AM, sp...@pe.uth.gr wrote:

hi people,
I am a newbie to R and I would appreciate it very much if someone can help me. I
am used to use SPSS so I don’t have experience with writing a script. I have a
questionnaire (questions 1-12) and I would like to use the omega reliability.
Question 1-8 is factor 1 and question 9-12 factor 2. How can I write the
scripit? Can someone help me???


Hi Asterios,
Try the omega function in the psych 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] timeseries plot

2010-04-03 Thread vibha patel
Hello,

YearERISSRIFTRIDFSRIIFSRITRISRIPSRIERI2
199540.1829.4841.4635.9835.5448.1579.5
11.1526.50120923
199642.9642929.144.0139.3130.4247.5179.78
30.6235.83816143
199744.8585724.4844.9247.3835.6154.2781.89
25.4635.83816143
199847.4985727.7347.4350.0530.7357.2181.51
37.8335.83816143
199948.7471424.9950.8356.9836.3956.8483.58
31.6235.83816143
200050.9336.0547.9355.5839.4954.4783.82
39.1735.83816143
200151.2085737.8845.850.5842.6457.4185.82
38.3335.83816143
200253.7933.6152.4952.8649.9364.2787.19
36.1835.83816143
200361.3585730.8758.1770.363.0172.2586.5
48.4135.83816143
200460.2085730.8563.0960.9462.9876.8386.33
40.4435.83816143
200563.4528635.4464.8366.1759.8876.5489.83
51.4835.83816143
200665.1042934.569.7457.3259.1382.0498.46
54.5435.83816143


This is the dataset.
for research i'm applying earth function on the dataset.
the code is given below.

the dataset:HCMecoref

i want to plot prdHCMeco. but as the dataset is divided into training and
testing sets,
it only plots for testing data.

i've refered ur reply.
still having problem.

and yes, i've refered ?ts.plot too.

tr.ecoref<-sample(1:nrow(HCMecoref), 0.8*nrow(HCMecoref))
tst.ecoref<- (1:nrow(HCMecoref))[-tr.ecoref]
HCMecoModel<-earth(ERI~SSRI+FTRI+DFSRI+IFSRI+TRI+SRI+PSRI+ERI2,data=HCMecoref[tr.ecoref,])
prdHCMeco<-predict(HCMecoModel, newdata=HCMecoref[tst.ecoref,])
#e2HCM<-HCMecoref$ERI[tst.ecoref]
#RecoHCM<-(1-sum((e2HCM - prdHCMeco)^2)/sum((e2HCM-mean(e2HCM))^2))
#print(RecoHCM)


ts_ecoref<-ts(data="prdHCMeco",...)
plot(ts_ecoref)

how to plot training dataset and testing dataset together in this case???

Thanks

Vibha.




On Fri, Apr 2, 2010 at 7:12 PM, Gabor Grothendieck
wrote:

> Here are a few ways:
>
> Try this:
>
> set.seed(123)
> TS <- ts(1:25 + rnorm(25))
> tt <- time(TS)
> tt.pred <- end(tt)[1] + 1:10
> both <- ts(c(TS, predict(lm(TS ~ tt), list(tt = tt.pred
> ts.plot(both, TS, gpars = list(type = "o", col = 2:1, pch = 20))
>
> and read ?ts, ?start, ?ts.plot and next time please provide some
> sample data using dput.  See last line to every message and the
> posting guide.
>
> On Fri, Apr 2, 2010 at 8:14 AM, vibha patel 
> wrote:
> > Hello,
> >
> > I am using plot( ) function to plot time-series.
> >
> > it takes time-series object as an argument
> > but i want to plot predicted data with training set, to compare them.
> >
> > is there any function available?
> >
> >
> > Vibha
> >
> >[[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] angles

2010-04-03 Thread Jim Lemon

On 04/03/2010 03:13 AM, Tom_R wrote:


Hi R users,

I would like to construct a sort hybrid vector/scatter plot.

My data is in the following format:  3-column x,y,z data-frame in which
every row is a separate data-point.
The x&  y columns are coordinates, and the z column contains orientation
data (range 0-180 degrees, with East=0&  North=90).

I need to set each x,y, point to have the alignment in z. Hence my 'vectors'
would simply be lines with the mid-point at x,y and without arrow-heads.

R's normal vector plot requires a pair of x,y coords for the start&  end of
each vector, whereas I just have an orientation.


Hi Tom,
Have a look at vectorField in the plotrix 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.