Re: [R] Datapoints underneath datapoints Problem

2007-06-02 Thread Philipp Pagel

> I would like to know if there is any
> possible way in which I could view those datapoints that are layered on top
> of each other

You could use jitter() to add a little noise to the data. Of course that
will slightly change the position of each point.

If that is not an option you could possibly detect points with almost
identical coordintes yourself and then change the color of the
respective plotting symbol.

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-8161-71 2131
Dept. of Genome Oriented Bioinformatics  Fax.  +49-8161-71 2186
Technical University of Munich
Science Center Weihenstephan
85350 Freising, Germany

 and

Institute for Bioinformatics / MIPS  Tel.  +49-89-3187 3675
GSF - National Research Center   Fax.  +49-89-3187 3585
  for Environment and Health
Ingolstädter Landstrasse 1
85764 Neuherberg, Germany
http://mips.gsf.de/staff/pagel

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


Re: [R] plotting command trouble

2007-04-19 Thread Philipp Pagel
On Thu, Apr 19, 2007 at 02:10:37PM +0200, Schmitt, Corinna wrote:

>> Hi, the length of the coordinates are different.
>> 
>> Try:
>> plot(seq(0,60, l=100), seq(0,0.896, l=100), type="n", xlab="Zeit [min]", 
>> ylab="Absorptionsmessung
>>bei 600nm",main="Zellwandstabilit?t" ) 

> I know, but it is needed. Any other idea?

Read the reply again. Of course, the number of x and y values needs to
be the same - how else would you plot the points?
The problem is that 0:0.896 does not do what you assumed it does.
Henrique actually provided the solution - did you try it?

Also, in your plot command you are using type='n' which will cause R not
to plot the actual data points. Without knowing the context of your
command I can only guess what you are trying to accomplish. Are you
plotting points into the empty plot later on?

Maybe you are just trying to set the plotting range? In that case better
use the xlim and ylim parameters of the plot function.

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-8161-71 2131
Dept. of Genome Oriented Bioinformatics  Fax.  +49-8161-71 2186
Technical University of Munich
Science Center Weihenstephan
85350 Freising, Germany

 and

Institute for Bioinformatics / MIPS  Tel.  +49-89-3187 3675
GSF - National Research Center   Fax.  +49-89-3187 3585
  for Environment and Health
Ingolstädter Landstrasse 1
85764 Neuherberg, Germany
http://mips.gsf.de/staff/pagel

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] categorical column to numeric column

2007-02-19 Thread Philipp Pagel

> Let 'dd' be a data frame given as:
> 
> dd=data.frame(aa=c("a","a","b","a","b","b"),bb=c(1,1,1,2,3,4))
> 
> Now I want to create a column 'g' such that if dd$aa=a then dd$g=1 else
> dd$g= -1 .

You need to use ifelse instead of the if ... else construction:

dd$g = ifelse(dd$a=='a', 1, -1)

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-8161-71 2131
Dept. of Genome Oriented Bioinformatics  Fax.  +49-8161-71 2186
Technical University of Munich
Science Center Weihenstephan
85350 Freising, Germany

 and

Institute for Bioinformatics / MIPS  Tel.  +49-89-3187 3675
GSF - National Research Center   Fax.  +49-89-3187 3585
  for Environment and Health
Ingolstädter Landstrasse 1
85764 Neuherberg, Germany
http://mips.gsf.de/staff/pagel

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] percent sign in plot annotation

2007-01-17 Thread Philipp Pagel
On Wed, Jan 17, 2007 at 09:57:49AM -, Martin Keller-Ressel wrote:
> I would like to annotate a graph with the expression 'alpha = 5%' (the  
> alpha should be displayed as the greek letter).
> I tried
> 
> > text(1,1,expression(alpha == 5%))

text(1,1, expression(paste(alpha == 5, '%')) )

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-8161-71 2131
Dept. of Genome Oriented Bioinformatics  Fax.  +49-8161-71 2186
Technical University of Munich
Science Center Weihenstephan
85350 Freising, Germany
http://mips.gsf.de/staff/pagel

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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/plotmath/substitute problem

2006-12-14 Thread Philipp Pagel
On Thu, Dec 14, 2006 at 06:25:49PM -0500, Duncan Murdoch wrote:
> On 12/14/2006 5:05 PM, Philipp Pagel wrote:
> >My problem starts, when I want to put more than one series of data in
> >the plot and accordingly need one legend row per data series:
> >
> >year1 = 2001
> >year2 = 2005
> >g1 = 1.9
> >g2 = 1.7
> >plot(1)
> >legend('top', 
> > legend=c(
> > substitute(paste(year, ': ', gamma, '=', g), 
> > list(year=year1, g=g1)),
> > substitute(paste(year, ': ', gamma, '=', g), 
> > list(year=year2, g=g2))
> > )
> >)
> >
> >This obviously does not produce the desired result. Apparently, I am not
> >generating a list of expressions, as intended. So I thought, maybe R uses a
> >variety of the recycling rule here and tried:
> 
> The problem is that legend wants an expression, but substitute() isn't 
> returning one, it's returning a call, and c(call1,call2) produces a list 
> of two calls, not an expression holding two calls.  So the following 
> would work, but there might be something more elegant:

Thanks a lot! Learned something, again.

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-8161-71 2131
Dept. of Genome Oriented Bioinformatics  Fax.  +49-8161-71 2186
Technical University of Munich
85350 Freising, Germany
http://mips.gsf.de/staff/pagel

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] legend/plotmath/substitute problem

2006-12-14 Thread Philipp Pagel

Dear R Experts,

I am trying to produce a legend for a series of plots which are
generated in a loop. The legend is supposed to look like this:

2000: gamma=1.8

where gamma is replaced by the greek letter and both the year and the
value of gamma are stored in variables.

Everything works fine as long as I have only one data series:

year = 2001
g = 1.9
plot(1)
legend('top', legend=substitute(paste(year, ': ', gamma, '=', g), 
list(year=year, g=g)) )


My problem starts, when I want to put more than one series of data in
the plot and accordingly need one legend row per data series:

year1 = 2001
year2 = 2005
g1 = 1.9
g2 = 1.7
plot(1)
legend('top', 
legend=c(
substitute(paste(year, ': ', gamma, '=', g), list(year=year1, 
g=g1)),
substitute(paste(year, ': ', gamma, '=', g), list(year=year2, 
g=g2))
)
)

This obviously does not produce the desired result. Apparently, I am not
generating a list of expressions, as intended. So I thought, maybe R uses a
variety of the recycling rule here and tried:

year = c(2001, 2005)
g = c(1.9, 1.7)
plot(1)
legend('top',
legend=list(
substitute(paste(year, ': ', gamma, '=', g), list(year=year, g=g)),
)
)

No succes, either...

I have read and re-read the documentation for legend, expression, substitute
and plotmath but can't figure it out. Even drinking a cup of tea prepared from
fine-cut man page printouts didn't lead to satori.

I'm probably missing something simple. Any hints are highly appreciated.

Thanks
Philipp

-- 
Dr. Philipp PagelTel.  +49-8161-71 2131
Dept. of Genome Oriented Bioinformatics  Fax.  +49-8161-71 2186
Technical University of Munich
85350 Freising, Germany
http://mips.gsf.de/staff/pagel

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] newbie: new_data_frame <- selected set of rows

2006-12-02 Thread Philipp Pagel

Hi!

> distances <- order(distancevector(scaled_DB, scaled_DB['query',],
> d="euclid"))

Just compute the distances WITHOUT ordering, here. And then

> 1) create a small top_five frame

top = scaled_DB[rank(distances)<=5, ]

rank() is better for this than order() in case there are ties.

> 2) after I got top_five I woul like to get the index
> of my query entry, something along Pythons 
> top_five.index('query_string')

You mean by row name?

which(row.names(scaled_DB)=='query_string')

But why would you need the index? If you want to get the respective row
use logical indexing:

my_dataframe['query_string', ]

> 3) possibly combine values in distances with row names
> from my_dataframe:
> row_1 distance_from_query1
> row_2 distance_from_query2

The easiest way to store the distances along with the original names and
data would be to simply make distances a column in your data frame,
which is what I would have done to begin with. The entire procedure
would then look like this:

my_dataframe = read.table( ... )
scaled_DB <- scale(my_dataframe, center=FALSE)
scaled_DB$dist1 = distancevector(scaled_DB, scaled_DB['query1',], ...)
scaled_DB$dist2 = distancevector(scaled_DB, scaled_DB['query2',], ...)
scaled_DB$dist3 = distancevector(scaled_DB, scaled_DB['query3',], ...)
...
top1 = scaled_DB[rank(scaled_DB$dist1)<=5, ]
...

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-8161-71 2131
Dept. of Genome Oriented Bioinformatics  Fax.  +49-8161-71 2186
Technical University of Munich
Science Center Weihenstephan
85350 Freising, Germany

 and

Institute for Bioinformatics / MIPS  Tel.  +49-89-3187 3675
GSF - National Research Center   Fax.  +49-89-3187 3585
  for Environment and Health
Ingolstädter Landstrasse 1
85764 Neuherberg, Germany
http://mips.gsf.de/staff/pagel

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] comma delimiter & comma in text

2006-11-29 Thread Philipp Pagel

> 1, A, 24, The Red House
> 2, A, 25, King's Home, by the Sea
> ...

> Is there a way i can specify to R that "King's Home, by the Sea" is one 
> word?

Yes: It needs to be quoted in the file:

2, A, 25, "King's Home, by the Sea"

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-8161-71 2131
Dept. of Genome Oriented Bioinformatics  Fax.  +49-8161-71 2186
Technical University of Munich

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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 increase decimal places

