Re: [R] Can any one help me on format file data.

2007-07-18 Thread Earl F. Glynn

Horacio Castellini [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Hi all.
   I'd like know what is the format file saved by  Leica
 Microsystems TCS SP2-AOBS equipped with a SP2-FCS2 Leica Microsystems
 workstation its datas. Cause it save in *.fcs extention  file but
 ins't flow cytometry standart format file...

From a Google search for SP2-FCS2 Leica Microsystems I found this paper 
http://jcs.biologists.org/cgi/reprint/118/24/5825.pdf that talked about 
Fluorescence Correlation Spectroscopy (FCS) data.  Is is possible you have 
Fluorescence Correlation Spectroscopy (FCS) data instead of flow cytometry 
(FCS) data?  I've worked some with both types of FCS data.

I wrote a ConfoCor 3 Fluroescence Correlation Spectroscopy FCS viewer in R:
http://research.stowers-institute.org/efg/ScientificSoftware/Utility/FCSViewer/R.htm.
 
The software that reads that older Fluroescence Correlation Spectroscopy FCS 
data was in Delphi 
http://research.stowers-institute.org/efg/ScientificSoftware/Utility/FCSViewer/index.htm.
 
It would be a bit of a pain to read that older Fluroescence Correlation 
Spectroscopy FCS bit stream in R.   But it'slikely Leica's format is 
different than Zeiss.

I have also worked with some versions of flow cytometery FCS data (e.g., see 
http://research.stowers-institute.org/efg/ScientificSoftware/Utility/FCSExtract/index.htm).
 
There are different versions of that FCS standard too.

If you send me a small file, I'll see if I can recognize if it's a format 
I've seen.

efg

Earl F. Glynn
Scientific Programmer
Stowers Institute for Medical Research

__
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] Writing - specyfic format

2007-06-28 Thread Earl F. Glynn
jastar [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]

 Hi all,
 I have a trouble - I need to write file in a very specyfic format.
 I have two vectors which different lengths and one data.frame (or matrix).
 I want to write it to *.txt file in following way:
 1st row of file is my 1st vector (separate by spacebar)
 2nd row of file is 2nd vector (also separate by spacebar)
 Rest of this file should be a matrix with elements separated by tab.
 For example: a=1, 2, 3, b=4, 5, c=[1, 2, 3, 4, 5, 6;
7, 8, 9, 10, 11, 12,]
 and I want to have file (it have to be .txt file) like:
 1 2 3
 4 5
 1 2 3 4 5 6
 7 8 9 10   1112

 This thing have to be done automaticly from R.
 Is it possible?

Try this:

a - 1:3
b - 4:5
c - matrix(1:12, 2,6, byrow=TRUE)

outFile - file(SpecificFormat.txt, w)
cat(paste(a, sep= ), \n, file=outFile)
cat(paste(b, sep= ), \n, file=outFile)

for (j in 1:nrow(c))
{
  cat(paste(c[j,], collapse=\t), \n, file=outFile)
}

close(outFile)


Resulting output file (with spaces or tabs as specified):
1 2 3
4 5
1 2 3 4 5 6
7 8 9 10 11 12


[But I normally avoid tabs since you cannot see them easily with many 
editors.]

efg

Earl F. Glynn
Stowers Institute for Medical Research

__
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 Windows-like .INI files into R data structure?

2007-06-13 Thread Earl F. Glynn
[EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]...
 .Ini files are, for lack of a better description, ancient.

In this case a device is creating the INI files as part of an experiment, so 
the file format cannot be changed (at least easily).

I've looked at XML files from time to time and I'm amazed more don't 
complain how bloated, if not wasteful, they are.  I've seen XML files that 
were megabytes long when they held kilobytes worth of data.  INI files may 
be ancient, but they can be efficient and effective compared with XML.  In 
some cases, newer may not really be better (but newer may have the 
momentum behind it).


Gabor Grothendieck [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]...
 In thinking about this a bit more here is an even shorter solution where
 Lines.raw is as before:

 # Lines - readLines(myfile.ini)
 Lines - readLines(textConnection(Lines.raw))
 Lines2 - chartr([], ==, Lines)
 DF - read.table(textConnection(Lines2), as.is = TRUE, sep = =, fill = 
 TRUE)
 L - DF$V1 == 
 subset(transform(DF, V3 = V2[which(L)[cumsum(L)]])[1:3], V1 != )

Thanks for your helpful suggestions, Gabor.  Perhaps your zoo option is 
more elegant, but I try to use as few packages as possible, so this option 
seemed the best for me.

Since in my problem the structure of the INI sections is almost static and 
always present, I extended your example to create an in-memory list of 
everything in the INI file with this function:

# Prototype of how to read INI files to process olfactometer data
# efg, 13 June 2007
# Thanks to Gabor Grothendieck for helpful suggestions in the R-Help
# mailing list on how to parse the INI file.
Parse.INI - function(INI.filename)
{
  connection - file(INI.filename)
  Lines  - readLines(connection)
  close(connection)

  Lines - chartr([], ==, Lines)  # change section headers

  connection - textConnection(Lines)
  d - read.table(connection, as.is = TRUE, sep = =, fill = TRUE)
  close(connection)

  L - d$V1 == # location of section breaks
  d - subset(transform(d, V3 = V2[which(L)[cumsum(L)]])[1:3],
   V1 != )

  ToParse  - paste(INI.list$, d$V3, $,  d$V1,  - ',
d$V2, ', sep=)

  INI.list - list()
  eval(parse(text=ToParse))

  return(INI.list)
}


Here's an example of using the above function (I'll put the sample input 
file below):

INI1 - Parse.INI(sample.ini)

# Explore INI contents
summary(INI1)

INI1$SystemSetup$OlfactometerCode
INI1$DefaultLevels
unlist(INI1$DefaultLevels)
INI1$Map

INI1$Map$port1
as.integer( unlist( strsplit(INI1$Map$port1, ,) ) )

= = = = =
Sample output:

 INI1 - Parse.INI(sample.ini)

 # Explore INI contents
 summary(INI1)
  Length Class  Mode
SystemSetup   1  -none- list
Files 8  -none- list
DefaultLevels 4  -none- list
OdorNames 2  -none- list
Map   3  -none- list

 INI1$SystemSetup$OlfactometerCode
[1] 3
 INI1$DefaultLevels
$FC00
[1] 50

$FC01
[1] 100

$FC02
[1] 50

$FC10
[1] 50

 unlist(INI1$DefaultLevels)
 FC00  FC01  FC02  FC10
 50 100  50  50
 INI1$Map
$port0
[1] 0,0,0,0,0,0,0,0,0,0,0,0

$port1
[1] 0,0,0,0,0,0,0,0,0,0,0,0

$port2
[1] 0,0,0,0,0,0,0,0,0,0,0,0


 INI1$Map$port1
[1] 0,0,0,0,0,0,0,0,0,0,0,0
 as.integer( unlist( strsplit(INI1$Map$port1, ,) ) )
 [1] 0 0 0 0 0 0 0 0 0 0 0 0

= = = = =
Sample input file, sample.ini:

[SystemSetup]
OlfactometerCode=3
[Files]
prelog0=Part0.txt
date0=2:06:27.461 PM 6/9/2007
note0=group1-1
name0=group1
prelog1=Part1.txt
date1=2:09:16.809 PM 6/9/2007
note1=group1-1
name1=group1-1
[DefaultLevels]
FC00=50
FC01=100
FC02=50
FC10=50
[OdorNames]
port0=None
port1=None
[Map]
port0=0,0,0,0,0,0,0,0,0,0,0,0
port1=0,0,0,0,0,0,0,0,0,0,0,0
port2=0,0,0,0,0,0,0,0,0,0,0,0

= = = = =

Thanks again, Gabor!

efg

Earl F. Glynn
Scientific Programmer
Stowers Institute for Medical Research

__
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] Read Windows-like .INI files into R data structure?

2007-06-12 Thread Earl F. Glynn
I need to process some datasets where the configuration information was 
stored in .INI-like files, i.e., text files with sections like this:

[Section1]
var1=value1
var2=value2
[Section2]
A=value3
B=value4

...

From Google and other searches I haven't found any package, or function 
within a package, that reads .INI files into an R list, or other data 
structure.



Any suggestions, or do I need to write my own?

efg

Earl F. Glynn
Stowers Institute for Medical Research

__
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] Can strptime handle milliseconds or AM/PM?

2007-06-12 Thread Earl F. Glynn
I'm trying to proess date/time fields from files that were given to me to 
analyze.

Any clues what I'm doing wrong with strptime?   This seems to fail the same 
way under Linux or Windows.

 For ?strptime would it make sense to explain %OS3 somewhere besides the 
Examples?

 # Why does %OS3 work here?
 format(Sys.time(), %H:%M:%S)
[1] 16:45:19
 format(Sys.time(), %H:%M:%OS3)
[1] 16:45:19.477

 # Why doesn't %OS3 work here?
 EventLog.Start - 17:49:33.779
 strptime(EventLog.Start, %H:%M:%S)
[1] 2007-06-12 17:49:33
 strptime(EventLog.Start, %H:%M:%OS3)
[1] NA


 # This works OK without milliseconds or AM/PM
 x - c(5:49:33 6/9/2007, 5:49:36 6/9/2007, 5:49:37 6/9/2007)
 strptime(x, %I:%M:%S)   # unclear why this inserts today's date?
[1] 2007-06-12 05:49:33 2007-06-12 05:49:36 2007-06-12 05:49:37
 strptime(x, %I:%M:%S %m/%d/%Y)
[1] 2007-06-09 05:49:33 2007-06-09 05:49:36 2007-06-09 05:49:37


 # How to handle milliseconds and AM/PM?  Why doesn't this work?
 y - c(5:49:33.795 PM 6/9/2007, 5:49:36.184 PM 6/9/2007, 5:49:37.808 
 PM 6/9/2007)
 strptime(y, %I:%M:%S)   # works except for milliseconds but 
 wrong date
[1] 2007-06-12 05:49:33 2007-06-12 05:49:36 2007-06-12 05:49:37
 strptime(y, %I:%M:%OS3) # doesn't work
[1] NA NA NA
 strptime(y, %I:%M:%S %p %m/%d/%Y)   # AM/PM doesn't work
[1] NA NA NA
 strptime(y, %I:%M:%S %p %m/%d/%Y)   # AM/PM with dates doesn't work
[1] NA NA NA
 strptime(5:49:33 PM 6/9/2007, %I:%M:%S %p)  # doesn't get date right
[1] 2007-06-12 17:49:33

### Windows ###

 Sys.getlocale(category = LC_TIME)
[1] English_United States.1252
 R.version
   _
platform   i386-pc-mingw32
arch   i386
os mingw32
system i386, mingw32
status
major  2
minor  5.0
year   2007
month  04
day23
svn rev41293
language   R
version.string R version 2.5.0 (2007-04-23)


### Linux ###

 Sys.getlocale(category = LC_TIME)
[1] C
 R.version
   _
platform   x86_64-unknown-linux-gnu
arch   x86_64
os linux-gnu
system x86_64, linux-gnu
status
major  2
minor  4.1
year   2006
month  12
day18
svn rev40228
language   R
version.string R version 2.4.1 (2006-12-18)


efg

Earl F. Glynn
Stowers Institute for Medical Research

__
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] Venn diagram

2007-05-31 Thread Earl F. Glynn
I'm not sure where you're getting the venn package. I don't find venn in 
either of these places:

- http://cran.r-project.org/src/contrib/PACKAGES.html
- http://www.bioconductor.org/packages/release/Software.html

In case this helps, here are some notes about creating Venn Diagrams using 
the limma package:
http://research.stowers-institute.org/efg/R/Math/VennDiagram.htm

efg
Stowers Institute for Medical Research


Nina Hubner [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Hello,



 I am a total beginner with R and found a package venn to
 create a venn diagram.

 The problem is, I cannot create the vectors required for the diagram.

 The manual say:
 R venn(accession, libname, main = All samples)
 where accession was a vector containing the codes identifying
 the RNA sequences, and libname was a vector containing the codes
 identifying the tissue sample (library).


 The structure of my data is as follows:



 R   structure(list(cyto = c(A, B, C, D), nuc = c(A, B, E, 
 ),
 chrom = c(B, F, , )),.Names = c(cyto, Nuc, chrom))


 accession should be A, B, and libname schould be cyto,
 nuc and chrom as I understand it...


 Could you help me?



 Sorry, that might be a very simple question, but I am a total beginner
 as said before! The question has already been asked, but unfortunately
 there was no answer...



 Thank you a lot,

 Nina Hubner

 __
 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-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] Selecting complementary colours

2007-05-22 Thread Earl F. Glynn
John Fox [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]

 The object is to get contrasting colours, so that
 when one is plotted over the other, the two will be readily 
 distinguishable.

A simple approach to contrast is to compute a mean intensity by taking the 
mean of the three  RGB components (should be 0..255) and then going with 
either black or white -- whichever one  is farthest away.

Look at the Color Chart with contrasting numbers
http://research.stowers-institute.org/efg/R/Color/Chart/index.htm
or
http://research.stowers-institute.org/efg/R/Color/Chart/ColorChart.pdf

efg

Earl F. Glynn
Stowers Institute for Medical Research

__
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] Need 64-bit integers on 32-bit platform

2007-05-21 Thread Earl F. Glynn
I'm using the latest R on Windows XP:

 R.version
   _
platform   i386-pc-mingw32
arch   i386
os mingw32
system i386, mingw32
status
major  2
minor  5.0
year   2007
month  04
day23
svn rev41293
language   R
version.string R version 2.5.0 (2007-04-23)

I understand this:

 .Machine$integer.max
[1] 2147483647

 .Machine$sizeof.longlong
[1] 8

So how can I get a longlong (i.e., 64-bit = 8-byte integers) in my 
environment?  Where is there no storage.mode of longlong or int64?

I'm reading electrophysiology data with a time stamp that's in a 64-bit 
integer (it's a microsecond clock count) but I'm getting negative values 
returned in R:

# Why no warning if this call doesn't return an 8-byte integer?
TimeStamp   - readBin(connection, integer(), size=8,  1)
[1] -311761023
[1] -311756172

I can get the hex values of these numbers like this:

TimeStamp   - readBin(connection, raw(),   8)
[1] 81 e7 6a ed 01 00 00 00
[1] 74 fa 6a ed 01 00 00 00

I can see what these number should be by converting to decimal in Excel:
=HEX2DEC(01ed6ae781)
8278173569

=HEX2DEC(01ed6afa74)
8278178420

How can I get these 8-byte integers in R so I don't have to use this ugly 
kludge?

# KLUDGE
TimeStamp   - readBin(connection, integer(), size=4,  2)

 TimeStamp
[1] -311761023  1

# Convert integers to doubles since a double has larger range for integers 
than 32-bit integers:
storage.mode(TimeStamp) - double

# This seems to work, but is too ugly:
 TimeStamp[2]*2^32 + (2^32 + TimeStamp[1])
[1] 8278173569

Can anyone suggest a better way?

Thanks for any suggestions.

efg

Earl F. Glynn
Stowers Institute for Medical Research

__
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] Polar graph of time and tide

2007-05-01 Thread Earl F. Glynn
Alan E. Davis [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
I have been trying to visualize times of lowest tides, month by month.
 I have tide predictions with times either in unix time or a text
 format, and heights in feet or meters.  I had been able to derive the
 clock times of each prediction.   I would now like to graph this data
 with points showing heights as r and times as theta, from  to
 2355.  There is a seasonal component: I am interested in displaying
 times of lowest tides in particular.

Does this get you started?


library(plotrix)

theta - seq(0, 23.5, by=0.5)
r - runif(length(theta), 5, 10)

clock24.plot(r, theta, main=Polar Plot)

or

clock24.plot(r, theta, main=Polar Plot, rp.type=p)


efg
Stowers Institute for Medical Research

__
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] R News, volume 7, issue 1 is now available

2007-04-25 Thread Earl F. Glynn
Torsten Hothorn [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]

 The October 2006 issue of R News is now available on CRAN under the
 Documentation/Newsletter link.

Direct links are useful:

R News
http://cran.r-project.org/doc/Rnews/

April 2007 Issue:
http://cran.r-project.org/doc/Rnews/Rnews_2007-1.pdf

efg

__
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] graphs superimposed on pictures?

