[R] Adding columns to a grouped data frame

2008-04-10 Thread filip rendel

Hello! I'm working with a big data set of patients. The data consists of 
different variables sorted rowwise for each patient. Now I want to add a new 
variable for each patient by adding two different variables of the data  frame. 
  

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

2008-04-10 Thread Patricia García
Hi everyone,

I need to get an error message as an object in the std output console. I can
get it as a file with the following instructions:

# Save error mesage:
error1  <-  file("error1.txt", open="wt")
sink(error1, type="message")
experiment <- function(data)


With this, the error messages get saved in the file, but i need them as
object in order to work with it in the console.

Is it possible?
Thanks


-- 
Patricia García

[[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 create a legend without plot, and to use scientific notation for axes label ?

2008-04-10 Thread Uwe Ligges


Ng Stanley wrote:
> Hi,
> 
> I have a 3 by 2 plots per page, and would like to place a legend on the last
> region. How to do that ?


Create an empty plot, e.g.:

plot(1, type="n", axes=FALSE, xlab="", ylab="")
legend(1, 1, legend = c("Hello", "World"), col=1:2,
lwd=2, cex=3, xjust=0.5, yjust=0.5)

Uwe Ligges



> Also, is there any way to specify scientific notation for axes label ?
> 
>   [[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] How to create a legend without plot, and to use scientific notation for axes label ?

2008-04-10 Thread Uwe Ligges


Uwe Ligges wrote:
> 
> 
> Ng Stanley wrote:
>> Hi,
>>
>> I have a 3 by 2 plots per page, and would like to place a legend on 
>> the last
>> region. How to do that ?
> 
> 
> Create an empty plot, e.g.:
> 
> plot(1, type="n", axes=FALSE, xlab="", ylab="")
> legend(1, 1, legend = c("Hello", "World"), col=1:2,
>lwd=2, cex=3, xjust=0.5, yjust=0.5)
> 
> Uwe Ligges
> 
> 
> 
>> Also, is there any way to specify scientific notation for axes label ?


Oh, I was too quick and forgot the 2nd question:
Use axis() with formatC().

Uwe Ligges





>> [[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] how to read data from table based a condition

2008-04-10 Thread Uwe Ligges


Xin wrote:
> Dear All:
> 
> I imported a table into R. But I want to read a variable (y) from this 
> table conditional on another variable (x=1) in the table.
> 
> y<-data[,7]
> x<-data[,3]
> 
> I want to know the mean of y if corresponding x=1.
> 
> I tried 
> 
> if (x==1) y3<-y 
> 
> It does not work.
> 
> Anyone can give a help?

Is this homework?
Please do read the posting guide and An Introduction to R!

Uwe Ligges


 > Thanks!
> 
> 
> Xin
>   [[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] Beautifying axis tick labels

2008-04-10 Thread Ng Stanley
Hi,

For example, the y axis shows "0 50 150". Is there any way to
beautify the tick labels to get 0 5 10 15, and at the top of y-axis "x10^5"
(superscript 5) ? My plots all have different ylim, how to perform the
beautification automatically ?

Thanks
Stanley

[[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] Beautifying axis tick labels

2008-04-10 Thread Richard . Cotton
> For example, the y axis shows "0 50 150". Is there any way to
> beautify the tick labels to get 0 5 10 15, and at the top of y-axis 
"x10^5"
> (superscript 5) ? My plots all have different ylim, how to perform the
> beautification automatically ?

plot((0:15)*1e5, yaxt="n", ylab="")
axis(side=2, at=c(0,5,15)*1e5, labels=c(0,5,15))
mtext("x10^5", adj=-.1)

Regards,
Richie.

Mathematical Sciences Unit
HSL



ATTENTION:

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

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


Re: [R] how to read data from table based a condition

2008-04-10 Thread Marc Moragues


Xin  hotmail.com> writes:


> 
> y<-data[,7]
> x<-data[,3]
> 
> I want to know the mean of y if corresponding x=1.
> 

Try this:

mean(data[data[,3]==1,data[,7])

You can also look at ?subset.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 read data from table based a condition

2008-04-10 Thread Uwe Ligges


Marc Moragues wrote:
> 
> Xin  hotmail.com> writes:
> 
> 
>> y<-data[,7]
>> x<-data[,3]
>>
>> I want to know the mean of y if corresponding x=1.
>>
> 
> Try this:
> 
> mean(data[data[,3]==1,data[,7])


Folks, please!

1. If you answer, please write at least syntactically valid code (look 
at your index brackets).

Just
   mean(y[x==1])
should do the trick


2. It is a bad idea to do others' homeworks, they won't learn much this way.


Best wishes,
Uwe Ligges





> You can also look at ?subset.
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Stderr

2008-04-10 Thread Patricia García
Hi,

sorry for the last sentence, i was trying to make a generic statement by
writing "function"
So the code has to be:

# Save error mesage:
   error1  <-  file("error1.txt", open="wt")
   sink(error1, type="message")
   experiment <- somefunction(data)

(I mean  no matter what function is...)

error1 is not a variable, y can't watch what contains, it is only the
definition of a file

What i wanted was in fact to create a variable with the error message, I can
do it of course by reading the file, but my question is about doing it
directly.
Thanks



2008/4/10, Uwe Ligges <[EMAIL PROTECTED]>:
>
>
>
> Patricia García wrote:
>
> > Hi everyone,
> >
> > I need to get an error message as an object in the std output console. I
> > can
> > get it as a file with the following instructions:
> >
> > # Save error mesage:
> >error1  <-  file("error1.txt", open="wt")
> >sink(error1, type="message")
> >experiment <- function(data)
> >
> >
> > With this, the error messages get saved in the file, but i need them as
> > object in order to work with it in the console.
> >
>
>
> I'm not sure what you are going to do, note that the last line contains an
> incomplete statement...
>
> If you want an object: you already have got the object error1 ...
>
> If you want error handling facilities, see ?try and its "See Also"
> section.
>
>
> Uwe Ligges
>
>
>  Is it possible?
> > 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.
> >
>


-- 
Patricia García

[[alternative HTML version deleted]]

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


Re: [R] Error: expected the collection operator c error pos 98 (error on line 1)

2008-04-10 Thread Uwe Ligges

Quick inspection shows that we cannot do anything.

In BUGS, Y indicates a scalar and Y[] indicates a vector.
For scalar Y, you need Y=0.0E+00 in your data file, but for vector 
Y[], you need Y=c(0.0E+00) in your data file.

This means you need to know what Y is in the model and I do not see any 
API I can use to ask the BRugs.dll what Y actually is.

So question redirected to Andrew Thomas (in CC).

Best wishes,
Uwe



Uwe Ligges wrote:
> 
> 
> Blanchard, Suzette wrote:
>> Greetings,
>>
>>  
>>
>>   I implemented BRugs to run the EWOC model with a cohort size 
>> N=1.  I output the simulation data using bugsdata(data),  where data 
>> is the following list.
>>
>>  
>>> data
>>
>> $Dose
>>
>> [1] 140
>>
>>  
>>
>> $Y
>>
>> [1] 0
>>
>>  
>>
>> bugsdata(data)  puts out the file data.txt as follows.
>>
>>  
>>
>> list(Dose=1.4E+02, Y=0.0E+00)
>>
>>  
>>
>> after I type the following line
>>
>> modelData("data.txt")  # read data file
>>
>>  
>>
>> I get the ERROR:
>> expected the collection operator c error pos 98 (error on line 1)
>>
>>  
>>
>> If I rewrite the file
>>
>>
>>
>> list(Dose=c(1.4E+02), c(Y=0.0E+00))
>>
>>  
>>
>> it runs fine.  Can you suggest a way to get the output dataset to 
>> automatically put the
>>
>> c( ) on the data when the sample size is 1?
> 
> Hmmm, I will take a look how to implement it.
> 
> I guess you have modeled Y to be a vector by indexing with brackets in 
> your BUGS model? It works for me if I use Y without index brackets in a 
> BUGS model file.

> Best wishes,
> Uwe
> 
> 
> 
>>  
>>
>> Thank you,
>>
>> Suzette
>>
>>  
>>
>> Suzette Blanchard, Ph.D.
>> Assistant Professor, Dept. of Biostatistics
>> City of Hope
>> 1500 East Duarte Rd
>> Duarte, CA 91010-3000
>> ph: (626) 256-4673 ext:64446
>> [EMAIL PROTECTED]
>>  
>>
>>
>> -
>>
>> SECURITY/CONFIDENTIALITY WARNING:  \ This message an...{{dropped:24}}
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/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] bucketing in histograms

2008-04-10 Thread Uwe Ligges


Mark Farnell wrote:
> Hi
> 
> I wish to draw a histogram for a numeric array and specify a bucket
> size (say 5 units  per bar and the height of that bar equals to the
> average of that 5 units)
>
> how can I do that?

Sometimes I wonder what is going on here. Folks, please read the posting 
guide and the help pages before posting!
In this case ?hist clearly reveals how to set breaks.

Uwe Ligges



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

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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: expected the collection operator c error pos 98 (error on line 1)

2008-04-10 Thread Uwe Ligges


Blanchard, Suzette wrote:
> Greetings,
> 
>  
> 
>   I implemented BRugs to run the EWOC model with a cohort size N=1.  I 
> output the simulation data using bugsdata(data),  where data is the following 
> list.
> 
>   
> 
>> data
> 
> $Dose
> 
> [1] 140
> 
>  
> 
> $Y
> 
> [1] 0
> 
>  
> 
> bugsdata(data)  puts out the file data.txt as follows.
> 
>  
> 
> list(Dose=1.4E+02, Y=0.0E+00)
> 
>  
> 
> after I type the following line
> 
> modelData("data.txt")  # read data file
> 
>  
> 
> I get the ERROR: 
> 
> expected the collection operator c error pos 98 (error on line 1)
> 
>  
> 
> If I rewrite the file
> 
> 
> 
> list(Dose=c(1.4E+02), c(Y=0.0E+00))
> 
>  
> 
> it runs fine.  Can you suggest a way to get the output dataset to 
> automatically put the
> 
> c( ) on the data when the sample size is 1?

Hmmm, I will take a look how to implement it.

I guess you have modeled Y to be a vector by indexing with brackets in 
your BUGS model? It works for me if I use Y without index brackets in a 
BUGS model file.

Best wishes,
Uwe



>  
> 
> Thank you,
> 
> Suzette
> 
>  
> 
> Suzette Blanchard, Ph.D.
> Assistant Professor, Dept. of Biostatistics
> City of Hope
> 1500 East Duarte Rd
> Duarte, CA 91010-3000
> ph: (626) 256-4673 ext:64446
> [EMAIL PROTECTED]
>  
> 
> 
> -
> 
> SECURITY/CONFIDENTIALITY WARNING:  \ This message an...{{dropped:24}}
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Stderr

2008-04-10 Thread Uwe Ligges


Patricia García wrote:
> Hi,
> 
> sorry for the last sentence, i was trying to make a generic statement by
> writing "function"
> So the code has to be:
> 
> # Save error mesage:
>error1  <-  file("error1.txt", open="wt")
>sink(error1, type="message")
>experiment <- somefunction(data)
> 
> (I mean  no matter what function is...)


So you want to implement error handling for function somefunction()?


> error1 is not a variable, y can't watch what contains, it is only the
> definition of a file

No, error1 is an *object* that contains information about the opened 
connection to the file.


> What i wanted was in fact to create a variable with the error message, I can
> do it of course by reading the file, but my question is about doing it
> directly.

As I already said in my former mail, error handling is available, please 
read ?try.

Uwe Ligges





> Thanks
> 
> 
> 
> 2008/4/10, Uwe Ligges <[EMAIL PROTECTED]>:
>>
>>
>> Patricia García wrote:
>>
>>> Hi everyone,
>>>
>>> I need to get an error message as an object in the std output console. I
>>> can
>>> get it as a file with the following instructions:
>>>
>>> # Save error mesage:
>>>error1  <-  file("error1.txt", open="wt")
>>>sink(error1, type="message")
>>>experiment <- function(data)
>>>
>>>
>>> With this, the error messages get saved in the file, but i need them as
>>> object in order to work with it in the console.
>>>
>>
>> I'm not sure what you are going to do, note that the last line contains an
>> incomplete statement...
>>
>> If you want an object: you already have got the object error1 ...
>>
>> If you want error handling facilities, see ?try and its "See Also"
>> section.
>>
>>
>> Uwe Ligges
>>
>>
>>  Is it possible?
>>> Thanks
>>>
>>>
>>>
>>>
>>> 
>>>
>>> __
>>> R-help@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide
>>> http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
> 
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 create a legend without plot, and to use scientific notation for axes label ?

2008-04-10 Thread Stanley Ng
Hi, 

How can I use formatC to convert 600 to 6e5 and not 6e+05 ?

> formatC(60)
[1] "6e+05"
> formatC(60, format="e", digit=0)
[1] "6e+05"

-Original Message-
From: Uwe Ligges [mailto:[EMAIL PROTECTED] 
Sent: Thursday, April 10, 2008 17:11
To: Ng Stanley
Cc: r-help
Subject: Re: [R] How to create a legend without plot, and to use scientific
notation for axes label ?



Uwe Ligges wrote:
> 
> 
> Ng Stanley wrote:
>> Hi,
>>
>> I have a 3 by 2 plots per page, and would like to place a legend on 
>> the last region. How to do that ?
> 
> 
> Create an empty plot, e.g.:
> 
> plot(1, type="n", axes=FALSE, xlab="", ylab="")
> legend(1, 1, legend = c("Hello", "World"), col=1:2,
>lwd=2, cex=3, xjust=0.5, yjust=0.5)
> 
> Uwe Ligges
> 
> 
> 
>> Also, is there any way to specify scientific notation for axes label ?


Oh, I was too quick and forgot the 2nd question:
Use axis() with formatC().

Uwe Ligges





>> [[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] How to estimate a hazard ratio using an external hazard function

2008-04-10 Thread Montserrat Rue
Hi,

I would like to compare the hazard functions of two samples using the Cox
proportional hazards model. For sample 1 I have individual time-to-event
data. For sample 2 I don't have individual data, but grouped data that
allows to obtain a hazard function.

I am wondering if there is an R function that allows to obtain a hazard
ratio of the two hazard funtions (under the proportionality assumption)
taking into account the censoring of the data?

I am aware of survexp and survdiff functions, but I am not sure if that is
the best way to do what I need.

Any help will be highly appreciated.

Montse Rue
Department of Basic Medical Sciences
University of Lleida (Spain)


P.S. I sent this message yesterday, but I think I did something wrong and
it did not arrive to the list. I apologize if I sent it twice.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Skipping specified rows in scan or read.table

2008-04-10 Thread Abhijit Dasgupta
Hi Ravi,

One thing I tend to do is, when using read.table, specify the option 
'colClasses='character''. This forces everything to be read as a 
character. From there, as.numeric works fine, and you don't have to deal 
with factors and reconverting them.

Hope this helps
Abhijit

Ravi Varadhan wrote:
> Hi,
>
>  
>
> I have a data file, certain lines of which are character fields.  I would
> like to skip these rows, and read the data file as a numeric data frame.  I
> know that I can skip lines at the beginning with read.table and scan, but is
> there a way to skip a specified sequence of lines (e.g., 1, 2, 10, 11, 19,
> 20, 28, 29, etc.) ?  
>
>  
>
> If I read the entire data file, and then delete the character fields, the
> values are still kept as factors, with each value denoted by its level.
> Since, I have continuous variables, there are as many levels as there are
> values.  I am unable to coerce this to "numeric" mode.  Is there a way to do
> this so that I can then manipulate the numeric data frame?
>
>  
>
> Thanks for any help.
>
> Best,
>
> Ravi.
>
> 
> ---
>
> Ravi Varadhan, Ph.D.
>
> Assistant Professor, The Center on Aging and Health
>
> Division of Geriatric Medicine and Gerontology 
>
> Johns Hopkins University
>
> Ph: (410) 502-2619
>
> Fax: (410) 614-9625
>
> Email: [EMAIL PROTECTED]
>
> Webpage:  http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html
>
>  
>
> 
> 
>
>  
>
>
>   [[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] New user, requesting help with MAC installation of R

2008-04-10 Thread Ingmar Visser
I guess that the default is to plot to a ps file rather than to a  
graphics window when using R from the terminal.
hth, Ingmar

On 10 Apr 2008, at 12:02, Sophia Yancopoulos wrote:

> Hi:
>
> Yesterday I downloaded R and got it up and running on my PC without a
> hitch, not so when I tried to do the same on my Mac powerbook, using
> Mac OSX: version 10.4.11..  I have virtually no experience, so I
> can't tell what exactly went wrong.
>
> At first it appeared that the software loaded correctly, it seemed
> like I was able to install R , and  I even successfully unpacked
> the   package 'scatterplot3d' and was able to run some rudimentary
> commands.
>
> However, I did not get a graphics window  when I tried to follow the
> same sequence of commands (following a tutorial) that worked on my
> PC-- basically everything worked except for the actual plot command:
>
>> plot(x,y)
>
> I did this in the command mode in a terminal window, but no graphics
> window came up.
>
> Can you please advise? THANKS IN ADVANCE!
>
> Sophia
>
> __
>
>
>   [[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.

Ingmar Visser
Department of Psychology, University of Amsterdam
Roetersstraat 15
1018 WB Amsterdam
The Netherlands
t: +31-20-5256723



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

2008-04-10 Thread Uwe Ligges


Patricia García wrote:
> Hi everyone,
> 
> I need to get an error message as an object in the std output console. I can
> get it as a file with the following instructions:
> 
> # Save error mesage:
> error1  <-  file("error1.txt", open="wt")
> sink(error1, type="message")
> experiment <- function(data)
> 
> 
> With this, the error messages get saved in the file, but i need them as
> object in order to work with it in the console.


I'm not sure what you are going to do, note that the last line contains 
an incomplete statement...

If you want an object: you already have got the object error1 ...

If you want error handling facilities, see ?try and its "See Also" section.


Uwe Ligges


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

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] New user, requesting help with MAC installation of R

2008-04-10 Thread Sophia Yancopoulos
Hi:

Yesterday I downloaded R and got it up and running on my PC without a  
hitch, not so when I tried to do the same on my Mac powerbook, using  
Mac OSX: version 10.4.11..  I have virtually no experience, so I  
can't tell what exactly went wrong.

At first it appeared that the software loaded correctly, it seemed  
like I was able to install R , and  I even successfully unpacked  
the   package 'scatterplot3d' and was able to run some rudimentary  
commands.

However, I did not get a graphics window  when I tried to follow the  
same sequence of commands (following a tutorial) that worked on my  
PC-- basically everything worked except for the actual plot command:

 > plot(x,y)

I did this in the command mode in a terminal window, but no graphics  
window came up.

Can you please advise? THANKS IN ADVANCE!

Sophia

__


[[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] bucketing in histograms

2008-04-10 Thread Mark Farnell
Hi

I wish to draw a histogram for a numeric array and specify a bucket
size (say 5 units  per bar and the height of that bar equals to the
average of that 5 units)

how can I do that?

Thanks!

Mark

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


[R] how to read data from table based a condition

2008-04-10 Thread Xin
Dear All:

I imported a table into R. But I want to read a variable (y) from this 
table conditional on another variable (x=1) in the table.

y<-data[,7]
x<-data[,3]

I want to know the mean of y if corresponding x=1.

I tried 

if (x==1) y3<-y 

It does not work.

Anyone can give a help?

Thanks!


Xin
[[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 create a legend without plot, and to use scientific notation for axes label ?

2008-04-10 Thread Hans-Joerg Bibiko

On 10 Apr 2008, at 12:33, Stanley Ng wrote:
> How can I use formatC to convert 600 to 6e5 and not 6e+05 ?
>
>> formatC(60)
> [1] "6e+05"
>> formatC(60, format="e", digit=0)
> [1] "6e+05"


Try this:

gsub("([eE])(\\+?)(\\-?)0+", "\\1\\3", formatC(60, format="e",  
digit=0))

--Hans

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 create a legend without plot, and to use scientific notation for axes label ?

2008-04-10 Thread Hans-Joerg Bibiko

On 10 Apr 2008, at 12:57, Hans-Joerg Bibiko wrote:
>
> On 10 Apr 2008, at 12:33, Stanley Ng wrote:
>> How can I use formatC to convert 600 to 6e5 and not 6e+05 ?
>>
>>> formatC(60)
>> [1] "6e+05"
>>> formatC(60, format="e", digit=0)
>> [1] "6e+05"
>
>
> Try this:
>
> gsub("([eE])(\\+?)(\\-?)0+", "\\1\\3", formatC(60, format="e",
> digit=0))

Sorry this only works up to e+09 or e-09.

This should handle all:

gsub("([eE])(\\+?)(\\-?)0*", "\\1\\3", formatC(60, format="e",  
digit=0))


--Hans

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

2008-04-10 Thread Duncan Murdoch
Ng Stanley wrote:
> Hi,
>
> I am plotting 5 charts using p <- par(mfrow = c(3, 2), how can I place my
> legend in the last region ? I don't wan to put it into the margin.

You should be able to do a blank plot, then plot the legend.  For example,

 > par(mfrow=c(3,2))
 > for (i in 1:5) plot(1)
 > plot(1, axes=F, xlab="", ylab="", type="n")
 > legend("center", pch=1, legend="points")


Duncan Murdoch

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


[R] Orthogonal polynomial contrasts

2008-04-10 Thread Chris Bennett


How do you remove one of the terms from an ordered polynomial contrast in
your linear model.  For example, I have significant terms for linear and
cubic but not quadratic, how would i remove the quadratic term from
lm(response~treatment)

Cheers,
Chris
-- 
View this message in context: 
http://www.nabble.com/Orthogonal-polynomial-contrasts-tp16608353p16608353.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] [R-pkgs] RcmdrPlugin.Export_0.2-0 released

2008-04-10 Thread Liviu Andronic
Dear R users,

I am pleased to announce the release of the Export plug-in for Rcmdr.
At the moment, it is simply a graphical user interface to xtable().
Several developments are, however, planned. It is worth to note that
the Manual offers several pointers on using Sweave together with LyX,
and from this perspective the plugin is an attempt to simplify
creating (LaTeX) reports by using graphical interfaces only.

In the near future, only exporting to LaTeX and HTML will be
supported. Exporting to other formats (say, RTF or ODF) could be
integrated provided that someone is willing to contribute the code
(say, personal scripts that were never published), or point to a
sensible way of automating the process. Any such contributions are
heartily welcome.

Comments and suggestions are, of course, always welcome.
Liviu

___
R-packages mailing list
[EMAIL PROTECTED]
https://stat.ethz.ch/mailman/listinfo/r-packages

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

2008-04-10 Thread Peter Dalgaard
Chris Bennett wrote:
> How do you remove one of the terms from an ordered polynomial contrast in
> your linear model.  For example, I have significant terms for linear and
> cubic but not quadratic, how would i remove the quadratic term from
> lm(response~treatment)
>
> Cheers,
> Chris
>   
Are you _sure_ you want to do that? The interpretation can get tricky, 
but if you insist, just set the contrast matrix for the term 
accordingly, e.g.,

C(myterm, contr.poly(4)[,-2])

-- 
   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
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

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

2008-04-10 Thread Jim Lemon
Ng Stanley wrote:
> Hi,
> 
> For example, the y axis shows "0 50 150". Is there any way to
> beautify the tick labels to get 0 5 10 15, and at the top of y-axis "x10^5"
> (superscript 5) ? My plots all have different ylim, how to perform the
> beautification automatically ?

Hi Stanley,
You may want axis.mult 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.


Re: [R] How to estimate a hazard ratio using an external hazard function

2008-04-10 Thread Terry Therneau
included message 
Hi,

I would like to compare the hazard functions of two samples using the  
Cox proportional hazards model. For sample 1 I have individual time-to- 
event data. For sample 2 I don't have individual data, but grouped  
data that allows to obtain a hazard function.

I am wondering if there is an R function that allows to obtain a  
hazard ratio of the two hazard funtions (under the proportionality  
assumption) taking into account the censoring of the data?

I am aware of survexp and survdiff functions, but I am not sure if  
that is the best way to do what I need.

Any help will be highly appreciated.

--- End inclusion 

  The functions for population expected survival are designed for just this 
problem, i.e., those that use the US death rate tables.  Under the assumption 
that the second (grouped data set) has a much larger sample size than the first 
(sample) data:
For each subject in sample 1, compute the expected number of events for 
that 
subject, using the rates found in sample 2 = (time at risk) * (rate during that 
time).  For population rate tables this turns out to be a sum: the external 
rates are a function of age so one gets ..+ (# days at age 55)*(rate for 55 
year olds) + (# days at age 56)*(rate for 56 year olds) +   Call the result 
"expected", a vector with one element per subject.  

Now fit a Poisson model with offset(log(expected)) as one of the 
predictors. 
This is a proportional hazards model, with the usual Cox baseline hazard 
lambda_0 replaced by the known hazard function from sample 2.

Terry Therneau

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] two graphs in one figure?

2008-04-10 Thread Anne-Katrin Link
Dear all,

how can I plot a line graph and a bar graph in one single figure? I tried 
to combine "barplot" and "plot". Even though they both have the same 
x-values (1 to 55),  it just doesnt look as if they match in their scale 
(the barplot is much wider than the "plot"even though I tried to put 
limits on the x-axis).
Here is an example of what I did:

barplot(y, xaxt="n",yaxt="n",ylim=c(-1,45), xlim=c(1,55))
...
par(new=TRUE)
plot(x, ynew, lty=2, type="l", ylim=c(0,15), xlim=c(1,55))

Another question: how can I make sure that the "0"-values from the barchart 
are displayed as well?

Thank you so much!

Anne-Katrin

-- 
Psst! Geheimtipp: Online Games kostenlos spielen bei den GMX Free Games! 
http://games.entertainment.gmx.net/de/entertainment/games/free

[[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] Orthogonal polynomial contrasts

2008-04-10 Thread Frank E Harrell Jr
Peter Dalgaard wrote:
> Chris Bennett wrote:
>> How do you remove one of the terms from an ordered polynomial contrast in
>> your linear model.  For example, I have significant terms for linear and
>> cubic but not quadratic, how would i remove the quadratic term from
>> lm(response~treatment)
>>
>> Cheers,
>> Chris
>>   
> Are you _sure_ you want to do that? The interpretation can get tricky, 
> but if you insist, just set the contrast matrix for the term 
> accordingly, e.g.,
> 
> C(myterm, contr.poly(4)[,-2])
> 

Related to Peter's note of caution, using statistical significance as a 
basis for this decision is asking for trouble.  See
   author = {Grambsch, P. M. and {O'Brien}, P. C.},
   year = 1991,
   title = {The effects of transformations and preliminary tests for
   non-linearity in regression},
   journal = Stat in Med,
   volume = 10,
   pages = {697-709}

Frank

-- 
Frank E Harrell Jr   Professor and Chair   School of Medicine
  Department of Biostatistics   Vanderbilt University

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

2008-04-10 Thread Hollister . Jeff

   Dear list,
   After some extensive searching, I have drawn a blank on this.  So ...
   Who is the best contact for questions about starting a new special interest
   group mailing list?
   Cheers,
   Jeff
   ***
   Dr. Jeffrey W. Hollister
   US EPA
   Atlantic Ecology Division
   27 Tarzwell Drive
   Narragansett, RI 02882
   (401) 782-9655
   ***
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] two graphs in one figure?

2008-04-10 Thread ONKELINX, Thierry
Dear Anne-Katrin,

You could use ggplot to do this. The example below works, although it generates 
some warnings.

library(ggplot2)
dataset <- data.frame(x = 0:55, y = rnorm(56, 10), z = runif(56, 9, 11))
ggplot(data = dataset) + geom_bar(aes(x = factor(x), y = y), position = 
"dodge") + geom_line(aes(x = x, y = z))

HTH,

Thierry



ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and 
Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology 
and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium 
tel. + 32 54/436 185
[EMAIL PROTECTED] 
www.inbo.be 

To call in the statistician after the experiment is done may be no more than 
asking him to perform a post-mortem examination: he may be able to say what the 
experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not ensure 
that a reasonable answer can be extracted from a given body of data.
~ John Tukey

-Oorspronkelijk bericht-
Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens Anne-Katrin Link
Verzonden: donderdag 10 april 2008 15:18
Aan: R Help
Onderwerp: [R] two graphs in one figure?

Dear all,

how can I plot a line graph and a bar graph in one single figure? I tried 
to combine "barplot" and "plot". Even though they both have the same 
x-values (1 to 55),  it just doesnt look as if they match in their scale 
(the barplot is much wider than the "plot"even though I tried to put 
limits on the x-axis).
Here is an example of what I did:

barplot(y, xaxt="n",yaxt="n",ylim=c(-1,45), xlim=c(1,55))
...
par(new=TRUE)
plot(x, ynew, lty=2, type="l", ylim=c(0,15), xlim=c(1,55))

Another question: how can I make sure that the "0"-values from the barchart 
are displayed as well?

Thank you so much!

Anne-Katrin

-- 
Psst! Geheimtipp: Online Games kostenlos spielen bei den GMX Free Games! 
http://games.entertainment.gmx.net/de/entertainment/games/free

[[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] quantitative real time PCR

2008-04-10 Thread Marcelo
Hi,

Please, I am looking for a way to analyze my qRT-PCR in my debian gnu linux and
I found a package named qpcR on cran.

Do you known another one that do this analysis (preferable a R addon)?

If you already had do this one in a linux box, could you point me out how
you did?

Thank you very much

Marcelo

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

2008-04-10 Thread Ivaha C (AT)

Hi all

I was wondering if I could ask for some assistance on two little
enquiries that I have got. In the R-project, when using the StructTS
function on a times series Zt, the programs return this:

Call:
StructTS(x = Zt)

Variances:
level   slope   seasepsilon  
 0.168461   0.00   0.005113  10.743687

My frist question is the following: The variances obtained seem to be
numerical values although in the literature (e.g., Kendall and Ord
(1990)), they are detailed as matrices. I need to provide these matrices
in my thesis but I am a bit lost as to how to write them down as.

Secondly, how does the R-project decide on the dimensions of the
matrices?

Any help will be most appreciated

Best Regards,

Christian Ivaha
PhD Student
University of Glamorgan
Faculty of Advanced Technology
Treforest
CF37 1DL



[[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] Recovering SPlus GraphSheets

2008-04-10 Thread Thompson, David (MNR)
Hello,

Is it possible with R to recover the contents of SPlus GraphSheets
(*.sgr) without access to SPlus?
Also, some of the .sgr files may have multiple pages.

Thanx, DaveT.
*
Silviculture Data Analyst
Ontario Forest Research Institute
Ontario Ministry of Natural Resources
[EMAIL PROTECTED]
http://ofri.mnr.gov.on.ca

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

2008-04-10 Thread Lindsay Banin
Subject: nls, step factor 0.000488281 reduced below 'minFactor' of
0.000976563

Hi there,
I'm trying to conduct nls regression using roughly the below code:

nls1 <- nls(y ~ a*(1-exp(-b*x^c)), start=list(a=a1,b=b1,c=c1))
I checked my start values by plotting the relationship etc. but I kept
getting an error message saying maximum iterations exceeded. I have
tried changing these start values, and I heeded advice from other
threads and ammended my code to include :, control = list(maxiter =
500), trace=TRUE)).
Now I receive an error message saying "step factor 0.000488281 reduced
below 'minFactor' of 0.000976563".

Any ideas?
Many thanks in anticipation,

LB

**
Lindsay Banin
School of Geography
University of Leeds
Leeds, LS2 9JT
UK
[EMAIL PROTECTED]
** 

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


Re: [R] lme and confidence intervals

2008-04-10 Thread Gregory Warnes
FWIW, the ci() function in the gmodels package supports generating  
confidence intervals for the fixed effects of lme objects.

-G


On Apr 8, 2008, at 1:34PM , Dieter Menne wrote:
> Cristian Carranza  hotmail.com> writes:
>> After fitting a mixed effects model to repeated measurements data  
>> set, and
> after several unsuccessful
>> atempts to make a simple plot of the confidence interval for the  
>> fitted model,
> I gave up and now I am asking
>> for help in this useful list.
>>
>> Could anyone be so kind to give me some code lines in order to  
>> make a plot of
> the fitted equation and the
>> correspondent confidence interval?
>
> The fitted equation is simple: use predict in its variations. For the
> "confidence interval", most people on the list will ask back what  
> it means. But
> I know my colleagues, they or their reviewers insist on having  
> error bar in the
> graphics, and don't care about the interpretation.
>
> Dimitri has given an approach that could be used to produce some
> reviewer-satisfaction plots limited borborygmy.
>
> http://finzi.psych.upenn.edu/R/Rhelp02a/archive/118174.html
>
> Note that his method is meant to estimate well-defined confidence  
> intervals for
> the coefficients, but you can use the profiled fits and compute the  
> "confidence
> intervals" at the data points. Alternatively, you could use mcmc to  
> get a range
> of curves for averaging.
>
> Dieter
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] LSODA not accurate when RK4 is; what's going on?

2008-04-10 Thread Ravi Varadhan
John,

You should decrease atol and/or rtol to get accurate integration of your
function.

Try this:

fn <- function(t,y,parms=0){return(list(t*y-1))}

t4 <- seq(0, 5, by=.0001)

s4 <- lsoda(y=sqrt(pi/2), times=t4, func=fn, parms=0, atol=1.e-10,
rtol=1.e-10)

plot(s4, type="l")

Hope this is helpful,
Ravi.


---

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: [EMAIL PROTECTED]

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

 




-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of John Tillinghast
Sent: Wednesday, April 09, 2008 7:18 PM
To: r-help@r-project.org
Subject: [R] LSODA not accurate when RK4 is; what's going on?

I'm solving the differential equation dy/dx = xy-1 with y(0) = sqrt(pi/2).
This can be used in computing the tail of the normal distribution.
(The actual solution is y(x) = exp(x^2/2) * Integral_x_inf {exp(-t^2/2) dt}
= Integral_0_inf {exp (-xt - t^2/2) dt}. For large x, y ~ 1/x, starting
around x~2.)

I'm testing both lsoda and rk4 from the package odesolve.
rk4 is accurate using step length 10^-2 and probably would be with even
larger steps.

lsoda is pretty accurate out to about x=4, then starts acting strangely. For
step length 10^-3, y suddenly starts to increase after 4, when it should be
strictly decreasing. For step length 10^-4, y instead turns down and start
dropping precipitously.

Any ideas why lsoda would go off the rails when rk4 does so well? I will
soon be using R to solve more complicated systems of ODEs which I don't
understand as well, so I want to know when it can mislead me.

Code:
t4 <- seq(0, 5, by=.0001)
> fn
function(t,y,parms=0){return(list(t*y-1))}
s4 <- lsoda(sqrt(pi/2), t4, fn, 0)

[[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] Recovering SPlus GraphSheets

2008-04-10 Thread Duncan Murdoch
On 4/10/2008 9:56 AM, Thompson, David (MNR) wrote:
> Hello,
> 
> Is it possible with R to recover the contents of SPlus GraphSheets
> (*.sgr) without access to SPlus?
> Also, some of the .sgr files may have multiple pages.

"Possible" is probably not the right word here:  I'm sure the answer to 
your question is yes, it's possible, someone just has to write the code 
to do it.  But that really means "no".  As far as I've heard, nobody has 
done that.

Duncan Murdoch

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


[R] adonis (vegan package) and subsetted factors

2008-04-10 Thread tyler
Hi,

I'm trying to use adonis on a subset of data from a dataframe. The
actual data is in columns 5:118, and the first four columns are various
factors. There are 3 levels of the factor Habitat, and I want to examine
differences among only two of them. So I started with:

> CoastNear = subset(gel_data, Habitat != "I")

The resulting data.frame has three levels for Habitat, but only two of
those levels have any records. Then I run:

> adonis(CoastNear[,5:118]~Habitat, data = CoastNear,permutations=1000,
+ method='jaccard')

Call:
adonis(formula = CoastNear[, 5:118] ~ Habitat, data = CoastNear,
permutations = 1000, method = "jaccard") 

  Df  SumsOfSqsMeanSqsF.Model R2 Pr(>F)
Habitat2.000  0.0092966  0.0046483  2.0549327 0.0707  0.005
Residuals 54.000  0.1221491  0.00226200.9293   
Total 56.000  0.1314457   1.   

This appears to be wrong - with only two Habitat levels I should only
have 1 Df, shouldn't I? I checked by forcibly excising the third factor
level:

> CoastNear$Habitat <- as.factor(as.character(CoastNear$Habitat))
> adonis(CoastNear[,5:118]~Habitat, data = CoastNear,permutations=1000,
+ method='jaccard')

Call:
adonis(formula = CoastNear[, 5:118] ~ Habitat, data = CoastNear,
permutations = 1000, method = "jaccard") 

  Df  SumsOfSqsMeanSqsF.Model R2 Pr(>F)
Habitat1.000  0.0092966  0.0092966  4.1859740 0.0707  0.003
Residuals 55.000  0.1221491  0.00222090.9293   
Total 56.000  0.1314457   1.   

This appears to be correct. Subsetting factors is something I always
struggle with in R, but, based on previous experience with lda(), it
seems that R generally does the right thing. Am I doing something wrong
here, or is there a problem in adonis?

Thanks,

Tyler

ps. Sorry for not supplying a reproducible bit of code. The data.frame
is quite large. The general layout is:

> head(gel_data) # additional data columns trimmed for email
  Site Habitat Plot Concate A01 A02 A03 A04 A05 A06 A07 A08 A09 A10 
1   PE   C1PEC1   1   1   1   1   1   1   1   1   1   1 
2   PE   C3PEC3   1   1   1   1   0   1   1   1   1   1 
3   PE   C4PEC4   1   1   1   1   0   1   1   1   1   1 
4   PE   C6PEC6   1   1   1   1   0   1   1   1   1   1 
5   PE   C   12   PEC12   1   1   1   1   0   1   1   1   1   1 
6   PE   C   13   PEC13   1   1   1   1   0   1   1   1   1   1

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] LSODA not accurate when RK4 is; what's going on?

2008-04-10 Thread Ravi Varadhan
John,

I should also mention that by looking at the R source for lsoda() you can
see that the default values for "atol" and "rtol" are 1.e-06.  This should
have been mentioned in the help file, but is not.

Another approach to solving your problem is to restrict "hmax", the maximum
steplength.

s4 <- lsoda(y=sqrt(pi/2), times=t4, func=fn, parms=0, hmax=0.001)

plot(s4, type="l")

Best,
Ravi.


---

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: [EMAIL PROTECTED]

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

 





-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of John Tillinghast
Sent: Wednesday, April 09, 2008 7:18 PM
To: r-help@r-project.org
Subject: [R] LSODA not accurate when RK4 is; what's going on?

I'm solving the differential equation dy/dx = xy-1 with y(0) = sqrt(pi/2).
This can be used in computing the tail of the normal distribution.
(The actual solution is y(x) = exp(x^2/2) * Integral_x_inf {exp(-t^2/2) dt}
= Integral_0_inf {exp (-xt - t^2/2) dt}. For large x, y ~ 1/x, starting
around x~2.)

I'm testing both lsoda and rk4 from the package odesolve.
rk4 is accurate using step length 10^-2 and probably would be with even
larger steps.

lsoda is pretty accurate out to about x=4, then starts acting strangely. For
step length 10^-3, y suddenly starts to increase after 4, when it should be
strictly decreasing. For step length 10^-4, y instead turns down and start
dropping precipitously.

Any ideas why lsoda would go off the rails when rk4 does so well? I will
soon be using R to solve more complicated systems of ODEs which I don't
understand as well, so I want to know when it can mislead me.

Code:
t4 <- seq(0, 5, by=.0001)
> fn
function(t,y,parms=0){return(list(t*y-1))}
s4 <- lsoda(sqrt(pi/2), t4, fn, 0)

[[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] ggplot - plot with only legend?

2008-04-10 Thread Pedro de Barros
Dear R'ers,

I am trying to build a composite plot (with several plots in one 
figure). I have tried, but I cannot use facetting, as I need to 
customize each plot using grid.
Since all the plots are the same (with different data, but same 
layout and categories), I would like to have only one legend, that I 
would place in its own viewport, below all the other plots. My questions are
(a) is there is a way, in ggplot, to build a plot that is only the 
legend (no data), where the legend occupies the whole viewport;
(b) How can I change the layout of the legend (e.g. have them written 
side-by side, instead of over each other).

Thanks in advance,
Pedro

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] LSODA not accurate when RK4 is; what's going on?

2008-04-10 Thread Ravi Varadhan
John,

In "lsoda" the increment for "time-marching" is adaptively chosen,
controlled by "atol" and "rtol".  The increment is restricted to lie in
(hmin, hmax).  So you can ensure accuracy, perhaps, at the cost of
efficiency by specifying smaller than default values for atol, rtol, and
hmax, which are 1e-06, 1e-06, and Inf, respectively.

"rk4", on the other hand is not so intelligent.  It basically use fixed time
increment.

Ravi.


---

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: [EMAIL PROTECTED]

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

 




-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of John Tillinghast
Sent: Wednesday, April 09, 2008 7:18 PM
To: r-help@r-project.org
Subject: [R] LSODA not accurate when RK4 is; what's going on?

I'm solving the differential equation dy/dx = xy-1 with y(0) = sqrt(pi/2).
This can be used in computing the tail of the normal distribution.
(The actual solution is y(x) = exp(x^2/2) * Integral_x_inf {exp(-t^2/2) dt}
= Integral_0_inf {exp (-xt - t^2/2) dt}. For large x, y ~ 1/x, starting
around x~2.)

I'm testing both lsoda and rk4 from the package odesolve.
rk4 is accurate using step length 10^-2 and probably would be with even
larger steps.

lsoda is pretty accurate out to about x=4, then starts acting strangely. For
step length 10^-3, y suddenly starts to increase after 4, when it should be
strictly decreasing. For step length 10^-4, y instead turns down and start
dropping precipitously.

Any ideas why lsoda would go off the rails when rk4 does so well? I will
soon be using R to solve more complicated systems of ODEs which I don't
understand as well, so I want to know when it can mislead me.

Code:
t4 <- seq(0, 5, by=.0001)
> fn
function(t,y,parms=0){return(list(t*y-1))}
s4 <- lsoda(sqrt(pi/2), t4, fn, 0)

[[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] Fit a nonlinear regression model with power exponentially distributed errors

2008-04-10 Thread Spencer Graves
  You are making progress. 

  Could you please provide a self-contained example of an attempt by 
you to make it work, as requested in the posting guide 
http://www.R-project.org/posting-guide.html?  That should make it easier 
for someone else to provide an answer that will actually be useful. 

  Hope this helps. 
  Spencer

Yan (Daniel) Zhao wrote:
> How to fit a nonlinear regression model with power exponentially distributed
> errors?  I know gnlm has a function gnlr3 that could work, but I would be
> grateful if example R code is provided.
> Daniel
>
>   [[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] Structural Modelling in R-project

2008-04-10 Thread markleeds
>From: "Ivaha C (AT)" <[EMAIL PROTECTED]>
>Date: 2008/04/10 Thu AM 08:51:14 CDT
>To: R Help 
>Subject: [R] Structural Modelling in R-project

if you have a univariate time series and you
want to break it into its various components, 
then you get the scalars based on a decomposition. 

if you have a kalman filter/
basic strucutural model type setup ( i.e see harvey 1990, can 't remember title 
), then you'll get matrices but I don't think structTS is used for the latter ? 
Professor Ripley,  correct me if i'm wrong on that 
because I don't use structTS.

I can't say much else but you may want to look at the DLM package if you are 
trying to  do what I think you might be trying to do ?




>
>Hi all
>
>I was wondering if I could ask for some assistance on two little
>enquiries that I have got. In the R-project, when using the StructTS
>function on a times series Zt, the programs return this:
>
>Call:
>StructTS(x = Zt)
>
>Variances:
>level  slope   seasepsilon  
> 0.168461   0.00   0.005113  10.743687
>
>My frist question is the following: The variances obtained seem to be
>numerical values although in the literature (e.g., Kendall and Ord
>(1990)), they are detailed as matrices. I need to provide these matrices
>in my thesis but I am a bit lost as to how to write them down as.
>
>Secondly, how does the R-project decide on the dimensions of the
>matrices?
>
>Any help will be most appreciated
>
>Best Regards,
>
>Christian Ivaha
>PhD Student
>University of Glamorgan
>Faculty of Advanced Technology
>Treforest
>CF37 1DL
>
>
>
>   [[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] Structural Modelling in R-project

2008-04-10 Thread Ivaha C (AT)

Thanks for this, it's a good start. I am using a univariate series
indeed. Do you know where I could find the codes for StructTS please? I
can't seem to find it. Thanks again

Christian Ivaha
PhD Student
University of Glamorgan
Faculty of Advanced Technology
Treforest
CF37 1DL


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: 10 April 2008 15:41
To: Ivaha C (AT)
Cc: r-help@r-project.org
Subject: Re: [R] Structural Modelling in R-project

>From: "Ivaha C (AT)" <[EMAIL PROTECTED]>
>Date: 2008/04/10 Thu AM 08:51:14 CDT
>To: R Help 
>Subject: [R] Structural Modelling in R-project

if you have a univariate time series and you
want to break it into its various components, 
then you get the scalars based on a decomposition. 

if you have a kalman filter/
basic strucutural model type setup ( i.e see harvey 1990, can 't
remember title ), then you'll get matrices but I don't think structTS is
used for the latter ? Professor Ripley,  correct me if i'm wrong on that

because I don't use structTS.

I can't say much else but you may want to look at the DLM package if you
are trying to  do what I think you might be trying to do ?




>
>Hi all
>
>I was wondering if I could ask for some assistance on two little
>enquiries that I have got. In the R-project, when using the StructTS
>function on a times series Zt, the programs return this:
>
>Call:
>StructTS(x = Zt)
>
>Variances:
>level  slope   seasepsilon  
> 0.168461   0.00   0.005113  10.743687
>
>My frist question is the following: The variances obtained seem to be
>numerical values although in the literature (e.g., Kendall and Ord
>(1990)), they are detailed as matrices. I need to provide these
matrices
>in my thesis but I am a bit lost as to how to write them down as.
>
>Secondly, how does the R-project decide on the dimensions of the
>matrices?
>
>Any help will be most appreciated
>
>Best Regards,
>
>Christian Ivaha
>PhD Student
>University of Glamorgan
>Faculty of Advanced Technology
>Treforest
>CF37 1DL
>
>
>
>   [[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] (no subject)

2008-04-10 Thread Katharine Mullen
I would suggest making your exact data and calls available.

You can get the estimated parameters from nls even in the case that the
convergence criterium is not met by saying warnOnly=TRUE in the control
list.

depending on why you are not getting convergence, you may want to try a
different algorithm for non-linear regression, like that in the package
minpack.lm.

examples:

x <- seq(0,1,length=100)
a <- 1
b <- .5
c <- .2
someData <- a*(1-exp(-b*x^c)) + rnorm(length(x))*.05*max(someData)

a1 <- 1.2
b1 <- .2
c1 <- .1

nls1 <- nls(someData ~ a*(1-exp(-b*x^c)), start=list(a=a1,b=b1,c=c1),
control = list(maxiter = 500, warnOnly = TRUE), trace=TRUE)

library(minpack.lm)

residF <- function(par) someData - par[1]*(1-exp(-par[2]*x^par[3]))

nls2 <- nls.lm(par = c(a1,b1,c1),
fn = residF, control = list(maxiter = 500, nprint=1))

plot(x,someData)
lines(x,fitted(nls1),col=2)
res <- coef(nls2)
lines(x,res[1]*(1-exp(-res[2]*x^res[3])),col=3)

On Thu, 10 Apr 2008, Lindsay Banin wrote:

> Subject: nls, step factor 0.000488281 reduced below 'minFactor' of
> 0.000976563
>
> Hi there,
> I'm trying to conduct nls regression using roughly the below code:
>
> nls1 <- nls(y ~ a*(1-exp(-b*x^c)), start=list(a=a1,b=b1,c=c1))
> I checked my start values by plotting the relationship etc. but I kept
> getting an error message saying maximum iterations exceeded. I have
> tried changing these start values, and I heeded advice from other
> threads and ammended my code to include :, control = list(maxiter =
> 500), trace=TRUE)).
> Now I receive an error message saying "step factor 0.000488281 reduced
> below 'minFactor' of 0.000976563".
>
> Any ideas?
> Many thanks in anticipation,
>
> LB
>
> **
> Lindsay Banin
> School of Geography
> University of Leeds
> Leeds, LS2 9JT
> UK
> [EMAIL PROTECTED]
> **
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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


Re: [R] Arbitrary Precision Numbers

2008-04-10 Thread Earl F. Glynn
"Rory Winston" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> (If you're wondering, this is a Project Euler question :))
>
> If I wanted to calculate the sum of the digits in the decimal 
> representation
> of 2^1000, what would be a good way to go about that?

Try this:

> library(gmp)
> for (N in c(10,16,32,100,1000))
+ {
+   s <- as.character(pow.bigz(2,N))
+   t <- as.numeric(unlist(strsplit(s,"")))
+   cat(N, s, sum(t), "\n")
+ }
10 1024 7
16 65536 25
32 4294967296 58
100 1267650600228229401496703205376 115
1000 
10715086071862673209484250490600018105614048117055336074437503883703510511249361224931983788156958581275946729175531468251871452856923140435984577574698574803934567774824230985421074605062371141877954182153046474983581941267398767559165543946077062914571196477686542167660429831652624386837205668069376
 
1366

The first few can be verified manually.

-- 
efg

Earl F. Glynn
Bioinformatics
Stowers Institute for Medical Research

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

2008-04-10 Thread -Halcyon-

Hi all,


I have a matrix which is filled with simulation results for several years.
Example of an output (7 years, 4 simulations):

 [,1] [,2] [,3] [,4] 
[1,]  500  500  500  500  
[2,]  516  519  509  508  
[3,]  559  573  556  566  
[4,]  613  650  611  633  
[5,]  676  714  667  716  
[6,]  751  808  742  809 
[7,]  816  890  823  879  

My matplot gives me 4 lines, but I would like to add a line with the
averages of each year for all simulations. Can anyone help me with this?

Thanks in advance!

-- 
View this message in context: 
http://www.nabble.com/Adding-average-into-a-matplot--tp16609064p16609064.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] two graphs in one figure?

2008-04-10 Thread hadley wickham
On Thu, Apr 10, 2008 at 8:36 AM, ONKELINX, Thierry
<[EMAIL PROTECTED]> wrote:
> Dear Anne-Katrin,
>
>  You could use ggplot to do this. The example below works, although it 
> generates some warnings.
>
>  library(ggplot2)
>  dataset <- data.frame(x = 0:55, y = rnorm(56, 10), z = runif(56, 9, 11))
>  ggplot(data = dataset) + geom_bar(aes(x = factor(x), y = y), position = 
> "dodge") + geom_line(aes(x = x, y = z))

ggplot(data = dataset, aes(factor(x), y)) + geom_bar() +
geom_line(aes(y=z, group=1))

does basically the same thing, but without warnings.

Hadley

-- 
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] adonis (vegan package) and subsetted factors

2008-04-10 Thread Gavin Simpson
On Thu, 2008-04-10 at 11:18 -0300, tyler wrote:
> Hi,
> 
> I'm trying to use adonis on a subset of data from a dataframe. The
> actual data is in columns 5:118, and the first four columns are various
> factors. There are 3 levels of the factor Habitat, and I want to examine
> differences among only two of them. So I started with:

Hi Tyler,

This behaviour arises from the following, using the in-built dune data:

> example(dune)

dune> data(dune)

dune> data(dune.env)
> newdune.env <- subset(dune.env, Management != "NM")
> newdune.env$Management
 [1] BF SF SF SF HF SF HF HF BF BF HF SF SF HF
Levels: BF HF NM SF

Notice this hasn't dropped the empty level "NM", and this is what is
catching out adonis --- it is not checking for empty levels in the
grouping factor, as this shows:

> newdune <- dune[which(dune.env$Management != "NM"), ]
> adonis(newdune ~ Management*A1, data=newdune.env, permutations=100)

Call:
adonis(formula = newdune ~ Management * A1, data = newdune.env,
permutations = 100) 

Df SumsOfSqs  MeanSqs  F.Model R2 Pr(>F)
Management 3.0   0.57288  0.19096  1.27735 0.2694  <0.01 ***
A1 1.0   0.29851  0.29851  1.99672 0.1404   0.33
Management:A1  3.0   0.35831  0.11944  0.79892 0.1685   0.87
Residuals  6.0   0.89699  0.14950  0.4218   
Total 13.0   2.12669   1.   
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 

For now, forcibly remove empty factor levels as per your second example,
but I'll take a look at fixing adonis() --- it looks easy but that could
be deceptive! I've CC'd the maintainer (Jari Oksanen) here as well, as I
don't think Jari follows R-help too closely at the moment.


> 
> Thanks,
> 
> Tyler
> 
> ps. Sorry for not supplying a reproducible bit of code. The data.frame
> is quite large. The general layout is:

It is often instructional to use one of the in-built data sets (as I
have here), even if just to prove to yourself that it isn't a problem
with your data.

All the best,

G

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

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


[R] Tukey in R, extracting values

2008-04-10 Thread mad_bassie

hey,
how can i extract the values from the CI's when i use following code for a
tukey test?
the output shows three CI's and i know it should work with 'names but i
don't really know how...
thanks

library(multcomp)
data1$soort<-as.factor(data1$soort)
amod<-aov(waarde~soort,data=data1)
g<-glht(amod, linfct=mcp(soort = "Tukey"))
confint(g)

-- 
View this message in context: 
http://www.nabble.com/Tukey-in-R%2C-extracting-values-tp16609570p16609570.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] adonis (vegan package) and subsetted factors

2008-04-10 Thread tyler
On Thu, Apr 10, 2008 at 04:47:44PM +0100, Gavin Simpson wrote:
> 
> This behaviour arises from the following, using the in-built dune data:
> 
> > newdune.env <- subset(dune.env, Management != "NM")
> > newdune.env$Management
>  [1] BF SF SF SF HF SF HF HF BF BF HF SF SF HF
> Levels: BF HF NM SF
> 
> Notice this hasn't dropped the empty level "NM", and this is what is
> catching out adonis --- it is not checking for empty levels in the
> grouping factor, as this shows:
> 
> > newdune <- dune[which(dune.env$Management != "NM"), ]
> > adonis(newdune ~ Management*A1, data=newdune.env, permutations=100)
> 
> Call:
> adonis(formula = newdune ~ Management * A1, data = newdune.env,
> permutations = 100) 
> 
> Df SumsOfSqs  MeanSqs  F.Model R2 Pr(>F)
> Management 3.0   0.57288  0.19096  1.27735 0.2694  <0.01 ***
> 
> For now, forcibly remove empty factor levels as per your second example,
> but I'll take a look at fixing adonis() 

Great, thanks!

Tyler

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

2008-04-10 Thread Sancar Adali
Our research group is thinking of buying a 64-bit windows workstation
with an intel core2 duo processor, and I am going to  use R on it. I
have a couple of questions.
Is it possible to run 32-bit build of R on a 64-bit computer without
problems?(For windows) Would there be problems with contrib packages?
>From what I've read in the mailing lists, there is eventually going to
be a 64-bit build for windows, but I can install linux on the machine
and use  64-bit build for linux without problems, right?

-- 
Sancar Adali
Johns Hopkins University

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] New user, requesting help with MAC installation of R

2008-04-10 Thread Armin Goralczyk
Hi
The graphics commands should work without problem. On Mac the default
graphics window is a quarz device. Did you get the 'official' mac
binary from CRAN with GUI? If the problem persits you can ask in the
mailing list R-SIG-Mac (see instructions for posting:
http://www.r-project.org/mail.html)
-- 
Armin Goralczyk, M.D.
--
Universitätsmedizin Göttingen
Abteilung Allgemein- und Viszeralchirurgie
Rudolf-Koch-Str. 40
39099 Göttingen
--
Dept. of General Surgery
University of Göttingen
Göttingen, Germany
--
http://www.gwdg.de/~agoralc
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 replace German umlauts in strings?

2008-04-10 Thread Hofert Marius
Dear R-users,

I have a file containing names of German students. These names  
contain the characters "ä", "ö" or "ü" (German umlauts). I use  
read.table() to read the file and let's assume the table is then  
stored in a variable called "data". The names are then contained in  
the first column, i.e. data[,1]. Now if I simply display the variable  
"data", I see, that "ä" is replaced by \x8a, "ö" is replaced by \x9a  
and so forth. Now, I would like to have these characters replaced by  
their LaTeX (or TeX) equivalents, meaning \x8a should be replaced by  
\"a, \x9a should be replaced by \"o and so forth. I tried a lot,  
especially with gsub(), however, the backslashes cause problems and I  
do not know how to get this to work. The data.frame should then be  
written to a file without destroying the replaced substrings (so that  
indeed \"a appears in the file for \x8a). Is this possible?

Here is a minimal example:
data=data.frame(names=c("Bj\x9arn","S\x9aren"),points=c 
(10,20),stringsAsFactors=F)
data[1,1]=gsub('\\x9a','\\"o',data[1,1]) #does not work! (neither do  
similar calls)

Thanks in advance

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


[R] Problem installing and using package "tseries"

2008-04-10 Thread Robert A. LaBudde
I have R 2.6.2, and have tried downloading and installing the package 
"tseries". I get the same error when I use two different mirror sites:

 > utils:::menuInstallPkgs()
trying URL 
'http://cran.mirrors.hoobly.com/bin/windows/contrib/2.6/tseries_0.10-14.zip'
Content type 'application/zip' length 400799 bytes (391 Kb)
opened URL
downloaded 391 Kb

package 'tseries' successfully unpacked and MD5 sums checked

The downloaded packages are in
 C:\Documents and Settings\User\Local 
Settings\Temp\Rtmpk2jrvn\downloaded_packages
updating HTML package descriptions
 > library('tseries')
Error in dyn.load(file, ...) :
   unable to load shared library 
'C:/PROGRA~1/R/R-26~1.2/library/tseries/libs/tseries.dll':
   LoadLibrary failure:  The specified module could not be found.


Error: package/namespace load failed for 'tseries'
 >

There doesn't seem to be anything unusual. The package is installed 
like any other, and the required file is at C:\Program 
Files\R\R-2.6.2\library\tseries\libs\tseries.dll. It is 36,864 bytes 
and looks superficially okay.

Any ideas as to what's wrong here?

Thanks.


Robert A. LaBudde, PhD, PAS, Dpl. ACAFS  e-mail: [EMAIL PROTECTED]
Least Cost Formulations, Ltd.URL: http://lcfltd.com/
824 Timberlake Drive Tel: 757-467-0954
Virginia Beach, VA 23464-3239Fax: 757-467-2947

"Vere scire est per causas scire"

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] QP.solve, QPmat, constraint matrix, and positive definite

2008-04-10 Thread jpolo
hello all,

i'm trying to use QPmat, from the popbio package. it appears to be based
on solve.QP and is intended for making a population projection matrix.
QPmat asks for: nout, A time series of population vectors and C, C
constraint matrix, (with two more vectors, b and nonzero). i believe the
relevant code from QPmat is:

function (nout, C, b, nonzero)
{
if (!"quadprog" %in% (.packages())) {
library(quadprog)
}
n <- dim(nout)
z <- nout[, 2:n[2]]
z <- matrix(z, n[1] * (n[2] - 1), 1)
M <- c()
for (i in 1:(n[2] - 1)) {
N <- kronecker(t(nout[, i]), diag(n[1]))
m <- N[, nonzero]
M <- rbind(M, m)
}
G <- t(M) %*% M
f <- t(M) %*% z
res <- solve.QP(G, f, -t(C), -b)

i'm receiving the error
"Error in solve.QP(G, f, -t(C), -b) :
  matrix D in quadratic function is not positive definite!"

solve.QP documentation says that Dmat goes into the place that is referred
to in the code as G. i've two matrices. nout is 31x3 and all elements are
0 or positive. my C matrix is 31 x 31 and has a -1 running diagonal from
the upper left to the lower right, with everything else 0. i'm somewhat
confused by what matrix or element is being multiplied as it leads up to G
and all i can guess is that i didn't construct the C matrix correctly. how
would i do that?

sorry if i have too much info or am missing something. thanks for your time.

john

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

2008-04-10 Thread Douglas Bates
Martin Maechler <[EMAIL PROTECTED]>, who oversees the mailing
lists, would be the best person to start with.

On 4/10/08, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
>
>Dear list,
>After some extensive searching, I have drawn a blank on this.  So ...
>Who is the best contact for questions about starting a new special interest
>group mailing list?
>Cheers,
>Jeff
>***
>Dr. Jeffrey W. Hollister
>US EPA
>Atlantic Ecology Division
>27 Tarzwell Drive
>Narragansett, RI 02882
>(401) 782-9655
>***
>  __
>  R-help@r-project.org mailing list
>  https://stat.ethz.ch/mailman/listinfo/r-help
>  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>  and provide commented, minimal, self-contained, reproducible code.
>

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


Re: [R] How to replace German umlauts in strings?

2008-04-10 Thread Hans-Jörg Bibiko
On 10.04.2008, at 18:03, Hofert Marius wrote:
> I have a file containing names of German students. These names
> contain the characters "ä", "ö" or "ü" (German umlauts). I use
> read.table() to read the file and let's assume the table is then
> stored in a variable called "data". The names are then contained in
> the first column, i.e. data[,1]. Now if I simply display the variable
> "data", I see, that "ä" is replaced by \x8a, "ö" is replaced by \x9a
> and so forth. Now, I would like to have these characters replaced by
> their LaTeX (or TeX) equivalents, meaning \x8a should be replaced by
> \"a, \x9a should be replaced by \"o and so forth. I tried a lot,
> especially with gsub(), however, the backslashes cause problems and I
> do not know how to get this to work. The data.frame should then be
> written to a file without destroying the replaced substrings (so that
> indeed \"a appears in the file for \x8a). Is this possible?
>
> Here is a minimal example:
> data=data.frame(names=c("Bj\x9arn","S\x9aren"),points=c
> (10,20),stringsAsFactors=F)
> data[1,1]=gsub('\\x9a','\\"o',data[1,1]) #does not work! (neither do
> similar calls)

Try this:

gsub('\\x9a','\\"o',m, perl = TRUE, useBytes = TRUE)

Cheers,

--Hans
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] QP.solve, QPmat, constraint matrix, and positive definite

2008-04-10 Thread jpolo
hello all,

i'm trying to use QPmat, from the popbio package. it appears to be based
on solve.QP and is intended for making a population projection matrix.
QPmat asks for: nout, A time series of population vectors and C, C
constraint matrix, (with two more vectors, b and nonzero). i believe the
relevant code from QPmat is:

function (nout, C, b, nonzero)
{
if (!"quadprog" %in% (.packages())) {
library(quadprog)
}
n <- dim(nout)
z <- nout[, 2:n[2]]
z <- matrix(z, n[1] * (n[2] - 1), 1)
M <- c()
for (i in 1:(n[2] - 1)) {
N <- kronecker(t(nout[, i]), diag(n[1]))
m <- N[, nonzero]
M <- rbind(M, m)
}
G <- t(M) %*% M
f <- t(M) %*% z
res <- solve.QP(G, f, -t(C), -b)

i'm receiving the error
"Error in solve.QP(G, f, -t(C), -b) :
  matrix D in quadratic function is not positive definite!"

solve.QP documentation says that Dmat goes into the place that is referred
to in the code as G. i've two matrices. nout is 31x3 and all elements are
0 or positive. my C matrix is 31 x 31 and has a -1 running diagonal from
the upper left to the lower right, with everything else 0. i'm somewhat
confused by what matrix or element is being multiplied as it leads up to G
and all i can guess is that i didn't construct the C matrix correctly. how
would i do that?

sorry if i have too much info or am missing something. thanks for your time.

john

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

2008-04-10 Thread Ramon Diaz-Uriarte
Just an additional note: what I find interesting (that is an
euphemism) is that a paper such as that got published on 2006 when a
whole bunch of detailed papers on the same topic had been published in
the past. For instance, the first I pick from the pile is by J.
Romano, "On the behavior of randomization tests without a group
invariance assumption", JASA, 1990, 85 (411): 686-692. There are other
related papers on that same issue of JASA. The relevance of
same-variance assumption also shows up in permutation test textbooks
(including, I think, Manly's, Good's, Noreen's, etc).

Best,

R.


On Wed, Apr 9, 2008 at 9:11 PM, Greg Snow <[EMAIL PROTECTED]> wrote:
> A few comments,
>
>  My first impression on reading that abstract was that it was complete 
> nonsense.  After thinking a bit about it and skimming the full article I 
> decided that it was nonsense, but nonsense that is important to research and 
> discuss (and therefore the paper is useful).
>
>  Why is it nonsense?  The permutation test is a test of the null hypothesis 
> that the 2 (or k) groups are from the same distribution (or identically 
> distributed, or exchangable).  The abstract says that they looked at the type 
> I error rate when the 2 groups had different variances or other differences.  
> The type I error is defined when the null hypothesis is true, so computing a 
> type I error rate when the null is by definition false does not make sense.
>
>  However, statisticians often do analyses where all the assumptions are not 
> necessarily true (is any population really distributed as a normal), but the 
> tests are close enough.  So with modern tools it is not suprising to see 
> people doing permutation tests without understanding what they are really 
> testing and the results may be close enough (or they might not be).  The 
> contribution of this paper is to test and see if the results are close enough 
> or not when you use a permutation test to test the null that the means are 
> equal when there are other differences in the groups.  Their answer is that 
> no, the results are not close enough and they suggest that if you want to 
> test for equality of means, but not identical distributions, then don't use a 
> permutation test.
>
>  To expand on Thierry's original answer:
>
>  If you are testing the correct hypotheses and doing a permutation test 
> correctly, then
>  "You can do permutation tests on an unbalanced design" and it will still be 
> a correct test.  Unbalance could affect the power, which you would want to 
> take into account when designing a study, but does not affect the correctness 
> of the test (when used properly).
>
>  Hope this helps,
>
>  --
>  Gregory (Greg) L. Snow Ph.D.
>  Statistical Data Center
>  Intermountain Healthcare
>  [EMAIL PROTECTED]
>  (801) 408-8111
>
>
>
>
>  > -Original Message-
>  > From: [EMAIL PROTECTED]
>  > [mailto:[EMAIL PROTECTED] On Behalf Of João Fadista
>  > Sent: Tuesday, April 08, 2008 4:10 PM
>
>
> > To: ONKELINX, Thierry; r-help@r-project.org
>  > Subject: Re: [R] permutation test assumption?
>  >
>  > Dear Thierry,
>  >
>  > Thanks for the reply. But as you may read in the paper
>  > http://bioinformatics.oxfordjournals.org/cgi/content/abstract/
>  > 22/18/2244 when the sample sizes are not the same there may
>  > be an increase in the Type I error rate.
>  >
>  > Comments will be appreciated.
>  >
>  > Best regards,
>  > João Fadista
>  >
>  >
>  > 
>  >
>  > De: ONKELINX, Thierry [mailto:[EMAIL PROTECTED]
>  > Enviada: ter 08-04-2008 15:27
>  > Para: João Fadista; r-help@r-project.org
>  > Assunto: RE: [R] permutation test assumption?
>  >
>  >
>  >
>  > Dear João,
>  >
>  > You can do permutation tests on an unbalanced design.
>  >
>  > HTH,
>  >
>  > Thierry
>  >
>  >
>  > --
>  > --
>  > ir. Thierry Onkelinx
>  > Instituut voor natuur- en bosonderzoek / Research Institute
>  > for Nature and Forest Cel biometrie, methodologie en
>  > kwaliteitszorg / Section biometrics, methodology and quality
>  > assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32
>  > 54/436 185 [EMAIL PROTECTED] www.inbo.be
>  >
>  > To call in the statistician after the experiment is done may
>  > be no more than asking him to perform a post-mortem
>  > examination: he may be able to say what the experiment died of.
>  > ~ Sir Ronald Aylmer Fisher
>  >
>  > The plural of anecdote is not data.
>  > ~ Roger Brinner
>  >
>  > The combination of some data and an aching desire for an
>  > answer does not ensure that a reasonable answer can be
>  > extracted from a given body of data.
>  > ~ John Tukey
>  >
>  > -Oorspronkelijk bericht-
>  > Van: [EMAIL PROTECTED]
>  > [mailto:[EMAIL PROTECTED] Namens João Fadista
>  > Verzonden: dinsdag 8 april 2008 15:18
>  > Aan: r-help@r-project.org
>  > Onderwerp: [R] permutation test assumption?
>  >
>  > Dear all,
>  >
>  > Can I do a p

[R] Problem with loading package Matrix

2008-04-10 Thread Peter H Singleton

Hello,

I recently upgraded from R 2.6.1 to 2.6.2. I uninstalled 2.6.1, installed
2.6.2, and installed the packages I regularly use. Everyting seems to be
running properly, including most of the packages, but when I try to call
the Matrix package, I get the following error:

> require(Matrix)
Loading required package: Matrix
Error in dyn.load(file, ...) :
  unable to load shared library
'C:/PROGRA~1/R/R-26~1.2/library/Matrix/libs/Matrix.dll':
  LoadLibrary failure:  The specified module could not be found.

This is preceded by a pop-up window with:
R Console: Rgui.exe - Unable To Locate DLL
The dynamic link library Rblas could not be found in the specified path ...

I've looked in the specified folder and the Matrix.dll file is there. I've
also tried installing the Matrix package from another CRAN repository, but
I'm still getting the error.

Any suggestions?

<<->><<->><<->><<->><<->><<->><<->>
Peter Singleton
USFS Pacific Northwest Research Station
1133 N. Western Ave.
Wenatchee WA 98801
Phone: (509)664-1732
Fax: (509)665-8362
E-mail: [EMAIL PROTECTED]

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


[R] subtract the mean from each column

2008-04-10 Thread kayj

Hi,

I am new to R an dI need some help
I have a matrix of real values 100*300 and I would like to calculate the
mean for each column , then for each entry in a column i need to subtract
the mean so I will have a matrix where the columns have zero mean. any one
know how to do that . Thanks  
-- 
View this message in context: 
http://www.nabble.com/subtract-the-mean-from-each-column-tp16610489p16610489.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] subtract the mean from each column

2008-04-10 Thread Chuck Cleland
On 4/10/2008 1:03 PM, kayj wrote:
> Hi,
> 
> I am new to R an dI need some help
> I have a matrix of real values 100*300 and I would like to calculate the
> mean for each column , then for each entry in a column i need to subtract
> the mean so I will have a matrix where the columns have zero mean. any one
> know how to do that . Thanks  

mymat <- matrix(runif(10*4), ncol=4)

colMeans(mymat)
[1] 0.4711083 0.4825977 0.4757448 0.3037873

newmat <- apply(mymat, 2, scale, scale=FALSE, center=TRUE)

colMeans(newmat)
[1]  1.110223e-17 -2.220446e-17 -1.110223e-17  1.110223e-17

?scale

-- 
Chuck Cleland, Ph.D.
NDRI, Inc. (www.ndri.org)
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Adding average into a matplot?

2008-04-10 Thread Mike Prager
-Halcyon- <[EMAIL PROTECTED]> wrote:

 
> I have a matrix which is filled with simulation results for several years.
> Example of an output (7 years, 4 simulations):
> 
[...]
 
> My matplot gives me 4 lines, but I would like to add a line with the
> averages of each year for all simulations. Can anyone help me with this?

Take a look at help pages of the following functions:  mean,
apply, abline.


-- 
Mike Prager, NOAA, Beaufort, NC
* Opinions expressed are personal and not represented otherwise.
* Any use of tradenames does not constitute a NOAA endorsement.

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

2008-04-10 Thread Henrique Dallazuanna
Or just:

scale(mymat, scale = FALSE)

On Thu, Apr 10, 2008 at 2:03 PM, kayj <[EMAIL PROTECTED]> wrote:

>
> Hi,
>
> I am new to R an dI need some help
> I have a matrix of real values 100*300 and I would like to calculate the
> mean for each column , then for each entry in a column i need to subtract
> the mean so I will have a matrix where the columns have zero mean. any one
> know how to do that . Thanks
> --
> View this message in context:
> http://www.nabble.com/subtract-the-mean-from-each-column-tp16610489p16610489.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.
>



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

[[alternative HTML version deleted]]

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


Re: [R] How to replace German umlauts in strings?

2008-04-10 Thread Dieter Menne
Hans-Jörg Bibiko  eva.mpg.de> writes:

> 
> On 10.04.2008, at 18:03, Hofert Marius wrote:
> > I have a file containing names of German students. These names
> > contain the characters "ä", "ö" or "ü" (German umlauts). I use
> > read.table() to read the file and let's assume the table is then
> > stored in a variable called "data". The names are then contained in
> > the first column, i.e. data[,1]. Now if I simply display the variable
> > "data", I see, that "ä" is replaced by \x8a, "ö" is replaced by \x9a
> > and so forth. 

This is strange. When I have a file umlaut.txt

Name
Äserich
Ömadel
Übermunsch

and read it in with 

umlaut = read.table("umlaut.txt", header = TRUE)
umlautasis = read.table("umlaut.txt", header = TRUE,as.is = TRUE)

I get the following in both cases: 

 umlautasis
Name
1Äserich
2 Ömadel
3 Übermunsch

This is on Windows Vista. I use it every day without ever having seen nasty
codings, typically with the following in latex

\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage{babel}
\usepackage[latin1]{inputenc} % For ü,ä


Dieter

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

2008-04-10 Thread Dieter Menne
mad_bassie  hotmail.com> writes:
> how can i extract the values from the CI's when i use following code for a
> tukey test?
> the output shows three CI's and i know it should work with 'names but i
> don't really know how...

You forgot to post a self-running example. Chances are always better to get an
answer if you include one more line that makes the examples reproducible on
other computers. R is complex, so only very few people immediately see what was
wrong without try it (and thus avoiding typos).

Dieter


library(multcomp)
# Please include a line like the following next time
data1 =data.frame(waarde = rnorm(100), soort=sample(1:3,100,replace=TRUE))
data1$soort<-as.factor(data1$soort)
amod<-aov(waarde~soort,data=data1)
g<-glht(amod, linfct=mcp(soort = "Tukey"))
confint(g)
coef(g)
vcov(g)

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] polytomous or multinomial regression for matched data

2008-04-10 Thread Sara Gale
Hi,

I've been trying to find a program that will run a multinomial 
conditional regression on k:m matched data.  Does anyone know of a 
package in R or another package that will allow this?  It's not obvious 
that multinom within nnet or VGAM will allow matched sets.  I've used a 
program (mcl) in STATA and SAS, but my parameter estimates from both 
packages do not match--can't figure out why, but I think it's because we 
have k:m matched sets.

Any help is appreciated.

Best,
Sara

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

2008-04-10 Thread Peter Dalgaard
Dieter Menne wrote:
> Hans-Jörg Bibiko  eva.mpg.de> writes:
>
>   
>> On 10.04.2008, at 18:03, Hofert Marius wrote:
>> 
>>> I have a file containing names of German students. These names
>>> contain the characters "ä", "ö" or "ü" (German umlauts). I use
>>> read.table() to read the file and let's assume the table is then
>>> stored in a variable called "data". The names are then contained in
>>> the first column, i.e. data[,1]. Now if I simply display the variable
>>> "data", I see, that "ä" is replaced by \x8a, "ö" is replaced by \x9a
>>> and so forth. 
>>>   
>
> This is strange. When I have a file umlaut.txt
>
> Name
> Äserich
> Ömadel
> Übermunsch
>
> and read it in with 
>
> umlaut = read.table("umlaut.txt", header = TRUE)
> umlautasis = read.table("umlaut.txt", header = TRUE,as.is = TRUE)
>
> I get the following in both cases: 
>
>  umlautasis
> Name
> 1Äserich
> 2 Ömadel
> 3 Übermunsch
>
> This is on Windows Vista. I use it every day without ever having seen nasty
> codings, typically with the following in latex
>
> \usepackage[T1]{fontenc}
> \usepackage{textcomp}
> \usepackage{babel}
> \usepackage[latin1]{inputenc} % For ü,ä
>
>
> Dieter
>   
Thing is that \x9a for o-umlaut is an unusual encoding:

 > names(which(sapply(iconvlist(),iconv, x="S\x9aren")=="Sören"))
[1] "CP1282""CSMACINTOSH"   "MAC" 
[4] "MAC-CENTRALEUROPE" "MACINTOSH" "MACIS"   
[7] "MAC-IS""MAC-SAMI"
 > iconv("öäüÖÄÜ", to="MAC")
[1] "\x9a\x8a\x9f\x85\x80\x86"


and accordingly,

 > data$names <- iconv(data$names,from="MAC")
 > data
  names points
1 Björn 10
2 Sören 20

or, if you need to do it for many variables, this should work:

ix <- sapply(data, is.character)
data[ix] <- lapply(data[ix], iconv, from="MAC")

-- 
   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
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 fit a model that is nonlinear with multiplicate errors

2008-04-10 Thread Stacey Burrows
Hi fellow R-users,

I am interested in fitting the following model

yi=log(a+xi*b*e), e~N(0,sigma2)

and where x is a known covariate and a and b are parameters to be estimated as 
is sigma2.

I am not sure how to fit such a model using lm or nls. Is there another 
function I can use to fit this?

Thanks for any help.

Stacey

   
-

[[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] Problem with loading package Matrix

2008-04-10 Thread Prof Brian Ripley
What OS is that?

If it is Windows 2000, try copying Rblas.dll to Rblas in the bin folder.
(We have no idea why that might be needed, but it has worked for some 
people -- others have no problem even with Windows 2000.)

On Thu, 10 Apr 2008, Peter H Singleton wrote:

>
> Hello,
>
> I recently upgraded from R 2.6.1 to 2.6.2. I uninstalled 2.6.1, installed
> 2.6.2, and installed the packages I regularly use. Everyting seems to be
> running properly, including most of the packages, but when I try to call
> the Matrix package, I get the following error:
>
>> require(Matrix)
> Loading required package: Matrix
> Error in dyn.load(file, ...) :
>  unable to load shared library
> 'C:/PROGRA~1/R/R-26~1.2/library/Matrix/libs/Matrix.dll':
>  LoadLibrary failure:  The specified module could not be found.
>
> This is preceded by a pop-up window with:
> R Console: Rgui.exe - Unable To Locate DLL
> The dynamic link library Rblas could not be found in the specified path ...
>
> I've looked in the specified folder and the Matrix.dll file is there. I've
> also tried installing the Matrix package from another CRAN repository, but
> I'm still getting the error.
>
> Any suggestions?
>
> <<->><<->><<->><<->><<->><<->><<->>
> Peter Singleton
> USFS Pacific Northwest Research Station
> 1133 N. Western Ave.
> Wenatchee WA 98801
> Phone: (509)664-1732
> Fax: (509)665-8362
> E-mail: [EMAIL PROTECTED]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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

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


Re: [R] How to replace German umlauts in strings?

2008-04-10 Thread Prof Brian Ripley

Or read the file with

read.table(file("umlaut.txt", encoding="MAC"), ...)


On Thu, 10 Apr 2008, Peter Dalgaard wrote:


Dieter Menne wrote:

Hans-Jörg Bibiko  eva.mpg.de> writes:



On 10.04.2008, at 18:03, Hofert Marius wrote:


I have a file containing names of German students. These names
contain the characters "ä", "ö" or "ü" (German umlauts). I use
read.table() to read the file and let's assume the table is then
stored in a variable called "data". The names are then contained in
the first column, i.e. data[,1]. Now if I simply display the variable
"data", I see, that "ä" is replaced by \x8a, "ö" is replaced by \x9a
and so forth.



This is strange. When I have a file umlaut.txt

Name
Äserich
Ömadel
Übermunsch

and read it in with

umlaut = read.table("umlaut.txt", header = TRUE)
umlautasis = read.table("umlaut.txt", header = TRUE,as.is = TRUE)

I get the following in both cases:

 umlautasis
Name
1Äserich
2 Ömadel
3 Übermunsch

This is on Windows Vista. I use it every day without ever having seen nasty
codings, typically with the following in latex

\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage{babel}
\usepackage[latin1]{inputenc} % For ü,ä


Dieter


Thing is that \x9a for o-umlaut is an unusual encoding:

> names(which(sapply(iconvlist(),iconv, x="S\x9aren")=="Sören"))
[1] "CP1282""CSMACINTOSH"   "MAC"
[4] "MAC-CENTRALEUROPE" "MACINTOSH" "MACIS"
[7] "MAC-IS""MAC-SAMI"
> iconv("öäüÖÄÜ", to="MAC")
[1] "\x9a\x8a\x9f\x85\x80\x86"


and accordingly,

> data$names <- iconv(data$names,from="MAC")
> data
 names points
1 Björn 10
2 Sören 20

or, if you need to do it for many variables, this should work:

ix <- sapply(data, is.character)
data[ix] <- lapply(data[ix], iconv, from="MAC")



--
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Arbitrary Precision Numbers

2008-04-10 Thread Rory Winston

Thanks Earl

Thats exactly what I was looking for - an extension that uses libgmp and
provides a bignum type that can be combined with standard operators and
numeric variables. Somehow my original search on CRAN missed this one.

Cheers
Rory

Earl F. Glynn wrote:
> 
> "Rory Winston" <[EMAIL PROTECTED]> wrote in message 
> news:[EMAIL PROTECTED]
>> (If you're wondering, this is a Project Euler question :))
>>
>> If I wanted to calculate the sum of the digits in the decimal 
>> representation
>> of 2^1000, what would be a good way to go about that?
> 
> Try this:
> 
>> library(gmp)
>> for (N in c(10,16,32,100,1000))
> + {
> +   s <- as.character(pow.bigz(2,N))
> +   t <- as.numeric(unlist(strsplit(s,"")))
> +   cat(N, s, sum(t), "\n")
> + }
> 10 1024 7
> 16 65536 25
> 32 4294967296 58
> 100 1267650600228229401496703205376 115
> 1000 
> 10715086071862673209484250490600018105614048117055336074437503883703510511249361224931983788156958581275946729175531468251871452856923140435984577574698574803934567774824230985421074605062371141877954182153046474983581941267398767559165543946077062914571196477686542167660429831652624386837205668069376
>  
> 1366
> 
> The first few can be verified manually.
> 
> -- 
> efg
> 
> Earl F. Glynn
> Bioinformatics
> Stowers Institute for Medical Research
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Arbitrary-Precision-Numbers-tp16492549p16615201.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] two graphs in one figure?

2008-04-10 Thread Greg Snow
Using par(new=TRUE) can be tricky.
 
A better approach is to create one plot, then add the other information to it.  
You can add bars to an existing graph using barplot with add=TRUE, you can add 
lines to an existing plot using the lines function.
 
If you give more detail of what you want (examples of x, y, and ynew) then we 
may be able to give more help.



From: [EMAIL PROTECTED] on behalf of Anne-Katrin Link
Sent: Thu 4/10/2008 7:18 AM
To: R Help
Subject: [R] two graphs in one figure?



Dear all,

how can I plot a line graph and a bar graph in one single figure? I tried
to combine "barplot" and "plot". Even though they both have the same
x-values (1 to 55),  it just doesnt look as if they match in their scale
(the barplot is much wider than the "plot"even though I tried to put
limits on the x-axis).
Here is an example of what I did:

barplot(y, xaxt="n",yaxt="n",ylim=c(-1,45), xlim=c(1,55))
...
par(new=TRUE)
plot(x, ynew, lty=2, type="l", ylim=c(0,15), xlim=c(1,55))

Another question: how can I make sure that the "0"-values from the barchart
are displayed as well?

Thank you so much!

Anne-Katrin
   
--
Psst! Geheimtipp: Online Games kostenlos spielen bei den GMX Free Games!
http://games.entertainment.gmx.net/de/entertainment/games/free

[[alternative HTML version deleted]]




[[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] Types in grouped multi-panel (lattice) xyplot

2008-04-10 Thread Aaron Arvey
Apologetic prologue: I've looked through the mailing list for an answer to 
this (since I'm sure it's trivial) but I have not been able to find a fix.

So the problem is that I want each group to have a different type of plot. 
"Probes" should be points and "Segments" should be lines (preferably using 
the segment plot command, but I've just been trying -- unsuccessfully -- 
to get lines to work).

To be exact, the data looks like:

loc  val   valtype  mouse
1428  0.1812367 Probes  2
1439 -0.4534155 Probes  2
1499 -0.4957303 Probes  2
1559  0.2448838 Probes  2
1611 -0.2030937 Probes  2
1788 -0.2235331 Probes  2
1428 0.5Segment 2
1439 0.5Segment 2
1499 0.5Segment 2
1559 0.5Segment 2
1611 0.5Segment 2
1788 0.5Segment 2
1428  0.1812367 Probes  1
1439 -0.4534155 Probes  1
1499 -0.4957303 Probes  1
1559  0.2448838 Probes  1
1611 -0.2030937 Probes  1
1788 -0.2235331 Probes  1
1428 0.5Segment 1
1439 0.5Segment 1
1499 0.5Segment 1
1559 0.1Segment 1
1611 0.1Segment 1
1788 0.1Segment 1


   * loc is the x-axis location
   * val is the y-axis value
   * valtype is equal to "which" had I been smart and used make.groups
   * mouse is the 'cond' variable


The plot command I'm currently using is,

xyplot(val ~ loc | mouse, data = df,
 groups=valtype
 aspect=0.5, layout=c(3,3),
 lty=0, lwd=3, type="p",
 col=c("black", "blue"),
 as.table = TRUE)

which gives me black and blue points for the probes/segments (I've infered 
alphabetical order for the groups colors).  When I change the type to 
c("p", "l"), I get

xyplot(val ~ loc | mouse, data = df,
 groups=valtype
 aspect=0.5, layout=c(3,3),
 lty=0, lwd=3, type=c("p","l"),
 col=c("black", "blue"),
 as.table = TRUE)


I get the exact same plot.  I've tried using a few of the panel functions 
I found on the list (I was particularly hopeful for 
http://tolstoy.newcastle.edu.au/R/help/06/07/30363.html) but I've either 
been misusing them, or they are not right for what I want to do.

If anyone knows how to get points and lines in the same panel for the two 
different groups (probes/segments), I would love to hear about it.

If you further know how to use the 'segment' plot in panels for the 
segments, I would really love to hear about it.

Thanks in advance!

Aaron

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

2008-04-10 Thread dt Excellent
Suppose that we have o 2-D contingency table where the row variable is nominal 
and the column one is ordinal. In SAS it is possible to compute the statistic 
named as row mean scores differ. How can we programmed it in R? 
(See also Aggresti (2002), Categorical Data Analysis, p. 302)
With regards

   
-



[[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] Relational Databases or XML?

2008-04-10 Thread Keith Alan Chamberlain
Dear R-Help,

I am working on a paper in an R course for large file support in R using 
scan(), relational databases, and XML. I have never used SQL or heirarchical 
document formats such as XML (except where it occurs without user interaction), 
and knowledge in RDBs and XML is lacking in my program. I have tried finding a 
working example for the novices-novice on the topic, read many postings, the 
r-data I/O manual several times, and descriptions of packages RODBC, DBI, XML, 
among others. I understand that RDBs are (assumed at least) used widely among 
the R community. I have not been able to put all of the pieces together, but 
assuming that RDB use is actually quite widespread, it should be quite easy to 
fill me in and/or correct my understanding where necessary.

For a cross-platform solution (PC/OSX at least, or in part) my 
questions/problems are about what preliminary steps are needed to get an SQL or 
XML query "to work" in R to begin with, what the appropriate data-file formats 
are, and how to convert to them if starting out with data in, say, a delimited 
ASCII text file. Very basic examples should suffice, say, a table with 20 
random observations, a grouping variable with 2 levels, and a factor with 2 
levels.

## untested code
set.seed(1024)
write.table("junk.txt", 
data.frame(Subj=c(rep(1,10),rep(2,10)),block=rep(c(rep(-1,5),rep(1,5)),2), 
obs=rnorm(20,0,1)))

Specifically,

1- what are the minimum required non R components that are needed to support 
SQL or XML functionality, which may or may not need to be installed?

2- what R packages need to be installed, at a minimum (also as a cross-PC/Mac 
solution if possible or at least as much as possible)

3- I keep seeing reference to connections of a given name "if previously 
setup". What kind of setup is needed outside of R, if any?

4- what steps are needed in R to then connect to a file and import a subset 
based on a query?

5- Do I then use standard R routines (e.g. write()) to export as a DB, or an 
RDB/XML specific function?

Sincerely,
KeithC. [U.S]

1/k^c

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

2008-04-10 Thread Doran, Harold
I'm not sure it is possible to parse an XML file in R directly. Well, I
guess it's *possible*, but may not be the best way to do it. ElementTree
in Python is an easy-to-use parser that you might use to first parse
your XML file (or others hierarchically structured data), organize it
anyway you want, and then bring those data into R for subsequent
analysis.

In fact, I have recently done just this. I have another statistical
program that outputs data as an XML file. So, I wrote a python program
that parses that XML file, pulls out the data of interest into a text
file, and then I bring those data into R for analysis.

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Keith Alan 
> Chamberlain
> Sent: Thursday, April 10, 2008 4:14 PM
> To: r-help@r-project.org
> Subject: [R] Relational Databases or XML?
> 
> Dear R-Help,
> 
> I am working on a paper in an R course for large file support 
> in R using scan(), relational databases, and XML. I have 
> never used SQL or heirarchical document formats such as XML 
> (except where it occurs without user interaction), and 
> knowledge in RDBs and XML is lacking in my program. I have 
> tried finding a working example for the novices-novice on the 
> topic, read many postings, the r-data I/O manual several 
> times, and descriptions of packages RODBC, DBI, XML, among 
> others. I understand that RDBs are (assumed at least) used 
> widely among the R community. I have not been able to put all 
> of the pieces together, but assuming that RDB use is actually 
> quite widespread, it should be quite easy to fill me in 
> and/or correct my understanding where necessary.
> 
> For a cross-platform solution (PC/OSX at least, or in part) 
> my questions/problems are about what preliminary steps are 
> needed to get an SQL or XML query "to work" in R to begin 
> with, what the appropriate data-file formats are, and how to 
> convert to them if starting out with data in, say, a 
> delimited ASCII text file. Very basic examples should 
> suffice, say, a table with 20 random observations, a grouping 
> variable with 2 levels, and a factor with 2 levels.
> 
> ## untested code
> set.seed(1024)
> write.table("junk.txt", 
> data.frame(Subj=c(rep(1,10),rep(2,10)),block=rep(c(rep(-1,5),r
> ep(1,5)),2), obs=rnorm(20,0,1)))
> 
> Specifically,
> 
> 1- what are the minimum required non R components that are 
> needed to support SQL or XML functionality, which may or may 
> not need to be installed?
> 
> 2- what R packages need to be installed, at a minimum (also 
> as a cross-PC/Mac solution if possible or at least as much as 
> possible)
> 
> 3- I keep seeing reference to connections of a given name "if 
> previously setup". What kind of setup is needed outside of R, if any?
> 
> 4- what steps are needed in R to then connect to a file and 
> import a subset based on a query?
> 
> 5- Do I then use standard R routines (e.g. write()) to export 
> as a DB, or an RDB/XML specific function?
> 
> Sincerely,
> KeithC. [U.S]
> 
> 1/k^c
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Relational Databases or XML?

2008-04-10 Thread Doran, Harold
Well, I guess it is possible with XML package on CRAN. But, it seems
there is no windows binary (yet)

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Doran, Harold
> Sent: Thursday, April 10, 2008 4:29 PM
> To: Keith Alan Chamberlain; r-help@r-project.org
> Subject: Re: [R] Relational Databases or XML?
> 
> I'm not sure it is possible to parse an XML file in R 
> directly. Well, I guess it's *possible*, but may not be the 
> best way to do it. ElementTree in Python is an easy-to-use 
> parser that you might use to first parse your XML file (or 
> others hierarchically structured data), organize it anyway 
> you want, and then bring those data into R for subsequent analysis.
> 
> In fact, I have recently done just this. I have another 
> statistical program that outputs data as an XML file. So, I 
> wrote a python program that parses that XML file, pulls out 
> the data of interest into a text file, and then I bring those 
> data into R for analysis.
> 
> > -Original Message-
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED] On Behalf Of Keith Alan 
> > Chamberlain
> > Sent: Thursday, April 10, 2008 4:14 PM
> > To: r-help@r-project.org
> > Subject: [R] Relational Databases or XML?
> > 
> > Dear R-Help,
> > 
> > I am working on a paper in an R course for large file support in R 
> > using scan(), relational databases, and XML. I have never 
> used SQL or 
> > heirarchical document formats such as XML (except where it occurs 
> > without user interaction), and knowledge in RDBs and XML is 
> lacking in 
> > my program. I have tried finding a working example for the 
> > novices-novice on the topic, read many postings, the r-data 
> I/O manual 
> > several times, and descriptions of packages RODBC, DBI, XML, among 
> > others. I understand that RDBs are (assumed at least) used widely 
> > among the R community. I have not been able to put all of 
> the pieces 
> > together, but assuming that RDB use is actually quite 
> widespread, it 
> > should be quite easy to fill me in and/or correct my understanding 
> > where necessary.
> > 
> > For a cross-platform solution (PC/OSX at least, or in part) my 
> > questions/problems are about what preliminary steps are 
> needed to get 
> > an SQL or XML query "to work" in R to begin with, what the 
> appropriate 
> > data-file formats are, and how to convert to them if 
> starting out with 
> > data in, say, a delimited ASCII text file. Very basic 
> examples should 
> > suffice, say, a table with 20 random observations, a 
> grouping variable 
> > with 2 levels, and a factor with 2 levels.
> > 
> > ## untested code
> > set.seed(1024)
> > write.table("junk.txt",
> > data.frame(Subj=c(rep(1,10),rep(2,10)),block=rep(c(rep(-1,5),r
> > ep(1,5)),2), obs=rnorm(20,0,1)))
> > 
> > Specifically,
> > 
> > 1- what are the minimum required non R components that are 
> needed to 
> > support SQL or XML functionality, which may or may not need to be 
> > installed?
> > 
> > 2- what R packages need to be installed, at a minimum (also as a 
> > cross-PC/Mac solution if possible or at least as much as
> > possible)
> > 
> > 3- I keep seeing reference to connections of a given name "if 
> > previously setup". What kind of setup is needed outside of 
> R, if any?
> > 
> > 4- what steps are needed in R to then connect to a file and 
> import a 
> > subset based on a query?
> > 
> > 5- Do I then use standard R routines (e.g. write()) to 
> export as a DB, 
> > or an RDB/XML specific function?
> > 
> > Sincerely,
> > KeithC. [U.S]
> > 
> > 1/k^c
> > 
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/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] Types in grouped multi-panel (lattice) xyplot

2008-04-10 Thread Deepayan Sarkar
On 4/10/08, Aaron Arvey <[EMAIL PROTECTED]> wrote:
> Apologetic prologue: I've looked through the mailing list for an answer to
>  this (since I'm sure it's trivial) but I have not been able to find a fix.
>
>  So the problem is that I want each group to have a different type of plot.
>  "Probes" should be points and "Segments" should be lines (preferably using
>  the segment plot command, but I've just been trying -- unsuccessfully --
>  to get lines to work).
>
>  To be exact, the data looks like:
>
>  loc  val   valtype  mouse
>  1428  0.1812367 Probes  2
>  1439 -0.4534155 Probes  2
>  1499 -0.4957303 Probes  2
>  1559  0.2448838 Probes  2
>  1611 -0.2030937 Probes  2
>  1788 -0.2235331 Probes  2
>  1428 0.5Segment 2
>  1439 0.5Segment 2
>  1499 0.5Segment 2
>  1559 0.5Segment 2
>  1611 0.5Segment 2
>  1788 0.5Segment 2
>  1428  0.1812367 Probes  1
>  1439 -0.4534155 Probes  1
>  1499 -0.4957303 Probes  1
>  1559  0.2448838 Probes  1
>  1611 -0.2030937 Probes  1
>  1788 -0.2235331 Probes  1
>  1428 0.5Segment 1
>  1439 0.5Segment 1
>  1499 0.5Segment 1
>  1559 0.1Segment 1
>  1611 0.1Segment 1
>  1788 0.1Segment 1
>
>
>* loc is the x-axis location
>* val is the y-axis value
>* valtype is equal to "which" had I been smart and used make.groups
>* mouse is the 'cond' variable
>
>
>  The plot command I'm currently using is,
>
>  xyplot(val ~ loc | mouse, data = df,
>  groups=valtype
>  aspect=0.5, layout=c(3,3),
>  lty=0, lwd=3, type="p",
>  col=c("black", "blue"),
>  as.table = TRUE)
>
>  which gives me black and blue points for the probes/segments (I've infered
>  alphabetical order for the groups colors).  When I change the type to
>  c("p", "l"), I get
>
>  xyplot(val ~ loc | mouse, data = df,
>  groups=valtype
>  aspect=0.5, layout=c(3,3),
>  lty=0, lwd=3, type=c("p","l"),
>  col=c("black", "blue"),
>  as.table = TRUE)

Try

xyplot(val ~ loc | mouse, data = df,
   groups=valtype,
   type=c("p","l"),
   ## distribute.type = TRUE,
   col=c("black", "blue"))

>  I get the exact same plot.  I've tried using a few of the panel functions
>  I found on the list (I was particularly hopeful for
>  http://tolstoy.newcastle.edu.au/R/help/06/07/30363.html) but I've either
>  been misusing them, or they are not right for what I want to do.
>
>  If anyone knows how to get points and lines in the same panel for the two
>  different groups (probes/segments), I would love to hear about it.
>
>  If you further know how to use the 'segment' plot in panels for the
>  segments, I would really love to hear about it.

Well, panel.segments() draws segments, but you need your data in the
form (x1, y1, x2, y2) for that. With your setup, it's probably easier
to have lines with some NA-s inserted wherever you want line breaks.

-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] Types in grouped multi-panel (lattice) xyplot

2008-04-10 Thread Deepayan Sarkar
On 4/10/08, Deepayan Sarkar <[EMAIL PROTECTED]> wrote:
> On 4/10/08, Aaron Arvey <[EMAIL PROTECTED]> wrote:
>  > Apologetic prologue: I've looked through the mailing list for an answer to
>  >  this (since I'm sure it's trivial) but I have not been able to find a fix.
>  >
>  >  So the problem is that I want each group to have a different type of plot.
>  >  "Probes" should be points and "Segments" should be lines (preferably using
>  >  the segment plot command, but I've just been trying -- unsuccessfully --
>  >  to get lines to work).
>  >
>  >  To be exact, the data looks like:
>  >
>  >  loc  val   valtype  mouse
>  >  1428  0.1812367 Probes  2
>  >  1439 -0.4534155 Probes  2
>  >  1499 -0.4957303 Probes  2
>  >  1559  0.2448838 Probes  2
>  >  1611 -0.2030937 Probes  2
>  >  1788 -0.2235331 Probes  2
>  >  1428 0.5Segment 2
>  >  1439 0.5Segment 2
>  >  1499 0.5Segment 2
>  >  1559 0.5Segment 2
>  >  1611 0.5Segment 2
>  >  1788 0.5Segment 2
>  >  1428  0.1812367 Probes  1
>  >  1439 -0.4534155 Probes  1
>  >  1499 -0.4957303 Probes  1
>  >  1559  0.2448838 Probes  1
>  >  1611 -0.2030937 Probes  1
>  >  1788 -0.2235331 Probes  1
>  >  1428 0.5Segment 1
>  >  1439 0.5Segment 1
>  >  1499 0.5Segment 1
>  >  1559 0.1Segment 1
>  >  1611 0.1Segment 1
>  >  1788 0.1Segment 1
>  >
>  >
>  >* loc is the x-axis location
>  >* val is the y-axis value
>  >* valtype is equal to "which" had I been smart and used make.groups
>  >* mouse is the 'cond' variable
>  >
>  >
>  >  The plot command I'm currently using is,
>  >
>  >  xyplot(val ~ loc | mouse, data = df,
>  >  groups=valtype
>  >  aspect=0.5, layout=c(3,3),
>  >  lty=0, lwd=3, type="p",
>  >  col=c("black", "blue"),
>  >  as.table = TRUE)
>  >
>  >  which gives me black and blue points for the probes/segments (I've infered
>  >  alphabetical order for the groups colors).  When I change the type to
>  >  c("p", "l"), I get
>  >
>  >  xyplot(val ~ loc | mouse, data = df,
>  >  groups=valtype
>  >  aspect=0.5, layout=c(3,3),
>  >  lty=0, lwd=3, type=c("p","l"),
>  >  col=c("black", "blue"),
>  >  as.table = TRUE)
>
>
> Try
>
>
>  xyplot(val ~ loc | mouse, data = df,
>
>groups=valtype,
>type=c("p","l"),
>## distribute.type = TRUE,

Sorry, that should be

   distribute.type = TRUE,

>col=c("black", "blue"))
>
>
>  >  I get the exact same plot.  I've tried using a few of the panel functions
>  >  I found on the list (I was particularly hopeful for
>  >  http://tolstoy.newcastle.edu.au/R/help/06/07/30363.html) but I've either
>  >  been misusing them, or they are not right for what I want to do.
>  >
>  >  If anyone knows how to get points and lines in the same panel for the two
>  >  different groups (probes/segments), I would love to hear about it.
>  >
>  >  If you further know how to use the 'segment' plot in panels for the
>  >  segments, I would really love to hear about it.
>
>
> Well, panel.segments() draws segments, but you need your data in the
>  form (x1, y1, x2, y2) for that. With your setup, it's probably easier
>  to have lines with some NA-s inserted wherever you want line breaks.
>
>
>  -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] Relational Databases or XML?

2008-04-10 Thread Prof Brian Ripley
On Thu, 10 Apr 2008, Doran, Harold wrote:

> Well, I guess it is possible with XML package on CRAN. But, it seems
> there is no windows binary (yet)

There certainly is -- did you try installing it from CRAN (extras)?


>> -Original Message-
>> From: [EMAIL PROTECTED]
>> [mailto:[EMAIL PROTECTED] On Behalf Of Doran, Harold
>> Sent: Thursday, April 10, 2008 4:29 PM
>> To: Keith Alan Chamberlain; r-help@r-project.org
>> Subject: Re: [R] Relational Databases or XML?
>>
>> I'm not sure it is possible to parse an XML file in R
>> directly. Well, I guess it's *possible*, but may not be the
>> best way to do it. ElementTree in Python is an easy-to-use
>> parser that you might use to first parse your XML file (or
>> others hierarchically structured data), organize it anyway
>> you want, and then bring those data into R for subsequent analysis.
>>
>> In fact, I have recently done just this. I have another
>> statistical program that outputs data as an XML file. So, I
>> wrote a python program that parses that XML file, pulls out
>> the data of interest into a text file, and then I bring those
>> data into R for analysis.
>>
>>> -Original Message-
>>> From: [EMAIL PROTECTED]
>>> [mailto:[EMAIL PROTECTED] On Behalf Of Keith Alan
>>> Chamberlain
>>> Sent: Thursday, April 10, 2008 4:14 PM
>>> To: r-help@r-project.org
>>> Subject: [R] Relational Databases or XML?
>>>
>>> Dear R-Help,
>>>
>>> I am working on a paper in an R course for large file support in R
>>> using scan(), relational databases, and XML. I have never
>> used SQL or
>>> heirarchical document formats such as XML (except where it occurs
>>> without user interaction), and knowledge in RDBs and XML is
>> lacking in
>>> my program. I have tried finding a working example for the
>>> novices-novice on the topic, read many postings, the r-data
>> I/O manual
>>> several times, and descriptions of packages RODBC, DBI, XML, among
>>> others. I understand that RDBs are (assumed at least) used widely
>>> among the R community. I have not been able to put all of
>> the pieces
>>> together, but assuming that RDB use is actually quite
>> widespread, it
>>> should be quite easy to fill me in and/or correct my understanding
>>> where necessary.
>>>
>>> For a cross-platform solution (PC/OSX at least, or in part) my
>>> questions/problems are about what preliminary steps are
>> needed to get
>>> an SQL or XML query "to work" in R to begin with, what the
>> appropriate
>>> data-file formats are, and how to convert to them if
>> starting out with
>>> data in, say, a delimited ASCII text file. Very basic
>> examples should
>>> suffice, say, a table with 20 random observations, a
>> grouping variable
>>> with 2 levels, and a factor with 2 levels.
>>>
>>> ## untested code
>>> set.seed(1024)
>>> write.table("junk.txt",
>>> data.frame(Subj=c(rep(1,10),rep(2,10)),block=rep(c(rep(-1,5),r
>>> ep(1,5)),2), obs=rnorm(20,0,1)))
>>>
>>> Specifically,
>>>
>>> 1- what are the minimum required non R components that are
>> needed to
>>> support SQL or XML functionality, which may or may not need to be
>>> installed?
>>>
>>> 2- what R packages need to be installed, at a minimum (also as a
>>> cross-PC/Mac solution if possible or at least as much as
>>> possible)
>>>
>>> 3- I keep seeing reference to connections of a given name "if
>>> previously setup". What kind of setup is needed outside of
>> R, if any?
>>>
>>> 4- what steps are needed in R to then connect to a file and
>> import a
>>> subset based on a query?
>>>
>>> 5- Do I then use standard R routines (e.g. write()) to
>> export as a DB,
>>> or an RDB/XML specific function?
>>>
>>> Sincerely,
>>> KeithC. [U.S]
>>>
>>> 1/k^c
>>>
>>> __
>>> R-help@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/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.
>

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

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

Re: [R] Problem installing and using package "tseries"

2008-04-10 Thread Uwe Ligges
Can you please try to reinstall in roughly 12 hours from now from CRAN 
master?
I have fixed the problem and recompiled tseries which will appear on 
CRAN master within 12 hours.

Best wishes,
Uwe Ligges


Robert A. LaBudde wrote:
> I have R 2.6.2, and have tried downloading and installing the package 
> "tseries". I get the same error when I use two different mirror sites:
> 
>  > utils:::menuInstallPkgs()
> trying URL 
> 'http://cran.mirrors.hoobly.com/bin/windows/contrib/2.6/tseries_0.10-14.zip'
> Content type 'application/zip' length 400799 bytes (391 Kb)
> opened URL
> downloaded 391 Kb
> 
> package 'tseries' successfully unpacked and MD5 sums checked
> 
> The downloaded packages are in
>  C:\Documents and Settings\User\Local 
> Settings\Temp\Rtmpk2jrvn\downloaded_packages
> updating HTML package descriptions
>  > library('tseries')
> Error in dyn.load(file, ...) :
>unable to load shared library 
> 'C:/PROGRA~1/R/R-26~1.2/library/tseries/libs/tseries.dll':
>LoadLibrary failure:  The specified module could not be found.
> 
> 
> Error: package/namespace load failed for 'tseries'
>  >
> 
> There doesn't seem to be anything unusual. The package is installed 
> like any other, and the required file is at C:\Program 
> Files\R\R-2.6.2\library\tseries\libs\tseries.dll. It is 36,864 bytes 
> and looks superficially okay.
> 
> Any ideas as to what's wrong here?
> 
> Thanks.
> 
> 
> Robert A. LaBudde, PhD, PAS, Dpl. ACAFS  e-mail: [EMAIL PROTECTED]
> Least Cost Formulations, Ltd.URL: http://lcfltd.com/
> 824 Timberlake Drive Tel: 757-467-0954
> Virginia Beach, VA 23464-3239Fax: 757-467-2947
> 
> "Vere scire est per causas scire"
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] function to calculate networkdays?

2008-04-10 Thread tom soyer
Hi,

Does anyone know if R has a built-in function that is similar to Excel's
NETWORKDAYS function? i.e., Returns the number of whole working days between
two dates. Working days exclude weekends.

Thanks,

-- 
Tom

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

2008-04-10 Thread bereket weldeslassie
Dear,
I am doing a time series regression (one dependent time series variable, 7
independent time series variables and 32 annual observations). I have the
problem of cointegration, autocorrelation and multicollinearity. I am
considering an error correction model of the form:
diff(lnY(t))=a+b1*lnY(t-1)+b2*lnX(t-1)+b3*diff(lnX(t))+error
and not able to solve all problems.
Any suggestion how to built a good model that solves these problems? I
appreciate your help.
Thanks,
Bereket

[[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] Relational Databases or XML?

2008-04-10 Thread Gabor Grothendieck
You may wish to try out sqldf.  It allows one to manipulate data
frames using sql.  The real work is
done by sqlite and the RSQLite interface but it sets up the database
for you and all the tables
and then deletes them so its as easy a typing in one line of code.
Check out the home page
at http://sqldf.googlecode.com .

On Windows sqlite is included in the RSQLite package so you have
nothing to install but
an ordinary R package.

For XML there is the XML R package.  The ctv and Ryacas packages are
two packages
that use XML (for the task view database and for parsing OpenMath
respectively).  At
least on Windows you just install the XML package and it includes
everything you need.
On omegahat site there is more about the R XML package.  There is also a package
to handle pubmed in XML in bioconductor.

On Thu, Apr 10, 2008 at 4:14 PM, Keith Alan Chamberlain
<[EMAIL PROTECTED]> wrote:
> Dear R-Help,
>
> I am working on a paper in an R course for large file support in R using 
> scan(), relational databases, and XML. I have never used SQL or heirarchical 
> document formats such as XML (except where it occurs without user 
> interaction), and knowledge in RDBs and XML is lacking in my program. I have 
> tried finding a working example for the novices-novice on the topic, read 
> many postings, the r-data I/O manual several times, and descriptions of 
> packages RODBC, DBI, XML, among others. I understand that RDBs are (assumed 
> at least) used widely among the R community. I have not been able to put all 
> of the pieces together, but assuming that RDB use is actually quite 
> widespread, it should be quite easy to fill me in and/or correct my 
> understanding where necessary.
>
> For a cross-platform solution (PC/OSX at least, or in part) my 
> questions/problems are about what preliminary steps are needed to get an SQL 
> or XML query "to work" in R to begin with, what the appropriate data-file 
> formats are, and how to convert to them if starting out with data in, say, a 
> delimited ASCII text file. Very basic examples should suffice, say, a table 
> with 20 random observations, a grouping variable with 2 levels, and a factor 
> with 2 levels.
>
> ## untested code
> set.seed(1024)
> write.table("junk.txt", 
> data.frame(Subj=c(rep(1,10),rep(2,10)),block=rep(c(rep(-1,5),rep(1,5)),2), 
> obs=rnorm(20,0,1)))
>
> Specifically,
>
> 1- what are the minimum required non R components that are needed to support 
> SQL or XML functionality, which may or may not need to be installed?
>
> 2- what R packages need to be installed, at a minimum (also as a cross-PC/Mac 
> solution if possible or at least as much as possible)
>
> 3- I keep seeing reference to connections of a given name "if previously 
> setup". What kind of setup is needed outside of R, if any?
>
> 4- what steps are needed in R to then connect to a file and import a subset 
> based on a query?
>
> 5- Do I then use standard R routines (e.g. write()) to export as a DB, or an 
> RDB/XML specific function?
>
> Sincerely,
> KeithC. [U.S]
>
> 1/k^c
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Degrees of freedom in binomial glm

2008-04-10 Thread Giovanni Petris

Hello,

I am looking at the job satisfaction data below, from a problem in
Agresti's book, and I am not sure where the degrees of freedom come
from. The way I am fitting a binomial model, I have 168 observations,
so in my understanding that should also be the number of fitted
parameters in the saturated model. Since I have one intercept
parameter, I was thinking to get 167 df for the Null model, but 
R tells me it's 165. Where does this number come from?

Thanks in advance,
Giovanni


> ### Agresti, Problem 5.23
> race <- c("White", "Other")
> gender <- c("M", "F")
> age <- c("<35", "35-44", ">44")
> loc <- c("NE", "MidAtl", "S", "MidW", "NW", "SW", "Pac")
> sat <- factor(c("Yes", "No"), levels = c("No", "Yes"))
> Freq <- c(288,  60, 224, 35, 337,  70,   38, 19, 32, 22, 21, 15,
+   177,  57, 166, 19, 172,  30,   33, 35, 11, 20,  8, 10,
+90,  19,  96, 12, 124,  17,   18, 13,  7,  0,  9,  1,
+45,  12,  42,  5,  39,   2,6,  7,  2,  3,  2,  1,
+   226,  88, 189, 44, 156,  70,   45, 47, 18, 13, 11,  9,
+   128,  57, 117, 34,  73,  25,   31, 35,  3,  7,  2,  2,
+   285, 110, 225, 53, 324,  60,   40, 66, 19, 25, 22, 11,
+   179,  93, 141, 24, 140,  47,   25, 56, 11, 19,  2, 12,
+   270, 176, 215, 80, 269, 110,   36, 25,  9, 11, 16,  4,
+   180, 151, 108, 40, 136,  40,   20, 16,  7,  5,  3,  5,
+   252,  97, 162, 47, 199,  62,   69, 45, 14,  8, 14,  2,
+   126,  61,  72, 27,  93,  24,   27, 36,  7,  4,  5,  0,
+   119,  62,  66, 20,  67,  25,   45, 22, 15, 10,  8,  6,
+58,  33,  20, 10,  21,  10,   16, 15, 10,  8,  6,  2)
> satdata <- data.frame(Freq, expand.grid(gender=gender, age=age,
+ race=race, sat=sat, loc=loc))
> sat.glm0 <- glm(sat ~ gender + age + race + loc, weights = Freq,
+ family = binomial, data = satdata)
> summary(sat.glm0)

Call:
glm(formula = sat ~ gender + age + race + loc, family = binomial, 
data = satdata, weights = Freq)

Deviance Residuals: 
Min   1Q   Median   3Q  Max  
-19.456   -6.8390.0006.309   17.635  

Coefficients:
 Estimate Std. Error z value Pr(>|z|)
(Intercept)  0.334265   0.056491   5.917 3.28e-09 ***
genderF -0.180480   0.047575  -3.794 0.000149 ***
age35-44 0.122422   0.051836   2.362 0.018191 *  
age>44   0.361610   0.051576   7.011 2.36e-12 ***
raceOther   -0.005883   0.061605  -0.095 0.923919
locMidAtl0.437342   0.103821   4.212 2.53e-05 ***
locS 0.178574   0.073033   2.445 0.014481 *  
locMidW  0.083189   0.066427   1.252 0.210449
locNW0.134337   0.067498   1.990 0.046563 *  
locSW0.295874   0.073488   4.026 5.67e-05 ***
locPac   0.425480   0.096561   4.406 1.05e-05 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ 
’ 1 

(Dispersion parameter for binomial family taken to be 1)

Null deviance: 12987  on 165  degrees of freedom
Residual deviance: 12880  on 155  degrees of freedom
AIC: 12902

Number of Fisher Scoring iterations: 4

> str(satdata)
'data.frame':   168 obs. of  6 variables:
 $ Freq  : num  288 60 224 35 337 70 38 19 32 22 ...
 $ gender: Factor w/ 2 levels "M","F": 1 2 1 2 1 2 1 2 1 2 ...
 $ age   : Factor w/ 3 levels "<35","35-44",..: 1 1 2 2 3 3 1 1 2 2 ...
 $ race  : Factor w/ 2 levels "White","Other": 1 1 1 1 1 1 2 2 2 2 ...
 $ sat   : Factor w/ 2 levels "No","Yes": 2 2 2 2 2 2 2 2 2 2 ...
 $ loc   : Factor w/ 7 levels "NE","MidAtl",..: 1 1 1 1 1 1 1 1 1 1 ...
> sessionInfo()
R version 2.6.2 (2008-02-08) 
i686-pc-linux-gnu 

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

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

loaded via a namespace (and not attached):
[1] tools_2.6.2
> 

-- 

Giovanni Petris  <[EMAIL PROTECTED]>
Associate Professor
Department of Mathematical Sciences
University of Arkansas - Fayetteville, AR 72701
Ph: (479) 575-6324, 575-8630 (fax)
http://definetti.uark.edu/~gpetris/

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

2008-04-10 Thread Gabor Grothendieck
Its avaliable on CRAN extras:

http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/

and can be downloaded even more easily through the Windows
package menu in R.

On Thu, Apr 10, 2008 at 4:45 PM, Doran, Harold <[EMAIL PROTECTED]> wrote:
> Well, I guess it is possible with XML package on CRAN. But, it seems
> there is no windows binary (yet)
>
> > -Original Message-
> > From: [EMAIL PROTECTED]
>
> > [mailto:[EMAIL PROTECTED] On Behalf Of Doran, Harold
> > Sent: Thursday, April 10, 2008 4:29 PM
> > To: Keith Alan Chamberlain; r-help@r-project.org
> > Subject: Re: [R] Relational Databases or XML?
> >
> > I'm not sure it is possible to parse an XML file in R
> > directly. Well, I guess it's *possible*, but may not be the
> > best way to do it. ElementTree in Python is an easy-to-use
> > parser that you might use to first parse your XML file (or
> > others hierarchically structured data), organize it anyway
> > you want, and then bring those data into R for subsequent analysis.
> >
> > In fact, I have recently done just this. I have another
> > statistical program that outputs data as an XML file. So, I
> > wrote a python program that parses that XML file, pulls out
> > the data of interest into a text file, and then I bring those
> > data into R for analysis.
> >
> > > -Original Message-
> > > From: [EMAIL PROTECTED]
> > > [mailto:[EMAIL PROTECTED] On Behalf Of Keith Alan
> > > Chamberlain
> > > Sent: Thursday, April 10, 2008 4:14 PM
> > > To: r-help@r-project.org
> > > Subject: [R] Relational Databases or XML?
> > >
> > > Dear R-Help,
> > >
> > > I am working on a paper in an R course for large file support in R
> > > using scan(), relational databases, and XML. I have never
> > used SQL or
> > > heirarchical document formats such as XML (except where it occurs
> > > without user interaction), and knowledge in RDBs and XML is
> > lacking in
> > > my program. I have tried finding a working example for the
> > > novices-novice on the topic, read many postings, the r-data
> > I/O manual
> > > several times, and descriptions of packages RODBC, DBI, XML, among
> > > others. I understand that RDBs are (assumed at least) used widely
> > > among the R community. I have not been able to put all of
> > the pieces
> > > together, but assuming that RDB use is actually quite
> > widespread, it
> > > should be quite easy to fill me in and/or correct my understanding
> > > where necessary.
> > >
> > > For a cross-platform solution (PC/OSX at least, or in part) my
> > > questions/problems are about what preliminary steps are
> > needed to get
> > > an SQL or XML query "to work" in R to begin with, what the
> > appropriate
> > > data-file formats are, and how to convert to them if
> > starting out with
> > > data in, say, a delimited ASCII text file. Very basic
> > examples should
> > > suffice, say, a table with 20 random observations, a
> > grouping variable
> > > with 2 levels, and a factor with 2 levels.
> > >
> > > ## untested code
> > > set.seed(1024)
> > > write.table("junk.txt",
> > > data.frame(Subj=c(rep(1,10),rep(2,10)),block=rep(c(rep(-1,5),r
> > > ep(1,5)),2), obs=rnorm(20,0,1)))
> > >
> > > Specifically,
> > >
> > > 1- what are the minimum required non R components that are
> > needed to
> > > support SQL or XML functionality, which may or may not need to be
> > > installed?
> > >
> > > 2- what R packages need to be installed, at a minimum (also as a
> > > cross-PC/Mac solution if possible or at least as much as
> > > possible)
> > >
> > > 3- I keep seeing reference to connections of a given name "if
> > > previously setup". What kind of setup is needed outside of
> > R, if any?
> > >
> > > 4- what steps are needed in R to then connect to a file and
> > import a
> > > subset based on a query?
> > >
> > > 5- Do I then use standard R routines (e.g. write()) to
> > export as a DB,
> > > or an RDB/XML specific function?
> > >
> > > Sincerely,
> > > KeithC. [U.S]
> > >
> > > 1/k^c
> > >
> > > __
> > > R-help@r-project.org mailing list
> > > https://stat.ethz.ch/mailman/listinfo/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.
>

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

Re: [R] Row mean scores differ association

2008-04-10 Thread Austin, Matt


There is a R companion to Agresti's text at the following site, I believe the 
answer to your question is there:

http://www.stat.ufl.edu/~aa/cda/cda.html


--Matt

Matt Austin
Biostatistics Director
Amgen, Inc


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of dt Excellent
Sent: Thursday, April 10, 2008 1:18 PM
To: R-Help
Subject: [R] Row mean scores differ association

Suppose that we have o 2-D contingency table where the row variable is nominal 
and the column one is ordinal. In SAS it is possible to compute the statistic 
named as row mean scores differ. How can we programmed it in R?
(See also Aggresti (2002), Categorical Data Analysis, p. 302) With regards


-



[[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] mixture distribution analisys

2008-04-10 Thread Antonio Olinto
Hello,

I'm analyzing some fish length-frequency data to access relative age and growth
information and I would like to do something different from FiSAT / ELEFAN 
analysis.

I found a package named MIX in http://www.math.mcmaster.ca/peter/mix/mix.html
but it's compiled for R 2.0.0

So I have two questions:
Is there any problem to run this package in R 2.7.0? - probably yes …
And, is there any other package in R that can be used to analyze and to separate
mixture distributions?

Thanks for any help. Best regards,

Antonio Olinto
Sao Paulo Fisheries Institute
Brazil

-
WebMail Bignet - O seu provedor do litoral
www.bignet.com.br

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Types in grouped multi-panel (lattice) xyplot

2008-04-10 Thread Aaron Arvey
On Thu, 10 Apr 2008, Deepayan Sarkar wrote:

> On 4/10/08, Deepayan Sarkar <[EMAIL PROTECTED]> wrote:
>> On 4/10/08, Aaron Arvey <[EMAIL PROTECTED]> wrote:
>> > Apologetic prologue: I've looked through the mailing list for an answer to
>> >  this (since I'm sure it's trivial) but I have not been able to find a fix.
>> >
>> >  So the problem is that I want each group to have a different type of plot.
>> >  "Probes" should be points and "Segments" should be lines (preferably using
>> >  the segment plot command, but I've just been trying -- unsuccessfully --
>> >  to get lines to work).
>> >
>> >  To be exact, the data looks like:
>> >
>> >  loc  val   valtype  mouse
>> >  1428  0.1812367 Probes  2
>> >  1439 -0.4534155 Probes  2
>> >  1499 -0.4957303 Probes  2
>> >  1559  0.2448838 Probes  2
>> >  1611 -0.2030937 Probes  2
>> >  1788 -0.2235331 Probes  2
>> >  1428 0.5Segment 2
>> >  1439 0.5Segment 2
>> >  1499 0.5Segment 2
>> >  1559 0.5Segment 2
>> >  1611 0.5Segment 2
>> >  1788 0.5Segment 2
>> >  1428  0.1812367 Probes  1
>> >  1439 -0.4534155 Probes  1
>> >  1499 -0.4957303 Probes  1
>> >  1559  0.2448838 Probes  1
>> >  1611 -0.2030937 Probes  1
>> >  1788 -0.2235331 Probes  1
>> >  1428 0.5Segment 1
>> >  1439 0.5Segment 1
>> >  1499 0.5Segment 1
>> >  1559 0.1Segment 1
>> >  1611 0.1Segment 1
>> >  1788 0.1Segment 1
>> >
>> >
>> >* loc is the x-axis location
>> >* val is the y-axis value
>> >* valtype is equal to "which" had I been smart and used make.groups
>> >* mouse is the 'cond' variable
>> >
>> >
>> >  The plot command I'm currently using is,
>> >
>> >  xyplot(val ~ loc | mouse, data = df,
>> >  groups=valtype
>> >  aspect=0.5, layout=c(3,3),
>> >  lty=0, lwd=3, type="p",
>> >  col=c("black", "blue"),
>> >  as.table = TRUE)
>> >
>> >  which gives me black and blue points for the probes/segments (I've infered
>> >  alphabetical order for the groups colors).  When I change the type to
>> >  c("p", "l"), I get
>> >
>> >  xyplot(val ~ loc | mouse, data = df,
>> >  groups=valtype
>> >  aspect=0.5, layout=c(3,3),
>> >  lty=0, lwd=3, type=c("p","l"),
>> >  col=c("black", "blue"),
>> >  as.table = TRUE)
>>
>>
>> Try
>>
>>
>>  xyplot(val ~ loc | mouse, data = df,
>>
>>groups=valtype,
>>type=c("p","l"),
>>## distribute.type = TRUE,
>
> Sorry, that should be
>
>   distribute.type = TRUE,
>
>>col=c("black", "blue"))

That did exactly what I was looking for!  I now have a very nice lattice 
plot with points and lines!


>> >  I get the exact same plot.  I've tried using a few of the panel functions
>> >  I found on the list (I was particularly hopeful for
>> >  http://tolstoy.newcastle.edu.au/R/help/06/07/30363.html) but I've either
>> >  been misusing them, or they are not right for what I want to do.
>> >
>> >  If anyone knows how to get points and lines in the same panel for the two
>> >  different groups (probes/segments), I would love to hear about it.
>> >
>> >  If you further know how to use the 'segment' plot in panels for the
>> >  segments, I would really love to hear about it.
>>
>>
>> Well, panel.segments() draws segments, but you need your data in the
>>  form (x1, y1, x2, y2) for that. With your setup, it's probably easier
>>  to have lines with some NA-s inserted wherever you want line breaks.

That works perfectly!  I was just planning on reformating the data, but 
this makes life even easier!

Thanks!

Aaron

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Degrees of freedom in binomial glm

2008-04-10 Thread Prof Brian Ripley

You don't have 168 observations - 2 of them have no data (Freq = 0).

On Thu, 10 Apr 2008, Giovanni Petris wrote:



Hello,

I am looking at the job satisfaction data below, from a problem in
Agresti's book, and I am not sure where the degrees of freedom come
from. The way I am fitting a binomial model, I have 168 observations,
so in my understanding that should also be the number of fitted
parameters in the saturated model. Since I have one intercept
parameter, I was thinking to get 167 df for the Null model, but
R tells me it's 165. Where does this number come from?

Thanks in advance,
Giovanni



### Agresti, Problem 5.23
race <- c("White", "Other")
gender <- c("M", "F")
age <- c("<35", "35-44", ">44")
loc <- c("NE", "MidAtl", "S", "MidW", "NW", "SW", "Pac")
sat <- factor(c("Yes", "No"), levels = c("No", "Yes"))
Freq <- c(288,  60, 224, 35, 337,  70,   38, 19, 32, 22, 21, 15,

+   177,  57, 166, 19, 172,  30,   33, 35, 11, 20,  8, 10,
+90,  19,  96, 12, 124,  17,   18, 13,  7,  0,  9,  1,
+45,  12,  42,  5,  39,   2,6,  7,  2,  3,  2,  1,
+   226,  88, 189, 44, 156,  70,   45, 47, 18, 13, 11,  9,
+   128,  57, 117, 34,  73,  25,   31, 35,  3,  7,  2,  2,
+   285, 110, 225, 53, 324,  60,   40, 66, 19, 25, 22, 11,
+   179,  93, 141, 24, 140,  47,   25, 56, 11, 19,  2, 12,
+   270, 176, 215, 80, 269, 110,   36, 25,  9, 11, 16,  4,
+   180, 151, 108, 40, 136,  40,   20, 16,  7,  5,  3,  5,
+   252,  97, 162, 47, 199,  62,   69, 45, 14,  8, 14,  2,
+   126,  61,  72, 27,  93,  24,   27, 36,  7,  4,  5,  0,
+   119,  62,  66, 20,  67,  25,   45, 22, 15, 10,  8,  6,
+58,  33,  20, 10,  21,  10,   16, 15, 10,  8,  6,  2)

satdata <- data.frame(Freq, expand.grid(gender=gender, age=age,

+ race=race, sat=sat, loc=loc))

sat.glm0 <- glm(sat ~ gender + age + race + loc, weights = Freq,

+ family = binomial, data = satdata)

summary(sat.glm0)


Call:
glm(formula = sat ~ gender + age + race + loc, family = binomial,
   data = satdata, weights = Freq)

Deviance Residuals:
   Min   1Q   Median   3Q  Max
-19.456   -6.8390.0006.309   17.635

Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept)  0.334265   0.056491   5.917 3.28e-09 ***
genderF -0.180480   0.047575  -3.794 0.000149 ***
age35-44 0.122422   0.051836   2.362 0.018191 *
age>44   0.361610   0.051576   7.011 2.36e-12 ***
raceOther   -0.005883   0.061605  -0.095 0.923919
locMidAtl0.437342   0.103821   4.212 2.53e-05 ***
locS 0.178574   0.073033   2.445 0.014481 *
locMidW  0.083189   0.066427   1.252 0.210449
locNW0.134337   0.067498   1.990 0.046563 *
locSW0.295874   0.073488   4.026 5.67e-05 ***
locPac   0.425480   0.096561   4.406 1.05e-05 ***
---
Signif. codes:  0 â??***â?? 0.001 â??**â?? 0.01 â??*â?? 0.05 â??.â?? 0.1 â?? 
â?? 1

(Dispersion parameter for binomial family taken to be 1)

   Null deviance: 12987  on 165  degrees of freedom
Residual deviance: 12880  on 155  degrees of freedom
AIC: 12902

Number of Fisher Scoring iterations: 4


str(satdata)

'data.frame':   168 obs. of  6 variables:
$ Freq  : num  288 60 224 35 337 70 38 19 32 22 ...
$ gender: Factor w/ 2 levels "M","F": 1 2 1 2 1 2 1 2 1 2 ...
$ age   : Factor w/ 3 levels "<35","35-44",..: 1 1 2 2 3 3 1 1 2 2 ...
$ race  : Factor w/ 2 levels "White","Other": 1 1 1 1 1 1 2 2 2 2 ...
$ sat   : Factor w/ 2 levels "No","Yes": 2 2 2 2 2 2 2 2 2 2 ...
$ loc   : Factor w/ 7 levels "NE","MidAtl",..: 1 1 1 1 1 1 1 1 1 1 ...

sessionInfo()

R version 2.6.2 (2008-02-08)
i686-pc-linux-gnu

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

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

loaded via a namespace (and not attached):
[1] tools_2.6.2




--

Giovanni Petris  <[EMAIL PROTECTED]>
Associate Professor
Department of Mathematical Sciences
University of Arkansas - Fayetteville, AR 72701
Ph: (479) 575-6324, 575-8630 (fax)
http://definetti.uark.edu/~gpetris/

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



--
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595__
R-help@r-project.org mailing list
https://s

[R] Fixing the physical size of Trellis graphs panels

2008-04-10 Thread Sébastien
Dear R-users,

Please consider the following script:

#

library(lattice)
ID <- rep(1:8,each=2)
x <- rep (c(1,2),8)
y <- c(rep(c(0.5,2),4),rep(c(50,1000),4))
df<-data.frame(ID,x,y)
g <- rep(1:2,each=8)
df.split<-split(df,g)

df.split

pdf(file="C:/Test.pdf")

for (i in 1:2) {
mydf<-as.data.frame(df.split[i])
myplot<-xyplot(mydf[,3]~mydf[,2]|mydf[,1],
   data=mydf,
   layout=c(2,2))
print(myplot)
}
dev.off()

You will find that the physical size of the panels are different on page 
1 and 2 because the axis labels have different length. Is it possible to 
fix the dimension of the panels regardless of the length of the axis labels?

Thank you for your input.

Sebastien

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

2008-04-10 Thread Martin Morgan
Harold -- you'll really want to check out the XML package. xmlTreeParse 
+ xpathApply provides a very flexible solution. As a recent example, 
parsing 189 XML files to extract 4 attributes from deeply nested 
elements into a data frame:

fls <- list.files('~/runBrowser', pattern=".*xml", full=TRUE)
f <- function(fl) {
 xq <- function(xml, q)
 unlist(xpathApply(xml, q, xmlValue, namespaces="xsi"))
 xml <- xmlTreeParse(fl, useInternal=TRUE)
 data.frame(idx=rep(as.numeric(xq(xml, "//xsi:tile/@idx")), each=4),
 lane=rep(as.numeric(xq(xml, "//xsi:tile/@lane")), each=4),
 base=xq(xml, '//xsi:image/@base'),
 medSigInt=as.numeric(xq(xml, "//xsi:sgnInt/@median")))
}
res <- do.call('rbind', lapply(fls, f))

'res' has 54800 rows and 4 columns. The XML stays in C, so this is fast. 
The data can be effectively (your mileage may vary) visualized with 
lattice, e.g.,

xyplot(log(medSigInt)~idx|lane*base, res, strip=FALSE, pch=".", cex=2)

Martin

Doran, Harold wrote:
> I'm not sure it is possible to parse an XML file in R directly. Well, I
> guess it's *possible*, but may not be the best way to do it. ElementTree
> in Python is an easy-to-use parser that you might use to first parse
> your XML file (or others hierarchically structured data), organize it
> anyway you want, and then bring those data into R for subsequent
> analysis.
> 
> In fact, I have recently done just this. I have another statistical
> program that outputs data as an XML file. So, I wrote a python program
> that parses that XML file, pulls out the data of interest into a text
> file, and then I bring those data into R for analysis.
> 
>> -Original Message-
>> From: [EMAIL PROTECTED] 
>> [mailto:[EMAIL PROTECTED] On Behalf Of Keith Alan 
>> Chamberlain
>> Sent: Thursday, April 10, 2008 4:14 PM
>> To: r-help@r-project.org
>> Subject: [R] Relational Databases or XML?
>>
>> Dear R-Help,
>>
>> I am working on a paper in an R course for large file support 
>> in R using scan(), relational databases, and XML. I have 
>> never used SQL or heirarchical document formats such as XML 
>> (except where it occurs without user interaction), and 
>> knowledge in RDBs and XML is lacking in my program. I have 
>> tried finding a working example for the novices-novice on the 
>> topic, read many postings, the r-data I/O manual several 
>> times, and descriptions of packages RODBC, DBI, XML, among 
>> others. I understand that RDBs are (assumed at least) used 
>> widely among the R community. I have not been able to put all 
>> of the pieces together, but assuming that RDB use is actually 
>> quite widespread, it should be quite easy to fill me in 
>> and/or correct my understanding where necessary.
>>
>> For a cross-platform solution (PC/OSX at least, or in part) 
>> my questions/problems are about what preliminary steps are 
>> needed to get an SQL or XML query "to work" in R to begin 
>> with, what the appropriate data-file formats are, and how to 
>> convert to them if starting out with data in, say, a 
>> delimited ASCII text file. Very basic examples should 
>> suffice, say, a table with 20 random observations, a grouping 
>> variable with 2 levels, and a factor with 2 levels.
>>
>> ## untested code
>> set.seed(1024)
>> write.table("junk.txt", 
>> data.frame(Subj=c(rep(1,10),rep(2,10)),block=rep(c(rep(-1,5),r
>> ep(1,5)),2), obs=rnorm(20,0,1)))
>>
>> Specifically,
>>
>> 1- what are the minimum required non R components that are 
>> needed to support SQL or XML functionality, which may or may 
>> not need to be installed?
>>
>> 2- what R packages need to be installed, at a minimum (also 
>> as a cross-PC/Mac solution if possible or at least as much as 
>> possible)
>>
>> 3- I keep seeing reference to connections of a given name "if 
>> previously setup". What kind of setup is needed outside of R, if any?
>>
>> 4- what steps are needed in R to then connect to a file and 
>> import a subset based on a query?
>>
>> 5- Do I then use standard R routines (e.g. write()) to export 
>> as a DB, or an RDB/XML specific function?
>>
>> Sincerely,
>> KeithC. [U.S]
>>
>> 1/k^c
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/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.


-- 
Martin Morgan
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109

Location: Arnold Building M2 B169
Phone: (206) 667-2793

__
R-help@r-project.org mailing list
https://stat.eth

Re: [R] Fixing the physical size of Trellis graphs panels

2008-04-10 Thread Deepayan Sarkar
On 4/10/08, Sébastien <[EMAIL PROTECTED]> wrote:
> Dear R-users,
>
>  Please consider the following script:
>
>  #
>
>  library(lattice)
>  ID <- rep(1:8,each=2)
>  x <- rep (c(1,2),8)
>  y <- c(rep(c(0.5,2),4),rep(c(50,1000),4))
>  df<-data.frame(ID,x,y)
>  g <- rep(1:2,each=8)
>  df.split<-split(df,g)
>
>  df.split
>
>  pdf(file="C:/Test.pdf")
>
>  for (i in 1:2) {
>  mydf<-as.data.frame(df.split[i])
>  myplot<-xyplot(mydf[,3]~mydf[,2]|mydf[,1],
>data=mydf,
>layout=c(2,2))
>  print(myplot)
>  }
>  dev.off()
>
>  You will find that the physical size of the panels are different on page
>  1 and 2 because the axis labels have different length. Is it possible to
>  fix the dimension of the panels regardless of the length of the axis labels?

Yes, look at the entry for panel.width and panel.height in
?print.trellis. You could use it as

print(myplot, panel.width = list(x = 3, unit = "inches"))

etc. See ?unit in the grid package for details.

-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] mixture distribution analisys

2008-04-10 Thread Ingmar Visser
The CRAN task view on cluster and mixture models likely has what you  
need.
hth, Ingmar

http://cran.r-project.org/web/views/Cluster.html

On Apr 10, 2008, at 11:20 PM, Antonio Olinto wrote:

> Hello,
>
> I'm analyzing some fish length-frequency data to access relative  
> age and growth
> information and I would like to do something different from FiSAT /  
> ELEFAN analysis.
>
> I found a package named MIX in http://www.math.mcmaster.ca/peter/ 
> mix/mix.html
> but it's compiled for R 2.0.0
>
> So I have two questions:
> Is there any problem to run this package in R 2.7.0? - probably yes …
> And, is there any other package in R that can be used to analyze  
> and to separate
> mixture distributions?
>
> Thanks for any help. Best regards,
>
> Antonio Olinto
> Sao Paulo Fisheries Institute
> Brazil
>
> -
> WebMail Bignet - O seu provedor do litoral
> www.bignet.com.br
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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.


  1   2   >