2006-11-12 Thread Philipp Pagel
On Sun, Nov 12, 2006 at 07:32:49PM +0100, "Maja Schröter" wrote:
> does anybody know how to increase the decimal places that R uses to
> calculate something.
> 
> I think that in default R uses 6 decimal places but I need 12.

What you are experiencing is R PRINTING only a certain number of digits.
All calcualtions are done at full precision, though. 

Example:

> a=1/3
> a
[1] 0.333
> print(a)
[1] 0.333
> print(a, digits=12)
[1] 0.

For more details have a look at ?print and also at ?options and search
for 'digits'.

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-8161-71 2131
Dept. of Genome Oriented Bioinformatics  Fax.  +49-8161-71 2186
Technical University of Munich
Science Center Weihenstephan
85350 Freising, Germany

 and

Institute for Bioinformatics / MIPS  Tel.  +49-89-3187 3675
GSF - National Research Center   Fax.  +49-89-3187 3585
  for Environment and Health
Ingolstädter Landstrasse 1
85764 Neuherberg, Germany
http://mips.gsf.de/staff/pagel

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] read file problem

2006-11-03 Thread Philipp Pagel
On Fri, Nov 03, 2006 at 02:02:35PM +, Luis Ridao Cruz wrote:

> DEPTH  CTDPRS  CTDTMP  CTDSAL  RAWFLU NUMB. QUAL
> MDBAR IPTS-68  PSS-78  OBS.
>   *** *** *** ***
> 1 1.0   2999
> 2 2.0  5.9793 35.1629.10717 2221
> 3 3.0  5.9797 35.1631.10117 2221
> 4 4.0  5.9809 35.1631.11812 2221
> 5 5.1  5.9811 35.1629.11542 2221
> 6 6.1  5.9810 35.1631.11618 2221
> 7 7.1  5.9797 35.1631.11615 2221
> 8 8.1  5.9798 35.1630.10213 2221
> 9 9.1  5.9792 35.1629.11311 2221

> read.table(file, skip = 10)

To me it looks like your data is in a fixed-width format. If that is the
case you should use read.fwf() instead of read.table().

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-8161-71 2131
Dept. of Genome Oriented Bioinformatics  Fax.  +49-8161-71 2186
Technical University of Munich
Science Center Weihenstephan
85350 Freising, Germany
http://mips.gsf.de/staff/pagel

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Read.csv

2006-10-26 Thread Philipp Pagel
On Thu, Oct 26, 2006 at 09:41:25AM +0900, Wang, Joshua (EQS) wrote:
> Are there ways to load a csv file without row.names by read.csv? Thanks.

Have a look at ?read.csv. Somewhere in there you will find an
explanation for the option row.name. In your case, you probably want to
set it to NULL.

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-8161-71 2131
Dept. of Genome Oriented Bioinformatics  Fax.  +49-8161-71 2186
Technical University of Munich
Science Center Weihenstephan
85350 Freising, Germany

 and

Institute for Bioinformatics / MIPS  Tel.  +49-89-3187 3675
GSF - National Research Center   Fax.  +49-89-3187 3585
  for Environment and Health
Ingolstädter Landstrasse 1
85764 Neuherberg, Germany
http://mips.gsf.de/staff/pagel

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] one is not one

2006-10-21 Thread Philipp Pagel
On Sat, Oct 21, 2006 at 11:04:13AM +0200, Patrick Giraudoux wrote:
> Which means that actually sum(x) is NOT considered equal to 1...
> 
> Any idea about what is going wrong?

Others have already pointed out the problem and I would like to add a
reference to a classical paper on this topic:

David Goldberg
What Every Computer Scientist Should Know About Floating-Point Arithmetic
Computing Surveys, 1991

Reprints can be found in many places online - e.g. here:

http://www.physics.ohio-state.edu/~dws/grouplinks/floating_point_math.pdf

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-8161-71 2131
Dept. of Genome Oriented Bioinformatics  Fax.  +49-8161-71 2186
Technical University of Munich
Science Center Weihenstephan
85350 Freising, Germany

 and

Institute for Bioinformatics / MIPS  Tel.  +49-89-3187 3675
GSF - National Research Center   Fax.  +49-89-3187 3585
  for Environment and Health
Ingolstädter Landstrasse 1
85764 Neuherberg, Germany
http://mips.gsf.de/staff/pagel

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Convert Contingency Table to Flat File

2006-10-17 Thread Philipp Pagel
On Tue, Oct 17, 2006 at 03:08:49AM -0700, Marco LO wrote:
>   Is there any R function out there to turn a multi-way contingency
>   table back to a flat file table of individual rows and attribute
>   columns.?

Are you looking for something like this?

# generate some data
x = sample(c(0,1), 100, replace=T)
y = sample(c(0,1), 100, replace=T)
z = sample(c(0,1), 100, replace=T)
# contingency table
mytab = table(x,y,z)
# flat contingency table
as.data.frame( mytab )

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-8161-71 2131
Dept. of Genome Oriented Bioinformatics  Fax.  +49-8161-71 2186
Technical University of Munich
Science Center Weihenstephan
85350 Freising, Germany

 and

Institute for Bioinformatics / MIPS  Tel.  +49-89-3187 3675
GSF - National Research Center   Fax.  +49-89-3187 3585
  for Environment and Health
Ingolstädter Landstrasse 1
85764 Neuherberg, Germany
http://mips.gsf.de/staff/pagel

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


Re: [R] Help on direction of axis in R needed

2006-10-11 Thread Philipp Pagel

> I'd like to plot things with axes going from the
> highest to the lowest value

You can use the xlim and ylim parameters of the plot function. E.g:

x = 1:100
plot(x, x^2)  # normal
plot(x, x^2, xlim=c(100,0))   # reversed x axis

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-8161-71 2131
Dept. of Genome Oriented Bioinformatics  Fax.  +49-8161-71 2186
Technical University of Munich
Science Center Weihenstephan
85350 Freising, Germany

 and

Institute for Bioinformatics / MIPS  Tel.  +49-89-3187 3675
GSF - National Research Center   Fax.  +49-89-3187 3585
  for Environment and Health
Ingolstädter Landstrasse 1
85764 Neuherberg, Germany
http://mips.gsf.de/staff/pagel

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Reading data with blank elements

2006-07-21 Thread Philipp Pagel

Hi!

On Fri, Jul 21, 2006 at 05:43:03AM -0700, Ahamarshan jn wrote:
>  I have a dataset saved in *.csv format, that contains
[...]

> BS00,-0.084,0.0136,-0.1569,-0.6484,1.103,1.7859,0.40287,0.5368,0.08461,-0.1935,-0.147974,0.30685
> BS01,0.491270283,0.875826172,,
> BS02,0.090794476,0.225858954,,,0.32643,0.34317,0.133145295,,,0.115832599,0.47636458,
> BS03,0.019828221,-0.095735935,-0.122767219,-0.0676,0.002533,-0.1510361,0.736247,2.053192,-0.423658,0.4591219,1.1245015,
> BS04,-0.435189342,-0.041595955,-0.781281128,-1.923036,-3.2301671020.152322609,-1.495513519,,