2007-04-11 Thread Earl F. Glynn
This example isn't quite what you're asking for, but perhaps it's a starting 
point:
http://addictedtor.free.fr/misc/gabor/

Earl F. Glynn
Stowers Institute

Robert Biddle [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 I am doing some work that involves plotting points of interest
 superimposed on photographs and maps. I can produce the plots fine in R, 
 but so far
 I have had to do the superimposition externally, which makes it tedious to 
 do exploratory work.
 I have looked to see if there is some capability to put a background 
 picture on a plot window,
 but I have not found anything.
 Advice, anyone?

__
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] Gaussian Adaptive Quadrature

2007-03-21 Thread Earl F. Glynn
Ravi Varadhan [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 The terminology Gaussian quadrature is not restricted to Gauss-Hermite
 quadrature (where exp(-x^2) is the weight function), but applies more
 broadly to Gauss-Legendre, Gauss-Laguerre, etc., where the abscissa are
 chosen from Legendre, Laguerre polynomials.

Also, the functional form of the integrand and limits of integration vary a 
bit with the different Gaussian Quadrature methods.  With Gaussian 
Quadrature the integral from a to b of f(x) dx is approximated as the sum of 
certain weights multiplied by the function evaluated at certain points 
related to the roots of the orthogonal polynomials.

Gauss-Legendre is perhaps the most general, since it works well with most 
functions over a fixed, finite, interval, normally [-1,1].  The Legendre 
polynomials are orthogonal on the interval [-1,1] with respect to a 
weighting function w(x) = 1.  A simple transformation allows the integration 
interval to be any finite interval, [a,b].

Gauss-Laguerre assumes a weighting function w(x) = exp(-x) in the integrand, 
and an interval of integration from 0 to infinity.

Gauss-Hermite assumes a weighting function w(x) = exp(-x^2) in the 
integrand, and an interval of integration from -infinity to infinity.

Applied Numerical Methods by Carnahan et al provides good details and 
examples (but in FORTRAN).


One adaptive approach that can be used with Gaussian Quadrature is to use 
a different number of  terms to evaluate the integral.  To save computation 
time, you can use fewer terms.  This file gives the weights needed for 
various N-point Gauss-Legendre quadrature approximation:
http://www.math.ntnu.no/num/nnm/Program/Numlibc/gauss_co.c

Some years ago on a project we found that 2-point Gaussian Quadrature gave 
us an answer that was good enough, and obviously was quite fast with so 
few function evaluations.  For your problem you might try 2-point to 
15-point quadrature to see if you get the desired accuracy.   I've always 
used pre-computed polynomial roots and weights for the various N-point 
formulas.  I'm not sure how gauss.quad in library(statmod) gets these 
values. It wasn't obvious to me from a quick look at the source code.

Another  adaptive Gaussian approach might break a single integral up into 
a number of other integrals.  One could even use different N-point formulas 
over different intervals, using lower N for smoother areas, and larger N 
if a function wasn't so well-behaved.

Some other good links:

Gauss-Legendre Quadrature
http://math.fullerton.edu/mathews/n2003/gaussianquad/GaussianQuadBib/Links/GaussianQuadBib_lnk_1.html
http://mathworld.wolfram.com/Legendre-GaussQuadrature.html

efg

Earl F. Glynn
Scientific Programmer
Stowers Institute for Medical Research

__
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] Deconvolution of a spectrum

2007-03-09 Thread Earl F. Glynn
Lukasz Komsta [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 I have a curve which is a mixture of Gaussian curves (for example UV
 emission or absorption spectrum). Do you have any suggestions how to
 implement searching for optimal set of Gaussian peaks to fit the curve?
 I know that it is very complex problem, but maybe it is a possibility
 to do it? First supposement is to use a nls() with very large functions,
 and compare AIC value, but it is very difficult to suggest any starting
 points for algotirithm.

Perhaps these notes will be helpful if you don't have too much noise in your 
data:
http://research.stowers-institute.org/efg/R/Statistics/MixturesOfDistributions/index.htm

efg

Earl F. Glynn
Stowers Institute for Medical Research

__
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] ordered matrix question

2007-02-27 Thread Earl F. Glynn
Juan Pablo Fededa [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Hi all,

 Is there an easy way to generate an object wich will be the same matrix, 
 but
 ordered by de cfp value?

Does this help?

 RawData - BlockXYcfpyfpID
+ 0524244213.417957.184821091
+ 055627065.3839049.5683726612
+ 052831640.7894745.5737321753
+ 0642432135.8173412.401344274
+ 071643034.3591353.9449230775
+ 0894362109.631583.1971603166
+ 095813063.984523.3964520047
+ 05069283.5139319.1054968568
+ 047646491.6749199.1780894149
+ 036442644.139322.06833436410
 d - read.table(textConnection(RawData), header=TRUE)

 d.ordered - data.matrix( d[order(d$cfp),] )

 d.ordered
   Block   X   Y   cfp   yfp ID
5  0 716 430  34.35914  3.944923  5
3  0 528 316  40.78947  5.573732  3
10 0 364 426  44.13932  2.068334 10
7  0 958 130  63.98452  3.396452  7
2  0 556 270  65.38390  9.568373  2
8  0 506  92  83.51393  9.105497  8
9  0 476 464  91.67492  9.178089  9
6  0 894 362 109.63158  3.197160  6
4  0 642 432 135.81734 12.401344  4
1  0 524 244 213.41795  7.184821  1


efg

Earl F. Glynn
Stowers Institute for Medical Research

__
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] mixture of 2 normals - starting values

2007-02-23 Thread Earl F. Glynn
If you don't have too much noise, the peaks in the derivative curves can be 
used:

See:

http://research.stowers-institute.org/efg/R/Statistics/MixturesOfDistributions/index.htm

efg
Earl F. Glynn
Scientific Programmer
Stowers Institute for Medical Research

[EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Hi,

 I have a problem of estimating a mixture of two normal distributions.  I
 need to find the starting points automatically, since this is a part of a
 larger piece of image processing code.

__
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] Suggestion about R equivalent of Splus peaks() function

2007-02-08 Thread Earl F. Glynn
In 2004 there was this R-Help posting from Jan 2004:

http://finzi.psych.upenn.edu/R/Rhelp02a/archive/33097.html
R equivalent of Splus peaks() function?

The peaks function there has worked well for me on a couple of projects, but 
some code using peaks failed today, which had worked fine in the past.

I was looking for a peak in a test case that was a sine curve over one 
cycle, so there should have been only one peak.  My unexpected surprise was 
to sometimes get one peak, or two adjoining peaks (a tie), but the no peaks 
case cause subsequent code to fail.  I wanted to eliminate this no peak 
case when there was an obvious peak.

I thought it was odd that the peak failure could be controlled by the random 
number seed.

# R equivalent of Splus peaks() function
# http://finzi.psych.upenn.edu/R/Rhelp02a/archive/33097.html

peaks - function(series,span=3)
{
  z - embed(series, span)
  s - span%/%2
  v - max.col(z) == 1 + s
  result - c(rep(FALSE,s),v)
  result - result[1:(length(result)-s)]
  result
}

 set.seed(19)
 peaks(c(1,4,4,1,6,1,5,1,1),3)
[1] FALSE  TRUE FALSE FALSE  TRUE FALSE  TRUE
 peaks(c(1,4,4,1,6,1,5,1,1),3)
[1] FALSE  TRUE FALSE FALSE  TRUE FALSE  TRUE
 peaks(c(1,4,4,1,6,1,5,1,1),3)
[1] FALSE  TRUE  TRUE FALSE  TRUE FALSE  TRUE
 peaks(c(1,4,4,1,6,1,5,1,1),3)
[1] FALSE FALSE FALSE FALSE  TRUE FALSE  TRUE
 peaks(c(1,4,4,1,6,1,5,1,1),3)
[1] FALSE FALSE  TRUE FALSE  TRUE FALSE  TRUE


Above, the 4 peak at positions 2 and 3 is shown by the TRUE and FALSE in 
positions 2 and 3 above.  Case 4 of FALSE, FALSE was most unexpected -- no 
peak.


I studied the peaks code and found the problem seems to be in max.col:
 z
 [,1] [,2] [,3]
[1,]441
[2,]144
[3,]614
[4,]161
[5,]516
[6,]151
[7,]115

 max.col(z)
[1] 2 3 1 2 3 2 3
 max.col(z)
[1] 2 2 1 2 3 2 3
 max.col(z)
[1] 1 2 1 2 3 2 3
 max.col(z)
[1] 2 2 1 2 3 2 3
 max.col(z)
[1] 1 3 1 2 3 2 3
 max.col(z)
[1] 2 2 1 2 3 2 3

The ?max.col help shows that it has a ties.method that defaults to random. 
I want a peak, any peak if there is a tie, but I don't want the case that a 
tie is treated as no peak.  For now, I added a first parameter to 
max.col in peaks:

# Break ties by using first

peaks - function(series,span=3)
{
  z - embed(series, span)
  s - span%/%2
  v - max.col(z, first) == 1 + s
  result - c(rep(FALSE,s),v)
  result - result[1:(length(result)-s)]
  result
}

A better solution might be a ties.method parameter to peaks, which can be 
passed to max.col.

I did all of this in R 2.4.1, but the problem seems to be in earlier 
versions too.

Just in case anyone else is using this peaks function.

efg

Earl F. Glynn
Stowers Institute for Medical Research

__
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] Simple spectral analysis

