Re: [R] Transform variable number of rows per subject to column variables?

2005-09-20 Thread Kevin Bartz
Hey Bing,

Reshape's the ticker -- ?reshape.

For example, reshape(myFrame, idvar = "ID", timevar = "TEST.A") should
do most of the trick.

Kevin

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Bing Ho
Sent: Monday, September 19, 2005 10:04 PM
To: r-help@stat.math.ethz.ch
Subject: [R] Transform variable number of rows per subject to column
variables?

Hello,

I am very new to R, but I am having trouble with my dataset.

I have a data frame where a subject has a variable number of multiple 
observations for each row, which I wish the transform these 
observations to column variables.

An example of the data frame
ID  TEST.A  TEST.B
1   10  1
1   13  2
1   11  1
2   15  2
2   17  3

And I wish to transform it to the following:
ID  TEST.A1 TEST.A2 TEST.A3 TEST.B1 TEST.B2 TEST.B3
1   10  13  11  1
2   1
2   15  17  NA  2
3   NA

In other words, for the variable number of repeated follow up 
studies, a new column variable for each subject, but they are grouped 
by the original test.

Thank you for any help - I'm realizing that I am a terrible programmer!

Bing Ho

__
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-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] [handling] Missing [values in randomForest]

2005-09-12 Thread Kevin Bartz
Hi Jan-Paul,

You definitely want to be careful with na.omit in randomForest -- that
wipes out any row with even one NA. If NAs are sprawled throughout your
dataset, na.omit might end up killing a lot of rows. Here's my usual MO
for missing values:

1) "impute" in Hmisc fills in gaps with the mean, median, most common
value, etc.
2) rfImpute: fits a forest on the rows available and uses it to predict
the missing values.
3) aregImpute: similar to rfImpute, but using a linear model.
4) You may want to consider using a single tree ("rpart" package) in
this case instead of a forest. Single trees deal with missing values
cleanly through surrogate splits.

Good luck!

Kevin

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Uwe Ligges
Sent: Sunday, September 11, 2005 3:44 AM
To: Jan-Paul Roodbol
Cc: r-help@stat.math.ethz.ch
Subject: Re: [R] [handling] Missing [values in randomForest]

Jan-Paul Roodbol wrote:

> Does anyone know if randomForest in R can handle
> dataset with missings?

See ?randomForest, you can omit observations including NAs by specifying

na.action=na.omit

Please do not cross-post!
Please specify a sensible subject!

Uwe Ligges


> Thank you
> 
> Kind regards
> 
> Jan-Paul
> 
> __
> 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-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-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] error with scan

2005-07-26 Thread Kevin Bartz
Can you show us the first line of the file?

The error means that in one of the values you specified as numeric (first, 
second, third, fourth, fifth, seventh, eighth, ninth), it found the character 
value it displayed.

Otherwise, this looks like a good use of scan.

Kevin

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jean-Pierre 
Gattuso
Sent: Tuesday, July 26, 2005 11:52 AM
To: r-help@stat.math.ethz.ch
Cc: Jean-Pierre Gattuso
Subject: [R] error with scan

Hi:

I am trying to read a large (50+ lines) with scan() as read.table  
is unable to read it.

I get a strange error (below) which says that 'a real' was expected  
and '5' was read. Can someone help?

Thanks,
jp

 > type=list(a=0,b=0,c=0,d=0,e=0,f="",g=0,h=0,i=0)
 > tmp2 <- scan(file="tmp2.txt", what=type, sep=",", quote="\"",  
dec=".", skip=1, nmax=541502)
Erreur dans scan(file = "tmp2.txt", what = type, sep = ",", quote =  
"\"",  :
 scan() attendait 'a real' et a reçu '5
'

__
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-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] vectorising ifelse()

2005-07-21 Thread Kevin Bartz
The code as you provided it is a bit unusual. In the second assignment,
you're using "drow[i]>0" as an index into "new," but ifelse has already
found that condition to be true, which means what you wrote is just the
same as saying new[1,zappo[i]].

Also, if zappo and zappo are vectors of probabilities, why are they
being used as indices into new? Indices are supposed to be integers or
T/Fs. 

It would be nice if you could provide some example data. I'm sure
there's a way to vectorize it, but I'm struggling to get my head around
the Zippos, zappos and haplos.

Kevin

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Federico Calboli
Sent: Thursday, July 21, 2005 4:44 PM
To: r-help
Subject: [R] vectorising ifelse()

Hi All,

is there any chance of vectorising the two ifelse() statements in the
following code:

for(i in gp){
   new[i,1] = ifelse(srow[i]>0, new[srow[i],zippo[i]], sample(1:100, 1,
prob =Y1, rep = T))
   new[i,2] = ifelse(drow[i]>0, new[drow[i]>0,zappo[i]], sample(1:100,
1, prob =Y1, rep = T))
 }

Where I am forced to check if the value of drow and srow are >0 for each
line... in practical terms, I am attributing haplotypes to a pedigree,
so I have to give the haplotypes to the parents before I give them to
the offspring. The vectors *zippo* and *zappo* are the chances of
getting one or the other hap from the sire and dam respectively. *gp* is
the vectors of non-ancestral animals. *new* is a two col matrix where
the haps are stored.

Cheers,

Federico

-- 
Federico C. F. Calboli
Department of Epidemiology and Public Health
Imperial College, St Mary's Campus
Norfolk Place, London W2 1PG

Tel  +44 (0)20 7594 1602 Fax (+44) 020 7594 3193

f.calboli [.a.t] imperial.ac.uk
f.calboli [.a.t] gmail.com

__
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-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] vectorization

2005-06-17 Thread Kevin Bartz
These two lines worked for me:

rst <- tapply(mydata$income, mydata$education, median)
mydata$md <- rst[mydata$education]

Here's my cheesy example:

> mydata <- data.frame(income= round(rnorm(3, 55000, 1)),
+  education = letters[rbinom(3, 4, 1/2)+1])
> rst <- tapply(mydata$income, mydata$education, median)
> mydata$md <- rst[mydata$education]
> head(mydata)
  income education  md
1  66223 e 55094.5
2  56830 c 54966.0
3  58035 b 54937.5
4  74045 a 55213.5
5  61327 b 54937.5
6  64150 b 54937.5

Is this what you wanted?

Kevin

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Dimitri Joe
Sent: Friday, June 17, 2005 10:01 AM
To: R-Help
Subject: [R] vectorization

Hi there,

I have a data frame (mydata) with 1 numeric variable (income) and 1
factor (education). I want a new column in this data with the median
income for each education level. A obviously inneficient way to do this
is