> person.data<-read.table("datafile.csv",header=TRUE,sep=',',row.names=1)
> 
> Error in scan (file = file, what = what, sep = sep,
> quote = quote, dec = dec,  : 
> line 1919 did not have 13 elements
> Execution halted "

R does handle empty elements fine. The error message you quote occurs if
a row does not contain the expected number of elements (empty or not.)

Did you have a look at row 1919? Does it really contain the same number
of separators (commas) as the other ones?

Some programs handle empty elements at the end of a row in a 'lazy' way
and simply ommit them. If this is the case you can use the option
'fill=TRUE' to tell read.table that you want it to silently pad short
rows with empty elements.

Another 'popular' reason for funny errors with read.table is the
unexpected occurence of quotation or comment characters in the data...

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-8161-71 2131
Dept. of Genome Oriented Bioinformatics  Fax.  +49-8161-71 2186
Technical University of Munich
Science Center Weihenstephan
85350 Freising, Germany

 and

Institute for Bioinformatics / MIPS  Tel.  +49-89-3187 3675
GSF - National Research Center   Fax.  +49-89-3187 3585
  for Environment and Health
Ingolstädter Landstrasse 1
85764 Neuherberg, Germany
http://mips.gsf.de/staff/pagel

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Merge two dataframes of different column length and row length by two columns at a time

2006-07-21 Thread Philipp Pagel
On Fri, Jul 21, 2006 at 09:33:56AM +0200, Gunther Höning wrote:
> I have two dataframes of the following structures:
[...]

> I want to merge these dataframes by V1 and V2 of a and b. The combination of
> V1, V2 is a unique key.
> Note that b is smaller than a.
> 
> Any suggestions to solve this problem ?

Use merge()

cu
    Philipp

-- 
Dr. Philipp PagelTel.  +49-8161-71 2131
Dept. of Genome Oriented Bioinformatics  Fax.  +49-8161-71 2186
Technical University of Munich
Science Center Weihenstephan
85350 Freising, Germany

 and

Institute for Bioinformatics / MIPS  Tel.  +49-89-3187 3675
GSF - National Research Center   Fax.  +49-89-3187 3585
  for Environment and Health
Ingolstädter Landstrasse 1
85764 Neuherberg, Germany
http://mips.gsf.de/staff/pagel

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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 can I delete rows?

2006-07-19 Thread Philipp Pagel
On Tue, Jul 18, 2006 at 12:25:47PM -0300, raul sanchez wrote:
>   I have the Barro-Lee data set which contains 98 countries and I want
>   to run the regressions only for the Latin America countries, so what
>   do you recomend? How can I delete all the other countries or how can
>   I select the countries of Lat. Am. thank you

>   this is the list of countries
>   SHCODE COUNTRY  NAME   WBCTRY   (1)   (2)
> _
> 
>   1Algeria  DZA  + +
>   2Angola   AGO  - -
>   3BeninBEN  - +
>   4Botswana BWA  + +
>   5Burkina Faso HVO  - -
>   6Burundi  BDI  + -
>   7Cameroon CMR  + +
[...]


Assuming the data is stored in a data frame called bl you could do
something like this:

First you generate a list of all countries you are interested in - e.g.

> set = c('Benin', 'Congo', 'Mali')


And then you subset the data frame with it

> bl[bl$COUNTRY %in% set, ]
   SHCODE COUNTRY NAME WBCTRY X.1. X.2.
3   3   Benin  BEN  -+   NA
12 12   Congo  COG  -+   NA
26 26Mali  MLI  -+   NA


cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-8161-71 2131
Dept. of Genome Oriented Bioinformatics  Fax.  +49-8161-71 2186
Technical University of Munich
Science Center Weihenstephan
85350 Freising, Germany

 and

Institute for Bioinformatics / MIPS  Tel.  +49-89-3187 3675
GSF - National Research Center   Fax.  +49-89-3187 3585
  for Environment and Health
Ingolstädter Landstrasse 1
85764 Neuherberg, Germany
http://mips.gsf.de/staff/pagel

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Way to convert data frame to matrix

2006-06-30 Thread Philipp Pagel
On Fri, Jun 30, 2006 at 10:11:15AM -0400, Wade Wall wrote:
>   I have a text file that I have imported into R.  It contains 3 columns and
> 316940 rows.  The first column is vegetation plot ID, the second species
> names and the third is a cover value (numeric).  I imported using the
> read.table function.
> 
> My problem is this.  I need to reformat the information as a matrix, with
> the first column becoming the row labels and the second the column labels
> and the cover values as the matrix cell data.

I'm not 100% sure but I think you are looking for reshape().

cu
    Philipp

-- 
Dr. Philipp PagelTel.  +49-8161-71 2131
Dept. of Genome Oriented Bioinformatics  Fax.  +49-8161-71 2186
Technical University of Munich
Science Center Weihenstephan
85350 Freising, Germany

 and

Institute for Bioinformatics / MIPS  Tel.  +49-89-3187 3675
GSF - National Research Center   Fax.  +49-89-3187 3585
  for Environment and Health
Ingolstädter Landstrasse 1
85764 Neuherberg, Germany
http://mips.gsf.de/staff/pagel

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Extracting R plots from MS Word

2006-06-29 Thread Philipp Pagel
On Thu, Jun 29, 2006 at 05:15:08PM +1200, [EMAIL PROTECTED] wrote:
> I am revising a paper that I am a co-author of. The figures are plots
> generated from R but at the moment I do not have the R code that generates
> them.
> 
> As this is time critical I would like to slightly abuse the list by asking
> whether anyone knows how to extract from MS Word into a stand-alone
> graphics file a plot that was pasted into Word from R (probably as a
> Windows Metafile, but possibly as a bitmap).

Open the doc file in OpenOffice, save in sxw format (openoffice's old 
native format), unpack the file with unzip and find the figure in the
resulting directory.

I'm not sure if and how this works with the new odt format used by
openoffice now, but sxw will work.

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-8161-71 2131
Dept. of Genome Oriented Bioinformatics  Fax.  +49-8161-71 2186
Technical University of Munich
Science Center Weihenstephan
85350 Freising, Germany

 and

Institute for Bioinformatics / MIPS  Tel.  +49-89-3187 3675
GSF - National Research Center   Fax.  +49-89-3187 3585
  for Environment and Health
Ingolstädter Landstrasse 1
85764 Neuherberg, Germany
http://mips.gsf.de/staff/pagel

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] PowerPoint

2006-06-23 Thread Philipp Pagel
On Fri, Jun 23, 2006 at 11:27:00AM -0500, Marc Schwartz (via MN) wrote:
> On Fri, 2006-06-23 at 18:16 +0200, Philipp Pagel wrote:
> > On Fri, Jun 23, 2006 at 09:21:37AM -0400, Gabor Grothendieck wrote:
> > > Note that jpg, bmp and png are in less desirable bit mapped formats 
> > > whereas
> > > eps is in a more desirable vector format (magnification and shrinking does
> > > not involve loss of info) and so would be preferable from a quality
> > > viewpoint.
> > 
> > In addition to seconding the above statement I'd like to add that in
> > cases where you are forced to use a bitmap format png tends to produce
> > much better results than jpg where line drawings (e.g. most plots) are
> > concerned. JPG format on the other hand is great for anyting which can be
> > discirbed as photography-like. jpg images of plots tend to suffer from
> > bad artifacts...

> That is generally because png files are not compressed, whereas jpg
> files are. 

In fact, png uses a combination of pre-filtering and lossless compression 
(in contrast to lossy compression algortihms use in jpg). 

Of course, lossy compression can achieve much smaller file sizes for
most images. While even a substantial loss of information can go
undetected by the observer in the case of photographic images with no
sharp edges, line drawings suffer badly. 

Line drawings usually contain vast percentages of empty space (i.e.
white) and thus can be compressed quite effectively by the
pre-filteing/lossless compression used by png.

Anyway - I totally agree that eps rules and pixel formats should be
avoided at all cost for illustrations, plots, etc. ...

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-8161-71 2131
Dept. of Genome Oriented Bioinformatics  Fax.  +49-8161-71 2186
Technical University of Munich
Science Center Weihenstephan
85350 Freising, Germany

 and

Institute for Bioinformatics / MIPS  Tel.  +49-89-3187 3675
GSF - National Research Center   Fax.  +49-89-3187 3585
  for Environment and Health
Ingolstädter Landstrasse 1
85764 Neuherberg, Germany
http://mips.gsf.de/staff/pagel

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] PowerPoint

2006-06-23 Thread Philipp Pagel
On Fri, Jun 23, 2006 at 09:21:37AM -0400, Gabor Grothendieck wrote:
> Note that jpg, bmp and png are in less desirable bit mapped formats whereas
> eps is in a more desirable vector format (magnification and shrinking does
> not involve loss of info) and so would be preferable from a quality
> viewpoint.

In addition to seconding the above statement I'd like to add that in
cases where you are forced to use a bitmap format png tends to produce
much better results than jpg where line drawings (e.g. most plots) are
concerned. JPG format on the other hand is great for anyting which can be
discirbed as photography-like. jpg images of plots tend to suffer from
bad artifacts...

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-8161-71 2131
Dept. of Genome Oriented Bioinformatics  Fax.  +49-8161-71 2186
Technical University of Munich
Science Center Weihenstephan
85350 Freising, Germany

 and

Institute for Bioinformatics / MIPS  Tel.  +49-89-3187 3675
GSF - National Research Center   Fax.  +49-89-3187 3585
  for Environment and Health
Ingolstädter Landstrasse 1
85764 Neuherberg, Germany
http://mips.gsf.de/staff/pagel

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] how to put the results of loop into a dataframe

2006-06-20 Thread Philipp Pagel
On Tue, Jun 20, 2006 at 09:09:16AM +0800, zhijie zhang wrote:
>  suppose i want to do the following caulation for 100 times, how to put the
> results of x , y and z into the same dataframe/dataset?
> x<-runif(1)
> y<-x+1
> z<-x+y

Several possibilities:

1) Use rbind

Before loop:

d = NULL

And in the loop:

d = rbind(d, data.frame(x, y, z))


2) Build empty data frame of desired size beforehand and fill by row

E.g. for 10 rows:
d = data.frame( x=rep(0, 10), y=rep(0,10), z=rep(0,10))

And in the loop (index i):

d[i, ] = c(x, y, z)


3) Build vectors first, dataframe after the loop

x = NULL
y = NULL
z = NULL

in the loop:

x = append(x, runif(1))
...

After loop:

d = data.frame(x, y, z)

Solutions 1&3 are slower but you don't need to know the final number of
rows in advance. Solution 2 is cleaner, in my opinion, but requires that
you know the final size.

Of course, for the particular example calculation you don't need a loop
at all:

x = runif(100)
y = x+1
z = x+y
d = data.frame(x,y,z)

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-8161-71 2131
Dept. of Genome Oriented Bioinformatics  Fax.  +49-8161-71 2186
Technical University of Munich
Science Center Weihenstephan
85350 Freising, Germany

 and

Institute for Bioinformatics / MIPS  Tel.  +49-89-3187 3675
GSF - National Research Center   Fax.  +49-89-3187 3585
  for Environment and Health
Ingolstädter Landstrasse 1
85764 Neuherberg, Germany
http://mips.gsf.de/staff/pagel

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] managing data

2006-06-17 Thread Philipp Pagel
On Sat, Jun 17, 2006 at 02:40:47PM +0100, yohannes alazar wrote:
> Dear mailing list, may some one be kind to help me solve following problem.
> 
> I am trying to write a code that will combine two tables "x" and "y". The
> first columns of both tables are unique identification for the rows. The
> first column of table "X" is a sub set of the first column of "Y". I need to
> find the matching rows in both tables by looking on their unique
> identification at the first columns.

?merge

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-8161-71 2131
Dept. of Genome Oriented Bioinformatics  Fax.  +49-8161-71 2186
Technical University of Munich
Science Center Weihenstephan
85350 Freising, Germany

 and

Institute for Bioinformatics / MIPS  Tel.  +49-89-3187 3675
GSF - National Research Center   Fax.  +49-89-3187 3585
  for Environment and Health