2007-01-09 Thread Earl F. Glynn
Georg Hoermann [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Peter Dalgaard wrote:
 Earl F. Glynn wrote:

 Thanks a lot for the help. I will post the script when its ready
 (an introduction for our biology students to time series, just 8 hours)

I've been working with one of our labs here to find cyclic genes from 
microarray data.  The supplement for the paper we published is here (I 
haven't bothered making the code general enough for a package yet):

http://research.stowers-institute.org/efg/2005/LombScargle/index.htm



Normally we only have about 20 to 50 points in our time series for each 
gene.  With missing data a problem, I used a Lomb-Scargle approach to find 
the periodicity.  With Fourier analysis, one must impute any missing data 
points, but with Lomb-Scargle you just process the data you have without any 
imputation.



Perhaps you or your students would be interested in the Numerical 
Experiments on this page 
http://research.stowers-institute.org/efg/2005/LombScargle/supplement/NumericalExperiments/index.htm



I was curious how well the Lomb-Scargle technique would work with your 
data -- see the R code below.   Normally the Lomb-Scargle periodogram shows 
a single peak when there is a single dominant frequency.  The Peak 
Significance curve for all your data is a difficult to interpret, and I'm 
not sure the statistical tests are valid (without some tweaks) for your size 
dataset.



I took a random sample of 50 of your ~3000 data points and analyzed those --  
see the second code block below.  [For 50 data points I know all the 
assumptions are good enough for the statistics being computed.]  The 
periodogram here shows a single peak for period 365.6 days, which has good 
statistical significance.  Other subset samples can show harmonic 
frequencies, sometimes.





# efg, 9 Jan 2007

air = read.csv(http://www.hydrology.uni-kiel.de/~schorsch/air_temp.csv;)
#air - read.csv(air_temp.csv)

TempAirC - air$T_air
Time - as.Date(air$Date, %d.%m.%Y)
N - length(Time)

# Lomb-Scargle code
source(http://research.stowers-institute.org/efg/2005/LombScargle/R/LombScargle.R;)
MAXSPD - 1500
unit - day
M - N# Usually use factor of 2 or 4, but with large N use 1 instead

# Look at test frequencies corresponding to periods of 200 days to 500 days: 
f = 1/T
TestFrequencies - (1/500) + (1/200 - 1/500) * (1:M / M)

# Use Horne  Baliunas' estimate of independent frequencies
Nindependent - NHorneBaliunas(length(Time))  # valid for this size?

# Fairly slow with this large dataset

ComputeAndPlotLombScargle(as.numeric(Time), TempAirC,
  TestFrequencies, Nindependent,
  Air Temperature [C])





# Could get good results with fewer points too, say 50 chosen at random

MAXSPD - 25
TempAirC - air$T_air
Time - as.Date(air$Date, %d.%m.%Y)

set.seed(19)  # For reproducible results
RandomSet - sample(1:length(Time), 50)
TempAirC - TempAirC[RandomSet]
Time -Time[RandomSet]

N - length(Time)
M - 4 * N# Usually use factor of 2 or 4

# Look at test frequencies corresponding to periods of 200 days to 500 days: 
f = 1/T
TestFrequencies - (1/500) + (1/200 - 1/500) * (1:M / M)

# Use Horne  Baliunas' estimate of independent frequencies
Nindependent - NHorneBaliunas(length(Time))

# Very fast to compute for only 50 points

ComputeAndPlotLombScargle(as.numeric(Time), TempAirC,
  TestFrequencies, Nindependent,
  Air Temperature [C])





efg



Earl F. Glynn

Scientific Programmer

Stowers Institute

__
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] listing all functions in R

2007-01-09 Thread Earl F. Glynn
Seth Falcon [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Are you sure you need to?  I just tried your code above with:

 pkgs - c(Biobase, GOstats, flrblr, bazbaz)

 And while I see warning messages about the flrblr and bazbaz packages,
 the function completed and I get the expected results in z.

 Oh, perhaps you have some broken installs?  Broken in the sense that
 you have a package installed but not its dependencies?

I installed all known CRAN packages after installing R 2.4.1 last week on a 
PC.  Perhaps some new consistency checks checks could be be made to catch 
such dependency problems?


 How about this:

 safeRequire - function(x) {
tryCatch(require(x, character.only=TRUE),
 error=function(e) FALSE)
 }

Thanks.  That's a much better function.

But if your process a lot of packages, even with just safeRequire (or 
findfuns), the search() path grows quite long, and things break, so it's not 
really possible to get a list of all functions in R if you have all packages 
installed.

Consider:

pkgs - dir(.Library)

length(pkgs)#957

length( search() )  # 9

# First 100 Packages
set1 - lapply(pkgs[1:100], safeRequire)
pkgs[which(!unlist(set1))]
#[1] bcp cairoDevice caMassClass
length( search() )  # 135

safeRequire(bcp)


Loading required package: bcp
Loading required package: DNAcopy
Warning in library(pkg, character.only = TRUE, logical = TRUE, lib.loc = 
lib.loc) :
 there is no package called 'DNAcopy'
[1] FALSE



In the 2nd 100 many packages seem to be affected by the Maximal number of 
DLLs reached...

I didn't bother trying to process packages 201 through 957.

efg

Earl F. Glynn
Scientific Programmer
Bioinformatics
Stowers Institute for Medical Research

__
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] listing all functions in R

2007-01-08 Thread Earl F. Glynn
Prof Brian Ripley [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Here is a reasonable shot:

 findfuns - function(x) {
 if(require(x, character.only=TRUE)) {
env - paste(package, x, sep=:)
nm - ls(env, all=TRUE)
nm[unlist(lapply(nm, function(n) exists(n, where=env,
   mode=function,
   inherits=FALSE)))]
 } else character(0)
 }
 pkgs - dir(.Library)
 z -  lapply(pkgs, findfuns)
 names(z) - pkgs

Any recommendations on how to trap problems with require when using 
findfuns?  One bad package and the lapply above doesn't return anything.

For example:

 findfuns(bcp)
Loading required package: bcp
Loading required package: DNAcopy
Error: package 'DNAcopy' could not be loaded
In addition: Warning message:
there is no package called 'DNAcopy' in: library(pkg, character.only = TRUE, 
logical = TRUE, lib.loc = lib.loc)

 require(bcp, character.only=TRUE)
Loading required package: bcp
Loading required package: DNAcopy
Error: package 'DNAcopy' could not be loaded
In addition: Warning message:
there is no package called 'DNAcopy' in: library(pkg, character.only = TRUE, 
logical = TRUE, lib.loc = lib.loc)


I used try around the require call with options(error=recover) with 
recover defined to be a do nothing function to avoid the stop, but then 
there were other problems (e.g., unable to load shared library ... 
LoadLibrary Failure: The specified module could not be found and Maximal 
number of DLLs reached)

Besides bcp I saw problems with other packages, e.g., cairoDevice, 
caMassClass, ... several others.

I'm using R 2.4.1with all CRAN packages installed that existed last week and 
at least several Bioconductor packages installed by the biocLite procedure.

FWIW:
 length(pkgs)
[1] 957


Thanks for any suggestions.

efg

Earl F. Glynn
Scientific Programmer
Stower Institute

__
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] Simple spectral analysis

2007-01-08 Thread Earl F. Glynn
Georg Hoermann [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 The data set:

 air = read.csv(http://www.hydrology.uni-kiel.de/~schorsch/air_temp.csv;)
 airtemp = ts(T_air, start=c(1989,1), freq = 365)
 plot(airtemp)

Maybe this will get you started using fft or spectrum -- I'm not sure why 
the spectrum answer is only close:

air = read.csv(http://www.hydrology.uni-kiel.de/~schorsch/air_temp.csv;)

TempAirC - air$T_air
Time - as.Date(air$Date, %d.%m.%Y)
N - length(Time)

oldpar - par(mfrow=c(4,1))
plot(TempAirC ~ Time)

# Using fft
transform - fft(TempAirC)

# Extract DC component from transform
dc - Mod(transform[1])/N

periodogram - round( Mod(transform)^2/N, 3)

# Drop first element, which is the mean
periodogram - periodogram[-1]

# keep first half up to Nyquist limit
periodogram - periodogram[1:(N/2)]

# Approximate number of data points in single cycle:
print( N / which(max(periodogram) == periodogram) )

# plot spectrum against Fourier Frequency index
plot(periodogram, col=red, type=o,
 xlab=Fourier Frequency Index, xlim=c(0,25),
 ylab=Periodogram,
 main=Periodogram derived from 'fft')

# Using spectrum
s - spectrum(TempAirC, taper=0, detrend=FALSE, col=red,
  main=Spectral Density)

plot(log(s$spec) ~ s$freq, col=red, type=o,
 xlab=Fourier Frequency, xlim=c(0.0, 0.005),
 ylab=Log(Periodogram),
 main=Periodogram from 'spectrum')

cat(Max frequency\n)
maxfreq - s$freq[ which(max(s$spec) == s$spec) ]

# Period will be 1/frequency:
cat(Corresponding period\n)
print(1/maxfreq)

par(oldpar)



efg

Earl F. Glynn
Scientific Programmer
Stowers Institute

__
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] setting new working directories

2007-01-04 Thread Earl F. Glynn
Bill,

I like to use Windows Explorer to find folders and then launch R with the 
selected folder as the working directory.

I put some notes online about this:
http://research.stowers-institute.org/efg/R/TechNote/WindowsExplorerWorkingDirectory/index.htm

efg

Bill Shipley [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Hello, and Happy New Year.  My default working directory is getting very
 cluttered.  I know that I should be using a different working directory 
 for
 each project (I work in Windows), but do not know how to go about creating
 different ones and moving back and forth between them.

__
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] counties in different colours using map()

2006-12-27 Thread Earl F. Glynn
The following example shows how to get/display the county names:

library(maps)

# Get County Data
m - map('county', 'colorado', plot=FALSE)
names(m)
m$names   # State,County names

# The names appear to be in alphabetical order by state, e.g.:
 m$names[1:3]
[1] colorado,adamscolorado,alamosa  colorado,arapahoe

# Show county names on map
map.text('county', 'colorado', proj='bonne', param=45)

# Show county indices on map
map.text('county', 'colorado', proj='bonne', param=45, 
labels=paste(1:length(m$names)))

#or perhaps
map.text('county', 'colorado', proj='bonne', param=45, 
labels=paste(1:length(m$names)), col=1:length(m$names))


You can use your own labels vector above to show county abbreviations 
instead of full names, or other info, if desired.

Once you get the mapping of the counties, you can connect to other sources 
of information.

efg

Tord Snäll [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
Hi,
I would like to plot a map of US counties using different colors. map()
seems to be the function to use, e.g.
library(maps); map('usa'); map('county', 'colorado', add=T,fill = T,
col=c(1:5))
plots Colorado counties using colours 1 to 5.

However, I want each color to represent a certain value - a value to be
picked from a data frame.
This code should show a correspoding map at the level of states:
state.names - system('tr [A-Z] [a-z]', state.name)
map.states - unix('sed s/:.*//', map(names=T,plot=F))
state.to.map - match(map.states, state.names)
color- votes.repub[state.to.map, votes.year = 1900] / 100
map('state', fill=T, col=color); map('state', add=T)
It is copied from page 6 in
Richard A. Becker, and Allan R. Wilks, Maps in S, ATT Bell
Laboratories Statistics Research Report [93.2], 1993.
http://public.research.att.com/areas/stat/doc/93.2.ps

I also wonder whether the county names are available in the database
used by map(), and, if yes, how to extract or utilize them.

Thanks!

Tord

__
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] set up directory for R when I start R

2006-12-13 Thread Earl F. Glynn
Duncan Murdoch [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 On 12/11/2006 2:21 PM, Earl F. Glynn wrote:
 Dieter Menne [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
 Aimin Yan aiminy at iastate.edu writes:

 I want to set default directory for R when I start R.
 How to do this?

 In Windows, I prefer the method described in

 http://tolstoy.newcastle.edu.au/R/help/00b/2454.html

If R version-specific registry keys are used, one can even select from 
multiple versions of R by right clicking on a directory from Windows 
Explorer:

To add key for R 2.4.0:

R2.4.0.reg  (delete the proxy part if not needed)
-
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Folder\shell\R 2.4.0]

[HKEY_CLASSES_ROOT\Folder\shell\R 2.4.0\command]
@=C:\\Program Files\\R\\R-2.4.0\\bin\\Rgui.exe 
http_proxy=http://proxy01:8080 http_proxy_user=ask
-


To delete this key:

R2.4.0-Delete.reg
-
Windows Registry Editor Version 5.00

[-HKEY_CLASSES_ROOT\Folder\shell\R 2.4.0]
-

These files can be edited with Windows Notepad and modified for other 
versions.

efg

 Earl F. Glynn
Bioinformatics
Stowers Institute for Medical Research

__
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] set up directory for R when I start R

2006-12-11 Thread Earl F. Glynn
Dieter Menne [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Aimin Yan aiminy at iastate.edu writes:


 I want to set default directory for R when I start R.
 How to do this?

 ?setwd

 In Windows, I prefer the method described in

 http://tolstoy.newcastle.edu.au/R/help/00b/2454.html

I learned a similar trick by using Regedit to set the registry keys 
directly.  (Years ago someone showed me this trick to start a DOS session). 
Apparently, either \Directory\shell or \Folder\shell do the same thing. 
Do you know if there is a difference?

I checked and your suggestion can be modified to even specify a http_proxy, 
if needed:

For example, this works for me under Windows XP, including the proxy server, 
from any directory chosen using Windows Explorer:


Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Folder\shell\R\command]
@=C:\\Program Files\\R\\R-2.4.0\\bin\\Rgui.exe 
http_proxy=http://proxy01:8080 http_proxy_user=ask
---

The above was the exported registry key from what I set manually using 
RegEdit. I used simply R instead of Run R, like you suggested.


efg

Earl F. Glynn
Bioinformatics
Stowers Institute for Medical Research

__
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] Calling R functions in Delphi

2006-12-06 Thread Earl F. Glynn
Thanks for the great example, Tom.

Tom Backer Johnsen [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Anna Belova wrote:

 We would like to call quantile() function from the R-package STATS in a
 Delphi program. If this is possible, could anyone provide us with an
 example?

 It is possible, and in principle simple.  The essentials:  (1) Write a
 file containing the something like a script in R with whatever
 commands. (2) Start a process involving the execution of R with a
 command line containing two arguments, the name of the command file
 and the file where you want the output (results) to be. (3) wait for
 the process to stop.  So, here is a function (returns true if
 everyhing worked OK) that does that:

. . .

CreateOK := CreateProcess(Nil, PChar('R.exe ' + CommandLine), nil,
   nil,False, CREATE_NEW_PROCESS_GROUP+NORMAL_PRIORITY_CLASS, nil,
   nil, StartInfo, proc_info);

I had to give the full path to the R executable to get this to work:

   CreateOK := CreateProcess(Nil, PChar('C:\Program 
Files\R\R-2.4.0\bin\R.exe ' + CommandLine), nil,
   nil,False, CREATE_NEW_PROCESS_GROUP+NORMAL_PRIORITY_CLASS, nil,
   nil, StartInfo, proc_info);

I used Delphi 7 to test StartRAndWait with this button press event:

procedure TForm1.Button1Click(Sender: TObject);
  VAR
Command: STRING;
begin
  Screen.Cursor := crHourGlass;
  TRY
Command := 'CMD  BATCH  Sample.R  SampleOutput.txt';
StartRAndWait(Command);
  FINALLY
Screen.Cursor := crDefault
  END
end;


Sample.R file
=
sink('quantile.txt')
quantile(0:100)
sink()
=

I used sink in the R script to isolate the output of the R quantile command 
to help any parsing of the output:

SampleOutput.txt
=
R version 2.4.0 (2006-10-03)
Copyright (C) 2006 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

 sink('quantile.txt')
 quantile(0:100)
 sink()

=


quantile.txt
=
  0%  25%  50%  75% 100%
   0   25   50   75  100
=


Tinn-R is written in Delphi, so its source code should be a great example of 
a Delphi/R interface.  I've never studied the source code -- that's been on 
my to do list for months --, but I'm guessing it uses RCOm, like 
Hans-Peter suggested.  Nevertheless, Tom's example above may also be quite 
useful.

efg

Earl F. Glynn
Scientific Programmer
Stowers Institute for Medical Research

__
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] There exist a FCS package on R-languaje?

2006-11-28 Thread Earl F. Glynn
I do not have R code for ConfoCor2 raw data, but I'm working on some R code 
to read ConfoCor3 raw data.  That R example is not quite ready for public 
release.

The ConfoCor3 raw data format, which is a binary file, is quite a bit 
simpler to process than ConfoCor2 raw data.  IMHO, the ConfoCor2 data format 
is unnecessarily complex.  With ConfoCor2 two bit streams are multiplexed 
into a single binary stream, and run-length compressed at the same time.  I 
did write a Delphi ConfoCor 2 viewer (with source code), which I'm modifying 
to handle either ConfoCor 2 or 3 raw data if that is of any interest:
http://research.stowers-institute.org/efg/ScientificSoftware/Utility/FCSViewer/index.htm
(I hope to update this page in the next week or two with that new version). 
Diagrams on that page show how the ConfoCor2 file can be parsed.  Bit 
manipulations in R would be a bit of a pain IMHO.

Unfortunately, FCS is an overloaded acronym and some may be interested in 
Flow Cytometery Standard FCS data, which is a different kind of binary 
file for a very different subject area.  There is a prada package for this 
other kind of FCS data.  Find some additional notes about using R with this 
kind of FCS data here:
http://research.stowers-institute.org/efg/ScientificSoftware/Utility/FCSExtract/index.htm

efg

Earl F. Glynn
Scientific Programmer
Stowers Institute for Medical Research


Horacio Castellini [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
Hi all, excuse me by this elementary question. I wish to know if a
package in language R exists to analyze FCS (Fluorescence Correlation
Spectroscopy) datas. And, if it possible, in addition can read the
archives in raw format generated by the ConfoCor2 program.

__
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 Text on a graph

2006-10-24 Thread Earl F. Glynn
Dan Chan [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]

 I plotted 12 graphs on a page and output to a png file.  I wanted to
 have an overall title for all 12 graphs.  What command can I use to do
 this?  Below is the code that plotted the 12 graphs in one page.

Define an outer margin area at the top and put your overall title there.

Find some illustrated examples of oma (outer margin area) and mar (margin 
area) here with mfrow/mfcol:
http://research.stowers-institute.org/efg/R/Graphics/Basics/mar-oma/index.htm


Perhaps this will get you started:

# Outer margin area (South, West, North, East).
# Default is all 0s, so ask for North oma of 2.
# Trim some of the space form regular margins (mar) too.

par(mfrow=c(3,4), mar=c(4,4.5,1,1), oma=c(0,0,2,0))

for (i in 1:12)
{
  plot(0)
}

mtext(Overall Title, NORTH-3, line=0.5, adj=0.5,
  col=red, outer=TRUE, cex=1.2)


efg
Earl F. Glynn
Scientific Programmer
Stowers Institute for Medical Research

__
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] plot correlation matrix

2006-09-21 Thread Earl F. Glynn
Vladimir Eremeev [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Dear useRs,

 While exploring new R packages, I have found the Rattle.
 This screenshot http://rattle.togaware.com/rattle-correlation.png
 is very interesting

 Which function was used to produce this plot?

library(ellipse)
 ?plotcorr

Look at the third example for the color plot.


Earl F. Glynn
Bioinformatics
Stowers Institute for Medical Research

__
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] converting decimal - hexadecimal

2006-08-30 Thread Earl F. Glynn
Romain Lorrilliere [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
Hi,

do you know, a method to convert an decimal value (integer) to the
corresponding hexadecimal value ?

Starting in R 2.1.0, sprintf can be used:

 x - c(0, 65535, 65536, 305419896, 2^31-1)
 y - sprintf(0x%X, x)
 y
[1] 0x00x 0x10x12345678 0x7FFF
 as.numeric(y)
[1]  0  65535  65536  305419896 2147483647

efg

Earl F. Glynn
Scientific Programmer
Stowers Institute for Medical Research

__
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] nls convergence problem

2006-08-15 Thread Earl F. Glynn
I'm having problems getting nls to agree that convergence has occurred in a 
toy problem.

nls.out never gets defined when there is an error in nls.  Reaching the 
maximum number of iterations is alway an error, so nls.out never gets 
defined when the maximum number of iterations is reched.

From ?nls.control:
  tol: A positive numeric value specifying the tolerance level for
  the relative offset convergence criterion.

From some S-Plus documentation I found online via Google:
http://www.uni-muenster.de/ZIV/Mitarbeiter/BennoSueselbeck/s-html/helpfiles/nls.control.html

tolerance:
tolerance for the relative offset convergence criterion in the algorithm. 
Default 0.001. Note that the convergence test used in nls() is strictly 
relative. Therefore if the solution to a problem turned out to be a perfect 
fit (unlikely except in artificial examples), convergence is not guaranteed 
to be recognized by the algorithm.


Here's my toy problem:
 ?nls.control
 ?nls
 # Method 2
 X - 0:15
 Y - 9.452 * exp(-0.109*X) + 5.111   # Toy problem

 nls.out - nls(Y ~ a*exp(b*X)+c,
+start=list(a=6,b=-0.5,c=1),
+control=nls.control(maxiter=15, tol=0.01),  # nothing makes 
sense here
+trace=TRUE)
1016.507 :   6.0 -0.5  1.0
143.5807 :   6.1680290 -0.1506021  4.4013020
7.306365 :   9.10093164 -0.09114858  5.44620298
0.0342703 :   9.2801070 -0.1109063  5.2795803
3.001985e-05 :   9.4506654 -0.1089749  5.1122982
1.918531e-14 :   9.452 -0.109  5.111
6.894644e-28 :   9.452 -0.109  5.111
2.208811e-29 :   9.452 -0.109  5.111
7.888609e-30 :   9.452 -0.109  5.111
7.888609e-30 :   9.452 -0.109  5.111
7.099748e-30 :   9.452 -0.109  5.111
3.155444e-30 :   9.452 -0.109  5.111
3.155444e-30 :   9.452 -0.109  5.111
3.155444e-30 :   9.452 -0.109  5.111
3.155444e-30 :   9.452 -0.109  5.111
3.155444e-30 :   9.452 -0.109  5.111
Error in nls(Y ~ a * exp(b * X) + c, start = list(a = 6, b = -0.5, c = 1), 
:
number of iterations exceeded maximum of 15

There is near-perfect convergence after 12 iterations, but I cannot figure 
out a way for R to recognize it.

What does relative offset convergence criterion mean?  How can nls.control 
be used to say this problem has converged, and have nls exit without an 
error?

Should the R documentation be modified to explain what relative offset 
convergence criterion means?  Should the R documentation be expanded to 
include the comment from the S-Plus: Therefore if the solution to a problem 
turned out to be a perfect fit (unlikely except in artificial examples), 
convergence is not guaranteed to be recognized by the algorithm.  If this 
is true, this seems like a suboptimal design.

Thanks for any insight about this.

efg

Earl F. Glynn
Scientific Programmer
Stowers Institute for Medical Research

__
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] nls convergence problem

2006-08-15 Thread Earl F. Glynn
Dieter Menne [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Earl F. Glynn efg at stowers-institute.org writes:
 This toy problem is exactly what the warning is for:

 Warning
 Do not use nls on artificial zero-residual data.

 Add some noise and try again.

Thank you!

I had adapted some code and must confess I had read ?nls.control thoroughly, 
but not ?nls. I had even used debug on nls, traced it through line by line 
to the .Call statement, trying to figure out why nls.out never got defined. 
The source code has no comments at all.

IMHO, the warning should be in the Description at the top of the ?nls 
page, not at the bottom of the page. The warning should also appear on the 
?nls.control page. But, a better way would be to have a software design that 
eliminated the warning.

It's not clear to me why this problem cannot be fixed somehow. You 
shouldn't need to add noise to a problem to solve it. (It's a bit like 
saying addition works, but not for integers without adding some noise.) If 
there can be arbitrary defaults of maxiter=50, and (relative) tol=1e-5 in 
nls.control, there could be another arbitrary (absolute) convergence 
criterion.  Or, maybe there's something I don't understand about the 
algorithm being used.

Just my $0.02 and minority opinion,
efg

__
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] nls convergence problem

2006-08-15 Thread Earl F. Glynn
Berton Gunter [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
   Or, maybe there's something I don't understand about the
 algorithm being used.

 Indeed! So before making such comments, why don't you try to learn about 
 it?
 Doug Bates is a pretty smart guy,  and I think you do him a disservice 
 when
 you assume that he somehow overlooked something that he explicitly warned
 you about. I am fairly confident that if he could have made the problem go
 away, he would have. So I think your vent was a bit inconsiderate and
 perhaps even intemperate. The R Core folks have produced a minor miracle
 IMO, and we should all be careful before assuming that they have 
 overlooked
 easily fixable problems. They're certainly not infallible -- but they're a
 lot less fallible than most of the rest of us when it comes to R.

I meant no disrespect to Doug Bates or any of the R Core folks. I thought 
what I wrote had a neutral tone and was respectful.  I am sorry if anyone 
was offended by my comments and suggestions.  I am certainly thankful for 
all the hard work that has gone into developing R.

efg

__
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] Help with workaround for: Function '`[`' is not in the derivatives table

2006-08-14 Thread Earl F. Glynn
# This works fine:
 a - 1

 b - 2

 c - 3



 E - expression(a * exp(b*X) + c)



 X - c(0.5, 1.0, 2.0)



 eval(E)

[1]  5.718282 10.389056 57.598150



 D(E, b)

a * (exp(b * X) * X)

 eval(D(E, b))

[1]   1.359141   7.389056 109.196300



# But if (a,b,c) are replaced with (A[1], A[2], A[3]), how can I get a 
derivative using D?



 A - c(1, 2, 3)

 E - expression(A[1] * exp(A[2]*X) + A[3])

 X - c(0.5, 1.0, 2.0)

 eval(E)

[1]  5.718282 10.389056 57.598150



# Why doesn't this work?  Any workarounds?

 D(E, A[2])

Error in D(E, A[2]) : Function '`[`' is not in the derivatives table



If I want to have a long vector of coefficients, A, (perhaps dozens) how can 
I use D to compute partial derivatives?



Thanks for any help with this.



efg



Earl F. Glynn

Scientific Programmer

Stowers Institute for Medical Research

__
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] rgb and col2rgb color conversion/modification/shading

2006-08-01 Thread Earl F. Glynn
[EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
I want to get a lighter shade of a color...I have a lot of colored objects 
and
 want each one printed as a foreground against a slightly lighter 
 background.

 I thought I could try something like changing the alpha channel by first
 converting it to rgb.

I'm not sure what you want to do with the alpha channel - it's sometimes 
used for transparency, especially on Macs, but is not used much on PCs 
(AFAIK).



Let's say you want different shades of gold:

 colors()[142]

[1] gold



Instead of RGB color space perhaps you should consider HSV 
(Hue-Saturation-Value) color space.



Let's convert gold to rgb to hsv:



 col2rgb( colors()[142] )

  [,1]

red255

green  215

blue 0



 rgb2hsv( col2rgb( colors()[142] ) )

   [,1]

h 0.1405229

s 1.000

v 1.000



The hue (h) is the color ranging from 0 to 1 around a color circle (with 
red= 0 or 1).  Find h = 0.140 (gold) in this color circle:



hue - seq(0.0, 1.0, by=1/40)



pie(rep(1,40),

labels=formatC(hue, digits=3, format=f), cex=0.75,

col=hsv(hue, 1.0, 1.0),

radius=1.0,

main=HSV (S=1, V=1) )




Hues range from 0.0 to 1.0.




A color is saturated (s=1) when it is far from a shade of gray (ranging 
from black to white).  Grays are unsaturated (no color) colors with s = 0. 
Saturation ranges from 0.0 to 1.0.



The value (v) is the brightness of the color.  Low values appear quite dark 
but still have color.  v=1 is as bright as possible.   Values range from 0.0 
to 1.0.



You can get different shades of the same color by varying changing the 
saturation and value for a given hue.  The hsv function returns the RGB 
color in hex form.



Consider:

 hsv(0.1405, 1, 1)

[1] #FFD700



Hex FF = decimal 255 = red

Hex D7 = decimal 215 = green

Hex 00 = decimal 0 = blue



Let's vary Saturation from 0.0 to 1.0 and Value from 0.0 to 1.0 in this 
plot:





MakeHSVRectangle - function(saturation, value)

{

  GoldHue - 0.140

  color - hsv(GoldHue, saturation, value)

  rect(100*saturation, 100*value, 100*saturation+4, 100*value+4, col=color)

}





plot(0:110,0:110, type=n,

 xlab=Saturation[%], ylab=Value[%],

 main=Shades of Gold, H=0.140)

outer(seq(0.0, 1.0, 0.05), seq(0.0, 1.0, 0.05), MakeHSVRectangle)





With Value = 0, all colors are black.  With Saturation=0, the only 
colors along the y axis are the shades of gray.  The original gold 
rectangle is at the upper right.



So, given a starting color, you have a number of shades (various 
saturations and values) with the same color hue.



I hope this helps.



efg

Earl F. Glynn

Scientific Programmer

Stowers Institute for Medical Research

__
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] Title of page with multiple plots

2006-05-12 Thread Earl F. Glynn
John Sorkin [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 I want to place four plots on a page, and I would like to have all four
 plots share a common title. I have tried the following code, but the
 title is centered over the fourth graph and not centered across all four
 plots. Does anyone have any suggestions?

You may want to adjust the North parameters for the outer margin area
(oma) and the regular margin (mar):

# oma and mar: c(South,West,North,East)
oldpar - par(mfcol =c(1,4), oma=c(0,0,2,0), mar=c(5.1,4.1,0,2.1))

plot(1)
plot(2)
plot(3)
plot(4)

title(Common title, outer=TRUE)

par(oldpar)


efg
Earl F. Glynn
Scientific Programmer
Bioinformatics
Stowers Institute for Medical Research

__
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] french secondary boxplot

2006-03-17 Thread Earl F. Glynn
Jean-Pierre GERBAL [EMAIL PROTECTED] wrote in
message
news:[EMAIL PROTECTED]

i'm a mathematic teacher and i have a question for R-developers :

is it possible to have (in the future) a boxplot with whiskers from
the first decile to the ninth decile, as usual in secondary french
schools... by example : boxplot(serie,range=-1) for french boxplot ?

Perhaps you could use bxp and bp.stats to create your own version:

set.seed(19)
x - rnorm(100)

oldpar - par(mfrow=c(1,3))

# 1. Normal boxplot
boxplot.info - boxplot(x, plot=FALSE)
boxplot.info

# compare boxplot.info$stats with deciles.  Boxplot's normal
# limits are 0% and 100% quantiles.
deciles - quantile(x, probs=seq(0,1,0.1))
deciles

bxp(boxplot.info, main=Normal boxplot, ylim=c(-3,3))


# 2. Modify boxplot.info to use 10% and 90% deciles instead of 0% and 100%
boxplot.info$stats[1] - deciles[10%]
boxplot.info$stats[5] - deciles[90%]
bxp(boxplot.info, main=10%/90% whiskers, ylim=c(-3,3))


# 3. Build your own, e.g, Mean +/- 1 and 2 standard deviations
boxplot.limits - as.matrix(c(mean(x) - 2*sd(x),
mean(x) - sd(x),
mean(x),
mean(x) + sd(x),
mean(x) + 2*sd(x)))
boxplot.meansd - list(stats = bp.limits,
   n = length(len),
   conf = NULL,
   out = numeric(0))
bxp(boxplot.meansd, main=expression(mean %+-% 1 and 2 SDs),
ylim=c(-3,3))


par(oldpar)


efg
Earl F. Glynn
Stowers Insititute for Medical Research

__
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] french secondary boxplot

2006-03-17 Thread Earl F. Glynn
Earl F. Glynn [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]

Sorry, I mixed up some code in Example #3.  Here is a correction:

 boxplot.meansd - list(stats = bp.limits,
n = length(len),

boxplot.meansd - list(stats = boxplot.limits,
   n = length(x),

efg

__
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] Debugging a program written in the R language

2006-03-09 Thread Earl F. Glynn
Prof Brian Ripley [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 On Wed, 8 Mar 2006, Liaw, Andy wrote:

 So now is a very good time for
 people to offer further information/suggestions for that chapter.

This may be useful:
Mark Bravington, Debugging Without (Too Many) Tears, R News, Vol 3, No 3,
Dec 2003, pp. 29-32.



R-News:

http://cran.r-project.org/doc/Rnews/



Exact link:

http://cran.r-project.org/doc/Rnews/Rnews_2003-3.pdf



efg

__
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] R and Power Point

2006-02-14 Thread Earl F. Glynn
Erin Hodgess [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 I am currently saving the R screen as WMF files and inserting them
 into PowerPoint.  While this works, it seems that there
 might be a simpler method.

 Does anyone have any suggestions for the Power Point, please?

Instead of saving to a file first, have you tried cutting from R and pasting
directly to PowerPoint?



File | Copy to Clipboard | As a Metafile



Paste onto PowerPoint page



In PowerPoint, the graphic has no background.  Set a background color (if
desired):



Right click on graphic | Format Picture | Colors and Lines | Fill | Change
from No Fill to white, or desired background color



Sometimes resizing even with a metafile is a problem in PowerPoint (or
Word).  Drawing the right size in R before cutting and pasting often
solves that problem.



For some very complicated graphics (e.g., a large heatmap), use Copy to
Clipboard | As a Bitmap to avoid delays in redrawing the graphic whenever
the page is shown.



efg

__
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] Very important! Global variables in R?

2006-01-24 Thread Earl F. Glynn
Sean Davis [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]

  I need urgently your assistance!!!
  I need a global variable in R. The variable ought to be known for every
  functions and subfunctions.  It is only to comparison purposes of the
  numeric algorithms. Is there a possibility?
 
  please answer in german if possible.

Es tut mir leid.  Ich kann Deutsch nicht sprechen.


  a - 1

If you make that assignment inside a function, it won't be known outside the
funtion, so a is not really global here.

Global assignment
x - 5
?-

BUT, be aware of these cautions about the use of global variables:

I wish - had never been invented, as it makes an esoteric
and dangerous feature of the language *seem* normal and reasonable.  If you
want to dumb down R/S into a macro language, this is the operator for you.
-- Bill.Venables, R-Help,  July 30, 2001

#thomas (tlumley), R-Help, Jan 24, 2001
This is one of the acceptable uses of -, as shown in
demo(scoping).  - is useful for modifying a variable that you know
exists in the enclosing environment. Most of the problems come from people
trying to use it to modify things in a parent environment or in the global
environment.

Also see Section 13.3 Global Data in Code Complete 2
(http://www.cc2e.com/) including:
- Common Problems with Global Data
- Use Global Data Only as a Last Resort
- How to Reduce the Risks of Using Global Data

efg

__
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 plot curves with more than 8 colors

2005-12-29 Thread Earl F. Glynn
Don MacQueen [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]

 I have found this little function useful when trying to choose colors:

FWIW:  To choose colors, this page
http://research.stowers-institute.org/efg/R/Color/Chart/index.htm
and PDF
http://research.stowers-institute.org/efg/R/Color/Chart/ColorChart.pdf
can be used to view the named colors in R, along with RGB information in
decimal or hex.

Not everyone can see the same colors.  In particular, about 7% of males
have some color blindness, especially red-green.  See some of the links
under Color Blindness:
http://www.efg2.com/Lab/Library/Color/index.html

Not all devices have the same color gamut.  That is, not all devices can
display the same ranges of colors:
http://www.efg2.com/Lab/Library/Color/Science.htm#gamuts
Matching color between the screen and printers can be a problem.

efg

__
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] Which cluster function can be used to cluster a correlaiton matrix?

2005-12-29 Thread Earl F. Glynn
Martin Maechler [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]

 The clue is to transform correlations to dissimilarities.
. . .
 and then use  hclust(), agnes(), pam(), [the latter two from
 package 'cluster'], ...
 with 'Dx' as dissimilarity

Perhaps this TechNote may be of interest:

Correlation Distances and Hierarchical Clustering
http://research.stowers-institute.org/efg/R/Visualization/cor-cluster/index.htm

efg

__
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 per page

2005-12-16 Thread Earl F. Glynn
Bill Hunsicker [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 R-help,

 I would like to place nine (3X3) plots per page.  I am not properly
 implement mfrow(3,3) in the script below:

Does this help?

jpeg(3x3.jpg)
oldpar - par( mfcol=c(3,3) )
plot(1)
plot(2)
plot(3)
plot(4)
plot(5)
plot(6)
plot(7)
plot(8)
plot(9)
par(oldpar)
dev.off()

efg

__
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] RODBC help

2005-11-17 Thread Earl F. Glynn
I had a similar problem when I posted this recently:

RODBC and Excel: Wrong Data Type Assumed on Import
http://tolstoy.newcastle.edu.au/~rking/R/help/05/11/14938.html

My conclusion was: Being lucky shouldn't be part of processing Excel
files, which is the case when RODBC is used.

This reply gave some suggestions:
http://tolstoy.newcastle.edu.au/~rking/R/help/05/11/14990.html

I found this suggestion the most useful:

You could try using the COM interface rather than the ODBC interface
http://tolstoy.newcastle.edu.au/~rking/R/help/05/11/15030.html

This approach has problems if you have holes in your data, but with some
work I found RDCOMClient the way to go:
http://tolstoy.newcastle.edu.au/~rking/R/help/05/11/15090.html

IMHO, RODBC should only be used if you have an Excel file without holes, and
with very regular numeric data.  I don't understand why the online
documentation is not updated to give a usage note that RODBC will often fail
reading Excel files.

Specifically,

this help:

  library(RODBC)
  ?odbcConnectExce

should be modified to have a warning RODBC considered harmful with Excel
files

efg


Keith Sabol [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 I am using the RODBC package to read data from an Excel file.
 ...
 My problem appears to be related to specification of data types by column.

__
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] R (2.2.0), R-DCOM and Delphi

2005-11-07 Thread Earl F. Glynn
Dieter Menne [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]...
 Jose Claudio Faria joseclaudio.faria at terra.com.br writes:

 Looks like a missing file in uses. I compiled it under Delphi 5, and it
looks
 like the variants are no longer included in my uses.

 Try to find out via help file where VarType is declared, add it to uses.
And
 please tell me about the result when you got it compiled, I will add your
 finding to the archive.

Here's what worked for me:

(1) Install the new (D)COM server (the old one gives the error Method '~'
of object '~' failed with R 2.2.0):

 For anybody who wants to try the R(D)COM server alone, I recommend
 http://sunsite.univie.ac.at/rcom/download/RSrv200beta.exe
 It is reasonably stable and will work with R 2.2.0.


(2) In C:\Program Files\R\(D)COM Server\samples\Simple run the simple.exe to
verify the server is working.


(3) Download and unzip:  http://www.menne-biomed.de/download/RDComDelphi.zip

Like Jose Claudio Faria described, a number of warnings and errors will be
seen in Delphi 7 in compiling the unmodified RDCom.dpr project.

To fix the compilation errors, add the Variants unit to the uses:

uses
  Windows, Messages, SysUtils,Classes, Dialogs,
STATCONNECTORSRVLib_TLB,Forms, Variants;

I don't remember why Borland made this change.

You can make the Warnings go away by selecting Project | Options | Compiler
Messages and unchecking the boxes for

- Unsafe type
- Unsafe code

These warning were introduced with Borland made changes to support .NET.
The code should be quite fine for Win32.

Note:  The Delphi source code could be modified to use {$IFDEF} directives
to take care of the differences by compiler version.  See the Compiler
Versions section of this page:
http://www.efg2.com/Lab/Library/Delphi/Miscellany/index.html.
Unfortunately, Borland has not been very helpful in promoting the use of a
common Versions.INC file or any other mechanism to take care of such
compiler version problems in a uniform way.  The file Versions.INC must be
updated with every new release by Borland.


(4) Run the RDCom.exe program. Select the Run and Plot buttons and see a
wonderful demo of Delphi and R working together.  (Now I can get busy and
use this in other Delphi applications with R as a backend.)


Thanks for the work on R-DCOM and this great example!

efg
Scientific Programmer
Stowers Institute for Medical Research

__
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] RODBC and Excel: Wrong Data Type Assumed on Import

2005-11-04 Thread Earl F. Glynn
Gabor Grothendieck [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 You could try using the COM interface rather than the ODBC
 interface.  Try code such as this:

 library(RDCOMClient)
 xls - COMCreate(Excel.Application)
 xls[[Workbooks]]$Open(MySpreadsheet.xls)
 sheet - xls[[ActiveSheet]]
 mydata - sheet[[UsedRange]][[value]]
 xls$Quit()

 # convert mydata to a character matrix
 mydata.char - matrix(unlist(mydata), nc = length(xx))

Gabor,

Thank you for that suggestion.  I try to avoid COM, but it seems to work
well with this problem.

Because I have empty cells, which are treated as NULLS, the unlist didn't
quite work.

Here's what I did:

library(RDCOMClient)
xls - COMCreate(Excel.Application)
xls[[Workbooks]]$Open(U:/efg/lab/R/Plasmid/construct list.xls)
sheet - xls[[ActiveSheet]]
mydata - sheet[[UsedRange]][[value]]
xls$Quit()

for (column in 1:length(mydata))
{
  cat(column,  , length(mydata[[column]]),  ,
length(unlist(mydata[[column]])), \n)
}

The results show that while mydata is a list of columns, if you unlist each
column you'll be short by the number of NULL values.

1   1251   1251
2   1251   1198
3   1251   870
4   1251   327
5   1251   1250

This seemed a bit crude to fix that problem (can someone suggest a more
elegant way?):

mymatrix - NULL
for (column in 1:length(mydata))
{
 # Use lappy to replace NULLs with  strings, column-by-column
  mymatrix - cbind(mymatrix, lapply(mydata[[column]], function(cell) {
ifelse(is.null(cell), , cell) } ))
}
# Fix column names
colnames(mymatrix) - mymatrix[1,]
mymatrix - mymatrix[-1,]

 mymatrix[273:276,]
 Plasmid Number Plasmid
Concentration Comments Lost
[1,] 274yxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxy 1 ug/ul
4 mg   
[2,] 275a xyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyx 1 ug/2
ul  
[3,] 275b xyxyxyxyxyxyxyxyxyxyxyxyx   1 ug/5
ul  
[4,] 276xyxyxyxyxyxyxyxyxyxyxyxyxyxy1 ug/5
ul  Assumed Lost

Thank you for preserving 275a and 275b as the names here.

So, I'd recommend RDCOMClient over RODBC with Excel files.  Being lucky
shouldn't be part of processing Excel files.

efg

__
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] RODBC and Excel: Wrong Data Type Assumed on Import

2005-11-03 Thread Earl F. Glynn
Kevin Wright [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 From my experience (somewhat of a guess):

 Excel uses the first 16 rows of data to determine if a column is numeric
or
 character. The data type which is most common in the first 16 rows will
then
 be used for the whole column.

I ran some experiments trying to force RODBC to read column 1 of my
worksheet as character data (the data are mostly numbers with two
exceptions, 275a and 275b, as mentioned earlier).



Here's the base code:



 library(RODBC)

 channel - odbcConnectExcel(U:/efg/lab/R/Krumlauf-Plasmid/construct
list.xls)

 plasmid - sqlFetch(channel,Sheet1, as.is=TRUE)

 odbcClose(channel)

 names(plasmid)

[1] Plasmid Number PlasmidConcentration  Comments
Lost



When Excel Sheet1 has rows 2:13 as an X to attempt to force treatment of
column 1 as character data:



 class(plasmid$Plasmid Number)

[1] numeric

 typeof(plasmid$Plasmid Number)

[1] double

 plasmid$Plasmid Number[1:20]

 [1] NA NA NA NA NA NA NA NA NA NA NA NA  2  3  4  5  6  7  8  9



Why would any software with 12 consecutive X character strings assume
the data are purely numeric?



Add one more X so rows 2:14 have an X to attempt to force treatment of
column 1 as character data:



 class(plasmid$Plasmid Number)

[1] character

 typeof(plasmid$Plasmid Number)

[1] character

 plasmid$Plasmid Number[1:20]

 [1] X X X X X X X X X X X X X NA  NA  NA  NA  NA
NA  NA



So RODBC now recognizes character Xs in column 1 and then declares all
numbers as invalid?  These are incredibly (bad) assumptions.



I say this is a bug, but it may be an ODBC problem and not one with R.
And if this is not an official bug, then it's a serious design problem.
Minimally, this issue should be described in the R Data Import/Export
document, which everyone is told to read before asking a question.



It's frustrating when packages like this work for toy problems, and the
documentation never mentions the pitfalls of real data.


 The gregmisc bundle has a different read.xls function that uses a Perl
 script (xls2csv) and seems to be safer with mixed-type columns.
 Requires a working version of Perl.

Thanks for this suggestion, but I think I'll just convert the Excel
spreadsheet to a .csv and maintain it in that format.

efg

__
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


[R] RODBC and Excel: Wrong Data Type Assumed on Import

2005-11-02 Thread Earl F. Glynn
The first column in my Excel sheet has mostly numbers but I need to treat it
as character data:

 library(RODBC)
 channel - odbcConnectExcel(U:/efg/lab/R/Plasmid/construct list.xls)
 plasmid - sqlFetch(channel,Sheet1, as.is=TRUE)
 odbcClose(channel)

 names(plasmid)
[1] Plasmid Number PlasmidConcentration  Comments
Lost

# How is the type decided?  I need a character type.
 class(plasmid$Plasmid Number)
[1] numeric
 typeof(plasmid$Plasmid Number)
[1] double

 plasmid$Plasmid Number[273:276]
[1] 274  NA  NA 276

The two NAs are supposed to be 275a and 275b.  I tried the as.is=TRUE but
that didn't help.

I consulted Section 4, Relational databases, in the R Data Import/Export
document (for Version 2.2.0).

Section 4.2.2, Data types, was not helpful.  In particular, this did not
seem helpful:  The more comprehensive of the R interface packages hide the
type conversion issues from the user.

Section 4.3.2, Package RODBC, provided a simple example of using ODBC ..
with a(sic) Excel spreadsheet but is silent on how to control the data type
on import.  Could the documentation be expanded to address this issue?

I really need to show Plasmid 275a and Plasmid 275b instead of Plasmid
NA.

Thanks for any help with this.

efg
--
Earl F. Glynn
Scientific Programmer
Bioinformatics Department
Stowers Institute for Medical Research

__
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] getting last 2 charcters of a string, other text functions?

2005-10-31 Thread Earl F. Glynn
t c [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 I wish to obtain the right-most n characters of a character string?  What
is the appropriate function?

substr will work:

 x - c(abcd, xyz)

 N - 2
 substr(x, nchar(x)-N+1, nchar(x))
[1] cd yz

 N - 3
 substr(x, nchar(x)-N+1, nchar(x))
[1] bcd xyz

efg

__
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


[R] R Programmer/Analyst

2005-10-21 Thread Earl F. Glynn
From
http://www.stowers-institute.org/ScientistsSought/ScientistsSought.asp#positions

Programmer/Analyst

 The Stowers Institute for Medical Research has an opening for a
Programmer/Analyst to support scientific data analysis and assist with
computational biology tasks.

 Responsibilities include:
Developing and/or maintaining software for analyzing biological data,
typically using the R language.
Updating related software packages, as needed and documenting how packages
can be used with the existing computing infrastructure;
Developing solutions to computational biology problems and assisting with
scientific data analysis, especially with gene expression data;
Writing code to use existing software packages for data analysis; and
Monitoring changes in scientific software, especially R and Bioconductor
packages

 In addition to excellent communication skills, the successful candidate
will also have experience with Splus, R, Matlab, Maple, or Mathematica, and
experience with computational biology, scientific computing, numerical
analysis, multi-platform development (UNIX/Windows) databases, or web
programming.

 Minimum requirements include an undergraduate degree in science, math,
computer science, engineering, or a related field; at least one year of
programming experience, and experience with at least two languages such as
R, Python, Java, PERL, C#, C++ or C

Apply now:
http://www.stowers-institute.org/ScientistsSought/ScientistsSought.asp#resume

Stowers Institute for Medical Research
1000 East 50th Street
Kansas City, MO  64110
USA

__
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] font=5 (Was: greek symbols using pch)

2005-10-12 Thread Earl F. Glynn
ecatchpole [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Earl,

 I don't think that's a bug. Try

 pdf(font5.pdf, onefile=FALSE)

 and similarly for postscript().

Mea culpa. The onefile=FALSE wasn't necessary (and caused Ghostscript not to
open the postscript file).

The 2nd page was caused by an erroneous second plot statement in ShowFont5,
which I put there for a one time test and then I failed to remove it.  I was
getting two pages because I had two plot statements.  Sorry for the
confusion.

All works fine with this code, which has only one plot statement, even with
postscript and pdf files:

ShowFont5 - function()
{
  oldpar - par(font=5, las=1)
  plot(0:15,0:15,type=n,ylim=c(15,0),
main=Symbols in Font=5,
xlab=, ylab=,xaxt=n, yaxt=n)
  axis(BOTTOM-1, at=0:15)
  axis(LEFT  -2, at=0:15, 16*0:15)
  abline(v=0.5 + 0:14,
 h=0.5 + 0:14, col=grey, lty=dotted)
  for(i in 0:255)
  {
x - i %%16;
y - i %/% 16;
points(x,y,pch=i)
  }
  par(oldpar)
}


efg

__
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] font=5 (Was: greek symbols using pch)

2005-10-11 Thread Earl F. Glynn
ecatchpole [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Thanks for that. Very instructive, and much appreciated.

 And sorry, yes, I strayed well off the original topic. The Greek symbols
   come out fine with font=5 in my locale,
 Locale:
 LC_CTYPE=en_GB.UTF-8;
 LC_NUMERIC=C;
 LC_TIME=en_GB.UTF-8;

 I was interested in some of the other nice characters, for example
 \infty and \partial, that appear in the table, but with a calligraphic R
 attached to them. But plotmath() works fine, so I'm happy.

I performed some tests with font=5 on both Linux and Windows using
source(font5.R), which is shown below, and then calling the Font5Test()
function.

Consistent results were seen with devices X11, png, and jpeg under either
Linux  (R 2.1.1) or Windows (R 2.2.0) in my locale.  Oddly, both the pdf and
postscript devices create 2 pages of output with the first page the expected
table and a second unexpected page with only the clubs suite symbol (167)
in the middle of the plot. I'd call this a bug, but I guess I haven't read
all the documentation about this yet.

efg
Earl F. Glynn
Scientific Programmer
Stowers Institute for Medical Research


font5.R
==

ShowFont5 - function()
{
  oldpar - par(font=5, las=1)
  plot(0:1, 0:1, type=n)
  points(.5, .5, pch=167)
  par(font=5, las=1)
  plot(0:15,0:15,type=n,ylim=c(15,0),
main=Symbols in Font=5,
xlab=, ylab=,xaxt=n, yaxt=n)
  axis(BOTTOM-1, at=0:15)
  axis(LEFT  -2, at=0:15, 16*0:15)
  abline(v=0.5 + 0:14,
 h=0.5 + 0:14, col=grey, lty=dotted)
  # pch index of any cell is 16*row + column
  for(i in 0:255)
  {
x - i %%16;
y - i %/% 16;
points(x,y,pch=i)
  }
  par(oldpar)
}

Font5Test - function()
{
  X11()
  ShowFont5()
  dev.off()

  pdf(font5.pdf)
  ShowFont5()
  dev.off()

  png(font5.png)
  ShowFont5()
  dev.off()

  jpeg(font5.jpg)
  ShowFont5()
  dev.off()

  postscript(font5.ps)
  ShowFont5()
  dev.off()

}


Linux Test
===
 Sys.getlocale()
[1] C

 R.Version()
$platform
[1] x86_64-unknown-linux-gnu

$arch
[1] x86_64

$os
[1] linux-gnu

$system
[1] x86_64, linux-gnu

$status
[1] 

$major
[1] 2

$minor
[1] 1.1

$year
[1] 2005

$month
[1] 06

$day
[1] 20

$language
[1] R



Windows Test
==
 Sys.getlocale()
[1] LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
States.1252;LC_MONETARY=English_United
States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252

 R.Version()
$platform
[1] i386-pc-mingw32

$arch
[1] i386

$os
[1] mingw32

$system
[1] i386, mingw32

$status
[1] 

$major
[1] 2

$minor
[1] 2.0

$year
[1] 2005

$month
[1] 10

$day
[1] 06

$svn rev
[1] 35749

$language
[1] R

__
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] greek symbols using pch

2005-10-10 Thread Earl F. Glynn
FISCHER, Matthew [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]

 In a plot, can I specify pch to be a greek symbol? (I looked at
 show.pch() in the Hmisc package but couldn't see the right symbols in
there).
 If not, I guess I can get around this using text(x,y,expression()).

I'm not sure where this is explained very well.  Having ?font give a clue
about this would be nice.

Use font=5, the symbol font.  To see what's in font=5:

par(font=5, las=1)
plot(0:15,0:15,type=n,ylim=c(15,0),
  main=Symbols in Font=5,
  xlab=, ylab=,xaxt=n, yaxt=n)
axis(BOTTOM-1, at=0:15, 1:16)
axis(LEFT  -2, at=0:15)
abline(v=0.5 + 0:14,
   h=0.5 + 0:14, col=grey, lty=dotted)

# pch index of any cell is 16*row + column
for(i in 0:255)
{
  x - i %%16;
  y - i %/% 16;
  points(x,y,pch=i+1)
}

The Greek letters are from 65 to 90 and 97 to 122 in this font.

Here are random points with Greek letters as the plot character:

par(font=5)
# Use Greek letter for plot characters from font=5
plot(0:1, 0:1, axes=F, type=n, xlab=, ylab=,
  main=Greek plotting characters)
box()
points(runif(100), runif(100), pch=c(65:90, 97:122))

--
efg
Earl F. Glynn
Scientific Programmer
Stowers Institute for Medical Research

__
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 line plots?

2005-09-06 Thread Earl F. Glynn
Ashish Ranpura [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]

 I still don't know how to draw
 each of the three line segments I need).