for ( k in 1: nrow(mydata) ){
l <- mydata$education[k]
mydata$md[k] <- median(mydata$income[mydata$education==l],na.rm=T)
}

Since mydata has nearly 30.000 rows, this will be done not untill the
end of this month. I thus need some help for vectorizing this, please.

Thanks,

Dimitri

[[alternative HTML version deleted]]






___ 

Instale o discador agora! http://br.acesso.yahoo.com/

__
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-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] apply for nested lists

2005-01-26 Thread Kevin Bartz
Actually, what you want is sapply.
sapply(tst.list, "[[", "VAL")
Kevin
Alexandre Sanchez Pla wrote:
Hi,
I am working with lists whose terms are lists whose terms are lists. Although 
the real ones contain locuslink identifiers and GO annotations (I work with the 
Bioconductor GO) package, I have prepared an simplified example of what I have 
and what I would like to do with it:

Imagine I have a list such as:
tst.list<-list("1"=list("1A"=list(ID="1A",VAL=172),"1B"=list
(ID="1B",VAL=134),"1C"=list(ID="1C",VAL=0)),"2"=list("2A"=NA),"3"=list("3A"=list
(ID="3A",VAL=33),"3B"=list(ID="3B",VAL=2)))
I would like, for instance, to be able to extract some values such as the 
content of the "VAL" field, which may sometimes not be available.
I may do it using a nested for such as:

x<-character(0)
for (i in 1:length(tst.list)){
if (!is.na(tst.list[[i]][[1]][[1]])){
for (j in 1:length(tst.list[[i]]))
{x<-c(x,tst.list[[i]][[j]]$VAL)}}
else
{x<-c(x, NA)}}

which gives me what I need

x
[1] "172" "134" "0"   NA  "33"  "2"  

According to most R documents this may be done more efficiently using apply 
instructions, but I have failed in my temptatives to obtain the same

Thanks for any help.
Alex

__
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 save a complete image of the current state of R ?