Ingolstädter Landstrasse 1
85764 Neuherberg, Germany
http://mips.gsf.de/staff/pagel

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] relative frequency plot

2006-04-27 Thread Philipp Pagel
On Thu, Apr 27, 2006 at 10:48:39AM -0700, [EMAIL PROTECTED] wrote:
> Hi All,
> 
> I want to use "hist" to get the relative frequency plot. But the range of
> ylab is greater than 1,which I think it should be less than 1 since it
> stands for the probability.
> 
> I'm confused. Could you please help me with it?

I was pretty confused by that, too at first. The solution is that
freq=False cause hist to plot the DENSITY rather than frequency. And
density is not necesssarily the same as relative frequency. Excerpt from
?hist:

 density: values f^(x[i]), as estimated density values. If
  'all(diff(breaks) == 1)', they are the relative frequencies
  'counts/n' and in general satisfy sum[i; f^(x[i])
  (b[i+1]-b[i])] = 1, where b[i] = 'breaks[i]'.

If you want relative distance try something like this:

myhist = hist(x,breaks=52, plot=F)
myhist$counts = myhist$counts / sum(myhist$counts)
plot(myhist,main=NULL,border=TRUE,xlab="days",xlim=c(0,6),lty=2)

Not exactly clean, though -- we are messing with the myhist object...


cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-8161-71 2131
Dept. of Genome Oriented Bioinformatics  Fax.  +49-8161-71 2186
Technical University of Munich
Science Center Weihenstephan
85350 Freising, Germany

 and

Institute for Bioinformatics / MIPS  Tel.  +49-89-3187 3675
GSF - National Research Center   Fax.  +49-89-3187 3585
  for Environment and Health
Ingolstädter Landstrasse 1
85764 Neuherberg, Germany
http://mips.gsf.de/staff/pagel

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] string vector indices

2006-04-16 Thread Philipp Pagel
On Sun, Apr 16, 2006 at 12:26:29AM -0400, Luke wrote:
> 
> x <- "a", "aab"
> y <- "a", "aa", "aab", "aabc".
> 
> Is there any R function to get the indices of y for the elements of x, that
> is, foo(x, y) will give me the index vector c(1, 3)?

match(x, y)

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-8161-71 2131
Dept. of Genome Oriented Bioinformatics  Fax.  +49-8161-71 2186
Technical University of Munich
Science Center Weihenstephan
85350 Freising, Germany

 and

Institute for Bioinformatics / MIPS  Tel.  +49-89-3187 3675
GSF - National Research Center   Fax.  +49-89-3187 3585
  for Environment and Health
Ingolstädter Landstrasse 1
85764 Neuherberg, Germany
http://mips.gsf.de/staff/pagel

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] simple if statement

2006-04-07 Thread Philipp Pagel
On Fri, Apr 07, 2006 at 09:55:47AM +0200, Philipp Pagel wrote:
> On Fri, Apr 07, 2006 at 02:58:00AM -0400, Brian Quinif wrote:
> > I tried this
> > years <- "Freshmen" if i==1
> > years <- "Sophomores" if i==2
> 
> What you are looking for is not an if clause but logical indexing:
> 
> years[years=="Freshmen"] <- 1
> years[years=="Sophomores"] <- 2
[...]


OK - I'll have to comment myself: I misread your message and it does not
make sense for you question.

Others have given good answers in the meantime...

cu
Philipp



-- 
Dr. Philipp PagelTel.  +49-8161-71 2131
Dept. of Genome Oriented Bioinformatics  Fax.  +49-8161-71 2186
Technical University of Munich
Science Center Weihenstephan
85350 Freising, Germany

 and

Institute for Bioinformatics / MIPS  Tel.  +49-89-3187 3675
GSF - National Research Center   Fax.  +49-89-3187 3585
  for Environment and Health
Ingolstädter Landstrasse 1
85764 Neuherberg, Germany
http://mips.gsf.de/staff/pagel

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] simple if statement

2006-04-07 Thread Philipp Pagel
On Fri, Apr 07, 2006 at 02:58:00AM -0400, Brian Quinif wrote:
> 
> I have data on college students.  I want to make a string variable
> that has the names of the years.  That is, when the year variable i is
> equal to 1, I want to have a variable called years equal to
> "Freshmen".
> 
> I tried this
> years <- "Freshmen" if i==1
> years <- "Sophomores" if i==2

What you are looking for is not an if clause but logical indexing:

years[years=="Freshmen"] <- 1
years[years=="Sophomores"] <- 2

Of course it's still a character vector so you will have to do

years = as.numeric(years)

Have a look at the manual (Introduciotn to R) for more details.

Another question is what you have in mind. To me it looks like what you
are trying to do is make a factor on your own. Maybe this is what you
want:

factor(years)

or maybe

factor(years, levels=c("Freshmen", "Sophomores"))

if you want more control over the coding.

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-8161-71 2131
Dept. of Genome Oriented Bioinformatics  Fax.  +49-8161-71 2186
Technical University of Munich
Science Center Weihenstephan
85350 Freising, Germany

 and

Institute for Bioinformatics / MIPS  Tel.  +49-89-3187 3675
GSF - National Research Center   Fax.  +49-89-3187 3585
  for Environment and Health
Ingolstädter Landstrasse 1
85764 Neuherberg, Germany
http://mips.gsf.de/staff/pagel

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] load file RData which store in zip file

2006-03-29 Thread Philipp Pagel
On Wed, Mar 29, 2006 at 11:44:03AM +0200, Muhammad Subianto wrote:
> How can I open/load "filename.zip"? Is there any function to open R
> workspace which it store in zip file?

I think you have two options:

1) use zip.file.extract() to unzip the file before loading

2) save your data with save.image(file="foo.RData", compress = True)

cu
    Philipp

-- 
Dr. Philipp PagelTel.  +49-8161-71 2131
Dept. of Genome Oriented Bioinformatics  Fax.  +49-8161-71 2186
Technical University of Munich
Science Center Weihenstephan
85350 Freising, Germany

 and

Institute for Bioinformatics / MIPS  Tel.  +49-89-3187 3675
GSF - National Research Center   Fax.  +49-89-3187 3585
  for Environment and Health
Ingolstädter Landstrasse 1
85764 Neuherberg, Germany
http://mips.gsf.de/staff/pagel

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Remove [1] ... from output

2006-03-28 Thread Philipp Pagel
On Tue, Mar 28, 2006 at 01:21:59PM +0200, Gregor Gorjanc wrote:
> 
> R> runif(20)
>  [1] 0.653574 0.164053 0.036031 0.127208 0.134274 0.103252 0.506480 0.547759
>  [9] 0.912421 0.584382 0.987208 0.996846 0.666760 0.053637 0.327590 0.370737
> [17] 0.505706 0.412316 0.887421 0.812151
> 
> Any hints how to solve my task?

The indexes are generated by the print method for the vector. Use cat
instead:

> cat(runif(20))
0.01053970 0.7196873 0.08709377 0.2059949 0.9583586 0.7059125 0.8179168
0.2345666 0.4157858 0.0538792 0.4140722 0.5700817 0.7087922 0.4012365
0.6587029 0.2803821 0.7353465 0.4457628 0.09914006 0.8109087

cu
    Philipp

-- 
Dr. Philipp PagelTel.  +49-8161-71 2131
Dept. of Genome Oriented Bioinformatics  Fax.  +49-8161-71 2186
Technical University of Munich
Science Center Weihenstephan
85350 Freising, Germany

 and

Institute for Bioinformatics / MIPS  Tel.  +49-89-3187 3675
GSF - National Research Center   Fax.  +49-89-3187 3585
  for Environment and Health
Ingolstädter Landstrasse 1
85764 Neuherberg, Germany
http://mips.gsf.de/staff/pagel

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] click on graph and select data points?

2006-03-15 Thread Philipp Pagel
> Now I want to select the best clustered class, how can I click on the data
> point, and the program returns the index of that cluster(its class number,
> or color number)?

Have a look at identify() 

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-8161-71 2131
Dept. of Genome Oriented Bioinformatics  Fax.  +49-8161-71 2186
Technical University of Munich
Science Center Weihenstephan
85350 Freising, Germany

 and

Institute for Bioinformatics / MIPS  Tel.  +49-89-3187 3675
GSF - National Research Center   Fax.  +49-89-3187 3585
  for Environment and Health
Ingolstädter Landstrasse 1
85764 Neuherberg, Germany
http://mips.gsf.de/staff/pagel

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] name of the graphics output

2006-03-14 Thread Philipp Pagel
On Tue, Mar 14, 2006 at 01:03:22PM +0100, Philipp Pagel wrote:
> On Tue, Mar 14, 2006 at 12:55:47PM +0100, Arnau Mir Torres wrote:
> 
> > All the outputs names are file.name.pdf but I want to put a different 
> > name for each graphic.
> 
> you can use paste() to put together the command:
> 
> file ="foo"
> system( paste("mv Rplots.pdf ", file,  ".name.pdf", sep='') )

Oops - of course it makes a lot more sense to put together the filename
when opening the pdf device:

pdf(file=paste(file, ".name.pdf", sep='') )


cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-8161-71 2131
Dept. of Genome Oriented Bioinformatics  Fax.  +49-8161-71 2186
Technical University of Munich
Science Center Weihenstephan
85350 Freising, Germany

 and

Institute for Bioinformatics / MIPS  Tel.  +49-89-3187 3675
GSF - National Research Center   Fax.  +49-89-3187 3585
  for Environment and Health
Ingolstädter Landstrasse 1
85764 Neuherberg, Germany
http://mips.gsf.de/staff/pagel

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] name of the graphics output