See ?segments

Could you post a small toy problem so we can see exactly what segements
you're wanting to draw?

efg

__
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] Spacing and margins in plot

2005-09-01 Thread Earl F. Glynn
This technote explains the margin area (mar) and how to modify it to control
white space around a graphic:
http://research.stowers-institute.org/efg/R/Graphics/Basics/mar-oma/index.htm

When you have multiple figures on a graphic, you may also want to learn to
control the outer margin area (oma), which is also explained.

AFAIK, the only way to get the axis label closer to the axis is to
suppress the actual axis labels and use the mtext command to display
alternative text where you want it.  For example, look at the blue text in
Figure 2B (at the above link)  that is between the axis label and the axis.
This blue text is at line=2, when the axis labels are at line=3.

efg
Bioinformatics
Stowers Institute

Jamieson Cobleigh [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 If I use the following command to plot points:

 plot(c(1,2,2,3,3,3), type=p, pch=20, ylab=Y Label, xlab=X Label,
xaxt=n)

 there is a large amount of space between the label X Label and the
 actual x-axis.  If I change the xaxt=n to xaxt=s, the label X
 Label don't move at all.  Is there a way to get the label X Label
 closer to the x-axis when xaxt=n?

 The plot I am generating is going to be included in a paper I am
 writing.  I can cause the plot to be saved in a PDF file by doing the
 following:

 pdf(foo.pdf, width=5.5, height=4.25, onefile=FALSE)

 plot(c(1,2,2,3,3,3), type=p, pch=20, ylab=Y Label, xlab=X Label,
xaxt=n)

 dev.off();

 In the resulting file, there is a lot of whitespace around the graph,
 particularly between the top line of the plot area and the top of the
 page.  Since I am including these plots in a paper, I want them to be
 as large as possible and not take up any extra space.  Is there a way
 to get R to draw a plot that goes all the way to the margins of the
 print area?

__
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] Spacing and margins in plot