2004-10-22 Thread Kevin Bartz
Andreas Buness wrote:
Hello,
I like to save the complete state of R, i.e. including
all environments, objects/workspaces, loaded packages etc..
This wish has arisen since I am not able to reproduce
an error which occurs when running R CMD check.
Many thanks for your advice in advance.
Best Regards
Andreas
__
[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

Does save.image meet your needs?
Kevin
__
[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] A question in R

2004-10-12 Thread Kevin Bartz
Yayira har wrote:
I started to learn the R language, but I didn't suceed to use an external file.
 
Let say that I have an excel file called "test1.xls" in the directory 
"C:/program files/R/rw2000/external_files" that looks like that:
 
name  mark
  yair  80
 yosi  70  ...
 
In the appropriate directory I wrote this:
 
x<-read.delim("test1.xls")
 
or this:
 
x<-read.csv("test1.xls")
 
but I got:
 
[1] X..
<0 rows> (or 0-length row.names)
 
way cannot I read the file? what is the appropriate command for reading an excel file?

I looked at the site of R-project but I didn't find a suitable comand.
__

[[alternative HTML version deleted]]
__
[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
Hi Yayiya,
R looks less than fondly on Excel files. The easiest solution for you 
will be to export your Excel file to a tab-delimited text format (Save 
-> (.txt) Tab-delimited Text), and then use read.delim as you did. Does 
that make sense?

Kevin
__
[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] R 2.0.0 is not suffisantly reliable to be used

2004-10-10 Thread Kevin Bartz
Fan wrote:
WHAT CAN I DO FOR YOU, SIR ?
Perhaps you're expecting some sort of congratulations for that new
release ?  I've taken time to download it, test it, and
I've said what I've got to say.
You're helping nobody with that sort of "process of intention".
--
Fan
Liaw, Andy wrote:
From: Fan
After wasting one whole day, I've finally decided to stay with 1.9.1,
some problems have been reported to R-Bugs.
For occasional users, I would say, there's no worst thing than that:
you installed the new release, and soem of your existing codes no
longer work !

Given the attitude that you've taken, I'd guess you do not deserve the
improvements introduced in R-2.0.0.  If you are at all serious about 
having
your code working with R-2.0.0, you would have tested it in the 
alpha/beta
cycle, and try to resolve it before the official release, rather than
ranting about it after the fact.  Most people know better, and will not
appreciate how you denigrate R-core's effort.

Andy
ps: If it's too hard for you to learn to spell, at least learn to use a
spell checker.

--
Fan
__
[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



-- 

Notice:  This e-mail message, together with any attachments, contains 
information of Merck & Co., Inc. (One Merck Drive, Whitehouse Station, 
New Jersey, USA 08889), and/or its affiliates (which may be known 
outside the United States as Merck Frosst, Merck Sharp & Dohme or MSD 
and in Japan, as Banyu) that may be confidential, proprietary 
copyrighted and/or legally privileged. It is intended solely for the 
use of the individual or entity named on this message.  If you are not 
the intended recipient, and have received this message in error, 
please notify us immediately by reply e-mail and then delete it from 
your system.
-- 


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

Hey Fan, sorry to hear that the latest version isn't working for you. 
You know, maybe I can help... what specifically were the problems that 
emerged when you installed the new version? I'd be happy to try to 
diagnose the lines or commands that are now giving you errors. I have a 
vast amount of existing code that ported with very few problems from 
1.9.1 to 2.0.0. I think it would be very informative for everyone--and 
you may get some quality answers--if you posted the lines that once 
worked but now bomb out.

Kevin
__
[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] Reading multiple files into R

2004-10-01 Thread Kevin Bartz
Roger Bivand wrote:
On Fri, 1 Oct 2004, Vikas Rawal wrote:

I want to read data from a number of files into R.
Reading individual files one by one requires writing enormous amount of 
code that will look something like the following.


maptools:::dbf.read("wb-01vc.dbf")->dist1
maptools:::dbf.read("wb-02vc.dbf")->dist2
maptools:::dbf.read("wb-03vc.dbf")->dist3
maptools:::dbf.read("wb-04vc.dbf")->dist4
maptools:::dbf.read("wb-05vc.dbf")->dist5
maptools:::dbf.read("wb-06vc.dbf")->dist6
maptools:::dbf.read("wb-07vc.dbf")->dist7
maptools:::dbf.read("wb-08vc.dbf")->dist8
maptools:::dbf.read("wb-09vc.dbf")->dist9
*

In this case, you could pre-allocate a list and:
res <- vector(mode="list", length=9)
for (i in 1:length(res)) 
res[[i]] <- maptools:::dbf.read(paste("wb-0", i, "vc.dbf", sep=""))


res <- vector(mode="list", length=9)
for (i in 1:length(res)) cat(paste("wb-0", i, "vc.dbf", sep=""), "\n")
wb-01vc.dbf 
wb-02vc.dbf 
wb-03vc.dbf 
...

gives a check on what file names are being used.
For 10 to 99 preserving the 01-09, use paste("wb-", formatC(i, width=2, 
flag="0"), "vc.dbf", sep="").

If the token is a character (string) that varies, you can roll out a 
character vector of tokens first and step along it.


res <- vector(mode="list", length=length(LETTERS))
for (i in 1:length(res)) cat(paste("wb-", LETTERS[i], "vc.dbf", sep=""), 
+ "\n")
wb-Avc.dbf 
wb-Bvc.dbf 
wb-Cvc.dbf 
...


Is there a better way of doing this?
Vikas
__
[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

Good call. Here's a somewhat more R-ified version:
res <- lapply(paste("wb-", formatC(1:99, width=2, flag="0"), "vc.dbf",
sep=""), maptools:::dbf.read)
Kevin
__
[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] pointsize in png graphics

2004-09-30 Thread Kevin Bartz
[EMAIL PROTECTED] wrote:
Dear all,
I'm trying to produce 2 png files, one consisting of an image plot and a
color-table (also an image plot) and the other one consisting of 4 image
plots and a color table. I'd like the color table to be exactly the same.
The way I proceded is the following:
for one plot and the color-table
png(file = png.file, width = 650, height = 800, pointsize = 16)
layout(matrix(c(1, 2), ncol = 2, nrow = 1, byrow = T),
   widths = c(6, 1), heights = 1)
par(mar = c(0.2, 0.2, 0.2, 0.2), mgp = c(2, 1, 0), las = 0)
...
dev.off()
for 4 plots and the color-table
png(file = png.file, width = 650, height = 800, pointsize = 16)
layout(matrix(c(1, 2, 5, 3, 4, 5), ncol = 3, nrow = 2, byrow = T),
   widths = c(3, 3, 1), heights = c(1, 1))
par(mar = c(0.2, 0.2, 0.2, 0.2), mgp = c(2, 1, 0), las = 0)
...
dev.off()
The only difference is the layout of the plot. The outcome though is
completely different. It seems that the definition of the size of one point
is different in the two plots as the graphics with 4 plots and color table
has smaller fonts and smaller margins. What do I have to do to be sure the
size of the fonts is the same in two different png graphcis of exactly the
same size when the pointsize is the same?
I'm working with Windows XP and tried both running the R script as a batch
job and running it within Emacs with ESS.

version
 _
platform i386-pc-mingw32
arch i386
os   mingw32
system   i386, mingw32
status
major1
minor9.1
year 2004
month06
day  21
language R
Many thanks in advance and best regards, Jan:-)
__
[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
Hi Jan,
Generally, I've found it very undesirable to set pointsize when calling 
a graphics device. Instead, I set the cex parameter, either globally 
through "par" or for each individual plot. If you don't tweak the 
defaults, then cex effectively works in picas, so you can divide your 
desired point size by 12 to come up with the right value of cex. Why 
don't you give that a try and let me know how it turns out?

Also, are you sure that you managed to run that code as a batched 
script? png() is one of the graphics devices that doesn't work in batch. 
To get batched pngs, I typically have to use bitmap(type = "png16m", ...).

Kevin
__
[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] multiple match question

2004-09-29 Thread Kevin Bartz
Marc Mamin wrote:
Hello,
 I'm looking for a fast way to retrieve the position of elements  from a vector which 
match element in another vector.
Example
va<-c('a','e')
vb<-c('a','b','c','d','e','f','e')
f(va,vb) should return c(1,5,7)
I have 2 different cases: 

I) my vector vb contains only distinct values
II) my vector vb may contains the same values more than once.
for I) I use following which is fast enough:
as.vector(na.omit(unlist(lapply(va,match,vb
Thanks for any help,
Marc
__
[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
Hi Marc,
How about this?
which(vb %in% va)
Let me know if you have any more questions.
Kevin
__
[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] Re: read dbf files into R

2004-09-28 Thread Kevin Bartz
Vikas Rawal wrote:
Is there a linux-based/free command line tool for converting dbf files 
into txt? Conceptually, it is not a great way of doing things. We have a 
dbf file with a well defined structure. We convert it into a text file, 
which has a loose structure, undefined variables types etc. And then we 
read the text file. I should be much better to directly read a dbf file 
and use its database structure definition to ensure that data come into 
R correctly.

RODBC route does not seem suitable for my needs. I need to read some 300 
files, and combine all the data. Using ODBC would mean that I would have 
to set up 300 DSNs in the odbc.ini.

Or is there a way to set it up from the command line as well? I suppose 
it must be possible to write a script that will suitably modify odbc.ini 
file. But that sounds far too complicated.

I have been a user of SAS for a long time. This exercise would be done 
in a flash there. I wish there was a simple way of doing it in R.

Don't we have a simple command that will read a dbf file, or in fact, a 
set of commands that will read common file formats. I see that we can 
read SAS, STATA and SPSS files. Somebody would have thought of doing the 
same for dbf. Isn't it?

Vikas
Vikas

Vito Ricci wrote:
Hi,
read the manual: R Data Import/Export
http://cran.r-project.org/doc/manuals/R-data.pdf
Another way is to convert .dbf file in .txt and use
read.table(), scan() an similar.
Best
Vito
You wrote:
I run R on redhat linux.
What would be the easiest way to read dbf files into
R?
Vikas
=
Diventare costruttori di soluzioni
"The business of the statistician is to catalyze the scientific 
learning process."  George E. P. Box

Visitate il portale http://www.modugno.it/
e in particolare la sezione su Palese 
http://www.modugno.it/archivio/cat_palese.shtml

   
___
Scopri Mister Yahoo! - il fantatorneo sul calcio di Yahoo! Sport
http://it.seriea.fantasysports.yahoo.com/

 

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

Hi Vikas,
I use dbf.read from the maptools package available on CRAN. The package 
itself is intended to read Arcview shapefiles, but dbf.read can read a 
general dbf and throw it into an R data frame. Because dbf.read's not in 
maptools' namespace, however, you'll have to access it directly; e.g.,

## Non-trivial example: Read ZIP-county mapping file from www.census.gov
> zipnov <- maptools:::dbf.read("/home/kevin/census/zipnov99.DBF")
> head(zipnov)
  ZIP_CODE   LATITUDE   LONGITUDE ZIP_CLASS PONAME STATE COUNTY
100210 +43.005895 -071.013202 U PORTSMOUTH33015
200211 +43.005895 -071.013202 U PORTSMOUTH33015
300212 +43.005895 -071.013202 U PORTSMOUTH33015
400213 +43.005895 -071.013202 U PORTSMOUTH33015
500214 +43.005895 -071.013202 U PORTSMOUTH33015
600215 +43.005895 -071.013202 U PORTSMOUTH33015
From there, you could write it out into a text file:
## Write to csv with usual options set
write.table(zipnov, row.names = F, sep = ",", file = "zipnov.csv")
Let me know if you have any questions.
Kevin
__
[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] do.call("[", ...) question

2004-09-08 Thread Kevin Bartz
This worked very well for me:

do.call("[", c(list(a), jj))

What about you?

Kevin

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Robin Hankin
Sent: Wednesday, September 08, 2004 7:08 AM
To: [EMAIL PROTECTED]
Subject: [R] do.call("[", ...) question

Hi again everyone

I have an arbitrarily dimensional array "a" and a list "jj" of length
length(dim(a)).The elements of jj are vectors of indexes.

How do I use do.call() to extract a[ jj[[1]], jj[[2]], jj[[3]], ...] ?


Toy example follows:

a <- matrix(1:30,5,6)
jj <- list(5:1,6:1)

I want the following

  a[ jj[[1]],jj[[2]] ]

How do I do this?



OBAttempts:

do.call("[",list(a,jj))
do.call("[",c(a,jj))
do.call("[",list(a,unlist(jj)))


Of course, the one that works is

do.call("[",list(a,jj[[1]],jj[[2]]))

but I don't know how long jj is apriori so this won't do.
-- 
Robin Hankin
Uncertainty Analyst
Southampton Oceanography Centre
SO14 3ZH
tel +44(0)23-8059-7743
[EMAIL PROTECTED] (edit in obvious way; spam precaution)

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

__
[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] gridBase and heatmap

2004-09-07 Thread Kevin Bartz
The problem is that most base plotting functions first wipe the graphics
device clean. To do what you want, you need to use par(new = T) liberally
between plots. Does that work for you?

Kevin

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Sean Davis
Sent: Tuesday, September 07, 2004 10:01 AM
To: r-help
Subject: [R] gridBase and heatmap

I would like to use gridBase to place four separate heatmaps (actually,  
a stripped-down heatmap.2 from ght gregmisc package that contains only  
the "image" part) into four different viewports.  I can get the  
placement correct, but I keep 'losing' the previous plot.  Any  
suggestions?

Here is some quick example code trying to put a heatmap into the left  
viewport and then put a second one into the upper right.

Thanks in advance for insight

Sean

 > pushViewport(viewport(layout = grid.layout(1, 3, widths =  
unit(rep(1,3), c("null", "cm", "null")
viewport[GRID.VP.177]
 > pushViewport(viewport(layout.pos.col=1))
viewport[GRID.VP.178]
 > par(omi=gridOMI(),new=T)
 > my.heatmap(eb$coefficients[(clsum[,1]>1) & (clsum[,2]>1) &  
(clsum[,3]==0),],breaks=c(seq(-2.5,-0.6,0.1), 
-0.1,0.10,seq(0.6,2.5,0.1)),dendrogram="none",Colv=c(9:12,5:8,1: 
4),labRow=rep('',520),margin=c(10,5),colsep=c(4,8),trace="none",density. 
info="none",col=greenred.colors(40),key=F)
 > popViewport()
viewport[GRID.VP.177]
 > pushViewport(viewport(layout.pos.col=3))
viewport[GRID.VP.179]
 > pushViewport(viewport(layout = grid.layout(3, 1, heights =  
unit(rep(1,3), c("null", "null", "null")
viewport[GRID.VP.180]
 > pushViewport(viewport(layout.pos.row=1))
viewport[GRID.VP.181]
 > par(omi=gridOMI(),new=T)
 > my.heatmap(eb$coefficients[(clsum[,1]>1) & (clsum[,2]>1) &  
(clsum[,3]==0),][tmp[505:520],],breaks=c(seq(-2.5,-0.6,0.1), 
-0.1,0.10,seq(0.6,2.5,0.1)),dendrogram="none",labRow=sapply(getSYMBOL(as 
.character(rownames(eb$coefficients[(clsum[,1]>1) & (clsum[,2]>1) &  
(clsum[,3]==0),])),'BrafPkg')[tmp[505:520]],function(x)  
{ifelse(is.na(x),"EST",x)}),Colv=c(9:12,5:8,1: 
4),margin=c(10,5),colsep=c(4,8),trace="none",density.info="none",col=gre 
enred.colors(40),key=F)

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

__
[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] using hist() with tapply()

2004-09-01 Thread Kevin Bartz
Hi Paul,

I think lattice's histogram will do what you want, and in a friendlier
manner. Take a look at this example:

require(lattice)
a <- data.frame(draw = as.vector(mapply(rnorm, rep(100, 4), rep(0, 4),
1:4)),
sd   = factor(paste("sd =", rep(1:4, each = 100

Go ahead and examine "a": "draw" contains the aggregate results of random
draws with four different standard deviations, while "sd" tells you which
value of the standard deviation generated the draw. Naturally, I'd want four
histograms as my result. With lattice, I'd do

histogram(~ draw | sd, a)

and get back a sensible result.

Was this what you were looking for?

Kevin

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Schwarz,Paul
Sent: Wednesday, September 01, 2004 11:45 AM
To: [EMAIL PROTECTED]
Subject: [R] using hist() with tapply()

Hi,

I've been passing the hist() function to tapply() to quickly generate
histograms based on the list of factors supplied to tapply().  However, I
have not figured out how to generate titles for each of the histograms,
which paste in the unique values of the list factors as part of the
histogram title.  I'm hoping that someone can tell me how to do this.

Thanks for your time and consideration,

-Paul Schwarz

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

__
[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] Help using Hmisc / Latex

2004-08-25 Thread Kevin Bartz
I'm afraid you need to modify your approach. You're trying to pass latex an
lm object, which latex doesn't know how to handle. Also, latex isn't
supposed to produce a full .tex file; it generates just a "core" that's
loaded into a "shell" when you run dvi.

Here's an example of how you might use it appropriately:

l <- latex(summary(lm(b ~ a, data.frame(a = 1:5, b = 1:5)))$coefficients)
d <- dvi(l)
d

If you want the full .tex file, you can read the console output after
running dvi(l) to find out where the .tex tempfile lives and copy it over to
someplace usable. Obviously, you'll have to tweak the row and column names
as well as the rounding to suit your preferences.

If you're just looking for graphical output--not necessarily a .tex file--I
have a function grid.table, now being rolled into a package I will soon
release, which uses grid to place a data frame (neatly) on the graphics
device. You could then wrap the command around a pdf(), postscript() or any
other device to produce an appropriate display. Let me know if you'd like me
to send over my working version of the binaries.

Kevin

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Joao Pedro W. de
Azevedo
Sent: Wednesday, August 25, 2004 4:02 AM
To: [EMAIL PROTECTED]
Subject: [R] Help using Hmisc / Latex

Dear R users,
I'm trying to automatically generate a *.tex file with the output of an OLS
estimation. Some people suggested to use the latex function on the Hmisc
package. I'm having a bit of trouble to properly specify this function (I'm
not a very experienced R user). Below you will find an example, of what I'm
doing.

## Annette Dobson (1990) "An Introduction to Generalized Linear Models".
## Page 9: Plant Weight Data.
summary(lm.D90 <- lm(weight ~ group - 1))# omitting intercept
out  <- latex(lm.D90)
latex(out, model1, file="")

When I run this code, I get an output which does not attend my needs.

First, I could not figure out how to print the variable names. Second I'm
not sure how I can select only the coefficients and the std. errors to be
inserted on the output. Third, I was wondering if there is any way I can
automatically generate significance level indicators next to either the
coefficients or the std erros. Forth, is there any way I can aumtomaticaly
insert some of model fitting statistics? Fifth, is it possible to specify
this function to save the std. error under the coefficient?

I'm sure this are quite basic questions, but my attempts to fiddle with the
parameters in the model took me nowhere. 

Many thanks once again,

Joao Pedro

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

__
[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] levels of factor

2004-08-17 Thread Kevin Bartz
Believe it or not, that's a feature, not a bug. The idea is that the factor
COULD take on those levels, even if it doesn't in your particular subset. To
drop them, you would have to re-initialize the factor as such:

a$column2 <- factor(a$column2)

Or, you could just download the Hmisc package, which redefines the subset
operator "[" to behave as you'd like. Personally, I think the default
behavior is clearer, however.

By the way, there are some problems with your code. First of all, you should
drop the quotes around column2--they're unnecessary. Secondly, your subset
is redundant: only one of your factor levels can be numbered 1, so only one
of the levels "factor1" and "factor2" is getting included in the result
(whichever is numbered 1 -- I'm guessing it's "factor1"). Was this your
intention?

Kevin

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Luis Rideau Cruz
Sent: Tuesday, August 17, 2004 7:30 AM
To: [EMAIL PROTECTED]
Subject: [R] levels of factor

R-help,

I have a data frame wich I subset like :

a <- subset(df,df$"column2" %in% c("factor1","factor2")  & df$"column2"==1)

But when I type levels(a$"column2") I still get the same levels as in df (my
original data frame)

Why is that?
Is it right?

Luis

Luis Ridao Cruz
Fiskirannsóknarstovan
Nóatún 1
P.O. Box 3051
FR-110 Tórshavn
Faroe Islands
Phone: +298 353900
Phone(direct): +298 353912
Mobile: +298 580800
Fax: +298 353901
E-mail:  [EMAIL PROTECTED]
Web:www.frs.fo

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

__
[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] extract a row

2004-08-16 Thread Kevin Bartz
The easiest way to do that is

subset(dataframe, rate == "slow").

Please let me know if you have any more questions.

Kevin

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Randy Zelick
Sent: Monday, August 16, 2004 10:49 AM
To: R list server posting
Subject: [R] extract a row

Hello there,

Using 1.9.0 on WinXP...

I have a data frame, one column of which is named "rate". The column has
text entries like "fast", "medium", "slow", "very slow", and so forth. I
have not tried to make them factors, but maybe R did this automatically.

Anyway, I would like to display on the console rows that meet a rate
criterion.

So I want to type something like:

dataframe[rate=="slow"]

and get back this sort of output:

test  subject  trial  rate  score

 34B27  3 slow   27
 55B55  4 slow   34

where test, subject, trial, rate, and score are all the
dataframe's columns.

How do I do that??

Thanks,

=Randy=


R. Zelick   email: [EMAIL PROTECTED]
Department of Biology   voice: 503-725-3086
Portland State University   fax:   503-725-3888

mailing:
P.O. Box 751
Portland, OR 97207

shipping:
1719 SW 10th Ave, Room 246
Portland, OR 97201

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

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


[R] DESCRIPTION.in

2004-07-27 Thread Kevin Bartz
Hello R world! I'm building a bundle of four packages, but I don't always
want to build the whole bundle. Usually I just want to tweak one function in
one of the packages and rebuild just that package. As such, I have
DESCRIPTION and DESCRIPTION.in files sitting in all the package folders.
Unfortunately, there's a pesky line in R CMD build that hacks away
DESCRIPTION whenever it sees DESCRIPTION.in. This is okay for building the
whole bundle, but it makes it a major pain to build any of the packages
individually. I am root, so for now I have commented the offending line in
/usr/local/lib/R/bin/build. Is this the proper solution or am I overlooking
something? Thanks for any help you can provide,

Kevin

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


RE: [R] row naming

2004-07-15 Thread Kevin Bartz
The rownames of a data.frame are there for reference; they are not
considered a column in your data set and will not be included in any
analyses. The short answer as to whether you should try to remove them is
no. To read in the file, use read.table(file, header=F), as you probably
already discovered.

Kevin

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Herman, David
(NIH/NIMH)
Sent: Thursday, July 15, 2004 11:35 AM
To: '[EMAIL PROTECTED]'
Subject: [R] row naming

Hello,
If I have a four column data set (with thousands of rows), that
doesn't have a header, how do I load in this text file, WITHOUT a row added
for naming(i.e. numbering the rows, 1 2 3 4 5..).
Also, if a row is added for naming, then will it be actually included in the
data? That is, will that numbered row be included in analysis I run? (like
PCA)
 
 
Thanks!
 

[[alternative HTML version deleted]]

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

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


RE: [R] GHK simulator

2004-07-15 Thread Kevin Bartz
Yes. See the mvtnorm package on CRAN. It implements Genz's algorithm, the
fastest method in town. (I have a version I converted to S-PLUS as well, if
you, or anyone, might need it.)

Kevin

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Trenkler, Dietrich
Sent: Thursday, July 15, 2004 8:00 AM
To: 'r-help'
Subject: [R] GHK simulator

Dear R-community,

not to re-invent the wheel I wonder if someone of you
has ever written a function to compute the GHK smooth recursive
simulator to estimate multivariate normal probabilities. See for instance
page 194 of

@BOOK{Greene97,
  author = {William H. Greene},
  year = 1997,
  title = {Econometric Analysis},
  edition = {3rd},
  publisher = {Prentice-Hall},
  address = {New Jersey 07458}
}


Thank you.   

Dietrich Trenkler

--
Dietrich Trenkler   Universität Osnabrück  
FB Wirtschaftswissenschaften   
Rolandstr.8  D-49069 Osnabrück

[EMAIL PROTECTED]

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

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


[R] RODBC repeated rows problem

2004-07-14 Thread Kevin Bartz
Hello everyone! I'm having the dreaded repeated rows problem in RODBC.
Specifically, when I have a NULL value in a column, odbcFetchRows reads the
value not as NULL or NA but as the most recent non-NULL value in the column.
If there is no such non-NULL column, odbcFetchRows reads the value as 0. Let
me give you an example (though you won't be able to run it with the
"product" table--just use some table you've defined):

> head(sqlQuery(channel, "select NULL from product"))
  c("0", "0", "0", "0", "0", "0")
1   0
2   0
3   0
4   0
5   0
6   0

Obviously, I'd like to see NAs here, not 0s. Let me give you some of my
specs:

> version
 _   
platform x86_64-unknown-linux-gnu
arch x86_64  
os   linux-gnu   
system   x86_64, linux-gnu   
status   
major1   
minor9.1 
year 2004
month06  
day  21  
language R   

Other specs: I'm reading a unixODBC ODBC driver. When I run from isql and
try the same query, I get, as I might expect, a bunch of blanks.

SQL> select top 5 NULL from product
++
||
++
||
||
||
||
||
++
SQLRowCount returns 5
5 rows fetched

It shouldn't be relevant, but the ODBC is powered by a FreeTDS driver hooked
to an MS SQL Server 2000 Professional.

I noticed a previous note from Professor Ripley reporting that this problem
had been fixed with a version of RODBC from long ago. I am running RODBC
version 1.04, the latest version, however, so I'm at a loss as to what to
do.

One last note: I looked at the relevant line from sql.h that defines my
SQL_NULL_DATA, which RODBC (presumably) compares to its results. It says:

#define SQL_NULL_DATA (-1)

Unfortunately, I have no idea what this should mean to me :(

Are there any further diagnostics I can run? Any new versions of software I
should install? Any workarounds for the time being?

Thanks for any help you can provide.

Kevin

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


[R] Visualizing Marketing Campaigns With R

2004-07-07 Thread Kevin Bartz
Warning: This is a bit off-topic.

Using R, I'm trying to develop a way of visualizing a marketing campaign
that is divided into lists, each with a mailing and control group. Within a
mailing group, we have respondents and sales conversions (think "successes")
and the overlap between the two. We also have conversions among those
subjects in the list's control group, who were withheld the mailing. There
are several lists to a campaign, with varied numbers of subjects in the
mailing and control groups.

I want some way of illustrating this information visually, a display that
communicates:

1) The relative sizes of each list's mailing and control groups
2) The lists' relative importance to the overall campaign
3) The effect each list's mailing has on proportion of conversions to sales
4) The volume of the overlap relative to the number of respondents and
number of conversions
5) Confidence intervals about all of these figures

I've taken a stab at developing my own type of display using R and grid,
which you can see, along with comments and the raw data set, at
http://r.loyaltymatrix.com. Unfortunately, my display feels clunky and
nonintuitive. Any suggestions? Please feel free to comment or to share any
ideas, either through e-mail or the commenting feature in the blog or on
this list.

As a subtext, I've looked into rmeta, which has a funnelplot function and a
plot for the Mantel-Haenszel test, meta.MH. Neither is quite what I want.
The funnel plot tells me nothing about the relative sizes of the mailing and
control groups; I would like to be able to see it when a control group is
tiny. By the same token, it shows no confidence intervals, which are
important if the control groups are too small to make any real statement.
plot.meta.MH shows the intervals, but doesn't offer any information about
the size of the lists and their relative importance in the campaign.
Additionally, neither utilizes the information I have available about
respondents (as opposed to conversions) and their overlap with converted
customers.

Sorry to bother everyone with a somewhat off-topic note, but it is my hope
that someone may have dealt with this question previously and may have some
wisdom to share. Thanks for any help you can provide,

Kevin

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


RE: [R] Seg. faults in mapthin (in package maps!)

2004-07-01 Thread Kevin Bartz
Dr. Ripley, you are the master. That fix worked like a charm! All the way to
50, with no problems. Thanks again,

Kevin

-Original Message-
From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] 
Sent: Thursday, July 01, 2004 10:07 AM
To: Kevin Bartz
Cc: [EMAIL PROTECTED]
Subject: Re: [R] Seg. faults in mapthin (in package maps!)

You are on a 64-bit architecture and the C interface is declared as

void mapthin(x, y, n, delta, symmetric)
 double *x, *y, *delta;
 long *n, *symmetric;

R's integer type is int, not long, but they are the same on a 32-bit 
platform.

I am pretty sure that changing long to int will fix this.

There are a few other quirks, and I would check some of the other uses of 
`long' in the C sources.

On Thu, 1 Jul 2004, Kevin Bartz wrote:

> Hi everyone! I know segmentation faults are awfully hard to diagnose, but
> I'm experiencing a fairly regular pattern of seg. faults when plotting
using
> map in the maps package. Starting R fresh, I run:
> 
> require(maps)
> for (i in 1:50) {
>   cat(i, "\n")
>   map("state")
> }
> 
> I always get the same result:
> 
> 1 
> 2 
> 3 
> 4 
> 5 
> 
> Process R segmentation fault at Thu Jul  1 09:07:39 2004
> 
> With some browsering, I've zeroed in on the source of the segmentation
> fault: map's call to mapthin. Funny thing is, when I comment out the call
to
> mapthin, everything works consistently, without a hitch, and with no
> apparent difference in the map.
> 
> Still, I'd rather work with the package the way it was built. I must be
> losing something by cutting out the call to mapthin. 
> 
> I was wondering if anyone has any ideas. I've never had a segmentation
fault
> before on this particular machine, but these few lines always produce the
> same unfortunate result. Has anyone else experienced segmentation faults
> plotting using map in the maps package? Is there any way I might rectify
it?
> I'm on SuSE Linux, by the way, with:
> 
> > version
>  _   
> platform x86_64-unknown-linux-gnu
> arch x86_64  
> os   linux-gnu   
> system   x86_64, linux-gnu   
> status   alpha   
> major1   
> minor9.1 
> year 2004
> month06  
> day  13  
> language R   
> 
> Thanks for any help you can provide,
> 
> Kevin
> 
> __
> [EMAIL PROTECTED] mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html
> 
> 

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

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


[R] Seg. faults in mapthin

2004-07-01 Thread Kevin Bartz
Hi everyone! I know segmentation faults are awfully hard to diagnose, but
I'm experiencing a fairly regular pattern of seg. faults when plotting using
map in the maps package. Starting R fresh, I run:

require(maps)
for (i in 1:50) {
  cat(i, "\n")
  map("state")
}

I always get the same result:

1 
2 
3 
4 
5 

Process R segmentation fault at Thu Jul  1 09:07:39 2004

With some browsering, I've zeroed in on the source of the segmentation
fault: map's call to mapthin. Funny thing is, when I comment out the call to
mapthin, everything works consistently, without a hitch, and with no
apparent difference in the map.

Still, I'd rather work with the package the way it was built. I must be
losing something by cutting out the call to mapthin. 

I was wondering if anyone has any ideas. I've never had a segmentation fault
before on this particular machine, but these few lines always produce the
same unfortunate result. Has anyone else experienced segmentation faults
plotting using map in the maps package? Is there any way I might rectify it?
I'm on SuSE Linux, by the way, with:

> version
 _   
platform x86_64-unknown-linux-gnu
arch x86_64  
os   linux-gnu   
system   x86_64, linux-gnu   
status   alpha   
major1   
minor9.1 
year 2004
month06  
day  13  
language R   

Thanks for any help you can provide,

Kevin

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


RE: [R] abline and its objects

2004-06-29 Thread Kevin Bartz
The problem is that you've instructed R to place lines at the values 91.55,
99.39, 97.04, 92.37 and 88.02, but these values do not correspond to the
user coordinates of the x-axis (which you've specified to be dates).

Luckily, the dates where you need lines are in the rownames of zi. You do
need to convert them to your user coordinates--and that depends on how plot
decides to specify your user coordinates, which hinges on the range of your
full data set (you clipped it).

What's on your x-axis? Do par("usr") when you have one of the plots open and
tell me what R says.

Kevin

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Laura Holt
Sent: Tuesday, June 29, 2004 2:06 PM
To: [EMAIL PROTECTED]
Subject: [R] abline and its objects

Hi R People:

Is there a way to put an abline line for its objects on a plot, please?

I have an its object, ibm2, which runs from the January 2 through May 28.

>ibm2
  ibm
2004-01-02  91.55
2004-01-05  93.05
2004-01-06  93.06
2004-01-07  92.78
2004-01-08  93.04
2004-01-09  91.21
2004-01-12  91.55
2004-01-13  89.70
2004-01-14  90.31
2004-01-15  94.02
.
.
.
I plot the data.  No Problem.
Now I extract the first day of the month in this fashion.
>zi <- extractIts(ibm2,weekday=T,find="first",period="month")
>zi
 ibm
2004-01-02 91.55
2004-02-02 99.39
2004-03-01 97.04
2004-04-01 92.37
2004-05-03 88.02
>

Still ok.
I would like to put a vertical line at each of the zi values.

>abline(v=zi,type="h",col=2)
>lines(zi,type="h",col=2)
>
Nothing happens.

I tried creating another its object with NA in all but the zi places.  Then 
I used lines(test1)

Still nothing happened.

Any suggestions would be much appreciated.
R Version 1.9.1
Sincerely,
Laura H
mailto: [EMAIL PROTECTED]


Married. http://lifeevents.msn.com/category.aspx?cid=married

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

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


RE: [R] removing NA from an its object

2004-06-29 Thread kevin bartz
What did you try with "apply"? It seems to work for me. I did

x2[!apply(is.na(x2), 1, any),]

and got the desired results.

Kevin

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Laura Holt
Sent: Tuesday, June 29, 2004 9:26 AM
To: [EMAIL PROTECTED]
Subject: [R] removing NA from an its object

Hi again!

I have the following its object:
>class(x1)
[1] "its"
attr(,"package")
[1] "its"
>x1
 FTSE DAX
2004-06-07 4491.6 4017.81
2004-06-08 4504.8 4018.95
2004-06-09 4489.5 3997.76
2004-06-10 4486.1 4021.64
2004-06-11 4484.0 4014.56
2004-06-14 4433.2 3948.65
2004-06-15 4458.6 3987.30
2004-06-16 4491.1 4003.24
2004-06-17 4493.3 3985.46
2004-06-18 4505.8 3999.79
2004-06-21 4502.2 3989.31
2004-06-22 NA 3928.39
2004-06-23 NA 3945.10
2004-06-24 NA 4007.05
2004-06-25 NA 4013.35
2004-06-28 NA 4069.35

I want to create an its object with no NAs; that is, if there is an NA in 
any column, strike the entire row.


I did the following:
>x2 <- its(na.omit(x1))
>x2
 FTSE DAX
2004-06-07 4491.6 4017.81
2004-06-08 4504.8 4018.95
2004-06-09 4489.5 3997.76
2004-06-10 4486.1 4021.64
2004-06-11 4484.0 4014.56
2004-06-14 4433.2 3948.65
2004-06-15 4458.6 3987.30
2004-06-16 4491.1 4003.24
2004-06-17 4493.3 3985.46
2004-06-18 4505.8 3999.79
2004-06-21 4502.2 3989.31
attr(,"na.action")
2004-06-22 2004-06-23 2004-06-24 2004-06-25 2004-06-28
12 13 14 15 16
attr(,"class")
[1] "omit"
>class(x2) <- "its"
>

My question:  is this the best way to accomplish the goal, please?  I tried 
apply with "all" and is.na but I got strange results.

Thanks.
R Version 1.9.1
Sincerely,
Laura
mailto: [EMAIL PROTECTED]


Married. http://lifeevents.msn.com/category.aspx?cid=married

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

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


[R] text length in grid

2004-06-28 Thread kevin bartz
Hello! I first would like to compliment the authors of grid on what has been
a wonderfully useful package for me. Now, my question: Is there any way I
can specify the size of some grid.text using grid units?

I must label the regions of a plot. The regions can be either very small or
very large, so I would like to label each by fitting its text to the size of
the region in question. Ideally, I could have nice, big text labeling the
big regions and tiny type in the small regions.

Let me try to illustrate my scenario. Imagine that my plot looks like this:

pushViewport(viewport(layout = grid.layout(5, 2, c(9,1), 1:5)))
for (i in 1:5) {
  pushViewport(viewport(layout.pos.row = i, layout.pos.col = 1))
  pushViewport(viewport(x = 0, width = i/5, height = .8, just = "left"))
  grid.rect(gp = gpar(fill = rainbow(5)[i]))
  grid.yaxis(main = F)
  grid.text("I am some descriptive text.")
  popViewport()
  popViewport()
}

Unfortunately, the descriptive text overlaps with the axis for the red
rectangle! Is there any way, given the dimensions of some region on the grid
and the desired text, that I can fit this text to the region?

Sorry if I missed something in the documentation. I really did look at
?grid.text, all the documentation for the grid package, all the PDFs posted
on the grid page as well as previous r-help postings, but none seemed to
address this question. Thanks so much for any help you can provide!

Kevin

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


RE: [R] question about latex command in Hmisc

2004-06-21 Thread kevin bartz
When you do "latex" from the command line (Run -> cmd), what does DOS say?
Maybe latex isn't in your PATH.

Kevin

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Laura Holt
Sent: Monday, June 21, 2004 9:59 AM
To: [EMAIL PROTECTED]
Subject: [R] question about latex command in Hmisc

Hi R People:

I got the following error from using the "latex" command from Hmisc;

>latex(bbm)
'latex' is not recognized as an internal or external command,
operable program or batch file.
Warning message:
cmd execution failed with error code 1 in: shell(cmd, wait = TRUE, intern = 
output)
>

I was printing a matrix to a Latex File.  This worked fine in Version 1.8.
This is from Version 1.9.0 for Windows.

Any suggestions would be much appreciated.

Thanks in advance!
Sincerely,
Laura
mailto: [EMAIL PROTECTED]

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

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


RE: [R] Readline on R-1.9.1a

2004-06-14 Thread Kevin Bartz
Hi Peter! Thanks so much for your help. Installing ncurses and ncurses-devel
did the trick for me, and now readline's working fine in R. Now how did you
manage to notice that?

Kevin

-Original Message-
From: Peter Dalgaard [mailto:[EMAIL PROTECTED] 
Sent: Monday, June 14, 2004 1:20 PM
To: Liaw, Andy
Cc: 'Roger D. Peng'; 'Peter Dalgaard'; Kevin Bartz; [EMAIL PROTECTED]
Subject: Re: [R] Readline on R-1.9.1a

"Liaw, Andy" <[EMAIL PROTECTED]> writes:

> > From: Roger D. Peng 
> > 
> > People who compile from source still need to install the 
> > necessary rpms.
> 
> Sure, but apparently one can install the R rpm without those, and that's
the
> real problem.

(Wasn't Kevin's though. But there's really no way of helping people
who build from source, beyond what they get from configure. Well, you
could refer them to read the spec files...)

You can actually *build* the R rpm on SuSE without a lot of stuff...
Detlef has put absolutely no dependency information in the spec file.

-- 
   O__   Peter Dalgaard Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics 2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark  Ph: (+45) 35327918
~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907

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


[R] Readline on R-1.9.1a

2004-06-14 Thread Kevin Bartz
Hello! I'm trying to install R-1.9.1a with readline on Suse Linux. As
recommended in other posts, I've installed readline and readline-devel:

 

[EMAIL PROTECTED]:~/R-1.9.1> rpm -qa | grep readline

readline-devel-32bit-9.0-0

readline-32bit-9.0-0

readline-4.3-207

readline-devel-4.3-207

 

Then I run configure with readline:

 

./configure --with-readline

 

The relevant lines are:

 

[EMAIL PROTECTED]:~/R-1.9.1> ./configure --with-readline | grep readline

checking for rl_callback_read_char in -lreadline... no

checking readline/history.h usability... yes

checking readline/history.h presence... yes

checking for readline/history.h... yes

checking readline/readline.h usability... yes

checking readline/readline.h presence... yes

checking for readline/readline.h... yes

 

In config.log all readline tests pass except this one:

 

configure:21277: checking for rl_callback_read_char in -lreadline

configure:21307: gcc -o conftest -g -O2 -I/usr/local/include
-L/usr/local/lib conftest.c \

-lreadline  -ldl -lm  >&5

/usr/local/lib/libreadline.so: undefined reference to `tgetnum'

/usr/local/lib/libreadline.so: undefined reference to `tgoto'

/usr/local/lib/libreadline.so: undefined reference to `tgetflag'

/usr/local/lib/libreadline.so: undefined reference to `BC'

/usr/local/lib/libreadline.so: undefined reference to `tputs'

/usr/local/lib/libreadline.so: undefined reference to `PC'

/usr/local/lib/libreadline.so: undefined reference to `tgetent'

/usr/local/lib/libreadline.so: undefined reference to `UP'

/usr/local/lib/libreadline.so: undefined reference to `tgetstr'

collect2: ld returned 1 exit status

configure:21313: $? = 1

configure: failed program was:

| /* confdefs.h.  */

|

| #define PACKAGE_NAME "R"

| #define PACKAGE_TARNAME "R"

| #define PACKAGE_VERSION "1.9.1"

| #define PACKAGE_STRING "R 1.9.1"

| #define PACKAGE_BUGREPORT "[EMAIL PROTECTED]"

| #define PACKAGE "R"

| #define VERSION "1.9.1"

| #define R_PLATFORM "x86_64-unknown-linux-gnu"

| #define R_CPU "x86_64"

| #define R_VENDOR "unknown"

| #define R_OS "linux-gnu"

| #define Unix 1

| #ifdef __cplusplus

| extern "C" void std::exit (int) throw (); using std::exit;

| #endif

| #define STDC_HEADERS 1

| #define HAVE_SYS_TYPES_H 1

| #define HAVE_SYS_STAT_H 1

| #define HAVE_STDLIB_H 1

| #define HAVE_STRING_H 1

| #define HAVE_MEMORY_H 1

| #define HAVE_STRINGS_H 1

| #define HAVE_INTTYPES_H 1

| #define HAVE_STDINT_H 1

| #define HAVE_UNISTD_H 1

| #define HAVE_DLFCN_H 1

| #define HAVE_LIBM 1

| #define HAVE_LIBDL 1

| /* end confdefs.h.  */

|

| /* Override any gcc2 internal prototype to avoid an error.  */

| #ifdef __cplusplus

| extern "C"

| #endif

| /* We use char because int might match the return type of a gcc2

|builtin and then its argument prototype would still apply.  */

| char rl_callback_read_char ();

| int

| main ()

| {

| rl_callback_read_char ();

|   ;

|   return 0;

| }

configure:21338: result: no

 

Any ideas? Thanks for any help you can provide.

 

Kevin Bartz

  


[[alternative HTML version deleted]]

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