2006-03-14 Thread Philipp Pagel
On Tue, Mar 14, 2006 at 12:55:47PM +0100, Arnau Mir Torres wrote:

> All the outputs names are file.name.pdf but I want to put a different 
> name for each graphic.

you can use paste() to put together the command:

file ="foo"
system( paste("mv Rplots.pdf ", file,  ".name.pdf", sep='') )

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-8161-71 2131
Dept. of Genome Oriented Bioinformatics  Fax.  +49-8161-71 2186
Technical University of Munich
Science Center Weihenstephan
85350 Freising, Germany

 and

Institute for Bioinformatics / MIPS  Tel.  +49-89-3187 3675
GSF - National Research Center   Fax.  +49-89-3187 3585
  for Environment and Health
Ingolstädter Landstrasse 1
85764 Neuherberg, Germany
http://mips.gsf.de/staff/pagel

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] data import problem

2006-03-08 Thread Philipp Pagel
On Wed, Mar 08, 2006 at 12:49:29PM +0100, [EMAIL PROTECTED] wrote:
> Well, the data is generated by a perl script, and I could just
> configure the perl script so that there is one file per data table,
> but I though I'd probably must more efficent to have all records in a
> single file rather than reading a thousands of small files ... .

I guess I would make it a singe file and put the IDs in their own
column:

 ID x y
123   89.17911.1024
123   90.57351.1024
123   92.56661.1024
123   95.07251.1024
123  101.20701.1024
321   60.16011.1024
321   64.80231.1024
321   70.05932.1502
...

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-8161-71 2131
Dept. of Genome Oriented Bioinformatics  Fax.  +49-8161-71 2186
Technical University of Munich
Science Center Weihenstephan
85350 Freising, Germany

 and

Institute for Bioinformatics / MIPS  Tel.  +49-89-3187 3675
GSF - National Research Center   Fax.  +49-89-3187 3585
  for Environment and Health
Ingolstädter Landstrasse 1
85764 Neuherberg, Germany
http://mips.gsf.de/staff/pagel

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] data import problem

2006-03-08 Thread Philipp Pagel
On Wed, Mar 08, 2006 at 12:32:28PM +0100, [EMAIL PROTECTED] wrote:
> I'm trying to read a text data file that contains several records
> separated by a blank line. Each record starts with a row that contains
> it's ID and the number of rows for the records (two columns), then the
> data table itself, e.g. 
> 
> 123 5
> 89.17911.1024
> 90.57351.1024
> 92.56661.1024
> 95.07251.1024
> 101.20701.1024
> 
> 321 3
> 60.16011.1024
> 64.80231.1024
> 70.05932.1502

That sound like a job for awk. I think it will be much easier to
transform the data into a flat table using awk, python or perl an then
just read the table with R. 

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-8161-71 2131
Dept. of Genome Oriented Bioinformatics  Fax.  +49-8161-71 2186
Technical University of Munich
Science Center Weihenstephan
85350 Freising, Germany

 and

Institute for Bioinformatics / MIPS  Tel.  +49-89-3187 3675
GSF - National Research Center   Fax.  +49-89-3187 3585
  for Environment and Health
Ingolstädter Landstrasse 1
85764 Neuherberg, Germany
http://mips.gsf.de/staff/pagel

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Semi-log plot in R

2006-03-06 Thread Philipp Pagel
On Sun, Mar 05, 2006 at 12:00:19AM +, christophe tournayre wrote:
> Is it possible to create a semilog plot in R?

If you mean a plot with one log-scale axis this is what you want:

x = 1:100
y = x^2
plot(x,y, log="y")

See ?plot for details

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-8161-71 2131
Dept. of Genome Oriented Bioinformatics  Fax.  +49-8161-71 2186
Technical University of Munich
Science Center Weihenstephan
85350 Freising, Germany

 and

Institute for Bioinformatics / MIPS  Tel.  +49-89-3187 3675
GSF - National Research Center   Fax.  +49-89-3187 3585
  for Environment and Health
Ingolstädter Landstrasse 1
85764 Neuherberg, Germany
http://mips.gsf.de/staff/pagel

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] How to Import Data

2006-02-21 Thread Philipp Pagel
On Tue, Feb 21, 2006 at 08:52:04AM -0500, Carl Klarner wrote:

> x111 <-read.table(file='x111.csv',
> sep="",header=T,
> quote="",comment.char="",as.is=T)

to make things easier for you you could do

x111 <-read.table( file.choose(), ... )

Also: Why are you setting sep="" ? Your filename suggests that you have
some kind of separator in your file...

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-8161-71 2131
Dept. of Genome Oriented Bioinformatics  Fax.  +49-8161-71 2186
Technical University of Munich
Science Center Weihenstephan
85350 Freising, Germany

 and

Institute for Bioinformatics / MIPS  Tel.  +49-89-3187 3675
GSF - National Research Center   Fax.  +49-89-3187 3585
  for Environment and Health
Ingolstädter Landstrasse 1
85764 Neuherberg, Germany
http://mips.gsf.de/staff/pagel

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] random samples

2005-01-13 Thread Philipp Pagel
On Thu, Jan 13, 2005 at 01:50:38PM +0100, [EMAIL PROTECTED] wrote:

> I need to divide the array
> 
> > A<-c(1:200)
> 
>  into two subsets at random. Therefore I use the function "sample" in R:

I suggest a slightly different approach which is probably faster than
using setdif() or %in% and friends:

a <- 1:200
i <- sample(1:200, 100)
s1 <- a[i]
s2 <- a[-i]

cu
    Philipp

-- 
Dr. Philipp PagelTel.  +49-89-3187-3675
Institute for Bioinformatics / MIPS  Fax.  +49-89-3187-3585
GSF - National Research Center for Environment and Health
Ingolstaedter Landstrasse 1
85764 Neuherberg, Germany
http://mips.gsf.de/staff/pagel

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] multiple plots problem

2004-04-01 Thread Philipp Pagel

> for testing & learning purposes I create X11 device and specify layout like
> layout(c(1,2,3), 3, 1), so I could play with parameters and see
> several plots at the same time. That works fine until I try to create 4-th
> plot - all other plots erased.

That's expected behaviour: you asked for three plots to be present on
your canvas.

> Such behaviour isn't desirable for testing purposes and I'm asking
> where to look to disable erasing other plots.

Two possible solutions - depending on what exactly you'd like to get:

Increase the size of the layout matrix to squeeze more plots on the
canvas or open a new device whenever you want a new window.

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-89-3187-3675
Institute for Bioinformatics / MIPS  Fax.  +49-89-3187-3585
GSF - National Research Center for Environment and Health
Ingolstaedter Landstrasse 1
85764 Neuherberg, Germany
http://mips.gsf.de/~pagel

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Can R be useful to me?

2004-03-31 Thread Philipp Pagel
On Wed, Mar 31, 2004 at 08:32:49AM -0300, Luiz Rodrigo Tozzi wrote:
> 
> My question is: can I generate graphics and tables in gif ou any graphical 
> format through shell script?? can I call R, run a package in my ascii data e 
> then export the results to a gif, png or whatever?

Yes - R is well suited for such a task. Actually there even is a package
called sweave which allows you to use LaTeX to format your results and
create a perfectly fine report on the fly.

If you need to generate such reports on a regular basis R is definitely
a good way to appraoch the task.

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-89-3187-3675
Institute for Bioinformatics / MIPS  Fax.  +49-89-3187-3585
GSF - National Research Center for Environment and Health
Ingolstaedter Landstrasse 1
85764 Neuherberg, Germany
http://mips.gsf.de/~pagel

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Problems with postscript output

2004-03-24 Thread Philipp Pagel
Hi!

> I have a little problem with saving plots to file.  I use the command
> postscript() followed by the plotting command and a dev.off().
> 
> When I then look at the resulting image saved to disk, some of the
> axis labels are missing (see attached image). Is there a way to fix
> this. 

R is trying to be smart about labels getting too close/overlap. Specify the
graph to be a little wider and the labels will appear.

cu
    Philipp

-- 
Dr. Philipp PagelTel.  +49-89-3187-3675
Institute for Bioinformatics / MIPS  Fax.  +49-89-3187-3585
GSF - National Research Center for Environment and Health
Ingolstaedter Landstrasse 1
85764 Neuherberg, Germany
http://mips.gsf.de/~pagel

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Frequency table

2004-03-17 Thread Philipp Pagel

On Wed, Mar 17, 2004 at 04:55:19PM +0200, Kai Hendry wrote:
> I am trying to construct a frequency table. I guess this should be done with
> table. Or perhaps factor and split. Or prop.table. cut? findInterval? Argh!

> I got this far:
> > table(cut(zz$x9, brk))
> 
>  (40,50]  (50,60]  (60,70]  (70,80]  (80,90] (90,100]
>2   19   21   1981
> > brk
> [1]  40  50  60  70  80  90 100
> > 
> > t(table(cut(zz$x9, brk)))
>  (40,50] (50,60] (60,70] (70,80] (80,90] (90,100]
> [1,]  2  19  21  19   8   1
> 
> Still feels a million miles off.

Why? To me it looks like you figured it all out. You found out how to
use cut() to get the appropriate factor and you used table() to
compute the counts. Nothing wrong with that...

The only difference to what you wanted to get is that your example looked
more like a data frame. Try

as.data.frame(yourtable)

which will give you something like this:

> as.data.frame(tbl)
 b Freq
1   (0,20]   17
2  (20,40]   28
3  (40,60]   19
4  (60,80]   15
5 (80,100]   21