2005-09-01 Thread Earl F. Glynn
Chris Wallace [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]

 how about
 plot(..., xlab=)
 title(xlab=label text, line=2)

Yes, Chris, I like your idea, especially when I can fix both X and Y axes
at the same time:

  plot(0, xlab=,ylab=)
  title(xlab=X axis, ylab=Y axis, line=2)

I'd prefer a way to set the axis title line at the same time I change the
mar parameters, but it's not a big deal.

Thanks.
efg

__
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] Determining physical display dimensions

2005-08-19 Thread Earl F. Glynn
Berton Gunter [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]

 Failing that, (how) can this be done for Windows (XP or 2000, say) ?

Take a look at the Windows GetDeviceCaps API call
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/devcons_88s3.asp

Parameters that can be queried include:
HORZRES  Width, in pixels, of the screen.
VERTRES Height, in raster lines, of the screen.

HORZSIZE Width, in millimeters, of the physical screen
VERTSIZE  Height, in millimeters, of the physical screen

The specifics of how to use this API call will vary by language.  Google
will be your friend.

efg
Bioinformatics
Stowers Institute for Medical Research

__
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] Image from bytes streams

2005-08-16 Thread Earl F. Glynn
Márcio de Medeiros Ribeiro [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]...
My big problem is that my program reads the image before that its
complete by the png() function. For instance, my graphic image has
1000Kb. When R saves it into the hard disk, my Java program reads the
file before the save operation completes (500Kb for example). So, I
got only a part of the file and hence the image... :(

One solution is read the image and search for a byte which represents
the end of the file, but it depends on the image format...

Have you considered in R writing the file to a temporary name (see
?tempfile). When the file is complete, after the dev.off() in R as suggested
by Prof Ripley, you could rename the file [using file.name() in R]. Your
external program can now access the file without worrying about whether it
is complete, since the file appears not to exist until the whole file has
been written.

efg

__
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


[R] Anything like dir.choose (similar to file.choose) in R?

2005-08-15 Thread Earl F. Glynn
Does R have a dir.choose function?

I can use file.choose like this as a kludge to get something like a
dir.choose, but a real dir.choose would be better:

  cat(Select one of files in directory to process:\n)
  filename - gsub(, /, file.choose())
  basepath - dirname(filename)

Windows provides a lower-level SHBrowseForFolder function to create such a
dialog (see links below).  Do other platforms have similar functionality at
a lower level?  (Hoping this would be an easy addition to R.)

SHBrowseForFolder Function
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/functions/shbrowseforfolder.asp

Using the Shell API function SHBrowseForFolder()
http://community.borland.com/article/0,1410,17008,00.html

efg
--
Earl F. Glynn
Bioinformatics
Stowers Institute for Medical Research

__
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] Digest reading is tedious