Is that what you wanted?

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-89-3187-3675
Institute for Bioinformatics / MIPS  Fax.  +49-89-3187-3585
GSF - National Research Center for Environment and Health
Ingolstaedter Landstrasse 1
85764 Neuherberg, Germany
http://mips.gsf.de/~pagel

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] saving a data.frame to "\t" files

2004-03-11 Thread Philipp Pagel
> could somebody please help with saving a data.frame with
> column names into "\t" text files for later importing in other
> programs? It seems an easy task, yet... it beats me.

write.table(mydf, file="foo.tbl", sep="\t", col.names=T)

Where mydf is your data frame.

If you don't want quoting you can also add 'quote=FALSE'

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-89-3187-3675
Institute for Bioinformatics / MIPS  Fax.  +49-89-3187-3585
GSF - National Research Center for Environment and Health
Ingolstaedter Landstrasse 1
85764 Neuherberg, Germany
http://mips.gsf.de/~pagel

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] recoding variables

2004-03-11 Thread Philipp Pagel

Hi!

> using R, and I'm trying to figure out how to recode a continuous
> variable to make it into an ordinal variable with 3 categories.

You are looking for cut():

> a <- runif(15)

> a
 [1] 0.19109987 0.78808597 0.78458256 0.31355035 0.02076274 0.82287287 0.75260382 
0.82627690 0.14775167
[10] 0.59427620 0.12314764 0.44151537 0.05123785 0.88879744 0.25552054

> b = cut(a, breaks=c(0, 0.33, 0.66, 1), labels=c('low', 'medium', 'high'))

> b
 [1] lowhigh   high   lowlowhigh   high   high   low medium lowmedium 
lowhigh   low
Levels: low medium high

cu
Philipp


-- 
Dr. Philipp PagelTel.  +49-89-3187-3675
Institute for Bioinformatics / MIPS  Fax.  +49-89-3187-3585
GSF - National Research Center for Environment and Health
Ingolstaedter Landstrasse 1
85764 Neuherberg, Germany
http://mips.gsf.de/~pagel

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Change the result data

2004-02-27 Thread Philipp Pagel

Using stack() would be a possibility:

> a <- stack(as.data.frame(hec.data))
> a$eye=rownames(hec.data)
> a
   values   ind   eye
1   5 Black Green
2  15 Black Hazel
3  20 Black  Blue
4  68 Black Brown
5  29 Brown Green
6  54 Brown Hazel
7  84 Brown  Blue
8 119 Brown Brown
9  14   Red Green
10 14   Red Hazel
11 17   Red  Blue
12 26   Red Brown
13 16 Blond Green
14 10 Blond Hazel
15 94 Blond  Blue
16  7 Blond Brown


Also have a look at reshape().

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-89-3187-3675
Institute for Bioinformatics / MIPS  Fax.  +49-89-3187-3585
GSF - National Research Center for Environment and Health
Ingolstaedter Landstrasse 1
85764 Neuherberg, Germany
http://mips.gsf.de/~pagel

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] interesting feature

2004-02-18 Thread Philipp Pagel
Hi!

On Wed, Feb 18, 2004 at 10:45:23AM -0600, Svetlana Eden wrote:
> > d <- rbind(d, add)
> > d
> x  y
> 1   1 99
> 2  10 55
> 11 14 99
> # it would be more natural to index the rows: 1,2,3 instead of
> #1,2,11  ?!

What you see in the first column are row-names not indexes. Since both
data frames had a row named '1' there was a conflict which R is trying
to resolve by appending '1'.

> # especially if index '11' is not functioning...
...
> # now I would think that the next index should be 21, BUT:
...
> # so what is the intuition of such indexing?

I think it all becomes clear if you try this:

> a <- data.frame(foo=1:5, bar=10:6, row.names=LETTERS[1:5])
> a
  foo bar
A   1  10
B   2   9
C   3   8
D   4   7
E   5   6
> b <- data.frame(foo=c(9,10), bar=c(99,98), row.names=c('A','B'))
> b
  foo bar
A   9  99
B  10  98
> rbind(a,b)
   foo bar
A1  10
B2   9
C3   8
D4   7
E5   6
A1   9  99
B1  10  98

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-89-3187-3675
Institute for Bioinformatics / MIPS  Fax.  +49-89-3187-3585
GSF - National Research Center for Environment and Health
Ingolstaedter Landstrasse 1
85764 Neuherberg, Germany
http://mips.gsf.de/~pagel

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Read In and Output Postscript file

2004-01-29 Thread Philipp Pagel
On Wed, Jan 28, 2004 at 05:31:11PM -0600, Marc Schwartz wrote:
> On Wed, 2004-01-28 at 14:19, Brad Holmes wrote:
> > 
> > Would it be possible to read in a pre-existing postscript file, and 
> > output it "as is" through R?
> > 
> > I have five plots, and I am placing them in a layout that is 2 X 3. I 
> > was hoping to "insert" the pre-existing postscript file made from 
> > Molscript in the last spot.
> 
> Your e-mail header suggests that you are on a Mac. If you have access to
> MS Word or an alternate document processing program like OpenOffice or a
> functional equivalent, you can import EPS files into a table, with each
> graphic going into a cell in the table. You can then "print" the
> document to a PS file, using a PS printer driver.
> 
> Others may have alternate ideas.

Yes: I'd recommend Illustrator rather than Word/OOo for this. 

But actually, the original question got me curious. How difficult would
it be to add EPS import to the postscript device? Other devices could
just ignore it or simply read the bounding box and insert the usual
empty box which says "EPS file". I guess I'll go for a litte walk in the
source code when I have a little spare time to burn. ;-)

I mean - this could be really usefull: Finally R would be capable of
producing the wealth of chartjunk other software has offered for
decades! Imagine using your corporate logo instead of boring circles or
dots for plotting! (OK ok - ouch - don't beat me, please...) ;-)


cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-89-3187-3675
Institute for Bioinformatics / MIPS  Fax.  +49-89-3187-3585
GSF - National Research Center for Environment and Health
Ingolstaedter Landstrasse 1
85764 Neuherberg, Germany

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Legend text -- discrepancy between X11 and postscript

2004-01-15 Thread Philipp Pagel
Hi!

On Wed, Jan 14, 2004 at 11:08:44PM -0800, Itay Furman wrote:
> When I place a legend on a plot it looks exactly as I intended
> on the screen. However, almost always, when I export this to 
> postscript file, the legend's text protrudes through the legend's 
> frame (the latter being placed correctly).

This routinely happens to me when using dev.copy2eps. If I use a
postscript device to begin with everything is fine.

cu
    Philipp

-- 
Dr. Philipp PagelTel.  +49-89-3187-3675
Institute for Bioinformatics / MIPS  Fax.  +49-89-3187-3585
GSF - National Research Center for Environment and Health
Ingolstaedter Landstrasse 1
85764 Neuherberg, Germany

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Easiest way to get the mean of a row of a data.frame?

2003-12-17 Thread Philipp Pagel
On Wed, Dec 17, 2003 at 08:27:41AM +0100, Sven C. Koehler wrote:
> I am kind of new to R.
> I would like to calculate the mean of the numbers of this expression:
> 
> data(USArrests)
> USArrests[row.names(M) == "Alabama",]
> 
> class() tells me it's a ``data.frame,'' what I actually desire is to get
> all numbers of a row as a vector or a list to let mean() calculate the mean
> of the whole row.  (I know this doesn't make sense with USArrests, I just
> used it here instead of my very own data.frame.)

rowMeans(USArrest)

does what you want.

In case you want to do soemthing else but compute the mean you will find
this handy:

apply(USArrests, 1, mean)

here you can substitute "mean" by whatever function you'd like to apply
to each row.

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-89-3187-3675
Institute for Bioinformatics / MIPS  Fax.  +49-89-3187-3585
GSF - National Research Center for Environment and Health
Ingolstaedter Landstrasse 1
85764 Neuherberg, Germany

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] incorporating R into C

2003-11-21 Thread Philipp Pagel
On Thu, Nov 20, 2003 at 02:38:35PM -0800, Amir Soofi wrote:
> I've become somewhat decent with R over the last month, and I feel
> confident that nothing online can help me with this question,

http://cran.r-project.org/doc/manuals/R-exts.pdf

is this online enough?

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-89-3187-3675
Institute for Bioinformatics / MIPS  Fax.  +49-89-3187-3585
GSF - National Research Center for Environment and Health
Ingolstaedter Landstrasse 1
85764 Neuherberg, Germany

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] reading data rows

2003-11-20 Thread Philipp Pagel

On Thu, Nov 20, 2003 at 10:21:49AM -0800, forkusam wrote:
>  I have problems reading a file with more than one row
> to carry out mathematical calculations 
> 
> I have a a file  of the form 
> mu1   mu2 alpha   betaWsigma sigmaA  b  r 
> 2515  .05 .05 22   3.3.5
> 3020  .1  .2  22  .3.3.5
> 
>  I intend to read one row , carry out the calculations
> and then the next row with which I intend to do the
> same calculations.

Although you can read the file line by line I guess you actually want to
read the whole table and then perform your calculations on the resulting
data frame.

> I do the following.
> p<-read.table(file="eingabe.csv", header=TRUE,sep=";")

Your file is not separated by ';'! From what you show above I guess it's
tab-separated - or maybe by variying numbers of spaces. Assuming tabs
this will read the entire file:

p <- read.table('eingabe.csv', header=T, sep='\t')


> data.frame(as.numeric(mu1<-p$mu1),as.numeric(mu2<-p$mu2),
> as.numeric(alpha<-p$alpha),as.numeric(beta<-p$beta),
> as.numeric(Wsigma<-p$Wsigma),as.numeric(sigmaA<-p$sigmaA),as.numeric(b<-p$b),as.numeric(r<-p$r))

I'm totally confused about this. First, p is already a data frame.
Second, the columns are already of type numeric or int after correctly
reading the file - so as.numeric is not needed here. You should
probably read 'An Introduction to R', especially the section on lists
and data frames and the one about reading data from files.

> I intend to use the variables stored in the the data
> frame for my caculations. but each time I try I get
> the  followingerror message.
> 
> Error in uniroot(function(n) eval(p.body) - power,
> c(2, 1e+07)) : 
> invalid function value in 'zeroin'
> In addition: Warning message: 
> the condition has length > 1 and only the first
> element will be used in: if (f(lower, ...) * f(upper,
> ...) >= 0) stop("f() values at end points not of
> opposite sign")
> 
> ...which I do not get when I use just one row.

Since you didn't say what calculation you were attempting I can't even
guess, what is going on. Maybe you can tell us what the goal of all this
is and what commands you were using ...

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-89-3187-3675
Institute for Bioinformatics / MIPS  Fax.  +49-89-3187-3585
GSF - National Research Center for Environment and Health
Ingolstaedter Landstrasse 1
85764 Neuherberg, Germany

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Find value in vector (or matrix)

2003-11-20 Thread Philipp Pagel
On Thu, Nov 20, 2003 at 01:26:23PM +0100, Pascal A. Niklaus wrote:
> Is there a function to check if a particular value is contained in a 
> vector?

> myvec <- c('foo','bar','duh','bonk')
> 'bonk' %in% myvec
[1] TRUE
> 'asdf' %in% myvec
[1] FALSE

> Also, is there a way to generate character sequences similar to numeric 
> sequences, e.g. something like "A":"J" ?

> LETTERS[1:5]
[1] "A" "B" "C" "D" "E"

> letters[c(8,9,12,23)]
[1] "h" "i" "l" "w"

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-89-3187-3675
Institute for Bioinformatics / MIPS  Fax.  +49-89-3187-3585
GSF - National Research Center for Environment and Health
Ingolstaedter Landstrasse 1
85764 Neuherberg, Germany

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] read.table(..)..Help?

2003-11-20 Thread Philipp Pagel
On Wed, Nov 19, 2003 at 11:11:27PM -0800, forkusam wrote:

> p<-read.table(file="FILENAME ", header=TRUE,sep=";")
> and later used the data.Frame() function.
> It functions when the file has only a row of
> variables.

It is not at all clear to me what you are doing and what is going wrong.
Please provide a (short) example of what exactly you do, what error
messages and warnings you get and what your input file looks like. 

BTW: read.table returns a data frame so I'm not sure what
you mean by using data.frame() later on. 

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-89-3187-3675
Institute for Bioinformatics / MIPS  Fax.  +49-89-3187-3585
GSF - National Research Center for Environment and Health
Ingolstaedter Landstrasse 1
85764 Neuherberg, Germany

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Running R-program as queue jobs

2003-11-13 Thread Philipp Pagel
Hi!

On Thu, Nov 13, 2003 at 09:59:48AM +, Arne Gjuvsland wrote:
> I have a problem with running my R programs as queue jobs. When I try
> to submit a batch file to the queue with qsub I get the following error
> message:
> 
> 
> /home/gjuvslan/kluster/R-1.7.1/bin/R.bin: error while loading shared
> libraries: 
> libpcre.so.0: cannot load shared object file: No such file or directory
> 
> 
> When executed from the command prompt the batch file does its job.

Did you run the script on the same machine in both cases? I got burnt a
couple of times with different machines running different versions of
the OS, non-identical versions of shared libraries etc...

cu
    Philipp

-- 
Dr. Philipp PagelTel.  +49-89-3187-3675
Institute for Bioinformatics / MIPS  Fax.  +49-89-3187-3585
GSF - National Research Center for Environment and Health
Ingolstaedter Landstrasse 1
85764 Neuherberg, Germany

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] postscript: font size in text(x,y,label)?

2003-11-12 Thread Philipp Pagel
Hi!

> I would like to just create my (point) labels [created by 
> text(x,y,labels)] in smaller font size, especially when I write out to 
> eps.  all other point sizes should not change.  is this possible?  help 

I don't know how to define the point size exactly (since ps=something
does not work in text()) but using the cex option is a workaround:

plot(1:100, (1:100)^2)
text(10,1000, "foo")
text(10,2000, "foo", cex=2)

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-89-3187-3675
Institute for Bioinformatics / MIPS  Fax.  +49-89-3187-3585
GSF - National Research Center for Environment and Health
Ingolstaedter Landstrasse 1
85764 Neuherberg, Germany

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] repeat until function

2003-11-12 Thread Philipp Pagel
> I what to generate N random numbers(integer) that are different from each 
> other.
> One suggestion:
> 
> tabel <- rep(NULL, N)
> for (i in 1:N){
>   temp <- as.integer(runif(1,1,max))
>   if(temp in tabel) {
>   repeat (?) (temp <- as.integer(runif(i,i,max)))
>   until (?) ((temp in tabel) ==FALSE)
>   }
>   else{ tabel[i] <- temp}
> 
> I can't use repeat/until - don't exist

repeat ... until loops can be rewritten as while loops.


The easiest way is this:

# n unique random numbers between min and max
sample(min:max, n)


But maybe you don't want to generate the array min:max for some reason
(because it is really large?). Then you can do the whole thing yourself:

# another way to the same result
left <- n
tab <- NULL
while (left > 0) {
new <- as.integer(runif(left, min, max))
tab <- unique(c(tab, new))
left <- n - length(tab) 
}

If max-min is really large and n is not much smaller than max-min you
may want to generate more numbers than you actually need so unique()
leaves you with more results and you don't have to iterate so often...

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-89-3187-3675
Institute for Bioinformatics / MIPS  Fax.  +49-89-3187-3585
GSF - National Research Center for Environment and Health
Ingolstaedter Landstrasse 1
85764 Neuherberg, Germany

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] (no subject)

2003-11-12 Thread Philipp Pagel

Hi!

> I got information on the shares of some subgroups over time (summing
> up to 1 in each year). The graph I want to create should display the
> development of the individual shares over time by shading rectangulars
> for each share in a different color.

Maybe I'm missing the point but this sounds like a pretty simple barplot
to me.

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-89-3187-3675
Institute for Bioinformatics / MIPS  Fax.  +49-89-3187-3585
GSF - National Research Center for Environment and Health
Ingolstaedter Landstrasse 1
85764 Neuherberg, Germany

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Barplots

2003-11-07 Thread Philipp Pagel
On Fri, Nov 07, 2003 at 03:16:13PM -0500, Suzanne E. Blatt wrote:
> Thanks for the suggestion below.  I did one of my figures and it
> worked perfectly.  I tried it on my second figure and got
> double-labelling on the first bar.  I used the same code to create
> both figures, and the same code to label.

Well, maybe you should use the x values returned by barplot (your
variable blocks) instead of computing x-positions yourself as I
originally suggested.

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-89-3187-3675
Institute for Bioinformatics / MIPS  Fax.  +49-89-3187-3585
GSF - National Research Center for Environment and Health
Ingolstaedter Landstrasse 1
85764 Neuherberg, Germany

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Barplots

2003-11-07 Thread Philipp Pagel
Hi!

On Fri, Nov 07, 2003 at 10:46:27AM -0500, Suzanne E. Blatt wrote:
> Can anyone tell me how to label individual bars on a barplot?  I want
> to put an "*" or letter ABOVE the bar to denote statistical
> significance.  Is this possible and how?

You can use text() to put arbitrary strings in your plot. So you only
need to add some offset to your y-values and work out the x-positions:

y <- c(10,12,15,8)
lab <- c('*','**','***','*')
barplot(y, ylim=c(0,20), space=0.5)
x <- (0:3*0.5)+1:4 
text(x, y+1, lab, adj=0.5)

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-89-3187-3675
Institute for Bioinformatics / MIPS  Fax.  +49-89-3187-3585
GSF - National Research Center for Environment and Health
Ingolstaedter Landstrasse 1
85764 Neuherberg, Germany

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Absolut newbie questions

2003-11-06 Thread Philipp Pagel
Hi!

> We have just measured dx and dt (d standing here for \Delta) on an inclined 
> plain and received some data thet are in two lists (x_list and t_list). The 
> theory says, that dx = a/2*(dt)^2 for a constant a.
> 
> I should like to fit the data against the theoretical prediction. This 
> should deliver an estimate for a.

You will find everyhing you want to know in the chapter on statistical
models in the manual "Introduction to R". Also look at the online
documentation for lm() and maybe nls().

> Then I should like to graph the data (as bullets) and the predicted 
> function into the same graph.

Have a look at the documentation for plot(), line() and predict(). 

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-89-3187-3675
Institute for Bioinformatics / MIPS  Fax.  +49-89-3187-3585
GSF - National Research Center for Environment and Health
Ingolstaedter Landstrasse 1
85764 Neuherberg, Germany

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] weighted rank correlation test?

2003-10-31 Thread Philipp Pagel

Hi R-gurus!

Is there a package that implements corr.test with weights, or will I
have to deal with this myself?

I found corr() from the boot package which will calculate r for me and I
could certainly do the ranking myself but it does not give me a
p-value...

Thanks for any hints.

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-89-3187-3675
Institute for Bioinformatics / MIPS  Fax.  +49-89-3187-3585
GSF - National Research Center for Environment and Health
Ingolstaedter Landstrasse 1
85764 Neuherberg, Germany

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Writing and running a R program

2003-10-23 Thread Philipp Pagel