2005-08-10 Thread Earl F. Glynn
Dirk Eddelbuettel [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 The R-help (!!) list is available via Gmane.org, a fabulous service that
 archives, redirects, displays, ... a gazillion mailing lists. Among them
are
 are r-help, r-devel, and several r-sig-* lists.  See the top of

 http://dir.gmane.org/index.php?prefix=gmane.comp.lang.r

 for the current list. By Gmane's convention, -help or -user lists often
end
 up as '*.general'. So r-help is at

Reading these newsgroups is a great way to keep up with what's going on
with R without the daily digest tedium:
- gmane.comp.lang.r.general
- gmane.comp.lang.r.devel
- gmane.comp.lang.r.announce

The BioConductor mailing list is also there, but I find its name a bit odd:
- gmane.science.biology.informatics.conductor

The name makes some sense, but I missed it for months because it didn't have
bioconductor exactly in the name.

efg

__
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


[R] Why only a string for heading for row.names with write.csv with a matrix?

2005-08-10 Thread Earl F. Glynn
Consider:
 x - matrix(1:6, 2,3)
 rownames(x) - c(ID1, ID2)
 colnames(x) - c(Attr1, Attr2, Attr3)

 x
Attr1 Attr2 Attr3
ID1 1 3 5
ID2 2 4 6

 write.csv(x,file=x.csv)
,Attr1,Attr2,Attr3
ID1,1,3,5
ID2,2,4,6

Have I missed an easy way to get the  string to be something meaningful?

There is no information in the  string.  This column heading for the row
names often could used as a database key, but the  entry would need to be
manually edited first.  Why not provide a way to specify the string instead
of putting  as the heading for the rownames?

From http://finzi.psych.upenn.edu/R/doc/manual/R-data.html

  Header line
  R prefers the header line to have no entry for the row names,
  . . .
  Some other systems require a (possibly empty) entry for the row names,
which is what write.table will provide if argument col.names = NA  is
specified. Excel is one such system.

Why is an empty entry the only option here?

A quick solution that comes to mind seems a bit kludgy:

 y - cbind(rownames(x), x)
 colnames(y)[1] - ID
 y
IDAttr1 Attr2 Attr3
ID1 ID1 1   3   5
ID2 ID2 2   4   6

 write.table(y, row.names=F, col.names=T, sep=,, file=y.csv)
ID,Attr1,Attr2,Attr3
ID1,1,3,5
ID2,2,4,6

Now the rownames have an ID header, which could be used as a key in a
database if desired without editing (but all the numbers are now
characters strings, too).

It's also not clear why I had to use write.table above, instead of
write.csv:
 write.csv(y, row.names=F, col.names=T, file=y.csv)
Error in write.table(..., col.names = NA, sep = ,, qmethod = double) :
col.names = NA makes no sense when row.names = FALSE

Thanks for any insight about this.

efg
--
Earl F. Glynn
Bioinformatics
Stowers Institute

__
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] red-black-green color palette?

2005-08-04 Thread Earl F. Glynn
Jake Michaelson [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 I'm working on some heatmaps, and the person I'm working with would
 prefer a red-black-green color palette (red denoting gene induction and
 green denoting gene repression).  Does such a palette exist already?
 If not, is there an easy way to create one?

Here are four ways:

showpanel - function(Colors)
{
  image(matrix(1:length(Colors), ncol=1), col=Colors, xaxt=n, yaxt=n )
}

oldpar - par(mfrow=c(4,2))

# Method 1 (colorRampPalette was new in R 2.1.0) in grDevices
# Same as function with same name in dichromat package?
showpanel(colorRampPalette( c(green, black, red), space=rgb)(32))
showpanel(colorRampPalette( c(green, black, red), space=rgb)(64))

# Method 2
library(gplots)
showpanel(greenred(32))
showpanel(redgreen(64))

# Method 3
library(geneplotter)
showpanel(greenred.colors(32))
showpanel(greenred.colors(64))

# Method 4
library(marray)
pal - maPalette(low=green, high=red,mid=black)
maColorBar(seq(-2,2, 0.2), col=pal, horizontal=TRUE, k=0)
maColorBar(seq(-2,2, 0.1), col=pal, horizontal=TRUE, k=0)


efg
--
Earl F. Glynn
Scientific Programmer
Stowers Institute for Medical Research

__
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 Create Movies with R with repeated plot()?

2005-07-27 Thread Earl F. Glynn


Jan Verbesselt [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Dear R-helpers,

Is it possible to create a type of 'movie' in R based on the output of
several figures (e.g., jpegs) via the plot() function.  I obtained dynamic
results with the plotting function and would like to save these as a movie
(e.g., avi or other formats)?

1) You can create animated GIFs with the caTools package.

2) ImageMagick (clipped from R-Help)
It is quite easy to do with ImageMagick (www.imagemagick.org), which can be
installed on most OSes.  I tried this simple sequence and it worked

beautifully.



In R:



 for(i in 1:5) {

+ jpeg(paste(fig, i, .jpg, sep = ))

+ hist(rnorm(100))

+ dev.off()

+ }



Then from the command line (I tried it using Linux, though it should be the

same on any platform):



% convert -delay 50 -loop 50 fig*.jpg animated.gif



This created animated.gif, a nice animation of my sequence of files.  You

can control the timing of the animation by playing with -delay and -loop.



3) TCL/TK Animation (clipped from R-Help)



The tcltk package also has ways of doing this kind of stuff:



 library(tcltk)

 f - function(){plot(rnorm(1000)); tkcmd(after, 1000,f)}

 f()



(To stop, set  f - NULL)





efg

__
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] R graphics

2005-07-21 Thread Earl F. Glynn
Sam Baxter [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 I am trying to set up 16 graphs on one graphics page in R. I have used
 the mfrow=c(4,4) command. However I get a lot of white space between
 each graph. Does anyone know how I can reduce this?

The default par()$mar is c(5,4,4,2) + 0.1 and can be reduced.

For example:
par(mfrow=c(4,4), mar=c(3,3,0,0))

for (i in 1:16)
{
  plot(0:10)
}

efg
--
Earl F. Glynn
Bioinformatics Department
Stowers Institute for Medical Research

__
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


[R] Partek has Dunn-Sidak Multiple Test Correction. Is this the same/similar to any of R's p.adjust.methods?

2005-07-14 Thread Earl F. Glynn
The Partek package (www.partek.com) allows only two selections for Multiple
Test Correction:  Bonferroni and Dunn-Sidak.  Can anyone suggest why Partek
implemented Dunn-Sidak and not the other methods that R has?  Is there any
particular advantage to the Dunn-Sidak method?
R knows about these methods (in R 2.1.1):

 p.adjust.methods
[1] holm hochberg hommel bonferroni BH BY fdr
[8] none

BH is Benjamini  Hochberg (1995) and is also called fdr (I wish R's
documentation said this clearly).  BY is Benjamini  Yekutieli (2001).

I found a few hits from Google on Dunn-Sidak, but I'm curious if anyone can
tell me on a conservative-liberal scale, where the Dunn-Sidak method
falls? My guess is it's less conservative than Bonferroni (but aren't all
the other methods?), but how does it compare to the other methods?

A limited numerical experiment suggested this order to me:  bonferroni (most
conservative), hochberg and holm about the same, BY, BH (also called fdr),
and then none.

Thanks for any of  thoughts on this.

efg

__
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] Using data frames for EDA: Insert, Change name, delete columns? (Newcomer's question)

2005-06-28 Thread Earl F. Glynn
Ben Fairbank [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]

 I ... cannot find commands to easily insert,
 remove (delete), rename, and re-order (arbitrarily, not sort) columns.
...
 Could a reader provide a reference where such commands are
 documented?

There's a lot of info in the old R-Help postings, but searching and finding
an answer for a particular problem can be a bit of a pain.
Here's some info from some old R-Help postings that may help on your
question:

DELETE TWO COLUMNS
---
 I have a dataframe 'd2004' and I want to remove two columns:
'd2004$concentration' and 'd2004$stade.

I could do it just as follows:

 names(d2004)

 [1] Localite   Date   parcelle   maille
presence.plant concentration  stade.culture
 [8] stade  Trou   HorizonProfondeur

 d2004 - d2004[, -c(6, 8)]

but I'd like to use column names (to avoid finding column numbers each
time).

I cannot find an easy way to operate...

I wonder why that works:
 d2004[, concentration]

and this don't:
 d2004 - d2004[, -c(concentration, stade)]



SOLUTIONS:

d2004$concentration - NULL
d2004$stade - NULL

or



Newdata - subset(d2004, select=-c(concentration,stade))







RENAMING COLUMNS
---
This is a sample data frame:

 myData - data.frame( col1 = 1:3, col2 = 2:4, col3 = 3:5 )

 myData

  col1 col2 col3

1123

2234

3345



You can change all names by:

 names( myData )- c( newcol1, newcol2, newcol3 )

 myData

  newcol1 newcol2 newcol3

1   1   2   3

2   2   3   4

3   3   4   5



Or a single name by:

 names( myData )[ 2 ] - newcol2

 myData

  col1 newcol2 col3

11   23

22   34

33   45



Or if you know the name, but not the column number:

 names( myData )[ which( names( myData ) == newcol2 ) ] - verynewcol2

 myData

  col1 verynewcol2 col3

11   23

22   34

33   45



REORDERING COLUMNS
---
I don't have a clipping for this one, but here's what I'd try:

 myData - data.frame( col1 = 1:3, col2 = 2:4, col3 = 3:5 )

 myData
  col1 col2 col3
1123
2234
3345
 MyData - myData[,c(3,1,2)]
 MyData
  col3 col1 col2
1312
2423
3534


--
efg
Earl F. Glynn
Bioinformatics
Stowers Institute for Medical Research

__
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] Preparing timestamped data for fourier analysis

2005-06-14 Thread Earl F. Glynn
Milos Zarkovic [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 I believe that FFT is not appropriate. However Lomb-Scargle periodogram
 could be used.

This may interest you:

(Preprint of  submitted paper)
Detecting periodic patterns in unevenly spaced gene expression time series
using Lomb-Scargle periodograms.
http://research.stowers-institute.org/bioinfo/PDF/m2005_lomb-scargle_submitted.pdf

R code here
http://research.stowers-institute.org/efg/2005/LombScargle/

efg

__
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


[R] p.adjust documentation suggestion: simple statement that new BH method is an alias for old fdr method

2005-06-06 Thread Earl F. Glynn
In R 2.0.1

 p.adjust.methods
[1] holm   hochberg   hommel bonferroni fdrnone

In R 2.1.0

 p.adjust.methods
[1] holm   hochberg   hommel bonferroni BH BY
fdr
[8] none

One  might conclude that two new methods BH and BY were added.  BUT,
there's a clue in one of the comments of the examples for ?p.adjust:

   ## or all of them at once (dropping the fdr alias):
  p.adjust.M - p.adjust.methods[p.adjust.methods != fdr]

Apparently, the old fdr that meant Benjamini  Hochberg now shares an
alias with the new BH, which is Benjamini  Hochberg.

Wouldn't a simple statement in the online documentation be useful that
explained that fdr and BH are aliases?

Is fdr soon to be deprecated and eventually shouldn't be used at all and
that BH is the way of the future?

http://cran.r-project.org/src/base/NEWS mentions p.adjust() has a new
method 'BY' but was silent on the apparently new alias BH.

efg

__
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] Why does summary show number of NAs as non-integer?

2005-06-01 Thread Earl F. Glynn
Berton Gunter [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 summary() is an S3 generic that for your vector dispatches
 summary.default(). The output of summary default has class table and so
 calls print.table (print is another S3 generic). Look at the code of
 print.table() to see how it formats the output.

Marc Schwartz [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 On Tue, 2005-05-31 at 17:14 -0500, Earl F. Glynn wrote:

  Why isn't the number of NA's just 2 instead of the 2.000 shown
above?

 The same number of decimal places is used throughout a vector

I'm talking about how this should be designed.  The current impementation
may be to print a vector using generic logic, but why use generic logic to
produce a wrong solution? Shouldn't correctness be more important than using
a generic solution?

There is special logic to suppress NA's when they don't exist (see below),
so why isn't there special logic to print the count of NAs, which MUST be an
integer, correctly when they do exist?

An integer should NOT be displayed with meaningless decimal places. Why
would this ever be desirable?  The generic solution should be dropped in
favor of a correct solution.

# Why not use special logic to show the number of NA's correctly as an
integer?
 set.seed(19)
 summary( c(NA, runif(10,1,100), NaN) )
   Min. 1st Qu.  MedianMean 3rd Qu.Max.NA's
  7.771  24.850  43.040  43.940  63.540  83.830   2.000

# There is already special logic to suppress NA's
 set.seed(19)
 summary( runif(10,1,100) )
   Min. 1st Qu.  MedianMean 3rd Qu.Max.
  7.771  24.850  43.040  43.940  63.540  83.830

2.000 and 2 do not have equivalent meaning.

efg

__
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


[R] Why does summary show number of NAs as non-integer?

2005-05-31 Thread Earl F. Glynn
Example:

 set.seed(19)
 summary( c(NA, runif(10,1,100), NaN) )
   Min. 1st Qu.  MedianMean 3rd Qu.Max.NA's
  7.771  24.850  43.040  43.940  63.540  83.830   2.000

Why isn't the number of NA's just 2 instead of the 2.000 shown above?

efg

__
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] Round a line

2005-05-27 Thread Earl F. Glynn
Luis Ridao Cruz [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 R-help,

 I have lloked in the archives found no answer to how to round the line
 joint.

 I have usedthe arguments lnd, ljoin in par but I get no differences in
 the plotting.

 x=1:10
 par(ljoin=round,lend=round)
 plot(x,sin(x),type=l,lwd=2)

On my Windows 2000 machine using R 2.1.0, par()$ljoin and par()$lend are
already round by default.  The par()$lmitre parameter is 10,

Paul Murrell's article Fonts, lines, and transparency ... in R News 4/2
(Sept 2004) gives some clues under The end of the line:
http://cran.stat.auckland.ac.nz/doc/Rnews/Rnews_2004-2.pdf



All lines are drawn using a particular style for line ends and joins,
though the difference only becomes obvious when lines become thick.



Is it possible that with par()$lmitre at 10, and a lwd=2, you won't see any
difference?



efg

__
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] colors and palettes and things...

2005-05-24 Thread Earl F. Glynn
Jeff D. Hamann [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 After trying to find if there was a color picker in the FAQs and the help,
 I thought I would send a post here. I was overwhelmed with all the
 wonderful color choices R has predefined (discovered after typing in
 colors()) but can't figure out what they all (by name) look like. Is there
 a color picker or some other method to display all those colors next to
 the name?

Perhaps this PDF with a Chart of R Colors will help:
http://research.stowers-institute.org/efg/R/Color/Chart/ColorChart.pdf

R details are on this page about color and also show how to create the above
PDF:
http://research.stowers-institute.org/efg/R/Color/Chart/index.htm

efg

__
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 plot Contour with NA in dataframe

2005-04-13 Thread Earl F. Glynn
Duncan Murdoch [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 [EMAIL PROTECTED] wrote:

 Your problem isn't the NA values, it's the fact that the contour
 functions want a matrix, and you're passing a data.frame.  If you use
 as.matrix on it, it converts to character mode, presumably because your
 last column is entirely missing (so is read as mode logical, not numeric).

 Use this massaging on it and the plot will work:

   myData - as.matrix(as.data.frame(lapply(myData,as.numeric)))

This looks unnecessarily complicated here, but appears to be necessary.  I
normally would try to use only as.matrix here but this can fail as shown
below, but sometimes can work.

R's rules about this conversion seem somewhat arbitrary to me.  Example 3,
in particular, doesn't make sense to me.  Can anyone share some insight on
what is going on?

==


Dummy.txt

1,2,3

4,5,6



# 1.  Integers, no missing values; as.matrix good enough for conversion

# Results make sense.

 myData - read.table('Dummy.txt',sep=',')

 typeof(myData)

[1] list

 class(myData)

[1] data.frame



 myData - as.matrix(myData)

 myData

  V1 V2 V3

1  1  2  3

2  4  5  6



 typeof(myData)

[1] integer

 class(myData)

[1] matrix



==



Dummy.txt

1,,3

4,2.5,6



# 2.  Doubles, missing values; as.matrix good enough for conversion

# Results make sense.

 myData - read.table('Dummy.txt',sep=',')

 myData - as.matrix(myData)

 myData

  V1  V2 V3

1  1  NA  3

2  4 2.5  6



 typeof(myData)

[1] double

 class(myData)

[1] matrix



==



Dummy.txt

1,,3



# 3.  Drop second row of data from 2 above.  Now instead of integers or
doubles,

# the type is character after using as.matrix?

# Results don't make sense.  Why did dropping the second row of data change

# the type to character here?

 myData - read.table('Dummy.txt',sep=',')

 myData - as.matrix(myData)

 myData

  V1  V2 V3

1 1 NA 3



 typeof(myData)

[1] character

 class(myData)

[1] matrix

==



Dummy.txt

1,,3



# 4.  More complicated solution than 3 above, like what Duncan suggested,

# but this gives expected results

 myData - read.table('Dummy.txt',sep=',')

 myData - as.matrix(as.data.frame(lapply(myData,as.numeric)))

 myData

  V1 V2 V3

1  1 NA  3



 typeof(myData)

[1] double

 class(myData)

[1] matrix



==


Thanks for any help in clarifying this R subtilty.

efg
--
Earl F. Glynn
Scientific Programmer
Stowers Institute for Medical Research

__
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] hex format

2005-04-08 Thread Earl F. Glynn
Thomas Lumley [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Yes, and convertColor in R-devel does quite a few of these (XYZ
 tristimulus space; CIE Lab and Luv; sRGB, Apple RGB and roll-your-own
 RGB based on chromaticities of the primaries; and chromatic adaptation for
 changing the white point).  The colorspace package has a more elegant
 implementation of a somewhat different set of color space computations,
 and R-devel also has hcl() for specifying colors based on hue, chroma, and
 luminance (polar coordinates in Luv space).

Thank you for this info.

I struggle to keep up with what is on CRAN and in Bioconductor, so I haven't
looked at the newer packages in R-devel.  Both convertColor and
colorspace look interesting and I'll definitely investigate them.

I see the latest (first?) version of colorspace was introduced in January
2005 and provides functions hex, hex2RGB, readhex and writehex, and these
functions seem to address my color concerns.  But I was using color
manipulations as an example of a need for more general capapabilities in R
to do these hex conversions when needed, and without a special package.

I recently discovered R's writeBin and readBin functions.  readBin, in
particular, looks like an extremely powerful tool for loading external
files.  This might be an easier way to perform some one-time data
manipulations instead of writing a separate C, Perl or Delphi program to
manipulate data before bringing it into R for analysis.

readBin returns a raw data type that looks like an array of bytes that R
displays in hex. That's where my problem begins and why I joined this hex
format thread.

I'd love to manipulate this raw  hex data, but R makes using these hex bytes
quite difficult to use (or more difficult than I think it should be based on
how easy it is in other languages).  I might want to interpret a byte, or a
string of bytes, as characters.  Or, I might want to interpret pairs of
bytes as 2-byte unsigned (or possibly signed) integers.  Or, I might want to
interpret 3-bytes at a time as RGB values (in either RGB or BGR order). Or,
I might want to interpret 8-bytes at a type as a IEEE754 floating point
number.

Every time someone wants to manipulate this raw data in R, as far as I can
tell now, one must start from scratch and do all sorts of manipulations on
these hex byte values to get characters, or integers, or doubles. And
because it's not that easy (but it's not that hard either, more of an
annoyance), I guess many just go back to C to get that job done there and
then return to R.

Perhaps I've missed some R functions that do this conversion, but if not, I
suggest some new functions that take an array of raw bytes like this, and
return either a single value, or an array of values, under a given
interpretation would be a useful addition to R for working with raw data
(like flow cytometery data -- 
http://www.softflow.com/sf_www/fcap/Fcsformt.htm, or even TIFF files, or
other forms of scientific data).


Examples of  writeBin/readBin:
# Integers
 IntegerSize - 4# How do I get this value from R?

 i - -2:2

 i

[1] -2 -1  0  1  2



 writeBin(i, big.bin, endian=big)

 big - readBin(big.bin, raw, length(i)*IntegerSize)

 big

 [1] ff ff ff fe ff ff ff ff 00 00 00 00 00 00 00 01 00 00 00 02

 typeof(big)
[1] raw


 writeBin(i, little.bin, endian=little)

 little - readBin(little.bin, raw, length(i)*IntegerSize)

 little

 [1] fe ff ff ff ff ff ff ff 00 00 00 00 01 00 00 00 02 00 00 00



#Doubles

 DoubleSize - 8

 x - 10^(-2:2)

 x

[1] 1e-02 1e-01 1e+00 1e+01 1e+02



 writeBin(x, big.bin, endian=big)

 big - readBin(big.bin, raw, length(x)*DoubleSize)

 big

 [1] 3f 84 7a e1 47 ae 14 7b 3f b9 99 99 99 99 99 9a 3f f0 00 00 00 00 00 00
40 24 00 00 00 00 00 00 40 59 00 00 00 00 00 00




 writeBin(x, platform.bin, endian=.Platform$endian)

 platform - readBin(platform.bin, raw, length(x)*DoubleSize)

 platform

 [1] 7b 14 ae 47 e1 7a 84 3f 9a 99 99 99 99 99 b9 3f 00 00 00 00 00 00 f0 3f
00 00 00 00 00 00 24 40 00 00 00 00 00 00 59 40

 y - readBin(platform.bin, double, length(x)*DoubleSize)

 y

[1] 1e-02 1e-01 1e+00 1e+01 1e+02





efg

__
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] hex format

2005-04-07 Thread Earl F. Glynn
Prof Brian Ripley [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 On Thu, 7 Apr 2005, Steve Vejcik wrote:
  Has anyone used hex notation within R to represents integers?

  Short answer: yes.

  as.numeric(0x1AF0)
 [1] 6896

 (which BTW is system-dependent, but one person used it as you asked).

I see this works fine with R 2.0.0 on a Linux platform, but doesn't work at
all under R 2.0.1 on Windows.

 as.numeric(0x1AF0)
[1] NA
Warning message:
NAs introduced by coercion

Seems to me the conversion from hex to decimal should be system independent
(and makes working with colors much more convenient).  Why isn't this system
independent now?

The prefix on hex numbers is somewhat language dependent (0x or $)
perhaps but I didn't think this conversion should be system dependent.

I don't remember where I got this, but this hex2dec works under both Linux
and Windows (and doesn't need the 0x prefix).

hex2dec - function(hexadecimal)
{
  hexdigits - c(0:9, LETTERS[1:6])
  hexadecimal - toupper(hexadecimal)# treat upper/lower case the same
  decimal - rep(0, length(hexadecimal))
  for (i in 1:length(hexadecimal))
  {
digits - match(strsplit(hexadecimal[i],)[[1]], hexdigits) - 1
decimal[i] - sum(digits * 16^((length(digits)-1):0))
  }
  return(decimal)
}

Example:
 hex2dec(c(1AF0, ))
[1]  6896 65535

 can be interpreted as 65535 as unsigned and -1 as signed on the same
system depending on context.  This isn't system dependent, but rather
context dependent.

I suggest as.numeric should perform the unsigned conversion on all
systems.  What am I missing?

efg
--
Earl F. Glynn
Scientific Programmer
Bioinformatics Department
Stowers Institute for Medical Research

__
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] hex format

2005-04-07 Thread Earl F. Glynn
Duncan Murdoch [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
  Seems to me the conversion from hex to decimal should be system
independent
  (and makes working with colors much more convenient).  Why isn't this
system
  independent now?

 Presumably because nobody thought it was important enough to make it so.
   R isn't a low level system programming language, so why should it
 treat hex specially?

1) While generally I'd agree with your statement, manipulating colors is one
place the ability to convert to/from hex would be quite nice.

 rgb(1,0,0.5)
[1] #FF0080

rgb returns a hex string and then R makes manipulating this string somewhat
difficult.  One might want to use such color values to convert to a
different color space, perform some sort of manipulation in that other color
space, and then convert back to rgb.

2) I would think that one of R's mathematical abilities would be to provide
a way to convert from any base to base 10, and from base 10 to any base.  I
haven't found this general math tool yet in R.  Working with base-16 (or
even base 2 sometimes) could be done with such a general math tool.

3) While I may be in a minority, I would even consider exporting IEEE
floating-point numbers in hex form as a way to avoid any additional
conversion losses converting to/from decimal.

4)  Why not make working with raw data a little easier?  readbin shows hex
values but they are not easy to work with inside of R.

 IntegerSize - 4# How do I get this value from R?
 i - -2:2
 i
[1] -2 -1  0  1  2
 length(i)
[1] 5
 object.size(i)
[1] 52

 writeBin(i, big.bin, endian=big)
 big - readBin(big.bin, raw, length(i)*IntegerSize)
 big
 [1] ff ff ff fe ff ff ff ff 00 00 00 00 00 00 00 01 00 00 00 02

 writeBin(i, little.bin, endian=little)
 little - readBin(little.bin, raw, length(i)*IntegerSize)
 little
 [1] fe ff ff ff ff ff ff ff 00 00 00 00 01 00 00 00 02 00 00 00


5) Does R have a hex consistency problem?  The color values start with a #
for hex, but the as.numeric(#FF0080) isn't allowed?


Thanks for your time.

efg

__
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] hex format

2005-04-07 Thread Earl F. Glynn
Thomas Lumley [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 The convertColor function in R 2.1.0 provides colorspace conversion,
 including hex.

 #ff0080 isn't a number, it's a colour (or perhaps a color). If it were
 converted to numeric form it would be a vector of three numbers, and which
 three numbers would depend on the coordinate system used for colour space.

Colo(u)rs and numbers are interchangeable to me.  When you look at a
picture, don't you see numbers?

Maybe you don't see a number here, but I do. #ff0080 is interpreted in some
(non-R) contexts as a single number.  In many contexts, including HTML,
colors are represented as three bytes in hex with this notation and the #
means hexadecimal.  The RGB color componets can be discerned quite easily:
hex FF is decimal 255 (red), hex 00 is decimal 0 (green), hex 80 is decimal
128 (blue).  Some programs, e.g., Dreamweaver, allow specification of colors
in this hex 3-byte form directly.  The 16 million colors you seen on a
true color display are from the 256*256*256 (or in hex FF*FF*FF) possible
RGB triples.

 For example, R already provides both hsv() and rgb() to create colours
 from vectors of three numbers, but the correspondence is different in each
 case.

Sorry if some consider this off topic:
HSV as a color space is really only liked by computer scientists.  Image
processing and color engineers rarely if ever use HSV.

There are MANY other color spaces and computations possible (see color
spaces or color conversions or other color topics on  this page
http://www.efg2.com/Lab/Library/Color/Science.htm).  Most of these color
manipulations in R are not easy because the very first step, converting
colors, I mean numbers g, like #ff0080 to the red, green components is
hindered because one must reinvent the wheel of hex-to-decimal conversion.

Perhaps R will someday introduce a pixel type that would encapsulate the
three color components (for color images at least).  A matrix of pixels
could easily be made into an image.  Some color computations such a Maxwell
Triangle, or a CIE Chromaticity Chart (sorry the links are currently broken,
but the image can be seen on this Chinese translation page)
http://bluemoon.myrice.com/efg/color/chromaticity.htm in R is more difficult
than it should be because of how R is designed now.  Many image processing
statistical problems could be tackled directly in R if there were an easier
way to manipulate pixels and images.

But the hex manipulations I'm advocating could be used for variety of other
purposes.  E.g, I must periodically deal with a binary data stream of flow
cytometery data -- part ASCII, part binary.  Reading this stream directly
from R would be nice and is almost doable.  Working with raw data and
understanding  exactly what you've got would be facilitated by better
conversion capabilities within R.

efg

__
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] 2d plotting and colours

2005-04-06 Thread Earl F. Glynn
Mulholland, Tom [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Since I was only concentrating on colour issues and not on your specific
problem I was just showing the possibilities.

 Does this code help

 n - 5
 par(mfrow = c(2,2))
 palette(default)
 barplot(1:25,col = 1:25)
 palette(rainbow(n))
 barplot(1:25,col = 1:25)
 palette(rgb((0:15)/15, g=0,b=0, names=paste(red,0:15,sep=.)))
 barplot(1:25,col = 1:25)


 require(cluster)
 x - runif(100) * 8 + 2
 cl - kmeans(x, n)
 palette(rainbow(n))
 plot(x, col = cl$cluster)
 abline(h = cl$centers, lty = 2,col = grey )
 palette(palette()[order(cl$centers)])
 points(x,col = cl$cluster,pch = 20,cex = 0.4)

Using Windows with R 2.0.1 this looks fine at first.

But when I resize the graphic, copy the graphic to a metafile and paste it
into Word, or go to an earlier graphic and come back using History, the
colors ae all messed up.  It's as if only the last palette is being used for
all four plots in the figure.  Oddly, if I copy the graphic as a bitmap, the
colors are preseved in the bitmap.  Is this a quirk of my machine or does
this happen for others?

Is it possible that the Windows palette manager is being used (which is such
about obsolete) and that true color graphics are not being used (which is
the easist way to avoid headaches from the Windows palette manager)?

efg

__
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] Multi-plot figures with different numbers of plots indifferent rows

2005-03-29 Thread Earl F. Glynn
Anne York [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]

 par(mfrow=c(2,3)) #set up 2 rows x 3 colums
 plot(1:10) #plot 1
 plot(1:10) #plot 2
 plot(1:10) #plot 3
 par(mfg=c(2,2))  # start next plot at 2,2 instead of 2,1
  plot(1:10)   # 4th plot

If you want to leave the last plot(s) in a such a figure blank,
and continue on with another figure, how does that work?

For example:

par(mfrow=c(2,3)) #set up 2 rows x 3 columns
plot(1:10, main=Plot 1)
plot(1:20, main=Plot 2)
plot(1:30, main=Plot 3)
par(mfg=c(2,2))  # start next plot at 2,2 instead of 2,1
plot(1:40, main=Plot 4)

# What if 5th plot is to start on next page?
# Why do plots 5 and 6 overlay plots 1 and 2 instead
# of being on a new page?
par(mfg=c(1,1))
plot(1:50, main=Plot 5)
plot(1:60, main=Plot 6)

If par(mfg=c(1,1)) is left out, Plot 6 is on the next figure.

The new=T parameters seems like a possible solution, but gives this
warning and is ignored:
 Warning messages:
 1: parameter new couldn't be set in high-level plot() function

par(mfrow=c(2,3)) #set up 2 rows x 3 columns
plot(1:10, main=Plot 1, new=T)
plot(1:20, main=Plot 2)
plot(1:30, main=Plot 3)
par(mfg=c(2,2))  # start next plot at 2,2 instead of 2,1
plot(1:40, main=Plot 4)

# What if 5th plot is to start on next page?
# Why do plots 5 and 6 overlay plots 1 and 2 instead
# of being on a new page?
par(mfg=c(1,1))
plot(1:50, main=Plot 5, new=T)
plot(1:60, main=Plot 6)

How do I create a series of plots in one figure and control
when a new figure is created? (without using dummy blank placeholder plots)

The example above is only for discussion.  I really want to do this in a
loop
and create 5 plots per figure, and repeat this for many pages in a PDF file.

Thanks for any insight on this.

efg
--
Earl F. Glynn
Scientific Programmer
Stowers Institute for Medical Research

__
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] Multi-plot figures with different numbers of plots indifferentrows