On Thu, Oct 23, 2003 at 09:29:46AM -0400, Subramanian Karthikeyan wrote:
> Is there a way I can combine multiple lines of R commands (see below) into
> a little code snippet or a program in a text file, and run it in R to do my
> analysis?

It's quite easy: Write your R code with your favorite text editor and run
it in R using source().

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-89-3187-3675
Institute for Bioinformatics / MIPS  Fax.  +49-89-3187-3585
GSF - National Research Center for Environment and Health
Ingolstaedter Landstrasse 1
85764 Neuherberg, Germany

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] r-ish ? how can i improve my code?

2003-10-15 Thread Philipp Pagel
On Wed, Oct 15, 2003 at 10:06:36AM +0100, Sean O'Riordain wrote:


> n <- 900; # number of valid items required...
> 
> x <- numeric(n);
> y <- numeric(n);
> z <- numeric(n);
> 
> c <- 1;  # current 'array' pointer
> tc <- 0; # total items actually looked at...
> 
> while (c <= n) {
> x[c] = runif(1, 0, 1);
> y[c] = runif(1, 0, 1);
> 
> z[c] = sqrt(x[c]^2 + y[c]^2);
> if (z[c] < 1)
> c <- c + 1;
> tc <- tc + 1;
> }
> 
> print("'overwork' ratio");
> print(tc/(c-1));
> plot(x,y);


If I read this correctly you want to find the frequency of the event
"sqrt(x^2 + y^2) < 1" where 0 <= x, y <= 1  
right?

How about this:

n <- 1000
z <- sqrt(runif(n,0,1)^2 + runif(n,0,1)^2)
ratio <- (length(z)-1) / (length( z[z<1] ))

The main difference of course is that I uses a fixed number of "total
items" rather than "valid items". If that's a problem and you need
exactly 900 "valid items" things get a bit more complicated...

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-89-3187-3675
Institute for Bioinformatics / MIPS  Fax.  +49-89-3187-3585
GSF - National Research Center for Environment and Health
Ingolstaedter Landstrasse 1
85764 Neuherberg, Germany

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Getting rows from a dataframe

2003-10-10 Thread Philipp Pagel

> Sorry if this is a silly question. I'm trying to extract all elements
> of a dataframe at a particular row.

How about

df[12, ]

to get row number 12?

> I can find no mention of this in any documentation

You must have different documentation than me 
Subsetting is described on the first couple of pages of pretty much
every introducory manual.

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-89-3187-3675
Institute for Bioinformatics / MIPS  Fax.  +49-89-3187-3585
GSF - National Research Center for Environment and Health
Ingolstaedter Landstrasse 1
85764 Neuherberg, Germany

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] startup file and lambda

2003-10-09 Thread Philipp Pagel
On Thu, Oct 09, 2003 at 07:39:58AM -0700, christoff pale wrote:
> Hi,s there a .Rrc file? so that when R starts up
> it automatically loads this file?

?Startup

will tell you everything you want to know - especially bout the
.Rprofile file.

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-89-3187-3675
Institute for Bioinformatics / MIPS  Fax.  +49-89-3187-3585
GSF - National Research Center for Environment and Health
Ingolstaedter Landstrasse 1
85764 Neuherberg, Germany

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] data.frame with duplicated id's

2003-09-24 Thread Philipp Pagel
Hi!

> is there a exstisting function (..i found nothing until now.) 
> what makes it possible transfrom a dataset:
> 
> ID AGE V.MAI V.JUNE
> 11 20   100   120
> 12 30   200   90
> 
> into 
> 
> IDAGEV
> 1120   100 
> 1120   120
> 1230200
> 123090

I think reshape() will do what you want.

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-89-3187-3675
Institute for Bioinformatics / MIPS  Fax.  +49-89-3187-3585
GSF - National Research Center for Environment and Health
Ingolstaedter Landstrasse 1
85764 Neuherberg, Germany

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] extracting the levels of a subset of data

2003-09-19 Thread Philipp Pagel
Hi!

> > tmpdata<-subset(myd, TYPE=="A")
> > levels(tmpdata$TYPE)
> > [1] "A" "B" "C"
> 
> I'd like to get only "A" as output...

rebuild the factor after subsetting:

tmpdata$TYPE <- factor(tmp$TYPE)

If you want the levels of all factors in your data frame to be
adjusted you could also use:

tmpdata <- data.frame(as.matrix( subset(myd, TYPE=='A') ))

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-89-3187-3675
Institute for Bioinformatics / MIPS  Fax.  +49-89-3187-3585
GSF - National Research Center for Environment and Health
Ingolstaedter Landstrasse 1
85764 Neuherberg, Germany

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] How to convert a Rd file into multi html files?

2003-09-09 Thread Philipp Pagel

Hi!

On Tue, Sep 09, 2003 at 04:17:25AM -0700, Yiming Zhou wrote:
> The command I used was ' R
> CMD Rdconv -t html foo.Rd'. It just converted the document of first
> object in .Rd into html format.

I'm not exactly an expert in writing R documentation but while playing
arround with package building I initially had the same problem. By
looking at other peoples *.Rd files I discovered that you need to
separate individual sections of documentation by \eof. "Writing R
Extensions" doesn't seem to mention this, though.

hope it helps
Philipp

-- 
Dr. Philipp PagelTel.  +49-89-3187-3675
Institute for Bioinformatics / MIPS  Fax.  +49-89-3187-3585
GSF - National Research Center for Environment and Health
Ingolstaedter Landstrasse 1
85764 Neuherberg, Germany

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] big data file geting truncated

2003-08-14 Thread Philipp Pagel
Hi!

> I used the following commands
>  mydata<-read.table("dataALLAMLtrain.txt", header=TRUE, sep
> ="\t",row.names=NULL)
> It reads data without any error
> Now if I use
> edit(mydata)
> It shows only 3916 entries, whereas the actual file contains 7129 entries)
[...]
> So it seems R is truncating the data. How  can I load the complete file?

Others have already recommended checking the length of the data.frame
using dim() and the file using wc. If it turns out that there really is
a difference in size the next thing would be to get an idea what lines
are affected: Are "random" lines missing or is everything ok up to line
3916 and then it stops? In either case - have a close look at the lines
missing or the last line present plus the first one missing: Is there
anything special about them?

But actually I have a feeling that this may be your problem:

read.table uses both '"' and "'" for quoting by default. Gene
descriptions love to contain things like "5'" and "3'".
=> Try quote='' in the read.table call.

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-89-3187-3675
Institute for Bioinformatics / MIPS  Fax.  +49-89-3187-3585
GSF - National Research Center for Environment and Health
Ingolstaedter Landstrasse 1
85764 Neuherberg, Germany

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] hi

2003-07-28 Thread Philipp Pagel

Hi!

> I have no clue what i am doing/ meant to do with R. i have just begun
> statistics for uni and all commands don't seem to work, they say
> syntax error, we are meant to put a hist.r in but ?

I guess you should have a look at the manuals. You can find them at the
R-Project web site:

http://www.r-project.org

In addition to the official manuals I found the "Simple R" manual very
helpful. It's under contributed documentation.

cu
    Philipp

-- 
Dr. Philipp PagelTel.  +49-89-3187-3675
Institute for Bioinformatics / MIPS  Fax.  +49-89-3187-3585
GSF - National Research Center for Environment and Health
Ingolstaedter Landstrasse 1
85764 Neuherberg, Germany

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] bug plotting dates?

2003-07-26 Thread Philipp Pagel

Hello R-experts!

I am using R Version 1.7.1  (2003-06-16) on a Debian Linux box and I
have discovered an odd result when plotting data involving dates. Please
try this minimal example:

a = seq(ISOdate(2000,1,1), ISOdate(2001,1,1), "months")
b = 1:13
plot(a,b, col="red")

What I get is a plot that looks as expected except the x-axis is mostly
red. Can anyone reproduce this behaviour? I have tried the same thing on
R 1.6.0 on a machine in the institute and everything looked fine there
(i.e. axis is black). 

Also, if I set the ylim in the plot command:

plot(a,b, col="red", ylim=c(0,20))

R gives me a warning 'parameter "ylim" couldn't be set in high-level
plot() function' but sets the limit as requested, anyway.

Any ideas what I'm doing wrong? Is this a bug?

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-89-3187-3675
Institute for Bioinformatics / MIPS  Fax.  +49-89-3187-3585
GSF - National Research Center for Environment and Health
Ingolstaedter Landstrasse 1
85764 Neuherberg, Germany

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] convert factor to numeric

2003-06-04 Thread Philipp Pagel

Hi R-experts!

Every once in a while I need to convert a factor to a vector of numeric
values. as.numeric(myfactor) of course returns a nice numeric vector of
the indexes of the levels which is usually not what I had in mind:

> v <- c(25, 3.78, 16.5, 37, 109)
> f <- factor(v)
> f
[1] 25   3.78 16.5 37   109
Levels: 3.78 16.5 25 37 109
> as.numeric(f)
[1] 3 1 2 4 5
>

What I really want is a function "unfactor" that returns v:
> unfactor(f)
[1]  25.00   3.78  16.50  37.00 109.00

Of course I could use something like

> as.numeric(levels(f)[as.integer(f)])

But I just can't believe there is no R function to do this in a more
readable way. Actually, the behaviour of as.numeric() doesn't strike me
as very intuitive. I'm sure it has been implemented that way for a
reason - but what is it?

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-89-3187-3675
Institute for Bioinformatics / MIPS  Fax.  +49-89-3187-3585
GSF - National Research Center for Environment and Health
Ingolstaedter Landstrasse 1
85764 Neuherberg
Germany

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help