2005-03-29 Thread Earl F. Glynn
Paul Murrell [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]...
 Does this do what you want?

 layout(rbind(c(1, 2, 3),
   c(0, 4, 0)))
 plot(1:10, main=Plot 1)
 plot(1:20, main=Plot 2)
 plot(1:30, main=Plot 3)
 plot(1:40, main=Plot 4)
 # new page!
 plot(1:40, main=Plot 5)

Yes, that works nicely.  Thank you very much.

I tried this wrapped with a pdf/dev.off and it works great:

pdf(test.pdf)
  plot statements here
dev.off()

I guess I should always use layout and avoid using mfrow or mfcol, since
it's more flexible in general.

I can't decide if the existing behavio(u)r of mfrow/mfcol is a bug or a
feature when some plots are to be left blank, and one wants to advance to
the next figure.  With your solution, I won't need to care g.  Thanks.

efg

__
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] Logic regression equation in character form?

2005-02-24 Thread Earl F. Glynn
Perhaps I can ask a more focused question:

Earl F. Glynn [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 I want to get some simple logic regression examples to work before
 exploring a hard problem.
..
 logicfit - logreg(resp=Y, bin=X,
type = REGRESSION.TYPE-2,
select = FIT.SINGLE.MODEL-1,
ntrees=1,
nleaves=2,   # force shape of final tree
anneal.control=Annealing)

OK, I have a logic regression equation and just want it in a character form.

For example, I can see this equation from the R command prompt:

 logicfit
score 0.968
 +2.14 * (((not X4) or ((not X13) and X19)) and (not X3)) -1.25 * not
X1) or (not X3)) and ((not X2) or X20)) and (((not X17) and X16) or ((not
X20) and (not X1

But I cannot figure out how to get this equation in character form:

Why does this NOT work?
 typeof(logicfit)
[1] list
 class(logicfit)
[1] logreg
 x - paste(print(logicfit))
score 0.968
 +2.14 * (((not X4) or ((not X13) and X19)) and (not X3)) -1.25 * not
X1) or (not X3)) and ((not X2) or X20)) and (((not X17) and X16) or ((not
X20) and (not X1
 x
character(0)
 cat(x, \n)
 [nothing]


The print makes the following error go away but does not give me the
string displayed on the R console:
 cat(logicfit)
Error in cat(list(...), file, sep, fill, labels, append) :
argument 1 not yet handled by cat


This simpler analogy DOES work:
 x - paste( print(string) )
[1] string
 x
[1] string
 cat(x, \n)
string


Any clues?  Thanks for any help with this.

efg

__
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


[R] Problem saving logic regression result equation to disk file

2005-02-23 Thread Earl F. Glynn
I want to get some simple logic regression examples to work before
exploring a hard problem.

I can get results, but I'm having some problems using cat to save the
logic regression equation to a disk file.

Consider this:

# Simple Logic Regression Example
# efg, 23 Feb 2005

library(LogicReg)

# Create simulated data with known logic equation:

# noise logic matrix
X - matrix(as.numeric(runif(160)  0.5), 20,8)
colnames(X) - paste(X, 1:ncol(X), sep=)
rownames(X) - paste(case, 1:nrow(X), sep=)

# Define expected result:  Y = (NOT X2) AND X6
Y - as.numeric(!X[,2]  X[,6])

# set seed for reproducible test
set.seed(19937)

# 100 interations too few:  some results in single node with |Parameter|  1
Annealing - logreg.anneal.control(start = -1, end = -4, iter = 500, update
= 50)

logicfit - logreg(resp=Y, bin=X,
   type = REGRESSION.TYPE-2,
   select = FIT.SINGLE.MODEL-1,
   ntrees=1,
   nleaves=2,   # force shape of final tree
   anneal.control=Annealing)

# I don't always want to see the plot
plot(logicfit)

# I'd like to write my regression equation to a file and
# then run many times to test my parameter selection
# with a known case before exploring unknown cases

logicfit

# In this case I want either of these equivalent answers
# (equivalent via DeMorgan's Theorem), and no others,
# such as single node results.

I want to run this say 100s (later 1000s) of times and look at the variation
in the results.  I want to figure out what parameters I should use so I only
see these results:

score 0
 +1 * (X6 and (not X2))


 -1 * ((not X6) or X2)


# I can't use cat to write this model to a file:
 cat(logicfit)
Error in cat(list(...), file, sep, fill, labels, append) :
argument 1 not yet handled by cat


 summary(logicfit)
   Length Class   Mode
nsample  1-none-  numeric
nbinary  1-none-  numeric
nseparate1-none-  numeric
type 1-none-  character
select   1-none-  character
anneal.control   5-none-  list
tree.control 4-none-  list
seed 1-none-  numeric
choice   1-none-  numeric
nleaves  1-none-  numeric
ntrees   1-none-  numeric
penalty  1-none-  numeric
response20-none-  numeric
binary 160-none-  numeric
separate 1-none-  numeric
censor  20-none-  numeric
weight  20-none-  numeric
model5logregmodel list
call 8-none-  call

# Just the logicfit$model would be good enough but I can't cat that
either:

 logicfit$model
 +1 * (X6 and (not X2))
 cat(logicfit$model)
Error in cat(list(...), file, sep, fill, labels, append) :
argument 1 not yet handled by cat

Using sink to get this result seems to be a huge kludge:
 sink(saveresults.txt)
 logicfit$model
 sink()
 results - readLines(saveresults.txt)
 results
[1]  +1 * (X6 and (not X2))

# FINALLY something I could write this result to a file:.
 cat(results, \n)
 +1 * (X6 and (not X2))


What is a simple way to get my logic regression equation as a string that I
can cat
without dealing with the internal data structures that are present here?

Thanks for any help with this.

efg
--
Earl F. Glynn
Scientific Programmer
Bioinformatics Department
Stowers Institute for Medical Research

__
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


[R] Windows BMPs: Why grey background? How to display BMP in R?

2005-02-08 Thread Earl F. Glynn
white is supposed to be the default background for BMPs (according to
?bmp) but it doesn't work



 bmp(test.bmp, bg=white)

 plot(0)

 dev.off()

# results in grey background



# This seems to be a good enough workaround for now.

 bmp(test.bmp)

 par(bg=white)

 plot(0)

 dev.off()

# background is white



Should bmps have been fixed when jpegs with a similar grey background were
fixed for Windows?  http://tolstoy.newcastle.edu.au/R/devel/04/10/0914.html

 jpeg(test.jpeg, bg=orangered)
 plot(1:10, 1:10, col=green)
 dev.off()

There was a Windows-specific bug, for which I've just committed a fix



How can I display a bmp directly in R?



When plotting 100,000+ points (common with flow cytometry data) [or even the
10,000s of points with microarray data] the Windows metafile is not the way
to go (nor is postscript) because the files are too large and repainting
them takes too long.  Does  R provide a way to plot to a bmp and then
display that graphic immediately?  It's a pain to leave R just to view the
graphics.



JPGs work fine for real world images, but not that well for drawings.  BMPs
look like the only alternative when plotting a huge number of points so the
file size is reasonable.  (GIFs with drawings would be even better than
BMPs.  I guess I could try PNGs.)



With the GIF/LZW patent issue now in the past, why not have a GIF driver and
even support creation/display of some simple animated GIFs in R?



Earl F. Glynn
Scientific Programmer
Stowers Institute for Medical Research

__
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] Windows BMPs: Why grey background? How to display BMP in R?

2005-02-08 Thread Earl F. Glynn
Duncan Murdoch [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 On Tue, 8 Feb 2005 11:35:22 -0600, Earl F. Glynn
 [EMAIL PROTECTED] wrote :

 In what version of R?  I just tried in 2.01 and R-patched, and it was
 fine.  Maybe the problem is your viewer?

Sorry.

I thought I was using R 2.0.1 but I used a shortcut on my desktop that
started the older R 2.0.0 -- so I just rediscovered the problem that you've
already fixed.  With the correct shortcut to R 2.0.1, I am seeing a white
bmp background.  Sorry to have bothered you with this.

I don't see much information about the bmp driver (from ?bmp).  I noticed
the BMPs that are created have only 8-bit color depth, which means the
palette must be stored with the image.  But what is the palette R uses with
BMPs?  I always use true color (24-bit) bmps in Windows instead of 8-bit
bmps to avoid palette issues on older 256 color displays.

Microsoft recommended only using 240 of the 256 palette entries, since 16
were reserved for system colors for older 256 color display monitors (which
are no longer common) and the Windows palette manager.  I guess R's bmps
only have 240 colors that will work on all PCs.

So are bmps created under R restricted to a single, fixed 256 color palette?
(I don't see any color palette parameter to the bmp device.) Is there any
way to create an R bmp that is hicolor (15 or 16-bit color) or true color
(24-bit color) to avoid the palette issues of 8-bit bmps?

Thanks for any info about this.

efg

__
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 call R in delphi?

2005-01-20 Thread Earl F. Glynn
Dieter Menne [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 To call R from Delphi, you may try
 http://www.menne-biomed.de/download/RDComDelphi.zip.

I downloaded this file and tried to compile the RDCom project using Delphi 5
and Delphi 7 but I get this message from both  compilers:

[Fatal Error] STATCONNECTORCLNTLib_TLB.pas(406): Could not create output
file 'c:\program
files\borland\delphi7\Twain\d5\dcu\STATCONNECTORCLNTLib_TLB.dcu'



The \db\dcu in the path in this error message was a bit curious so I
looked at

Project | Options | Directories/Conditionals



Unit output directory:

$(DELPHI)\Twain\d5\dcu



Search path:

$(DELPHI)\Compon;C:\D2Pr\CascCont\COMPON;$(DELPHI)\Source\Toolsapi



On my vanilla Delphi 5 and Delphi 7 installations all of the directories
for the Unit output directory and Search path are invalid for the RDCom.dpr
project.

If I delete the Unit output directory, I then get 17 compilation errors, all
like this:
[Error] RCom.pas(115): Undeclared identifier: 'VarType'
[Error] RCom.pas(141): Undeclared identifier: 'VarArrayDimCount'
[Error] RCom.pas(123): Undeclared identifier: 'VarArrayHighBound'
. . .

All of the above seems to happen whether or not I install
STATCONNECTORCLNTLib_TLB.pas and STATCONNECTORSRVLib_TLP.pas as components
(i.e., Component | Install Component | browse to .pas file | Open | OK |
Compile).  Am I supposed to do this at some point?

Can you give me any clues how to make this work?  Something seems to be
missing.

   Example program showing use of R from Delphi.
   Connecting to R via COM using Neuwirth's StatConnectorSrvLib
   Uses RCom.pas, which is a simple Delphi wrapper for passing
   commands, integer and double arrays.
   See http://cran.r-project.org/contrib/extra/dcom
   By:  [EMAIL PROTECTED]

I'm not sure I understand this either.  I went to
http://cran.r-project.org/contrib/extra/dcom

I read this documentation:
http://cran.r-project.org/contrib/extra/dcom/RSrv135.html

I downloaded and installed the R(COM) server (and rebooted)
http://cran.r-project.org/contrib/extra/dcom/RSrv135.exe

So, how I can I call R from Delphi using R(COM)?  Something seems to be
missing.

Duncan Murdoch's suggestion about direct calls to R.dll looks interesting,
but a complete working example would be nice.

Thanks for any help with this.

efg
Earl F. Glynn
Scientific Programmer
Stowers Institute for Medical Research

__
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] increase thr range in R

2004-12-13 Thread Earl F. Glynn
IEEE floating point provides a double-extended type often called a long
double.  The exact size of a double-extended can vary but the minimum
specified by the spec is 80 bits.  A PC with the IEEE extended type gives an
approximate range from 3.4E-4932 to 1.1E4932, which would give you the range
you want.  Other architectures, such as a Tru64 alpha, give an even larger
extended.

Reference:  See the IEEE Standard in
What Every Computer Scientist Should Know About Floating-Point Arithmetic
http://docs.sun.com/source/806-3568/ncg_goldberg.html

The note under R's ?numeric help says All real numbers are stored in
double precision format, so R apparently does not yet support the extended
type.

str(.Machine) in R gives a sizeof.longdouble, but I don't know how to use
such a longdouble in native R -- perhaps someone else could enlighten us.  C
or C++ (or other languges) would support the long double type and the
computations you'd like to do.

efg
Earl F. Glynn
Stowers Institute for Medical Research

=
Sebastian Kaiser [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Hello Everybody in order to get some needed results out of my function i
need to get my besselI function evaluated at some values which normally gave
Inf or 0 (expon.scaled NAN) back. So I would like to increase the range in R
from approxamittly 1e+320 to aabout 1e+500 or something like that. Is there
any possibility or pacckage to do this easily?
Thank You
Sebastian Kaiser
Institut for Statistics in Munich Germany

__
[EMAIL PROTECTED] 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] lomb periodogram package

2004-09-15 Thread Earl F. Glynn
 Does anyone know the name of the package that
 includes a function for computing the lomb periodogram on irregular
 spaced ts data? I saw the package once ~ 1 month ago but cannot
 find it now ...

I have a LombScargleLibrary.R file that I will be talking about at CAMDA '04
in November:

Searching for Periodic Microarray Expression Patterns Using Lomb-Scargle
Periodograms
http://research.stowers-institute.org/efg/2004/CAMDA/

I'll get the file online by the time of the conference on Nov 10:
http://www.camda.duke.edu/camda04

I could E-mail you the preliminary version before then if you'd like.  Just
drop me an E-mail.

efg
Earl F. Glynn
Scientific Programmer
Bioinformatics Department
Stowers Institute for Medical Research

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